zink: flag shaders as needing update when clip_halfz changes
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 18 Aug 2020 19:06:15 +0000 (15:06 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 29 Jan 2021 15:38:06 +0000 (15:38 +0000)
this means we may or may not need to run the nir pass in the shader,
so force this to go back through the update path using the shader key

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8682>

src/gallium/drivers/zink/zink_compiler.c
src/gallium/drivers/zink/zink_context.h
src/gallium/drivers/zink/zink_draw.c
src/gallium/drivers/zink/zink_state.c

index 55e49c7..69d6115 100644 (file)
@@ -338,8 +338,10 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
          if (zs->streamout.so_info_slots)
             streamout = &zs->streamout;
 
-         nir = nir_shader_clone(NULL, zs->nir);
-         NIR_PASS_V(nir, nir_lower_clip_halfz);
+         if (!zink_vs_key(key)->clip_halfz) {
+            nir = nir_shader_clone(NULL, zs->nir);
+            NIR_PASS_V(nir, nir_lower_clip_halfz);
+         }
       }
    } else {
       if (!zink_fs_key(key)->samples &&
index 7d28dae..10e11fd 100644 (file)
@@ -121,6 +121,7 @@ struct zink_context {
    struct zink_gfx_program *curr_program;
 
    unsigned dirty_shader_stages : 6; /* mask of changed shader stages */
+   bool last_vertex_stage_dirty;
 
    struct hash_table *render_pass_cache;
 
index 262ed5b..90ec531 100644 (file)
@@ -162,6 +162,14 @@ zink_bind_vertex_buffers(struct zink_batch *batch, struct zink_context *ctx)
 static struct zink_gfx_program *
 get_gfx_program(struct zink_context *ctx)
 {
+   if (ctx->last_vertex_stage_dirty) {
+      if (ctx->gfx_stages[PIPE_SHADER_GEOMETRY])
+         ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_GEOMETRY);
+      else if (ctx->gfx_stages[PIPE_SHADER_TESS_EVAL])
+         ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_TESS_EVAL);
+      else
+         ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_VERTEX);
+   }
    if (ctx->dirty_shader_stages) {
       struct hash_entry *entry = _mesa_hash_table_search(ctx->program_cache,
                                                          ctx->gfx_stages);
index d8e08bb..810d971 100644 (file)
@@ -464,6 +464,7 @@ static void
 zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
 {
    struct zink_context *ctx = zink_context(pctx);
+   bool clip_halfz = ctx->rast_state ? ctx->rast_state->base.clip_halfz : false;
    ctx->rast_state = cso;
 
    if (ctx->rast_state) {
@@ -472,6 +473,9 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
          ctx->gfx_pipeline_state.dirty = true;
       }
 
+      if (clip_halfz != ctx->rast_state->base.clip_halfz)
+         ctx->last_vertex_stage_dirty = true;
+
       if (ctx->line_width != ctx->rast_state->line_width) {
          ctx->line_width = ctx->rast_state->line_width;
          ctx->gfx_pipeline_state.dirty = true;