Cleanup: DRW: Remove unused Uniform types

This commit is contained in:
Clément Foucault 2019-05-13 19:20:27 +02:00
parent be5192bbb9
commit 92b4e96afe
3 changed files with 16 additions and 52 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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;