From 0a19d0f8c297705e62f23e2127556fb25f880d1a Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Fri, 17 Nov 2023 19:37:50 +0900 Subject: [PATCH] drm/asahi: render, buffer: Fix layered rendering on G13X (again) The meta1 buffer needs to be multiplied by the layer count. This does not seem to be needed on G14X (where even the stride is not specified anywhere and no other registers are affected by the layer count). Signed-off-by: Asahi Lina --- drivers/gpu/drm/asahi/buffer.rs | 2 ++ drivers/gpu/drm/asahi/queue/render.rs | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/asahi/buffer.rs b/drivers/gpu/drm/asahi/buffer.rs index f9e7db45516e93..cbac6c622805e2 100644 --- a/drivers/gpu/drm/asahi/buffer.rs +++ b/drivers/gpu/drm/asahi/buffer.rs @@ -89,6 +89,8 @@ pub(crate) struct TileInfo { pub(crate) tilemap_size: usize, /// Size of the Tail Pointer Cache, in bytes (for all layers * clusters). pub(crate) tpc_size: usize, + /// Number of blocks in the clustering meta buffer (for clustering) per layer. + pub(crate) meta1_layer_stride: u32, /// Number of blocks in the clustering meta buffer (for clustering). pub(crate) meta1_blocks: u32, /// Layering metadata size. diff --git a/drivers/gpu/drm/asahi/queue/render.rs b/drivers/gpu/drm/asahi/queue/render.rs index 02cc874c10c5ab..cb61aa5a95cf84 100644 --- a/drivers/gpu/drm/asahi/queue/render.rs +++ b/drivers/gpu/drm/asahi/queue/render.rs @@ -145,8 +145,7 @@ impl super::Queue::ver { // No idea where this comes from, but it fits what macOS does... // GUESS: Number of 32K heap blocks to fit a 5-byte region header/pointer per tile? // That would make a ton of sense... - // TODO: Layers? Why the sample count factor here? - let meta1_blocks = if num_clusters > 1 { + let meta1_layer_stride = if num_clusters > 1 { div_ceil( align(tiles_x, 2) * align(tiles_y, 4) * utiles_per_tile, 0x1980, @@ -177,7 +176,11 @@ impl super::Queue::ver { //utiles_per_mtile: tiles_per_mtile * utiles_per_tile, tilemap_size, tpc_size, - meta1_blocks, + meta1_layer_stride, + #[ver(G < G14X)] + meta1_blocks: meta1_layer_stride * cmdbuf.layers, + #[ver(G >= G14X)] + meta1_blocks: meta1_layer_stride, layermeta_size: if layers > 1 { 0x100 } else { 0 }, min_tvb_blocks: min_tvb_blocks as usize, params: fw::vertex::raw::TilingParameters { @@ -1305,7 +1308,7 @@ impl super::Queue::ver { tvb_cluster_meta1: inner .scene .meta_1_pointer() - .map(|x| x.or((tile_info.meta1_blocks as u64) << 50)), + .map(|x| x.or((tile_info.meta1_layer_stride as u64) << 50)), utile_config, unk_4c: 0, ppp_multisamplectl: U64(cmdbuf.ppp_multisamplectl), // fixed