From: Jonathan Marek Date: Tue, 12 May 2020 16:34:37 +0000 (-0400) Subject: freedreno/a6xx: FETCHSIZE is PITCHALIGN X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a9ab3b6e96ee37a89a99dc6a825022cdd4b7c35;p=mesa.git freedreno/a6xx: FETCHSIZE is PITCHALIGN "FETCHSIZE" is actually a "minimum pitch" or "pitchalign" value that's relevant for mipmaps. The 0 value means 64-bytes. Understanding this allows some simplifications and will make it possible to use less alignment on linear formats. Signed-off-by: Jonathan Marek Part-of: --- diff --git a/src/freedreno/fdl/fd6_layout.c b/src/freedreno/fdl/fd6_layout.c index 20aec1fdb9a..146e86900aa 100644 --- a/src/freedreno/fdl/fd6_layout.c +++ b/src/freedreno/fdl/fd6_layout.c @@ -165,6 +165,9 @@ fdl6_layout(struct fdl_layout *layout, ta->ubwc_blockheight), ubwc_tile_height_alignment); + layout->pitchalign = + util_logbase2_ceil(fdl6_pitchalign(layout, mip_levels - 1) * layout->cpp >> 6); + for (uint32_t level = 0; level < mip_levels; level++) { uint32_t depth = u_minify(depth0, level); struct fdl_slice *slice = &layout->slices[level]; diff --git a/src/freedreno/fdl/freedreno_layout.h b/src/freedreno/fdl/freedreno_layout.h index ec4090066ca..3b2cb67c493 100644 --- a/src/freedreno/fdl/freedreno_layout.h +++ b/src/freedreno/fdl/freedreno_layout.h @@ -121,6 +121,7 @@ struct fdl_layout { uint32_t size; /* Size of the whole image, in bytes. */ uint32_t base_align; /* Alignment of the base address, in bytes. */ + uint8_t pitchalign; /* log2(pitchalign / 64) */ }; static inline uint32_t diff --git a/src/freedreno/registers/a6xx.xml b/src/freedreno/registers/a6xx.xml index 515b1043aae..382dc7e1fb1 100644 --- a/src/freedreno/registers/a6xx.xml +++ b/src/freedreno/registers/a6xx.xml @@ -158,14 +158,6 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd"> - - - - - - - - @@ -3489,7 +3481,8 @@ to upconvert to 32b float internally? behavior of texture in dEQP-GLES31.functional.texture.texture_buffer.render.as_fragment_texture.buffer_size_131071 --> - + + Pitch in bytes (so actually stride) diff --git a/src/freedreno/vulkan/tu_clear_blit.c b/src/freedreno/vulkan/tu_clear_blit.c index c9cf1a0a589..0ebe3ba2c90 100644 --- a/src/freedreno/vulkan/tu_clear_blit.c +++ b/src/freedreno/vulkan/tu_clear_blit.c @@ -709,7 +709,6 @@ r3d_src_buffer(struct tu_cmd_buffer *cmd, A6XX_TEX_CONST_0_SWIZ_W(vk_format == VK_FORMAT_R8_UNORM ? A6XX_TEX_X : A6XX_TEX_W); desc[1] = A6XX_TEX_CONST_1_WIDTH(width) | A6XX_TEX_CONST_1_HEIGHT(height); desc[2] = - A6XX_TEX_CONST_2_FETCHSIZE(tu6_fetchsize(vk_format)) | A6XX_TEX_CONST_2_PITCH(pitch) | A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D); desc[3] = 0; diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index b2712af5b84..13e782a80a2 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -1318,8 +1318,7 @@ tu_emit_input_attachments(struct tu_cmd_buffer *cmd, /* patched for gmem */ dst[0] &= ~(A6XX_TEX_CONST_0_SWAP__MASK | A6XX_TEX_CONST_0_TILE_MODE__MASK); dst[0] |= A6XX_TEX_CONST_0_TILE_MODE(TILE6_2); - dst[2] &= ~(A6XX_TEX_CONST_2_TYPE__MASK | A6XX_TEX_CONST_2_PITCH__MASK); - dst[2] |= + dst[2] = A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D) | A6XX_TEX_CONST_2_PITCH(cmd->state.tiling_config.tile0.extent.width * att->cpp); dst[3] = 0; diff --git a/src/freedreno/vulkan/tu_image.c b/src/freedreno/vulkan/tu_image.c index 420842f4544..4d3980e66ef 100644 --- a/src/freedreno/vulkan/tu_image.c +++ b/src/freedreno/vulkan/tu_image.c @@ -187,20 +187,6 @@ invalid_layout: return vk_error(device->instance, VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT); } -enum a6xx_tex_fetchsize -tu6_fetchsize(VkFormat format) -{ - switch (vk_format_get_blocksize(format)) { - case 1: return TFETCH6_1_BYTE; - case 2: return TFETCH6_2_BYTE; - case 4: return TFETCH6_4_BYTE; - case 8: return TFETCH6_8_BYTE; - case 16: return TFETCH6_16_BYTE; - default: - unreachable("bad block size"); - } -} - static void compose_swizzle(unsigned char *swiz, const VkComponentMapping *mapping) { @@ -398,7 +384,7 @@ tu_image_view_init(struct tu_image_view *iview, A6XX_TEX_CONST_0_MIPLVLS(tu_get_levelCount(image, range) - 1); iview->descriptor[1] = A6XX_TEX_CONST_1_WIDTH(width) | A6XX_TEX_CONST_1_HEIGHT(height); iview->descriptor[2] = - A6XX_TEX_CONST_2_FETCHSIZE(tu6_fetchsize(format)) | + A6XX_TEX_CONST_2_PITCHALIGN(layout->pitchalign) | A6XX_TEX_CONST_2_PITCH(pitch) | A6XX_TEX_CONST_2_TYPE(tu6_tex_type(pCreateInfo->viewType, false)); iview->descriptor[3] = A6XX_TEX_CONST_3_ARRAY_PITCH(layer_size); diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 5e50b983302..f7fe939ce14 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -1299,8 +1299,6 @@ tu_get_levelCount(const struct tu_image *image, enum a3xx_msaa_samples tu_msaa_samples(uint32_t samples); -enum a6xx_tex_fetchsize -tu6_fetchsize(VkFormat format); struct tu_image_view { diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c index 0853a9529b0..70c464b4afe 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_emit.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_emit.c @@ -258,8 +258,7 @@ fd6_emit_fb_tex(struct fd_ringbuffer *state, struct fd_context *ctx) OUT_RING(state, texconst0); OUT_RING(state, A6XX_TEX_CONST_1_WIDTH(pfb->width) | A6XX_TEX_CONST_1_HEIGHT(pfb->height)); - OUT_RINGP(state, A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D) | - A6XX_TEX_CONST_2_FETCHSIZE(TFETCH6_2_BYTE), + OUT_RINGP(state, A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D), &ctx->batch->fb_read_patches); OUT_RING(state, A6XX_TEX_CONST_3_ARRAY_PITCH(rsc->layout.layer_size)); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_format.c b/src/gallium/drivers/freedreno/a6xx/fd6_format.c index 0cd7b397a34..bbc71cf0a08 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_format.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_format.c @@ -369,28 +369,6 @@ fd6_pipe2swap(enum pipe_format format) return formats[format].swap; } -// XXX possibly same as a4xx.. -enum a6xx_tex_fetchsize -fd6_pipe2fetchsize(enum pipe_format format) -{ - if (format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) - format = PIPE_FORMAT_Z32_FLOAT; - - switch (util_format_get_blocksizebits(format)) { - case 8: return TFETCH6_1_BYTE; - case 16: return TFETCH6_2_BYTE; - case 32: return TFETCH6_4_BYTE; - case 64: return TFETCH6_8_BYTE; - case 96: return TFETCH6_1_BYTE; /* Does this matter? */ - case 128: return TFETCH6_16_BYTE; - default: - debug_printf("Unknown block size for format %s: %d\n", - util_format_name(format), - util_format_get_blocksizebits(format)); - return TFETCH6_1_BYTE; - } -} - enum a6xx_depth_format fd6_pipe2depth(enum pipe_format format) { diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_format.h b/src/gallium/drivers/freedreno/a6xx/fd6_format.h index ef8818f233f..a7fe81084e7 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_format.h +++ b/src/gallium/drivers/freedreno/a6xx/fd6_format.h @@ -37,7 +37,6 @@ enum a6xx_format fd6_pipe2vtx(enum pipe_format format); enum a6xx_format fd6_pipe2tex(enum pipe_format format); enum a6xx_format fd6_pipe2color(enum pipe_format format); enum a3xx_color_swap fd6_pipe2swap(enum pipe_format format); -enum a6xx_tex_fetchsize fd6_pipe2fetchsize(enum pipe_format format); enum a6xx_depth_format fd6_pipe2depth(enum pipe_format format); enum a6xx_tex_swiz fd6_pipe2swiz(unsigned swiz); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_image.c b/src/gallium/drivers/freedreno/a6xx/fd6_image.c index 6098799e22d..b7999aacf9a 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_image.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_image.c @@ -39,7 +39,6 @@ struct fd6_image { struct pipe_resource *prsc; enum pipe_format pfmt; enum a6xx_format fmt; - enum a6xx_tex_fetchsize fetchsize; enum a6xx_tex_type type; bool srgb; uint32_t cpp; @@ -69,7 +68,6 @@ static void translate_image(struct fd6_image *img, const struct pipe_image_view img->prsc = prsc; img->pfmt = format; img->fmt = fd6_pipe2tex(format); - img->fetchsize = fd6_pipe2fetchsize(format); img->type = fd6_tex_type(prsc->target); img->srgb = util_format_is_srgb(format); img->cpp = rsc->layout.cpp; @@ -148,7 +146,6 @@ static void translate_buf(struct fd6_image *img, const struct pipe_shader_buffer img->prsc = prsc; img->pfmt = format; img->fmt = fd6_pipe2tex(format); - img->fetchsize = fd6_pipe2fetchsize(format); img->type = fd6_tex_type(prsc->target); img->srgb = util_format_is_srgb(format); img->cpp = rsc->layout.cpp; @@ -179,7 +176,7 @@ static void emit_image_tex(struct fd_ringbuffer *ring, struct fd6_image *img) PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W)); OUT_RING(ring, A6XX_TEX_CONST_1_WIDTH(img->width) | A6XX_TEX_CONST_1_HEIGHT(img->height)); - OUT_RING(ring, A6XX_TEX_CONST_2_FETCHSIZE(img->fetchsize) | + OUT_RING(ring, COND(img->buffer, A6XX_TEX_CONST_2_UNK4 | A6XX_TEX_CONST_2_UNK31) | A6XX_TEX_CONST_2_TYPE(img->type) | A6XX_TEX_CONST_2_PITCH(img->pitch)); diff --git a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c index 4338f1f1f6c..19402290565 100644 --- a/src/gallium/drivers/freedreno/a6xx/fd6_texture.c +++ b/src/gallium/drivers/freedreno/a6xx/fd6_texture.c @@ -265,7 +265,7 @@ fd6_sampler_view_create(struct pipe_context *pctx, struct pipe_resource *prsc, A6XX_TEX_CONST_1_WIDTH(u_minify(prsc->width0, lvl)) | A6XX_TEX_CONST_1_HEIGHT(u_minify(prsc->height0, lvl)); so->texconst2 = - A6XX_TEX_CONST_2_FETCHSIZE(fd6_pipe2fetchsize(format)) | + A6XX_TEX_CONST_2_PITCHALIGN(rsc->layout.pitchalign) | A6XX_TEX_CONST_2_PITCH(slice->pitch); so->offset = fd_resource_offset(rsc, lvl, cso->u.tex.first_layer); so->ubwc_offset = fd_resource_ubwc_offset(rsc, lvl, cso->u.tex.first_layer);