diff options
| author | Yong He <yonghe@outlook.com> | 2022-10-05 19:35:47 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-10-05 19:35:47 -0700 |
| commit | cf34d2830a3103b2b47a4140d27d054b797705f2 (patch) | |
| tree | 3620bc07e53edc6c959777d069b1931aa28691e4 /tools/gfx/d3d12/d3d12-shader-object.cpp | |
| parent | 364e43264b9f69957ddaed8890392d82fb25c822 (diff) | |
Various gfx fixes. (#2434)
Diffstat (limited to 'tools/gfx/d3d12/d3d12-shader-object.cpp')
| -rw-r--r-- | tools/gfx/d3d12/d3d12-shader-object.cpp | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/tools/gfx/d3d12/d3d12-shader-object.cpp b/tools/gfx/d3d12/d3d12-shader-object.cpp index e5875f55c..fd92dbfa0 100644 --- a/tools/gfx/d3d12/d3d12-shader-object.cpp +++ b/tools/gfx/d3d12/d3d12-shader-object.cpp @@ -447,6 +447,14 @@ void ShaderObjectImpl::updateSubObjectsRecursive() } } +static void bindPendingTables(BindingContext* context) +{ + for (auto& binding : *context->pendingTableBindings) + { + context->submitter->setRootDescriptorTable(binding.rootIndex, binding.handle); + } +} + /// Prepare to bind this object as a parameter block. /// /// This involves allocating and binding any descriptor tables necessary @@ -504,7 +512,7 @@ Result ShaderObjectImpl::prepareToBindAsParameterBlock( // root parameter. // auto tableRootParamIndex = rootParamIndex++; - submitter->setRootDescriptorTable(tableRootParamIndex, table.getGpuHandle()); + context->pendingTableBindings->add(PendingDescriptorTableBinding{ tableRootParamIndex, table.getGpuHandle() }); } if (auto descriptorCount = specializedLayout->getTotalSamplerDescriptorCount()) { @@ -527,7 +535,7 @@ Result ShaderObjectImpl::prepareToBindAsParameterBlock( // root parameter. // auto tableRootParamIndex = rootParamIndex++; - submitter->setRootDescriptorTable(tableRootParamIndex, table.getGpuHandle()); + context->pendingTableBindings->add(PendingDescriptorTableBinding{ tableRootParamIndex, table.getGpuHandle() }); } return SLANG_OK; @@ -602,6 +610,10 @@ Result ShaderObjectImpl::bindAsParameterBlock( // descriptor table) to represent its values. // BindingOffset subOffset = offset; + ShortList<PendingDescriptorTableBinding> pendingTableBindings; + auto oldPendingTableBindings = context->pendingTableBindings; + context->pendingTableBindings = &pendingTableBindings; + SLANG_RETURN_ON_FAIL(prepareToBindAsParameterBlock( context, /* inout */ subOffset, specializedLayout, m_cachedGPUDescriptorSet)); @@ -611,6 +623,9 @@ Result ShaderObjectImpl::bindAsParameterBlock( SLANG_RETURN_ON_FAIL( bindAsConstantBuffer(context, m_cachedGPUDescriptorSet, subOffset, specializedLayout)); + bindPendingTables(context); + context->pendingTableBindings = oldPendingTableBindings; + m_cachedGPUDescriptorSetVersion = m_version; return SLANG_OK; } @@ -1116,8 +1131,12 @@ Result RootShaderObjectImpl::bindAsRoot( // need to bind the entry points into the same descriptor set that is // being used for the root object. - BindingOffset rootOffset; + ShortList<PendingDescriptorTableBinding> pendingTableBindings; + auto oldPendingTableBindings = context->pendingTableBindings; + context->pendingTableBindings = &pendingTableBindings; + BindingOffset rootOffset; + // Bind all root parameters first. Super::bindRootArguments(context, rootOffset.rootParam); @@ -1143,6 +1162,9 @@ Result RootShaderObjectImpl::bindAsRoot( context, descriptorSet, entryPointOffset, entryPointInfo.layout)); } + bindPendingTables(context); + context->pendingTableBindings = oldPendingTableBindings; + return SLANG_OK; } |
