@@ -547,21 +547,10 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
547547 const HnMesh::Components::Skinning>();
548548
549549 Uint32 MultiDrawCount = 0 ;
550- for (size_t item_idx = 0 ; item_idx < m_DrawList. size () ; ++item_idx)
550+ for (size_t item_idx = 0 ; item_idx < m_ValidDrawItemCount ; ++item_idx)
551551 {
552552 DrawListItem& ListItem = m_DrawList[item_idx];
553- if (!ListItem.DrawItem .IsValid ())
554- {
555- // All invalid draw items are grouped at the end of the draw list.
556- #ifdef DILIGENT_DEBUG
557- for (size_t i = item_idx + 1 ; i < m_DrawList.size (); ++i)
558- {
559- VERIFY (!m_DrawList[i].DrawItem .IsValid (), " Invalid draw items must be grouped at the end of the draw list" );
560- }
561-
562- #endif
563- break ;
564- }
553+ VERIFY (ListItem.DrawItem .IsValid (), " All valid draw items must be grouped at the beginning of the list by UpdateDrawListGPUResources" );
565554
566555 if (!ListItem)
567556 continue ;
@@ -724,6 +713,12 @@ HnRenderPass::EXECUTE_RESULT HnRenderPass::Execute(HnRenderPassState& RPState, c
724713 AttribsBufferOffset += ListItem.ShaderAttribsDataSize ;
725714 ++MultiDrawCount;
726715 }
716+ #ifdef DILIGENT_DEBUG
717+ for (size_t i = m_ValidDrawItemCount; i < m_DrawList.size (); ++i)
718+ {
719+ VERIFY (!m_DrawList[i].DrawItem .IsValid (), " All invalid draw items must be grouped at the end of the list by UpdateDrawListGPUResources" );
720+ }
721+ #endif
727722 if (AttribsBufferOffset != 0 )
728723 {
729724 FlushPendingDraws ();
@@ -1062,7 +1057,8 @@ void HnRenderPass::UpdateDrawListGPUResources(RenderState& State)
10621057 };
10631058 std::unordered_map<DrawListItemRenderState, Uint32, DrawListItemRenderState::Hasher> DrawListItemRenderStateIDs;
10641059
1065- bool DrawListDirty = false ;
1060+ bool DrawListDirty = false ;
1061+ m_ValidDrawItemCount = 0 ;
10661062 for (DrawListItem& ListItem : m_DrawList)
10671063 {
10681064 if (!ListItem.DrawItem .IsValid ())
@@ -1071,9 +1067,9 @@ void HnRenderPass::UpdateDrawListGPUResources(RenderState& State)
10711067 continue ;
10721068 }
10731069
1074- auto DrawItemGPUResDirtyFlags = m_DrawListItemsDirtyFlags;
1070+ DRAW_LIST_ITEM_DIRTY_FLAGS DrawItemGPUResDirtyFlags = m_DrawListItemsDirtyFlags;
10751071
1076- const auto Version = ListItem.Mesh .GetGeometryVersion () + ListItem.Mesh .GetMaterialVersion ();
1072+ const Uint32 Version = ListItem.Mesh .GetGeometryVersion () + ListItem.Mesh .GetMaterialVersion ();
10771073 if (ListItem.Version != Version)
10781074 {
10791075 DrawItemGPUResDirtyFlags |= DRAW_LIST_ITEM_DIRTY_FLAG_PSO | DRAW_LIST_ITEM_DIRTY_FLAG_MESH_DATA;
@@ -1088,6 +1084,7 @@ void HnRenderPass::UpdateDrawListGPUResources(RenderState& State)
10881084 // Assign a unique ID to the combination of render states used to render the draw item.
10891085 // We have to do this after we update the draw item GPU resources.
10901086 ListItem.RenderStateID = DrawListItemRenderStateIDs.emplace (DrawListItemRenderState{ListItem}, static_cast <Uint32>(DrawListItemRenderStateIDs.size ())).first ->second ;
1087+ ++m_ValidDrawItemCount;
10911088 }
10921089
10931090 if (DrawListDirty)
@@ -1154,6 +1151,17 @@ void HnRenderPass::UpdateDrawListGPUResources(RenderState& State)
11541151#endif
11551152 }
11561153
1154+ #ifdef DILIGENT_DEBUG
1155+ for (size_t i = 0 ; i < m_ValidDrawItemCount; ++i)
1156+ {
1157+ VERIFY (m_DrawList[i].DrawItem .IsValid (), " All valid draw items must be grouped at the beginning of the list" );
1158+ }
1159+ for (size_t i = m_ValidDrawItemCount; i < m_DrawList.size (); ++i)
1160+ {
1161+ VERIFY (!m_DrawList[i].DrawItem .IsValid (), " All invalid draw items must be grouped at the end of the list" );
1162+ }
1163+ #endif
1164+
11571165 UpdateDrawListJoints (State.RenderDelegate );
11581166 }
11591167
0 commit comments