| 503 | } |
| 504 | |
| 505 | void HnRenderDelegate::CommitResources(pxr::HdChangeTracker* tracker) |
| 506 | { |
| 507 | m_ResourceMgr->UpdateVertexBuffers(m_pDevice, m_pContext); |
| 508 | m_ResourceMgr->UpdateIndexBuffer(m_pDevice, m_pContext); |
| 509 | |
| 510 | m_TextureRegistry.Commit(m_pContext); |
| 511 | if (m_ShadowMapManager) |
| 512 | { |
| 513 | m_ShadowMapManager->Commit(m_pDevice, m_pContext); |
| 514 | const Uint32 ShadowAtlasVersion = m_ShadowMapManager->GetAtlasVersion(); |
| 515 | if (m_ShadowAtlasVersion != ShadowAtlasVersion) |
| 516 | { |
| 517 | m_ShadowAtlasVersion = ShadowAtlasVersion; |
| 518 | m_MainPassFrameAttribsSRB.Release(); |
| 519 | } |
| 520 | } |
| 521 | |
| 522 | auto CreateFrameAttribsSRB = [this](Uint32 BufferRange, ITextureView* ShadowSRV) { |
| 523 | RefCntAutoPtr<IShaderResourceBinding> SRB; |
| 524 | m_USDRenderer->CreateResourceBinding(&SRB, 0); |
| 525 | if (!SRB) |
| 526 | { |
| 527 | UNEXPECTED("Failed to create Frame Atttibs SRB"); |
| 528 | return SRB; |
| 529 | } |
| 530 | |
| 531 | // Primitive attribs buffer is in SRB1 |
| 532 | constexpr bool BindPrimitiveAttribsBuffer = false; |
| 533 | m_USDRenderer->InitCommonSRBVars(SRB, |
| 534 | nullptr, // pFrameAttribs |
| 535 | BindPrimitiveAttribsBuffer, |
| 536 | ShadowSRV); |
| 537 | if (auto* pVar = SRB->GetVariableByName(SHADER_TYPE_VERTEX, "cbFrameAttribs")) |
| 538 | { |
| 539 | // m_FrameAttribsCB has space for the main pass and all shadow passes. |
| 540 | pVar->SetBufferRange(m_FrameAttribsCB, 0, BufferRange); |
| 541 | } |
| 542 | else |
| 543 | { |
| 544 | UNEXPECTED("cbFrameAttribs variable not found in the SRB"); |
| 545 | } |
| 546 | |
| 547 | return SRB; |
| 548 | }; |
| 549 | |
| 550 | // FrameAttribs |
| 551 | // |
| 552 | // || Main Pass || Shadow Pass 1 || ... || Shadow Pass N || |
| 553 | // || Camera|PrevCamera|Renderer|Lights|ShadowMaps || Camera|PrevCamera|Renderer || ... || Camera|PrevCamera|Renderer || |
| 554 | // |<-------------------------------------------->||<-------------------------->|| |
| 555 | // m_USDRenderer->GetPRBFrameAttribsSize() USD_Renderer::GetPRBFrameAttribsSize(0, 0) |
| 556 | if (!m_MainPassFrameAttribsSRB) |
| 557 | { |
| 558 | m_MainPassFrameAttribsSRB = CreateFrameAttribsSRB(m_USDRenderer->GetPRBFrameAttribsSize(), m_ShadowMapManager ? m_ShadowMapManager->GetShadowSRV() : nullptr); |
| 559 | } |
| 560 | if (m_ShadowMapManager && !m_ShadowPassFrameAttribs.SRB) |
| 561 | { |
| 562 | constexpr Uint32 LightCount = 0; |
nothing calls this directly
no test coverage detected