radeonsi/gfx10: update a tunable max_es_verts_base for NGG
[mesa.git] / src / gallium / drivers / panfrost / pan_sfbd.c
index d04da20e258ab6868d621d63b9ce5498f6cc09a3..563e4269b8df31a2988e5340a7e2307f0e6def5b 100644 (file)
@@ -36,22 +36,17 @@ panfrost_sfbd_format(struct pipe_surface *surf)
 }
 
 static void
-panfrost_sfbd_enable_msaa(struct panfrost_context *ctx)
-{
-        ctx->fragment_sfbd.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
-}
-
-static void
-panfrost_sfbd_clear(struct panfrost_job *job)
+panfrost_sfbd_clear(
+        struct panfrost_job *job,
+        struct mali_single_framebuffer *sfbd)
 {
         struct panfrost_context *ctx = job->ctx;
-        struct mali_single_framebuffer *sfbd = &ctx->fragment_sfbd;
 
         if (job->clear & PIPE_CLEAR_COLOR) {
-                sfbd->clear_color_1 = job->clear_color;
-                sfbd->clear_color_2 = job->clear_color;
-                sfbd->clear_color_3 = job->clear_color;
-                sfbd->clear_color_4 = job->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 (job->clear & PIPE_CLEAR_DEPTH) {
@@ -60,14 +55,14 @@ panfrost_sfbd_clear(struct panfrost_job *job)
                 sfbd->clear_depth_3 = job->clear_depth;
                 sfbd->clear_depth_4 = job->clear_depth;
 
-                sfbd->depth_buffer = ctx->depth_stencil_buffer.gpu;
+                sfbd->depth_buffer = ctx->depth_stencil_buffer.bo->gpu;
                 sfbd->depth_buffer_enable = MALI_DEPTH_STENCIL_ENABLE;
         }
 
         if (job->clear & PIPE_CLEAR_STENCIL) {
                 sfbd->clear_stencil = job->clear_stencil;
 
-                sfbd->stencil_buffer = ctx->depth_stencil_buffer.gpu;
+                sfbd->stencil_buffer = ctx->depth_stencil_buffer.bo->gpu;
                 sfbd->stencil_buffer_enable = MALI_DEPTH_STENCIL_ENABLE;
         }
 
@@ -91,60 +86,44 @@ panfrost_sfbd_clear(struct panfrost_job *job)
 
 static void
 panfrost_sfbd_set_cbuf(
-                struct panfrost_context *ctx,
-                struct pipe_surface *surf)
+        struct mali_single_framebuffer *fb,
+        struct pipe_surface *surf)
 {
         struct panfrost_resource *rsrc = pan_resource(surf->texture);
 
-        signed stride =
-                util_format_get_stride(surf->format, surf->texture->width0);
-
-        ctx->fragment_sfbd.format = panfrost_sfbd_format(surf);
+        signed stride = rsrc->slices[0].stride;
 
-        if (rsrc->bo->layout == PAN_LINEAR) {
-                mali_ptr framebuffer = rsrc->bo->gpu[0];
+        fb->format = panfrost_sfbd_format(surf);
 
-                /* The default is upside down from OpenGL's perspective. */
-                if (panfrost_is_scanout(ctx)) {
-                        framebuffer += stride * (surf->texture->height0 - 1);
-                        stride = -stride;
-                }
-
-                ctx->fragment_sfbd.framebuffer = framebuffer;
-                ctx->fragment_sfbd.stride = stride;
+        if (rsrc->layout == PAN_LINEAR) {
+                fb->framebuffer = rsrc->bo->gpu;
+                fb->stride = stride;
         } else {
                 fprintf(stderr, "Invalid render layout\n");
                 assert(0);
         }
 }
 
-static void
-panfrost_sfbd_set_targets(struct panfrost_context *ctx)
-{
-        assert(ctx->pipe_framebuffer.nr_cbufs == 1);
-        panfrost_sfbd_set_cbuf(ctx, ctx->pipe_framebuffer.cbufs[0]);
-
-        if (ctx->pipe_framebuffer.zsbuf) {
-                /* TODO */
-        }
-}
-
 /* Creates an SFBD for the FRAGMENT section of the bound framebuffer */
 
 mali_ptr
-panfrost_sfbd_fragment(struct panfrost_context *ctx)
+panfrost_sfbd_fragment(struct panfrost_context *ctx, 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(ctx);
-        memcpy(&ctx->fragment_sfbd, &fb, sizeof(fb));
+        panfrost_sfbd_clear(job, &fb);
 
-        panfrost_sfbd_clear(job);
-        panfrost_sfbd_set_targets(ctx);
+        /* 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]);
+
+        if (ctx->pipe_framebuffer.zsbuf) {
+                /* TODO */
+        }
 
-        if (job->msaa)
-                panfrost_sfbd_enable_msaa(ctx);
+        if (job->requirements & PAN_REQ_MSAA)
+                fb.format |= MALI_FRAMEBUFFER_MSAA_A | MALI_FRAMEBUFFER_MSAA_B;
 
-        return MALI_SFBD |
-                panfrost_upload_transient(ctx, &ctx->fragment_sfbd, sizeof(fb));
+        return panfrost_upload_transient(ctx, &fb, sizeof(fb)) | MALI_SFBD;
 }