llvmpipe: bind task/mesh resources and dirty bits
authorDave Airlie <airlied@redhat.com>
Wed, 17 May 2023 01:56:41 +0000 (11:56 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 5 Jun 2023 19:01:47 +0000 (05:01 +1000)
This binds the task/mesh states to be updated on dirty changes

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23066>

src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_cs.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c

index 184004c..93c6a44 100644 (file)
@@ -129,9 +129,21 @@ void
 llvmpipe_update_setup(struct llvmpipe_context *lp);
 
 void
+llvmpipe_update_task_shader(struct llvmpipe_context *lp);
+
+void
+llvmpipe_update_mesh_shader(struct llvmpipe_context *lp);
+
+void
 llvmpipe_update_derived_clear(struct llvmpipe_context *llvmpipe);
 
 void
+llvmpipe_task_update_derived(struct llvmpipe_context *llvmpipe);
+
+void
+llvmpipe_mesh_update_derived(struct llvmpipe_context *llvmpipe);
+
+void
 llvmpipe_update_derived(struct llvmpipe_context *llvmpipe);
 
 void
index a549ccd..023b79a 100644 (file)
@@ -1625,6 +1625,15 @@ lp_csctx_create(struct pipe_context *pipe)
    return csctx;
 }
 
+void
+llvmpipe_update_task_shader(struct llvmpipe_context *lp)
+{
+   if (!lp->tss)
+      return;
+   struct lp_compute_shader_variant *variant = llvmpipe_update_cs_variant(lp, PIPE_SHADER_TASK, lp->tss);
+   lp_cs_ctx_set_cs_variant(lp->task_ctx, variant);
+}
+
 static void *
 llvmpipe_create_ts_state(struct pipe_context *pipe,
                            const struct pipe_shader_state *templ)
@@ -1658,6 +1667,7 @@ llvmpipe_bind_ts_state(struct pipe_context *pipe, void *_task)
       return;
 
    llvmpipe->tss = (struct lp_compute_shader *)_task;
+   llvmpipe->dirty |= LP_NEW_TASK;
 }
 
 static void
@@ -1684,6 +1694,15 @@ llvmpipe_init_task_funcs(struct llvmpipe_context *llvmpipe)
    llvmpipe->pipe.delete_ts_state = llvmpipe_delete_ts_state;
 }
 
+void
+llvmpipe_update_mesh_shader(struct llvmpipe_context *lp)
+{
+   if (!lp->mhs)
+      return;
+   struct lp_compute_shader_variant *variant = llvmpipe_update_cs_variant(lp, PIPE_SHADER_MESH, lp->mhs);
+   lp_cs_ctx_set_cs_variant(lp->mesh_ctx, variant);
+}
+
 static void *
 llvmpipe_create_ms_state(struct pipe_context *pipe,
                            const struct pipe_shader_state *templ)
@@ -1726,6 +1745,7 @@ llvmpipe_bind_ms_state(struct pipe_context *pipe, void *_mesh)
    llvmpipe->mhs = (struct lp_compute_shader *)_mesh;
 
    draw_bind_mesh_shader(llvmpipe->draw, _mesh ? llvmpipe->mhs->draw_mesh_data : NULL);
+   llvmpipe->dirty |= LP_NEW_MESH;
 }
 
 
@@ -1755,3 +1775,75 @@ llvmpipe_init_mesh_funcs(struct llvmpipe_context *llvmpipe)
    llvmpipe->pipe.bind_ms_state   = llvmpipe_bind_ms_state;
    llvmpipe->pipe.delete_ms_state = llvmpipe_delete_ms_state;
 }
+
+void
+llvmpipe_task_update_derived(struct llvmpipe_context *llvmpipe)
+{
+   if (llvmpipe->dirty & LP_NEW_TASK_CONSTANTS) {
+      lp_csctx_set_cs_constants(llvmpipe->task_ctx,
+                                ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_TASK]),
+                                llvmpipe->constants[PIPE_SHADER_TASK]);
+      update_csctx_consts(llvmpipe, llvmpipe->task_ctx);
+   }
+
+   if (llvmpipe->dirty & LP_NEW_TASK_SSBOS) {
+      lp_csctx_set_cs_ssbos(llvmpipe->task_ctx,
+                            ARRAY_SIZE(llvmpipe->ssbos[PIPE_SHADER_TASK]),
+                            llvmpipe->ssbos[PIPE_SHADER_TASK]);
+      update_csctx_ssbo(llvmpipe, llvmpipe->task_ctx);
+   }
+
+   if (llvmpipe->dirty & LP_NEW_TASK_SAMPLER_VIEW)
+      lp_csctx_set_sampler_views(llvmpipe->task_ctx,
+                                 llvmpipe->num_sampler_views[PIPE_SHADER_TASK],
+                                 llvmpipe->sampler_views[PIPE_SHADER_TASK]);
+
+   if (llvmpipe->dirty & LP_NEW_TASK_SAMPLER)
+      lp_csctx_set_sampler_state(llvmpipe->task_ctx,
+                                 llvmpipe->num_samplers[PIPE_SHADER_TASK],
+                                 llvmpipe->samplers[PIPE_SHADER_TASK]);
+
+   if (llvmpipe->dirty & LP_NEW_TASK_IMAGES)
+      lp_csctx_set_cs_images(llvmpipe->task_ctx,
+                              ARRAY_SIZE(llvmpipe->images[PIPE_SHADER_TASK]),
+                              llvmpipe->images[PIPE_SHADER_TASK]);
+
+   struct lp_cs_context *csctx = llvmpipe->task_ctx;
+   csctx->cs.current.jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
+}
+
+void
+llvmpipe_mesh_update_derived(struct llvmpipe_context *llvmpipe)
+{
+   if (llvmpipe->dirty & LP_NEW_MESH_CONSTANTS) {
+      lp_csctx_set_cs_constants(llvmpipe->mesh_ctx,
+                                ARRAY_SIZE(llvmpipe->constants[PIPE_SHADER_MESH]),
+                                llvmpipe->constants[PIPE_SHADER_MESH]);
+      update_csctx_consts(llvmpipe, llvmpipe->mesh_ctx);
+   }
+
+   if (llvmpipe->dirty & LP_NEW_MESH_SSBOS) {
+      lp_csctx_set_cs_ssbos(llvmpipe->mesh_ctx,
+                            ARRAY_SIZE(llvmpipe->ssbos[PIPE_SHADER_MESH]),
+                            llvmpipe->ssbos[PIPE_SHADER_MESH]);
+      update_csctx_ssbo(llvmpipe, llvmpipe->mesh_ctx);
+   }
+
+   if (llvmpipe->dirty & LP_NEW_MESH_SAMPLER_VIEW)
+      lp_csctx_set_sampler_views(llvmpipe->mesh_ctx,
+                                 llvmpipe->num_sampler_views[PIPE_SHADER_MESH],
+                                 llvmpipe->sampler_views[PIPE_SHADER_MESH]);
+
+   if (llvmpipe->dirty & LP_NEW_MESH_SAMPLER)
+      lp_csctx_set_sampler_state(llvmpipe->mesh_ctx,
+                                 llvmpipe->num_samplers[PIPE_SHADER_MESH],
+                                 llvmpipe->samplers[PIPE_SHADER_MESH]);
+
+   if (llvmpipe->dirty & LP_NEW_MESH_IMAGES)
+      lp_csctx_set_cs_images(llvmpipe->mesh_ctx,
+                              ARRAY_SIZE(llvmpipe->images[PIPE_SHADER_MESH]),
+                              llvmpipe->images[PIPE_SHADER_MESH]);
+
+   struct lp_cs_context *csctx = llvmpipe->mesh_ctx;
+   csctx->cs.current.jit_resources.aniso_filter_table = lp_build_sample_aniso_filter_table();
+}
index 06ee4f4..1a5a553 100644 (file)
@@ -268,12 +268,19 @@ llvmpipe_update_derived(struct llvmpipe_context *llvmpipe)
       llvmpipe->dirty |= LP_NEW_SAMPLER_VIEW;
    }
 
+   if (llvmpipe->dirty & (LP_NEW_TASK))
+      llvmpipe_update_task_shader(llvmpipe);
+
+   if (llvmpipe->dirty & (LP_NEW_MESH))
+      llvmpipe_update_mesh_shader(llvmpipe);
+
    /* This needs LP_NEW_RASTERIZER because of draw_prepare_shader_outputs(). */
    if (llvmpipe->dirty & (LP_NEW_RASTERIZER |
                           LP_NEW_FS |
                           LP_NEW_GS |
                           LP_NEW_TCS |
                           LP_NEW_TES |
+                          LP_NEW_MESH |
                           LP_NEW_VS))
       compute_vertex_info(llvmpipe);
 
@@ -357,6 +364,9 @@ llvmpipe_update_derived(struct llvmpipe_context *llvmpipe)
                              llvmpipe->viewports);
    }
 
+   llvmpipe_task_update_derived(llvmpipe);
+   llvmpipe_mesh_update_derived(llvmpipe);
+
    llvmpipe_update_derived_clear(llvmpipe);
 
    llvmpipe->dirty = 0;
index 8517703..9a68f6f 100644 (file)
@@ -4219,6 +4219,12 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe,
    case PIPE_SHADER_FRAGMENT:
       llvmpipe->dirty |= LP_NEW_FS_CONSTANTS;
       break;
+   case PIPE_SHADER_TASK:
+      llvmpipe->dirty |= LP_NEW_TASK_CONSTANTS;
+      break;
+   case PIPE_SHADER_MESH:
+      llvmpipe->dirty |= LP_NEW_MESH_CONSTANTS;
+      break;
    default:
       unreachable("Illegal shader type");
       break;
@@ -4265,6 +4271,12 @@ llvmpipe_set_shader_buffers(struct pipe_context *pipe,
       case PIPE_SHADER_COMPUTE:
          llvmpipe->cs_dirty |= LP_CSNEW_SSBOS;
          break;
+      case PIPE_SHADER_TASK:
+         llvmpipe->dirty |= LP_NEW_TASK_SSBOS;
+         break;
+      case PIPE_SHADER_MESH:
+         llvmpipe->dirty |= LP_NEW_MESH_SSBOS;
+         break;
       case PIPE_SHADER_FRAGMENT:
          llvmpipe->fs_ssbo_write_mask &= ~(((1 << count) - 1) << start_slot);
          llvmpipe->fs_ssbo_write_mask |= writable_bitmask << start_slot;
@@ -4315,6 +4327,12 @@ llvmpipe_set_shader_images(struct pipe_context *pipe,
    case PIPE_SHADER_FRAGMENT:
       llvmpipe->dirty |= LP_NEW_FS_IMAGES;
       break;
+   case PIPE_SHADER_TASK:
+      llvmpipe->dirty |= LP_NEW_TASK_IMAGES;
+      break;
+   case PIPE_SHADER_MESH:
+      llvmpipe->dirty |= LP_NEW_MESH_IMAGES;
+      break;
    default:
       unreachable("Illegal shader type");
       break;
index 7335959..a3ee46b 100644 (file)
@@ -112,6 +112,12 @@ llvmpipe_bind_sampler_states(struct pipe_context *pipe,
    case PIPE_SHADER_FRAGMENT:
       llvmpipe->dirty |= LP_NEW_SAMPLER;
       break;
+   case PIPE_SHADER_TASK:
+      llvmpipe->dirty |= LP_NEW_TASK_SAMPLER;
+      break;
+   case PIPE_SHADER_MESH:
+      llvmpipe->dirty |= LP_NEW_MESH_SAMPLER;
+      break;
    default:
       unreachable("Illegal shader type");
       break;
@@ -200,6 +206,12 @@ llvmpipe_set_sampler_views(struct pipe_context *pipe,
                                           llvmpipe->num_sampler_views[PIPE_SHADER_FRAGMENT],
                                           llvmpipe->sampler_views[PIPE_SHADER_FRAGMENT]);
       break;
+   case PIPE_SHADER_TASK:
+      llvmpipe->dirty |= LP_NEW_TASK_SAMPLER_VIEW;
+      break;
+   case PIPE_SHADER_MESH:
+      llvmpipe->dirty |= LP_NEW_MESH_SAMPLER_VIEW;
+      break;
    default:
       unreachable("Illegal shader type");
       break;