freedreno/a3xx/compiler: refactor trans_samp()
[mesa.git] / src / gallium / drivers / freedreno / freedreno_gmem.c
index 0270538a3d0e080f321ffb591f4642c3c499c4d3..861ebf5675e96ff2a1a0a949abc514c150efd1cb 100644 (file)
@@ -35,6 +35,7 @@
 #include "freedreno_gmem.h"
 #include "freedreno_context.h"
 #include "freedreno_resource.h"
+#include "freedreno_query_hw.h"
 #include "freedreno_util.h"
 
 /*
@@ -143,6 +144,8 @@ calculate_tiles(struct fd_context *ctx)
        gmem->bin_w = bin_w;
        gmem->nbins_x = nbins_x;
        gmem->nbins_y = nbins_y;
+       gmem->minx = minx;
+       gmem->miny = miny;
        gmem->width = width;
        gmem->height = height;
 
@@ -260,6 +263,9 @@ render_tiles(struct fd_context *ctx)
 
        ctx->emit_tile_init(ctx);
 
+       if (ctx->restore)
+               ctx->stats.batch_restore++;
+
        for (i = 0; i < (gmem->nbins_x * gmem->nbins_y); i++) {
                struct fd_tile *tile = &ctx->tile[i];
 
@@ -268,16 +274,24 @@ render_tiles(struct fd_context *ctx)
 
                ctx->emit_tile_prep(ctx, tile);
 
-               if (ctx->restore)
+               if (ctx->restore) {
+                       fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_MEM2GMEM);
                        ctx->emit_tile_mem2gmem(ctx, tile);
+                       fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_NULL);
+               }
 
                ctx->emit_tile_renderprep(ctx, tile);
 
+               fd_hw_query_prepare_tile(ctx, i, ctx->ring);
+
                /* emit IB to drawcmds: */
                OUT_IB(ctx->ring, ctx->draw_start, ctx->draw_end);
+               fd_reset_wfi(ctx);
 
                /* emit gmem2mem to transfer tile back to system memory: */
+               fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_GMEM2MEM);
                ctx->emit_tile_gmem2mem(ctx, tile);
+               fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_NULL);
        }
 }
 
@@ -286,8 +300,11 @@ render_sysmem(struct fd_context *ctx)
 {
        ctx->emit_sysmem_prep(ctx);
 
+       fd_hw_query_prepare_tile(ctx, 0, ctx->ring);
+
        /* emit IB to drawcmds: */
        OUT_IB(ctx->ring, ctx->draw_start, ctx->draw_end);
+       fd_reset_wfi(ctx);
 }
 
 void
@@ -307,22 +324,35 @@ fd_gmem_render_tiles(struct pipe_context *pctx)
                }
        }
 
+       /* close out the draw cmds by making sure any active queries are
+        * paused:
+        */
+       fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_NULL);
+
        /* mark the end of the clear/draw cmds before emitting per-tile cmds: */
        fd_ringmarker_mark(ctx->draw_end);
        fd_ringmarker_mark(ctx->binning_end);
 
+       fd_reset_wfi(ctx);
+
+       ctx->stats.batch_total++;
+
        if (sysmem) {
                DBG("rendering sysmem (%s/%s)",
                        util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
                        util_format_short_name(pipe_surface_format(pfb->zsbuf)));
+               fd_hw_query_prepare(ctx, 1);
                render_sysmem(ctx);
+               ctx->stats.batch_sysmem++;
        } else {
                struct fd_gmem_stateobj *gmem = &ctx->gmem;
                calculate_tiles(ctx);
                DBG("rendering %dx%d tiles (%s/%s)", gmem->nbins_x, gmem->nbins_y,
                        util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
                        util_format_short_name(pipe_surface_format(pfb->zsbuf)));
+               fd_hw_query_prepare(ctx, gmem->nbins_x * gmem->nbins_y);
                render_tiles(ctx);
+               ctx->stats.batch_gmem++;
        }
 
        /* GPU executes starting from tile cmds, which IB back to draw cmds: */
@@ -332,7 +362,7 @@ fd_gmem_render_tiles(struct pipe_context *pctx)
        fd_ringmarker_mark(ctx->draw_start);
        fd_ringmarker_mark(ctx->binning_start);
 
-       fd_reset_rmw_state(ctx);
+       fd_reset_wfi(ctx);
 
        /* update timestamps on render targets: */
        timestamp = fd_ringbuffer_timestamp(ctx->ring);