UI: Remove hardcoded 11 uniform parameters
Using a define makes it easy to increase this later.
This commit is contained in:
parent
c6fccbf842
commit
c06bfe9d09
|
@ -1032,6 +1032,7 @@ static void widgetbase_set_uniform_colors_ubv(
|
|||
|
||||
/* keep in sync with shader */
|
||||
#define MAX_WIDGET_BASE_BATCH 6
|
||||
#define MAX_WIDGET_PARAMETERS 11
|
||||
|
||||
struct {
|
||||
Gwn_Batch *batch; /* Batch type */
|
||||
|
@ -1051,13 +1052,14 @@ void UI_widgetbase_draw_cache_flush(void)
|
|||
if (g_widget_base_batch.count == 1) {
|
||||
/* draw single */
|
||||
GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE);
|
||||
GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)g_widget_base_batch.params);
|
||||
GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params);
|
||||
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
|
||||
GWN_batch_draw(batch);
|
||||
}
|
||||
else {
|
||||
GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST);
|
||||
GWN_batch_uniform_4fv_array(batch, "parameters", 11 * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params);
|
||||
GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH,
|
||||
(float *)g_widget_base_batch.params);
|
||||
GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params);
|
||||
gpuBindMatrices(batch->interface);
|
||||
GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true);
|
||||
|
|
|
@ -78,31 +78,32 @@ const vec2 triavec[37] = vec2[37](
|
|||
|
||||
uniform mat4 ModelViewProjectionMatrix;
|
||||
|
||||
#define MAX_PARAM 11
|
||||
#ifdef USE_INSTANCE
|
||||
#define MAX_INSTANCE 6
|
||||
uniform vec4 parameters[11 * MAX_INSTANCE];
|
||||
uniform vec4 parameters[MAX_PARAM * MAX_INSTANCE];
|
||||
#else
|
||||
uniform vec4 parameters[11];
|
||||
uniform vec4 parameters[MAX_PARAM];
|
||||
#endif
|
||||
|
||||
/* gl_InstanceID is 0 if not drawing instances. */
|
||||
#define recti parameters[gl_InstanceID * 11 + 0]
|
||||
#define rect parameters[gl_InstanceID * 11 + 1]
|
||||
#define radsi parameters[gl_InstanceID * 11 + 2].x
|
||||
#define rads parameters[gl_InstanceID * 11 + 2].y
|
||||
#define faci parameters[gl_InstanceID * 11 + 2].zw
|
||||
#define roundCorners parameters[gl_InstanceID * 11 + 3]
|
||||
#define colorInner1 parameters[gl_InstanceID * 11 + 4]
|
||||
#define colorInner2 parameters[gl_InstanceID * 11 + 5]
|
||||
#define colorEdge parameters[gl_InstanceID * 11 + 6]
|
||||
#define colorEmboss parameters[gl_InstanceID * 11 + 7]
|
||||
#define colorTria parameters[gl_InstanceID * 11 + 8]
|
||||
#define tria1Center parameters[gl_InstanceID * 11 + 9].xy
|
||||
#define tria2Center parameters[gl_InstanceID * 11 + 9].zw
|
||||
#define tria1Size parameters[gl_InstanceID * 11 + 10].x
|
||||
#define tria2Size parameters[gl_InstanceID * 11 + 10].y
|
||||
#define shadeDir parameters[gl_InstanceID * 11 + 10].z
|
||||
#define doAlphaCheck parameters[gl_InstanceID * 11 + 10].w
|
||||
#define recti parameters[gl_InstanceID * MAX_PARAM + 0]
|
||||
#define rect parameters[gl_InstanceID * MAX_PARAM + 1]
|
||||
#define radsi parameters[gl_InstanceID * MAX_PARAM + 2].x
|
||||
#define rads parameters[gl_InstanceID * MAX_PARAM + 2].y
|
||||
#define faci parameters[gl_InstanceID * MAX_PARAM + 2].zw
|
||||
#define roundCorners parameters[gl_InstanceID * MAX_PARAM + 3]
|
||||
#define colorInner1 parameters[gl_InstanceID * MAX_PARAM + 4]
|
||||
#define colorInner2 parameters[gl_InstanceID * MAX_PARAM + 5]
|
||||
#define colorEdge parameters[gl_InstanceID * MAX_PARAM + 6]
|
||||
#define colorEmboss parameters[gl_InstanceID * MAX_PARAM + 7]
|
||||
#define colorTria parameters[gl_InstanceID * MAX_PARAM + 8]
|
||||
#define tria1Center parameters[gl_InstanceID * MAX_PARAM + 9].xy
|
||||
#define tria2Center parameters[gl_InstanceID * MAX_PARAM + 9].zw
|
||||
#define tria1Size parameters[gl_InstanceID * MAX_PARAM + 10].x
|
||||
#define tria2Size parameters[gl_InstanceID * MAX_PARAM + 10].y
|
||||
#define shadeDir parameters[gl_InstanceID * MAX_PARAM + 10].z
|
||||
#define doAlphaCheck parameters[gl_InstanceID * MAX_PARAM + 10].w
|
||||
|
||||
in uint vflag;
|
||||
|
||||
|
|
Loading…
Reference in New Issue