freedreno: Move FD_MESA_DEBUG cases out of draw_vbo
authorRob Clark <robdclark@chromium.org>
Sat, 11 Feb 2023 16:03:35 +0000 (08:03 -0800)
committerMarge Bot <emma+marge@anholt.net>
Thu, 16 Feb 2023 19:57:13 +0000 (19:57 +0000)
If the debug options are enabled, just plug in a debug version of
draw_vbo with the additional checks.

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

src/gallium/drivers/freedreno/freedreno_batch.c
src/gallium/drivers/freedreno/freedreno_draw.c

index fcade12..f716517 100644 (file)
@@ -535,11 +535,6 @@ fd_batch_resource_read_slowpath(struct fd_batch *batch, struct fd_resource *rsc)
 void
 fd_batch_check_size(struct fd_batch *batch)
 {
-   if (FD_DBG(FLUSH)) {
-      fd_batch_flush(batch);
-      return;
-   }
-
    if (batch->num_draws > 100000) {
       fd_batch_flush(batch);
       return;
index 5d38c2b..8eb8f7b 100644 (file)
@@ -390,9 +390,6 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
       ctx->streamout.offsets[i] += draws[0].count;
    }
 
-   if (FD_DBG(DDRAW))
-      fd_context_all_dirty(ctx);
-
    assert(!batch->flushed);
 
    fd_batch_unlock_submit(batch);
@@ -404,6 +401,22 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
 }
 
 static void
+fd_draw_vbo_dbg(struct pipe_context *pctx, const struct pipe_draw_info *info,
+                unsigned drawid_offset,
+                const struct pipe_draw_indirect_info *indirect,
+                const struct pipe_draw_start_count_bias *draws, unsigned num_draws)
+   in_dt
+{
+   fd_draw_vbo(pctx, info, drawid_offset, indirect, draws, num_draws);
+
+   if (FD_DBG(DDRAW))
+      fd_context_all_dirty(fd_context(pctx));
+
+   if (FD_DBG(FLUSH))
+      pctx->flush(pctx, NULL, 0);
+}
+
+static void
 batch_clear_tracking(struct fd_batch *batch, unsigned buffers) assert_dt
 {
    struct fd_context *ctx = batch->ctx;
@@ -609,7 +622,12 @@ fd_launch_grid(struct pipe_context *pctx,
 void
 fd_draw_init(struct pipe_context *pctx)
 {
-   pctx->draw_vbo = fd_draw_vbo;
+   if (FD_DBG(DDRAW) || FD_DBG(FLUSH)) {
+      pctx->draw_vbo = fd_draw_vbo_dbg;
+   } else {
+      pctx->draw_vbo = fd_draw_vbo;
+   }
+
    pctx->clear = fd_clear;
    pctx->clear_render_target = fd_clear_render_target;
    pctx->clear_depth_stencil = fd_clear_depth_stencil;