| 1017 | } |
| 1018 | |
| 1019 | void HnMaterial::BindPrimitiveAttribsBuffer(HnRenderDelegate& RendererDelegate) |
| 1020 | { |
| 1021 | if (m_PrimitiveAttribsVar != nullptr) |
| 1022 | return; |
| 1023 | |
| 1024 | m_PrimitiveAttribsVar = m_SRB->GetVariableByName(SHADER_TYPE_PIXEL, "cbPrimitiveAttribs"); |
| 1025 | if (m_PrimitiveAttribsVar == nullptr) |
| 1026 | { |
| 1027 | UNEXPECTED("Failed to find 'cbPrimitiveAttribs' variable in the shader resource binding."); |
| 1028 | return; |
| 1029 | } |
| 1030 | |
| 1031 | RefCntAutoPtr<HnMaterialSRBCache> SRBCache{RendererDelegate.GetMaterialSRBCache(), IID_HnMaterialSRBCache}; |
| 1032 | VERIFY_EXPR(SRBCache); |
| 1033 | |
| 1034 | m_PBRPrimitiveAttribsBufferRange = SRBCache->GetPrimitiveAttribsBufferRange(m_SRB); |
| 1035 | VERIFY(m_PBRPrimitiveAttribsBufferRange != 0, |
| 1036 | "PBRRimitiveAttribsBufferRange is zero, which indicates the SRB was not found in the cache. This appears to be a bug."); |
| 1037 | |
| 1038 | if (m_PrimitiveAttribsVar->Get() != nullptr) |
| 1039 | { |
| 1040 | // The buffer has already been set by another material that uses the same SRB |
| 1041 | return; |
| 1042 | } |
| 1043 | |
| 1044 | USD_Renderer& UsdRenderer = *RendererDelegate.GetUSDRenderer(); |
| 1045 | m_PrimitiveAttribsVar->SetBufferRange(UsdRenderer.GetPBRPrimitiveAttribsCB(), 0, m_PBRPrimitiveAttribsBufferRange); |
| 1046 | } |
| 1047 | |
| 1048 | } // namespace USD |
| 1049 |
no test coverage detected