st/mesa: move point_size_per_vertex-logic to helper
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 18 Jul 2019 14:29:27 +0000 (16:29 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 17 Oct 2019 08:41:36 +0000 (10:41 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/state_tracker/st_atom_rasterizer.c
src/mesa/state_tracker/st_util.h

index 9bf9fb108465096c041496b456af3108f89b7cf1..1cbefce29b509c821b1bf3f04b50170c2ffe1e3d 100644 (file)
@@ -61,13 +61,11 @@ translate_fill(GLenum mode)
    }
 }
 
-
 void
 st_update_rasterizer(struct st_context *st)
 {
    struct gl_context *ctx = st->ctx;
    struct pipe_rasterizer_state *raster = &st->state.rasterizer;
-   const struct gl_program *vertProg = ctx->VertexProgram._Current;
    const struct gl_program *fragProg = ctx->FragmentProgram._Current;
 
    memset(raster, 0, sizeof(*raster));
@@ -199,34 +197,7 @@ st_update_rasterizer(struct st_context *st)
 
    /* ST_NEW_VERTEX_PROGRAM
     */
-   if (vertProg) {
-      if (vertProg->Id == 0) {
-         if (vertProg->info.outputs_written &
-             BITFIELD64_BIT(VARYING_SLOT_PSIZ)) {
-            /* generated program which emits point size */
-            raster->point_size_per_vertex = TRUE;
-         }
-      }
-      else if (ctx->API != API_OPENGLES2) {
-         /* PointSizeEnabled is always set in ES2 contexts */
-         raster->point_size_per_vertex = ctx->VertexProgram.PointSizeEnabled;
-      }
-      else {
-         /* ST_NEW_TESSEVAL_PROGRAM | ST_NEW_GEOMETRY_PROGRAM */
-         /* We have to check the last bound stage and see if it writes psize */
-         struct gl_program *last = NULL;
-         if (ctx->GeometryProgram._Current)
-            last = ctx->GeometryProgram._Current;
-         else if (ctx->TessEvalProgram._Current)
-            last = ctx->TessEvalProgram._Current;
-         else if (ctx->VertexProgram._Current)
-            last = ctx->VertexProgram._Current;
-         if (last)
-            raster->point_size_per_vertex =
-               !!(last->info.outputs_written &
-                  BITFIELD64_BIT(VARYING_SLOT_PSIZ));
-      }
-   }
+   raster->point_size_per_vertex = st_point_size_per_vertex(ctx);
    if (!raster->point_size_per_vertex) {
       /* clamp size now */
       raster->point_size = CLAMP(ctx->Point.Size,
index bae85974f0e3c0d7e36820c8bc0876bd1bb171f2..edb13a1f26fb9d0602aa351a0ccccf3ba5046fd5 100644 (file)
@@ -101,6 +101,39 @@ st_user_clip_planes_enabled(struct gl_context *ctx)
           ctx->Transform.ClipPlanesEnabled;
 }
 
+static inline bool
+st_point_size_per_vertex(struct gl_context *ctx)
+{
+   const struct gl_program *vertProg = ctx->VertexProgram._Current;
+   if (vertProg) {
+      if (vertProg->Id == 0) {
+         if (vertProg->info.outputs_written &
+             BITFIELD64_BIT(VARYING_SLOT_PSIZ)) {
+            /* generated program which emits point size */
+            return true;
+         }
+      }
+      else if (ctx->API != API_OPENGLES2) {
+         /* PointSizeEnabled is always set in ES2 contexts */
+         return ctx->VertexProgram.PointSizeEnabled;
+      }
+      else {
+         /* ST_NEW_TESSEVAL_PROGRAM | ST_NEW_GEOMETRY_PROGRAM */
+         /* We have to check the last bound stage and see if it writes psize */
+         struct gl_program *last = NULL;
+         if (ctx->GeometryProgram._Current)
+            last = ctx->GeometryProgram._Current;
+         else if (ctx->TessEvalProgram._Current)
+            last = ctx->TessEvalProgram._Current;
+         else if (ctx->VertexProgram._Current)
+            last = ctx->VertexProgram._Current;
+         if (last)
+            return !!(last->info.outputs_written &
+                      BITFIELD64_BIT(VARYING_SLOT_PSIZ));
+      }
+   }
+   return false;
+}
 
 /** clear-alloc a struct-sized object, with casting */
 #define ST_CALLOC_STRUCT(T)   (struct T *) calloc(1, sizeof(struct T))