Cleanup: GPU: Move program point size to GPU_state
authorClément Foucault <foucault.clem@gmail.com>
Tue, 28 May 2019 15:14:22 +0000 (17:14 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 28 May 2019 15:19:42 +0000 (17:19 +0200)
17 files changed:
source/blender/draw/intern/draw_manager.c
source/blender/draw/intern/draw_manager_exec.c
source/blender/editors/animation/keyframes_draw.c
source/blender/editors/gpencil/annotate_draw.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/mask/mask_draw.c
source/blender/editors/space_clip/clip_dopesheet_draw.c
source/blender/editors/space_graph/graph_draw.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_node/node_draw.c
source/blender/editors/uvedit/uvedit_draw.c
source/blender/gpu/GPU_draw.h
source/blender/gpu/GPU_shader.h
source/blender/gpu/GPU_state.h
source/blender/gpu/intern/gpu_draw.c
source/blender/gpu/intern/gpu_state.c

index b1f8e95..7a95120 100644 (file)
@@ -2822,7 +2822,7 @@ void DRW_framebuffer_select_id_setup(ARegion *ar, const bool clear)
   glDisable(GL_DITHER);
 
   GPU_depth_test(true);
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 
   if (clear) {
     GPU_framebuffer_clear_color_depth(
index 11c19b2..ae0239a 100644 (file)
@@ -355,7 +355,7 @@ void DRW_state_reset(void)
   DRW_state_reset_ex(DRW_STATE_DEFAULT);
 
   GPU_point_size(5);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   /* Reset blending function */
   glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
index 678afef..889d274 100644 (file)
@@ -815,7 +815,7 @@ static void draw_keylist(View2D *v2d,
           format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
       uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
       immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
-      GPU_enable_program_point_size();
+      GPU_program_point_size(true);
       immUniform2f(
           "ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1);
       immBegin(GPU_PRIM_POINTS, key_len);
@@ -849,7 +849,7 @@ static void draw_keylist(View2D *v2d,
       }
 
       immEnd();
-      GPU_disable_program_point_size();
+      GPU_program_point_size(false);
       immUnbindProgram();
     }
   }
index f325422..a853e2b 100644 (file)
@@ -561,7 +561,7 @@ static void annotation_draw_strokes(bGPdata *UNUSED(gpd),
                                     short lthick,
                                     const float color[4])
 {
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
     /* check if stroke can be drawn */
@@ -622,7 +622,7 @@ static void annotation_draw_strokes(bGPdata *UNUSED(gpd),
     }
   }
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 }
 
 /* Draw selected verts for strokes being edited */
@@ -658,7 +658,7 @@ static void annotation_draw_strokes_edit(bGPdata *gpd,
     }
   }
 
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   /* draw stroke verts */
   for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -751,7 +751,7 @@ static void annotation_draw_strokes_edit(bGPdata *gpd,
     immUnbindProgram();
   }
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 
   /* clear depth mask */
   if (dflag & GP_DRAWDATA_ONLY3D) {
index ef74aa2..5f08035 100644 (file)
@@ -180,7 +180,7 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points,
       format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
 
   immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
   immBegin(GPU_PRIM_POINTS, totpoints);
 
   const bGPDspoint *pt = points;
@@ -199,7 +199,7 @@ static void gp_draw_stroke_volumetric_2d(const bGPDspoint *points,
 
   immEnd();
   immUnbindProgram();
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 }
 
 /* draw a 3D stroke in "volumetric" style */
@@ -215,7 +215,7 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points,
       format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
 
   immBindBuiltinProgram(GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
   immBegin(GPU_PRIM_POINTS, totpoints);
 
   const bGPDspoint *pt = points;
@@ -229,7 +229,7 @@ static void gp_draw_stroke_volumetric_3d(const bGPDspoint *points,
 
   immEnd();
   immUnbindProgram();
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 }
 
 /* --------------- Stroke Fills ----------------- */
@@ -867,7 +867,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
   short sthickness;
   float ink[4];
 
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   bGPDstroke *gps_init = (tgpw->gps) ? tgpw->gps : tgpw->t_gpf->strokes.first;
 
@@ -1104,7 +1104,7 @@ static void gp_draw_strokes(tGPDdraw *tgpw)
     }
   }
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 }
 
 /* ----- General Drawing ------ */
index fa36052..6f1f4dd 100644 (file)
@@ -317,7 +317,7 @@ static void vicon_keytype_draw_wrapper(
   uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
 
   immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
   immUniform2f("ViewportSize", -1.0f, -1.0f);
   immBegin(GPU_PRIM_POINTS, 1);
 
@@ -343,7 +343,7 @@ static void vicon_keytype_draw_wrapper(
                       KEYFRAME_EXTREME_NONE);
 
   immEnd();
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
   immUnbindProgram();
 
   UI_Theme_Restore(&theme_state);
index 33e89b1..d9ca58f 100644 (file)
@@ -600,7 +600,7 @@ static void draw_masklays(const bContext *C,
   GPU_blend(true);
   GPU_blend_set_func_separate(
       GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   MaskLayer *masklay;
   int i;
@@ -635,7 +635,7 @@ static void draw_masklays(const bContext *C,
     }
   }
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
   GPU_blend(false);
 }
 
index 0f6e794..599a92f 100644 (file)
@@ -223,7 +223,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
       uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
 
       immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
-      GPU_enable_program_point_size();
+      GPU_program_point_size(true);
       immUniform2f(
           "ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1);
       immBegin(GPU_PRIM_POINTS, keyframe_len);
@@ -282,7 +282,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
       }
 
       immEnd();
-      GPU_disable_program_point_size();
+      GPU_program_point_size(false);
       immUnbindProgram();
     }
 
index 062c9f8..b16374e 100644 (file)
@@ -292,7 +292,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
   uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
 
   GPU_blend(true);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   /* draw the two handles first (if they're shown, the curve doesn't
    * have just a single keyframe, and the curve is being edited) */
@@ -303,7 +303,7 @@ static void draw_fcurve_vertices(ARegion *ar, FCurve *fcu, bool do_handles, bool
   /* draw keyframes over the handles */
   draw_fcurve_keyframe_vertices(fcu, v2d, !(fcu->flag & FCURVE_PROTECTED), pos);
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
   GPU_blend(false);
 }
 
index 68cbfd7..5cf9646 100644 (file)
@@ -142,7 +142,7 @@ static void nla_action_draw_keyframes(
         format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
     uint flags_id = GPU_vertformat_attr_add(format, "flags", GPU_COMP_U32, 1, GPU_FETCH_INT);
     immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND);
-    GPU_enable_program_point_size();
+    GPU_program_point_size(true);
     immUniform2f("ViewportSize", BLI_rcti_size_x(&v2d->mask) + 1, BLI_rcti_size_y(&v2d->mask) + 1);
     immBegin(GPU_PRIM_POINTS, key_len);
 
@@ -167,7 +167,7 @@ static void nla_action_draw_keyframes(
     }
 
     immEnd();
-    GPU_disable_program_point_size();
+    GPU_program_point_size(false);
     immUnbindProgram();
   }
 
index 020bdbf..1c35440 100644 (file)
@@ -896,7 +896,7 @@ void node_draw_sockets(View2D *v2d,
   uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
 
   GPU_blend(true);
-  GPU_enable_program_point_size();
+  GPU_program_point_size(true);
 
   immBindBuiltinProgram(GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA);
 
@@ -991,7 +991,7 @@ void node_draw_sockets(View2D *v2d,
 
   immUnbindProgram();
 
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
   GPU_blend(false);
 }
 
index 7f9b90f..93cef18 100644 (file)
@@ -425,7 +425,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
       float pinned_col[4] = {1.0f, 0.0f, 0.0f, 1.0f}; /* TODO Theme? */
       UI_GetThemeColor4fv(TH_VERTEX, col1);
       GPU_blend(true);
-      GPU_enable_program_point_size();
+      GPU_program_point_size(true);
 
       GPU_batch_program_set_builtin(verts, GPU_SHADER_2D_UV_VERTS);
       GPU_batch_uniform_4f(verts, "vertColor", col1[0], col1[1], col1[2], 1.0f);
@@ -450,7 +450,7 @@ static void draw_uvs(SpaceImage *sima, Scene *scene, Object *obedit, Depsgraph *
       }
 
       GPU_blend(false);
-      GPU_disable_program_point_size();
+      GPU_program_point_size(false);
     }
     if (facedots) {
       GPU_point_size(pointsize);
index 8b830aa..507baa9 100644 (file)
@@ -51,13 +51,6 @@ struct ViewLayer;
 
 void GPU_state_init(void);
 
-/* Programmable point size
- * - shaders set their own point size when enabled
- * - use glPointSize when disabled */
-
-void GPU_enable_program_point_size(void);
-void GPU_disable_program_point_size(void);
-
 /* Mipmap settings
  * - these will free textures on changes */
 
index 00570bd..0fe5427 100644 (file)
@@ -156,7 +156,6 @@ typedef enum eGPUBuiltinShader {
   GPU_SHADER_3D_UNIFORM_COLOR,
   /* Sets Z-depth to 1.0 (draw onto background). */
   GPU_SHADER_3D_UNIFORM_COLOR_BACKGROUND,
-  GPU_SHADER_3D_UNIFORM_COLOR_INSTANCE,
   /**
    * Take a 3D position and color for each vertex without color interpolation.
    *
index 48c700a..7b97078 100644 (file)
@@ -49,6 +49,7 @@ void GPU_line_smooth(bool enable);
 void GPU_line_width(float width);
 void GPU_point_size(float size);
 void GPU_polygon_smooth(bool enable);
+void GPU_program_point_size(bool enable);
 void GPU_scissor(int x, int y, int width, int height);
 void GPU_scissor_get_f(float coords[4]);
 void GPU_scissor_get_i(int coords[4]);
index 638729d..5f27a0e 100644 (file)
@@ -1354,7 +1354,7 @@ static void gpu_disable_multisample(void)
 
 void GPU_state_init(void)
 {
-  GPU_disable_program_point_size();
+  GPU_program_point_size(false);
 
   glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
 
@@ -1374,16 +1374,6 @@ void GPU_state_init(void)
   gpu_disable_multisample();
 }
 
-void GPU_enable_program_point_size(void)
-{
-  glEnable(GL_PROGRAM_POINT_SIZE);
-}
-
-void GPU_disable_program_point_size(void)
-{
-  glDisable(GL_PROGRAM_POINT_SIZE);
-}
-
 /** \name Framebuffer color depth, for selection codes
  * \{ */
 
index 176965b..7e82892 100644 (file)
@@ -126,6 +126,19 @@ void GPU_polygon_smooth(bool enable)
   }
 }
 
+/* Programmable point size
+ * - shaders set their own point size when enabled
+ * - use glPointSize when disabled */
+void GPU_program_point_size(bool enable)
+{
+  if (enable) {
+    glEnable(GL_PROGRAM_POINT_SIZE);
+  }
+  else {
+    glDisable(GL_PROGRAM_POINT_SIZE);
+  }
+}
+
 void GPU_scissor(int x, int y, int width, int height)
 {
   glScissor(x, y, width, height);