[D3D12] DXBC binding fixes

This commit is contained in:
Triang3l 2018-09-11 23:15:32 +03:00
parent 2a98d29eda
commit 15e0501a49
2 changed files with 13 additions and 6 deletions

View File

@ -134,11 +134,18 @@ ID3D12RootSignature* D3D12CommandProcessor::GetRootSignature(
uint32_t vertex_texture_count, vertex_sampler_count; uint32_t vertex_texture_count, vertex_sampler_count;
vertex_shader->GetTextureSRVs(vertex_texture_count); vertex_shader->GetTextureSRVs(vertex_texture_count);
vertex_shader->GetSamplerBindings(vertex_sampler_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 uint32_t index = 0;
// shader stages have different texture sets. uint32_t index_offset = 0;
uint32_t index = pixel_texture_count | (pixel_sampler_count << 7) | index |= pixel_texture_count << index_offset;
(vertex_texture_count << 12) | (vertex_sampler_count << 19); 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. // Try an existing root signature.
auto it = root_signatures_.find(index); auto it = root_signatures_.find(index);

View File

@ -2945,7 +2945,7 @@ uint32_t DxbcShaderTranslator::FindOrAddSamplerBinding(
new_sampler_binding.mip_filter = mip_filter; new_sampler_binding.mip_filter = mip_filter;
new_sampler_binding.aniso_filter = aniso_filter; new_sampler_binding.aniso_filter = aniso_filter;
new_sampler_binding.name = name.str(); 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)); sampler_bindings_.emplace_back(std::move(new_sampler_binding));
return sampler_register; return sampler_register;
} }