diff --git a/Hydrogent/interface/HnMaterial.hpp b/Hydrogent/interface/HnMaterial.hpp index 489e5cfe..3f0fdcf0 100644 --- a/Hydrogent/interface/HnMaterial.hpp +++ b/Hydrogent/interface/HnMaterial.hpp @@ -192,6 +192,12 @@ class HnMaterial final : public pxr::HdMaterial PBR_Renderer::PSO_FLAGS m_PSOFlags = PBR_Renderer::PSO_FLAG_NONE; + // Material attribs data resides in a single buffer shared by all SRBs. + // + // Size + // | |-------------| x x x x | + // Offset Alignment + // Material attribs shader data size in bytes. Uint32 m_PBRMaterialAttribsSize = 0; diff --git a/Hydrogent/src/HnMaterial.cpp b/Hydrogent/src/HnMaterial.cpp index 8d4fa0e6..e46044bc 100644 --- a/Hydrogent/src/HnMaterial.cpp +++ b/Hydrogent/src/HnMaterial.cpp @@ -743,6 +743,8 @@ class HnMaterialSRBCache : public ObjectBase m_DirtyRangeEnd = m_MaterialAttribsData.size(); } pContext->UpdateBuffer(pBuffer, m_DirtyRangeStart, m_DirtyRangeEnd - m_DirtyRangeStart, &m_MaterialAttribsData[m_DirtyRangeStart], RESOURCE_STATE_TRANSITION_MODE_TRANSITION); + m_DirtyRangeStart = 0; + m_DirtyRangeEnd = 0; } return pBuffer; } @@ -775,6 +777,7 @@ class HnMaterialSRBCache : public ObjectBase Uint32 m_CurrBufferOffset = 0; Uint32 m_RequiredBufferSize = 0; + // Material attribs data resides in a single buffer shared by all SRBs. DynamicBuffer m_MaterialAttribsBuffer; std::vector m_MaterialAttribsData; Uint32 m_DirtyRangeStart = 0; diff --git a/Hydrogent/src/HnRenderPass.cpp b/Hydrogent/src/HnRenderPass.cpp index 498bc4d3..bba480fb 100644 --- a/Hydrogent/src/HnRenderPass.cpp +++ b/Hydrogent/src/HnRenderPass.cpp @@ -1158,6 +1158,7 @@ void HnRenderPass::UpdateDrawListItemGPUResources(DrawListItem& ListItem, Render "Attribs data size (", ListItem.ShaderAttribsDataSize, ") computed from the PSO flags exceeds the attribs buffer range (", ListItem.PrimitiveAttribsBufferRange, ") computed from material PSO flags. The latter is used by HnMaterial to set the buffer range."); + // Note: some PSOs (e.g. shadow) may not use the full range of the material attribs buffer. VERIFY(ListItem.pMaterial->GetPBRMaterialAttribsSize() >= State.USDRenderer.GetPBRMaterialAttribsSize(ListItem.PSOFlags), "Material attribs size is smaller than required by the PSO flags"); VERIFY_EXPR(ListItem.pPSO != nullptr);