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 <jonathan@marek.ca>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5013>
This commit is contained in:
Jonathan Marek 2020-05-12 12:34:37 -04:00 committed by Marge Bot
parent 6269405a2b
commit 3a9ab3b6e9
12 changed files with 11 additions and 59 deletions

View File

@ -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];

View File

@ -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

View File

@ -158,14 +158,6 @@ xsi:schemaLocation="http://nouveau.freedesktop.org/ rules-ng.xsd">
</enum>
<enum name="a6xx_tex_fetchsize">
<value name="TFETCH6_1_BYTE" value="0"/>
<value name="TFETCH6_2_BYTE" value="1"/>
<value name="TFETCH6_4_BYTE" value="2"/>
<value name="TFETCH6_8_BYTE" value="3"/>
<value name="TFETCH6_16_BYTE" value="4"/>
</enum>
<!-- probably same as a5xx -->
<enum name="a6xx_depth_format">
<value name="DEPTH6_NONE" value="0"/>
@ -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
-->
<bitfield name="UNK4" pos="4" type="boolean"/>
<bitfield name="FETCHSIZE" low="0" high="3" type="a6xx_tex_fetchsize"/>
<!-- minimum pitch (for mipmap levels): log2(pitchalign / 64) -->
<bitfield name="PITCHALIGN" low="0" high="3" type="uint"/>
<doc>Pitch in bytes (so actually stride)</doc>
<bitfield name="PITCH" low="7" high="28" type="uint"/>
<bitfield name="TYPE" low="29" high="30" type="a6xx_tex_type"/>

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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
{

View File

@ -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));

View File

@ -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)
{

View File

@ -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);

View File

@ -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));

View File

@ -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);