panfrost: untangle faces from layers

The hardware doesn't prevent us from mapping random 2DArray layers
as cube/cube arrays. The only restriction we have is on the number
of layers we pass (must be a multiple of 6 for cube arrays).

This patch makes the surface emission logic cube-agnostic, and
moves the cube face -> surface index conversion logic one layer
up to simplify things.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28909>
This commit is contained in:
Erik Faye-Lund
2024-04-23 11:58:28 +02:00
committed by Marge Bot
parent 8455e0521e
commit afef382009
5 changed files with 32 additions and 57 deletions

View File

@@ -86,8 +86,6 @@ spec@arb_texture_rg@fbo-blending-formats,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_R8,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_RG8,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_RG,Fail
spec@arb_texture_view@sampling-2d-array-as-cubemap-array,Crash
spec@arb_texture_view@sampling-2d-array-as-cubemap,Crash
spec@arb_transform_feedback_instanced@draw-auto instanced,Fail
spec@arb_uniform_buffer_object@rendering-dsa-offset,Fail
spec@arb_uniform_buffer_object@rendering-offset,Fail
@@ -306,7 +304,6 @@ spec@khr_texture_compression_astc@sliced-3d-miptree-gl hdr,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gl hdr@HDR Profile,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp@sRGB decode full precision,Fail
spec@oes_texture_view@sampling-2d-array-as-cubemap,Crash
spec@!opengl 1.0@gl-1.0-edgeflag-const,Fail
spec@!opengl 1.0@gl-1.0-edgeflag,Fail
spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail

View File

@@ -47,8 +47,6 @@ spec@arb_texture_rectangle@tex-miplevel-selection gl2:texture() 2drectshadow
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drect
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drect_projvec4
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drectshadow
spec@arb_texture_view@sampling-2d-array-as-cubemap-array
spec@arb_texture_view@sampling-2d-array-as-cubemap
spec@ext_transform_feedback@immediate-reuse-index-buffer
spec@ext_transform_feedback@immediate-reuse-uniform-buffer
spec@glsl-1.30@execution@tex-miplevel-selection texture() 2drect
@@ -71,6 +69,5 @@ spec@glsl-1.30@execution@tex-miplevel-selection textureprojgradoffset 2drectshad
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drect
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drect_projvec4
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drectshadow
spec@oes_texture_view@sampling-2d-array-as-cubemap
spec@!opengl 1.0@rasterpos
spec@!opengl es 3.0@gles-3.0-transform-feedback-uniform-buffer-object

View File

@@ -122,8 +122,8 @@ spec@arb_texture_rg@fbo-blending-formats,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_R8,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_RG8,Fail
spec@arb_texture_rg@fbo-blending-formats@GL_RG,Fail
spec@arb_texture_view@sampling-2d-array-as-cubemap-array,Crash
spec@arb_texture_view@sampling-2d-array-as-cubemap,Crash
spec@arb_texture_view@sampling-2d-array-as-cubemap-array,Fail
spec@arb_texture_view@sampling-2d-array-as-cubemap,Fail
spec@arb_transform_feedback_instanced@draw-auto instanced,Fail
spec@arb_uniform_buffer_object@rendering-dsa-offset,Fail
spec@arb_uniform_buffer_object@rendering-offset,Fail
@@ -452,7 +452,7 @@ spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_RGBA32I/Destinat
spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_RGBA32UI/Destination: GL_RGBA32UI,Fail
spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_RGBA8/Destination: GL_RGBA8,Fail
spec@nv_copy_image@nv_copy_image-formats --samples=4@Source: GL_RGBA8_SNORM/Destination: GL_RGBA8_SNORM,Fail
spec@oes_texture_view@sampling-2d-array-as-cubemap,Crash
spec@oes_texture_view@sampling-2d-array-as-cubemap,Fail
spec@!opengl 1.0@gl-1.0-edgeflag-const,Fail
spec@!opengl 1.0@gl-1.0-edgeflag,Fail
spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail

View File

@@ -37,8 +37,6 @@ spec@arb_texture_rectangle@tex-miplevel-selection gl2:texture() 2drectshadow
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drect
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drect_projvec4
spec@arb_texture_rectangle@tex-miplevel-selection gl2:textureproj 2drectshadow
spec@arb_texture_view@sampling-2d-array-as-cubemap-array
spec@arb_texture_view@sampling-2d-array-as-cubemap
spec@ext_transform_feedback@immediate-reuse-index-buffer
spec@ext_transform_feedback@immediate-reuse-uniform-buffer
spec@glsl-1.30@execution@tex-miplevel-selection texture() 2drect
@@ -61,6 +59,5 @@ spec@glsl-1.30@execution@tex-miplevel-selection textureprojgradoffset 2drectshad
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drect
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drect_projvec4
spec@glsl-1.30@execution@tex-miplevel-selection textureprojoffset 2drectshadow
spec@oes_texture_view@sampling-2d-array-as-cubemap
spec@!opengl 1.0@rasterpos
spec@!opengl es 3.0@gles-3.0-transform-feedback-uniform-buffer-object

View File

@@ -127,23 +127,6 @@ panfrost_compression_tag(const struct util_format_description *desc,
return 0;
}
/* Cubemaps have 6 faces as "layers" in between each actual layer. We
* need to fix this up. TODO: logic wrong in the asserted out cases ...
* can they happen, perhaps from cubemap arrays? */
static void
panfrost_adjust_cube_dimensions(unsigned *first_face, unsigned *last_face,
unsigned *first_layer, unsigned *last_layer)
{
*first_face = *first_layer % 6;
*last_face = *last_layer % 6;
*first_layer /= 6;
*last_layer /= 6;
assert((*first_layer == *last_layer) ||
(*first_face == 0 && *last_face == 5));
}
/* Following the texture descriptor is a number of descriptors. How many? */
static unsigned
@@ -208,17 +191,16 @@ panfrost_get_surface_strides(const struct pan_image_layout *layout, unsigned l,
static mali_ptr
panfrost_get_surface_pointer(const struct pan_image_layout *layout,
enum mali_texture_dimension dim, mali_ptr base,
unsigned l, unsigned w, unsigned f, unsigned s)
unsigned l, unsigned i, unsigned s)
{
unsigned face_mult = dim == MALI_TEXTURE_DIMENSION_CUBE ? 6 : 1;
unsigned offset;
if (layout->dim == MALI_TEXTURE_DIMENSION_3D) {
assert(!f && !s);
assert(!s);
offset =
layout->slices[l].offset + (w * panfrost_get_layer_stride(layout, l));
layout->slices[l].offset + i * panfrost_get_layer_stride(layout, l);
} else {
offset = panfrost_texture_offset(layout, l, (w * face_mult) + f, s);
offset = panfrost_texture_offset(layout, l, i, s);
}
return base + offset;
@@ -457,7 +439,7 @@ panfrost_emit_plane(const struct pan_image_layout *layout,
static void
panfrost_emit_surface(const struct pan_image_view *iview, unsigned level,
unsigned layer, unsigned face, unsigned sample,
unsigned index, unsigned sample,
enum pipe_format format, void **payload)
{
ASSERTED const struct util_format_description *desc =
@@ -497,7 +479,7 @@ panfrost_emit_surface(const struct pan_image_view *iview, unsigned level,
panfrost_compression_tag(desc, layouts[i]->dim, layouts[i]->modifier);
plane_ptrs[i] = panfrost_get_surface_pointer(
layouts[i], iview->dim, base | tag, level, layer, face, sample);
layouts[i], iview->dim, base | tag, level, index, sample);
panfrost_get_surface_strides(layouts[i], level, &row_strides[i],
&surface_strides[i]);
}
@@ -552,37 +534,37 @@ panfrost_emit_texture_payload(const struct pan_image_view *iview,
* into a single plane descriptor.
*/
unsigned first_layer = iview->first_layer, last_layer = iview->last_layer;
unsigned first_face = 0, last_face = 0;
if (iview->dim == MALI_TEXTURE_DIMENSION_CUBE) {
panfrost_adjust_cube_dimensions(&first_face, &last_face, &first_layer,
&last_layer);
}
#if PAN_ARCH >= 7
/* V7 and later treats faces as extra layers */
for (int layer = first_layer; layer <= last_layer; ++layer) {
for (int face = first_face; face <= last_face; ++face) {
for (int sample = 0; sample < nr_samples; ++sample) {
for (int level = iview->first_level; level <= iview->last_level; ++level) {
panfrost_emit_surface(iview, level, layer, face, sample,
format, &payload);
}
for (int layer = iview->first_layer; layer <= iview->last_layer; ++layer) {
for (int sample = 0; sample < nr_samples; ++sample) {
for (int level = iview->first_level; level <= iview->last_level; ++level) {
panfrost_emit_surface(iview, level, layer, sample,
format, &payload);
}
}
}
#else
unsigned first_layer = iview->first_layer, last_layer = iview->last_layer;
unsigned face_count = 1;
if (iview->dim == MALI_TEXTURE_DIMENSION_CUBE) {
first_layer /= 6;
last_layer /= 6;
face_count = 6;
}
/* V6 and earlier has a different memory-layout */
for (int layer = first_layer; layer <= last_layer; ++layer) {
for (int level = iview->first_level; level <= iview->last_level; ++level) {
/* order of face and sample doesn't matter; we can only have multiple
* of one or the other (no support for multisampled cubemaps)
*/
for (int face = first_face; face <= last_face; ++face) {
for (int sample = 0; sample < nr_samples; ++sample)
panfrost_emit_surface(iview, level, layer, face, sample,
format, &payload);
for (int face = 0; face < face_count; ++face) {
for (int sample = 0; sample < nr_samples; ++sample) {
panfrost_emit_surface(iview, level, (face_count * layer) + face,
sample, format, &payload);
}
}
}
}
@@ -662,9 +644,11 @@ GENX(panfrost_new_texture)(const struct pan_image_view *iview, void *out,
unsigned array_size = iview->last_layer - iview->first_layer + 1;
/* If this is a cubemap, we expect the number of layers to be a multiple
* of 6.
*/
if (iview->dim == MALI_TEXTURE_DIMENSION_CUBE) {
assert(iview->first_layer % 6 == 0);
assert(iview->last_layer % 6 == 5);
assert(array_size % 6 == 0);
array_size /= 6;
}