[Bf-blender-cvs] [31ff2fd530b] tmp-drw-callbatching: Cleanup: DRW: Remove unused vars and reduce size of DRWUniform

Clément Foucault noreply at git.blender.org
Sat Aug 17 14:49:36 CEST 2019


Commit: 31ff2fd530bc0ff808c5f5d5e8cdf435313ae9ac
Author: Clément Foucault
Date:   Sat Jun 1 23:27:08 2019 +0200
Branches: tmp-drw-callbatching
https://developer.blender.org/rB31ff2fd530bc0ff808c5f5d5e8cdf435313ae9ac

Cleanup: DRW: Remove unused vars and reduce size of DRWUniform

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

M	source/blender/draw/intern/draw_manager.h
M	source/blender/draw/intern/draw_manager_data.c
M	source/blender/draw/intern/draw_manager_exec.c

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

diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 9dfd4d9d0bf..941bc6cba84 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -168,7 +168,7 @@ typedef struct DRWCall {
 
 /* Used by DRWUniform.type */
 typedef enum {
-  DRW_UNIFORM_INT,
+  DRW_UNIFORM_INT = 0,
   DRW_UNIFORM_INT_COPY,
   DRW_UNIFORM_FLOAT,
   DRW_UNIFORM_FLOAT_COPY,
@@ -192,11 +192,11 @@ struct DRWUniform {
     float fvalue[2];
     int ivalue[2];
   };
-  int name_ofs; /* name offset in name buffer. */
   int location;
-  char type;      /* DRWUniformType */
-  char length;    /* cannot be more than 16 */
-  char arraysize; /* cannot be more than 16 too */
+  uint32_t type : 4;      /* DRWUniformType */
+  uint32_t length : 4;    /* cannot be more than 16 */
+  uint32_t arraysize : 4; /* cannot be more than 16 too */
+  uint32_t name_ofs : 20; /* name offset in name buffer. */
 };
 
 struct DRWShadingGroup {
@@ -224,7 +224,6 @@ struct DRWShadingGroup {
   int model;
   int modelinverse;
   int modelviewprojection;
-  int orcotexfac;
   int objectinfo;
   int callid;
 
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 53ca496b4e5..0142da8c170 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -483,7 +483,7 @@ static DRWResourceHandle drw_call_handle_object(DRWShadingGroup *shgroup,
       DST.ob_state_obinfo_init = false;
     }
 
-    if (shgroup->objectinfo != -1 || shgroup->orcotexfac != -1) {
+    if (shgroup->objectinfo != -1) {
       if (!DST.ob_state_obinfo_init) {
         DST.ob_state_obinfo_init = true;
 
@@ -889,13 +889,10 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
     drw_shgroup_uniform_create_ex(
         shgroup, info_ubo_location, DRW_UNIFORM_BLOCK_OBINFOS, NULL, 0, 1);
 
-    shgroup->orcotexfac = -1;
-    /* Abusing this loc. */
+    /* Abusing this loc to tell shgroup we need the obinfos. */
     shgroup->objectinfo = 1;
   }
   else {
-    /* TODO remove */
-    shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_ORCO);
     shgroup->objectinfo = -1;
   }
 
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 30d07eec0cb..9afcf8ce44e 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -576,6 +576,7 @@ static void draw_compute_culling(DRWView *view)
 
 BLI_INLINE void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWResourceHandle handle)
 {
+  /* Still supported for compatibility with gpu_shader_* but should be forbidden. */
   if (shgroup->model != -1 || shgroup->modelinverse != -1 || shgroup->modelviewprojection != -1) {
     DRWObjectMatrix *ob_mats = BLI_memblock_elem_get(
         DST.vmempool->obmats, handle.chunk, handle.id);
@@ -595,17 +596,6 @@ BLI_INLINE void draw_geometry_prepare(DRWShadingGroup *shgroup, DRWResourceHandl
           shgroup->shader, shgroup->modelviewprojection, 16, 1, (float *)mvp);
     }
   }
-  if (shgroup->objectinfo != -1 && shgroup->orcotexfac != -1) {
-    DRWObjectInfos *ob_infos = BLI_memblock_elem_get(
-        DST.vmempool->obmats, handle.chunk, handle.id);
-    if (shgroup->objectinfo != -1) {
-      GPU_shader_uniform_vector(shgroup->shader, shgroup->objectinfo, 4, 1, &ob_infos->ob_index);
-    }
-    if (shgroup->orcotexfac != -1) {
-      GPU_shader_uniform_vector(
-          shgroup->shader, shgroup->orcotexfac, 4, 2, (float *)ob_infos->orcotexfac);
-    }
-  }
 }
 
 BLI_INLINE void draw_geometry_execute(DRWShadingGroup *shgroup,



More information about the Bf-blender-cvs mailing list