summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/logging/backend.cpp4
-rw-r--r--src/core/hle/kernel/shared_memory.cpp8
-rw-r--r--src/core/hle/kernel/svc.cpp20
-rw-r--r--src/core/hle/kernel/vm_manager.cpp4
-rw-r--r--src/core/hle/kernel/vm_manager.h26
-rw-r--r--src/core/hle/service/ldr/ldr.cpp9
-rw-r--r--src/core/hle/service/service.cpp19
-rw-r--r--src/core/hle/service/sm/sm.cpp8
-rw-r--r--src/core/loader/deconstructed_rom_directory.h2
-rw-r--r--src/core/loader/elf.h2
-rw-r--r--src/core/loader/loader.h2
-rw-r--r--src/core/loader/nax.cpp2
-rw-r--r--src/core/loader/nax.h2
-rw-r--r--src/core/loader/nca.h2
-rw-r--r--src/core/loader/nro.h2
-rw-r--r--src/core/loader/nso.h2
-rw-r--r--src/core/loader/nsp.h2
-rw-r--r--src/core/loader/xci.h2
-rw-r--r--src/core/memory.cpp11
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp240
-rw-r--r--src/yuzu/game_list_worker.cpp24
21 files changed, 215 insertions, 178 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 5753b871a..12f6d0114 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -13,7 +13,7 @@
#include <vector>
#ifdef _WIN32
#include <share.h> // For _SH_DENYWR
-#include <windows.h> // For OutputDebugStringA
+#include <windows.h> // For OutputDebugStringW
#else
#define _SH_DENYWR 0
#endif
@@ -148,7 +148,7 @@ void FileBackend::Write(const Entry& entry) {
void DebuggerBackend::Write(const Entry& entry) {
#ifdef _WIN32
- ::OutputDebugStringA(FormatLogMessage(entry).append(1, '\n').c_str());
+ ::OutputDebugStringW(Common::UTF8ToUTF16W(FormatLogMessage(entry).append(1, '\n')).c_str());
#endif
}
diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp
index 0494581f5..d1ca60125 100644
--- a/src/core/hle/kernel/shared_memory.cpp
+++ b/src/core/hle/kernel/shared_memory.cpp
@@ -39,15 +39,15 @@ SharedPtr<SharedMemory> SharedMemory::Create(KernelCore& kernel, SharedPtr<Proce
shared_memory->backing_block.get());
}
} else {
- auto& vm_manager = shared_memory->owner_process->VMManager();
+ const auto& vm_manager = shared_memory->owner_process->VMManager();
// The memory is already available and mapped in the owner process.
- auto vma = vm_manager.FindVMA(address);
- ASSERT_MSG(vma != vm_manager.vma_map.end(), "Invalid memory address");
+ const auto vma = vm_manager.FindVMA(address);
+ ASSERT_MSG(vm_manager.IsValidHandle(vma), "Invalid memory address");
ASSERT_MSG(vma->second.backing_block, "Backing block doesn't exist for address");
// The returned VMA might be a bigger one encompassing the desired address.
- auto vma_offset = address - vma->first;
+ const auto vma_offset = address - vma->first;
ASSERT_MSG(vma_offset + size <= vma->second.size,
"Shared memory exceeds bounds of mapped block");
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 84df2040e..f43c7201c 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -239,7 +239,7 @@ static ResultCode SetMemoryPermission(VAddr addr, u64 size, u32 prot) {
}
const VMManager::VMAHandle iter = vm_manager.FindVMA(addr);
- if (iter == vm_manager.vma_map.end()) {
+ if (!vm_manager.IsValidHandle(iter)) {
LOG_ERROR(Kernel_SVC, "Unable to find VMA for address=0x{:016X}", addr);
return ERR_INVALID_ADDRESS_STATE;
}
@@ -1077,19 +1077,23 @@ static ResultCode QueryProcessMemory(MemoryInfo* memory_info, PageInfo* /*page_i
process_handle);
return ERR_INVALID_HANDLE;
}
- auto vma = process->VMManager().FindVMA(addr);
+
+ const auto& vm_manager = process->VMManager();
+ const auto vma = vm_manager.FindVMA(addr);
+
memory_info->attributes = 0;
- if (vma == process->VMManager().vma_map.end()) {
- memory_info->base_address = 0;
- memory_info->permission = static_cast<u32>(VMAPermission::None);
- memory_info->size = 0;
- memory_info->type = static_cast<u32>(MemoryState::Unmapped);
- } else {
+ if (vm_manager.IsValidHandle(vma)) {
memory_info->base_address = vma->second.base;
memory_info->permission = static_cast<u32>(vma->second.permissions);
memory_info->size = vma->second.size;
memory_info->type = static_cast<u32>(vma->second.meminfo_state);
+ } else {
+ memory_info->base_address = 0;
+ memory_info->permission = static_cast<u32>(VMAPermission::None);
+ memory_info->size = 0;
+ memory_info->type = static_cast<u32>(MemoryState::Unmapped);
}
+
return RESULT_SUCCESS;
}
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp
index 100f8f6bf..6187993ce 100644
--- a/src/core/hle/kernel/vm_manager.cpp
+++ b/src/core/hle/kernel/vm_manager.cpp
@@ -87,6 +87,10 @@ VMManager::VMAHandle VMManager::FindVMA(VAddr target) const {
}
}
+bool VMManager::IsValidHandle(VMAHandle handle) const {
+ return handle != vma_map.cend();
+}
+
ResultVal<VMManager::VMAHandle> VMManager::MapMemoryBlock(VAddr target,
std::shared_ptr<std::vector<u8>> block,
std::size_t offset, u64 size,
diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h
index d522404fe..a12419d1e 100644
--- a/src/core/hle/kernel/vm_manager.h
+++ b/src/core/hle/kernel/vm_manager.h
@@ -113,16 +113,10 @@ struct VirtualMemoryArea {
* - http://duartes.org/gustavo/blog/post/page-cache-the-affair-between-memory-and-files/
*/
class VMManager final {
+ using VMAMap = std::map<VAddr, VirtualMemoryArea>;
+
public:
- /**
- * A map covering the entirety of the managed address space, keyed by the `base` field of each
- * VMA. It must always be modified by splitting or merging VMAs, so that the invariant
- * `elem.base + elem.size == next.base` is preserved, and mergeable regions must always be
- * merged when possible so that no two similar and adjacent regions exist that have not been
- * merged.
- */
- std::map<VAddr, VirtualMemoryArea> vma_map;
- using VMAHandle = decltype(vma_map)::const_iterator;
+ using VMAHandle = VMAMap::const_iterator;
VMManager();
~VMManager();
@@ -133,6 +127,9 @@ public:
/// Finds the VMA in which the given address is included in, or `vma_map.end()`.
VMAHandle FindVMA(VAddr target) const;
+ /// Indicates whether or not the given handle is within the VMA map.
+ bool IsValidHandle(VMAHandle handle) const;
+
// TODO(yuriks): Should these functions actually return the handle?
/**
@@ -281,7 +278,7 @@ public:
Memory::PageTable page_table;
private:
- using VMAIter = decltype(vma_map)::iterator;
+ using VMAIter = VMAMap::iterator;
/// Converts a VMAHandle to a mutable VMAIter.
VMAIter StripIterConstness(const VMAHandle& iter);
@@ -328,6 +325,15 @@ private:
/// Clears out the page table
void ClearPageTable();
+ /**
+ * A map covering the entirety of the managed address space, keyed by the `base` field of each
+ * VMA. It must always be modified by splitting or merging VMAs, so that the invariant
+ * `elem.base + elem.size == next.base` is preserved, and mergeable regions must always be
+ * merged when possible so that no two similar and adjacent regions exist that have not been
+ * merged.
+ */
+ VMAMap vma_map;
+
u32 address_space_width = 0;
VAddr address_space_base = 0;
VAddr address_space_end = 0;
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp
index 453d90a22..13bcefe07 100644
--- a/src/core/hle/service/ldr/ldr.cpp
+++ b/src/core/hle/service/ldr/ldr.cpp
@@ -408,13 +408,13 @@ private:
using SHA256Hash = std::array<u8, 0x20>;
struct NROHeader {
- u32_le entrypoint_insn;
+ INSERT_PADDING_WORDS(1);
u32_le mod_offset;
INSERT_PADDING_WORDS(2);
u32_le magic;
- INSERT_PADDING_WORDS(1);
+ u32_le version;
u32_le nro_size;
- INSERT_PADDING_WORDS(1);
+ u32_le flags;
u32_le text_offset;
u32_le text_size;
u32_le ro_offset;
@@ -430,9 +430,10 @@ private:
struct NRRHeader {
u32_le magic;
- INSERT_PADDING_BYTES(0x1C);
+ INSERT_PADDING_BYTES(12);
u64_le title_id_mask;
u64_le title_id_pattern;
+ INSERT_PADDING_BYTES(16);
std::array<u8, 0x100> modulus;
std::array<u8, 0x100> signature_1;
std::array<u8, 0x100> signature_2;
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 1ec340466..d41df3732 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -70,10 +70,6 @@
#include "core/hle/service/vi/vi.h"
#include "core/hle/service/wlan/wlan.h"
-using Kernel::ClientPort;
-using Kernel::ServerPort;
-using Kernel::SharedPtr;
-
namespace Service {
/**
@@ -110,10 +106,8 @@ void ServiceFrameworkBase::InstallAsNamedPort() {
ASSERT(port == nullptr);
auto& kernel = Core::System::GetInstance().Kernel();
- SharedPtr<ServerPort> server_port;
- SharedPtr<ClientPort> client_port;
- std::tie(server_port, client_port) =
- ServerPort::CreatePortPair(kernel, max_sessions, service_name);
+ auto [server_port, client_port] =
+ Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name);
server_port->SetHleHandler(shared_from_this());
kernel.AddNamedPort(service_name, std::move(client_port));
}
@@ -122,11 +116,9 @@ Kernel::SharedPtr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort() {
ASSERT(port == nullptr);
auto& kernel = Core::System::GetInstance().Kernel();
- Kernel::SharedPtr<Kernel::ServerPort> server_port;
- Kernel::SharedPtr<Kernel::ClientPort> client_port;
- std::tie(server_port, client_port) =
+ auto [server_port, client_port] =
Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name);
- port = MakeResult<Kernel::SharedPtr<Kernel::ServerPort>>(std::move(server_port)).Unwrap();
+ port = MakeResult(std::move(server_port)).Unwrap();
port->SetHleHandler(shared_from_this());
return client_port;
}
@@ -152,8 +144,7 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext
}
buf.push_back('}');
- LOG_ERROR(Service, "unknown / unimplemented {}", fmt::to_string(buf));
- UNIMPLEMENTED();
+ UNIMPLEMENTED_MSG("Unknown / unimplemented {}", fmt::to_string(buf));
}
void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) {
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp
index 0d0f63a78..d73530086 100644
--- a/src/core/hle/service/sm/sm.cpp
+++ b/src/core/hle/service/sm/sm.cpp
@@ -54,13 +54,11 @@ ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> ServiceManager::RegisterService
return ERR_ALREADY_REGISTERED;
auto& kernel = Core::System::GetInstance().Kernel();
- Kernel::SharedPtr<Kernel::ServerPort> server_port;
- Kernel::SharedPtr<Kernel::ClientPort> client_port;
- std::tie(server_port, client_port) =
+ auto [server_port, client_port] =
Kernel::ServerPort::CreatePortPair(kernel, max_sessions, name);
registered_services.emplace(std::move(name), std::move(client_port));
- return MakeResult<Kernel::SharedPtr<Kernel::ServerPort>>(std::move(server_port));
+ return MakeResult(std::move(server_port));
}
ResultCode ServiceManager::UnregisterService(const std::string& name) {
@@ -83,7 +81,7 @@ ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> ServiceManager::GetServicePort(
return ERR_SERVICE_NOT_REGISTERED;
}
- return MakeResult<Kernel::SharedPtr<Kernel::ClientPort>>(it->second);
+ return MakeResult(it->second);
}
ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ServiceManager::ConnectToService(
diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h
index d109ed2b5..1615cb5a8 100644
--- a/src/core/loader/deconstructed_rom_directory.h
+++ b/src/core/loader/deconstructed_rom_directory.h
@@ -33,7 +33,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/elf.h b/src/core/loader/elf.h
index 6af76441c..a2d33021c 100644
--- a/src/core/loader/elf.h
+++ b/src/core/loader/elf.h
@@ -22,7 +22,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/loader.h b/src/core/loader/loader.h
index 7686634bf..5390ab9ee 100644
--- a/src/core/loader/loader.h
+++ b/src/core/loader/loader.h
@@ -131,7 +131,7 @@ public:
* Returns the type of this file
* @return FileType corresponding to the loaded file
*/
- virtual FileType GetFileType() = 0;
+ virtual FileType GetFileType() const = 0;
/**
* Load the application and return the created Process instance
diff --git a/src/core/loader/nax.cpp b/src/core/loader/nax.cpp
index 42f4a777b..a093e3d36 100644
--- a/src/core/loader/nax.cpp
+++ b/src/core/loader/nax.cpp
@@ -37,7 +37,7 @@ FileType AppLoader_NAX::IdentifyType(const FileSys::VirtualFile& file) {
return IdentifyTypeImpl(nax);
}
-FileType AppLoader_NAX::GetFileType() {
+FileType AppLoader_NAX::GetFileType() const {
return IdentifyTypeImpl(*nax);
}
diff --git a/src/core/loader/nax.h b/src/core/loader/nax.h
index b4d93bd01..0a97511b8 100644
--- a/src/core/loader/nax.h
+++ b/src/core/loader/nax.h
@@ -31,7 +31,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override;
+ FileType GetFileType() const override;
ResultStatus Load(Kernel::Process& process) override;
diff --git a/src/core/loader/nca.h b/src/core/loader/nca.h
index 95d9b73a1..cbbe701d2 100644
--- a/src/core/loader/nca.h
+++ b/src/core/loader/nca.h
@@ -29,7 +29,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h
index 6deff3a51..013d629c0 100644
--- a/src/core/loader/nro.h
+++ b/src/core/loader/nro.h
@@ -33,7 +33,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/nso.h b/src/core/loader/nso.h
index 0c1defbb6..135b6ea5a 100644
--- a/src/core/loader/nso.h
+++ b/src/core/loader/nso.h
@@ -37,7 +37,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/nsp.h b/src/core/loader/nsp.h
index db91cd01e..9ed8a59cf 100644
--- a/src/core/loader/nsp.h
+++ b/src/core/loader/nsp.h
@@ -31,7 +31,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/loader/xci.h b/src/core/loader/xci.h
index 46f8dfc9e..ded5bb88a 100644
--- a/src/core/loader/xci.h
+++ b/src/core/loader/xci.h
@@ -31,7 +31,7 @@ public:
*/
static FileType IdentifyType(const FileSys::VirtualFile& file);
- FileType GetFileType() override {
+ FileType GetFileType() const override {
return IdentifyType(file);
}
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index 41fd2a6a0..643afdee8 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -125,14 +125,13 @@ void RemoveDebugHook(PageTable& page_table, VAddr base, u64 size, MemoryHookPoin
* using a VMA from the current process
*/
static u8* GetPointerFromVMA(const Kernel::Process& process, VAddr vaddr) {
- u8* direct_pointer = nullptr;
-
- auto& vm_manager = process.VMManager();
+ const auto& vm_manager = process.VMManager();
- auto it = vm_manager.FindVMA(vaddr);
- ASSERT(it != vm_manager.vma_map.end());
+ const auto it = vm_manager.FindVMA(vaddr);
+ DEBUG_ASSERT(vm_manager.IsValidHandle(it));
- auto& vma = it->second;
+ u8* direct_pointer = nullptr;
+ const auto& vma = it->second;
switch (vma.type) {
case Kernel::VMAType::AllocatedMemoryBlock:
direct_pointer = vma.backing_block->data() + vma.offset;
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 4fc09cac6..e7057a9cb 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -1681,7 +1681,7 @@ private:
for (size_t i = 0; i < coord_count; ++i) {
const bool last = (i == (coord_count - 1)) && (coord_count > 1);
coord += regs.GetRegisterAsFloat(last ? last_coord_register : coord_register + i);
- if (!last) {
+ if (i < coord_count - 1) {
coord += ',';
}
}
@@ -1702,6 +1702,99 @@ private:
is_array, (coord_count > 2 ? 1 : 0)));
}
+ std::pair<std::string, std::string> GetTLD4Code(const Instruction& instr,
+ const Tegra::Shader::TextureType texture_type,
+ const bool depth_compare, const bool is_array) {
+
+ const size_t coord_count = TextureCoordinates(texture_type);
+ const size_t total_coord_count = coord_count + (is_array ? 1 : 0);
+ const size_t total_reg_count = total_coord_count + (depth_compare ? 1 : 0);
+
+ constexpr std::array<const char*, 5> coord_container{
+ {"", "", "vec2 coord = vec2(", "vec3 coord = vec3(", "vec4 coord = vec4("}};
+
+ // If enabled arrays index is always stored in the gpr8 field
+ const u64 array_register = instr.gpr8.Value();
+ // First coordinate index is the gpr8 or gpr8 + 1 when arrays are used
+ const u64 coord_register = array_register + (is_array ? 1 : 0);
+
+ std::string coord = coord_container[total_coord_count];
+ for (size_t i = 0; i < coord_count;) {
+ coord += regs.GetRegisterAsFloat(coord_register + i);
+ ++i;
+ if (i != coord_count) {
+ coord += ',';
+ }
+ }
+
+ if (is_array) {
+ coord += ',' + regs.GetRegisterAsInteger(array_register);
+ }
+ coord += ");";
+
+ const std::string sampler =
+ GetSampler(instr.sampler, texture_type, is_array, depth_compare);
+
+ std::string texture = "textureGather(" + sampler + ", coord, ";
+ if (depth_compare) {
+ // Depth is always stored in the register signaled by gpr20
+ texture += regs.GetRegisterAsFloat(instr.gpr20.Value()) + ')';
+ } else {
+ texture += std::to_string(instr.tld4.component) + ')';
+ }
+ return std::make_pair(coord, texture);
+ }
+
+ std::pair<std::string, std::string> GetTLDSCode(const Instruction& instr,
+ const Tegra::Shader::TextureType texture_type,
+ const bool is_array) {
+
+ const size_t coord_count = TextureCoordinates(texture_type);
+ const size_t total_coord_count = coord_count + (is_array ? 1 : 0);
+ const bool lod_enabled =
+ instr.tlds.GetTextureProcessMode() == Tegra::Shader::TextureProcessMode::LL;
+
+ constexpr std::array<const char*, 4> coord_container{
+ {"", "int coord = (", "ivec2 coord = ivec2(", "ivec3 coord = ivec3("}};
+
+ std::string coord = coord_container[total_coord_count];
+
+ // If enabled arrays index is always stored in the gpr8 field
+ const u64 array_register = instr.gpr8.Value();
+
+ // if is array gpr20 is used
+ const u64 coord_register = is_array ? instr.gpr20.Value() : instr.gpr8.Value();
+
+ const u64 last_coord_register =
+ ((coord_count > 2) || (coord_count == 2 && !lod_enabled)) && !is_array
+ ? static_cast<u64>(instr.gpr20.Value())
+ : coord_register + 1;
+
+ for (size_t i = 0; i < coord_count; ++i) {
+ const bool last = (i == (coord_count - 1)) && (coord_count > 1);
+ coord += regs.GetRegisterAsInteger(last ? last_coord_register : coord_register + i);
+ if (i < coord_count - 1) {
+ coord += ',';
+ }
+ }
+ if (is_array) {
+ coord += ',' + regs.GetRegisterAsInteger(array_register);
+ }
+ coord += ");";
+
+ const std::string sampler = GetSampler(instr.sampler, texture_type, is_array, false);
+
+ std::string texture = "texelFetch(" + sampler + ", coords";
+
+ if (lod_enabled) {
+ // When lod is used always is in grp20
+ texture += ", " + regs.GetRegisterAsInteger(instr.gpr20) + ')';
+ } else {
+ texture += ", 0)";
+ }
+ return std::make_pair(coord, texture);
+ }
+
/**
* Compiles a single instruction from Tegra to GLSL.
* @param offset the offset of the Tegra shader instruction.
@@ -2825,9 +2918,6 @@ private:
const Tegra::Shader::TextureType texture_type{instr.tlds.GetTextureType()};
const bool is_array{instr.tlds.IsArrayTexture()};
- ASSERT(texture_type == Tegra::Shader::TextureType::Texture2D);
- ASSERT(is_array == false);
-
UNIMPLEMENTED_IF_MSG(instr.tlds.UsesMiscMode(Tegra::Shader::TextureMiscMode::NODEP),
"NODEP is not implemented");
UNIMPLEMENTED_IF_MSG(instr.tlds.UsesMiscMode(Tegra::Shader::TextureMiscMode::AOFFI),
@@ -2835,54 +2925,16 @@ private:
UNIMPLEMENTED_IF_MSG(instr.tlds.UsesMiscMode(Tegra::Shader::TextureMiscMode::MZ),
"MZ is not implemented");
- u32 extra_op_offset = 0;
-
- ShaderScopedScope scope = shader.Scope();
-
- switch (texture_type) {
- case Tegra::Shader::TextureType::Texture1D: {
- const std::string x = regs.GetRegisterAsInteger(instr.gpr8);
- shader.AddLine("float coords = " + x + ';');
- break;
- }
- case Tegra::Shader::TextureType::Texture2D: {
- UNIMPLEMENTED_IF_MSG(is_array, "Unhandled 2d array texture");
-
- const std::string x = regs.GetRegisterAsInteger(instr.gpr8);
- const std::string y = regs.GetRegisterAsInteger(instr.gpr20);
- // shader.AddLine("ivec2 coords = ivec2(" + x + ", " + y + ");");
- shader.AddLine("ivec2 coords = ivec2(" + x + ", " + y + ");");
- extra_op_offset = 1;
- break;
- }
- default:
- UNIMPLEMENTED_MSG("Unhandled texture type {}", static_cast<u32>(texture_type));
- }
- const std::string sampler =
- GetSampler(instr.sampler, texture_type, is_array, false);
+ const auto [coord, texture] = GetTLDSCode(instr, texture_type, is_array);
- const std::string texture = [&]() {
- switch (instr.tlds.GetTextureProcessMode()) {
- case Tegra::Shader::TextureProcessMode::LZ:
- return "texelFetch(" + sampler + ", coords, 0)";
- case Tegra::Shader::TextureProcessMode::LL:
- shader.AddLine(
- "float lod = " +
- regs.GetRegisterAsInteger(instr.gpr20.Value() + extra_op_offset) + ';');
- return "texelFetch(" + sampler + ", coords, lod)";
- default:
- UNIMPLEMENTED_MSG("Unhandled texture process mode {}",
- static_cast<u32>(instr.tlds.GetTextureProcessMode()));
- return "texelFetch(" + sampler + ", coords, 0)";
- }
- }();
+ const auto scope = shader.Scope();
- WriteTexsInstructionFloat(instr, texture);
+ shader.AddLine(coord);
+ shader.AddLine("vec4 texture_tmp = " + texture + ';');
+ WriteTexsInstructionFloat(instr, "texture_tmp");
break;
}
case OpCode::Id::TLD4: {
- ASSERT(instr.tld4.texture_type == Tegra::Shader::TextureType::Texture2D);
- ASSERT(instr.tld4.array == 0);
UNIMPLEMENTED_IF_MSG(instr.tld4.UsesMiscMode(Tegra::Shader::TextureMiscMode::NODEP),
"NODEP is not implemented");
@@ -2892,56 +2944,29 @@ private:
"NDV is not implemented");
UNIMPLEMENTED_IF_MSG(instr.tld4.UsesMiscMode(Tegra::Shader::TextureMiscMode::PTP),
"PTP is not implemented");
+
+ auto texture_type = instr.tld4.texture_type.Value();
const bool depth_compare =
instr.tld4.UsesMiscMode(Tegra::Shader::TextureMiscMode::DC);
- auto texture_type = instr.tld4.texture_type.Value();
- u32 num_coordinates = TextureCoordinates(texture_type);
- if (depth_compare)
- num_coordinates += 1;
-
- const auto scope = shader.Scope();
+ const bool is_array = instr.tld4.array != 0;
- switch (num_coordinates) {
- case 2: {
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- shader.AddLine("vec2 coords = vec2(" + x + ", " + y + ");");
- break;
- }
- case 3: {
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- const std::string z = regs.GetRegisterAsFloat(instr.gpr8.Value() + 2);
- shader.AddLine("vec3 coords = vec3(" + x + ", " + y + ", " + z + ");");
- break;
- }
- default:
- UNIMPLEMENTED_MSG("Unhandled coordinates number {}",
- static_cast<u32>(num_coordinates));
- const std::string x = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- shader.AddLine("vec2 coords = vec2(" + x + ", " + y + ");");
- texture_type = Tegra::Shader::TextureType::Texture2D;
- }
+ const auto [coord, texture] =
+ GetTLD4Code(instr, texture_type, depth_compare, is_array);
- const std::string sampler =
- GetSampler(instr.sampler, texture_type, false, depth_compare);
+ const auto scope = shader.Scope();
- const std::string texture = "textureGather(" + sampler + ", coords, " +
- std::to_string(instr.tld4.component) + ')';
+ shader.AddLine(coord);
+ std::size_t dest_elem{};
- if (depth_compare) {
- regs.SetRegisterToFloat(instr.gpr0, 0, texture, 1, 1, false);
- } else {
- std::size_t dest_elem{};
- for (std::size_t elem = 0; elem < 4; ++elem) {
- if (!instr.tex.IsComponentEnabled(elem)) {
- // Skip disabled components
- continue;
- }
- regs.SetRegisterToFloat(instr.gpr0, elem, texture, 1, 4, false, dest_elem);
- ++dest_elem;
+ shader.AddLine("vec4 texture_tmp = " + texture + ';');
+ for (std::size_t elem = 0; elem < 4; ++elem) {
+ if (!instr.tex.IsComponentEnabled(elem)) {
+ // Skip disabled components
+ continue;
}
+ regs.SetRegisterToFloat(instr.gpr0, elem, "texture_tmp", 1, 4, false,
+ dest_elem);
+ ++dest_elem;
}
break;
}
@@ -2955,28 +2980,31 @@ private:
const auto scope = shader.Scope();
+ std::string coords;
+
const bool depth_compare =
instr.tld4s.UsesMiscMode(Tegra::Shader::TextureMiscMode::DC);
- const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
- const std::string op_b = regs.GetRegisterAsFloat(instr.gpr20);
- // TODO(Subv): Figure out how the sampler type is encoded in the TLD4S instruction.
+
const std::string sampler = GetSampler(
instr.sampler, Tegra::Shader::TextureType::Texture2D, false, depth_compare);
- if (depth_compare) {
- // Note: TLD4S coordinate encoding works just like TEXS's
- const std::string op_y = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
- shader.AddLine("vec3 coords = vec3(" + op_a + ", " + op_y + ", " + op_b + ");");
- } else {
- shader.AddLine("vec2 coords = vec2(" + op_a + ", " + op_b + ");");
- }
- std::string texture = "textureGather(" + sampler + ", coords, " +
- std::to_string(instr.tld4s.component) + ')';
- if (depth_compare) {
- texture = "vec4(" + texture + ')';
- }
+ const std::string op_a = regs.GetRegisterAsFloat(instr.gpr8);
+ coords = "vec2 coords = vec2(" + op_a + ", ";
+ std::string texture = "textureGather(" + sampler + ", coords, ";
- WriteTexsInstructionFloat(instr, texture);
+ if (!depth_compare) {
+ const std::string op_b = regs.GetRegisterAsFloat(instr.gpr20);
+ coords += op_b + ");";
+ texture += std::to_string(instr.tld4s.component) + ')';
+ } else {
+ const std::string op_b = regs.GetRegisterAsFloat(instr.gpr8.Value() + 1);
+ const std::string op_c = regs.GetRegisterAsFloat(instr.gpr20);
+ coords += op_b + ");";
+ texture += op_c + ')';
+ }
+ shader.AddLine(coords);
+ shader.AddLine("vec4 texture_tmp = " + texture + ';');
+ WriteTexsInstructionFloat(instr, "texture_tmp");
break;
}
case OpCode::Id::TXQ: {
diff --git a/src/yuzu/game_list_worker.cpp b/src/yuzu/game_list_worker.cpp
index 9fd074223..20f5e8798 100644
--- a/src/yuzu/game_list_worker.cpp
+++ b/src/yuzu/game_list_worker.cpp
@@ -99,12 +99,14 @@ QList<QStandardItem*> MakeGameListEntry(const std::string& path, const std::stri
compatibility = it->second.first;
}
+ const auto file_type = loader.GetFileType();
+ const auto file_type_string = QString::fromStdString(Loader::GetFileTypeString(file_type));
+
QList<QStandardItem*> list{
- new GameListItemPath(
- FormatGameName(path), icon, QString::fromStdString(name),
- QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType())), program_id),
+ new GameListItemPath(FormatGameName(path), icon, QString::fromStdString(name),
+ file_type_string, program_id),
new GameListItemCompat(compatibility),
- new GameListItem(QString::fromStdString(Loader::GetFileTypeString(loader.GetFileType()))),
+ new GameListItem(file_type_string),
new GameListItemSize(FileUtil::GetSize(path)),
};
@@ -196,12 +198,16 @@ void GameListWorker::AddFstEntriesToGameList(const std::string& dir_path, unsign
const bool is_dir = FileUtil::IsDirectory(physical_name);
if (!is_dir &&
(HasSupportedFileExtension(physical_name) || IsExtractedNCAMain(physical_name))) {
- std::unique_ptr<Loader::AppLoader> loader =
- Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
- if (!loader || ((loader->GetFileType() == Loader::FileType::Unknown ||
- loader->GetFileType() == Loader::FileType::Error) &&
- !UISettings::values.show_unknown))
+ auto loader = Loader::GetLoader(vfs->OpenFile(physical_name, FileSys::Mode::Read));
+ if (!loader) {
return true;
+ }
+
+ const auto file_type = loader->GetFileType();
+ if ((file_type == Loader::FileType::Unknown || file_type == Loader::FileType::Error) &&
+ !UISettings::values.show_unknown) {
+ return true;
+ }
std::vector<u8> icon;
const auto res1 = loader->ReadIcon(icon);