freedreno: implement set_compute_state()
authorRob Clark <robdclark@gmail.com>
Tue, 1 May 2018 20:03:58 +0000 (16:03 -0400)
committerMarge Bot <eric+marge@anholt.net>
Thu, 21 Oct 2021 18:59:57 +0000 (18:59 +0000)
This interface should really go away, but for now just implement it
to directly update constant state (ie. what clover *should* be doing
instead)

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13300>

src/gallium/drivers/freedreno/freedreno_state.c

index 5d5b942..5995424 100644 (file)
@@ -606,11 +606,36 @@ fd_bind_compute_state(struct pipe_context *pctx, void *state) in_dt
    ctx->dirty_shader[PIPE_SHADER_COMPUTE] |= FD_DIRTY_SHADER_PROG;
 }
 
+/* TODO pipe_context::set_compute_resources() should DIAF and clover
+ * should be updated to use pipe_context::set_constant_buffer() and
+ * pipe_context::set_shader_images().  Until then just directly frob
+ * the UBO/image state to avoid the rest of the driver needing to
+ * know about this bastard api..
+ */
 static void
 fd_set_compute_resources(struct pipe_context *pctx, unsigned start,
                          unsigned count, struct pipe_surface **prscs) in_dt
 {
-   // TODO
+   struct fd_context *ctx = fd_context(pctx);
+   struct fd_constbuf_stateobj *so = &ctx->constbuf[PIPE_SHADER_COMPUTE];
+
+   for (unsigned i = 0; i < count; i++) {
+      const uint32_t index = i + start + 1;   /* UBOs start at index 1 */
+
+      if (!prscs) {
+         util_copy_constant_buffer(&so->cb[index], NULL, false);
+         so->enabled_mask &= ~(1 << index);
+      } else if (prscs[i]->format == PIPE_FORMAT_NONE) {
+         struct pipe_constant_buffer cb = {
+               .buffer = prscs[i]->texture,
+         };
+         util_copy_constant_buffer(&so->cb[index], &cb, false);
+         so->enabled_mask |= (1 << index);
+      } else {
+         // TODO images
+         unreachable("finishme");
+      }
+   }
 }
 
 /* used by clover to bind global objects, returning the bo address