Mesa (staging/19.3): radv: Only use the gfx mipmap level offset/pitch for linear textures.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jan 6 18:07:15 UTC 2020


Module: Mesa
Branch: staging/19.3
Commit: 4d7704801b2406c1e736b8d26b8306d021c49b49
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d7704801b2406c1e736b8d26b8306d021c49b49

Author: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Date:   Fri Jan  3 11:25:31 2020 +0100

radv: Only use the gfx mipmap level offset/pitch for linear textures.

The tiled-case is non-sensical for non-base mips, but Vulkan requires
that this function handles it but at the same time does not require
returning anything useful. So we can basically return anything.

Correct tiled pitch and offset are still required for our own WSI and
in the future getting the layouts of images with DRM format modifiers.
Both don't have to deal with images with more than 1 level though.

Fixes: 824bd0830e8 "radv: return the correct pitch for linear mipmaps on GFX10"
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2301
Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2304
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
(cherry picked from commit 17741a0a05722245314e8ce9a3d5191feb63d9bd)

---

 src/amd/vulkan/radv_image.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index 7baa51b9c3b..134f9f9d627 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -1874,7 +1874,9 @@ void radv_GetImageSubresourceLayout(
 	struct radeon_surf *surface = &plane->surface;
 
 	if (device->physical_device->rad_info.chip_class >= GFX9) {
-		pLayout->offset = plane->offset + surface->u.gfx9.offset[level] + surface->u.gfx9.surf_slice_size * layer;
+		uint64_t level_offset = surface->is_linear ? surface->u.gfx9.offset[level] : 0;
+		
+		pLayout->offset = plane->offset + level_offset + surface->u.gfx9.surf_slice_size * layer;
 		if (image->vk_format == VK_FORMAT_R32G32B32_UINT ||
 		    image->vk_format == VK_FORMAT_R32G32B32_SINT ||
 		    image->vk_format == VK_FORMAT_R32G32B32_SFLOAT) {
@@ -1884,8 +1886,10 @@ void radv_GetImageSubresourceLayout(
 			 */
 			pLayout->rowPitch = surface->u.gfx9.surf_pitch * surface->bpe / 3;
 		} else {
+			uint32_t pitch = surface->is_linear ? surface->u.gfx9.pitch[level] : surface->u.gfx9.surf_pitch;
+
 			assert(util_is_power_of_two_nonzero(surface->bpe));
-			pLayout->rowPitch = surface->u.gfx9.pitch[level] * surface->bpe;
+			pLayout->rowPitch = pitch * surface->bpe;
 		}
 
 		pLayout->arrayPitch = surface->u.gfx9.surf_slice_size;




More information about the mesa-commit mailing list