diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-05-13 20:20:27 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-05-14 11:57:04 +0300 |
commit | 92b4e96afed7bbc63e969f213266beaebc4c71b9 (patch) | |
tree | db79f43428934dc0605d3b9f554f44ef4e82175d | |
parent | be5192bbb9981a8b82ae47e695f084e23c96f519 (diff) |
Cleanup: DRW: Remove unused Uniform types
-rw-r--r-- | source/blender/draw/intern/draw_manager.h | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_data.c | 32 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_exec.c | 28 |
3 files changed, 16 insertions, 52 deletions
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h index c2287acf8e9..b5dc88205db 100644 --- a/source/blender/draw/intern/draw_manager.h +++ b/source/blender/draw/intern/draw_manager.h @@ -142,10 +142,6 @@ typedef struct DRWCall { /* Used by DRWUniform.type */ typedef enum { - DRW_UNIFORM_BOOL, - DRW_UNIFORM_BOOL_COPY, - DRW_UNIFORM_SHORT_TO_INT, - DRW_UNIFORM_SHORT_TO_FLOAT, DRW_UNIFORM_INT, DRW_UNIFORM_INT_COPY, DRW_UNIFORM_FLOAT, @@ -163,8 +159,8 @@ struct DRWUniform { /* For reference or array/vector types. */ const void *pvalue; /* Single values. */ - float fvalue; - int ivalue; + float fvalue[2]; + int ivalue[2]; }; int name_ofs; /* name offset in name buffer. */ int location; diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c index 1d44ac069f4..1a58cb4c25f 100644 --- a/source/blender/draw/intern/draw_manager_data.c +++ b/source/blender/draw/intern/draw_manager_data.c @@ -83,16 +83,15 @@ static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup, switch (type) { case DRW_UNIFORM_INT_COPY: - uni->ivalue = *((int *)value); - break; - case DRW_UNIFORM_BOOL_COPY: - uni->ivalue = (int)*((bool *)value); + BLI_assert(length <= 2); + memcpy(uni->ivalue, value, sizeof(int) * length); break; case DRW_UNIFORM_FLOAT_COPY: - uni->fvalue = *((float *)value); + BLI_assert(length <= 2); + memcpy(uni->fvalue, value, sizeof(float) * length); break; default: - uni->pvalue = value; + uni->pvalue = (const float *)value; break; } @@ -200,7 +199,7 @@ void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const int *value, int arraysize) { - drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BOOL, value, 1, arraysize); + drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT, value, 1, arraysize); } void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, @@ -235,22 +234,6 @@ void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_FLOAT, value, 4, arraysize); } -void DRW_shgroup_uniform_short_to_int(DRWShadingGroup *shgroup, - const char *name, - const short *value, - int arraysize) -{ - drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_INT, value, 1, arraysize); -} - -void DRW_shgroup_uniform_short_to_float(DRWShadingGroup *shgroup, - const char *name, - const short *value, - int arraysize) -{ - drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_SHORT_TO_FLOAT, value, 1, arraysize); -} - void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, @@ -301,7 +284,8 @@ void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, co void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value) { - drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_BOOL_COPY, &value, 1, 1); + int ival = value; + drw_shgroup_uniform(shgroup, name, DRW_UNIFORM_INT_COPY, &ival, 1, 1); } void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value) diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c index e1ef2e81b8d..f76c46a9146 100644 --- a/source/blender/draw/intern/draw_manager_exec.c +++ b/source/blender/draw/intern/draw_manager_exec.c @@ -1090,8 +1090,6 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) GPUTexture *tex; GPUUniformBuffer *ubo; - int val; - float fval; const bool shader_changed = (DST.shader != shgroup->shader); bool use_tfeedback = false; @@ -1123,34 +1121,20 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state) continue; } } + const void *data = uni->pvalue; + if (ELEM(uni->type, DRW_UNIFORM_INT_COPY, DRW_UNIFORM_FLOAT_COPY)) { + data = uni->fvalue; + } switch (uni->type) { - case DRW_UNIFORM_SHORT_TO_INT: - val = (int)*((short *)uni->pvalue); - GPU_shader_uniform_vector_int( - shgroup->shader, uni->location, uni->length, uni->arraysize, &val); - break; - case DRW_UNIFORM_SHORT_TO_FLOAT: - fval = (float)*((short *)uni->pvalue); - GPU_shader_uniform_vector( - shgroup->shader, uni->location, uni->length, uni->arraysize, (float *)&fval); - break; - case DRW_UNIFORM_BOOL_COPY: case DRW_UNIFORM_INT_COPY: - GPU_shader_uniform_vector_int( - shgroup->shader, uni->location, uni->length, uni->arraysize, &uni->ivalue); - break; - case DRW_UNIFORM_BOOL: case DRW_UNIFORM_INT: GPU_shader_uniform_vector_int( - shgroup->shader, uni->location, uni->length, uni->arraysize, (int *)uni->pvalue); + shgroup->shader, uni->location, uni->length, uni->arraysize, data); break; case DRW_UNIFORM_FLOAT_COPY: - GPU_shader_uniform_vector( - shgroup->shader, uni->location, uni->length, uni->arraysize, &uni->fvalue); - break; case DRW_UNIFORM_FLOAT: GPU_shader_uniform_vector( - shgroup->shader, uni->location, uni->length, uni->arraysize, (float *)uni->pvalue); + shgroup->shader, uni->location, uni->length, uni->arraysize, data); break; case DRW_UNIFORM_TEXTURE: tex = (GPUTexture *)uni->pvalue; |