freedreno/a6xx: Handle driver-params in GS/DS
authorRob Clark <robdclark@chromium.org>
Mon, 4 Jul 2022 16:13:17 +0000 (09:13 -0700)
committerMarge Bot <emma+marge@anholt.net>
Fri, 8 Jul 2022 20:32:35 +0000 (20:32 +0000)
Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17341>

src/gallium/drivers/freedreno/a6xx/fd6_const.c
src/gallium/drivers/freedreno/a6xx/fd6_const.h
src/gallium/drivers/freedreno/a6xx/fd6_draw.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.c
src/gallium/drivers/freedreno/a6xx/fd6_emit.h

index a6c2df6..868d226 100644 (file)
@@ -293,22 +293,48 @@ fd6_build_user_consts(struct fd6_emit *emit)
 }
 
 struct fd_ringbuffer *
-fd6_build_vs_driver_params(struct fd6_emit *emit)
+fd6_build_driver_params(struct fd6_emit *emit)
 {
    struct fd_context *ctx = emit->ctx;
    struct fd6_context *fd6_ctx = fd6_context(ctx);
-   const struct ir3_shader_variant *vs = emit->vs;
-
-   if (vs->need_driver_params) {
-      struct fd_ringbuffer *dpconstobj = fd_submit_new_ringbuffer(
-         ctx->batch->submit, (4 + IR3_DP_VS_COUNT) * 4, FD_RINGBUFFER_STREAMING);
-      ir3_emit_driver_params(vs, dpconstobj, ctx, emit->info, emit->indirect, emit->draw);
-      fd6_ctx->has_dp_state = true;
-      return dpconstobj;
+   unsigned num_dp = 0;
+
+   if (emit->vs->need_driver_params)
+      num_dp++;
+
+   if (emit->gs && emit->gs->need_driver_params)
+      num_dp++;
+
+   if (emit->ds && emit->ds->need_driver_params)
+      num_dp++;
+
+   if (!num_dp) {
+      fd6_ctx->has_dp_state = false;
+      return NULL;
+   }
+
+   unsigned size_dwords = num_dp * (4 + IR3_DP_VS_COUNT);  /* 4dw PKT7 header */
+   struct fd_ringbuffer *dpconstobj = fd_submit_new_ringbuffer(
+         ctx->batch->submit, size_dwords * 4, FD_RINGBUFFER_STREAMING);
+
+   if (emit->vs->need_driver_params) {
+      ir3_emit_driver_params(emit->vs, dpconstobj, ctx, emit->info,
+                             emit->indirect, emit->draw);
+   }
+
+   if (emit->gs && emit->gs->need_driver_params) {
+      ir3_emit_driver_params(emit->gs, dpconstobj, ctx, emit->info,
+                             emit->indirect, emit->draw);
    }
 
-   fd6_ctx->has_dp_state = false;
-   return NULL;
+   if (emit->ds && emit->ds->need_driver_params) {
+      ir3_emit_driver_params(emit->ds, dpconstobj, ctx, emit->info,
+                             emit->indirect, emit->draw);
+   }
+
+   fd6_ctx->has_dp_state = true;
+
+   return dpconstobj;
 }
 
 void
index 6310985..4489cea 100644 (file)
@@ -30,7 +30,7 @@
 struct fd_ringbuffer *fd6_build_tess_consts(struct fd6_emit *emit) assert_dt;
 struct fd_ringbuffer *fd6_build_user_consts(struct fd6_emit *emit) assert_dt;
 struct fd_ringbuffer *
-fd6_build_vs_driver_params(struct fd6_emit *emit) assert_dt;
+fd6_build_driver_params(struct fd6_emit *emit) assert_dt;
 
 void fd6_emit_cs_consts(const struct ir3_shader_variant *v,
                         struct fd_ringbuffer *ring, struct fd_context *ctx,
index 68dadda..fc844d7 100644 (file)
@@ -220,7 +220,11 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
    emit.fs = fd6_emit_get_prog(&emit)->fs;
 
    if (emit.vs->need_driver_params || fd6_ctx->has_dp_state)
-      emit.dirty_groups |= BIT(FD6_GROUP_VS_DRIVER_PARAMS);
+      emit.dirty_groups |= BIT(FD6_GROUP_DRIVER_PARAMS);
+   else if (emit.gs && emit.gs->need_driver_params)
+      emit.dirty_groups |= BIT(FD6_GROUP_DRIVER_PARAMS);
+   else if (emit.ds && emit.ds->need_driver_params)
+      emit.dirty_groups |= BIT(FD6_GROUP_DRIVER_PARAMS);
 
    /* If we are doing xfb, we need to emit the xfb state on every draw: */
    if (emit.prog->stream_output)
index 9059853..9e18c59 100644 (file)
@@ -1100,8 +1100,8 @@ fd6_emit_state(struct fd_ringbuffer *ring, struct fd6_emit *emit)
       case FD6_GROUP_CONST:
          state = fd6_build_user_consts(emit);
          break;
-      case FD6_GROUP_VS_DRIVER_PARAMS:
-         state = fd6_build_vs_driver_params(emit);
+      case FD6_GROUP_DRIVER_PARAMS:
+         state = fd6_build_driver_params(emit);
          break;
       case FD6_GROUP_PRIMITIVE_PARAMS:
          state = fd6_build_tess_consts(emit);
index 0c46d8a..db31812 100644 (file)
@@ -53,7 +53,7 @@ enum fd6_state_id {
    FD6_GROUP_VTXSTATE,
    FD6_GROUP_VBO,
    FD6_GROUP_CONST,
-   FD6_GROUP_VS_DRIVER_PARAMS,
+   FD6_GROUP_DRIVER_PARAMS,
    FD6_GROUP_PRIMITIVE_PARAMS,
    FD6_GROUP_VS_TEX,
    FD6_GROUP_HS_TEX,