mesa/st: add special casing for pointsize constant updating during validate
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Fri, 25 Mar 2022 01:45:32 +0000 (21:45 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 25 Mar 2022 04:03:23 +0000 (04:03 +0000)
the previous method of using affected_states to trigger constant updates
was ineffectual in the scenario where a ubo pointsize was needed on
the first time a non-precompiled shader was used after being the not-last
vertex stage:

* have vs+gs -> gs precompiles with pointsize lowering -> gs constants get updated
* remove gs -> vs was precompiled without pointsize lowering -> vs constants broken

now just do a quick check as in st_atom_shader.c and set the flag manually to
ensure the update is done correctly every time

cc: mesa-stable

fixes #6207

fixes (radv):
KHR-GL46.texture_cube_map_array.image_op_fragment_sh
KHR-GL46.texture_cube_map_array.sampling
KHR-GL46.texture_cube_map_array.texture_size_fragment_sh
KHR-GL46.constant_expressions*

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15570>

src/gallium/drivers/zink/ci/zink-radv-fails.txt
src/mesa/state_tracker/st_atom.c
src/mesa/state_tracker/st_program.c

index fbf0e74..0dc4930 100644 (file)
@@ -1,9 +1,3 @@
-#6207
-KHR-GL46.texture_cube_map_array.image_op_fragment_sh,Fail
-KHR-GL46.texture_cube_map_array.sampling,Fail
-KHR-GL46.texture_cube_map_array.texture_size_fragment_sh,Fail
-
-
 #6185
 KHR-GL46.tessellation_shader.single.isolines_tessellation,Crash
 KHR-GL46.tessellation_shader.tessellation_control_to_tessellation_evaluation.gl_MaxPatchVertices_Position_PointSize,Fail
index ee6e47b..0b7b5ff 100644 (file)
@@ -178,6 +178,18 @@ static void check_attrib_edgeflag(struct st_context *st)
    st_update_edgeflags(st, _mesa_draw_edge_flag_array_enabled(st->ctx));
 }
 
+static void check_pointsize(struct st_context *st)
+{
+   if (st->ctx->VertexProgram.PointSizeEnabled)
+      return;
+   if (st->ctx->GeometryProgram._Current)
+      st->dirty |= ST_NEW_GS_CONSTANTS;
+   else if (st->ctx->TessEvalProgram._Current)
+      st->dirty |= ST_NEW_TES_CONSTANTS;
+   else
+      st->dirty |= ST_NEW_VS_CONSTANTS;
+}
+
 
 /***********************************************************************
  * Update all derived state:
@@ -207,6 +219,9 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
          check_program_state(st);
          st->gfx_shaders_may_be_dirty = false;
       }
+      if (st->lower_point_size &&
+          (st->ctx->API == API_OPENGL_COMPAT || st->ctx->API == API_OPENGL_CORE))
+         check_pointsize(st);
 
       st_manager_validate_framebuffers(st);
 
@@ -217,6 +232,9 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
       break;
 
    case ST_PIPELINE_CLEAR:
+      if (st->lower_point_size &&
+          (st->ctx->API == API_OPENGL_COMPAT || st->ctx->API == API_OPENGL_CORE))
+         check_pointsize(st);
       st_manager_validate_framebuffers(st);
       pipeline_mask = ST_PIPELINE_CLEAR_STATE_MASK;
       break;
@@ -226,12 +244,18 @@ void st_validate_state( struct st_context *st, enum st_pipeline pipeline )
          check_program_state(st);
          st->gfx_shaders_may_be_dirty = false;
       }
+      if (st->lower_point_size &&
+          (st->ctx->API == API_OPENGL_COMPAT || st->ctx->API == API_OPENGL_CORE))
+         check_pointsize(st);
 
       st_manager_validate_framebuffers(st);
       pipeline_mask = ST_PIPELINE_META_STATE_MASK;
       break;
 
    case ST_PIPELINE_UPDATE_FRAMEBUFFER:
+      if (st->lower_point_size &&
+          (st->ctx->API == API_OPENGL_COMPAT || st->ctx->API == API_OPENGL_CORE))
+         check_pointsize(st);
       st_manager_validate_framebuffers(st);
       pipeline_mask = ST_PIPELINE_UPDATE_FB_STATE_MASK;
       break;
index 06b2eb2..1bc3327 100644 (file)
@@ -802,20 +802,6 @@ st_create_common_variant(struct st_context *st,
          NIR_PASS_V(state.ir.nir, nir_lower_point_size_mov,
                     point_size_state);
 
-         switch (prog->info.stage) {
-         case MESA_SHADER_VERTEX:
-            prog->affected_states |= ST_NEW_VS_CONSTANTS;
-            break;
-         case MESA_SHADER_TESS_EVAL:
-            prog->affected_states |= ST_NEW_TES_CONSTANTS;
-            break;
-         case MESA_SHADER_GEOMETRY:
-            prog->affected_states |= ST_NEW_GS_CONSTANTS;
-            break;
-         default:
-            unreachable("bad shader stage");
-         }
-
          finalize = true;
       }