[Bf-blender-cvs] [10558d6973b] master: Cleanup: GPUState: remove use of GPU_blend_set_func

Clément Foucault noreply at git.blender.org
Tue Aug 18 21:31:00 CEST 2020


Commit: 10558d6973be8fc461a4b8aad734ba0881d18e85
Author: Clément Foucault
Date:   Sun Aug 16 15:33:05 2020 +0200
Branches: master
https://developer.blender.org/rB10558d6973be8fc461a4b8aad734ba0881d18e85

Cleanup: GPUState: remove use of GPU_blend_set_func

===================================================================

M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/interface/interface_draw.c
M	source/blender/editors/interface/interface_icons.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/sculpt_paint/paint_cursor.c
M	source/blender/gpu/GPU_state.h
M	source/blender/gpu/intern/gpu_state.cc
M	source/blender/windowmanager/intern/wm_draw.c
M	source/blender/windowmanager/intern/wm_gesture.c

===================================================================

diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 664d514a77e..fd57934b8e5 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1595,7 +1595,7 @@ void DRW_draw_render_loop_offscreen(struct Depsgraph *depsgraph,
     GPU_clear_color(0.0f, 0.0f, 0.0f, 1.0f);
     GPU_clear(GPU_COLOR_BIT);
     /* Premult Alpha over black background. */
-    GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+    GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
     GPU_blend(true);
   }
 
diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c
index 4cb2b16910e..5614e802f75 100644
--- a/source/blender/editors/interface/interface_draw.c
+++ b/source/blender/editors/interface/interface_draw.c
@@ -1161,7 +1161,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(region),
   }
 
   if (scopes->ok && scopes->waveform_1 != NULL) {
-    GPU_blend_set_func(GPU_ONE, GPU_ONE);
+    GPU_blend_set_func_separate(GPU_BLEND_ADDITIVE);
     GPU_point_size(1.0);
 
     /* LUMA (1 channel) */
@@ -1463,7 +1463,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(region),
     /* pixel point cloud */
     const float col[3] = {alpha, alpha, alpha};
 
-    GPU_blend_set_func(GPU_ONE, GPU_ONE);
+    GPU_blend_set_func_separate(GPU_BLEND_ADDITIVE);
     GPU_point_size(1.0);
 
     GPU_matrix_push();
diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c
index 2dc4081a4c6..b43b32aefb3 100644
--- a/source/blender/editors/interface/interface_icons.c
+++ b/source/blender/editors/interface/interface_icons.c
@@ -1595,7 +1595,7 @@ static void icon_draw_cache_flush_ex(bool only_full_caches)
     /* We need to flush widget base first to ensure correct ordering. */
     UI_widgetbase_draw_cache_flush();
 
-    GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+    GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
 
     if (!only_full_caches || g_icon_draw_cache.normal.calls == ICON_DRAW_CACHE_SIZE) {
       icon_draw_cache_texture_flush_ex(icongltex.tex[0], &g_icon_draw_cache.normal);
@@ -1689,7 +1689,7 @@ static void icon_draw_texture(float x,
   /* We need to flush widget base first to ensure correct ordering. */
   UI_widgetbase_draw_cache_flush();
 
-  GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+  GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
 
   float x1, x2, y1, y2;
 
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index f39ca028e7a..a4f43650c3b 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -740,7 +740,7 @@ void ED_mask_draw_region(
     if (overlay_mode != MASK_OVERLAY_ALPHACHANNEL) {
       /* More blending types could be supported in the future. */
       GPU_blend(true);
-      GPU_blend_set_func(GPU_DST_COLOR, GPU_ZERO);
+      GPU_blend_set_func_separate(GPU_BLEND_MULTIPLY);
     }
 
     GPU_matrix_push();
diff --git a/source/blender/editors/sculpt_paint/paint_cursor.c b/source/blender/editors/sculpt_paint/paint_cursor.c
index 0c5e4ea9538..a80339d4cf7 100644
--- a/source/blender/editors/sculpt_paint/paint_cursor.c
+++ b/source/blender/editors/sculpt_paint/paint_cursor.c
@@ -635,7 +635,7 @@ static bool paint_draw_tex_overlay(UnifiedPaintSettings *ups,
 
     /* Premultiplied alpha blending. */
     GPU_blend(true);
-    GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+    GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
 
     immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
 
@@ -728,7 +728,7 @@ static bool paint_draw_cursor_overlay(
     uint texCoord = GPU_vertformat_attr_add(format, "texCoord", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
     GPU_blend(true);
-    GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+    GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
 
     immBindBuiltinProgram(GPU_SHADER_2D_IMAGE_COLOR);
 
diff --git a/source/blender/gpu/GPU_state.h b/source/blender/gpu/GPU_state.h
index cb580adf23a..94dd2f18927 100644
--- a/source/blender/gpu/GPU_state.h
+++ b/source/blender/gpu/GPU_state.h
@@ -88,15 +88,6 @@ typedef enum eGPUStencilOp {
   GPU_STENCIL_OP_COUNT_DEPTH_FAIL,
 } eGPUStencilOp;
 
-/* These map directly to the GL_ blend functions, to minimize API add as needed*/
-typedef enum eGPUBlendFunction {
-  GPU_ONE,
-  GPU_SRC_ALPHA,
-  GPU_ONE_MINUS_SRC_ALPHA,
-  GPU_DST_COLOR,
-  GPU_ZERO,
-} eGPUBlendFunction;
-
 typedef enum eGPUFaceCullTest {
   GPU_CULL_NONE = 0, /* Culling disabled. */
   GPU_CULL_FRONT,
@@ -115,7 +106,6 @@ typedef enum eGPUProvokingVertex {
 void GPU_state_init(void);
 
 void GPU_blend(bool enable);
-void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor);
 void GPU_blend_set_func_separate(eGPUBlend blend);
 void GPU_face_culling(eGPUFaceCullTest culling);
 void GPU_front_facing(bool invert);
diff --git a/source/blender/gpu/intern/gpu_state.cc b/source/blender/gpu/intern/gpu_state.cc
index be4450193f5..c670e034585 100644
--- a/source/blender/gpu/intern/gpu_state.cc
+++ b/source/blender/gpu/intern/gpu_state.cc
@@ -40,12 +40,6 @@
 
 using namespace blender::gpu;
 
-// /* This should replace GPU_blend, GPU_blend_set_func and GPU_blend_set_func_separate. */
-// void GPU_blend_set(eGPUBlend blend)
-// {
-//   GLStateStack::set_blend(blend);
-// }
-
 void GPU_blend(bool enable)
 {
   if (enable) {
@@ -56,25 +50,6 @@ void GPU_blend(bool enable)
   }
 }
 
-void GPU_blend_set_func(eGPUBlendFunction sfactor, eGPUBlendFunction dfactor)
-{
-  if (sfactor == GPU_ONE && dfactor == GPU_ONE) {
-    GLStateStack::set_blend(GPU_BLEND_ADDITIVE);
-  }
-  else if (sfactor == GPU_ONE && dfactor == GPU_ONE_MINUS_SRC_ALPHA) {
-    GLStateStack::set_blend(GPU_BLEND_ALPHA_PREMULT);
-  }
-  else if (sfactor == GPU_SRC_ALPHA && dfactor == GPU_ONE_MINUS_SRC_ALPHA) {
-    GLStateStack::set_blend(GPU_BLEND_ALPHA);
-  }
-  else if (sfactor == GPU_DST_COLOR && dfactor == GPU_ZERO) {
-    GLStateStack::set_blend(GPU_BLEND_MULTIPLY);
-  }
-  else {
-    BLI_assert(0);
-  }
-}
-
 void GPU_blend_set_func_separate(eGPUBlend blend)
 {
   GLStateStack::set_blend(blend);
diff --git a/source/blender/windowmanager/intern/wm_draw.c b/source/blender/windowmanager/intern/wm_draw.c
index a9af4f16747..14f6ad420b5 100644
--- a/source/blender/windowmanager/intern/wm_draw.c
+++ b/source/blender/windowmanager/intern/wm_draw.c
@@ -578,7 +578,7 @@ void wm_draw_region_blend(ARegion *region, int view, bool blend)
   if (blend) {
     /* GL_ONE because regions drawn offscreen have premultiplied alpha. */
     GPU_blend(true);
-    GPU_blend_set_func(GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
+    GPU_blend_set_func_separate(GPU_BLEND_ALPHA_PREMULT);
   }
 
   /* setup actual texture */
diff --git a/source/blender/windowmanager/intern/wm_gesture.c b/source/blender/windowmanager/intern/wm_gesture.c
index abe8364d7c3..633c6b53ecd 100644
--- a/source/blender/windowmanager/intern/wm_gesture.c
+++ b/source/blender/windowmanager/intern/wm_gesture.c
@@ -353,9 +353,8 @@ static void draw_filled_lasso(wmGesture *gt)
                                   draw_filled_lasso_px_cb,
                                   &lasso_fill_data);
 
-    /* Additive Blending */
     GPU_blend(true);
-    GPU_blend_set_func(GPU_ONE, GPU_ONE);
+    GPU_blend_set_func_separate(GPU_BLEND_ADDITIVE);
 
     IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
     GPU_shader_bind(state.shader);



More information about the Bf-blender-cvs mailing list