diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 2 | ||||
-rw-r--r-- | source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 6 | ||||
-rw-r--r-- | source/blender/editors/space_node/drawnode.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/GPU_batch.h | 30 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.cc | 81 |
7 files changed, 31 insertions, 106 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index e436424b460..4aa12ff2d23 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -2475,7 +2475,7 @@ void DRW_draw_depth_object( GPU_SHADER_CFG_DEFAULT; GPU_batch_program_set_builtin_with_config(batch, GPU_SHADER_3D_DEPTH_ONLY, sh_cfg); if (world_clip_planes != NULL) { - GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes[0]); + GPU_batch_uniform_4fv_array(batch, "WorldClipPlanes", 6, world_clip_planes); } GPU_batch_draw(batch); diff --git a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c index c5231b3cd96..ef3381110d4 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/button2d_gizmo.c @@ -226,10 +226,10 @@ static void button2d_draw_intern(const bContext *C, float color_contrast[4]; copy_v3_fl(color_contrast, rgb_to_grayscale(color) < 0.2f ? 1 : 0); color_contrast[3] = color[3]; - GPU_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color_contrast)); + GPU_shader_uniform_4f(button->shape_batch[i]->shader, "color", UNPACK4(color_contrast)); } else { - GPU_batch_uniform_4f(button->shape_batch[i], "color", UNPACK4(color)); + GPU_shader_uniform_4f(button->shape_batch[i]->shader, "color", UNPACK4(color)); } GPU_batch_draw(button->shape_batch[i]); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 6cd274c8b15..fb09320a0f2 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -161,7 +161,7 @@ void UI_draw_roundbox_aa( GPUBatch *batch = ui_batch_roundbox_widget_get(); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float(*)[4]) & widget_params); GPU_blend(true); @@ -290,7 +290,7 @@ void UI_draw_roundbox_4fv( GPUBatch *batch = ui_batch_roundbox_widget_get(); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float(*)[4]) & widget_params); GPU_blend(true); @@ -483,7 +483,7 @@ void UI_draw_roundbox_shade_x(bool filled, GPUBatch *batch = ui_batch_roundbox_widget_get(); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float(*)[4]) & widget_params); GPU_batch_draw(batch); GPU_blend(false); @@ -2760,7 +2760,7 @@ void ui_draw_dropshadow( GPUBatch *batch = ui_batch_roundbox_shadow_get(); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); - GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); + GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float(*)[4]) & widget_params); GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility); GPU_batch_draw(batch); diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 1be62e535de..01e03a2a83b 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -1170,7 +1170,7 @@ void UI_widgetbase_draw_cache_flush(void) /* draw single */ GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); GPU_batch_uniform_4fv_array( - batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); + batch, "parameters", MAX_WIDGET_PARAMETERS, (float(*)[4])g_widget_base_batch.params); GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GPU_batch_draw(batch); } @@ -1179,7 +1179,7 @@ void UI_widgetbase_draw_cache_flush(void) GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, - (float *)g_widget_base_batch.params); + (float(*)[4])g_widget_base_batch.params); GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GPU_batch_draw_instanced(batch, g_widget_base_batch.count); } @@ -1247,7 +1247,7 @@ static void draw_widgetbase_batch(uiWidgetBase *wtb) GPUBatch *batch = ui_batch_roundbox_widget_get(); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); GPU_batch_uniform_4fv_array( - batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)&wtb->uniform_params); + batch, "parameters", MAX_WIDGET_PARAMETERS, (float(*)[4]) & wtb->uniform_params); GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); GPU_batch_draw(batch); } diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 37daa881317..8f15cd82fe0 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -4026,7 +4026,7 @@ static void nodelink_batch_draw(SpaceNode *snode) GPU_vertbuf_use(g_batch_link.inst_vbo); /* force update. */ GPU_batch_program_set_builtin(g_batch_link.batch, GPU_SHADER_2D_NODELINK_INST); - GPU_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, (float *)colors); + GPU_batch_uniform_4fv_array(g_batch_link.batch, "colors", 6, colors); GPU_batch_uniform_1f(g_batch_link.batch, "expandSize", snode->aspect * LINK_WIDTH); GPU_batch_uniform_1f(g_batch_link.batch, "arrowSize", ARROW_SIZE); GPU_batch_draw(g_batch_link.batch); @@ -4108,8 +4108,8 @@ void node_draw_link_bezier( GPUBatch *batch = g_batch_link.batch_single; GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_NODELINK); - GPU_batch_uniform_2fv_array(batch, "bezierPts", 4, (float *)vec); - GPU_batch_uniform_4fv_array(batch, "colors", 3, (float *)colors); + GPU_batch_uniform_2fv_array(batch, "bezierPts", 4, vec); + GPU_batch_uniform_4fv_array(batch, "colors", 3, colors); GPU_batch_uniform_1f(batch, "expandSize", snode->aspect * LINK_WIDTH); GPU_batch_uniform_1f(batch, "arrowSize", ARROW_SIZE); GPU_batch_uniform_1i(batch, "doArrow", drawarrow); diff --git a/source/blender/gpu/GPU_batch.h b/source/blender/gpu/GPU_batch.h index d57739156f8..e87ad328f1d 100644 --- a/source/blender/gpu/GPU_batch.h +++ b/source/blender/gpu/GPU_batch.h @@ -128,18 +128,24 @@ void GPU_batch_program_set_builtin_with_config(GPUBatch *batch, eGPUShaderConfig sh_cfg); /* Will only work after setting the batch program. */ -void GPU_batch_uniform_1i(GPUBatch *, const char *name, int value); -void GPU_batch_uniform_1b(GPUBatch *, const char *name, bool value); -void GPU_batch_uniform_1f(GPUBatch *, const char *name, float value); -void GPU_batch_uniform_2f(GPUBatch *, const char *name, float x, float y); -void GPU_batch_uniform_3f(GPUBatch *, const char *name, float x, float y, float z); -void GPU_batch_uniform_4f(GPUBatch *, const char *name, float x, float y, float z, float w); -void GPU_batch_uniform_2fv(GPUBatch *, const char *name, const float data[2]); -void GPU_batch_uniform_3fv(GPUBatch *, const char *name, const float data[3]); -void GPU_batch_uniform_4fv(GPUBatch *, const char *name, const float data[4]); -void GPU_batch_uniform_2fv_array(GPUBatch *, const char *name, const int len, const float *data); -void GPU_batch_uniform_4fv_array(GPUBatch *, const char *name, const int len, const float *data); -void GPU_batch_uniform_mat4(GPUBatch *, const char *name, const float data[4][4]); +/* TODO(fclem) Theses needs to be replaced by GPU_shader_uniform_* with explicit shader. */ +#define GPU_batch_uniform_1i(batch, name, x) GPU_shader_uniform_1i((batch)->shader, name, x); +#define GPU_batch_uniform_1b(batch, name, x) GPU_shader_uniform_1b((batch)->shader, name, x); +#define GPU_batch_uniform_1f(batch, name, x) GPU_shader_uniform_1f((batch)->shader, name, x); +#define GPU_batch_uniform_2f(batch, name, x, y) GPU_shader_uniform_2f((batch)->shader, name, x, y); +#define GPU_batch_uniform_3f(batch, name, x, y, z) \ + GPU_shader_uniform_3f((batch)->shader, name, x, y, z); +#define GPU_batch_uniform_4f(batch, name, x, y, z, w) \ + GPU_shader_uniform_4f((batch)->shader, name, x, y, z, w); +#define GPU_batch_uniform_2fv(batch, name, val) GPU_shader_uniform_2fv((batch)->shader, name, val); +#define GPU_batch_uniform_3fv(batch, name, val) GPU_shader_uniform_3fv((batch)->shader, name, val); +#define GPU_batch_uniform_4fv(batch, name, val) GPU_shader_uniform_4fv((batch)->shader, name, val); +#define GPU_batch_uniform_2fv_array(batch, name, len, val) \ + GPU_shader_uniform_2fv_array((batch)->shader, name, len, val); +#define GPU_batch_uniform_4fv_array(batch, name, len, val) \ + GPU_shader_uniform_4fv_array((batch)->shader, name, len, val); +#define GPU_batch_uniform_mat4(batch, name, val) \ + GPU_shader_uniform_mat4((batch)->shader, name, val); void GPU_batch_draw(GPUBatch *batch); void GPU_batch_draw_range(GPUBatch *batch, int v_first, int v_count); diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc index 9efb6b464bc..b0a0c142036 100644 --- a/source/blender/gpu/intern/gpu_batch.cc +++ b/source/blender/gpu/intern/gpu_batch.cc @@ -226,87 +226,6 @@ void GPU_batch_set_shader(GPUBatch *batch, GPUShader *shader) GPU_shader_bind(batch->shader); } -#define GET_UNIFORM \ - const GPUShaderInput *uniform = GPU_shaderinterface_uniform(batch->shader->interface, name); \ - BLI_assert(uniform); - -void GPU_batch_uniform_1i(GPUBatch *batch, const char *name, int value) -{ - GET_UNIFORM - GPU_shader_uniform_int(batch->shader, uniform->location, value); -} - -void GPU_batch_uniform_1b(GPUBatch *batch, const char *name, bool value) -{ - GPU_batch_uniform_1i(batch, name, value ? GL_TRUE : GL_FALSE); -} - -void GPU_batch_uniform_2f(GPUBatch *batch, const char *name, float x, float y) -{ - const float data[2] = {x, y}; - GPU_batch_uniform_2fv(batch, name, data); -} - -void GPU_batch_uniform_3f(GPUBatch *batch, const char *name, float x, float y, float z) -{ - const float data[3] = {x, y, z}; - GPU_batch_uniform_3fv(batch, name, data); -} - -void GPU_batch_uniform_4f(GPUBatch *batch, const char *name, float x, float y, float z, float w) -{ - const float data[4] = {x, y, z, w}; - GPU_batch_uniform_4fv(batch, name, data); -} - -void GPU_batch_uniform_1f(GPUBatch *batch, const char *name, float x) -{ - GET_UNIFORM - GPU_shader_uniform_float(batch->shader, uniform->location, x); -} - -void GPU_batch_uniform_2fv(GPUBatch *batch, const char *name, const float data[2]) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 2, 1, data); -} - -void GPU_batch_uniform_3fv(GPUBatch *batch, const char *name, const float data[3]) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 3, 1, data); -} - -void GPU_batch_uniform_4fv(GPUBatch *batch, const char *name, const float data[4]) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 4, 1, data); -} - -void GPU_batch_uniform_2fv_array(GPUBatch *batch, - const char *name, - const int len, - const float *data) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 2, len, data); -} - -void GPU_batch_uniform_4fv_array(GPUBatch *batch, - const char *name, - const int len, - const float *data) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 4, len, data); -} - -void GPU_batch_uniform_mat4(GPUBatch *batch, const char *name, const float data[4][4]) -{ - GET_UNIFORM - GPU_shader_uniform_vector(batch->shader, uniform->location, 16, 1, (const float *)data); -} - /** \} */ /* -------------------------------------------------------------------- */ |