panfrost: Free cloned NIR shader
[mesa.git] / src / gallium / drivers / panfrost / pan_sfbd.c
index 6e80649abf6496d945decdc81e30f40839088d84..58d33dcddde32b488fb8360a621618e81f7f312c 100644 (file)
@@ -25,7 +25,6 @@
 #include "pan_bo.h"
 #include "pan_context.h"
 #include "pan_util.h"
-#include "pan_format.h"
 
 #include "util/format/u_format.h"
 
@@ -69,6 +68,7 @@ panfrost_sfbd_format(struct pipe_surface *surf)
 
         case PIPE_FORMAT_A4B4G4R4_UNORM:
         case PIPE_FORMAT_B4G4R4A4_UNORM:
+        case PIPE_FORMAT_R4G4B4A4_UNORM:
                 fmt.unk1 = 0x4;
                 fmt.nr_channels = MALI_POSITIVE(1);
                 fmt.unk2 = 0x5;
@@ -134,20 +134,20 @@ panfrost_sfbd_set_cbuf(
         assert(surf->u.tex.last_layer == first_layer);
         signed stride = rsrc->slices[level].stride;
 
-        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer);
+        mali_ptr base = panfrost_get_texture_address(rsrc, level, first_layer, 0);
 
         fb->format = panfrost_sfbd_format(surf);
 
         fb->framebuffer = base;
         fb->stride = stride;
 
-        if (rsrc->layout == MALI_TEXTURE_LINEAR)
-                fb->format.block = MALI_BLOCK_LINEAR;
-        else if (rsrc->layout == MALI_TEXTURE_TILED) {
-                fb->format.block = MALI_BLOCK_TILED;
+        if (rsrc->modifier == DRM_FORMAT_MOD_LINEAR)
+                fb->format.block = MALI_BLOCK_FORMAT_LINEAR;
+        else if (rsrc->modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED) {
+                fb->format.block = MALI_BLOCK_FORMAT_TILED;
                 fb->stride *= 16;
         } else {
-                fprintf(stderr, "Invalid render layout\n");
+                fprintf(stderr, "Invalid render modifier\n");
                 assert(0);
         }
 }
@@ -163,27 +163,23 @@ panfrost_sfbd_set_zsbuf(
         unsigned level = surf->u.tex.level;
         assert(surf->u.tex.first_layer == 0);
 
-        if (rsrc->layout != MALI_TEXTURE_TILED)
-                unreachable("Invalid render layout.");
+        if (rsrc->modifier != DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED)
+                unreachable("Invalid render modifier.");
 
         fb->depth_buffer = rsrc->bo->gpu + rsrc->slices[level].offset;
         fb->depth_stride = rsrc->slices[level].stride;
 
         /* No stencil? Job done. */
-        if (!ctx->depth_stencil || !ctx->depth_stencil->stencil[0].enabled)
+        if (!ctx->depth_stencil || !ctx->depth_stencil->base.stencil[0].enabled)
                 return;
 
         if (panfrost_is_z24s8_variant(surf->format)) {
-
                 /* Stencil data is interleaved with depth */
                 fb->stencil_buffer = fb->depth_buffer;
                 fb->stencil_stride = fb->depth_stride;
-        } else if (surf->format == PIPE_FORMAT_Z32_UNORM ||
-                   surf->format == PIPE_FORMAT_Z32_FLOAT) {
-
+        } else if (surf->format == PIPE_FORMAT_Z32_FLOAT) {
                 /* No stencil, nothing to do */
         } else if (surf->format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
-
                 /* Stencil data in separate buffer */
                 struct panfrost_resource *stencil = rsrc->separate_stencil;
                 struct panfrost_slice stencil_slice = stencil->slices[level];
@@ -200,7 +196,7 @@ panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
 {
         struct panfrost_context *ctx = batch->ctx;
         struct pipe_context *gallium = (struct pipe_context *) ctx;
-        struct panfrost_screen *screen = pan_screen(gallium->screen);
+        struct panfrost_device *dev = pan_device(gallium->screen);
 
         unsigned width = batch->key.width;
         unsigned height = batch->key.height;
@@ -208,14 +204,13 @@ panfrost_emit_sfbd(struct panfrost_batch *batch, unsigned vertex_count)
         /* TODO: Why do we need to make the stack bigger than other platforms? */
         unsigned shift = panfrost_get_stack_shift(MAX2(batch->stack_size, 512));
 
-        /* TODO: where do we specify the shift? */
-
         struct mali_single_framebuffer framebuffer = {
                 .width = MALI_POSITIVE(width),
                 .height = MALI_POSITIVE(height),
                 .shared_memory = {
+                        .stack_shift = shift,
                         .shared_workgroup_count = ~0,
-                        .scratchpad = panfrost_batch_get_scratchpad(batch, shift, screen->thread_tls_alloc, screen->core_count)->gpu,
+                        .scratchpad = panfrost_batch_get_scratchpad(batch, shift, dev->thread_tls_alloc, dev->core_count)->gpu,
                 },
                 .format = {
                         .unk3 = 0x3,
@@ -271,5 +266,5 @@ panfrost_sfbd_fragment(struct panfrost_batch *batch, bool has_draws)
                 fb.format.unk2 |= MALI_SFBD_FORMAT_MSAA_B;
         }
 
-        return panfrost_upload_transient(batch, &fb, sizeof(fb));
+        return panfrost_pool_upload(&batch->pool, &fb, sizeof(fb));
 }