Skip to content

Commit 24e9fdd

Browse files
ShaderVarManagerD3D12: properly handle offset from table start for inline constants (#672)
1 parent 7f03389 commit 24e9fdd

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Graphics/GraphicsEngineD3D12/include/ShaderResourceCacheD3D12.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ class ShaderResourceCacheD3D12 : public ShaderResourceCacheBase
295295
Uint32 BufferDynamicOffset);
296296

297297
void SetInlineConstants(Uint32 RootIndex,
298+
Uint32 OffsetFromTableStart,
298299
const void* pConstants,
299300
Uint32 FirstConstant,
300301
Uint32 NumConstants);

Graphics/GraphicsEngineD3D12/src/ShaderResourceCacheD3D12.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,12 +459,13 @@ void ShaderResourceCacheD3D12::SetBufferDynamicOffset(Uint32 RootIndex,
459459
}
460460

461461
void ShaderResourceCacheD3D12::SetInlineConstants(Uint32 RootIndex,
462+
Uint32 OffsetFromTableStart,
462463
const void* pConstants,
463464
Uint32 FirstConstant,
464465
Uint32 NumConstants)
465466
{
466467
RootTable& Tbl = GetRootTable(RootIndex);
467-
Resource& Res = Tbl.GetResource(0);
468+
Resource& Res = Tbl.GetResource(OffsetFromTableStart);
468469
VERIFY_EXPR(Res.Type == SHADER_RESOURCE_TYPE_CONSTANT_BUFFER);
469470
VERIFY(Res.IsNull(), "There should be no resource bound for root constants as they contain raw data.");
470471
VERIFY(Res.CPUDescriptorHandle.ptr != 0, "Resources used to store root constants must have valid pointer to the data.");

Graphics/GraphicsEngineD3D12/src/ShaderVariableManagerD3D12.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,10 @@ void ShaderVariableManagerD3D12::SetInlineConstants(Uint32 ResIndex,
674674
Uint32 FirstConstant,
675675
Uint32 NumConstants)
676676
{
677-
const ResourceAttribs& Attribs = m_pSignature->GetResourceAttribs(ResIndex);
678-
const ResourceCacheContentType CacheType = m_ResourceCache.GetContentType();
679-
const Uint32 RootIndex = Attribs.RootIndex(CacheType);
680-
VERIFY_EXPR(Attribs.OffsetFromTableStart(CacheType) == 0);
677+
const ResourceAttribs& Attribs = m_pSignature->GetResourceAttribs(ResIndex);
678+
const ResourceCacheContentType CacheType = m_ResourceCache.GetContentType();
679+
const Uint32 RootIndex = Attribs.RootIndex(CacheType);
680+
const Uint32 OffsetFromTableStart = Attribs.OffsetFromTableStart(CacheType);
681681

682682
#ifdef DILIGENT_DEVELOPMENT
683683
{
@@ -686,7 +686,7 @@ void ShaderVariableManagerD3D12::SetInlineConstants(Uint32 ResIndex,
686686
}
687687
#endif
688688

689-
m_ResourceCache.SetInlineConstants(RootIndex, pConstants, FirstConstant, NumConstants);
689+
m_ResourceCache.SetInlineConstants(RootIndex, OffsetFromTableStart, pConstants, FirstConstant, NumConstants);
690690
}
691691

692692
IDeviceObject* ShaderVariableManagerD3D12::Get(Uint32 ArrayIndex,

0 commit comments

Comments
 (0)