From db349c75a9563d38afaf1a8a602d9ee1155d62bb Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sat, 3 Apr 2021 21:55:58 +0300 Subject: [PATCH] Do an early return from Mesh::draw if there's no data Otherwise if would try to set zero-sized storage for the buffers, which is not allowed. Also guard against empty batches in resize_buffers just in case. --- source/core/mesh.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/core/mesh.cpp b/source/core/mesh.cpp index 3a79f3e5..d3fd7360 100644 --- a/source/core/mesh.cpp +++ b/source/core/mesh.cpp @@ -155,6 +155,9 @@ void Mesh::draw(Renderer &renderer, const VertexSetup *vs, unsigned count) const return; } + if(batches.empty()) + return; + if(dirty) resize_buffers(); @@ -177,7 +180,7 @@ void Mesh::resize_buffers() const { if(dirty&VERTEX_BUFFER) vbuf->storage(vertices.get_required_buffer_size()); - if(dirty&INDEX_BUFFER) + if((dirty&INDEX_BUFFER) && !batches.empty()) ibuf->storage(batches.front().get_required_buffer_size()); dirty = 0; } -- 2.43.0