diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 86b2e23749..bcf13744bd 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -143,7 +143,7 @@ D3D12GSRender::D3D12GSRender() m_device->CreateRenderTargetView(m_backbuffer[1].Get(), &renter_target_view_desc, m_backbuffer_descriptor_heap[1]->GetCPUDescriptorHandleForHeapStart()); // Common root signatures - for (int vertex_buffer_count = 1; vertex_buffer_count <= 16; vertex_buffer_count++) + for (int vertex_buffer_count = 0; vertex_buffer_count < 17; vertex_buffer_count++) // Some app (naruto ultimate ninja storm 2) uses a shader without inputs... { for (unsigned texture_count = 0; texture_count < 17; texture_count++) { @@ -161,7 +161,12 @@ D3D12GSRender::D3D12GSRender() CD3DX12_DESCRIPTOR_RANGE(D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER, texture_count, 0), }; CD3DX12_ROOT_PARAMETER RP[2]; - RP[0].InitAsDescriptorTable((texture_count > 0) ? 4 : 3, &descriptorRange[0]); + size_t cbv_srv_uav_descriptor_size = 4; + if (texture_count == 0) + cbv_srv_uav_descriptor_size -= 1; + if (vertex_buffer_count == 0) + cbv_srv_uav_descriptor_size -= 1; + RP[0].InitAsDescriptorTable(cbv_srv_uav_descriptor_size, (vertex_buffer_count > 0) ? &descriptorRange[0] : &descriptorRange[1]); RP[1].InitAsDescriptorTable(1, &descriptorRange[4]); Microsoft::WRL::ComPtr rootSignatureBlob; @@ -173,7 +178,7 @@ D3D12GSRender::D3D12GSRender() m_device->CreateRootSignature(0, rootSignatureBlob->GetBufferPointer(), rootSignatureBlob->GetBufferSize(), - IID_PPV_ARGS(m_root_signatures[texture_count][vertex_buffer_count - 1].GetAddressOf())); + IID_PPV_ARGS(m_root_signatures[texture_count][vertex_buffer_count].GetAddressOf())); } } @@ -283,7 +288,7 @@ void D3D12GSRender::end() std::chrono::time_point program_load_end = std::chrono::system_clock::now(); m_timers.m_program_load_duration += std::chrono::duration_cast(program_load_end - program_load_start).count(); - get_current_resource_storage().command_list->SetGraphicsRootSignature(m_root_signatures[std::get<2>(m_current_pso)][vertex_buffer_count - 1].Get()); + get_current_resource_storage().command_list->SetGraphicsRootSignature(m_root_signatures[std::get<2>(m_current_pso)][vertex_buffer_count].Get()); get_current_resource_storage().command_list->OMSetStencilRef(rsx::method_registers[NV4097_SET_STENCIL_FUNC_REF]); std::chrono::time_point constants_duration_start = std::chrono::system_clock::now(); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h index f32374359c..d1d7136df6 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.h @@ -56,7 +56,7 @@ private: ComPtr m_backbuffer[2]; ComPtr m_backbuffer_descriptor_heap[2]; // m_rootSignatures[N] is RS with N texture/sample - ComPtr m_root_signatures[17][16]; // indexed by [texture count][vertex count] + ComPtr m_root_signatures[17][17]; // indexed by [texture count][vertex count] // TODO: Use a tree structure to parse more efficiently data_cache m_texture_cache; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h index 966545f0b8..bdd282b814 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h @@ -148,7 +148,7 @@ struct D3D12Traits 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) + ID3D12Device *device, gsl::span, 17, 17> 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_input_count - 1].Get(); + graphicPipelineStateDesc.pRootSignature = root_signatures[fragmentProgramData.m_textureCount][vertexProgramData.vertex_shader_input_count].Get(); graphicPipelineStateDesc.BlendState = pipelineProperties.Blend; graphicPipelineStateDesc.DepthStencilState = pipelineProperties.DepthStencil;