asahi: Pass layer stride in pixels, not elements

We do all the math in pixels and only multiply by the sample count at the end,
meaning the layer stride needs to be in terms of pixels (not samples) for
correct addressing of multisample array images in our texture lowering. This is
particularly used for lowering the multisample array stores we get from eMRT
with multisampled layered framebuffers.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24847>
This commit is contained in:
Alyssa Rosenzweig 2023-08-16 15:35:02 -04:00 committed by Marge Bot
parent 486fb75981
commit a51c3f638b
3 changed files with 9 additions and 9 deletions

View file

@ -575,7 +575,7 @@ nir_bitfield_mask(nir_builder *b, nir_def *x)
static nir_def *
calculate_twiddled_coordinates(nir_builder *b, nir_def *coord,
nir_def *tile_w_px_log2, nir_def *tile_h_px_log2,
nir_def *width_tl, nir_def *layer_stride_el)
nir_def *width_tl, nir_def *layer_stride_px)
{
/* SIMD-within-a-register */
nir_def *coord_px = nir_pack_32_2x16(b, nir_u2u16(b, coord));
@ -623,9 +623,9 @@ calculate_twiddled_coordinates(nir_builder *b, nir_def *coord,
nir_def *offs_px = nir_interleave_agx(b, offs_x_px, offs_y_px);
nir_def *total_px = nir_iadd(b, tile_offset_px, nir_u2u32(b, offs_px));
if (layer_stride_el) {
if (layer_stride_px) {
nir_def *layer = nir_channel(b, coord, 2);
nir_def *layer_offset_px = nir_imul(b, layer, layer_stride_el);
nir_def *layer_offset_px = nir_imul(b, layer, layer_stride_px);
total_px = nir_iadd(b, total_px, layer_offset_px);
}
@ -657,12 +657,12 @@ image_texel_address(nir_builder *b, nir_intrinsic_instr *intr,
*/
nir_def *meta_ptr = nir_iadd_imm(b, desc_address, 16);
nir_def *meta = nir_load_global_constant(b, meta_ptr, 8, 1, 64);
nir_def *layer_stride_el = NULL;
nir_def *layer_stride_px = NULL;
if (layered) {
nir_def *desc = nir_load_global_constant(b, meta, 8, 3, 32);
meta = nir_pack_64_2x32(b, nir_trim_vector(b, desc, 2));
layer_stride_el = nir_channel(b, desc, 2);
layer_stride_px = nir_channel(b, desc, 2);
}
nir_def *meta_hi = nir_unpack_64_2x32_split_y(b, meta);
@ -690,7 +690,7 @@ image_texel_address(nir_builder *b, nir_intrinsic_instr *intr,
total_px = nir_channel(b, coord, 0);
} else {
total_px = calculate_twiddled_coordinates(
b, coord, tile_w_px_log2, tile_h_px_log2, width_tl, layer_stride_el);
b, coord, tile_w_px_log2, tile_h_px_log2, width_tl, layer_stride_px);
}
nir_def *total_sa;

View file

@ -216,7 +216,7 @@
<field name="Sample count" size="2" start="54" type="uint" modifier="log2" default="1"/>
<!-- Extended fields begin here -->
<field name="Layer stride (elements)" size="32" start="64" type="uint"/>
<field name="Layer stride (pixels)" size="32" start="64" type="uint"/>
</struct>
<struct name="PBE Buffer (software)" size="8">

View file

@ -1113,8 +1113,8 @@ agx_pack_image_atomic_data(void *packed, struct pipe_image_view *view)
unsigned width_el = u_minify(tex->base.width0, level);
cfg.tiles_per_row = DIV_ROUND_UP(width_el, tile_size.width_el);
cfg.layer_stride_elements =
DIV_ROUND_UP(tex->layout.layer_stride_B, blocksize_B);
cfg.layer_stride_pixels = DIV_ROUND_UP(
tex->layout.layer_stride_B, blocksize_B * cfg.sample_count);
}
}
}