DRW/GWN: Add callId builtin uniform.
This uniforms can be used to have a unique id for each drawcall of a shgrp. This only works for standard shgroups and is an exception for the outline drawing.
This commit is contained in:
parent
2b0b4133c8
commit
dccda1fe43
|
@ -36,6 +36,7 @@ typedef enum {
|
|||
|
||||
GWN_UNIFORM_COLOR, // vec4 color
|
||||
GWN_UNIFORM_EYE, // vec3 eye
|
||||
GWN_UNIFORM_CALLID, // int callId
|
||||
|
||||
GWN_UNIFORM_CUSTOM, // custom uniform, not one of the above built-ins
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ static const char* BuiltinUniform_name(Gwn_UniformBuiltin u)
|
|||
|
||||
[GWN_UNIFORM_COLOR] = "color",
|
||||
[GWN_UNIFORM_EYE] = "eye",
|
||||
[GWN_UNIFORM_CALLID] = "callId",
|
||||
|
||||
[GWN_UNIFORM_CUSTOM] = NULL,
|
||||
[GWN_NUM_UNIFORMS] = NULL,
|
||||
|
|
|
@ -222,6 +222,7 @@ struct DRWShadingGroup {
|
|||
int normalworld;
|
||||
int orcotexfac;
|
||||
int eye;
|
||||
int callid;
|
||||
uint16_t matflag; /* Matrices needed, same as DRWCall.flag */
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
|
|
@ -498,6 +498,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
|
|||
shgroup->normalworld = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_WORLDNORMAL);
|
||||
shgroup->orcotexfac = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_ORCO);
|
||||
shgroup->eye = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_EYE);
|
||||
shgroup->callid = GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_CALLID);
|
||||
|
||||
shgroup->matflag = 0;
|
||||
if (shgroup->modelinverse > -1)
|
||||
|
|
|
@ -1005,6 +1005,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
}
|
||||
else {
|
||||
bool prev_neg_scale = false;
|
||||
int callid = 0;
|
||||
for (DRWCall *call = shgroup->calls.first; call; call = call->next) {
|
||||
|
||||
/* OPTI/IDEA(clem): Do this preparation in another thread. */
|
||||
|
@ -1013,6 +1014,12 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
if ((call->state->flag & DRW_CALL_CULLED) != 0)
|
||||
continue;
|
||||
|
||||
/* XXX small exception/optimisation for outline rendering. */
|
||||
if (shgroup->callid != -1) {
|
||||
GPU_shader_uniform_vector_int(shgroup->shader, shgroup->callid, 1, 1, &callid);
|
||||
callid += 1;
|
||||
}
|
||||
|
||||
/* Negative scale objects */
|
||||
bool neg_scale = call->state->flag & DRW_CALL_NEGSCALE;
|
||||
if (neg_scale != prev_neg_scale) {
|
||||
|
|
Loading…
Reference in New Issue