From 42c4d8353a65b2dd88bb810e131b60d66a6e8d8c Mon Sep 17 00:00:00 2001 From: xezrunner <8061077+xezrunner@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:48:28 +0200 Subject: [PATCH 1/3] Fix control.sopp.simm flipping sign in CFG label generation This used to cause a fatal crash that would prevent Amplitude [CUSA02480] from booting beyond initialization. A conditional true label would get an address starting with 0xffff...., which wasn't realistic with the given shader. The multiplication by 4 causes the value to have its MSB set due to the smaller type. --- src/shader_recompiler/frontend/instruction.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shader_recompiler/frontend/instruction.cpp b/src/shader_recompiler/frontend/instruction.cpp index d4847708..756d3b4e 100644 --- a/src/shader_recompiler/frontend/instruction.cpp +++ b/src/shader_recompiler/frontend/instruction.cpp @@ -7,7 +7,7 @@ namespace Shader::Gcn { u32 GcnInst::BranchTarget(u32 pc) const { - const s16 simm = static_cast(control.sopp.simm * 4); + const s32 simm = static_cast(control.sopp.simm) * 4; const u32 target = pc + simm + 4; return target; } From ece821820d58c5210a74a6ac114f35ceaa38b935 Mon Sep 17 00:00:00 2001 From: xezrunner <8061077+xezrunner@users.noreply.github.com> Date: Tue, 20 Aug 2024 22:55:15 +0200 Subject: [PATCH 2/3] Temporary workarounds for Amplitude 2016 --- .../backend/spirv/spirv_emit_context.cpp | 8 ++++++++ .../frontend/translate/data_share.cpp | 10 +++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp index d61e108f..0e236c6f 100644 --- a/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp +++ b/src/shader_recompiler/backend/spirv/spirv_emit_context.cpp @@ -425,6 +425,14 @@ spv::ImageFormat GetFormat(const AmdGpu::Image& image) { image.GetNumberFmt() == AmdGpu::NumberFormat::Unorm) { return spv::ImageFormat::Rgba8; } + if (image.GetDataFmt() == AmdGpu::DataFormat::Format8_8_8_8 && + image.GetNumberFmt() == AmdGpu::NumberFormat::Srgb) { + // TEMP: for Amplitude 2016 + // The game requests a Format8_8_8_8 SRGB image format. + // Interpreting it as R16Snorm makes the game draw with no major color deviations. + // What should the SRGB format be? + return spv::ImageFormat::R16Snorm; + } if (image.GetDataFmt() == AmdGpu::DataFormat::Format8_8_8_8 && image.GetNumberFmt() == AmdGpu::NumberFormat::Uint) { return spv::ImageFormat::Rgba8ui; diff --git a/src/shader_recompiler/frontend/translate/data_share.cpp b/src/shader_recompiler/frontend/translate/data_share.cpp index b7b5aa13..d0f70c76 100644 --- a/src/shader_recompiler/frontend/translate/data_share.cpp +++ b/src/shader_recompiler/frontend/translate/data_share.cpp @@ -162,18 +162,22 @@ void Translator::S_BARRIER() { ir.Barrier(); } +// TEMP: for Amplitude 2016 +// These are "warp instructions" and are stubbed to work outside of compute shaders. +// The game makes use of them and works fine when the assertions are removed. + void Translator::V_READFIRSTLANE_B32(const GcnInst& inst) { - ASSERT(info.stage != Stage::Compute); + //ASSERT(info.stage != Stage::Compute); SetDst(inst.dst[0], GetSrc(inst.src[0])); } void Translator::V_READLANE_B32(const GcnInst& inst) { - ASSERT(info.stage != Stage::Compute); + //ASSERT(info.stage != Stage::Compute); SetDst(inst.dst[0], GetSrc(inst.src[0])); } void Translator::V_WRITELANE_B32(const GcnInst& inst) { - ASSERT(info.stage != Stage::Compute); + //ASSERT(info.stage != Stage::Compute); SetDst(inst.dst[0], GetSrc(inst.src[0])); } From c7fd36cf0eaec3ae1ecbc58d43cc47c6592e3739 Mon Sep 17 00:00:00 2001 From: xezrunner <8061077+xezrunner@users.noreply.github.com> Date: Tue, 20 Aug 2024 23:32:40 +0200 Subject: [PATCH 3/3] workaround: skip track section shader (V_MOVREL...) --- src/video_core/renderer_vulkan/vk_pipeline_cache.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index c11705e7..af006885 100644 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -327,6 +327,13 @@ std::unique_ptr PipelineCache::CreateComputePipeline() { MakeShaderInfo(Shader::Stage::Compute, cs_pgm.user_data, liverpool->regs); info.pgm_base = cs_pgm.Address(); info.pgm_hash = compute_key; + + // TEMP: for Amplitude 2016: + // Skip broken shader with V_MOVREL... instructions: + if (compute_key == 0xc7f34c4f) { + return nullptr; + } + auto program = Shader::TranslateProgram(inst_pool, block_pool, code, std::move(info), profile);