Fix image LUT for gfx11

For gfx11 the image type table has some different values compared to
previous asic families (e.g TYPE_SRGB). Creating a new LUT class to
use these new values.

Change-Id: Ifdfc6cd29bfd5f4ec2643c848fcb9986eb874f9e


[ROCm/ROCR-Runtime commit: 117495fe88]
This commit is contained in:
David Yat Sin
2022-07-06 20:05:24 -04:00
parent aed560a306
commit 51a3a22e4b
10 changed files with 467 additions and 100 deletions
@@ -229,14 +229,12 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
bool atc_access = true;
const void* image_data_addr = image.data;
ImageProperty image_prop =
image_lut_.MapFormat(image.desc.format, image.desc.geometry);
ImageProperty image_prop = ImageLut().MapFormat(image.desc.format, image.desc.geometry);
if ((image_prop.cap == HSA_EXT_IMAGE_CAPABILITY_NOT_SUPPORTED) ||
(image_prop.element_size == 0))
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
const Swizzle swizzle =
image_lut_.MapSwizzle(image.desc.format.channel_order);
const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order);
if (IsLocalMemory(image.data)) {
atc_access = false;
@@ -279,7 +277,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
image.srd[1] = word1.val;
image.srd[3] = word3.val;
} else {
uint32_t hwPixelSize = image_lut_.GetPixelSize(image_prop.data_format, image_prop.data_type);
uint32_t hwPixelSize = ImageLut().GetPixelSize(image_prop.data_format, image_prop.data_type);
if (image_prop.element_size != hwPixelSize) {
return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED;
@@ -300,7 +298,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image,
if (image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DA ||
image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1D) {
reinterpret_cast<SQ_IMG_RSRC_WORD3*>(&image.srd[3])->bits.TYPE =
image_lut_.MapGeometry(image.desc.geometry);
ImageLut().MapGeometry(image.desc.geometry);
}
// Imported metadata holds the offset to metadata, add the image base address.
@@ -375,8 +373,7 @@ static TEX_BC_SWIZZLE GetBcSwizzle(const Swizzle& swizzle) {
hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
ImageProperty image_prop =
image_lut_.MapFormat(image.desc.format, image.desc.geometry);
ImageProperty image_prop = ImageLut().MapFormat(image.desc.format, image.desc.geometry);
assert(image_prop.cap != HSA_EXT_IMAGE_CAPABILITY_NOT_SUPPORTED);
assert(image_prop.element_size != 0);
@@ -406,8 +403,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
word2.f.NUM_RECORDS = image.desc.width * image_prop.element_size;
const Swizzle swizzle =
image_lut_.MapSwizzle(image.desc.format.channel_order);
const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order);
word3.val = 0;
word3.f.RESOURCE_LEVEL = 1;
word3.f.DST_SEL_X = swizzle.x;
@@ -416,7 +412,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
word3.f.DST_SEL_W = swizzle.w;
word3.f.FORMAT = GetCombinedFormat(image_prop.data_format, image_prop.data_type);
word3.f.INDEX_STRIDE = image_prop.element_size;
word3.f.TYPE = image_lut_.MapGeometry(image.desc.geometry);
word3.f.TYPE = ImageLut().MapGeometry(image.desc.geometry);
image.srd[0] = word0.val;
image.srd[1] = word1.val;
@@ -463,8 +459,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
word2.f.HEIGHT = image.desc.height ? image.desc.height - 1 : 0;
word2.f.RESOURCE_LEVEL = 1;
const Swizzle swizzle =
image_lut_.MapSwizzle(image.desc.format.channel_order);
const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order);
word3.val = 0;
word3.f.DST_SEL_X = swizzle.x;
word3.f.DST_SEL_Y = swizzle.y;
@@ -472,7 +467,7 @@ hsa_status_t ImageManagerNv::PopulateImageSrd(Image& image) const {
word3.f.DST_SEL_W = swizzle.w;
word3.f.SW_MODE = swizzleMode;
word3.f.BC_SWIZZLE = GetBcSwizzle(swizzle);
word3.f.TYPE = image_lut_.MapGeometry(image.desc.geometry);
word3.f.TYPE = ImageLut().MapGeometry(image.desc.geometry);
const bool image_array =
(image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DA ||
@@ -518,14 +513,12 @@ hsa_status_t ImageManagerNv::ModifyImageSrd(
Image& image, hsa_ext_image_format_t& new_format) const {
image.desc.format = new_format;
ImageProperty image_prop =
image_lut_.MapFormat(image.desc.format, image.desc.geometry);
ImageProperty image_prop = ImageLut().MapFormat(image.desc.format, image.desc.geometry);
assert(image_prop.cap != HSA_EXT_IMAGE_CAPABILITY_NOT_SUPPORTED);
assert(image_prop.element_size != 0);
if (image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DB) {
const Swizzle swizzle =
image_lut_.MapSwizzle(image.desc.format.channel_order);
const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order);
SQ_BUF_RSRC_WORD3* word3 =
reinterpret_cast<SQ_BUF_RSRC_WORD3*>(&image.srd[3]);
word3->bits.DST_SEL_X = swizzle.x;
@@ -538,8 +531,7 @@ hsa_status_t ImageManagerNv::ModifyImageSrd(
reinterpret_cast<SQ_IMG_RSRC_WORD1*>(&image.srd[1]);
word1->bits.FORMAT = GetCombinedFormat(image_prop.data_format, image_prop.data_type);
const Swizzle swizzle =
image_lut_.MapSwizzle(image.desc.format.channel_order);
const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order);
SQ_IMG_RSRC_WORD3* word3 =
reinterpret_cast<SQ_IMG_RSRC_WORD3*>(&image.srd[3]);
word3->bits.DST_SEL_X = swizzle.x;
@@ -762,7 +754,7 @@ hsa_status_t ImageManagerNv::FillImage(const Image& image, const void* pattern,
fill_value[3] = pattern_f[3];
new_pattern = fill_value;
ImageProperty image_prop = image_lut_.MapFormat(image.desc.format, image.desc.geometry);
ImageProperty image_prop = ImageLut().MapFormat(image.desc.format, image.desc.geometry);
word1 = reinterpret_cast<SQ_IMG_RSRC_WORD1*>(&image_view->srd[1]);
num_format_original = word1->bits.FORMAT;