From 55761ca4a5de075b2761a2dc046890d49f21fa2f Mon Sep 17 00:00:00 2001 From: David Belanger Date: Mon, 15 Apr 2024 11:41:58 -0400 Subject: [PATCH] Fix image issue on GFX12 Fix encoding of pitch in SRD (1 bit missing). Issue affects images with pitch > 8192. Signed-off-by: David Belanger Change-Id: Id0b431f51ab3984d1a47d3e8c13d35e28a6009cf Signed-off-by: Chris Freehill [ROCm/ROCR-Runtime commit: 4f453f3bd4410cd426d79b206b8ed5e1287fcb58] --- .../hsa-runtime/image/image_manager_gfx12.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx12.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx12.cpp index 14a37b8fec..a755c6ac50 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx12.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx12.cpp @@ -519,16 +519,17 @@ hsa_status_t ImageManagerGfx12::PopulateImageSrd(Image& image) const { const bool image_3d = (image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_3D); word4.val = 0; - word4.f.DEPTH = + + // For 1d, 2d and 2d-msaa, fields DEPTH+PITCH_MSB encode pitch-1 + if (!image_array && !image_3d) { + uint32_t encPitch = out.pitch - 1; + word4.f.DEPTH = encPitch & 0x3fff; // first 14 bits + word4.f.PITCH_MSB = (encPitch >> 14) & 0x3; // last 2 bits + } else { + word4.f.DEPTH = (image_array) // Doesn't hurt but isn't array_size already >0? ? std::max(image.desc.array_size, static_cast(1)) - 1 : (image_3d) ? image.desc.depth - 1 : 0; - - // For 1d, 2d and 2d-msaa this is pitch-1 - if (!image_array && !image_3d) { - uint32_t encPitch = out.pitch - 1; - word4.f.DEPTH = encPitch & 0x1fff; // 13 bits - word4.f.PITCH_MSB = (encPitch >> 13) & 0x3; // last 2 bits } word5.val = 0;