Commit: baf2835ff746b4ac1b8b2478be8aea9928604970 Author: Germano Cavalcante Date: Thu Sep 1 10:04:00 2022 -0300 Branches: master https://developer.blender.org/rBbaf2835ff746b4ac1b8b2478be8aea9928604970
GPU: remove 'GPU_SHADER_2D_FLAT_COLOR' The only real difference between `GPU_SHADER_2D_FLAT_COLOR` and `GPU_SHADER_3D_FLAT_COLOR` is that in the vertex shader the 2D version uses `vec4(pos, 0.0, 1.0)` and the 3D version uses `vec4(pos, 1.0)`. But VBOs with 2D attributes work perfectly in shaders that use 3D attributes. Components not specified are filled with components from `vec4(0.0, 0.0, 0.0, 1.0)`. So there is no real benefit to having two different shader versions. This will simplify porting shaders to python as it will not be necessary to use a 3D and a 2D version of the shaders. In python the new name for '2D_FLAT_COLOR'' and '3D_FLAT_COLOR' is 'FLAT_COLOR', but the old names still work for backward compatibility. =================================================================== M source/blender/draw/intern/draw_view.c M source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c M source/blender/editors/interface/interface_draw.c M source/blender/editors/interface/interface_panel.cc M source/blender/editors/interface/view2d.cc M source/blender/editors/screen/area.c M source/blender/editors/space_file/file_draw.c M source/blender/editors/space_graph/graph_draw.c M source/blender/editors/space_sequencer/sequencer_draw.c M source/blender/editors/space_view3d/view3d_draw.c M source/blender/gpu/CMakeLists.txt M source/blender/gpu/GPU_shader.h M source/blender/gpu/intern/gpu_immediate.cc M source/blender/gpu/intern/gpu_shader_builtin.c D source/blender/gpu/shaders/gpu_shader_2D_flat_color_vert.glsl D source/blender/gpu/shaders/infos/gpu_shader_2D_flat_color_info.hh =================================================================== diff --git a/source/blender/draw/intern/draw_view.c b/source/blender/draw/intern/draw_view.c index 817f97cbea4..35ff8891a0f 100644 --- a/source/blender/draw/intern/draw_view.c +++ b/source/blender/draw/intern/draw_view.c @@ -175,7 +175,7 @@ void DRW_draw_cursor(void) GPU_matrix_scale_2f(U.widget_unit, U.widget_unit); GPUBatch *cursor_batch = DRW_cache_cursor_get(is_aligned); - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR); GPU_batch_set_shader(cursor_batch, shader); GPU_batch_draw(cursor_batch); @@ -241,7 +241,7 @@ void DRW_draw_cursor_2d_ex(const ARegion *region, const float cursor[2]) GPUBatch *cursor_batch = DRW_cache_cursor_get(true); - GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_FLAT_COLOR); + GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR); GPU_batch_set_shader(cursor_batch, shader); GPU_batch_draw(cursor_batch); diff --git a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c index 1c8985b1ad7..600abaf3737 100644 --- a/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c +++ b/source/blender/editors/gizmo_library/gizmo_types/cage2d_gizmo.c @@ -388,7 +388,7 @@ static void cage2d_draw_box_interaction(const float color[4], .pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT), .col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT), }; - immBindBuiltinProgram(is_solid ? GPU_SHADER_2D_FLAT_COLOR : GPU_SHADER_3D_POLYLINE_FLAT_COLOR); + immBindBuiltinProgram(is_solid ? GPU_SHADER_3D_FLAT_COLOR : GPU_SHADER_3D_POLYLINE_FLAT_COLOR); { if (is_solid) { diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 7d1b6482110..4dae8222b14 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1698,7 +1698,7 @@ void ui_draw_but_CURVE(ARegion *region, uiBut *but, const uiWidgetColors *wcol, format = immVertexFormat(); pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); /* Calculate vertex colors based on text theme. */ float color_vert[4], color_vert_select[4]; @@ -1948,7 +1948,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, format = immVertexFormat(); pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); /* Calculate vertex colors based on text theme. */ float color_vert[4], color_vert_select[4], color_sample[4]; @@ -2152,7 +2152,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel); UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline); diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index 38ed126880e..745a2201dc1 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -1160,7 +1160,7 @@ static void panel_draw_aligned_widgets(const uiStyle *style, GPUBatch *batch = GPU_batch_preset_panel_drag_widget( U.pixelsize, color_high, color_dark, drag_widget_size); - GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_FLAT_COLOR); + GPU_batch_program_set_builtin(batch, GPU_SHADER_3D_FLAT_COLOR); GPU_batch_draw(batch); GPU_matrix_pop(); } diff --git a/source/blender/editors/interface/view2d.cc b/source/blender/editors/interface/view2d.cc index 1bf7e25b154..c2ca0ac8c72 100644 --- a/source/blender/editors/interface/view2d.cc +++ b/source/blender/editors/interface/view2d.cc @@ -1136,7 +1136,7 @@ void UI_view2d_multi_grid_draw( GPU_line_width(1.0f); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); immBeginAtMost(GPU_PRIM_LINES, vertex_count); for (int level = 0; level < totlevels; level++) { @@ -1234,7 +1234,7 @@ void UI_view2d_dot_grid_draw(const View2D *v2d, GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); const uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); /* Scaling the dots fully with the zoom looks too busy, but a bit of size variation is nice. */ const float min_point_size = 2.0f * UI_DPI_FAC; diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index b41eaa26edf..dc3aaea5e49 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -3664,7 +3664,7 @@ void ED_region_grid_draw(ARegion *region, float zoomx, float zoomy, float x0, fl pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); immBegin(GPU_PRIM_LINES, 4 * count_fine + 4 * count_large); float theme_color[3]; diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c index 9b9b7199c99..8ebda7ef98e 100644 --- a/source/blender/editors/space_file/file_draw.c +++ b/source/blender/editors/space_file/file_draw.c @@ -631,7 +631,7 @@ static void draw_dividers(FileLayout *layout, View2D *v2d) uint color = GPU_vertformat_attr_add( format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); immBegin(GPU_PRIM_LINES, vertex_len); sx = (int)v2d->tot.xmin; diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index 6ee1e6f021a..659cba0587a 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -408,7 +408,7 @@ static void draw_fcurve_handles(SpaceGraph *sipo, FCurve *fcu) uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint color = GPU_vertformat_attr_add( format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); if ((sipo->flag & SIPO_BEAUTYDRAW_OFF) == 0) { GPU_line_smooth(true); } diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 8ab89a3368d..929217fa10e 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -311,7 +311,7 @@ static size_t draw_waveform_segment(WaveVizData *waveform_data, bool use_rms) GPUPrimType prim_type = waveform_data->draw_line ? GPU_PRIM_LINE_STRIP : GPU_PRIM_TRI_STRIP; uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); immBegin(prim_type, vertex_count); while (vertices_done < vertex_count && !waveform_data->final_sample) { diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a91a1277899..0af8994ea78 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -982,7 +982,7 @@ static void draw_view_axis(RegionView3D *rv3d, const rcti *rect) uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); - immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); + immBindBuiltinProgram(GPU_SHADER_3D_FLAT_COLOR); immBegin(GPU_PRIM_LINES, 6); for (int axis_i = 0; axis_i < 3; axis_i++) { diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index 6c7e03b0994..d1b0e227506 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -272,7 +272,6 @@ set(GLSL_SRC shaders/gpu_shader_2D_widget_shadow_frag.glsl shaders/gpu_shader_2D_nodelink_frag.glsl shaders/gpu_shader_2D_nodelink_vert.glsl - shaders/gpu_shader_2D_flat_color_vert.glsl shaders/gpu_shader_2D_line_dashed_uniform_color_vert.glsl shaders/gpu_shader_2D_line_dashed_frag.glsl shaders/gpu_shader_2D_smooth_color_vert.glsl @@ -577,7 +576,6 @@ set(SRC_SHADER_CREATE_INFOS shaders/infos/gpu_shader_2D_area_borders_info.hh shaders/infos/gpu_shader_2D_checker_info.hh shaders/infos/gpu_shader_2D_diag_stripes_info.hh - shaders/infos/gpu_shader_2D_flat_color_info.hh shaders/infos/gpu_shader_2D_image_color_info.hh shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh shaders/infos/gpu_shader_2D_image_info.hh diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index dcf63507f89..65a628bcd76 100644 --- a/source/blen @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs