| 1001 | } |
| 1002 | |
| 1003 | void HnRenderPass::RenderPendingDrawItems(RenderState& State) |
| 1004 | { |
| 1005 | size_t item_idx = 0; |
| 1006 | while (item_idx < m_PendingDrawItems.size()) |
| 1007 | { |
| 1008 | const PendingDrawItem& PendingItem = m_PendingDrawItems[item_idx]; |
| 1009 | const DrawListItem& ListItem = PendingItem.ListItem; |
| 1010 | |
| 1011 | State.SetPipelineState(m_UseFallbackPSO ? m_FallbackPSO : ListItem.pPSO); |
| 1012 | |
| 1013 | IShaderResourceBinding* pSRB = ListItem.Material.GetSRB(PendingItem.BufferOffset); |
| 1014 | VERIFY(pSRB != nullptr, "Material SRB is null. This may happen if UpdateSRB was not called for this material."); |
| 1015 | State.CommitShaderResources(pSRB); |
| 1016 | |
| 1017 | State.SetIndexBuffer(ListItem.IndexBuffer); |
| 1018 | State.SetVertexBuffers(ListItem.VertexBuffers.data(), ListItem.NumVertexBuffers); |
| 1019 | |
| 1020 | if (PendingItem.DrawCount > 1) |
| 1021 | { |
| 1022 | #ifdef DILIGENT_DEBUG |
| 1023 | VERIFY_EXPR(item_idx + PendingItem.DrawCount <= m_PendingDrawItems.size()); |
| 1024 | for (size_t i = 1; i < PendingItem.DrawCount; ++i) |
| 1025 | { |
| 1026 | const auto& BatchItem = m_PendingDrawItems[item_idx + i].ListItem; |
| 1027 | VERIFY_EXPR(BatchItem.RenderStateID == ListItem.RenderStateID && |
| 1028 | BatchItem.pPSO == ListItem.pPSO && |
| 1029 | BatchItem.IndexBuffer == ListItem.IndexBuffer && |
| 1030 | BatchItem.NumVertexBuffers == ListItem.NumVertexBuffers && |
| 1031 | BatchItem.VertexBuffers == ListItem.VertexBuffers && |
| 1032 | BatchItem.DrawItem.GetMaterial()->GetSRB() == ListItem.DrawItem.GetMaterial()->GetSRB()); |
| 1033 | } |
| 1034 | VERIFY_EXPR(m_ScratchSpace.size() >= PendingItem.DrawCount * (ListItem.IndexBuffer != nullptr ? sizeof(MultiDrawIndexedItem) : sizeof(MultiDrawItem))); |
| 1035 | #endif |
| 1036 | |
| 1037 | if (ListItem.IndexBuffer != nullptr) |
| 1038 | { |
| 1039 | if (State.NativeMultiDrawSupported) |
| 1040 | { |
| 1041 | MultiDrawIndexedItem* pMultiDrawItems = reinterpret_cast<MultiDrawIndexedItem*>(m_ScratchSpace.data()); |
| 1042 | for (size_t i = 0; i < PendingItem.DrawCount; ++i) |
| 1043 | { |
| 1044 | const DrawListItem& BatchItem = m_PendingDrawItems[item_idx + i].ListItem; |
| 1045 | pMultiDrawItems[i] = {BatchItem.NumVertices, BatchItem.StartIndex, 0}; |
| 1046 | } |
| 1047 | State.pCtx->MultiDrawIndexed({PendingItem.DrawCount, pMultiDrawItems, VT_UINT32, DRAW_FLAG_VERIFY_ALL}); |
| 1048 | } |
| 1049 | else |
| 1050 | { |
| 1051 | for (size_t i = 0; i < PendingItem.DrawCount; ++i) |
| 1052 | { |
| 1053 | // When native multi-draw is not supported, we pass primitive ID as instance ID. |
| 1054 | const DrawListItem& BatchItem = m_PendingDrawItems[item_idx + i].ListItem; |
| 1055 | DrawIndexedAttribs Attribs{BatchItem.NumVertices, VT_UINT32, DRAW_FLAG_VERIFY_ALL}; |
| 1056 | if (i > 0) |
| 1057 | { |
| 1058 | Attribs.Flags |= DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT; |
| 1059 | } |
| 1060 | Attribs.FirstIndexLocation = BatchItem.StartIndex; |
nothing calls this directly
no test coverage detected