From 15e0501a49adf9e768e28e1d9f79c26b9e534071 Mon Sep 17 00:00:00 2001 From: Triang3l Date: Tue, 11 Sep 2018 23:15:32 +0300 Subject: [PATCH] [D3D12] DXBC binding fixes --- src/xenia/gpu/d3d12/d3d12_command_processor.cc | 17 ++++++++++++----- src/xenia/gpu/dxbc_shader_translator.cc | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/xenia/gpu/d3d12/d3d12_command_processor.cc b/src/xenia/gpu/d3d12/d3d12_command_processor.cc index 8f1a3a257..980a09e81 100644 --- a/src/xenia/gpu/d3d12/d3d12_command_processor.cc +++ b/src/xenia/gpu/d3d12/d3d12_command_processor.cc @@ -134,11 +134,18 @@ ID3D12RootSignature* D3D12CommandProcessor::GetRootSignature( uint32_t vertex_texture_count, vertex_sampler_count; vertex_shader->GetTextureSRVs(vertex_texture_count); vertex_shader->GetSamplerBindings(vertex_sampler_count); - // Max 96 textures (if all kinds of tfetch instructions are used for all fetch - // registers) and 32 samplers (one sampler per used fetch), but different - // shader stages have different texture sets. - uint32_t index = pixel_texture_count | (pixel_sampler_count << 7) | - (vertex_texture_count << 12) | (vertex_sampler_count << 19); + + uint32_t index = 0; + uint32_t index_offset = 0; + index |= pixel_texture_count << index_offset; + index_offset += D3D12Shader::kMaxTextureSRVIndexBits; + index |= pixel_sampler_count << index_offset; + index_offset += D3D12Shader::kMaxSamplerBindingIndexBits; + index |= vertex_texture_count << index_offset; + index_offset += D3D12Shader::kMaxTextureSRVIndexBits; + index |= vertex_sampler_count << index_offset; + index_offset += D3D12Shader::kMaxSamplerBindingIndexBits; + assert_true(index_offset <= 32); // Try an existing root signature. auto it = root_signatures_.find(index); diff --git a/src/xenia/gpu/dxbc_shader_translator.cc b/src/xenia/gpu/dxbc_shader_translator.cc index 4a7b88100..7d4c5a4cf 100644 --- a/src/xenia/gpu/dxbc_shader_translator.cc +++ b/src/xenia/gpu/dxbc_shader_translator.cc @@ -2945,7 +2945,7 @@ uint32_t DxbcShaderTranslator::FindOrAddSamplerBinding( new_sampler_binding.mip_filter = mip_filter; new_sampler_binding.aniso_filter = aniso_filter; new_sampler_binding.name = name.str(); - uint32_t sampler_register = 1 + uint32_t(sampler_bindings_.size()); + uint32_t sampler_register = uint32_t(sampler_bindings_.size()); sampler_bindings_.emplace_back(std::move(new_sampler_binding)); return sampler_register; }