Compare commits
1 Commits
__refs_pul
...
__refs_pul
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17a9b0178d |
@@ -104,8 +104,7 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
|
||||
return vfs->OpenFile(path, FileSys::Mode::Read);
|
||||
}
|
||||
struct System::Impl {
|
||||
explicit Impl(System& system)
|
||||
: kernel{system}, cpu_core_manager{system}, applet_manager{system}, reporter{system} {}
|
||||
explicit Impl(System& system) : kernel{system}, cpu_core_manager{system}, reporter{system} {}
|
||||
|
||||
Cpu& CurrentCpuCore() {
|
||||
return cpu_core_manager.GetCurrentCore();
|
||||
|
||||
@@ -296,6 +296,12 @@ ResultVal<VAddr> VMManager::SetHeapSize(u64 size) {
|
||||
}
|
||||
|
||||
ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
const auto end_addr = target + size;
|
||||
const auto last_addr = end_addr - 1;
|
||||
VAddr cur_addr = target;
|
||||
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
||||
// Check how much memory we've already mapped.
|
||||
const auto mapped_size_result = SizeOfAllocatedVMAsInRange(target, size);
|
||||
if (mapped_size_result.Failed()) {
|
||||
@@ -318,16 +324,13 @@ ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
|
||||
// Keep track of the memory regions we unmap.
|
||||
std::vector<std::pair<u64, u64>> mapped_regions;
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
||||
// Iterate, trying to map memory.
|
||||
{
|
||||
const auto end_addr = target + size;
|
||||
const auto last_addr = end_addr - 1;
|
||||
VAddr cur_addr = target;
|
||||
cur_addr = target;
|
||||
|
||||
auto iter = FindVMA(target);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "MapPhysicalMemory iter != end");
|
||||
|
||||
while (true) {
|
||||
const auto& vma = iter->second;
|
||||
@@ -339,7 +342,7 @@ ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
const auto map_size = std::min(end_addr - cur_addr, vma_end - cur_addr);
|
||||
if (vma.state == MemoryState::Unmapped) {
|
||||
const auto map_res =
|
||||
MapMemoryBlock(cur_addr, std::make_shared<PhysicalMemory>(map_size), 0,
|
||||
MapMemoryBlock(cur_addr, std::make_shared<PhysicalMemory>(map_size, 0), 0,
|
||||
map_size, MemoryState::Heap, VMAPermission::ReadWrite);
|
||||
result = map_res.Code();
|
||||
if (result.IsError()) {
|
||||
@@ -357,7 +360,7 @@ ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
// Advance to the next block.
|
||||
cur_addr = vma_end;
|
||||
iter = FindVMA(cur_addr);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "MapPhysicalMemory iter != end");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,7 +368,7 @@ ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
if (result.IsError()) {
|
||||
for (const auto [unmap_address, unmap_size] : mapped_regions) {
|
||||
ASSERT_MSG(UnmapRange(unmap_address, unmap_size).IsSuccess(),
|
||||
"Failed to unmap memory range.");
|
||||
"MapPhysicalMemory un-map on error");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -378,6 +381,12 @@ ResultCode VMManager::MapPhysicalMemory(VAddr target, u64 size) {
|
||||
}
|
||||
|
||||
ResultCode VMManager::UnmapPhysicalMemory(VAddr target, u64 size) {
|
||||
const auto end_addr = target + size;
|
||||
const auto last_addr = end_addr - 1;
|
||||
VAddr cur_addr = target;
|
||||
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
||||
// Check how much memory is currently mapped.
|
||||
const auto mapped_size_result = SizeOfUnmappablePhysicalMemoryInRange(target, size);
|
||||
if (mapped_size_result.Failed()) {
|
||||
@@ -392,16 +401,13 @@ ResultCode VMManager::UnmapPhysicalMemory(VAddr target, u64 size) {
|
||||
|
||||
// Keep track of the memory regions we unmap.
|
||||
std::vector<std::pair<u64, u64>> unmapped_regions;
|
||||
ResultCode result = RESULT_SUCCESS;
|
||||
|
||||
// Try to unmap regions.
|
||||
{
|
||||
const auto end_addr = target + size;
|
||||
const auto last_addr = end_addr - 1;
|
||||
VAddr cur_addr = target;
|
||||
cur_addr = target;
|
||||
|
||||
auto iter = FindVMA(target);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "UnmapPhysicalMemory iter != end");
|
||||
|
||||
while (true) {
|
||||
const auto& vma = iter->second;
|
||||
@@ -428,7 +434,7 @@ ResultCode VMManager::UnmapPhysicalMemory(VAddr target, u64 size) {
|
||||
// Advance to the next block.
|
||||
cur_addr = vma_end;
|
||||
iter = FindVMA(cur_addr);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "UnmapPhysicalMemory iter != end");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,12 +443,10 @@ ResultCode VMManager::UnmapPhysicalMemory(VAddr target, u64 size) {
|
||||
if (result.IsError()) {
|
||||
for (const auto [map_address, map_size] : unmapped_regions) {
|
||||
const auto remap_res =
|
||||
MapMemoryBlock(map_address, std::make_shared<PhysicalMemory>(map_size), 0, map_size,
|
||||
MemoryState::Heap, VMAPermission::None);
|
||||
ASSERT_MSG(remap_res.Succeeded(), "Failed to remap a memory block.");
|
||||
MapMemoryBlock(map_address, std::make_shared<PhysicalMemory>(map_size, 0), 0,
|
||||
map_size, MemoryState::Heap, VMAPermission::None);
|
||||
ASSERT_MSG(remap_res.Succeeded(), "UnmapPhysicalMemory re-map on error");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Update mapped amount
|
||||
@@ -753,26 +757,20 @@ void VMManager::MergeAdjacentVMA(VirtualMemoryArea& left, const VirtualMemoryAre
|
||||
// Always merge allocated memory blocks, even when they don't share the same backing block.
|
||||
if (left.type == VMAType::AllocatedMemoryBlock &&
|
||||
(left.backing_block != right.backing_block || left.offset + left.size != right.offset)) {
|
||||
const auto right_begin = right.backing_block->begin() + right.offset;
|
||||
const auto right_end = right_begin + right.size;
|
||||
|
||||
// Check if we can save work.
|
||||
if (left.offset == 0 && left.size == left.backing_block->size()) {
|
||||
// Fast case: left is an entire backing block.
|
||||
left.backing_block->insert(left.backing_block->end(), right_begin, right_end);
|
||||
left.backing_block->insert(left.backing_block->end(),
|
||||
right.backing_block->begin() + right.offset,
|
||||
right.backing_block->begin() + right.offset + right.size);
|
||||
} else {
|
||||
// Slow case: make a new memory block for left and right.
|
||||
const auto left_begin = left.backing_block->begin() + left.offset;
|
||||
const auto left_end = left_begin + left.size;
|
||||
const auto left_size = static_cast<std::size_t>(std::distance(left_begin, left_end));
|
||||
const auto right_size = static_cast<std::size_t>(std::distance(right_begin, right_end));
|
||||
|
||||
auto new_memory = std::make_shared<PhysicalMemory>();
|
||||
new_memory->reserve(left_size + right_size);
|
||||
new_memory->insert(new_memory->end(), left_begin, left_end);
|
||||
new_memory->insert(new_memory->end(), right_begin, right_end);
|
||||
|
||||
left.backing_block = std::move(new_memory);
|
||||
new_memory->insert(new_memory->end(), left.backing_block->begin() + left.offset,
|
||||
left.backing_block->begin() + left.offset + left.size);
|
||||
new_memory->insert(new_memory->end(), right.backing_block->begin() + right.offset,
|
||||
right.backing_block->begin() + right.offset + right.size);
|
||||
left.backing_block = new_memory;
|
||||
left.offset = 0;
|
||||
}
|
||||
|
||||
@@ -967,7 +965,7 @@ ResultVal<std::size_t> VMManager::SizeOfAllocatedVMAsInRange(VAddr address,
|
||||
|
||||
VAddr cur_addr = address;
|
||||
auto iter = FindVMA(cur_addr);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "SizeOfAllocatedVMAsInRange iter != end");
|
||||
|
||||
while (true) {
|
||||
const auto& vma = iter->second;
|
||||
@@ -988,7 +986,7 @@ ResultVal<std::size_t> VMManager::SizeOfAllocatedVMAsInRange(VAddr address,
|
||||
// Advance to the next block.
|
||||
cur_addr = vma_end;
|
||||
iter = std::next(iter);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "SizeOfAllocatedVMAsInRange iter != end");
|
||||
}
|
||||
|
||||
return MakeResult(mapped_size);
|
||||
@@ -1002,7 +1000,7 @@ ResultVal<std::size_t> VMManager::SizeOfUnmappablePhysicalMemoryInRange(VAddr ad
|
||||
|
||||
VAddr cur_addr = address;
|
||||
auto iter = FindVMA(cur_addr);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "SizeOfUnmappablePhysicalMemoryInRange iter != end");
|
||||
|
||||
while (true) {
|
||||
const auto& vma = iter->second;
|
||||
@@ -1031,7 +1029,7 @@ ResultVal<std::size_t> VMManager::SizeOfUnmappablePhysicalMemoryInRange(VAddr ad
|
||||
// Advance to the next block.
|
||||
cur_addr = vma_end;
|
||||
iter = std::next(iter);
|
||||
ASSERT(iter != vma_map.end());
|
||||
ASSERT_MSG(iter != vma_map.end(), "SizeOfUnmappablePhysicalMemoryInRange iter != end");
|
||||
}
|
||||
|
||||
return MakeResult(mapped_size);
|
||||
|
||||
@@ -454,8 +454,8 @@ public:
|
||||
|
||||
/// Maps memory at a given address.
|
||||
///
|
||||
/// @param target The virtual address to map memory at.
|
||||
/// @param size The amount of memory to map.
|
||||
/// @param addr The virtual address to map memory at.
|
||||
/// @param size The amount of memory to map.
|
||||
///
|
||||
/// @note The destination address must lie within the Map region.
|
||||
///
|
||||
@@ -468,8 +468,8 @@ public:
|
||||
|
||||
/// Unmaps memory at a given address.
|
||||
///
|
||||
/// @param target The virtual address to unmap memory at.
|
||||
/// @param size The amount of memory to unmap.
|
||||
/// @param addr The virtual address to unmap memory at.
|
||||
/// @param size The amount of memory to unmap.
|
||||
///
|
||||
/// @note The destination address must lie within the Map region.
|
||||
///
|
||||
|
||||
@@ -56,8 +56,7 @@ struct LaunchParameters {
|
||||
};
|
||||
static_assert(sizeof(LaunchParameters) == 0x88);
|
||||
|
||||
IWindowController::IWindowController(Core::System& system_)
|
||||
: ServiceFramework("IWindowController"), system{system_} {
|
||||
IWindowController::IWindowController() : ServiceFramework("IWindowController") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "CreateWindow"},
|
||||
@@ -76,7 +75,7 @@ IWindowController::IWindowController(Core::System& system_)
|
||||
IWindowController::~IWindowController() = default;
|
||||
|
||||
void IWindowController::GetAppletResourceUserId(Kernel::HLERequestContext& ctx) {
|
||||
const u64 process_id = system.CurrentProcess()->GetProcessID();
|
||||
const u64 process_id = Core::System::GetInstance().Kernel().CurrentProcess()->GetProcessID();
|
||||
|
||||
LOG_DEBUG(Service_AM, "called. Process ID=0x{:016X}", process_id);
|
||||
|
||||
@@ -232,9 +231,8 @@ IDebugFunctions::IDebugFunctions() : ServiceFramework{"IDebugFunctions"} {
|
||||
|
||||
IDebugFunctions::~IDebugFunctions() = default;
|
||||
|
||||
ISelfController::ISelfController(Core::System& system_,
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger_)
|
||||
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger_)) {
|
||||
ISelfController::ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger)
|
||||
: ServiceFramework("ISelfController"), nvflinger(std::move(nvflinger)) {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "Exit"},
|
||||
@@ -282,7 +280,7 @@ ISelfController::ISelfController(Core::System& system_,
|
||||
|
||||
RegisterHandlers(functions);
|
||||
|
||||
auto& kernel = system_.Kernel();
|
||||
auto& kernel = Core::System::GetInstance().Kernel();
|
||||
launchable_event = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
||||
"ISelfController:LaunchableEvent");
|
||||
|
||||
@@ -503,7 +501,8 @@ void ISelfController::GetAccumulatedSuspendedTickChangedEvent(Kernel::HLERequest
|
||||
rb.PushCopyObjects(accumulated_suspended_tick_changed_event.readable);
|
||||
}
|
||||
|
||||
AppletMessageQueue::AppletMessageQueue(Kernel::KernelCore& kernel) {
|
||||
AppletMessageQueue::AppletMessageQueue() {
|
||||
auto& kernel = Core::System::GetInstance().Kernel();
|
||||
on_new_message = Kernel::WritableEvent::CreateEventPair(kernel, Kernel::ResetType::Manual,
|
||||
"AMMessageQueue:OnMessageRecieved");
|
||||
on_operation_mode_changed = Kernel::WritableEvent::CreateEventPair(
|
||||
@@ -938,8 +937,9 @@ void IStorageAccessor::Read(Kernel::HLERequestContext& ctx) {
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
ILibraryAppletCreator::ILibraryAppletCreator(Core::System& system_)
|
||||
: ServiceFramework("ILibraryAppletCreator"), system{system_} {
|
||||
ILibraryAppletCreator::ILibraryAppletCreator(u64 current_process_title_id)
|
||||
: ServiceFramework("ILibraryAppletCreator"),
|
||||
current_process_title_id(current_process_title_id) {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &ILibraryAppletCreator::CreateLibraryApplet, "CreateLibraryApplet"},
|
||||
{1, nullptr, "TerminateAllLibraryApplets"},
|
||||
@@ -961,8 +961,8 @@ void ILibraryAppletCreator::CreateLibraryApplet(Kernel::HLERequestContext& ctx)
|
||||
LOG_DEBUG(Service_AM, "called with applet_id={:08X}, applet_mode={:08X}",
|
||||
static_cast<u32>(applet_id), applet_mode);
|
||||
|
||||
const auto& applet_manager{system.GetAppletManager()};
|
||||
const auto applet = applet_manager.GetApplet(applet_id);
|
||||
const auto& applet_manager{Core::System::GetInstance().GetAppletManager()};
|
||||
const auto applet = applet_manager.GetApplet(applet_id, current_process_title_id);
|
||||
|
||||
if (applet == nullptr) {
|
||||
LOG_ERROR(Service_AM, "Applet doesn't exist! applet_id={}", static_cast<u32>(applet_id));
|
||||
@@ -999,7 +999,8 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
|
||||
const auto handle{rp.Pop<Kernel::Handle>()};
|
||||
|
||||
const auto transfer_mem =
|
||||
system.CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(handle);
|
||||
Core::System::GetInstance().CurrentProcess()->GetHandleTable().Get<Kernel::TransferMemory>(
|
||||
handle);
|
||||
|
||||
if (transfer_mem == nullptr) {
|
||||
LOG_ERROR(Service_AM, "shared_mem is a nullpr for handle={:08X}", handle);
|
||||
@@ -1017,8 +1018,7 @@ void ILibraryAppletCreator::CreateTransferMemoryStorage(Kernel::HLERequestContex
|
||||
rb.PushIpcInterface(std::make_shared<IStorage>(std::move(memory)));
|
||||
}
|
||||
|
||||
IApplicationFunctions::IApplicationFunctions(Core::System& system_)
|
||||
: ServiceFramework("IApplicationFunctions"), system{system_} {
|
||||
IApplicationFunctions::IApplicationFunctions() : ServiceFramework("IApplicationFunctions") {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{1, &IApplicationFunctions::PopLaunchParameter, "PopLaunchParameter"},
|
||||
@@ -1180,7 +1180,7 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
||||
// Get supported languages from NACP, if possible
|
||||
// Default to 0 (all languages supported)
|
||||
u32 supported_languages = 0;
|
||||
FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()};
|
||||
FileSys::PatchManager pm{Core::System::GetInstance().CurrentProcess()->GetTitleID()};
|
||||
|
||||
const auto res = pm.GetControlMetadata();
|
||||
if (res.first != nullptr) {
|
||||
@@ -1188,8 +1188,8 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
|
||||
}
|
||||
|
||||
// Call IApplicationManagerInterface implementation.
|
||||
auto& service_manager = system.ServiceManager();
|
||||
auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2");
|
||||
auto& service_manager = Core::System::GetInstance().ServiceManager();
|
||||
auto ns_am2 = service_manager.GetService<Service::NS::NS>("ns:am2");
|
||||
auto app_man = ns_am2->GetApplicationManagerInterface();
|
||||
|
||||
// Get desired application language
|
||||
@@ -1261,8 +1261,8 @@ void IApplicationFunctions::ExtendSaveData(Kernel::HLERequestContext& ctx) {
|
||||
"new_journal={:016X}",
|
||||
static_cast<u8>(type), user_id[1], user_id[0], new_normal_size, new_journal_size);
|
||||
|
||||
const auto title_id = system.CurrentProcess()->GetTitleID();
|
||||
FileSystem::WriteSaveDataSize(type, title_id, user_id, {new_normal_size, new_journal_size});
|
||||
FileSystem::WriteSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id,
|
||||
{new_normal_size, new_journal_size});
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 4};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -1281,8 +1281,8 @@ void IApplicationFunctions::GetSaveDataSize(Kernel::HLERequestContext& ctx) {
|
||||
LOG_DEBUG(Service_AM, "called with type={:02X}, user_id={:016X}{:016X}", static_cast<u8>(type),
|
||||
user_id[1], user_id[0]);
|
||||
|
||||
const auto title_id = system.CurrentProcess()->GetTitleID();
|
||||
const auto size = FileSystem::ReadSaveDataSize(type, title_id, user_id);
|
||||
const auto size =
|
||||
FileSystem::ReadSaveDataSize(type, Core::CurrentProcess()->GetTitleID(), user_id);
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 6};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
@@ -1300,9 +1300,9 @@ void IApplicationFunctions::GetGpuErrorDetectedSystemEvent(Kernel::HLERequestCon
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager,
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system) {
|
||||
auto message_queue = std::make_shared<AppletMessageQueue>(system.Kernel());
|
||||
// Needed on game boot
|
||||
message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged);
|
||||
auto message_queue = std::make_shared<AppletMessageQueue>();
|
||||
message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); // Needed on
|
||||
// game boot
|
||||
|
||||
std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
|
||||
std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager);
|
||||
|
||||
@@ -10,15 +10,12 @@
|
||||
#include "core/hle/kernel/writable_event.h"
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Kernel {
|
||||
class KernelCore;
|
||||
}
|
||||
|
||||
namespace Service::NVFlinger {
|
||||
namespace Service {
|
||||
namespace NVFlinger {
|
||||
class NVFlinger;
|
||||
}
|
||||
|
||||
namespace Service::AM {
|
||||
namespace AM {
|
||||
|
||||
enum SystemLanguage {
|
||||
Japanese = 0,
|
||||
@@ -50,7 +47,7 @@ public:
|
||||
PerformanceModeChanged = 31,
|
||||
};
|
||||
|
||||
explicit AppletMessageQueue(Kernel::KernelCore& kernel);
|
||||
AppletMessageQueue();
|
||||
~AppletMessageQueue();
|
||||
|
||||
const Kernel::SharedPtr<Kernel::ReadableEvent>& GetMesssageRecieveEvent() const;
|
||||
@@ -68,14 +65,12 @@ private:
|
||||
|
||||
class IWindowController final : public ServiceFramework<IWindowController> {
|
||||
public:
|
||||
explicit IWindowController(Core::System& system_);
|
||||
IWindowController();
|
||||
~IWindowController() override;
|
||||
|
||||
private:
|
||||
void GetAppletResourceUserId(Kernel::HLERequestContext& ctx);
|
||||
void AcquireForegroundRights(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
class IAudioController final : public ServiceFramework<IAudioController> {
|
||||
@@ -118,8 +113,7 @@ public:
|
||||
|
||||
class ISelfController final : public ServiceFramework<ISelfController> {
|
||||
public:
|
||||
explicit ISelfController(Core::System& system_,
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger_);
|
||||
explicit ISelfController(std::shared_ptr<NVFlinger::NVFlinger> nvflinger);
|
||||
~ISelfController() override;
|
||||
|
||||
private:
|
||||
@@ -214,7 +208,7 @@ private:
|
||||
|
||||
class ILibraryAppletCreator final : public ServiceFramework<ILibraryAppletCreator> {
|
||||
public:
|
||||
explicit ILibraryAppletCreator(Core::System& system_);
|
||||
ILibraryAppletCreator(u64 current_process_title_id);
|
||||
~ILibraryAppletCreator() override;
|
||||
|
||||
private:
|
||||
@@ -222,12 +216,12 @@ private:
|
||||
void CreateStorage(Kernel::HLERequestContext& ctx);
|
||||
void CreateTransferMemoryStorage(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Core::System& system;
|
||||
u64 current_process_title_id;
|
||||
};
|
||||
|
||||
class IApplicationFunctions final : public ServiceFramework<IApplicationFunctions> {
|
||||
public:
|
||||
explicit IApplicationFunctions(Core::System& system_);
|
||||
IApplicationFunctions();
|
||||
~IApplicationFunctions() override;
|
||||
|
||||
private:
|
||||
@@ -251,7 +245,6 @@ private:
|
||||
void GetGpuErrorDetectedSystemEvent(Kernel::HLERequestContext& ctx);
|
||||
|
||||
Kernel::EventPair gpu_error_detected_event;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
class IHomeMenuFunctions final : public ServiceFramework<IHomeMenuFunctions> {
|
||||
@@ -285,4 +278,5 @@ public:
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager,
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger, Core::System& system);
|
||||
|
||||
} // namespace Service::AM
|
||||
} // namespace AM
|
||||
} // namespace Service
|
||||
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ISelfController>(system, nvflinger);
|
||||
rb.PushIpcInterface<ISelfController>(nvflinger);
|
||||
}
|
||||
|
||||
void GetWindowController(Kernel::HLERequestContext& ctx) {
|
||||
@@ -58,7 +58,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IWindowController>(system);
|
||||
rb.PushIpcInterface<IWindowController>();
|
||||
}
|
||||
|
||||
void GetAudioController(Kernel::HLERequestContext& ctx) {
|
||||
@@ -98,7 +98,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID());
|
||||
}
|
||||
|
||||
void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IApplicationFunctions>(system);
|
||||
rb.PushIpcInterface<IApplicationFunctions>();
|
||||
}
|
||||
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
|
||||
@@ -154,7 +154,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ISelfController>(system, nvflinger);
|
||||
rb.PushIpcInterface<ISelfController>(nvflinger);
|
||||
}
|
||||
|
||||
void GetWindowController(Kernel::HLERequestContext& ctx) {
|
||||
@@ -162,7 +162,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IWindowController>(system);
|
||||
rb.PushIpcInterface<IWindowController>();
|
||||
}
|
||||
|
||||
void GetAudioController(Kernel::HLERequestContext& ctx) {
|
||||
@@ -194,7 +194,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID());
|
||||
}
|
||||
|
||||
void GetHomeMenuFunctions(Kernel::HLERequestContext& ctx) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "common/logging/log.h"
|
||||
#include "core/hle/ipc_helpers.h"
|
||||
#include "core/hle/kernel/process.h"
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applet_oe.h"
|
||||
#include "core/hle/service/nvflinger/nvflinger.h"
|
||||
@@ -63,7 +64,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IWindowController>(system);
|
||||
rb.PushIpcInterface<IWindowController>();
|
||||
}
|
||||
|
||||
void GetSelfController(Kernel::HLERequestContext& ctx) {
|
||||
@@ -71,7 +72,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ISelfController>(system, nvflinger);
|
||||
rb.PushIpcInterface<ISelfController>(nvflinger);
|
||||
}
|
||||
|
||||
void GetCommonStateGetter(Kernel::HLERequestContext& ctx) {
|
||||
@@ -87,7 +88,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system);
|
||||
rb.PushIpcInterface<ILibraryAppletCreator>(system.CurrentProcess()->GetTitleID());
|
||||
}
|
||||
|
||||
void GetApplicationFunctions(Kernel::HLERequestContext& ctx) {
|
||||
@@ -95,7 +96,7 @@ private:
|
||||
|
||||
IPC::ResponseBuilder rb{ctx, 2, 0, 1};
|
||||
rb.Push(RESULT_SUCCESS);
|
||||
rb.PushIpcInterface<IApplicationFunctions>(system);
|
||||
rb.PushIpcInterface<IApplicationFunctions>();
|
||||
}
|
||||
|
||||
std::shared_ptr<NVFlinger::NVFlinger> nvflinger;
|
||||
|
||||
@@ -23,7 +23,8 @@
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
AppletDataBroker::AppletDataBroker(Kernel::KernelCore& kernel) {
|
||||
AppletDataBroker::AppletDataBroker() {
|
||||
auto& kernel = Core::System::GetInstance().Kernel();
|
||||
state_changed_event = Kernel::WritableEvent::CreateEventPair(
|
||||
kernel, Kernel::ResetType::Manual, "ILibraryAppletAccessor:StateChangedEvent");
|
||||
pop_out_data_event = Kernel::WritableEvent::CreateEventPair(
|
||||
@@ -120,7 +121,7 @@ Kernel::SharedPtr<Kernel::ReadableEvent> AppletDataBroker::GetStateChangedEvent(
|
||||
return state_changed_event.readable;
|
||||
}
|
||||
|
||||
Applet::Applet(Kernel::KernelCore& kernel_) : broker{kernel_} {}
|
||||
Applet::Applet() = default;
|
||||
|
||||
Applet::~Applet() = default;
|
||||
|
||||
@@ -153,7 +154,7 @@ AppletFrontendSet::AppletFrontendSet(AppletFrontendSet&&) noexcept = default;
|
||||
|
||||
AppletFrontendSet& AppletFrontendSet::operator=(AppletFrontendSet&&) noexcept = default;
|
||||
|
||||
AppletManager::AppletManager(Core::System& system_) : system{system_} {}
|
||||
AppletManager::AppletManager() = default;
|
||||
|
||||
AppletManager::~AppletManager() = default;
|
||||
|
||||
@@ -215,28 +216,28 @@ void AppletManager::ClearAll() {
|
||||
frontend = {};
|
||||
}
|
||||
|
||||
std::shared_ptr<Applet> AppletManager::GetApplet(AppletId id) const {
|
||||
std::shared_ptr<Applet> AppletManager::GetApplet(AppletId id, u64 current_process_title_id) const {
|
||||
switch (id) {
|
||||
case AppletId::Auth:
|
||||
return std::make_shared<Auth>(system, *frontend.parental_controls);
|
||||
return std::make_shared<Auth>(*frontend.parental_controls);
|
||||
case AppletId::Error:
|
||||
return std::make_shared<Error>(system, *frontend.error);
|
||||
return std::make_shared<Error>(*frontend.error);
|
||||
case AppletId::ProfileSelect:
|
||||
return std::make_shared<ProfileSelect>(system, *frontend.profile_select);
|
||||
return std::make_shared<ProfileSelect>(*frontend.profile_select);
|
||||
case AppletId::SoftwareKeyboard:
|
||||
return std::make_shared<SoftwareKeyboard>(system, *frontend.software_keyboard);
|
||||
return std::make_shared<SoftwareKeyboard>(*frontend.software_keyboard);
|
||||
case AppletId::PhotoViewer:
|
||||
return std::make_shared<PhotoViewer>(system, *frontend.photo_viewer);
|
||||
return std::make_shared<PhotoViewer>(*frontend.photo_viewer);
|
||||
case AppletId::LibAppletShop:
|
||||
return std::make_shared<WebBrowser>(system, *frontend.web_browser,
|
||||
return std::make_shared<WebBrowser>(*frontend.web_browser, current_process_title_id,
|
||||
frontend.e_commerce.get());
|
||||
case AppletId::LibAppletOff:
|
||||
return std::make_shared<WebBrowser>(system, *frontend.web_browser);
|
||||
return std::make_shared<WebBrowser>(*frontend.web_browser, current_process_title_id);
|
||||
default:
|
||||
UNIMPLEMENTED_MSG(
|
||||
"No backend implementation exists for applet_id={:02X}! Falling back to stub applet.",
|
||||
static_cast<u8>(id));
|
||||
return std::make_shared<StubApplet>(system, id);
|
||||
return std::make_shared<StubApplet>(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
|
||||
union ResultCode;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Core::Frontend {
|
||||
class ECommerceApplet;
|
||||
class ErrorApplet;
|
||||
@@ -26,10 +22,6 @@ class SoftwareKeyboardApplet;
|
||||
class WebBrowserApplet;
|
||||
} // namespace Core::Frontend
|
||||
|
||||
namespace Kernel {
|
||||
class KernelCore;
|
||||
}
|
||||
|
||||
namespace Service::AM {
|
||||
|
||||
class IStorage;
|
||||
@@ -61,7 +53,7 @@ enum class AppletId : u32 {
|
||||
|
||||
class AppletDataBroker final {
|
||||
public:
|
||||
explicit AppletDataBroker(Kernel::KernelCore& kernel_);
|
||||
AppletDataBroker();
|
||||
~AppletDataBroker();
|
||||
|
||||
struct RawChannelData {
|
||||
@@ -116,7 +108,7 @@ private:
|
||||
|
||||
class Applet {
|
||||
public:
|
||||
explicit Applet(Kernel::KernelCore& kernel_);
|
||||
Applet();
|
||||
virtual ~Applet();
|
||||
|
||||
virtual void Initialize();
|
||||
@@ -187,7 +179,7 @@ struct AppletFrontendSet {
|
||||
|
||||
class AppletManager {
|
||||
public:
|
||||
explicit AppletManager(Core::System& system_);
|
||||
AppletManager();
|
||||
~AppletManager();
|
||||
|
||||
void SetAppletFrontendSet(AppletFrontendSet set);
|
||||
@@ -195,11 +187,10 @@ public:
|
||||
void SetDefaultAppletsIfMissing();
|
||||
void ClearAll();
|
||||
|
||||
std::shared_ptr<Applet> GetApplet(AppletId id) const;
|
||||
std::shared_ptr<Applet> GetApplet(AppletId id, u64 current_process_title_id) const;
|
||||
|
||||
private:
|
||||
AppletFrontendSet frontend;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Applets
|
||||
|
||||
@@ -85,8 +85,7 @@ ResultCode Decode64BitError(u64 error) {
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
Error::Error(Core::System& system_, const Core::Frontend::ErrorApplet& frontend_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_), system{system_} {}
|
||||
Error::Error(const Core::Frontend::ErrorApplet& frontend) : frontend(frontend) {}
|
||||
|
||||
Error::~Error() = default;
|
||||
|
||||
@@ -146,8 +145,8 @@ void Error::Execute() {
|
||||
}
|
||||
|
||||
const auto callback = [this] { DisplayCompleted(); };
|
||||
const auto title_id = system.CurrentProcess()->GetTitleID();
|
||||
const auto& reporter{system.GetReporter()};
|
||||
const auto title_id = Core::CurrentProcess()->GetTitleID();
|
||||
const auto& reporter{Core::System::GetInstance().GetReporter()};
|
||||
|
||||
switch (mode) {
|
||||
case ErrorAppletMode::ShowError:
|
||||
|
||||
@@ -7,10 +7,6 @@
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/am/applets/applets.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
enum class ErrorAppletMode : u8 {
|
||||
@@ -25,7 +21,7 @@ enum class ErrorAppletMode : u8 {
|
||||
|
||||
class Error final : public Applet {
|
||||
public:
|
||||
explicit Error(Core::System& system_, const Core::Frontend::ErrorApplet& frontend_);
|
||||
explicit Error(const Core::Frontend::ErrorApplet& frontend);
|
||||
~Error() override;
|
||||
|
||||
void Initialize() override;
|
||||
@@ -46,7 +42,6 @@ private:
|
||||
std::unique_ptr<ErrorArguments> args;
|
||||
|
||||
bool complete = false;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
||||
@@ -37,8 +37,7 @@ static void LogCurrentStorage(AppletDataBroker& broker, std::string_view prefix)
|
||||
}
|
||||
}
|
||||
|
||||
Auth::Auth(Core::System& system_, Core::Frontend::ParentalControlsApplet& frontend_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_) {}
|
||||
Auth::Auth(Core::Frontend::ParentalControlsApplet& frontend) : frontend(frontend) {}
|
||||
|
||||
Auth::~Auth() = default;
|
||||
|
||||
@@ -152,8 +151,7 @@ void Auth::AuthFinished(bool successful) {
|
||||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
PhotoViewer::PhotoViewer(Core::System& system_, const Core::Frontend::PhotoViewerApplet& frontend_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_), system{system_} {}
|
||||
PhotoViewer::PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend) : frontend(frontend) {}
|
||||
|
||||
PhotoViewer::~PhotoViewer() = default;
|
||||
|
||||
@@ -187,7 +185,7 @@ void PhotoViewer::Execute() {
|
||||
const auto callback = [this] { ViewFinished(); };
|
||||
switch (mode) {
|
||||
case PhotoViewerAppletMode::CurrentApp:
|
||||
frontend.ShowPhotosForApplication(system.CurrentProcess()->GetTitleID(), callback);
|
||||
frontend.ShowPhotosForApplication(Core::CurrentProcess()->GetTitleID(), callback);
|
||||
break;
|
||||
case PhotoViewerAppletMode::AllApps:
|
||||
frontend.ShowAllPhotos(callback);
|
||||
@@ -202,8 +200,7 @@ void PhotoViewer::ViewFinished() {
|
||||
broker.SignalStateChanged();
|
||||
}
|
||||
|
||||
StubApplet::StubApplet(Core::System& system_, AppletId id_)
|
||||
: Applet{system_.Kernel()}, id(id_), system{system_} {}
|
||||
StubApplet::StubApplet(AppletId id) : id(id) {}
|
||||
|
||||
StubApplet::~StubApplet() = default;
|
||||
|
||||
@@ -212,7 +209,7 @@ void StubApplet::Initialize() {
|
||||
Applet::Initialize();
|
||||
|
||||
const auto data = broker.PeekDataToAppletForDebug();
|
||||
system.GetReporter().SaveUnimplementedAppletReport(
|
||||
Core::System::GetInstance().GetReporter().SaveUnimplementedAppletReport(
|
||||
static_cast<u32>(id), common_args.arguments_version, common_args.library_version,
|
||||
common_args.theme_color, common_args.play_startup_sound, common_args.system_tick,
|
||||
data.normal, data.interactive);
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
|
||||
#include "core/hle/service/am/applets/applets.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
enum class AuthAppletType : u32 {
|
||||
@@ -20,7 +16,7 @@ enum class AuthAppletType : u32 {
|
||||
|
||||
class Auth final : public Applet {
|
||||
public:
|
||||
explicit Auth(Core::System& system_, Core::Frontend::ParentalControlsApplet& frontend_);
|
||||
explicit Auth(Core::Frontend::ParentalControlsApplet& frontend);
|
||||
~Auth() override;
|
||||
|
||||
void Initialize() override;
|
||||
@@ -49,7 +45,7 @@ enum class PhotoViewerAppletMode : u8 {
|
||||
|
||||
class PhotoViewer final : public Applet {
|
||||
public:
|
||||
explicit PhotoViewer(Core::System& system_, const Core::Frontend::PhotoViewerApplet& frontend_);
|
||||
explicit PhotoViewer(const Core::Frontend::PhotoViewerApplet& frontend);
|
||||
~PhotoViewer() override;
|
||||
|
||||
void Initialize() override;
|
||||
@@ -64,12 +60,11 @@ private:
|
||||
const Core::Frontend::PhotoViewerApplet& frontend;
|
||||
bool complete = false;
|
||||
PhotoViewerAppletMode mode = PhotoViewerAppletMode::CurrentApp;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
class StubApplet final : public Applet {
|
||||
public:
|
||||
explicit StubApplet(Core::System& system_, AppletId id_);
|
||||
explicit StubApplet(AppletId id);
|
||||
~StubApplet() override;
|
||||
|
||||
void Initialize() override;
|
||||
@@ -81,7 +76,6 @@ public:
|
||||
|
||||
private:
|
||||
AppletId id;
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
||||
@@ -15,9 +15,8 @@ namespace Service::AM::Applets {
|
||||
|
||||
constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
|
||||
|
||||
ProfileSelect::ProfileSelect(Core::System& system_,
|
||||
const Core::Frontend::ProfileSelectApplet& frontend_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_) {}
|
||||
ProfileSelect::ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend)
|
||||
: frontend(frontend) {}
|
||||
|
||||
ProfileSelect::~ProfileSelect() = default;
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
#include "core/hle/result.h"
|
||||
#include "core/hle/service/am/applets/applets.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
struct UserSelectionConfig {
|
||||
@@ -33,8 +29,7 @@ static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has inco
|
||||
|
||||
class ProfileSelect final : public Applet {
|
||||
public:
|
||||
explicit ProfileSelect(Core::System& system_,
|
||||
const Core::Frontend::ProfileSelectApplet& frontend_);
|
||||
explicit ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend);
|
||||
~ProfileSelect() override;
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
@@ -39,9 +39,8 @@ static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters(
|
||||
return params;
|
||||
}
|
||||
|
||||
SoftwareKeyboard::SoftwareKeyboard(Core::System& system_,
|
||||
const Core::Frontend::SoftwareKeyboardApplet& frontend_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_) {}
|
||||
SoftwareKeyboard::SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend)
|
||||
: frontend(frontend) {}
|
||||
|
||||
SoftwareKeyboard::~SoftwareKeyboard() = default;
|
||||
|
||||
|
||||
@@ -16,10 +16,6 @@
|
||||
|
||||
union ResultCode;
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
enum class KeysetDisable : u32 {
|
||||
@@ -59,8 +55,7 @@ static_assert(sizeof(KeyboardConfig) == 0x3E0, "KeyboardConfig has incorrect siz
|
||||
|
||||
class SoftwareKeyboard final : public Applet {
|
||||
public:
|
||||
explicit SoftwareKeyboard(Core::System& system_,
|
||||
const Core::Frontend::SoftwareKeyboardApplet& frontend_);
|
||||
explicit SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend);
|
||||
~SoftwareKeyboard() override;
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
@@ -190,9 +190,8 @@ std::map<WebArgTLVType, std::vector<u8>> GetWebArguments(const std::vector<u8>&
|
||||
return out;
|
||||
}
|
||||
|
||||
FileSys::VirtualFile GetApplicationRomFS(const Core::System& system, u64 title_id,
|
||||
FileSys::ContentRecordType type) {
|
||||
const auto& installed{system.GetContentProvider()};
|
||||
FileSys::VirtualFile GetApplicationRomFS(u64 title_id, FileSys::ContentRecordType type) {
|
||||
const auto& installed{Core::System::GetInstance().GetContentProvider()};
|
||||
const auto res = installed.GetEntry(title_id, type);
|
||||
|
||||
if (res != nullptr) {
|
||||
@@ -208,10 +207,10 @@ FileSys::VirtualFile GetApplicationRomFS(const Core::System& system, u64 title_i
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
WebBrowser::WebBrowser(Core::System& system_, Core::Frontend::WebBrowserApplet& frontend_,
|
||||
Core::Frontend::ECommerceApplet* frontend_e_commerce_)
|
||||
: Applet{system_.Kernel()}, frontend(frontend_),
|
||||
frontend_e_commerce(frontend_e_commerce_), system{system_} {}
|
||||
WebBrowser::WebBrowser(Core::Frontend::WebBrowserApplet& frontend, u64 current_process_title_id,
|
||||
Core::Frontend::ECommerceApplet* frontend_e_commerce)
|
||||
: frontend(frontend), frontend_e_commerce(frontend_e_commerce),
|
||||
current_process_title_id(current_process_title_id) {}
|
||||
|
||||
WebBrowser::~WebBrowser() = default;
|
||||
|
||||
@@ -267,7 +266,7 @@ void WebBrowser::UnpackRomFS() {
|
||||
ASSERT(offline_romfs != nullptr);
|
||||
const auto dir =
|
||||
FileSys::ExtractRomFS(offline_romfs, FileSys::RomFSExtractionType::SingleDiscard);
|
||||
const auto& vfs{system.GetFilesystem()};
|
||||
const auto& vfs{Core::System::GetInstance().GetFilesystem()};
|
||||
const auto temp_dir = vfs->CreateDirectory(temporary_dir, FileSys::Mode::ReadWrite);
|
||||
FileSys::VfsRawCopyD(dir, temp_dir);
|
||||
|
||||
@@ -471,10 +470,10 @@ void WebBrowser::InitializeOffline() {
|
||||
}
|
||||
|
||||
if (title_id == 0) {
|
||||
title_id = system.CurrentProcess()->GetTitleID();
|
||||
title_id = current_process_title_id;
|
||||
}
|
||||
|
||||
offline_romfs = GetApplicationRomFS(system, title_id, type);
|
||||
offline_romfs = GetApplicationRomFS(title_id, type);
|
||||
if (offline_romfs == nullptr) {
|
||||
status = ResultCode(-1);
|
||||
LOG_ERROR(Service_AM, "Failed to find offline data for request!");
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
#include "core/hle/service/am/am.h"
|
||||
#include "core/hle/service/am/applets/applets.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::AM::Applets {
|
||||
|
||||
enum class ShimKind : u32;
|
||||
@@ -21,8 +17,8 @@ enum class WebArgTLVType : u16;
|
||||
|
||||
class WebBrowser final : public Applet {
|
||||
public:
|
||||
WebBrowser(Core::System& system_, Core::Frontend::WebBrowserApplet& frontend_,
|
||||
Core::Frontend::ECommerceApplet* frontend_e_commerce_ = nullptr);
|
||||
WebBrowser(Core::Frontend::WebBrowserApplet& frontend, u64 current_process_title_id,
|
||||
Core::Frontend::ECommerceApplet* frontend_e_commerce = nullptr);
|
||||
|
||||
~WebBrowser() override;
|
||||
|
||||
@@ -63,6 +59,8 @@ private:
|
||||
bool unpacked = false;
|
||||
ResultCode status = RESULT_SUCCESS;
|
||||
|
||||
u64 current_process_title_id;
|
||||
|
||||
ShimKind kind;
|
||||
std::map<WebArgTLVType, std::vector<u8>> args;
|
||||
|
||||
@@ -76,8 +74,6 @@ private:
|
||||
std::optional<u128> user_id;
|
||||
std::optional<bool> shop_full_display;
|
||||
std::string shop_extra_parameter;
|
||||
|
||||
Core::System& system;
|
||||
};
|
||||
|
||||
} // namespace Service::AM::Applets
|
||||
|
||||
@@ -258,15 +258,6 @@ ResultStatus AppLoader_NRO::ReadTitle(std::string& title) {
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
ResultStatus AppLoader_NRO::ReadControlData(FileSys::NACP& control) {
|
||||
if (nacp == nullptr) {
|
||||
return ResultStatus::ErrorNoControl;
|
||||
}
|
||||
|
||||
control = *nacp;
|
||||
return ResultStatus::Success;
|
||||
}
|
||||
|
||||
bool AppLoader_NRO::IsRomFSUpdatable() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ public:
|
||||
ResultStatus ReadProgramId(u64& out_program_id) override;
|
||||
ResultStatus ReadRomFS(FileSys::VirtualFile& dir) override;
|
||||
ResultStatus ReadTitle(std::string& title) override;
|
||||
ResultStatus ReadControlData(FileSys::NACP& control) override;
|
||||
bool IsRomFSUpdatable() const override;
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <bitset>
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/log.h"
|
||||
#include "core/core.h"
|
||||
@@ -50,33 +49,6 @@ void KeplerCompute::CallMethod(const GPU::MethodCall& method_call) {
|
||||
}
|
||||
}
|
||||
|
||||
Tegra::Texture::FullTextureInfo KeplerCompute::GetTexture(std::size_t offset) const {
|
||||
const std::bitset<8> cbuf_mask = launch_description.const_buffer_enable_mask.Value();
|
||||
ASSERT(cbuf_mask[regs.tex_cb_index]);
|
||||
|
||||
const auto& texinfo = launch_description.const_buffer_config[regs.tex_cb_index];
|
||||
ASSERT(texinfo.Address() != 0);
|
||||
|
||||
const GPUVAddr address = texinfo.Address() + offset * sizeof(Texture::TextureHandle);
|
||||
ASSERT(address < texinfo.Address() + texinfo.size);
|
||||
|
||||
const Texture::TextureHandle tex_handle{memory_manager.Read<u32>(address)};
|
||||
return GetTextureInfo(tex_handle, offset);
|
||||
}
|
||||
|
||||
Texture::FullTextureInfo KeplerCompute::GetTextureInfo(const Texture::TextureHandle tex_handle,
|
||||
std::size_t offset) const {
|
||||
return Texture::FullTextureInfo{static_cast<u32>(offset), GetTICEntry(tex_handle.tic_id),
|
||||
GetTSCEntry(tex_handle.tsc_id)};
|
||||
}
|
||||
|
||||
u32 KeplerCompute::AccessConstBuffer32(u64 const_buffer, u64 offset) const {
|
||||
const auto& buffer = launch_description.const_buffer_config[const_buffer];
|
||||
u32 result;
|
||||
std::memcpy(&result, memory_manager.GetPointer(buffer.Address() + offset), sizeof(u32));
|
||||
return result;
|
||||
}
|
||||
|
||||
void KeplerCompute::ProcessLaunch() {
|
||||
const GPUVAddr launch_desc_loc = regs.launch_desc_loc.Address();
|
||||
memory_manager.ReadBlockUnsafe(launch_desc_loc, &launch_description,
|
||||
@@ -88,29 +60,4 @@ void KeplerCompute::ProcessLaunch() {
|
||||
rasterizer.DispatchCompute(code_addr);
|
||||
}
|
||||
|
||||
Texture::TICEntry KeplerCompute::GetTICEntry(u32 tic_index) const {
|
||||
const GPUVAddr tic_address_gpu{regs.tic.Address() + tic_index * sizeof(Texture::TICEntry)};
|
||||
|
||||
Texture::TICEntry tic_entry;
|
||||
memory_manager.ReadBlockUnsafe(tic_address_gpu, &tic_entry, sizeof(Texture::TICEntry));
|
||||
|
||||
const auto r_type{tic_entry.r_type.Value()};
|
||||
const auto g_type{tic_entry.g_type.Value()};
|
||||
const auto b_type{tic_entry.b_type.Value()};
|
||||
const auto a_type{tic_entry.a_type.Value()};
|
||||
|
||||
// TODO(Subv): Different data types for separate components are not supported
|
||||
DEBUG_ASSERT(r_type == g_type && r_type == b_type && r_type == a_type);
|
||||
|
||||
return tic_entry;
|
||||
}
|
||||
|
||||
Texture::TSCEntry KeplerCompute::GetTSCEntry(u32 tsc_index) const {
|
||||
const GPUVAddr tsc_address_gpu{regs.tsc.Address() + tsc_index * sizeof(Texture::TSCEntry)};
|
||||
|
||||
Texture::TSCEntry tsc_entry;
|
||||
memory_manager.ReadBlockUnsafe(tsc_address_gpu, &tsc_entry, sizeof(Texture::TSCEntry));
|
||||
return tsc_entry;
|
||||
}
|
||||
|
||||
} // namespace Tegra::Engines
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "common/common_types.h"
|
||||
#include "video_core/engines/engine_upload.h"
|
||||
#include "video_core/gpu.h"
|
||||
#include "video_core/textures/texture.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@@ -112,7 +111,7 @@ public:
|
||||
|
||||
INSERT_PADDING_WORDS(0x3FE);
|
||||
|
||||
u32 tex_cb_index;
|
||||
u32 texture_const_buffer_index;
|
||||
|
||||
INSERT_PADDING_WORDS(0x374);
|
||||
};
|
||||
@@ -150,7 +149,7 @@ public:
|
||||
union {
|
||||
BitField<0, 8, u32> const_buffer_enable_mask;
|
||||
BitField<29, 2, u32> cache_layout;
|
||||
};
|
||||
} memory_config;
|
||||
|
||||
INSERT_PADDING_WORDS(0x8);
|
||||
|
||||
@@ -195,14 +194,6 @@ public:
|
||||
/// Write the value to the register identified by method.
|
||||
void CallMethod(const GPU::MethodCall& method_call);
|
||||
|
||||
Tegra::Texture::FullTextureInfo GetTexture(std::size_t offset) const;
|
||||
|
||||
/// Given a Texture Handle, returns the TSC and TIC entries.
|
||||
Texture::FullTextureInfo GetTextureInfo(const Texture::TextureHandle tex_handle,
|
||||
std::size_t offset) const;
|
||||
|
||||
u32 AccessConstBuffer32(u64 const_buffer, u64 offset) const;
|
||||
|
||||
private:
|
||||
Core::System& system;
|
||||
VideoCore::RasterizerInterface& rasterizer;
|
||||
@@ -210,12 +201,6 @@ private:
|
||||
Upload::State upload_state;
|
||||
|
||||
void ProcessLaunch();
|
||||
|
||||
/// Retrieves information about a specific TIC entry from the TIC buffer.
|
||||
Texture::TICEntry GetTICEntry(u32 tic_index) const;
|
||||
|
||||
/// Retrieves information about a specific TSC entry from the TSC buffer.
|
||||
Texture::TSCEntry GetTSCEntry(u32 tsc_index) const;
|
||||
};
|
||||
|
||||
#define ASSERT_REG_POSITION(field_name, position) \
|
||||
@@ -233,12 +218,12 @@ ASSERT_REG_POSITION(launch, 0xAF);
|
||||
ASSERT_REG_POSITION(tsc, 0x557);
|
||||
ASSERT_REG_POSITION(tic, 0x55D);
|
||||
ASSERT_REG_POSITION(code_loc, 0x582);
|
||||
ASSERT_REG_POSITION(tex_cb_index, 0x982);
|
||||
ASSERT_REG_POSITION(texture_const_buffer_index, 0x982);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(program_start, 0x8);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(grid_dim_x, 0xC);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(shared_alloc, 0x11);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(block_dim_x, 0x12);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(const_buffer_enable_mask, 0x14);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(memory_config, 0x14);
|
||||
ASSERT_LAUNCH_PARAM_POSITION(const_buffer_config, 0x1D);
|
||||
|
||||
#undef ASSERT_REG_POSITION
|
||||
|
||||
@@ -244,7 +244,7 @@ void Maxwell3D::InitDirtySettings() {
|
||||
dirty_pointers[MAXWELL3D_REG_INDEX(polygon_offset_clamp)] = polygon_offset_dirty_reg;
|
||||
}
|
||||
|
||||
void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters) {
|
||||
void Maxwell3D::CallMacroMethod(u32 method, std::vector<u32> parameters) {
|
||||
// Reset the current macro.
|
||||
executing_macro = 0;
|
||||
|
||||
@@ -252,7 +252,7 @@ void Maxwell3D::CallMacroMethod(u32 method, std::size_t num_parameters, const u3
|
||||
const u32 entry = ((method - MacroRegistersStart) >> 1) % macro_positions.size();
|
||||
|
||||
// Execute the current macro.
|
||||
macro_interpreter.Execute(macro_positions[entry], num_parameters, parameters);
|
||||
macro_interpreter.Execute(macro_positions[entry], std::move(parameters));
|
||||
}
|
||||
|
||||
void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
|
||||
@@ -289,8 +289,7 @@ void Maxwell3D::CallMethod(const GPU::MethodCall& method_call) {
|
||||
|
||||
// Call the macro when there are no more parameters in the command buffer
|
||||
if (method_call.IsLastCall()) {
|
||||
CallMacroMethod(executing_macro, macro_params.size(), macro_params.data());
|
||||
macro_params.clear();
|
||||
CallMacroMethod(executing_macro, std::move(macro_params));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,6 @@ public:
|
||||
static constexpr std::size_t NumVertexAttributes = 32;
|
||||
static constexpr std::size_t NumVaryings = 31;
|
||||
static constexpr std::size_t NumTextureSamplers = 32;
|
||||
static constexpr std::size_t NumImages = 8; // TODO(Rodrigo): Investigate this number
|
||||
static constexpr std::size_t NumClipDistances = 8;
|
||||
static constexpr std::size_t MaxShaderProgram = 6;
|
||||
static constexpr std::size_t MaxShaderStage = 5;
|
||||
@@ -1308,10 +1307,9 @@ private:
|
||||
/**
|
||||
* Call a macro on this engine.
|
||||
* @param method Method to call
|
||||
* @param num_parameters Number of arguments
|
||||
* @param parameters Arguments to the method call
|
||||
*/
|
||||
void CallMacroMethod(u32 method, std::size_t num_parameters, const u32* parameters);
|
||||
void CallMacroMethod(u32 method, std::vector<u32> parameters);
|
||||
|
||||
/// Handles writes to the macro uploading register.
|
||||
void ProcessMacroUpload(u32 data);
|
||||
|
||||
@@ -674,10 +674,6 @@ union Instruction {
|
||||
BitField<48, 1, u64> is_signed;
|
||||
} shift;
|
||||
|
||||
union {
|
||||
BitField<39, 1, u64> wrap;
|
||||
} shr;
|
||||
|
||||
union {
|
||||
BitField<39, 5, u64> shift_amount;
|
||||
BitField<48, 1, u64> negate_b;
|
||||
|
||||
@@ -14,18 +14,11 @@ namespace Tegra {
|
||||
|
||||
MacroInterpreter::MacroInterpreter(Engines::Maxwell3D& maxwell3d) : maxwell3d(maxwell3d) {}
|
||||
|
||||
void MacroInterpreter::Execute(u32 offset, std::size_t num_parameters, const u32* parameters) {
|
||||
void MacroInterpreter::Execute(u32 offset, std::vector<u32> parameters) {
|
||||
MICROPROFILE_SCOPE(MacroInterp);
|
||||
Reset();
|
||||
|
||||
registers[1] = parameters[0];
|
||||
|
||||
if (num_parameters > parameters_capacity) {
|
||||
parameters_capacity = num_parameters;
|
||||
this->parameters = std::make_unique<u32[]>(num_parameters);
|
||||
}
|
||||
std::memcpy(this->parameters.get(), parameters, num_parameters * sizeof(u32));
|
||||
this->num_parameters = num_parameters;
|
||||
this->parameters = std::move(parameters);
|
||||
|
||||
// Execute the code until we hit an exit condition.
|
||||
bool keep_executing = true;
|
||||
@@ -34,7 +27,7 @@ void MacroInterpreter::Execute(u32 offset, std::size_t num_parameters, const u32
|
||||
}
|
||||
|
||||
// Assert the the macro used all the input parameters
|
||||
ASSERT(next_parameter_index == num_parameters);
|
||||
ASSERT(next_parameter_index == this->parameters.size());
|
||||
}
|
||||
|
||||
void MacroInterpreter::Reset() {
|
||||
@@ -42,7 +35,7 @@ void MacroInterpreter::Reset() {
|
||||
pc = 0;
|
||||
delayed_pc = {};
|
||||
method_address.raw = 0;
|
||||
num_parameters = 0;
|
||||
parameters.clear();
|
||||
// The next parameter index starts at 1, because $r1 already has the value of the first
|
||||
// parameter.
|
||||
next_parameter_index = 1;
|
||||
@@ -236,8 +229,7 @@ void MacroInterpreter::ProcessResult(ResultOperation operation, u32 reg, u32 res
|
||||
}
|
||||
|
||||
u32 MacroInterpreter::FetchParameter() {
|
||||
ASSERT(next_parameter_index < num_parameters);
|
||||
return parameters[next_parameter_index++];
|
||||
return parameters.at(next_parameter_index++);
|
||||
}
|
||||
|
||||
u32 MacroInterpreter::GetRegister(u32 register_id) const {
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
* @param offset Offset to start execution at.
|
||||
* @param parameters The parameters of the macro.
|
||||
*/
|
||||
void Execute(u32 offset, std::size_t num_parameters, const u32* parameters);
|
||||
void Execute(u32 offset, std::vector<u32> parameters);
|
||||
|
||||
private:
|
||||
enum class Operation : u32 {
|
||||
@@ -162,12 +162,10 @@ private:
|
||||
MethodAddress method_address = {};
|
||||
|
||||
/// Input parameters of the current macro.
|
||||
std::unique_ptr<u32[]> parameters;
|
||||
std::size_t num_parameters = 0;
|
||||
std::size_t parameters_capacity = 0;
|
||||
std::vector<u32> parameters;
|
||||
/// Index of the next parameter that will be fetched by the 'parm' instruction.
|
||||
u32 next_parameter_index = 0;
|
||||
|
||||
bool carry_flag = false;
|
||||
bool carry_flag{};
|
||||
};
|
||||
} // namespace Tegra
|
||||
|
||||
@@ -331,7 +331,7 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
|
||||
const auto stage_enum = static_cast<Maxwell::ShaderStage>(stage);
|
||||
SetupDrawConstBuffers(stage_enum, shader);
|
||||
SetupDrawGlobalMemory(stage_enum, shader);
|
||||
const auto texture_buffer_usage{SetupDrawTextures(stage_enum, shader, base_bindings)};
|
||||
const auto texture_buffer_usage{SetupTextures(stage_enum, shader, base_bindings)};
|
||||
|
||||
const ProgramVariant variant{base_bindings, primitive_mode, texture_buffer_usage};
|
||||
const auto [program_handle, next_bindings] = shader->GetProgramHandle(variant);
|
||||
@@ -801,11 +801,7 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
|
||||
}
|
||||
|
||||
auto kernel = shader_cache.GetComputeKernel(code_addr);
|
||||
ProgramVariant variant;
|
||||
variant.texture_buffer_usage = SetupComputeTextures(kernel);
|
||||
SetupComputeImages(kernel);
|
||||
|
||||
const auto [program, next_bindings] = kernel->GetProgramHandle(variant);
|
||||
const auto [program, next_bindings] = kernel->GetProgramHandle({});
|
||||
state.draw.shader_program = program;
|
||||
state.draw.program_pipeline = 0;
|
||||
|
||||
@@ -820,13 +816,13 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) {
|
||||
SetupComputeConstBuffers(kernel);
|
||||
SetupComputeGlobalMemory(kernel);
|
||||
|
||||
// TODO(Rodrigo): Bind images and samplers
|
||||
|
||||
buffer_cache.Unmap();
|
||||
|
||||
bind_ubo_pushbuffer.Bind();
|
||||
bind_ssbo_pushbuffer.Bind();
|
||||
|
||||
state.ApplyTextures();
|
||||
state.ApplyImages();
|
||||
state.ApplyShaderProgram();
|
||||
state.ApplyProgramPipeline();
|
||||
|
||||
@@ -926,7 +922,7 @@ void RasterizerOpenGL::SetupComputeConstBuffers(const Shader& kernel) {
|
||||
const auto& launch_desc = system.GPU().KeplerCompute().launch_description;
|
||||
for (const auto& entry : kernel->GetShaderEntries().const_buffers) {
|
||||
const auto& config = launch_desc.const_buffer_config[entry.GetIndex()];
|
||||
const std::bitset<8> mask = launch_desc.const_buffer_enable_mask.Value();
|
||||
const std::bitset<8> mask = launch_desc.memory_config.const_buffer_enable_mask.Value();
|
||||
Tegra::Engines::ConstBufferInfo buffer;
|
||||
buffer.address = config.Address();
|
||||
buffer.size = config.size;
|
||||
@@ -985,125 +981,53 @@ void RasterizerOpenGL::SetupGlobalMemory(const GLShader::GlobalMemoryEntry& entr
|
||||
bind_ssbo_pushbuffer.Push(ssbo, buffer_offset, static_cast<GLsizeiptr>(size));
|
||||
}
|
||||
|
||||
TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stage,
|
||||
const Shader& shader,
|
||||
BaseBindings base_bindings) {
|
||||
TextureBufferUsage RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
|
||||
BaseBindings base_bindings) {
|
||||
MICROPROFILE_SCOPE(OpenGL_Texture);
|
||||
const auto& gpu = system.GPU();
|
||||
const auto& maxwell3d = gpu.Maxwell3D();
|
||||
const auto& entries = shader->GetShaderEntries().samplers;
|
||||
|
||||
ASSERT_MSG(base_bindings.sampler + entries.size() <= std::size(state.textures),
|
||||
ASSERT_MSG(base_bindings.sampler + entries.size() <= std::size(state.texture_units),
|
||||
"Exceeded the number of active textures.");
|
||||
|
||||
TextureBufferUsage texture_buffer_usage{0};
|
||||
|
||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||
const auto& entry = entries[bindpoint];
|
||||
const auto texture = [&]() {
|
||||
if (!entry.IsBindless()) {
|
||||
return maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
||||
}
|
||||
Tegra::Texture::FullTextureInfo texture;
|
||||
if (entry.IsBindless()) {
|
||||
const auto cbuf = entry.GetBindlessCBuf();
|
||||
Tegra::Texture::TextureHandle tex_handle;
|
||||
tex_handle.raw = maxwell3d.AccessConstBuffer32(stage, cbuf.first, cbuf.second);
|
||||
return maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
|
||||
}();
|
||||
texture = maxwell3d.GetTextureInfo(tex_handle, entry.GetOffset());
|
||||
} else {
|
||||
texture = maxwell3d.GetStageTexture(stage, entry.GetOffset());
|
||||
}
|
||||
const u32 current_bindpoint = base_bindings.sampler + bindpoint;
|
||||
|
||||
if (SetupTexture(base_bindings.sampler + bindpoint, texture, entry)) {
|
||||
texture_buffer_usage.set(bindpoint);
|
||||
auto& unit{state.texture_units[current_bindpoint]};
|
||||
unit.sampler = sampler_cache.GetSampler(texture.tsc);
|
||||
|
||||
if (const auto view{texture_cache.GetTextureSurface(texture, entry)}; view) {
|
||||
if (view->GetSurfaceParams().IsBuffer()) {
|
||||
// Record that this texture is a texture buffer.
|
||||
texture_buffer_usage.set(bindpoint);
|
||||
} else {
|
||||
// Apply swizzle to textures that are not buffers.
|
||||
view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
|
||||
texture.tic.w_source);
|
||||
}
|
||||
state.texture_units[current_bindpoint].texture = view->GetTexture();
|
||||
} else {
|
||||
// Can occur when texture addr is null or its memory is unmapped/invalid
|
||||
unit.texture = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return texture_buffer_usage;
|
||||
}
|
||||
|
||||
TextureBufferUsage RasterizerOpenGL::SetupComputeTextures(const Shader& kernel) {
|
||||
MICROPROFILE_SCOPE(OpenGL_Texture);
|
||||
const auto& compute = system.GPU().KeplerCompute();
|
||||
const auto& entries = kernel->GetShaderEntries().samplers;
|
||||
|
||||
ASSERT_MSG(entries.size() <= std::size(state.textures),
|
||||
"Exceeded the number of active textures.");
|
||||
|
||||
TextureBufferUsage texture_buffer_usage{0};
|
||||
|
||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||
const auto& entry = entries[bindpoint];
|
||||
const auto texture = [&]() {
|
||||
if (!entry.IsBindless()) {
|
||||
return compute.GetTexture(entry.GetOffset());
|
||||
}
|
||||
const auto cbuf = entry.GetBindlessCBuf();
|
||||
Tegra::Texture::TextureHandle tex_handle;
|
||||
tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second);
|
||||
return compute.GetTextureInfo(tex_handle, entry.GetOffset());
|
||||
}();
|
||||
|
||||
if (SetupTexture(bindpoint, texture, entry)) {
|
||||
texture_buffer_usage.set(bindpoint);
|
||||
}
|
||||
}
|
||||
|
||||
return texture_buffer_usage;
|
||||
}
|
||||
|
||||
bool RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
|
||||
const GLShader::SamplerEntry& entry) {
|
||||
state.samplers[binding] = sampler_cache.GetSampler(texture.tsc);
|
||||
|
||||
const auto view = texture_cache.GetTextureSurface(texture.tic, entry);
|
||||
if (!view) {
|
||||
// Can occur when texture addr is null or its memory is unmapped/invalid
|
||||
state.textures[binding] = 0;
|
||||
return false;
|
||||
}
|
||||
state.textures[binding] = view->GetTexture();
|
||||
|
||||
if (view->GetSurfaceParams().IsBuffer()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Apply swizzle to textures that are not buffers.
|
||||
view->ApplySwizzle(texture.tic.x_source, texture.tic.y_source, texture.tic.z_source,
|
||||
texture.tic.w_source);
|
||||
return false;
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SetupComputeImages(const Shader& shader) {
|
||||
const auto& compute = system.GPU().KeplerCompute();
|
||||
const auto& entries = shader->GetShaderEntries().images;
|
||||
for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
|
||||
const auto& entry = entries[bindpoint];
|
||||
const auto tic = [&]() {
|
||||
if (!entry.IsBindless()) {
|
||||
return compute.GetTexture(entry.GetOffset()).tic;
|
||||
}
|
||||
const auto cbuf = entry.GetBindlessCBuf();
|
||||
Tegra::Texture::TextureHandle tex_handle;
|
||||
tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second);
|
||||
return compute.GetTextureInfo(tex_handle, entry.GetOffset()).tic;
|
||||
}();
|
||||
SetupImage(bindpoint, tic, entry);
|
||||
}
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
|
||||
const GLShader::ImageEntry& entry) {
|
||||
const auto view = texture_cache.GetImageSurface(tic, entry);
|
||||
if (!view) {
|
||||
state.images[binding] = 0;
|
||||
return;
|
||||
}
|
||||
if (!tic.IsBuffer()) {
|
||||
view->ApplySwizzle(tic.x_source, tic.y_source, tic.z_source, tic.w_source);
|
||||
}
|
||||
if (entry.IsWritten()) {
|
||||
view->MarkAsModified(texture_cache.Tick());
|
||||
}
|
||||
state.images[binding] = view->GetTexture();
|
||||
}
|
||||
|
||||
void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
|
||||
const auto& regs = system.GPU().Maxwell3D().regs;
|
||||
const bool geometry_shaders_enabled =
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "video_core/renderer_opengl/gl_state.h"
|
||||
#include "video_core/renderer_opengl/gl_texture_cache.h"
|
||||
#include "video_core/renderer_opengl/utils.h"
|
||||
#include "video_core/textures/texture.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
@@ -138,22 +137,8 @@ private:
|
||||
|
||||
/// Configures the current textures to use for the draw command. Returns shaders texture buffer
|
||||
/// usage.
|
||||
TextureBufferUsage SetupDrawTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
|
||||
const Shader& shader, BaseBindings base_bindings);
|
||||
|
||||
/// Configures the textures used in a compute shader. Returns texture buffer usage.
|
||||
TextureBufferUsage SetupComputeTextures(const Shader& kernel);
|
||||
|
||||
/// Configures a texture. Returns true when the texture is a texture buffer.
|
||||
bool SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture,
|
||||
const GLShader::SamplerEntry& entry);
|
||||
|
||||
/// Configures images in a compute shader.
|
||||
void SetupComputeImages(const Shader& shader);
|
||||
|
||||
/// Configures an image.
|
||||
void SetupImage(u32 binding, const Tegra::Texture::TICEntry& tic,
|
||||
const GLShader::ImageEntry& entry);
|
||||
TextureBufferUsage SetupTextures(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,
|
||||
const Shader& shader, BaseBindings base_bindings);
|
||||
|
||||
/// Syncs the viewport and depth range to match the guest state
|
||||
void SyncViewport(OpenGLState& current_state);
|
||||
|
||||
@@ -389,10 +389,11 @@ public:
|
||||
for (const auto& sampler : ir.GetSamplers()) {
|
||||
entries.samplers.emplace_back(sampler);
|
||||
}
|
||||
for (const auto& [offset, image] : ir.GetImages()) {
|
||||
for (const auto& image : ir.GetImages()) {
|
||||
entries.images.emplace_back(image);
|
||||
}
|
||||
for (const auto& [base, usage] : ir.GetGlobalMemory()) {
|
||||
for (const auto& gmem_pair : ir.GetGlobalMemory()) {
|
||||
const auto& [base, usage] = gmem_pair;
|
||||
entries.global_memory_entries.emplace_back(base.cbuf_index, base.cbuf_offset,
|
||||
usage.is_read, usage.is_written);
|
||||
}
|
||||
@@ -705,7 +706,7 @@ private:
|
||||
|
||||
void DeclareImages() {
|
||||
const auto& images{ir.GetImages()};
|
||||
for (const auto& [offset, image] : images) {
|
||||
for (const auto& image : images) {
|
||||
const std::string image_type = [&]() {
|
||||
switch (image.GetType()) {
|
||||
case Tegra::Shader::ImageType::Texture1D:
|
||||
@@ -725,16 +726,9 @@ private:
|
||||
return "image1D";
|
||||
}
|
||||
}();
|
||||
std::string qualifier = "coherent volatile";
|
||||
if (image.IsRead() && !image.IsWritten()) {
|
||||
qualifier += " readonly";
|
||||
} else if (image.IsWritten() && !image.IsRead()) {
|
||||
qualifier += " writeonly";
|
||||
}
|
||||
|
||||
code.AddLine("layout (binding = IMAGE_BINDING_{}) {} uniform "
|
||||
code.AddLine("layout (binding = IMAGE_BINDING_{}) coherent volatile writeonly uniform "
|
||||
"{} {};",
|
||||
image.GetIndex(), qualifier, image_type, GetImage(image));
|
||||
image.GetIndex(), image_type, GetImage(image));
|
||||
}
|
||||
if (!images.empty()) {
|
||||
code.AddNewLine();
|
||||
@@ -990,10 +984,10 @@ private:
|
||||
return {std::move(temporary), value.GetType()};
|
||||
}
|
||||
|
||||
Expression GetOutputAttribute(const AbufNode* abuf) {
|
||||
std::optional<Expression> GetOutputAttribute(const AbufNode* abuf) {
|
||||
switch (const auto attribute = abuf->GetIndex()) {
|
||||
case Attribute::Index::Position:
|
||||
return {"gl_Position"s + GetSwizzle(abuf->GetElement()), Type::Float};
|
||||
return {{"gl_Position"s + GetSwizzle(abuf->GetElement()), Type::Float}};
|
||||
case Attribute::Index::LayerViewportPointSize:
|
||||
switch (abuf->GetElement()) {
|
||||
case 0:
|
||||
@@ -1003,25 +997,25 @@ private:
|
||||
if (IsVertexShader(stage) && !device.HasVertexViewportLayer()) {
|
||||
return {};
|
||||
}
|
||||
return {"gl_Layer", Type::Int};
|
||||
return {{"gl_Layer", Type::Int}};
|
||||
case 2:
|
||||
if (IsVertexShader(stage) && !device.HasVertexViewportLayer()) {
|
||||
return {};
|
||||
}
|
||||
return {"gl_ViewportIndex", Type::Int};
|
||||
return {{"gl_ViewportIndex", Type::Int}};
|
||||
case 3:
|
||||
UNIMPLEMENTED_MSG("Requires some state changes for gl_PointSize to work in shader");
|
||||
return {"gl_PointSize", Type::Float};
|
||||
return {{"gl_PointSize", Type::Float}};
|
||||
}
|
||||
return {};
|
||||
case Attribute::Index::ClipDistances0123:
|
||||
return {fmt::format("gl_ClipDistance[{}]", abuf->GetElement()), Type::Float};
|
||||
return {{fmt::format("gl_ClipDistance[{}]", abuf->GetElement()), Type::Float}};
|
||||
case Attribute::Index::ClipDistances4567:
|
||||
return {fmt::format("gl_ClipDistance[{}]", abuf->GetElement() + 4), Type::Float};
|
||||
return {{fmt::format("gl_ClipDistance[{}]", abuf->GetElement() + 4), Type::Float}};
|
||||
default:
|
||||
if (IsGenericAttribute(attribute)) {
|
||||
return {GetOutputAttribute(attribute) + GetSwizzle(abuf->GetElement()),
|
||||
Type::Float};
|
||||
return {
|
||||
{GetOutputAttribute(attribute) + GetSwizzle(abuf->GetElement()), Type::Float}};
|
||||
}
|
||||
UNIMPLEMENTED_MSG("Unhandled output attribute: {}", static_cast<u32>(attribute));
|
||||
return {};
|
||||
@@ -1193,7 +1187,11 @@ private:
|
||||
target = {GetRegister(gpr->GetIndex()), Type::Float};
|
||||
} else if (const auto abuf = std::get_if<AbufNode>(&*dest)) {
|
||||
UNIMPLEMENTED_IF(abuf->IsPhysicalBuffer());
|
||||
target = GetOutputAttribute(abuf);
|
||||
auto output = GetOutputAttribute(abuf);
|
||||
if (!output) {
|
||||
return {};
|
||||
}
|
||||
target = std::move(*output);
|
||||
} else if (const auto lmem = std::get_if<LmemNode>(&*dest)) {
|
||||
if (stage == ProgramType::Compute) {
|
||||
LOG_WARNING(Render_OpenGL, "Local memory is stubbed on compute shaders");
|
||||
|
||||
@@ -341,16 +341,13 @@ std::optional<ShaderDiskCacheDecompiled> ShaderDiskCacheOpenGL::LoadDecompiledEn
|
||||
u64 index{};
|
||||
u32 type{};
|
||||
u8 is_bindless{};
|
||||
u8 is_read{};
|
||||
u8 is_written{};
|
||||
if (!LoadObjectFromPrecompiled(offset) || !LoadObjectFromPrecompiled(index) ||
|
||||
!LoadObjectFromPrecompiled(type) || !LoadObjectFromPrecompiled(is_bindless) ||
|
||||
!LoadObjectFromPrecompiled(is_read) || !LoadObjectFromPrecompiled(is_written)) {
|
||||
!LoadObjectFromPrecompiled(type) || !LoadObjectFromPrecompiled(is_bindless)) {
|
||||
return {};
|
||||
}
|
||||
entry.entries.images.emplace_back(static_cast<u64>(offset), static_cast<std::size_t>(index),
|
||||
static_cast<Tegra::Shader::ImageType>(type),
|
||||
is_bindless != 0, is_written != 0, is_read != 0);
|
||||
entry.entries.images.emplace_back(
|
||||
static_cast<std::size_t>(offset), static_cast<std::size_t>(index),
|
||||
static_cast<Tegra::Shader::ImageType>(type), is_bindless != 0);
|
||||
}
|
||||
|
||||
u32 global_memory_count{};
|
||||
@@ -432,9 +429,7 @@ bool ShaderDiskCacheOpenGL::SaveDecompiledFile(u64 unique_identifier, const std:
|
||||
if (!SaveObjectToPrecompiled(static_cast<u64>(image.GetOffset())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u64>(image.GetIndex())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u32>(image.GetType())) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsBindless() ? 1 : 0)) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsRead() ? 1 : 0)) ||
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsWritten() ? 1 : 0))) {
|
||||
!SaveObjectToPrecompiled(static_cast<u8>(image.IsBindless() ? 1 : 0))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,25 +34,6 @@ bool UpdateTie(T1 current_value, const T2 new_value) {
|
||||
return changed;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::optional<std::pair<GLuint, GLsizei>> UpdateArray(T& current_values, const T& new_values) {
|
||||
std::optional<std::size_t> first;
|
||||
std::size_t last;
|
||||
for (std::size_t i = 0; i < std::size(current_values); ++i) {
|
||||
if (!UpdateValue(current_values[i], new_values[i])) {
|
||||
continue;
|
||||
}
|
||||
if (!first) {
|
||||
first = i;
|
||||
}
|
||||
last = i;
|
||||
}
|
||||
if (!first) {
|
||||
return std::nullopt;
|
||||
}
|
||||
return std::make_pair(static_cast<GLuint>(*first), static_cast<GLsizei>(last - *first + 1));
|
||||
}
|
||||
|
||||
void Enable(GLenum cap, bool enable) {
|
||||
if (enable) {
|
||||
glEnable(cap);
|
||||
@@ -153,6 +134,10 @@ OpenGLState::OpenGLState() {
|
||||
logic_op.enabled = false;
|
||||
logic_op.operation = GL_COPY;
|
||||
|
||||
for (auto& texture_unit : texture_units) {
|
||||
texture_unit.Reset();
|
||||
}
|
||||
|
||||
draw.read_framebuffer = 0;
|
||||
draw.draw_framebuffer = 0;
|
||||
draw.vertex_array = 0;
|
||||
@@ -511,20 +496,52 @@ void OpenGLState::ApplyAlphaTest() const {
|
||||
}
|
||||
|
||||
void OpenGLState::ApplyTextures() const {
|
||||
if (const auto update = UpdateArray(cur_state.textures, textures)) {
|
||||
glBindTextures(update->first, update->second, textures.data() + update->first);
|
||||
bool has_delta{};
|
||||
std::size_t first{};
|
||||
std::size_t last{};
|
||||
std::array<GLuint, Maxwell::NumTextureSamplers> textures;
|
||||
|
||||
for (std::size_t i = 0; i < std::size(texture_units); ++i) {
|
||||
const auto& texture_unit = texture_units[i];
|
||||
auto& cur_state_texture_unit = cur_state.texture_units[i];
|
||||
textures[i] = texture_unit.texture;
|
||||
if (cur_state_texture_unit.texture == textures[i]) {
|
||||
continue;
|
||||
}
|
||||
cur_state_texture_unit.texture = textures[i];
|
||||
if (!has_delta) {
|
||||
first = i;
|
||||
has_delta = true;
|
||||
}
|
||||
last = i;
|
||||
}
|
||||
if (has_delta) {
|
||||
glBindTextures(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1),
|
||||
textures.data() + first);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGLState::ApplySamplers() const {
|
||||
if (const auto update = UpdateArray(cur_state.samplers, samplers)) {
|
||||
glBindSamplers(update->first, update->second, samplers.data() + update->first);
|
||||
}
|
||||
}
|
||||
bool has_delta{};
|
||||
std::size_t first{};
|
||||
std::size_t last{};
|
||||
std::array<GLuint, Maxwell::NumTextureSamplers> samplers;
|
||||
|
||||
void OpenGLState::ApplyImages() const {
|
||||
if (const auto update = UpdateArray(cur_state.images, images)) {
|
||||
glBindImageTextures(update->first, update->second, images.data() + update->first);
|
||||
for (std::size_t i = 0; i < std::size(samplers); ++i) {
|
||||
samplers[i] = texture_units[i].sampler;
|
||||
if (cur_state.texture_units[i].sampler == texture_units[i].sampler) {
|
||||
continue;
|
||||
}
|
||||
cur_state.texture_units[i].sampler = texture_units[i].sampler;
|
||||
if (!has_delta) {
|
||||
first = i;
|
||||
has_delta = true;
|
||||
}
|
||||
last = i;
|
||||
}
|
||||
if (has_delta) {
|
||||
glBindSamplers(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1),
|
||||
samplers.data() + first);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -559,7 +576,6 @@ void OpenGLState::Apply() {
|
||||
ApplyLogicOp();
|
||||
ApplyTextures();
|
||||
ApplySamplers();
|
||||
ApplyImages();
|
||||
if (dirty.polygon_offset) {
|
||||
ApplyPolygonOffset();
|
||||
dirty.polygon_offset = false;
|
||||
@@ -590,18 +606,18 @@ void OpenGLState::EmulateViewportWithScissor() {
|
||||
}
|
||||
|
||||
OpenGLState& OpenGLState::UnbindTexture(GLuint handle) {
|
||||
for (auto& texture : textures) {
|
||||
if (texture == handle) {
|
||||
texture = 0;
|
||||
for (auto& unit : texture_units) {
|
||||
if (unit.texture == handle) {
|
||||
unit.Unbind();
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
OpenGLState& OpenGLState::ResetSampler(GLuint handle) {
|
||||
for (auto& sampler : samplers) {
|
||||
if (sampler == handle) {
|
||||
sampler = 0;
|
||||
for (auto& unit : texture_units) {
|
||||
if (unit.sampler == handle) {
|
||||
unit.sampler = 0;
|
||||
}
|
||||
}
|
||||
return *this;
|
||||
|
||||
@@ -118,9 +118,21 @@ public:
|
||||
GLenum operation;
|
||||
} logic_op;
|
||||
|
||||
std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> textures{};
|
||||
std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> samplers{};
|
||||
std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumImages> images{};
|
||||
// 3 texture units - one for each that is used in PICA fragment shader emulation
|
||||
struct TextureUnit {
|
||||
GLuint texture; // GL_TEXTURE_BINDING_2D
|
||||
GLuint sampler; // GL_SAMPLER_BINDING
|
||||
|
||||
void Unbind() {
|
||||
texture = 0;
|
||||
}
|
||||
|
||||
void Reset() {
|
||||
Unbind();
|
||||
sampler = 0;
|
||||
}
|
||||
};
|
||||
std::array<TextureUnit, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_units;
|
||||
|
||||
struct {
|
||||
GLuint read_framebuffer; // GL_READ_FRAMEBUFFER_BINDING
|
||||
@@ -208,7 +220,6 @@ public:
|
||||
void ApplyLogicOp() const;
|
||||
void ApplyTextures() const;
|
||||
void ApplySamplers() const;
|
||||
void ApplyImages() const;
|
||||
void ApplyDepthClamp() const;
|
||||
void ApplyPolygonOffset() const;
|
||||
void ApplyAlphaTest() const;
|
||||
|
||||
@@ -78,17 +78,6 @@ public:
|
||||
/// Attaches this texture view to the current bound GL_DRAW_FRAMEBUFFER
|
||||
void Attach(GLenum attachment, GLenum target) const;
|
||||
|
||||
void ApplySwizzle(Tegra::Texture::SwizzleSource x_source,
|
||||
Tegra::Texture::SwizzleSource y_source,
|
||||
Tegra::Texture::SwizzleSource z_source,
|
||||
Tegra::Texture::SwizzleSource w_source);
|
||||
|
||||
void DecorateViewName(GPUVAddr gpu_addr, std::string prefix);
|
||||
|
||||
void MarkAsModified(u64 tick) {
|
||||
surface.MarkAsModified(true, tick);
|
||||
}
|
||||
|
||||
GLuint GetTexture() const {
|
||||
if (is_proxy) {
|
||||
return surface.GetTexture();
|
||||
@@ -100,6 +89,13 @@ public:
|
||||
return surface.GetSurfaceParams();
|
||||
}
|
||||
|
||||
void ApplySwizzle(Tegra::Texture::SwizzleSource x_source,
|
||||
Tegra::Texture::SwizzleSource y_source,
|
||||
Tegra::Texture::SwizzleSource z_source,
|
||||
Tegra::Texture::SwizzleSource w_source);
|
||||
|
||||
void DecorateViewName(GPUVAddr gpu_addr, std::string prefix);
|
||||
|
||||
private:
|
||||
u32 EncodeSwizzle(Tegra::Texture::SwizzleSource x_source,
|
||||
Tegra::Texture::SwizzleSource y_source,
|
||||
@@ -115,8 +111,8 @@ private:
|
||||
GLenum target{};
|
||||
|
||||
OGLTextureView texture_view;
|
||||
u32 swizzle{};
|
||||
bool is_proxy{};
|
||||
u32 swizzle;
|
||||
bool is_proxy;
|
||||
};
|
||||
|
||||
class TextureCacheOpenGL final : public TextureCacheBase {
|
||||
|
||||
@@ -342,7 +342,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
|
||||
ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v),
|
||||
}};
|
||||
|
||||
state.textures[0] = screen_info.display_texture;
|
||||
state.texture_units[0].texture = screen_info.display_texture;
|
||||
// Workaround brigthness problems in SMO by enabling sRGB in the final output
|
||||
// if it has been used in the frame. Needed because of this bug in QT: QTBUG-50987
|
||||
state.framebuffer_srgb.enabled = OpenGLState::GetsRGBUsed();
|
||||
@@ -352,7 +352,7 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
// Restore default state
|
||||
state.framebuffer_srgb.enabled = false;
|
||||
state.textures[0] = 0;
|
||||
state.texture_units[0].texture = 0;
|
||||
state.AllDirty();
|
||||
state.Apply();
|
||||
// Clear sRGB state for the next frame
|
||||
|
||||
@@ -61,54 +61,56 @@ u32 ShaderIR::DecodeImage(NodeBlock& bb, u32 pc) {
|
||||
}
|
||||
|
||||
const auto type{instr.sust.image_type};
|
||||
auto& image{instr.sust.is_immediate ? GetImage(instr.image, type)
|
||||
: GetBindlessImage(instr.gpr39, type)};
|
||||
image.MarkWrite();
|
||||
|
||||
const auto& image{instr.sust.is_immediate ? GetImage(instr.image, type)
|
||||
: GetBindlessImage(instr.gpr39, type)};
|
||||
MetaImage meta{image, values};
|
||||
const Node store{Operation(OperationCode::ImageStore, meta, std::move(coords))};
|
||||
bb.push_back(store);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNIMPLEMENTED_MSG("Unhandled image instruction: {}", opcode->get().GetName());
|
||||
UNIMPLEMENTED_MSG("Unhandled conversion instruction: {}", opcode->get().GetName());
|
||||
}
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) {
|
||||
const auto offset{static_cast<u64>(image.index.Value())};
|
||||
const Image& ShaderIR::GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type) {
|
||||
const auto offset{static_cast<std::size_t>(image.index.Value())};
|
||||
|
||||
// If this image has already been used, return the existing mapping.
|
||||
const auto it = used_images.find(offset);
|
||||
if (it != used_images.end()) {
|
||||
ASSERT(it->second.GetType() == type);
|
||||
return it->second;
|
||||
const auto itr{std::find_if(used_images.begin(), used_images.end(),
|
||||
[=](const Image& entry) { return entry.GetOffset() == offset; })};
|
||||
if (itr != used_images.end()) {
|
||||
ASSERT(itr->GetType() == type);
|
||||
return *itr;
|
||||
}
|
||||
|
||||
// Otherwise create a new mapping for this image.
|
||||
const std::size_t next_index{used_images.size()};
|
||||
return used_images.emplace(offset, Image{offset, next_index, type}).first->second;
|
||||
const Image entry{offset, next_index, type};
|
||||
return *used_images.emplace(entry).first;
|
||||
}
|
||||
|
||||
Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type) {
|
||||
const Image& ShaderIR::GetBindlessImage(Tegra::Shader::Register reg,
|
||||
Tegra::Shader::ImageType type) {
|
||||
const Node image_register{GetRegister(reg)};
|
||||
const auto [base_image, cbuf_index, cbuf_offset]{
|
||||
TrackCbuf(image_register, global_code, static_cast<s64>(global_code.size()))};
|
||||
const auto cbuf_key{(static_cast<u64>(cbuf_index) << 32) | static_cast<u64>(cbuf_offset)};
|
||||
|
||||
// If this image has already been used, return the existing mapping.
|
||||
const auto it = used_images.find(cbuf_key);
|
||||
if (it != used_images.end()) {
|
||||
ASSERT(it->second.GetType() == type);
|
||||
return it->second;
|
||||
const auto itr{std::find_if(used_images.begin(), used_images.end(),
|
||||
[=](const Image& entry) { return entry.GetOffset() == cbuf_key; })};
|
||||
if (itr != used_images.end()) {
|
||||
ASSERT(itr->GetType() == type);
|
||||
return *itr;
|
||||
}
|
||||
|
||||
// Otherwise create a new mapping for this image.
|
||||
const std::size_t next_index{used_images.size()};
|
||||
return used_images.emplace(cbuf_key, Image{cbuf_index, cbuf_offset, next_index, type})
|
||||
.first->second;
|
||||
const Image entry{cbuf_index, cbuf_offset, next_index, type};
|
||||
return *used_images.emplace(entry).first;
|
||||
}
|
||||
|
||||
} // namespace VideoCommon::Shader
|
||||
|
||||
@@ -17,8 +17,8 @@ u32 ShaderIR::DecodeShift(NodeBlock& bb, u32 pc) {
|
||||
const Instruction instr = {program_code[pc]};
|
||||
const auto opcode = OpCode::Decode(instr);
|
||||
|
||||
Node op_a = GetRegister(instr.gpr8);
|
||||
Node op_b = [&]() {
|
||||
const Node op_a = GetRegister(instr.gpr8);
|
||||
const Node op_b = [&]() {
|
||||
if (instr.is_b_imm) {
|
||||
return Immediate(instr.alu.GetSignedImm20_20());
|
||||
} else if (instr.is_b_gpr) {
|
||||
@@ -32,23 +32,16 @@ u32 ShaderIR::DecodeShift(NodeBlock& bb, u32 pc) {
|
||||
case OpCode::Id::SHR_C:
|
||||
case OpCode::Id::SHR_R:
|
||||
case OpCode::Id::SHR_IMM: {
|
||||
if (instr.shr.wrap) {
|
||||
op_b = Operation(OperationCode::UBitwiseAnd, std::move(op_b), Immediate(0x1f));
|
||||
} else {
|
||||
op_b = Operation(OperationCode::IMax, std::move(op_b), Immediate(0));
|
||||
op_b = Operation(OperationCode::IMin, std::move(op_b), Immediate(31));
|
||||
}
|
||||
|
||||
Node value = SignedOperation(OperationCode::IArithmeticShiftRight, instr.shift.is_signed,
|
||||
std::move(op_a), std::move(op_b));
|
||||
const Node value = SignedOperation(OperationCode::IArithmeticShiftRight,
|
||||
instr.shift.is_signed, PRECISE, op_a, op_b);
|
||||
SetInternalFlagsFromInteger(bb, value, instr.generates_cc);
|
||||
SetRegister(bb, instr.gpr0, std::move(value));
|
||||
SetRegister(bb, instr.gpr0, value);
|
||||
break;
|
||||
}
|
||||
case OpCode::Id::SHL_C:
|
||||
case OpCode::Id::SHL_R:
|
||||
case OpCode::Id::SHL_IMM: {
|
||||
const Node value = Operation(OperationCode::ILogicalShiftLeft, op_a, op_b);
|
||||
const Node value = Operation(OperationCode::ILogicalShiftLeft, PRECISE, op_a, op_b);
|
||||
SetInternalFlagsFromInteger(bb, value, instr.generates_cc);
|
||||
SetRegister(bb, instr.gpr0, value);
|
||||
break;
|
||||
|
||||
@@ -273,64 +273,46 @@ private:
|
||||
bool is_bindless{}; ///< Whether this sampler belongs to a bindless texture or not.
|
||||
};
|
||||
|
||||
class Image final {
|
||||
class Image {
|
||||
public:
|
||||
constexpr explicit Image(u64 offset, std::size_t index, Tegra::Shader::ImageType type)
|
||||
explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{false} {}
|
||||
|
||||
constexpr explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index,
|
||||
Tegra::Shader::ImageType type)
|
||||
explicit Image(u32 cbuf_index, u32 cbuf_offset, std::size_t index,
|
||||
Tegra::Shader::ImageType type)
|
||||
: offset{(static_cast<u64>(cbuf_index) << 32) | cbuf_offset}, index{index}, type{type},
|
||||
is_bindless{true} {}
|
||||
|
||||
constexpr explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
|
||||
bool is_bindless, bool is_written, bool is_read)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{is_bindless},
|
||||
is_written{is_written}, is_read{is_read} {}
|
||||
explicit Image(std::size_t offset, std::size_t index, Tegra::Shader::ImageType type,
|
||||
bool is_bindless)
|
||||
: offset{offset}, index{index}, type{type}, is_bindless{is_bindless} {}
|
||||
|
||||
void MarkRead() {
|
||||
is_read = true;
|
||||
}
|
||||
|
||||
void MarkWrite() {
|
||||
is_written = true;
|
||||
}
|
||||
|
||||
constexpr std::size_t GetOffset() const {
|
||||
std::size_t GetOffset() const {
|
||||
return offset;
|
||||
}
|
||||
|
||||
constexpr std::size_t GetIndex() const {
|
||||
std::size_t GetIndex() const {
|
||||
return index;
|
||||
}
|
||||
|
||||
constexpr Tegra::Shader::ImageType GetType() const {
|
||||
Tegra::Shader::ImageType GetType() const {
|
||||
return type;
|
||||
}
|
||||
|
||||
constexpr bool IsBindless() const {
|
||||
bool IsBindless() const {
|
||||
return is_bindless;
|
||||
}
|
||||
|
||||
constexpr bool IsRead() const {
|
||||
return is_read;
|
||||
}
|
||||
|
||||
constexpr bool IsWritten() const {
|
||||
return is_written;
|
||||
}
|
||||
|
||||
constexpr std::pair<u32, u32> GetBindlessCBuf() const {
|
||||
return {static_cast<u32>(offset >> 32), static_cast<u32>(offset)};
|
||||
bool operator<(const Image& rhs) const {
|
||||
return std::tie(offset, index, type, is_bindless) <
|
||||
std::tie(rhs.offset, rhs.index, rhs.type, rhs.is_bindless);
|
||||
}
|
||||
|
||||
private:
|
||||
u64 offset{};
|
||||
std::size_t offset{};
|
||||
std::size_t index{};
|
||||
Tegra::Shader::ImageType type{};
|
||||
bool is_bindless{};
|
||||
bool is_read{};
|
||||
bool is_written{};
|
||||
};
|
||||
|
||||
struct GlobalMemoryBase {
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
return used_samplers;
|
||||
}
|
||||
|
||||
const std::map<u64, Image>& GetImages() const {
|
||||
const std::set<Image>& GetImages() const {
|
||||
return used_images;
|
||||
}
|
||||
|
||||
@@ -272,10 +272,10 @@ private:
|
||||
bool is_shadow);
|
||||
|
||||
/// Accesses an image.
|
||||
Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type);
|
||||
const Image& GetImage(Tegra::Shader::Image image, Tegra::Shader::ImageType type);
|
||||
|
||||
/// Access a bindless image sampler.
|
||||
Image& GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type);
|
||||
const Image& GetBindlessImage(Tegra::Shader::Register reg, Tegra::Shader::ImageType type);
|
||||
|
||||
/// Extracts a sequence of bits from a node
|
||||
Node BitfieldExtract(Node value, u32 offset, u32 bits);
|
||||
@@ -356,7 +356,7 @@ private:
|
||||
std::set<Tegra::Shader::Attribute::Index> used_output_attributes;
|
||||
std::map<u32, ConstBuffer> used_cbufs;
|
||||
std::set<Sampler> used_samplers;
|
||||
std::map<u64, Image> used_images;
|
||||
std::set<Image> used_images;
|
||||
std::array<bool, Tegra::Engines::Maxwell3D::Regs::NumClipDistances> used_clip_distances{};
|
||||
std::map<GlobalMemoryBase, GlobalMemoryUsage> used_global_memory;
|
||||
bool uses_layer{};
|
||||
|
||||
@@ -513,26 +513,6 @@ bool IsPixelFormatASTC(PixelFormat format) {
|
||||
}
|
||||
}
|
||||
|
||||
bool IsPixelFormatSRGB(PixelFormat format) {
|
||||
switch (format) {
|
||||
case PixelFormat::RGBA8_SRGB:
|
||||
case PixelFormat::BGRA8_SRGB:
|
||||
case PixelFormat::DXT1_SRGB:
|
||||
case PixelFormat::DXT23_SRGB:
|
||||
case PixelFormat::DXT45_SRGB:
|
||||
case PixelFormat::BC7U_SRGB:
|
||||
case PixelFormat::ASTC_2D_4X4_SRGB:
|
||||
case PixelFormat::ASTC_2D_8X8_SRGB:
|
||||
case PixelFormat::ASTC_2D_8X5_SRGB:
|
||||
case PixelFormat::ASTC_2D_5X4_SRGB:
|
||||
case PixelFormat::ASTC_2D_5X5_SRGB:
|
||||
case PixelFormat::ASTC_2D_10X8_SRGB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format) {
|
||||
return {GetDefaultBlockWidth(format), GetDefaultBlockHeight(format)};
|
||||
}
|
||||
|
||||
@@ -547,8 +547,6 @@ SurfaceType GetFormatType(PixelFormat pixel_format);
|
||||
|
||||
bool IsPixelFormatASTC(PixelFormat format);
|
||||
|
||||
bool IsPixelFormatSRGB(PixelFormat format);
|
||||
|
||||
std::pair<u32, u32> GetASTCBlockSize(PixelFormat format);
|
||||
|
||||
/// Returns true if the specified PixelFormat is a BCn format, e.g. DXT or DXN
|
||||
|
||||
@@ -195,18 +195,18 @@ public:
|
||||
|
||||
virtual void DownloadTexture(std::vector<u8>& staging_buffer) = 0;
|
||||
|
||||
void MarkAsModified(bool is_modified_, u64 tick) {
|
||||
void MarkAsModified(const bool is_modified_, const u64 tick) {
|
||||
is_modified = is_modified_ || is_target;
|
||||
modification_tick = tick;
|
||||
}
|
||||
|
||||
void MarkAsRenderTarget(bool is_target_, u32 index_) {
|
||||
is_target = is_target_;
|
||||
index = index_;
|
||||
void MarkAsRenderTarget(const bool is_target, const u32 index) {
|
||||
this->is_target = is_target;
|
||||
this->index = index;
|
||||
}
|
||||
|
||||
void MarkAsPicked(bool is_picked_) {
|
||||
is_picked = is_picked_;
|
||||
void MarkAsPicked(const bool is_picked) {
|
||||
this->is_picked = is_picked;
|
||||
}
|
||||
|
||||
bool IsModified() const {
|
||||
|
||||
@@ -24,62 +24,55 @@ using VideoCore::Surface::SurfaceTarget;
|
||||
using VideoCore::Surface::SurfaceTargetFromTextureType;
|
||||
using VideoCore::Surface::SurfaceType;
|
||||
|
||||
namespace {
|
||||
|
||||
SurfaceTarget TextureTypeToSurfaceTarget(Tegra::Shader::TextureType type, bool is_array) {
|
||||
SurfaceTarget TextureType2SurfaceTarget(Tegra::Shader::TextureType type, bool is_array) {
|
||||
switch (type) {
|
||||
case Tegra::Shader::TextureType::Texture1D:
|
||||
return is_array ? SurfaceTarget::Texture1DArray : SurfaceTarget::Texture1D;
|
||||
case Tegra::Shader::TextureType::Texture2D:
|
||||
return is_array ? SurfaceTarget::Texture2DArray : SurfaceTarget::Texture2D;
|
||||
case Tegra::Shader::TextureType::Texture3D:
|
||||
case Tegra::Shader::TextureType::Texture1D: {
|
||||
if (is_array)
|
||||
return SurfaceTarget::Texture1DArray;
|
||||
else
|
||||
return SurfaceTarget::Texture1D;
|
||||
}
|
||||
case Tegra::Shader::TextureType::Texture2D: {
|
||||
if (is_array)
|
||||
return SurfaceTarget::Texture2DArray;
|
||||
else
|
||||
return SurfaceTarget::Texture2D;
|
||||
}
|
||||
case Tegra::Shader::TextureType::Texture3D: {
|
||||
ASSERT(!is_array);
|
||||
return SurfaceTarget::Texture3D;
|
||||
case Tegra::Shader::TextureType::TextureCube:
|
||||
return is_array ? SurfaceTarget::TextureCubeArray : SurfaceTarget::TextureCubemap;
|
||||
default:
|
||||
}
|
||||
case Tegra::Shader::TextureType::TextureCube: {
|
||||
if (is_array)
|
||||
return SurfaceTarget::TextureCubeArray;
|
||||
else
|
||||
return SurfaceTarget::TextureCubemap;
|
||||
}
|
||||
default: {
|
||||
UNREACHABLE();
|
||||
return SurfaceTarget::Texture2D;
|
||||
}
|
||||
}
|
||||
|
||||
SurfaceTarget ImageTypeToSurfaceTarget(Tegra::Shader::ImageType type) {
|
||||
switch (type) {
|
||||
case Tegra::Shader::ImageType::Texture1D:
|
||||
return SurfaceTarget::Texture1D;
|
||||
case Tegra::Shader::ImageType::TextureBuffer:
|
||||
return SurfaceTarget::TextureBuffer;
|
||||
case Tegra::Shader::ImageType::Texture1DArray:
|
||||
return SurfaceTarget::Texture1DArray;
|
||||
case Tegra::Shader::ImageType::Texture2D:
|
||||
return SurfaceTarget::Texture2D;
|
||||
case Tegra::Shader::ImageType::Texture2DArray:
|
||||
return SurfaceTarget::Texture2DArray;
|
||||
case Tegra::Shader::ImageType::Texture3D:
|
||||
return SurfaceTarget::Texture3D;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return SurfaceTarget::Texture2D;
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
constexpr u32 GetMipmapSize(bool uncompressed, u32 mip_size, u32 tile) {
|
||||
return uncompressed ? mip_size : std::max(1U, (mip_size + tile - 1) / tile);
|
||||
}
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& tic,
|
||||
SurfaceParams SurfaceParams::CreateForTexture(Core::System& system,
|
||||
const Tegra::Texture::FullTextureInfo& config,
|
||||
const VideoCommon::Shader::Sampler& entry) {
|
||||
SurfaceParams params;
|
||||
params.is_tiled = tic.IsTiled();
|
||||
params.srgb_conversion = tic.IsSrgbConversionEnabled();
|
||||
params.block_width = params.is_tiled ? tic.BlockWidth() : 0,
|
||||
params.block_height = params.is_tiled ? tic.BlockHeight() : 0,
|
||||
params.block_depth = params.is_tiled ? tic.BlockDepth() : 0,
|
||||
params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
|
||||
params.pixel_format =
|
||||
PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion);
|
||||
params.is_tiled = config.tic.IsTiled();
|
||||
params.srgb_conversion = config.tic.IsSrgbConversionEnabled();
|
||||
params.block_width = params.is_tiled ? config.tic.BlockWidth() : 0,
|
||||
params.block_height = params.is_tiled ? config.tic.BlockHeight() : 0,
|
||||
params.block_depth = params.is_tiled ? config.tic.BlockDepth() : 0,
|
||||
params.tile_width_spacing = params.is_tiled ? (1 << config.tic.tile_width_spacing.Value()) : 1;
|
||||
params.pixel_format = PixelFormatFromTextureFormat(config.tic.format, config.tic.r_type.Value(),
|
||||
params.srgb_conversion);
|
||||
params.type = GetFormatType(params.pixel_format);
|
||||
if (entry.IsShadow() && params.type == SurfaceType::ColorTexture) {
|
||||
switch (params.pixel_format) {
|
||||
@@ -99,72 +92,31 @@ SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& ti
|
||||
}
|
||||
params.type = GetFormatType(params.pixel_format);
|
||||
}
|
||||
params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
|
||||
params.component_type = ComponentTypeFromTexture(config.tic.r_type.Value());
|
||||
params.type = GetFormatType(params.pixel_format);
|
||||
// TODO: on 1DBuffer we should use the tic info.
|
||||
if (tic.IsBuffer()) {
|
||||
if (!config.tic.IsBuffer()) {
|
||||
params.target = TextureType2SurfaceTarget(entry.GetType(), entry.IsArray());
|
||||
params.width = config.tic.Width();
|
||||
params.height = config.tic.Height();
|
||||
params.depth = config.tic.Depth();
|
||||
params.pitch = params.is_tiled ? 0 : config.tic.Pitch();
|
||||
if (params.target == SurfaceTarget::TextureCubemap ||
|
||||
params.target == SurfaceTarget::TextureCubeArray) {
|
||||
params.depth *= 6;
|
||||
}
|
||||
params.num_levels = config.tic.max_mip_level + 1;
|
||||
params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap());
|
||||
params.is_layered = params.IsLayered();
|
||||
} else {
|
||||
params.target = SurfaceTarget::TextureBuffer;
|
||||
params.width = tic.Width();
|
||||
params.width = config.tic.Width();
|
||||
params.pitch = params.width * params.GetBytesPerPixel();
|
||||
params.height = 1;
|
||||
params.depth = 1;
|
||||
params.num_levels = 1;
|
||||
params.emulated_levels = 1;
|
||||
params.is_layered = false;
|
||||
} else {
|
||||
params.target = TextureTypeToSurfaceTarget(entry.GetType(), entry.IsArray());
|
||||
params.width = tic.Width();
|
||||
params.height = tic.Height();
|
||||
params.depth = tic.Depth();
|
||||
params.pitch = params.is_tiled ? 0 : tic.Pitch();
|
||||
if (params.target == SurfaceTarget::TextureCubemap ||
|
||||
params.target == SurfaceTarget::TextureCubeArray) {
|
||||
params.depth *= 6;
|
||||
}
|
||||
params.num_levels = tic.max_mip_level + 1;
|
||||
params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap());
|
||||
params.is_layered = params.IsLayered();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic,
|
||||
const VideoCommon::Shader::Image& entry) {
|
||||
SurfaceParams params;
|
||||
params.is_tiled = tic.IsTiled();
|
||||
params.srgb_conversion = tic.IsSrgbConversionEnabled();
|
||||
params.block_width = params.is_tiled ? tic.BlockWidth() : 0,
|
||||
params.block_height = params.is_tiled ? tic.BlockHeight() : 0,
|
||||
params.block_depth = params.is_tiled ? tic.BlockDepth() : 0,
|
||||
params.tile_width_spacing = params.is_tiled ? (1 << tic.tile_width_spacing.Value()) : 1;
|
||||
params.pixel_format =
|
||||
PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion);
|
||||
params.type = GetFormatType(params.pixel_format);
|
||||
params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
|
||||
params.type = GetFormatType(params.pixel_format);
|
||||
params.target = ImageTypeToSurfaceTarget(entry.GetType());
|
||||
// TODO: on 1DBuffer we should use the tic info.
|
||||
if (tic.IsBuffer()) {
|
||||
params.target = SurfaceTarget::TextureBuffer;
|
||||
params.width = tic.Width();
|
||||
params.pitch = params.width * params.GetBytesPerPixel();
|
||||
params.height = 1;
|
||||
params.depth = 1;
|
||||
params.num_levels = 1;
|
||||
params.emulated_levels = 1;
|
||||
params.is_layered = false;
|
||||
} else {
|
||||
params.width = tic.Width();
|
||||
params.height = tic.Height();
|
||||
params.depth = tic.Depth();
|
||||
params.pitch = params.is_tiled ? 0 : tic.Pitch();
|
||||
if (params.target == SurfaceTarget::TextureCubemap ||
|
||||
params.target == SurfaceTarget::TextureCubeArray) {
|
||||
params.depth *= 6;
|
||||
}
|
||||
params.num_levels = tic.max_mip_level + 1;
|
||||
params.emulated_levels = std::min(params.num_levels, params.MaxPossibleMipmap());
|
||||
params.is_layered = params.IsLayered();
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "common/alignment.h"
|
||||
#include "common/bit_util.h"
|
||||
#include "common/cityhash.h"
|
||||
@@ -21,13 +23,10 @@ using VideoCore::Surface::SurfaceCompression;
|
||||
class SurfaceParams {
|
||||
public:
|
||||
/// Creates SurfaceCachedParams from a texture configuration.
|
||||
static SurfaceParams CreateForTexture(const Tegra::Texture::TICEntry& tic,
|
||||
static SurfaceParams CreateForTexture(Core::System& system,
|
||||
const Tegra::Texture::FullTextureInfo& config,
|
||||
const VideoCommon::Shader::Sampler& entry);
|
||||
|
||||
/// Creates SurfaceCachedParams from an image configuration.
|
||||
static SurfaceParams CreateForImage(const Tegra::Texture::TICEntry& tic,
|
||||
const VideoCommon::Shader::Image& entry);
|
||||
|
||||
/// Creates SurfaceCachedParams for a depth buffer configuration.
|
||||
static SurfaceParams CreateForDepthBuffer(
|
||||
Core::System& system, u32 zeta_width, u32 zeta_height, Tegra::DepthFormat format,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
namespace VideoCommon {
|
||||
|
||||
std::size_t ViewParams::Hash() const {
|
||||
return static_cast<std::size_t>(base_layer) ^ (static_cast<std::size_t>(num_layers) << 16) ^
|
||||
return static_cast<std::size_t>(base_layer) ^ static_cast<std::size_t>(num_layers << 16) ^
|
||||
(static_cast<std::size_t>(base_level) << 24) ^
|
||||
(static_cast<std::size_t>(num_levels) << 32) ^ (static_cast<std::size_t>(target) << 36);
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
namespace VideoCommon {
|
||||
|
||||
struct ViewParams {
|
||||
constexpr explicit ViewParams(VideoCore::Surface::SurfaceTarget target, u32 base_layer,
|
||||
u32 num_layers, u32 base_level, u32 num_levels)
|
||||
ViewParams(VideoCore::Surface::SurfaceTarget target, u32 base_layer, u32 num_layers,
|
||||
u32 base_level, u32 num_levels)
|
||||
: target{target}, base_layer{base_layer}, num_layers{num_layers}, base_level{base_level},
|
||||
num_levels{num_levels} {}
|
||||
|
||||
@@ -22,6 +22,12 @@ struct ViewParams {
|
||||
|
||||
bool operator==(const ViewParams& rhs) const;
|
||||
|
||||
VideoCore::Surface::SurfaceTarget target{};
|
||||
u32 base_layer{};
|
||||
u32 num_layers{};
|
||||
u32 base_level{};
|
||||
u32 num_levels{};
|
||||
|
||||
bool IsLayered() const {
|
||||
switch (target) {
|
||||
case VideoCore::Surface::SurfaceTarget::Texture1DArray:
|
||||
@@ -33,19 +39,13 @@ struct ViewParams {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
VideoCore::Surface::SurfaceTarget target{};
|
||||
u32 base_layer{};
|
||||
u32 num_layers{};
|
||||
u32 base_level{};
|
||||
u32 num_levels{};
|
||||
};
|
||||
|
||||
class ViewBase {
|
||||
public:
|
||||
constexpr explicit ViewBase(const ViewParams& params) : params{params} {}
|
||||
ViewBase(const ViewParams& params) : params{params} {}
|
||||
|
||||
constexpr const ViewParams& GetViewParams() const {
|
||||
const ViewParams& GetViewParams() const {
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,29 +89,14 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
TView GetTextureSurface(const Tegra::Texture::TICEntry& tic,
|
||||
TView GetTextureSurface(const Tegra::Texture::FullTextureInfo& config,
|
||||
const VideoCommon::Shader::Sampler& entry) {
|
||||
std::lock_guard lock{mutex};
|
||||
const auto gpu_addr{tic.Address()};
|
||||
const auto gpu_addr{config.tic.Address()};
|
||||
if (!gpu_addr) {
|
||||
return {};
|
||||
}
|
||||
const auto params{SurfaceParams::CreateForTexture(tic, entry)};
|
||||
const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
|
||||
if (guard_samplers) {
|
||||
sampled_textures.push_back(surface);
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
TView GetImageSurface(const Tegra::Texture::TICEntry& tic,
|
||||
const VideoCommon::Shader::Image& entry) {
|
||||
std::lock_guard lock{mutex};
|
||||
const auto gpu_addr{tic.Address()};
|
||||
if (!gpu_addr) {
|
||||
return {};
|
||||
}
|
||||
const auto params{SurfaceParams::CreateForImage(tic, entry)};
|
||||
const auto params{SurfaceParams::CreateForTexture(system, config, entry)};
|
||||
const auto [surface, view] = GetSurface(gpu_addr, params, true, false);
|
||||
if (guard_samplers) {
|
||||
sampled_textures.push_back(surface);
|
||||
|
||||
Reference in New Issue
Block a user