summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItalo Nicola <italonicola@collabora.com>2023-07-13 14:45:36 +0000
committerMarge Bot <emma+marge@anholt.net>2023-08-07 19:35:12 +0000
commit6a15167b817c3c1136f60935cedc371667e159b4 (patch)
tree45d09c049f631f1c1d196727db3a4c4238983c2c
parentf27b02838d142ba3a855ea42b49008a8bcd49a11 (diff)
panfrost: refactor (un)packing of surface descriptors
Use the genxml helpers to pack/unpack midgard and bifrost surface descriptors. Also changed how we describe midgard's descriptors, to make it more straightforward. We currently only use SURFACE_WITH_STRIDE for midgard, but pandecode should still be able to decode other surface descriptor types. This commit shouldn't change panfrost/pandecode behavior. Consequenctly, this refactor also prepares pandecode to handle the SURFACE_YUV descriptor for bifrost in the following patch. Signed-off-by: Italo Nicola <italonicola@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21109>
-rw-r--r--src/panfrost/lib/genxml/decode.c83
-rw-r--r--src/panfrost/lib/genxml/v4.xml19
-rw-r--r--src/panfrost/lib/genxml/v5.xml19
-rw-r--r--src/panfrost/lib/pan_texture.c2
4 files changed, 73 insertions, 50 deletions
diff --git a/src/panfrost/lib/genxml/decode.c b/src/panfrost/lib/genxml/decode.c
index 5e05abd89f5..022fe83c9f5 100644
--- a/src/panfrost/lib/genxml/decode.c
+++ b/src/panfrost/lib/genxml/decode.c
@@ -217,13 +217,10 @@ GENX(pandecode_blend)(void *descs, int rt_no, mali_ptr frag_shader)
#if PAN_ARCH <= 7
static void
-pandecode_texture_payload(mali_ptr payload, enum mali_texture_dimension dim,
- enum mali_texture_layout layout, bool manual_stride,
- uint8_t levels, uint16_t nr_samples,
- uint16_t array_size)
+pandecode_texture_payload(mali_ptr payload, const struct MALI_TEXTURE *tex)
{
- pandecode_log(".payload = {\n");
- pandecode_indent++;
+ unsigned nr_samples =
+ tex->dimension == MALI_TEXTURE_DIMENSION_3D ? 1 : tex->sample_count;
/* A bunch of bitmap pointers follow.
* We work out the correct number,
@@ -231,44 +228,50 @@ pandecode_texture_payload(mali_ptr payload, enum mali_texture_dimension dim,
* properties, but dump extra
* possibilities to futureproof */
- int bitmap_count = levels;
+ int bitmap_count = tex->levels;
/* Miptree for each face */
- if (dim == MALI_TEXTURE_DIMENSION_CUBE)
+ if (tex->dimension == MALI_TEXTURE_DIMENSION_CUBE)
bitmap_count *= 6;
/* Array of layers */
bitmap_count *= nr_samples;
/* Array of textures */
- bitmap_count *= array_size;
-
- /* Stride for each element */
- if (manual_stride)
- bitmap_count *= 2;
-
- mali_ptr *pointers_and_strides =
- pandecode_fetch_gpu_mem(payload, sizeof(mali_ptr) * bitmap_count);
- for (int i = 0; i < bitmap_count; ++i) {
- /* How we dump depends if this is a stride or a pointer */
-
- if (manual_stride && (i & 1)) {
- /* signed 32-bit snuck in as a 64-bit pointer */
- uint64_t stride_set = pointers_and_strides[i];
- int32_t row_stride = stride_set;
- int32_t surface_stride = stride_set >> 32;
- pandecode_log(
- "(mali_ptr) %d /* surface stride */ %d /* row stride */, \n",
- surface_stride, row_stride);
- } else {
- char *a = pointer_as_memory_reference(pointers_and_strides[i]);
- pandecode_log("%s, \n", a);
- free(a);
- }
+ bitmap_count *= tex->array_size;
+
+#define PANDECODE_EMIT_TEX_PAYLOAD_DESC(T, msg) \
+ for (int i = 0; i < bitmap_count; ++i) { \
+ uint64_t addr = payload + pan_size(T) * i; \
+ pan_unpack(PANDECODE_PTR(addr, void), T, s); \
+ DUMP_UNPACKED(T, s, msg " @%" PRIx64 ":\n", addr) \
}
- pandecode_indent--;
- pandecode_log("},\n");
+#if PAN_ARCH <= 5
+ switch (tex->surface_type) {
+ case MALI_SURFACE_TYPE_32:
+ PANDECODE_EMIT_TEX_PAYLOAD_DESC(SURFACE_32, "Surface 32");
+ break;
+ case MALI_SURFACE_TYPE_64:
+ PANDECODE_EMIT_TEX_PAYLOAD_DESC(SURFACE, "Surface");
+ break;
+ case MALI_SURFACE_TYPE_32_WITH_ROW_STRIDE:
+ PANDECODE_EMIT_TEX_PAYLOAD_DESC(SURFACE_32, "Surface 32 With Row Stride");
+ break;
+ case MALI_SURFACE_TYPE_64_WITH_STRIDES:
+ PANDECODE_EMIT_TEX_PAYLOAD_DESC(SURFACE_WITH_STRIDE,
+ "Surface With Stride");
+ break;
+ default:
+ fprintf(pandecode_dump_stream, "Unknown surface descriptor type %X\n",
+ tex->surface_type);
+ break;
+ }
+#else
+ PANDECODE_EMIT_TEX_PAYLOAD_DESC(SURFACE_WITH_STRIDE, "Surface With Stride");
+#endif
+
+#undef PANDECODE_EMIT_TEX_PAYLOAD_DESC
}
#endif
@@ -282,11 +285,7 @@ GENX(pandecode_texture)(mali_ptr u, unsigned tex)
DUMP_UNPACKED(TEXTURE, temp, "Texture:\n")
pandecode_indent++;
- unsigned nr_samples =
- temp.dimension == MALI_TEXTURE_DIMENSION_3D ? 1 : temp.sample_count;
- pandecode_texture_payload(u + pan_size(TEXTURE), temp.dimension,
- temp.texel_ordering, temp.manual_stride,
- temp.levels, nr_samples, temp.array_size);
+ pandecode_texture_payload(u + pan_size(TEXTURE), &temp);
pandecode_indent--;
}
#else
@@ -308,11 +307,7 @@ GENX(pandecode_texture)(const void *cl, unsigned tex)
for (unsigned i = 0; i < plane_count; ++i)
DUMP_ADDR(PLANE, temp.surfaces + i * pan_size(PLANE), "Plane %u:\n", i);
#else
- unsigned nr_samples =
- temp.dimension == MALI_TEXTURE_DIMENSION_3D ? 1 : temp.sample_count;
-
- pandecode_texture_payload(temp.surfaces, temp.dimension, temp.texel_ordering,
- true, temp.levels, nr_samples, temp.array_size);
+ pandecode_texture_payload(temp.surfaces, &temp);
#endif
pandecode_indent--;
}
diff --git a/src/panfrost/lib/genxml/v4.xml b/src/panfrost/lib/genxml/v4.xml
index 8591549c116..63b7f7f57ac 100644
--- a/src/panfrost/lib/genxml/v4.xml
+++ b/src/panfrost/lib/genxml/v4.xml
@@ -555,10 +555,26 @@
<field name="FBD" size="64" start="28:0" type="address"/>
</struct>
+ <enum name="Surface Type">
+ <value name="32" value="0"/>
+ <value name="64" value="1"/>
+ <value name="32 With Row Stride" value="2"/>
+ <value name="64 With Strides" value="3"/>
+ </enum>
+
<struct name="Surface" align="8">
<field name="Pointer" size="64" start="0:0" type="address"/>
</struct>
+ <struct name="Surface 32" align="4">
+ <field name="Pointer" size="32" start="0:0" type="address"/>
+ </struct>
+
+ <struct name="Surface 32 With Row Stride" align="8">
+ <field name="Pointer" size="32" start="0:0" type="address"/>
+ <field name="Row stride" size="32" start="1:0" type="int"/>
+ </struct>
+
<struct name="Surface With Stride" align="8">
<field name="Pointer" size="64" start="0:0" type="address"/>
<field name="Row stride" size="32" start="2:0" type="int"/>
@@ -594,8 +610,7 @@
<field name="Format" size="22" start="2:0" type="Pixel Format"/>
<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="Surface pointer is 64b" size="1" start="2:28" type="bool" default="true"/>
- <field name="Manual stride" size="1" start="2:29" type="bool" default="false"/>
+ <field name="Surface Type" size="2" start="2:28" type="Surface Type" default="64 With Strides"/>
<field name="Levels" size="8" start="3:24" type="uint" modifier="minus(1)" default="1"/>
<field name="Swizzle" size="12" start="4:0" type="uint"/>
</struct>
diff --git a/src/panfrost/lib/genxml/v5.xml b/src/panfrost/lib/genxml/v5.xml
index b658a53ac55..6c53dac00e6 100644
--- a/src/panfrost/lib/genxml/v5.xml
+++ b/src/panfrost/lib/genxml/v5.xml
@@ -577,10 +577,26 @@
<field name="FBD" size="64" start="28:0" type="address"/>
</struct>
+ <enum name="Surface Type">
+ <value name="32" value="0"/>
+ <value name="64" value="1"/>
+ <value name="32 With Row Stride" value="2"/>
+ <value name="64 With Strides" value="3"/>
+ </enum>
+
<struct name="Surface" align="8">
<field name="Pointer" size="64" start="0:0" type="address"/>
</struct>
+ <struct name="Surface 32" align="4">
+ <field name="Pointer" size="32" start="0:0" type="address"/>
+ </struct>
+
+ <struct name="Surface 32 With Row Stride" align="8">
+ <field name="Pointer" size="32" start="0:0" type="address"/>
+ <field name="Row stride" size="32" start="1:0" type="int"/>
+ </struct>
+
<struct name="Surface With Stride" align="8">
<field name="Pointer" size="64" start="0:0" type="address"/>
<field name="Row stride" size="32" start="2:0" type="int"/>
@@ -616,8 +632,7 @@
<field name="Format" size="22" start="2:0" type="Pixel Format"/>
<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="Surface pointer is 64b" size="1" start="2:28" type="bool" default="true"/>
- <field name="Manual stride" size="1" start="2:29" type="bool" default="false"/>
+ <field name="Surface Type" size="2" start="2:28" type="Surface Type" default="64 With Strides"/>
<field name="Levels" size="8" start="3:24" type="uint" modifier="minus(1)" default="1"/>
<field name="Swizzle" size="12" start="4:0" type="uint"/>
</struct>
diff --git a/src/panfrost/lib/pan_texture.c b/src/panfrost/lib/pan_texture.c
index ff3d7437ebe..90c27ab4fd6 100644
--- a/src/panfrost/lib/pan_texture.c
+++ b/src/panfrost/lib/pan_texture.c
@@ -637,8 +637,6 @@ GENX(panfrost_new_texture)(const struct panfrost_device *dev,
*/
cfg.minimum_lod = 0;
cfg.maximum_lod = cfg.levels - 1;
-#else
- cfg.manual_stride = true;
#endif
}
}