Commit: 186abf7d3bab9ed8b905c6914de02427bb2547cf
Author: Clément Foucault
Date:   Sat Aug 8 23:37:43 2020 +0200
Branches: master
https://developer.blender.org/rB186abf7d3bab9ed8b905c6914de02427bb2547cf

GPUBatch: Remove usage of gl_prim_type outside of GPU module

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

M       source/blender/draw/intern/draw_instance_data.c
M       source/blender/draw/intern/draw_manager_exec.c
M       source/blender/gpu/GPU_batch.h
M       source/blender/gpu/intern/gpu_batch.cc
M       source/blender/gpu/opengl/gl_drawlist.cc

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

diff --git a/source/blender/draw/intern/draw_instance_data.c 
b/source/blender/draw/intern/draw_instance_data.c
index 5005f38c558..a40fc1726d7 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -152,7 +152,7 @@ GPUBatch 
*DRW_temp_batch_instance_request(DRWInstanceDataList *idatalist,
   bool instancer_compat = buf ? ((batch->inst[0] == buf) && (buf->vbo_id != 
0)) :
                                 ((batch->inst[0] == instancer->inst[0]) &&
                                  (batch->inst[1] == instancer->inst[1]));
-  bool is_compatible = (batch->gl_prim_type == geom->gl_prim_type) && 
instancer_compat &&
+  bool is_compatible = (batch->prim_type == geom->prim_type) && 
instancer_compat &&
                        (batch->phase == GPU_BATCH_READY_TO_DRAW) && 
(batch->elem == geom->elem);
   for (int i = 0; i < GPU_BATCH_VBO_MAX_LEN && is_compatible; i++) {
     if (batch->verts[i] != geom->verts[i]) {
@@ -186,7 +186,7 @@ GPUBatch *DRW_temp_batch_request(DRWInstanceDataList 
*idatalist,
 
   GPUBatch *batch = *batch_ptr;
   bool is_compatible = (batch->verts[0] == buf) && (buf->vbo_id != 0) &&
-                       (batch->gl_prim_type == 
convert_prim_type_to_gl(prim_type));
+                       (batch->prim_type == prim_type);
   if (!is_compatible) {
     GPU_batch_clear(batch);
     GPU_batch_init(batch, prim_type, buf, NULL);
diff --git a/source/blender/draw/intern/draw_manager_exec.c 
b/source/blender/draw/intern/draw_manager_exec.c
index 8f5dba87a56..c36b8834b9d 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -865,10 +865,10 @@ BLI_INLINE void draw_select_buffer(DRWShadingGroup 
*shgroup,
   /* Batching */
   if (!is_instancing) {
     /* FIXME: Meh a bit nasty. */
-    if (batch->gl_prim_type == convert_prim_type_to_gl(GPU_PRIM_TRIS)) {
+    if (batch->prim_type == GPU_PRIM_TRIS) {
       count = 3;
     }
-    else if (batch->gl_prim_type == convert_prim_type_to_gl(GPU_PRIM_LINES)) {
+    else if (batch->prim_type == GPU_PRIM_LINES) {
       count = 2;
     }
   }
diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h
index 4b79b175fec..fb273847a9c 100644
--- a/source/blender/gpu/GPU_batch.h
+++ b/source/blender/gpu/GPU_batch.h
@@ -57,7 +57,7 @@ typedef struct GPUBatch {
   GPUVertBuf *inst[GPU_BATCH_INST_VBO_MAX_LEN];
   /** NULL if element list not needed */
   GPUIndexBuf *elem;
-  uint32_t gl_prim_type;
+  GPUPrimType prim_type;
 
   /* cached values (avoid dereferencing later) */
   uint32_t vao_id;
diff --git a/source/blender/gpu/intern/gpu_batch.cc 
b/source/blender/gpu/intern/gpu_batch.cc
index 5b8a3c4636b..0c82279fe6e 100644
--- a/source/blender/gpu/intern/gpu_batch.cc
+++ b/source/blender/gpu/intern/gpu_batch.cc
@@ -115,7 +115,7 @@ void GPU_batch_init_ex(
     batch->inst[v] = NULL;
   }
   batch->elem = elem;
-  batch->gl_prim_type = convert_prim_type_to_gl(prim_type);
+  batch->prim_type = prim_type;
   batch->phase = GPU_BATCH_READY_TO_DRAW;
   batch->is_dynamic_vao_count = false;
   batch->owns_flag = owns_flag;
@@ -127,7 +127,7 @@ void GPU_batch_copy(GPUBatch *batch_dst, GPUBatch 
*batch_src)
 {
   GPU_batch_init_ex(batch_dst, GPU_PRIM_POINTS, batch_src->verts[0], 
batch_src->elem, 0);
 
-  batch_dst->gl_prim_type = batch_src->gl_prim_type;
+  batch_dst->prim_type = batch_src->prim_type;
   for (int v = 1; v < GPU_BATCH_VBO_MAX_LEN; v++) {
     batch_dst->verts[v] = batch_src->verts[v];
   }
@@ -744,6 +744,8 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, 
int v_count, int i_fi
     }
   }
 
+  GLenum gl_prim_type = convert_prim_type_to_gl(batch->prim_type);
+
   if (batch->elem) {
     const GPUIndexBuf *el = batch->elem;
     GLenum index_type = INDEX_TYPE(el);
@@ -752,11 +754,11 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int 
v_first, int v_count, int i_fi
 
     if (GPU_arb_base_instance_is_supported()) {
       glDrawElementsInstancedBaseVertexBaseInstance(
-          batch->gl_prim_type, v_count, index_type, v_first_ofs, i_count, 
base_index, i_first);
+          gl_prim_type, v_count, index_type, v_first_ofs, i_count, base_index, 
i_first);
     }
     else {
       glDrawElementsInstancedBaseVertex(
-          batch->gl_prim_type, v_count, index_type, v_first_ofs, i_count, 
base_index);
+          gl_prim_type, v_count, index_type, v_first_ofs, i_count, base_index);
     }
   }
   else {
@@ -764,10 +766,10 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int 
v_first, int v_count, int i_fi
     glDisable(GL_PRIMITIVE_RESTART);
 #endif
     if (GPU_arb_base_instance_is_supported()) {
-      glDrawArraysInstancedBaseInstance(batch->gl_prim_type, v_first, v_count, 
i_count, i_first);
+      glDrawArraysInstancedBaseInstance(gl_prim_type, v_first, v_count, 
i_count, i_first);
     }
     else {
-      glDrawArraysInstanced(batch->gl_prim_type, v_first, v_count, i_count);
+      glDrawArraysInstanced(gl_prim_type, v_first, v_count, i_count);
     }
 #ifdef __APPLE__
     glEnable(GL_PRIMITIVE_RESTART);
diff --git a/source/blender/gpu/opengl/gl_drawlist.cc 
b/source/blender/gpu/opengl/gl_drawlist.cc
index 3fc6985e582..f24bfdc8751 100644
--- a/source/blender/gpu/opengl/gl_drawlist.cc
+++ b/source/blender/gpu/opengl/gl_drawlist.cc
@@ -33,6 +33,7 @@
 
 #include "gpu_context_private.hh"
 #include "gpu_drawlist_private.hh"
+#include "gpu_primitive_private.h"
 
 #include "gl_backend.hh"
 #include "gl_drawlist.hh"
@@ -193,8 +194,7 @@ void GLDrawList::submit(void)
    * case where only a few instances are needed to finish filling a call 
buffer. */
   const bool is_finishing_a_buffer = (command_offset_ >= data_size_);
   if (command_len_ > 2 || is_finishing_a_buffer) {
-    // GLenum prim = convert_prim_type_to_gl(batch_->prim_type);
-    GLenum prim = batch_->gl_prim_type;
+    GLenum prim = convert_prim_type_to_gl(batch_->prim_type);
     void *offset = (void *)data_offset_;
 
     glBindBuffer(GL_DRAW_INDIRECT_BUFFER, buffer_id_);

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

Reply via email to