diff --git a/src/graphics/host_gpu/renderer/renderDraw.cpp b/src/graphics/host_gpu/renderer/renderDraw.cpp index b3ba36daf..2a7249b49 100644 --- a/src/graphics/host_gpu/renderer/renderDraw.cpp +++ b/src/graphics/host_gpu/renderer/renderDraw.cpp @@ -1161,7 +1161,6 @@ void RenderExecutor::ExecutePreparedDraw(uint64_t submit_id, CommandBuffer& buff if (mesh_active) { draw_data = {draw.index_count, static_cast(emit.vertex_offset), - emit.first_instance, index_source.guest_element_size, static_cast(index_source.address), static_cast(index_source.address >> 32u)}; diff --git a/src/graphics/shader/recompiler/frontend/translate/Translate.cpp b/src/graphics/shader/recompiler/frontend/translate/Translate.cpp index 4266ba167..06bc315f5 100644 --- a/src/graphics/shader/recompiler/frontend/translate/Translate.cpp +++ b/src/graphics/shader/recompiler/frontend/translate/Translate.cpp @@ -1244,12 +1244,12 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph& entry_ir.BitwiseOr(wave_info, entry_ir.BitwiseOr(entry_ir.ShiftLeftLogical( primitive_count, u32(8)), vertex_count))); + // Instance IDs exclude the start instance, which shaders add from user data. if (mesh.fast_launch) { // Fast launch broadcasts the subgroup's base vertex and instance to every lane. entry_ir.SetVectorReg(static_cast(5), entry_ir.IAdd(draw(1), group)); - entry_ir.SetVectorReg( - static_cast(6), - entry_ir.IAdd(draw(2), builtin(IR::StageInputKind::WorkgroupId, 1))); + entry_ir.SetVectorReg(static_cast(6), + builtin(IR::StageInputKind::WorkgroupId, 1)); } else { // GS adjacency addresses local ES records in LDS. Fans retain the draw's // center in every subgroup; strip winding follows the global primitive. @@ -1277,14 +1277,14 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph& entry_ir.ShiftLeftLogical(second, u32(18)))); entry_ir.SetVectorReg(static_cast(1), entry_ir.ShiftLeftLogical(third, u32(2))); - const auto index_bytes = draw(3); + const auto index_bytes = draw(2); const auto indexed = entry_ir.INotEqual(index_bytes, u32(0)); - const auto index_low = draw(4); + const auto index_low = draw(3); const auto byte_offset = entry_ir.IAdd(entry_ir.BitwiseAnd(index_low, u32(3)), entry_ir.IMul(input_vertex, index_bytes)); const auto index_resource = entry_ir.Emit( IR::ValueOpcode::GetAddressResource, - {entry_ir.BitwiseAnd(index_low, u32(~3u)), draw(5)}); + {entry_ir.BitwiseAnd(index_low, u32(~3u)), draw(4)}); const auto memory_index = static_cast(result.memory_info.size()); result.memory_info.push_back({.kind = IR::ResourceKind::Global}); const auto packed_index = entry_ir.Emit( @@ -1298,9 +1298,8 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph& entry_ir.IMul(index_bytes, u32(8))})); entry_ir.SetVectorReg(static_cast(5), entry_ir.IAdd(draw(1), entry_ir.Select(indexed, index, input_vertex))); - entry_ir.SetVectorReg( - static_cast(8), - entry_ir.IAdd(draw(2), builtin(IR::StageInputKind::WorkgroupId, 1))); + entry_ir.SetVectorReg(static_cast(8), + builtin(IR::StageInputKind::WorkgroupId, 1)); } } else if (options.stage == ShaderType::Local) { entry_ir.SetScalarReg(static_cast(3), IR::U32(IR::Value(64u))); diff --git a/src/graphics/shader/recompiler/ir/ShaderIR.h b/src/graphics/shader/recompiler/ir/ShaderIR.h index 9e41d7799..034a17975 100644 --- a/src/graphics/shader/recompiler/ir/ShaderIR.h +++ b/src/graphics/shader/recompiler/ir/ShaderIR.h @@ -365,7 +365,7 @@ static_assert(static_cast(DescriptorBindingKind::Count) == 58u); struct PushData { static constexpr uint32_t DwordCount = 32; - static constexpr uint32_t MeshDrawDwordCount = 6; + static constexpr uint32_t MeshDrawDwordCount = 5; static constexpr uint32_t NoStart = UINT32_MAX; std::array dwords {}; diff --git a/tests/shaderCfgTests.cpp b/tests/shaderCfgTests.cpp index eb47d01df..25c2bde72 100644 --- a/tests/shaderCfgTests.cpp +++ b/tests/shaderCfgTests.cpp @@ -11787,7 +11787,7 @@ void TestMeshInputAssembly() { options.user_data_count = 0; options.input_info.vertex = &input; auto program = Frontend::TranslateProgram(decoded, graph, options); - const uint32_t draw[] = {test.count, test.base_vertex, 7, test.width, + const uint32_t draw[] = {test.count, test.base_vertex, test.width, test.address_low, 0x12}; Inst *load = nullptr; for (auto &inst : *program.blocks.front()) { @@ -11832,7 +11832,7 @@ void TestMeshInputAssembly() { Check(sgprs[2] == test.group_info && sgprs[3] == test.wave_info && vgprs[0] == ((test.first << 2) | (test.second << 18)) && vgprs[1] == test.third * 4 && vgprs[5] == test.vertex_id && - vgprs[test.fast_launch ? 6 : 8] == 9u, + vgprs[test.fast_launch ? 6 : 8] == 2u, "mesh prolog changed input assembly, wave counts, vertex ID, or instance ID"); } }