From 619b1bc23b05f5be64bc3bc9fb3fe0d281c2c26c Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 1 Jun 2021 19:09:00 -0400 Subject: [PATCH] panfrost: Be explicit in image modifier handling Signed-off-by: Alyssa Rosenzweig Part-of: --- src/gallium/drivers/panfrost/pan_cmdstream.c | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 67e2968b80c..ef81a42fecd 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1494,6 +1494,19 @@ emit_image_attribs(struct panfrost_context *ctx, enum pipe_shader_type shader, } } +static enum mali_attribute_type +pan_modifier_to_attr_type(uint64_t modifier) +{ + switch (modifier) { + case DRM_FORMAT_MOD_LINEAR: + return MALI_ATTRIBUTE_TYPE_3D_LINEAR; + case DRM_FORMAT_MOD_ARM_16X16_BLOCK_U_INTERLEAVED: + return MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED; + default: + unreachable("Invalid modifier for attribute record"); + } +} + static void emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader, struct mali_attribute_buffer_packed *bufs, @@ -1520,7 +1533,6 @@ emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader, assert(image->resource->nr_samples <= 1 && "MSAA'd images not supported"); bool is_3d = rsrc->base.target == PIPE_TEXTURE_3D; - bool is_linear = rsrc->image.layout.modifier == DRM_FORMAT_MOD_LINEAR; bool is_buffer = rsrc->base.target == PIPE_BUFFER; unsigned offset = is_buffer ? image->u.buf.offset : @@ -1529,9 +1541,6 @@ emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader, is_3d ? 0 : image->u.tex.first_layer, is_3d ? image->u.tex.first_layer : 0); - /* AFBC should've been converted to tiled on panfrost_set_shader_image */ - assert(!drm_is_afbc(rsrc->image.layout.modifier)); - /* Add a dependency of the batch on the shader image buffer */ uint32_t flags = PAN_BO_ACCESS_SHARED | PAN_BO_ACCESS_VERTEX_TILER; if (image->shader_access & PIPE_IMAGE_ACCESS_READ) @@ -1544,10 +1553,7 @@ emit_image_bufs(struct panfrost_batch *batch, enum pipe_shader_type shader, panfrost_batch_add_bo(batch, rsrc->image.data.bo, flags); pan_pack(bufs + (i * 2), ATTRIBUTE_BUFFER, cfg) { - cfg.type = is_linear ? - MALI_ATTRIBUTE_TYPE_3D_LINEAR : - MALI_ATTRIBUTE_TYPE_3D_INTERLEAVED; - + cfg.type = pan_modifier_to_attr_type(rsrc->image.layout.modifier); cfg.pointer = rsrc->image.data.bo->ptr.gpu + offset; cfg.stride = util_format_get_blocksize(image->format); cfg.size = rsrc->image.data.bo->size;