panfrost: Add a panfrost_freeze_batch() helper
[mesa.git] / src / gallium / drivers / panfrost / pan_sfbd.c
index 63dde93038239a965aeca902dd8e125af5d7a677..b5e18f07045ee5efb7fec70c61406a9a7bae59a0 100644 (file)
@@ -22,6 +22,7 @@
  *
  */
 
+#include "pan_bo.h"
 #include "pan_context.h"
 #include "pan_util.h"
 #include "pan_format.h"
@@ -37,39 +38,39 @@ panfrost_sfbd_format(struct pipe_surface *surf)
 
 static void
 panfrost_sfbd_clear(
-        struct panfrost_job *job,
+        struct panfrost_batch *batch,
         struct mali_single_framebuffer *sfbd)
 {
-        if (job->clear & PIPE_CLEAR_COLOR) {
-                sfbd->clear_color_1 = job->clear_color[0][0];
-                sfbd->clear_color_2 = job->clear_color[0][1];
-                sfbd->clear_color_3 = job->clear_color[0][2];
-                sfbd->clear_color_4 = job->clear_color[0][3];
+        if (batch->clear & PIPE_CLEAR_COLOR) {
+                sfbd->clear_color_1 = batch->clear_color[0][0];
+                sfbd->clear_color_2 = batch->clear_color[0][1];
+                sfbd->clear_color_3 = batch->clear_color[0][2];
+                sfbd->clear_color_4 = batch->clear_color[0][3];
         }
 
-        if (job->clear & PIPE_CLEAR_DEPTH) {
-                sfbd->clear_depth_1 = job->clear_depth;
-                sfbd->clear_depth_2 = job->clear_depth;
-                sfbd->clear_depth_3 = job->clear_depth;
-                sfbd->clear_depth_4 = job->clear_depth;
+        if (batch->clear & PIPE_CLEAR_DEPTH) {
+                sfbd->clear_depth_1 = batch->clear_depth;
+                sfbd->clear_depth_2 = batch->clear_depth;
+                sfbd->clear_depth_3 = batch->clear_depth;
+                sfbd->clear_depth_4 = batch->clear_depth;
         }
 
-        if (job->clear & PIPE_CLEAR_STENCIL) {
-                sfbd->clear_stencil = job->clear_stencil;
+        if (batch->clear & PIPE_CLEAR_STENCIL) {
+                sfbd->clear_stencil = batch->clear_stencil;
         }
 
         /* Set flags based on what has been cleared, for the SFBD case */
         /* XXX: What do these flags mean? */
         int clear_flags = 0x101100;
 
-        if (!(job->clear & ~(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
+        if (!(batch->clear & ~(PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
                 /* On a tiler like this, it's fastest to clear all three buffers at once */
 
                 clear_flags |= MALI_CLEAR_FAST;
         } else {
                 clear_flags |= MALI_CLEAR_SLOW;
 
-                if (job->clear & PIPE_CLEAR_STENCIL)
+                if (batch->clear & PIPE_CLEAR_STENCIL)
                         clear_flags |= MALI_CLEAR_SLOW_STENCIL;
         }
 
@@ -130,22 +131,21 @@ panfrost_sfbd_set_zsbuf(
 /* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
 
 mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx, bool has_draws)
+panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
 {
-        struct panfrost_job *job = panfrost_get_job_for_fbo(ctx);
-        struct mali_single_framebuffer fb = panfrost_emit_sfbd(ctx, has_draws);
+        struct mali_single_framebuffer fb = panfrost_emit_sfbd(batch, has_draws);
 
-        panfrost_sfbd_clear(job, &fb);
+        panfrost_sfbd_clear(batch, &fb);
 
         /* SFBD does not support MRT natively; sanity check */
-        assert(ctx->pipe_framebuffer.nr_cbufs == 1);
-        panfrost_sfbd_set_cbuf(&fb, ctx->pipe_framebuffer.cbufs[0]);
+        assert(batch->key.nr_cbufs == 1);
+        panfrost_sfbd_set_cbuf(&fb, batch->key.cbufs[0]);
 
-        if (ctx->pipe_framebuffer.zsbuf)
-                panfrost_sfbd_set_zsbuf(&fb, ctx->pipe_framebuffer.zsbuf);
+        if (batch->key.zsbuf)
+                panfrost_sfbd_set_zsbuf(&fb, batch->key.zsbuf);
 
-        if (job->requirements & PAN_REQ_MSAA)
+        if (batch->requirements & PAN_REQ_MSAA)
                 fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
 
-        return panfrost_upload_transient(ctx, &fb, sizeof(fb)) | MALI_SFBD;
+        return panfrost_upload_transient(batch, &fb, sizeof(fb)) | MALI_SFBD;
 }