Skip to content

Commit 8341b1f

Browse files
PixelyIonFireBurn
authored andcommitted
tu: Use Z24_UNORM_S8_UINT_AS_R8G8B8A8 for A7XX GMEM D24S8 blits/clear
A7XX has corruption when 2D blits are performed on D24S8 images from GMEM when the source format is FMT6_8_8_8_8_UNORM, this is fixed by using FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8. Fixes VK-CTS: dEQP-VK.pipeline.monolithic.multisample.misc.* Signed-off-by: Mark Collins <[email protected]>
1 parent af12ee1 commit 8341b1f

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

src/freedreno/vulkan/tu_clear_blit.cc

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ format_to_ifmt(enum pipe_format format)
6767
}
6868
}
6969

70+
template <chip CHIP>
7071
static struct tu_native_format
71-
blit_format_texture(enum pipe_format format, enum a6xx_tile_mode tile_mode)
72+
blit_format_texture(enum pipe_format format, enum a6xx_tile_mode tile_mode, bool gmem)
7273
{
7374
struct tu_native_format fmt = tu6_format_texture(format, tile_mode);
7475

@@ -79,8 +80,12 @@ blit_format_texture(enum pipe_format format, enum a6xx_tile_mode tile_mode)
7980
* FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8 or FMT6_8_8_8_8_UNORM for blit
8081
* src. Since this is called when there is no image and thus no ubwc,
8182
* we can always use FMT6_8_8_8_8_UNORM.
83+
*
84+
* Note (A7XX): Since it's erroneous to use FMT6_8_8_8_8_UNORM for a GMEM
85+
* image (see blit_base_format), we use FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8
86+
* instead.
8287
*/
83-
fmt.fmt = FMT6_8_8_8_8_UNORM;
88+
fmt.fmt = CHIP >= A7XX && gmem ? FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8 : FMT6_8_8_8_8_UNORM;
8489
break;
8590
default:
8691
break;
@@ -107,9 +112,18 @@ blit_format_color(enum pipe_format format, enum a6xx_tile_mode tile_mode)
107112
return fmt;
108113
}
109114

115+
template <chip CHIP>
110116
static enum a6xx_format
111-
blit_base_format(enum pipe_format format, bool ubwc)
117+
blit_base_format(enum pipe_format format, bool ubwc, bool gmem)
112118
{
119+
if (CHIP >= A7XX && gmem)
120+
/* A7XX requires D24S8 in GMEM to always be treated as
121+
* FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8 regardless of if the image
122+
* is UBWC-compatible. Using FMT6_8_8_8_8_UNORM instead will result
123+
* in misrendering around the edges of the destination image.
124+
*/
125+
ubwc = true;
126+
113127
if (ubwc) {
114128
switch (format) {
115129
case PIPE_FORMAT_Z24X8_UNORM:
@@ -316,7 +330,7 @@ r2d_src_buffer(struct tu_cmd_buffer *cmd,
316330
uint32_t width, uint32_t height,
317331
enum pipe_format dst_format)
318332
{
319-
struct tu_native_format fmt = blit_format_texture(format, TILE6_LINEAR);
333+
struct tu_native_format fmt = blit_format_texture<CHIP>(format, TILE6_LINEAR, false);
320334
enum a6xx_format color_format = fmt.fmt;
321335
fixup_src_format(&format, dst_format, &color_format);
322336

@@ -408,7 +422,7 @@ r2d_setup_common(struct tu_cmd_buffer *cmd,
408422
tu_cs_emit_call(cs, cmd->device->dbg_renderpass_stomp_cs);
409423
}
410424

411-
enum a6xx_format fmt = blit_base_format(dst_format, ubwc);
425+
enum a6xx_format fmt = blit_base_format<CHIP>(dst_format, ubwc, false);
412426
fixup_dst_format(src_format, &dst_format, &fmt);
413427
enum a6xx_2d_ifmt ifmt = format_to_ifmt(dst_format);
414428

@@ -1100,6 +1114,7 @@ r3d_src(struct tu_cmd_buffer *cmd,
11001114
filter);
11011115
}
11021116

1117+
template <chip CHIP>
11031118
static void
11041119
r3d_src_buffer(struct tu_cmd_buffer *cmd,
11051120
struct tu_cs *cs,
@@ -1110,7 +1125,7 @@ r3d_src_buffer(struct tu_cmd_buffer *cmd,
11101125
{
11111126
uint32_t desc[A6XX_TEX_CONST_DWORDS];
11121127

1113-
struct tu_native_format fmt = blit_format_texture(format, TILE6_LINEAR);
1128+
struct tu_native_format fmt = blit_format_texture<CHIP>(format, TILE6_LINEAR, false);
11141129
enum a6xx_format color_format = fmt.fmt;
11151130
fixup_src_format(&format, dst_format, &color_format);
11161131

@@ -1242,6 +1257,7 @@ r3d_src_gmem_load(struct tu_cmd_buffer *cmd,
12421257
VK_FILTER_NEAREST);
12431258
}
12441259

1260+
template <chip CHIP>
12451261
static void
12461262
r3d_src_gmem(struct tu_cmd_buffer *cmd,
12471263
struct tu_cs *cs,
@@ -1254,7 +1270,7 @@ r3d_src_gmem(struct tu_cmd_buffer *cmd,
12541270
uint32_t desc[A6XX_TEX_CONST_DWORDS];
12551271
memcpy(desc, iview->view.descriptor, sizeof(desc));
12561272

1257-
enum a6xx_format fmt = blit_format_texture(format, TILE6_LINEAR).fmt;
1273+
enum a6xx_format fmt = blit_format_texture<CHIP>(format, TILE6_LINEAR, true).fmt;
12581274
fixup_src_format(&format, dst_format, &fmt);
12591275

12601276
/* patch the format so that depth/stencil get the right format and swizzle */
@@ -1431,7 +1447,7 @@ r3d_setup(struct tu_cmd_buffer *cmd,
14311447
tu_cs_emit_call(cs, cmd->device->dbg_renderpass_stomp_cs);
14321448
}
14331449

1434-
enum a6xx_format fmt = blit_base_format(dst_format, ubwc);
1450+
enum a6xx_format fmt = blit_base_format<CHIP>(dst_format, ubwc, false);
14351451
fixup_dst_format(src_format, &dst_format, &fmt);
14361452

14371453
if (!cmd->state.pass) {
@@ -1609,7 +1625,7 @@ static const struct blit_ops r3d_ops = {
16091625
.coords = r3d_coords,
16101626
.clear_value = r3d_clear_value,
16111627
.src = r3d_src,
1612-
.src_buffer = r3d_src_buffer,
1628+
.src_buffer = r3d_src_buffer<CHIP>,
16131629
.dst = r3d_dst,
16141630
.dst_depth = r3d_dst_depth,
16151631
.dst_stencil = r3d_dst_stencil,
@@ -2185,11 +2201,12 @@ TU_GENX(tu_CmdCopyImageToBuffer2);
21852201
* format, i.e. only when the other image is linear.
21862202
*/
21872203

2204+
template <chip CHIP>
21882205
static bool
21892206
is_swapped_format(enum pipe_format format)
21902207
{
2191-
struct tu_native_format linear = blit_format_texture(format, TILE6_LINEAR);
2192-
struct tu_native_format tiled = blit_format_texture(format, TILE6_3);
2208+
struct tu_native_format linear = blit_format_texture<CHIP>(format, TILE6_LINEAR, false);
2209+
struct tu_native_format tiled = blit_format_texture<CHIP>(format, TILE6_3, false);
21932210
return linear.fmt != tiled.fmt || linear.swap != tiled.swap;
21942211
}
21952212

@@ -2276,8 +2293,8 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmd,
22762293
* due to the different tile layout.
22772294
*/
22782295
use_staging_blit = true;
2279-
} else if (is_swapped_format(src_format) ||
2280-
is_swapped_format(dst_format)) {
2296+
} else if (is_swapped_format<CHIP>(src_format) ||
2297+
is_swapped_format<CHIP>(dst_format)) {
22812298
/* If either format has a non-identity swap, then we can't copy
22822299
* to/from it.
22832300
*/
@@ -3063,7 +3080,7 @@ clear_gmem_attachment(struct tu_cmd_buffer *cmd,
30633080
{
30643081
tu_cs_emit_pkt4(cs, REG_A6XX_RB_BLIT_DST_INFO, 1);
30653082
tu_cs_emit(cs, A6XX_RB_BLIT_DST_INFO_COLOR_FORMAT(
3066-
blit_base_format(format, false)));
3083+
blit_base_format<CHIP>(format, false, true)));
30673084

30683085
tu_cs_emit_regs(cs, A6XX_RB_BLIT_INFO(.gmem = 1, .clear_mask = clear_mask));
30693086

@@ -3667,7 +3684,7 @@ store_cp_blit(struct tu_cmd_buffer *cmd,
36673684
r2d_dst<CHIP>(cs, &iview->view, layer, src_format);
36683685
}
36693686

3670-
enum a6xx_format fmt = blit_format_texture(src_format, TILE6_2).fmt;
3687+
enum a6xx_format fmt = blit_format_texture<CHIP>(src_format, TILE6_2, true).fmt;
36713688
fixup_src_format(&src_format, dst_format, &fmt);
36723689

36733690
tu_cs_emit_regs(cs,
@@ -3746,7 +3763,7 @@ store_3d_blit(struct tu_cmd_buffer *cmd,
37463763
r3d_dst(cs, &iview->view, layer, src_format);
37473764
}
37483765

3749-
r3d_src_gmem(cmd, cs, iview, src_format, dst_format, gmem_offset, cpp);
3766+
r3d_src_gmem<CHIP>(cmd, cs, iview, src_format, dst_format, gmem_offset, cpp);
37503767

37513768
/* sync GMEM writes with CACHE. */
37523769
tu_emit_event_write<CHIP>(cmd, cs, FD_CACHE_INVALIDATE);
@@ -3977,7 +3994,6 @@ tu_store_gmem_attachment(struct tu_cmd_buffer *cmd,
39773994
}
39783995
}
39793996
} else {
3980-
/* A7XX TODO: Fix D24S8 MSAA resolves using the 2D blits */
39813997
if (!cmd->state.pass->has_fdm) {
39823998
r2d_coords(cs, render_area->offset, render_area->offset,
39833999
render_area->extent);

0 commit comments

Comments
 (0)