Commit: 41235eed1dad40abf7a34750beedff1176e0c6e5
Author: Clément Foucault
Date:   Tue Aug 18 13:53:00 2020 +0200
Branches: master
https://developer.blender.org/rB41235eed1dad40abf7a34750beedff1176e0c6e5

GPU: Avoid invalid GL API usage

Drawing with 0 sized buffer is prohibited.

===================================================================

M       source/blender/gpu/opengl/gl_batch.cc
M       source/blender/gpu/opengl/gl_drawlist.cc

===================================================================

diff --git a/source/blender/gpu/opengl/gl_batch.cc 
b/source/blender/gpu/opengl/gl_batch.cc
index 00e1a61f7cf..38448e8a0b8 100644
--- a/source/blender/gpu/opengl/gl_batch.cc
+++ b/source/blender/gpu/opengl/gl_batch.cc
@@ -325,6 +325,8 @@ void GLBatch::draw(int v_first, int v_count, int i_first, 
int i_count)
 {
   this->bind(i_first);
 
+  BLI_assert(v_count > 0 && i_count > 0);
+
   GLenum gl_type = convert_prim_type_to_gl(prim_type);
 
   if (elem) {
diff --git a/source/blender/gpu/opengl/gl_drawlist.cc 
b/source/blender/gpu/opengl/gl_drawlist.cc
index b02681af892..16ea924d8dc 100644
--- a/source/blender/gpu/opengl/gl_drawlist.cc
+++ b/source/blender/gpu/opengl/gl_drawlist.cc
@@ -151,6 +151,11 @@ void GLDrawList::append(GPUBatch *batch, int i_first, int 
i_count)
     v_count_ = batch->elem ? batch->elem->index_len : 
batch->verts[0]->vertex_len;
   }
 
+  if (v_count_ == 0) {
+    /* Nothing to draw. */
+    return;
+  }
+
   if (MDI_INDEXED) {
     GLDrawCommandIndexed *cmd = reinterpret_cast<GLDrawCommandIndexed *>(data_ 
+ command_offset_);
     cmd->v_first = v_first_;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to