freedreno/a3xx/compiler: refactor trans_samp()
[mesa.git] / src / gallium / drivers / freedreno / freedreno_gmem.c
index 6a55aa4c133baaf4821e79b43f650fe2f4afe91b..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;
 
@@ -271,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);
        }
 }
 
@@ -289,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
@@ -310,16 +324,24 @@ 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 {
@@ -328,6 +350,7 @@ fd_gmem_render_tiles(struct pipe_context *pctx)
                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++;
        }
@@ -339,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);