diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index cdeef06e7d..f32374359c 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -67,7 +67,7 @@ private: RSXVertexProgram vertex_program; RSXFragmentProgram fragment_program; PipelineStateObjectCache m_pso_cache; - std::tuple, std::vector, size_t> m_current_pso; + std::tuple, size_t, size_t> m_current_pso; struct { diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h index 56a6d7e087..966545f0b8 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h @@ -75,7 +75,7 @@ public: ComPtr bytecode; // For debugging std::string content; - std::vector vertex_shader_inputs; + size_t vertex_shader_input_count; std::vector FragmentConstantOffsetCache; size_t m_textureCount; @@ -104,7 +104,7 @@ struct D3D12Traits { using vertex_program_type = Shader; using fragment_program_type = Shader; - using pipeline_storage_type = std::tuple, std::vector, size_t>; + using pipeline_storage_type = std::tuple, size_t, size_t>; using pipeline_properties = D3D12PipelineProperties; static @@ -140,15 +140,15 @@ struct D3D12Traits D3D12VertexProgramDecompiler VS(RSXVP); std::string shaderCode = VS.Decompile(); vertexProgramData.Compile(shaderCode, Shader::SHADER_TYPE::SHADER_TYPE_VERTEX); - vertexProgramData.vertex_shader_inputs = VS.input_slots; + vertexProgramData.vertex_shader_input_count = RSXVP.rsx_vertex_inputs.size(); fs::file(fs::get_config_dir() + "VertexProgram" + std::to_string(ID) + ".hlsl", fom::rewrite).write(shaderCode); vertexProgramData.id = (u32)ID; } static - pipeline_storage_type build_pipeline( - const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties, - ID3D12Device *device, gsl::span, 17, 16> root_signatures) + pipeline_storage_type build_pipeline( + const vertex_program_type &vertexProgramData, const fragment_program_type &fragmentProgramData, const pipeline_properties &pipelineProperties, + ID3D12Device *device, gsl::span, 17, 16> root_signatures) { std::tuple, size_t> result = {}; D3D12_GRAPHICS_PIPELINE_STATE_DESC graphicPipelineStateDesc = {}; @@ -163,7 +163,7 @@ struct D3D12Traits graphicPipelineStateDesc.PS.BytecodeLength = fragmentProgramData.bytecode->GetBufferSize(); graphicPipelineStateDesc.PS.pShaderBytecode = fragmentProgramData.bytecode->GetBufferPointer(); - graphicPipelineStateDesc.pRootSignature = root_signatures[fragmentProgramData.m_textureCount][vertexProgramData.vertex_shader_inputs.size() - 1].Get(); + graphicPipelineStateDesc.pRootSignature = root_signatures[fragmentProgramData.m_textureCount][vertexProgramData.vertex_shader_input_count - 1].Get(); graphicPipelineStateDesc.BlendState = pipelineProperties.Blend; graphicPipelineStateDesc.DepthStencilState = pipelineProperties.DepthStencil; @@ -186,7 +186,7 @@ struct D3D12Traits std::wstring name = L"PSO_" + std::to_wstring(vertexProgramData.id) + L"_" + std::to_wstring(fragmentProgramData.id); pso->SetName(name.c_str()); - return std::make_tuple(pso, vertexProgramData.vertex_shader_inputs, fragmentProgramData.m_textureCount); + return std::make_tuple(pso, vertexProgramData.vertex_shader_input_count, fragmentProgramData.m_textureCount); } }; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp index 9c51e69492..d91d6e105f 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.cpp @@ -60,7 +60,6 @@ void D3D12VertexProgramDecompiler::insertInputs(std::stringstream & OS, const st for (const ParamItem &PI : PT.items) { input_data.push_back(std::make_tuple(PI.location, PI.name)); - input_slots.push_back(PI.location); } } @@ -169,7 +168,19 @@ void D3D12VertexProgramDecompiler::insertMainStart(std::stringstream & OS) for (const ParamType PT : m_parr.params[PF_PARAM_IN]) { for (const ParamItem &PI : PT.items) - OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(vertex_id);" << std::endl; + { + for (const auto &real_input : rsx_vertex_program.rsx_vertex_inputs) + { + if (real_input.location != PI.location) + continue; + if (!real_input.is_array) + { + OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(0);\n"; + continue; + } + OS << " " << PT.type << " " << PI.name << " = " << PI.name << "_buffer.Load(vertex_id);\n"; + } + } } } @@ -189,7 +200,7 @@ void D3D12VertexProgramDecompiler::insertMainEnd(std::stringstream & OS) } D3D12VertexProgramDecompiler::D3D12VertexProgramDecompiler(const RSXVertexProgram &prog) : - VertexProgramDecompiler(prog) + VertexProgramDecompiler(prog), rsx_vertex_program(prog) { } #endif diff --git a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.h b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.h index fd5a55a7a8..01161b37c8 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12VertexProgramDecompiler.h @@ -18,7 +18,8 @@ protected: virtual void insertOutputs(std::stringstream &OS, const std::vector &outputs); virtual void insertMainStart(std::stringstream &OS); virtual void insertMainEnd(std::stringstream &OS); + + const RSXVertexProgram &rsx_vertex_program; public: - std::vector input_slots; D3D12VertexProgramDecompiler(const RSXVertexProgram &prog); };