panfrost: XMLify Midgard textures
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 11 Aug 2020 21:27:36 +0000 (17:27 -0400)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 13 Aug 2020 06:55:16 +0000 (08:55 +0200)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6195>

src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_job.c
src/gallium/drivers/panfrost/pan_mfbd.c
src/gallium/drivers/panfrost/pan_resource.h
src/panfrost/include/panfrost-job.h
src/panfrost/lib/decode.c
src/panfrost/lib/midgard.xml
src/panfrost/lib/pan_blit.c
src/panfrost/lib/pan_texture.c
src/panfrost/lib/pan_texture.h

index 6fd3f15d1f62d269f2820b0ed74608c660dc50e0..18e6f78cd4b6e1f7117ab86cfcd3d90511c0c07d 100644 (file)
@@ -958,8 +958,8 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                 assert(texture->nr_samples <= 1);
         }
 
-        enum mali_texture_type type =
-                panfrost_translate_texture_type(so->base.target);
+        enum mali_texture_dimension type =
+                panfrost_translate_texture_dimension(so->base.target);
 
         if (device->quirks & IS_BIFROST) {
                 unsigned char composed_swizzle[4];
@@ -1000,7 +1000,7 @@ panfrost_create_sampler_view_bo(struct panfrost_sampler_view *so,
                                 so->base.u.tex.last_layer,
                                 texture->nr_samples,
                                 type, prsrc->modifier);
-                size += sizeof(struct mali_texture_descriptor);
+                size += MALI_MIDGARD_TEXTURE_LENGTH;
 
                 so->bo = panfrost_bo_create(device, size, 0);
 
index 0b6ffd0d329b456ffca7d07c14e9331129a16a26..9aa1f1bb71d9061c6b6bbf21cad646d07a990f0b 100644 (file)
@@ -836,15 +836,15 @@ panfrost_load_surface(struct panfrost_batch *batch, struct pipe_surface *surf, u
                 format = util_format_stencil_only(format);
         }
 
-        enum mali_texture_type type =
-                panfrost_translate_texture_type(rsrc->base.target);
+        enum mali_texture_dimension dim =
+                panfrost_translate_texture_dimension(rsrc->base.target);
 
         struct pan_image img = {
                 .width0 = rsrc->base.width0,
                 .height0 = rsrc->base.height0,
                 .depth0 = rsrc->base.depth0,
                 .format = format,
-                .type = type,
+                .dim = dim,
                 .modifier = rsrc->modifier,
                 .array_size = rsrc->base.array_size,
                 .first_level = level,
index 759b8d9936bfa73636d7294821b3be737a9fa90c..3dc3a3dd25ac496a650e3042e44d8e80dccef812 100644 (file)
@@ -313,7 +313,6 @@ panfrost_mfbd_set_zsbuf(
                 fbx->ds_afbc.padding = 0x1000;
         } else {
                 assert(rsrc->modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED || rsrc->modifier == DRM_FORMAT_MOD_LINEAR);
-
                 /* TODO: Z32F(S8) support, which is always linear */
 
                 int stride = rsrc->slices[level].stride;
index 12f1dd8f270abc10f534ba3335a4c135cfb5ab16..009f13c0f86afe2e76962fe15ef6c934bf1fbae0 100644 (file)
@@ -122,26 +122,26 @@ panfrost_resource_set_damage_region(struct pipe_screen *screen,
                                     unsigned int nrects,
                                     const struct pipe_box *rects);
 
-static inline enum mali_texture_type
-panfrost_translate_texture_type(enum pipe_texture_target t) {
+static inline enum mali_texture_dimension
+panfrost_translate_texture_dimension(enum pipe_texture_target t) {
         switch (t)
         {
         case PIPE_BUFFER:
         case PIPE_TEXTURE_1D:
         case PIPE_TEXTURE_1D_ARRAY:
-                return MALI_TEX_1D;
+                return MALI_TEXTURE_DIMENSION_1D;
 
         case PIPE_TEXTURE_2D:
         case PIPE_TEXTURE_2D_ARRAY:
         case PIPE_TEXTURE_RECT:
-                return MALI_TEX_2D;
+                return MALI_TEXTURE_DIMENSION_2D;
 
         case PIPE_TEXTURE_3D:
-                return MALI_TEX_3D;
+                return MALI_TEXTURE_DIMENSION_3D;
 
         case PIPE_TEXTURE_CUBE:
         case PIPE_TEXTURE_CUBE_ARRAY:
-                return MALI_TEX_CUBE;
+                return MALI_TEXTURE_DIMENSION_CUBE;
 
         default:
                 unreachable("Unknown target");
index 62067a557f159f171a9cf6b93275aad836a251d9..20209e95dc1628be355c102c6447a3931276f956 100644 (file)
@@ -1139,15 +1139,6 @@ struct bifrost_payload_fused {
 
 #define MALI_POSITIVE(dim) (dim - 1)
 
-/* Shared across both command stream and Midgard, and even with Bifrost */
-
-enum mali_texture_type {
-        MALI_TEX_CUBE = 0x0,
-        MALI_TEX_1D = 0x1,
-        MALI_TEX_2D = 0x2,
-        MALI_TEX_3D = 0x3
-};
-
 /* 8192x8192 */
 #define MAX_MIP_LEVELS (13)
 
@@ -1157,76 +1148,12 @@ enum mali_texture_type {
 /* For each pointer, there is an address and optionally also a stride */
 #define MAX_ELEMENTS (2)
 
-/* It's not known why there are 4-bits allocated -- this enum is almost
- * certainly incomplete */
-
-enum mali_texture_layout {
-        /* For a Z/S texture, this is linear */
-        MALI_TEXTURE_TILED = 0x1,
-
-        /* Z/S textures cannot be tiled */
-        MALI_TEXTURE_LINEAR = 0x2,
-
-        /* 16x16 sparse */
-        MALI_TEXTURE_AFBC = 0xC
-};
-
-/* Corresponds to the type passed to glTexImage2D and so forth */
-
-struct mali_texture_format {
-        unsigned swizzle : 12;
-        enum mali_format format : 8;
-
-        unsigned srgb : 1;
-        unsigned unknown1 : 1;
-
-        enum mali_texture_type type : 2;
-        enum mali_texture_layout layout : 4;
-
-        /* Always set */
-        unsigned unknown2 : 1;
-
-        /* Set to allow packing an explicit stride */
-        unsigned manual_stride : 1;
-
-        unsigned zero : 2;
-} __attribute__((packed));
-
-struct mali_texture_descriptor {
-        uint16_t width;
-        uint16_t height;
-        uint16_t depth;
-        uint16_t array_size;
-
-        struct mali_texture_format format;
-
-        uint16_t unknown3;
-
-        /* One for non-mipmapped, zero for mipmapped */
-        uint8_t unknown3A;
-
-        /* Zero for non-mipmapped, (number of levels - 1) for mipmapped */
-        uint8_t levels;
-
-        /* Swizzling is a single 32-bit word, broken up here for convenience.
-         * Here, swizzling refers to the ES 3.0 texture parameters for channel
-         * level swizzling, not the internal pixel-level swizzling which is
-         * below OpenGL's reach */
-
-        unsigned swizzle : 12;
-        unsigned swizzle_zero       : 20;
-
-        uint32_t unknown5;
-        uint32_t unknown6;
-        uint32_t unknown7;
-} __attribute__((packed));
-
 /* While Midgard texture descriptors are variable length, Bifrost descriptors
  * are fixed like samplers with more pointers to expand if necessary */
 
 struct bifrost_texture_descriptor {
         unsigned format_unk : 4; /* 2 */
-        enum mali_texture_type type : 2;
+        enum mali_texture_dimension type : 2;
         unsigned zero : 4;
         unsigned format_swizzle : 12;
         enum mali_format format : 8;
index 4126ec546506a273217e682fb5380f3fa83d9993..4589613b4abdcae96341a1bb80cf9c8a8fb7c981 100644 (file)
@@ -2034,7 +2034,7 @@ pandecode_shader_disassemble(mali_ptr shader_ptr, int shader_no, int type,
 
 static void
 pandecode_texture_payload(mali_ptr payload,
-                          enum mali_texture_type type,
+                          enum mali_texture_dimension dim,
                           enum mali_texture_layout layout,
                           bool manual_stride,
                           uint8_t levels,
@@ -2054,14 +2054,14 @@ pandecode_texture_payload(mali_ptr payload,
         int bitmap_count = levels + 1;
 
         /* Miptree for each face */
-        if (type == MALI_TEX_CUBE)
+        if (dim == MALI_TEXTURE_DIMENSION_CUBE)
                 bitmap_count *= 6;
 
         /* Array of layers */
-        bitmap_count *= (depth + 1);
+        bitmap_count *= depth;
 
         /* Array of textures */
-        bitmap_count *= (array_size + 1);
+        bitmap_count *= array_size;
 
         /* Stride for each element */
         if (manual_stride)
@@ -2095,126 +2095,16 @@ pandecode_texture(mali_ptr u,
                 struct pandecode_mapped_memory *tmem,
                 unsigned job_no, unsigned tex)
 {
-        struct mali_texture_descriptor *PANDECODE_PTR_VAR(t, tmem, u);
+        struct pandecode_mapped_memory *mapped_mem = pandecode_find_mapped_gpu_mem_containing(u);
+        const uint8_t *cl = pandecode_fetch_gpu_mem(mapped_mem, u, MALI_MIDGARD_TEXTURE_LENGTH);
 
-        pandecode_log("struct mali_texture_descriptor texture_descriptor_%"PRIx64"_%d_%d = {\n", u, job_no, tex);
-        pandecode_indent++;
-
-        pandecode_prop("width = %" PRId32, t->width);
-        pandecode_prop("height = %" PRId32, t->height);
-        pandecode_prop("depth = %" PRId32, t->depth);
-        pandecode_prop("array_size = %" PRId32, t->array_size);
-
-        pandecode_log("\n");
-        pandecode_prop("f.swizzle = 0x%" PRIx32, t->format.swizzle);
-        pandecode_prop("f.format = 0x%" PRIx32, t->format.format);
-        pandecode_prop("f.srgb = 0x%" PRIx32, t->format.srgb);
-        pandecode_prop("f.unknown1 = 0x%" PRIx32, t->format.unknown1);
-        pandecode_prop("f.type = %" PRId32, t->format.type);
-        pandecode_prop("f.layout = %" PRId32, t->format.layout);
-        pandecode_prop("f.unknown2 = 0x%" PRIx32, t->format.unknown2);
-        pandecode_prop("f.manual_stride = %" PRId32, t->format.manual_stride);
-        pandecode_prop("f.zero = 0x%" PRIx32, t->format.zero);
-        pandecode_log("\n");
-
-        pandecode_prop("unknown3 = 0x%" PRIx32, t->unknown3);
-        pandecode_prop("unknown3A = 0x%" PRIx32, t->unknown3A);
-        pandecode_prop("levels = %" PRId32, t->levels);
-        pandecode_prop("swizzle = 0x%" PRIx32, t->swizzle);
-        pandecode_prop("swizzle_zero = 0x%" PRIx32, t->swizzle_zero);
-
-        pandecode_prop("unknown5 = 0x%" PRIx32, t->unknown5);
-        pandecode_prop("unknown6 = 0x%" PRIx32, t->unknown6);
-        pandecode_prop("unknown7 = 0x%" PRIx32, t->unknown7);
-        pandecode_log("\n");
-
-        struct mali_texture_format f = t->format;
-
-        /* See the definiton of enum mali_texture_type */
-
-        bool is_cube = f.type == MALI_TEX_CUBE;
-        unsigned dimension = is_cube ? 2 : f.type;
-
-        pandecode_make_indent();
-
-        /* Print the layout. Default is linear; a modifier can denote AFBC or
-         * u-interleaved/tiled modes */
-
-        if (f.layout == MALI_TEXTURE_AFBC)
-                pandecode_log_cont("afbc");
-        else if (f.layout == MALI_TEXTURE_TILED)
-                pandecode_log_cont("tiled");
-        else if (f.layout == MALI_TEXTURE_LINEAR)
-                pandecode_log_cont("linear");
-        else
-                pandecode_msg("XXX: invalid texture layout 0x%X\n", f.layout);
-
-        pandecode_swizzle(t->swizzle, f.format);
-        pandecode_log_cont(" ");
-
-        /* Distinguish cube/2D with modifier */
-
-        if (is_cube)
-                pandecode_log_cont("cube ");
-
-        pandecode_format_short(f.format, f.srgb);
-        pandecode_swizzle(f.swizzle, f.format);
+        struct MALI_MIDGARD_TEXTURE temp;
+        MALI_MIDGARD_TEXTURE_unpack(cl, &temp);
+        MALI_MIDGARD_TEXTURE_print(pandecode_dump_stream, &temp, 2);
 
-        /* All four width/height/depth/array_size dimensions are present
-         * regardless of the type of texture, but it is an error to have
-         * non-zero dimensions for unused dimensions. Verify this. array_size
-         * can always be set, as can width. Depth used for MSAA. */
-
-        if (t->height && dimension < 2)
-                pandecode_msg("XXX: nonzero height for <2D texture\n");
-
-        /* Print only the dimensions that are actually there */
-
-        pandecode_log_cont(": %d", t->width + 1);
-
-        if (t->height || t->depth)
-                pandecode_log_cont("x%u", t->height + 1);
-
-        if (t->depth)
-                pandecode_log_cont("x%u", t->depth + 1);
-
-        if (t->array_size)
-                pandecode_log_cont("[%u]", t->array_size + 1);
-
-        if (t->levels)
-                pandecode_log_cont(" mip %u", t->levels);
-
-        pandecode_log_cont("\n");
-
-        if (f.unknown1 | f.zero) {
-                pandecode_msg("XXX: texture format zero tripped\n");
-                pandecode_prop("unknown1 = %" PRId32, f.unknown1);
-                pandecode_prop("zero = %" PRId32, f.zero);
-        }
-
-        if (!f.unknown2) {
-                pandecode_msg("XXX: expected unknown texture bit set\n");
-                pandecode_prop("unknown2 = %" PRId32, f.unknown2);
-        }
-
-        if (t->swizzle_zero) {
-                pandecode_msg("XXX: swizzle zero tripped\n");
-                pandecode_prop("swizzle_zero = %d", t->swizzle_zero);
-        }
-
-        if (t->unknown3 | t->unknown3A | t->unknown5 | t->unknown6 | t->unknown7) {
-                pandecode_msg("XXX: texture zero tripped\n");
-                pandecode_prop("unknown3 = %" PRId16, t->unknown3);
-                pandecode_prop("unknown3A = %" PRId8, t->unknown3A);
-                pandecode_prop("unknown5 = 0x%" PRIx32, t->unknown5);
-                pandecode_prop("unknown6 = 0x%" PRIx32, t->unknown6);
-                pandecode_prop("unknown7 = 0x%" PRIx32, t->unknown7);
-        }
-
-        pandecode_texture_payload(u + sizeof(*t), f.type, f.layout, f.manual_stride, t->levels, t->depth, t->array_size, tmem);
-
-        pandecode_indent--;
-        pandecode_log("};\n");
+        pandecode_texture_payload(u + MALI_MIDGARD_TEXTURE_LENGTH,
+                        temp.dimension, temp.texel_ordering, temp.manual_stride,
+                        temp.levels, temp.depth, temp.array_size, mapped_mem);
 }
 
 static void
@@ -2252,19 +2142,17 @@ pandecode_bifrost_texture(
         pandecode_prop("unk5 = 0x%" PRIx32, t->unk5);
         pandecode_log("\n");
 
-        /* See the definiton of enum mali_texture_type */
-
-        bool is_cube = t->type == MALI_TEX_CUBE;
+        bool is_cube = t->type == MALI_TEXTURE_DIMENSION_CUBE;
         unsigned dimension = is_cube ? 2 : t->type;
 
         /* Print the layout. Default is linear; a modifier can denote AFBC or
          * u-interleaved/tiled modes */
 
-        if (t->layout == MALI_TEXTURE_AFBC)
+        if (t->layout == MALI_TEXTURE_LAYOUT_AFBC)
                 pandecode_log_cont("afbc");
-        else if (t->layout == MALI_TEXTURE_TILED)
+        else if (t->layout == MALI_TEXTURE_LAYOUT_TILED)
                 pandecode_log_cont("tiled");
-        else if (t->layout == MALI_TEXTURE_LINEAR)
+        else if (t->layout == MALI_TEXTURE_LAYOUT_LINEAR)
                 pandecode_log_cont("linear");
         else
                 pandecode_msg("XXX: invalid texture layout 0x%X\n", t->layout);
index 7e4cf01c781ba446e060e2812fc513a51182dc70..9a847741056620a6d2816ea5e2f89c47edee7620 100644 (file)
     <value name="Decr Sat" value="7"/>
   </enum>
 
+  <enum name="Texture Dimension">
+    <value name="Cube" value="0"/>
+    <value name="1D" value="1"/>
+    <value name="2D" value="2"/>
+    <value name="3D" value="3"/>
+  </enum>
+
+  <enum name="Texture Layout">
+    <!--- 16x16 block u-interleaved -->
+    <value name="Tiled" value="1"/>
+    <value name="Linear" value="2"/>
+    <value name="AFBC" value="12"/>
+  </enum>
+
   <enum name="Wrap Mode">
     <value name="Repeat" value="8"/>
     <value name="Clamp to Edge" value="9"/>
     <field name="Border Color A" size="32" start="7:0" type="float" default="0.0"/>
   </struct>
 
+  <struct name="Midgard Texture" size="8">
+    <field name="Width" size="16" start="0:0" type="uint" modifier="minus(1)"/>
+    <field name="Height" size="16" start="0:16" type="uint" modifier="minus(1)"/>
+    <field name="Depth" size="16" start="1:0" type="uint" modifier="minus(1)"/>
+    <field name="Array size" size="16" start="1:16" type="uint" modifier="minus(1)"/>
+    <field name="Format" size="22" start="2:0" type="uint"/>
+    <field name="Dimension" size="2" start="2:22" type="Texture Dimension"/>
+    <field name="Texel ordering" size="4" start="2:24" type="Texture Layout"/>
+    <field name="Unknown" size="1" start="2:28" type="bool" default="true"/>
+    <field name="Manual stride" size="1" start="2:29" type="bool" default="false"/>
+    <field name="Levels" size="8" start="3:24" type="uint"/>
+    <field name="Swizzle" size="12" start="4:0" type="uint"/>
+  </struct>
+
   <struct name="Bifrost Sampler" size="8">
     <field name="Type" size="4" start="0:0" type="uint" default="1"/>
     <field name="Wrap Mode R" size="4" start="0:8" type="Wrap Mode" default="Clamp to Edge"/>
index 28e0b8aeb4f04add3ebfdcb38bc13ebc11ecaf2f..836f4ad3485dbd6c3f5839fa0ff43aa6903fc914 100644 (file)
@@ -289,12 +289,12 @@ panfrost_load_midg(
          * textures, removing the need to separately key the blit shaders for
          * 2D and 3D variants */
 
-        struct panfrost_transfer texture_t = panfrost_pool_alloc(pool, sizeof(struct mali_texture_descriptor) + sizeof(mali_ptr) * 2 * MAX2(image->nr_samples, 1));
+        struct panfrost_transfer texture_t = panfrost_pool_alloc(pool, MALI_MIDGARD_TEXTURE_LENGTH + sizeof(mali_ptr) * 2 * MAX2(image->nr_samples, 1));
 
         panfrost_new_texture(texture_t.cpu,
                         image->width0, image->height0,
                         MAX2(image->nr_samples, 1), 1,
-                        image->format, MALI_TEX_2D,
+                        image->format, MALI_TEXTURE_DIMENSION_2D,
                         image->modifier,
                         image->first_level, image->last_level,
                         0, 0,
@@ -303,7 +303,7 @@ panfrost_load_midg(
                         (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) | (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9),
                         image->bo->gpu + image->first_layer *
                                 panfrost_get_layer_stride(image->slices,
-                                        image->type == MALI_TEX_3D,
+                                        image->dim == MALI_TEXTURE_DIMENSION_3D,
                                         image->cubemap_stride, image->first_level),
                         image->slices);
 
index 4466b6f0ca49618bf64cee28b9a78e41ba5ebc44..335e143b2e83729fe9f819d09cf9af816f747758 100644 (file)
  * dedicated BO and not have to worry. In practice there are some minor gotchas
  * with this (the driver sometimes will change the format of a texture on the
  * fly for compression) but it's fast enough to just regenerate the descriptor
- * in those cases, rather than monkeypatching at drawtime.
- *
- * A texture descriptor consists of a 32-byte mali_texture_descriptor structure
- * followed by a variable number of pointers. Due to this variance and
- * potentially large size, we actually upload directly rather than returning
- * the descriptor. Whether the user does a copy themselves or not is irrelevant
- * to us here.
+ * in those cases, rather than monkeypatching at drawtime. A texture descriptor
+ * consists of a 32-byte header followed by pointers. 
  */
 
 /* List of supported modifiers, in descending order of preference. AFBC is
@@ -67,11 +62,11 @@ static enum mali_texture_layout
 panfrost_modifier_to_layout(uint64_t modifier)
 {
         if (drm_is_afbc(modifier))
-                return MALI_TEXTURE_AFBC;
+                return MALI_TEXTURE_LAYOUT_AFBC;
         else if (modifier == DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED)
-                return MALI_TEXTURE_TILED;
+                return MALI_TEXTURE_LAYOUT_TILED;
         else if (modifier == DRM_FORMAT_MOD_LINEAR)
-                return MALI_TEXTURE_LINEAR;
+                return MALI_TEXTURE_LAYOUT_LINEAR;
         else
                 unreachable("Invalid modifer");
 }
@@ -190,7 +185,7 @@ panfrost_estimate_texture_payload_size(
                 unsigned first_level, unsigned last_level,
                 unsigned first_layer, unsigned last_layer,
                 unsigned nr_samples,
-                enum mali_texture_type type, uint64_t modifier)
+                enum mali_texture_dimension dim, uint64_t modifier)
 {
         /* Assume worst case */
         unsigned manual_stride = (modifier == DRM_FORMAT_MOD_LINEAR);
@@ -199,7 +194,7 @@ panfrost_estimate_texture_payload_size(
                         first_level, last_level,
                         first_layer, last_layer,
                         nr_samples,
-                        type == MALI_TEX_CUBE, manual_stride);
+                        dim == MALI_TEXTURE_DIMENSION_CUBE, manual_stride);
 
         return sizeof(mali_ptr) * elements;
 }
@@ -228,7 +223,7 @@ panfrost_emit_texture_payload(
         mali_ptr *payload,
         const struct util_format_description *desc,
         enum mali_format mali_format,
-        enum mali_texture_type type,
+        enum mali_texture_dimension dim,
         uint64_t modifier,
         unsigned width, unsigned height,
         unsigned first_level, unsigned last_level,
@@ -246,7 +241,7 @@ panfrost_emit_texture_payload(
 
         unsigned first_face  = 0, last_face = 0, face_mult = 1;
 
-        if (type == MALI_TEX_CUBE) {
+        if (dim == MALI_TEXTURE_DIMENSION_CUBE) {
                 face_mult = 6;
                 panfrost_adjust_cube_dimensions(&first_face, &last_face, &first_layer, &last_layer);
         }
@@ -260,7 +255,7 @@ panfrost_emit_texture_payload(
                         for (unsigned f = first_face; f <= last_face; ++f) {
                                 for (unsigned s = 0; s < nr_samples; ++s) {
                                         payload[idx++] = base + panfrost_texture_offset(
-                                                        slices, type == MALI_TEX_3D,
+                                                        slices, dim == MALI_TEXTURE_DIMENSION_3D,
                                                         cube_stride, l, w * face_mult + f, s);
 
                                         if (manual_stride) {
@@ -296,7 +291,7 @@ panfrost_new_texture(
         uint16_t width, uint16_t height,
         uint16_t depth, uint16_t array_size,
         enum pipe_format format,
-        enum mali_texture_type type,
+        enum mali_texture_dimension dim,
         uint64_t modifier,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
@@ -318,36 +313,32 @@ panfrost_new_texture(
                 && panfrost_needs_explicit_stride(slices, width,
                                 first_level, last_level, bytes_per_pixel);
 
-        struct mali_texture_descriptor descriptor = {
-                .width = MALI_POSITIVE(u_minify(width, first_level)),
-                .height = MALI_POSITIVE(u_minify(height, first_level)),
-                .depth = MALI_POSITIVE(u_minify(depth, first_level)),
-                .array_size = MALI_POSITIVE(array_size),
-                .format = {
-                        .swizzle = (format == PIPE_FORMAT_X24S8_UINT) ?
+        unsigned format_swizzle = (format == PIPE_FORMAT_X24S8_UINT) ?
                                 MALI_SWIZZLE_A001 :
                                 (format == PIPE_FORMAT_S8_UINT) ?
                                 MALI_SWIZZLE_R001 :
-                                panfrost_translate_swizzle_4(desc->swizzle),
-                        .format = mali_format,
-                        .srgb = (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB),
-                        .type = type,
-                        .layout = panfrost_modifier_to_layout(modifier),
-                        .manual_stride = manual_stride,
-                        .unknown2 = 1,
-                },
-                .levels = last_level - first_level,
-                .swizzle = swizzle
+                                panfrost_translate_swizzle_4(desc->swizzle);
+
+        bool srgb = (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB);
+
+        pan_pack(out, MIDGARD_TEXTURE, cfg) {
+                cfg.width = u_minify(width, first_level);
+                cfg.height = u_minify(height, first_level);
+                cfg.depth = u_minify(depth, first_level);
+                cfg.array_size = array_size;
+                cfg.format = format_swizzle | (mali_format << 12) | (srgb << 20);
+                cfg.dimension = dim;
+                cfg.texel_ordering = panfrost_modifier_to_layout(modifier);
+                cfg.manual_stride = manual_stride;
+                cfg.levels = last_level - first_level;
+                cfg.swizzle = swizzle;
         };
 
-        memcpy(out, &descriptor, sizeof(descriptor));
-
-        mali_ptr *payload = (mali_ptr *) (out + sizeof(struct mali_texture_descriptor));
         panfrost_emit_texture_payload(
-                payload,
+                (mali_ptr *) (out + MALI_MIDGARD_TEXTURE_LENGTH),
                 desc,
                 mali_format,
-                type,
+                dim,
                 modifier,
                 width, height,
                 first_level, last_level,
@@ -365,7 +356,7 @@ panfrost_new_texture_bifrost(
         uint16_t width, uint16_t height,
         uint16_t depth, uint16_t array_size,
         enum pipe_format format,
-        enum mali_texture_type type,
+        enum mali_texture_dimension dim,
         uint64_t modifier,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
@@ -386,7 +377,7 @@ panfrost_new_texture_bifrost(
                 (mali_ptr *) payload->cpu,
                 desc,
                 mali_format,
-                type,
+                dim,
                 modifier,
                 width, height,
                 first_level, last_level,
@@ -398,7 +389,7 @@ panfrost_new_texture_bifrost(
                 slices);
 
         descriptor->format_unk = 0x2;
-        descriptor->type = type;
+        descriptor->type = dim;
         descriptor->format = mali_format;
         descriptor->srgb = (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB);
         descriptor->format_unk3 = 0x0;
index 196c7b5e6bba6e6f2ce100057791bd873aaf8db5..af12ee1ea649630d987f9c15b1dd66478cd6ffa0 100644 (file)
@@ -61,7 +61,7 @@ struct pan_image {
         /* Format and size */
         uint16_t width0, height0, depth0, array_size;
         enum pipe_format format;
-        enum mali_texture_type type;
+        enum mali_texture_dimension dim;
         unsigned first_level, last_level;
         unsigned first_layer, last_layer;
         unsigned nr_samples;
@@ -88,14 +88,12 @@ panfrost_afbc_header_size(unsigned width, unsigned height);
 bool
 panfrost_afbc_can_ytr(enum pipe_format format);
 
-/* mali_texture_descriptor */
-
 unsigned
 panfrost_estimate_texture_payload_size(
                 unsigned first_level, unsigned last_level,
                 unsigned first_layer, unsigned last_layer,
                 unsigned nr_samples,
-                enum mali_texture_type type, uint64_t modifier);
+                enum mali_texture_dimension dim, uint64_t modifier);
 
 void
 panfrost_new_texture(
@@ -103,7 +101,7 @@ panfrost_new_texture(
         uint16_t width, uint16_t height,
         uint16_t depth, uint16_t array_size,
         enum pipe_format format,
-        enum mali_texture_type type,
+        enum mali_texture_dimension dim,
         uint64_t modifier,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,
@@ -119,7 +117,7 @@ panfrost_new_texture_bifrost(
         uint16_t width, uint16_t height,
         uint16_t depth, uint16_t array_size,
         enum pipe_format format,
-        enum mali_texture_type type,
+        enum mali_texture_dimension dim,
         uint64_t modifier,
         unsigned first_level, unsigned last_level,
         unsigned first_layer, unsigned last_layer,