Skip to content

Commit

Permalink
HnMaterial: slightly reworked ApplyMaterialAttribsBufferOffset method
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Nov 25, 2024
1 parent 5be06fb commit 649e2e8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 6 additions & 7 deletions Hydrogent/interface/HnMaterial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ class HnMaterial final : public pxr::HdMaterial
m_PrimitiveAttribsVar->SetBufferOffset(PrimitiveAttribsOffset);
return m_SRB;
}
void ApplyMaterialAttribsBufferOffset() const
void ApplyMaterialAttribsBufferOffset(Uint32& CurrentOffset) const
{
VERIFY_EXPR(m_MaterialAttribsVar != nullptr);
VERIFY_EXPR(m_PBRMaterialAttribsBufferOffset != ~0u);
m_MaterialAttribsVar->SetBufferOffset(m_PBRMaterialAttribsBufferOffset);
if (CurrentOffset != m_PBRMaterialAttribsBufferOffset)
{
m_MaterialAttribsVar->SetBufferOffset(m_PBRMaterialAttribsBufferOffset);
CurrentOffset = m_PBRMaterialAttribsBufferOffset;
}
}
void SetJointsBufferOffset(Uint32 Offset) const
{
Expand Down Expand Up @@ -137,11 +141,6 @@ class HnMaterial final : public pxr::HdMaterial

Uint32 GetPBRPrimitiveAttribsBufferRange() const { return m_PBRPrimitiveAttribsBufferRange; }
Uint32 GetPBRMaterialAttribsSize() const { return m_PBRMaterialAttribsSize; }
Uint32 GetPBRMaterialAttribsBufferOffset() const
{
VERIFY_EXPR(m_PBRMaterialAttribsBufferOffset != ~0u);
return m_PBRMaterialAttribsBufferOffset;
}

private:
HnMaterial(pxr::SdfPath const& id);
Expand Down
8 changes: 4 additions & 4 deletions Hydrogent/src/HnRenderPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ struct HnRenderPass::RenderState
return;
}

if (pNewSRB != this->pMaterialSRB || this->MaterialBufferOffset != Material.GetPBRMaterialAttribsBufferOffset())
if (pNewSRB != this->pMaterialSRB)
{
Material.ApplyMaterialAttribsBufferOffset();
this->MaterialBufferOffset = Material.GetPBRMaterialAttribsBufferOffset();
this->MaterialBufferOffset = ~0u;
}
Material.ApplyMaterialAttribsBufferOffset(this->MaterialBufferOffset);

if (pNewSRB == this->pMaterialSRB)
return;
Expand Down Expand Up @@ -226,7 +226,7 @@ struct HnRenderPass::RenderState

IBuffer* pIndexBuffer = nullptr;

Uint32 MaterialBufferOffset = 0;
Uint32 MaterialBufferOffset = ~0u;

Uint32 NumVertexBuffers = 0;
std::array<IBuffer*, VERTEX_BUFFER_SLOT_COUNT> ppVertexBuffers = {};
Expand Down

0 comments on commit 649e2e8

Please sign in to comment.