@@ -215,14 +215,17 @@ void RenderCommandList::DrawIndexed(Primitive primitive_type, uint32_t index_cou
215215if (m_is_validation_enabled)
216216 {
217217const DrawingState& drawing_state =GetDrawingState ();
218+ META_CHECK_NOT_NULL_DESCR (drawing_state.render_state_ptr ," render state must be set before indexed draw call" );
219+ META_CHECK_NOT_NULL_DESCR (drawing_state.view_state_ptr ," view state must be set before indexed draw call" );
218220META_CHECK_NOT_NULL_DESCR (drawing_state.index_buffer_ptr ," index buffer must be set before indexed draw call" );
219221META_CHECK_NOT_NULL_DESCR (drawing_state.vertex_buffer_set_ptr ," vertex buffers must be set before draw call" );
220222
221223const uint32_t formatted_items_count = drawing_state.index_buffer_ptr ->GetFormattedItemsCount ();
222224META_CHECK_NOT_ZERO_DESCR (formatted_items_count," can not draw with index buffer which contains no formatted vertices" );
223225META_CHECK_NOT_ZERO_DESCR (index_count," can not draw zero index/vertex count" );
224226META_CHECK_NOT_ZERO_DESCR (instance_count," can not draw zero instances" );
225- META_CHECK_LESS_DESCR (start_index, formatted_items_count - index_count +1U ," ending index is out of buffer bounds" );
227+ META_CHECK_LESS_OR_EQUAL_DESCR (index_count, formatted_items_count," can not draw more indices than available in the index buffer" );
228+ META_CHECK_LESS_OR_EQUAL_DESCR (start_index, formatted_items_count - index_count," ending index is out of buffer bounds" );
226229
227230ValidateDrawVertexBuffers (start_vertex);
228231 }
@@ -245,6 +248,7 @@ void RenderCommandList::Draw(Primitive primitive_type, uint32_t vertex_count, ui
245248 {
246249const DrawingState& drawing_state =GetDrawingState ();
247250META_CHECK_NOT_NULL_DESCR (drawing_state.render_state_ptr ," render state must be set before draw call" );
251+ META_CHECK_NOT_NULL_DESCR (drawing_state.view_state_ptr ," view state must be set before draw call" );
248252const size_t input_buffers_count = drawing_state.render_state_ptr ->GetSettings ().program_ptr ->GetSettings ().input_buffer_layouts .size ();
249253META_CHECK_TRUE_DESCR (!input_buffers_count || drawing_state.vertex_buffer_set_ptr ,
250254" vertex buffers must be set when program has non empty input buffer layouts" );
@@ -322,10 +326,13 @@ void RenderCommandList::ValidateDrawVertexBuffers(uint32_t draw_start_vertex, ui
322326const Rhi::IBuffer& vertex_buffer = (*m_drawing_state.vertex_buffer_set_ptr )[vertex_buffer_index];
323327const uint32_t vertex_count = vertex_buffer.GetFormattedItemsCount ();
324328META_UNUSED (vertex_count);
325- META_CHECK_LESS_DESCR (draw_start_vertex, vertex_count - draw_vertex_count +1U ,
326- " can not draw starting from vertex {}{} which is out of bounds for vertex buffer '{}' with vertex count {}" ,
327- draw_start_vertex, draw_vertex_count ?fmt::format (" with {} vertex count" , draw_vertex_count) :" " ,
328- vertex_buffer.GetName (), vertex_count);
329+ META_CHECK_LESS_OR_EQUAL_DESCR (draw_vertex_count, vertex_count,
330+ " vertex count to draw is out of bounds of initialized vertex size for buffer '{}'" ,
331+ vertex_buffer.GetName ());
332+ META_CHECK_LESS_OR_EQUAL_DESCR (draw_start_vertex, vertex_count - draw_vertex_count,
333+ " can not draw starting from vertex {}{} which is out of bounds for vertex buffer '{}' with vertex count {}" ,
334+ draw_start_vertex, draw_vertex_count ?fmt::format (" with {} vertex count" , draw_vertex_count) :" " ,
335+ vertex_buffer.GetName (), vertex_count);
329336 }
330337}
331338