diff --git a/runtime/hsa-runtime/CMakeLists.txt b/runtime/hsa-runtime/CMakeLists.txt index f11345d209..8d1937cd15 100644 --- a/runtime/hsa-runtime/CMakeLists.txt +++ b/runtime/hsa-runtime/CMakeLists.txt @@ -238,6 +238,7 @@ if(${IMAGE_SUPPORT}) image/image_manager_nv.cpp image/image_manager_gfx11.cpp image/image_lut_kv.cpp + image/image_lut_gfx11.cpp image/blit_object_gfx7xx.cpp image/blit_object_gfx8xx.cpp image/blit_object_gfx9xx.cpp diff --git a/runtime/hsa-runtime/image/image_lut_gfx11.cpp b/runtime/hsa-runtime/image/image_lut_gfx11.cpp new file mode 100644 index 0000000000..df31432615 --- /dev/null +++ b/runtime/hsa-runtime/image/image_lut_gfx11.cpp @@ -0,0 +1,317 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// The University of Illinois/NCSA +// Open Source License (NCSA) +// +// Copyright (c) 2014-2022, Advanced Micro Devices, Inc. All rights reserved. +// +// Developed by: +// +// AMD Research and AMD HSA Software Development +// +// Advanced Micro Devices, Inc. +// +// www.amd.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal with the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimers. +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimers in +// the documentation and/or other materials provided with the distribution. +// - Neither the names of Advanced Micro Devices, Inc, +// nor the names of its contributors may be used to endorse or promote +// products derived from this Software without specific prior written +// permission. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS WITH THE SOFTWARE. +// +//////////////////////////////////////////////////////////////////////////////// + +#include "image_lut_gfx11.h" +#include "resource_gfx11.h" + +namespace rocr { +namespace image { + + /* + * The type table has changed for gfx11, so we need a separate instance for + * the Property LUT + */ + const ImageProperty ImageLutGfx11::kPropLutGfx11_[ORDER_COUNT][TYPE_COUNT] = { + {// HSA_EXT_IMAGE_CHANNEL_ORDER_A + {RW, 1, FMT_8, TYPE_SNORM}, + {RW, 2, FMT_16, TYPE_SNORM}, + {RW, 1, FMT_8, TYPE_UNORM}, + {RW, 2, FMT_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 1, FMT_8, TYPE_SINT}, + {RW, 2, FMT_16, TYPE_SINT}, + {RW, 4, FMT_32, TYPE_SINT}, + {RW, 1, FMT_8, TYPE_UINT}, + {RW, 2, FMT_16, TYPE_UINT}, + {RW, 4, FMT_32, TYPE_UINT}, + {RW, 2, FMT_16, TYPE_FLOAT}, + {RW, 4, FMT_32, TYPE_FLOAT}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_R + {RW, 1, FMT_8, TYPE_SNORM}, + {RW, 2, FMT_16, TYPE_SNORM}, + {RW, 1, FMT_8, TYPE_UNORM}, + {RW, 2, FMT_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 1, FMT_8, TYPE_SINT}, + {RW, 2, FMT_16, TYPE_SINT}, + {RW, 4, FMT_32, TYPE_SINT}, + {RW, 1, FMT_8, TYPE_UINT}, + {RW, 2, FMT_16, TYPE_UINT}, + {RW, 4, FMT_32, TYPE_UINT}, + {RW, 2, FMT_16, TYPE_FLOAT}, + {RW, 4, FMT_32, TYPE_FLOAT}}, + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_RX + { // HSA_EXT_IMAGE_CHANNEL_ORDER_RG + {RW, 2, FMT_8_8, TYPE_SNORM}, + {RW, 4, FMT_16_16, TYPE_SNORM}, + {RW, 2, FMT_8_8, TYPE_UNORM}, + {RW, 4, FMT_16_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 2, FMT_8_8, TYPE_SINT}, + {RW, 4, FMT_16_16, TYPE_SINT}, + {RW, 8, FMT_32_32, TYPE_SINT}, + {RW, 2, FMT_8_8, TYPE_UINT}, + {RW, 4, FMT_16_16, TYPE_UINT}, + {RW, 8, FMT_32_32, TYPE_UINT}, + {RW, 4, FMT_16_16, TYPE_FLOAT}, + {RW, 8, FMT_32_32, TYPE_FLOAT}}, + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_RGX + { // HSA_EXT_IMAGE_CHANNEL_ORDER_RA + {RW, 2, FMT_8_8, TYPE_SNORM}, + {RW, 4, FMT_16_16, TYPE_SNORM}, + {RW, 2, FMT_8_8, TYPE_UNORM}, + {RW, 4, FMT_16_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 2, FMT_8_8, TYPE_SINT}, + {RW, 4, FMT_16_16, TYPE_SINT}, + {RW, 8, FMT_32_32, TYPE_SINT}, + {RW, 2, FMT_8_8, TYPE_UINT}, + {RW, 4, FMT_16_16, TYPE_UINT}, + {RW, 8, FMT_32_32, TYPE_UINT}, + {RW, 4, FMT_16_16, TYPE_FLOAT}, + {RW, 8, FMT_32_32, TYPE_FLOAT}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_RGB + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 2, FMT_1_5_5_5, TYPE_UNORM}, + {RW, 2, FMT_5_6_5, TYPE_UNORM}, + {RW, 4, FMT_2_10_10_10, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_RGBX + { // HSA_EXT_IMAGE_CHANNEL_ORDER_RGBA + {RW, 4, FMT_8_8_8_8, TYPE_SNORM}, + {RW, 8, FMT_16_16_16_16, TYPE_SNORM}, + {RW, 4, FMT_8_8_8_8, TYPE_UNORM}, + {RW, 8, FMT_16_16_16_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_SINT}, + {RW, 8, FMT_16_16_16_16, TYPE_SINT}, + {RW, 16, FMT_32_32_32_32, TYPE_SINT}, + {RW, 4, FMT_8_8_8_8, TYPE_UINT}, + {RW, 8, FMT_16_16_16_16, TYPE_UINT}, + {RW, 16, FMT_32_32_32_32, TYPE_UINT}, + {RW, 8, FMT_16_16_16_16, TYPE_FLOAT}, + {RW, 16, FMT_32_32_32_32, TYPE_FLOAT}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_BGRA + {RW, 4, FMT_8_8_8_8, TYPE_SNORM}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_SINT}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_UINT}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_ARGB + {RW, 4, FMT_8_8_8_8, TYPE_SNORM}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_SINT}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 4, FMT_8_8_8_8, TYPE_UINT}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_ABGR + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_SRGB + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBX + { // HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBA + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RO, 4, FMT_8_8_8_8, TYPE_SRGB}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}}, + {0}, // HSA_EXT_IMAGE_CHANNEL_ORDER_SBGRA + { // HSA_EXT_IMAGE_CHANNEL_ORDER_INTENSITY + {RW, 1, FMT_8, TYPE_SNORM}, + {RW, 2, FMT_16, TYPE_SNORM}, + {RW, 1, FMT_8, TYPE_UNORM}, + {RW, 2, FMT_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 2, FMT_16, TYPE_FLOAT}, + {RW, 4, FMT_32, TYPE_FLOAT}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_LUMINANCE + {RW, 1, FMT_8, TYPE_SNORM}, + {RW, 2, FMT_16, TYPE_SNORM}, + {RW, 1, FMT_8, TYPE_UNORM}, + {RW, 2, FMT_16, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {RW, 2, FMT_16, TYPE_FLOAT}, + {RW, 4, FMT_32, TYPE_FLOAT}}, + {// HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {ROWO, 2, FMT_16, TYPE_UNORM}, + // TODO: 24 bit + {0, 3, FMT_32, TYPE_UNORM}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {0, 0, 0, 0}, + {ROWO, 4, FMT_32, TYPE_FLOAT}}, + {0} // HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH_STENCIL +}; + +ImageProperty ImageLutGfx11::MapFormat(const hsa_ext_image_format_t& format, + hsa_ext_image_geometry_t geometry) const { + switch (geometry) { + case HSA_EXT_IMAGE_GEOMETRY_1D: + case HSA_EXT_IMAGE_GEOMETRY_2D: + case HSA_EXT_IMAGE_GEOMETRY_3D: + case HSA_EXT_IMAGE_GEOMETRY_1DA: + case HSA_EXT_IMAGE_GEOMETRY_2DA: + return kPropLutGfx11_[format.channel_order][format.channel_type]; + case HSA_EXT_IMAGE_GEOMETRY_1DB: + switch (format.channel_order) { + // Hardware does not support buffer access to srgb image. + case HSA_EXT_IMAGE_CHANNEL_ORDER_SRGB: + case HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBX: + case HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBA: + case HSA_EXT_IMAGE_CHANNEL_ORDER_SBGRA: + break; + default: + switch (format.channel_type) { + // Hardware does not support buffer access to 555/565 packed image. + case HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555: + case HSA_EXT_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565: + break; + default: + return kPropLutGfx11_[format.channel_order][format.channel_type]; + } + } + break; + case HSA_EXT_IMAGE_GEOMETRY_2DDEPTH: + case HSA_EXT_IMAGE_GEOMETRY_2DADEPTH: + switch (format.channel_order) { + case HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH: + case HSA_EXT_IMAGE_CHANNEL_ORDER_DEPTH_STENCIL: + return kPropLutGfx11_[format.channel_order][format.channel_type]; + default: + break; + } + break; + default: + assert(false && "Should not reach here"); + break; + } + + ImageProperty prop = {0}; + return prop; +} + +} // namespace image +} // namespace rocr diff --git a/runtime/hsa-runtime/image/image_lut_gfx11.h b/runtime/hsa-runtime/image/image_lut_gfx11.h new file mode 100644 index 0000000000..5eb99642c5 --- /dev/null +++ b/runtime/hsa-runtime/image/image_lut_gfx11.h @@ -0,0 +1,70 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// The University of Illinois/NCSA +// Open Source License (NCSA) +// +// Copyright (c) 2014-2022, Advanced Micro Devices, Inc. All rights reserved. +// +// Developed by: +// +// AMD Research and AMD HSA Software Development +// +// Advanced Micro Devices, Inc. +// +// www.amd.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal with the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimers. +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimers in +// the documentation and/or other materials provided with the distribution. +// - Neither the names of Advanced Micro Devices, Inc, +// nor the names of its contributors may be used to endorse or promote +// products derived from this Software without specific prior written +// permission. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS WITH THE SOFTWARE. +// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef AMD_HSA_EXT_IMAGE_IMAGE_LUT_GFX11_H +#define AMD_HSA_EXT_IMAGE_IMAGE_LUT_GFX11_H + +#include "image_lut.h" +#include "image_lut_kv.h" + +namespace rocr { +namespace image { + +class ImageLutGfx11 : public ImageLutKv { + public: + ImageLutGfx11() { } + + ImageProperty MapFormat(const hsa_ext_image_format_t& format, + hsa_ext_image_geometry_t geometry) const; + + private: + // Lookup table of channel format property. Based on HSA Programmer's + // Reference Manual 1.0P Table 9-4 Channel Order, Channel type and Image + // Geometry Combinations. + static const ImageProperty kPropLutGfx11_[ORDER_COUNT][TYPE_COUNT]; + + DISALLOW_COPY_AND_ASSIGN(ImageLutGfx11); +}; + +} // namespace image +} // namespace rocr +#endif // AMD_HSA_EXT_IMAGE_IMAGE_LUT_GFX11_H diff --git a/runtime/hsa-runtime/image/image_manager_ai.cpp b/runtime/hsa-runtime/image/image_manager_ai.cpp old mode 100755 new mode 100644 index c4c0cfe891..9a7d57d409 --- a/runtime/hsa-runtime/image/image_manager_ai.cpp +++ b/runtime/hsa-runtime/image/image_manager_ai.cpp @@ -113,12 +113,12 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t 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; @@ -161,7 +161,8 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t image.srd[1] = word1.val; image.srd[3] = word3.val; } else { - uint32_t hwPixelSize = image_lut_.GetPixelSize(desc->word1.bitfields.DATA_FORMAT, desc->word1.bitfields.NUM_FORMAT); + uint32_t hwPixelSize = ImageLut().GetPixelSize(desc->word1.bitfields.DATA_FORMAT, + desc->word1.bitfields.NUM_FORMAT); if(image_prop.element_size!=hwPixelSize) return (hsa_status_t)HSA_EXT_STATUS_ERROR_IMAGE_FORMAT_UNSUPPORTED; @@ -175,7 +176,8 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image, const metadata_amd_t ((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.DST_SEL_W = swizzle.w; if (image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DA || image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1D) { - ((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.TYPE = image_lut_.MapGeometry(image.desc.geometry); + ((SQ_IMG_RSRC_WORD3*)(&image.srd[3]))->bits.TYPE = + ImageLut().MapGeometry(image.desc.geometry); } // Imported metadata holds the offset to metadata, add the image base address. @@ -265,8 +267,7 @@ static TEX_BC_SWIZZLE GetBcSwizzle(const Swizzle& swizzle) { hsa_status_t ImageManagerAi::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); @@ -296,8 +297,7 @@ hsa_status_t ImageManagerAi::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.dst_sel_x = swizzle.x; word3.f.dst_sel_y = swizzle.y; @@ -306,7 +306,7 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image) const { word3.f.num_format = image_prop.data_type; word3.f.data_format = image_prop.data_format; 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; @@ -350,15 +350,14 @@ hsa_status_t ImageManagerAi::PopulateImageSrd(Image& image) const { word2.f.height = image.desc.height - 1; word2.f.perf_mod = 0; - 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; word3.f.dst_sel_z = swizzle.z; word3.f.dst_sel_w = swizzle.w; word3.f.sw_mode = swizzleMode; - 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 || @@ -402,14 +401,12 @@ hsa_status_t ImageManagerAi::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(&image.srd[3]); word3->bits.DST_SEL_X = swizzle.x; @@ -424,8 +421,7 @@ hsa_status_t ImageManagerAi::ModifyImageSrd( word1->bits.DATA_FORMAT = image_prop.data_format; word1->bits.NUM_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(&image.srd[3]); word3->bits.DST_SEL_X = swizzle.x; diff --git a/runtime/hsa-runtime/image/image_manager_gfx11.cpp b/runtime/hsa-runtime/image/image_manager_gfx11.cpp index 203c85910f..c1dd7d44f7 100644 --- a/runtime/hsa-runtime/image/image_manager_gfx11.cpp +++ b/runtime/hsa-runtime/image/image_manager_gfx11.cpp @@ -62,7 +62,7 @@ namespace image { //----------------------------------------------------------------------------- // Workaround switch to combined format/type codes and missing gfx11 -// specific look up table. Only covers types used in image_lut_kv.cpp. +// specific look up table. Only covers types used in image_lut_gfx11.cpp. //----------------------------------------------------------------------------- struct formatconverstion_t { FMT fmt; @@ -238,19 +238,16 @@ bool ImageManagerGfx11::IsLocalMemory(const void* address) const { hsa_status_t ImageManagerGfx11::PopulateImageSrd(Image& image, const metadata_amd_t* descriptor) const { - const metadata_amd_nv_t* desc = - reinterpret_cast(descriptor); + const metadata_amd_gfx11_t* desc = reinterpret_cast(descriptor); 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; @@ -293,7 +290,7 @@ hsa_status_t ImageManagerGfx11::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; @@ -314,7 +311,7 @@ hsa_status_t ImageManagerGfx11::PopulateImageSrd(Image& image, if (image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1DA || image.desc.geometry == HSA_EXT_IMAGE_GEOMETRY_1D) { reinterpret_cast(&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. @@ -389,8 +386,7 @@ static TEX_BC_SWIZZLE GetBcSwizzle(const Swizzle& swizzle) { hsa_status_t ImageManagerGfx11::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); @@ -419,8 +415,7 @@ hsa_status_t ImageManagerGfx11::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; @@ -429,7 +424,7 @@ hsa_status_t ImageManagerGfx11::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; @@ -474,8 +469,7 @@ hsa_status_t ImageManagerGfx11::PopulateImageSrd(Image& image) const { word2.f.WIDTH_HI = BitSelect<2, 13>(image.desc.width - 1); word2.f.HEIGHT = image.desc.height ? image.desc.height - 1 : 0; - 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; @@ -483,7 +477,7 @@ hsa_status_t ImageManagerGfx11::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 || @@ -528,14 +522,12 @@ hsa_status_t ImageManagerGfx11::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(&image.srd[3]); word3->bits.DST_SEL_X = swizzle.x; @@ -548,8 +540,7 @@ hsa_status_t ImageManagerGfx11::ModifyImageSrd( reinterpret_cast(&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(&image.srd[3]); word3->bits.DST_SEL_X = swizzle.x; @@ -762,7 +753,7 @@ hsa_status_t ImageManagerGfx11::FillImage(const Image& image, const void* patter case HSA_EXT_IMAGE_CHANNEL_ORDER_SRGB: case HSA_EXT_IMAGE_CHANNEL_ORDER_SRGBX: case HSA_EXT_IMAGE_CHANNEL_ORDER_SBGRA: { - // KV and CZ don't have write support for SRGBA image, so convert pattern + // We do not have write support for SRGBA image, so convert pattern // to standard form and treat the image as RGBA image. const float* pattern_f = reinterpret_cast(pattern); fill_value[0] = LinearToStandardRGB(pattern_f[0]); @@ -771,7 +762,7 @@ hsa_status_t ImageManagerGfx11::FillImage(const Image& image, const void* patter 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(&image_view->srd[1]); num_format_original = word1->bits.FORMAT; diff --git a/runtime/hsa-runtime/image/image_manager_gfx11.h b/runtime/hsa-runtime/image/image_manager_gfx11.h index a9cd786c7e..fdea20974b 100755 --- a/runtime/hsa-runtime/image/image_manager_gfx11.h +++ b/runtime/hsa-runtime/image/image_manager_gfx11.h @@ -44,6 +44,7 @@ #define EXT_IMAGE_IMAGE_MANAGER_GFX11_H_ #include "addrlib/inc/addrinterface.h" +#include "image_lut_gfx11.h" #include "image_manager_kv.h" namespace rocr { @@ -88,8 +89,10 @@ class ImageManagerGfx11 : public ImageManagerKv { ADDR2_COMPUTE_SURFACE_INFO_OUTPUT& out) const; bool IsLocalMemory(const void* address) const; + virtual const ImageLutGfx11& ImageLut() const { return image_lut_gfx11; }; private: + ImageLutGfx11 image_lut_gfx11; DISALLOW_COPY_AND_ASSIGN(ImageManagerGfx11); }; diff --git a/runtime/hsa-runtime/image/image_manager_kv.cpp b/runtime/hsa-runtime/image/image_manager_kv.cpp old mode 100755 new mode 100644 index fea0491fde..0b4fef8a72 --- a/runtime/hsa-runtime/image/image_manager_kv.cpp +++ b/runtime/hsa-runtime/image/image_manager_kv.cpp @@ -181,7 +181,7 @@ void ImageManagerKv::Cleanup() { ImageProperty ImageManagerKv::GetImageProperty( hsa_agent_t component, const hsa_ext_image_format_t& format, hsa_ext_image_geometry_t geometry) const { - return image_lut_.MapFormat(format, geometry); + return ImageLut().MapFormat(format, geometry); } void ImageManagerKv::GetImageInfoMaxDimension(hsa_agent_t component, @@ -189,10 +189,10 @@ void ImageManagerKv::GetImageInfoMaxDimension(hsa_agent_t component, uint32_t& width, uint32_t& height, uint32_t& depth, uint32_t& array_size) const { - width = image_lut_.GetMaxWidth(geometry); - height = image_lut_.GetMaxHeight(geometry); - depth = image_lut_.GetMaxDepth(geometry); - array_size = image_lut_.GetMaxArraySize(geometry); + width = ImageLut().GetMaxWidth(geometry); + height = ImageLut().GetMaxHeight(geometry); + depth = ImageLut().GetMaxDepth(geometry); + array_size = ImageLut().GetMaxArraySize(geometry); } hsa_status_t ImageManagerKv::CalculateImageSizeAndAlignment( @@ -258,16 +258,17 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image, const metadata_amd_t uint32_t mtype = mtype_; 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; - uint32_t hwPixelSize = image_lut_.GetPixelSize(desc->word1.bitfields.data_format, desc->word1.bitfields.num_format); + uint32_t hwPixelSize = + ImageLut().GetPixelSize(desc->word1.bitfields.data_format, desc->word1.bitfields.num_format); if(image_prop.element_size!=hwPixelSize) 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; @@ -310,8 +311,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image, const metadata_amd_t } hsa_status_t ImageManagerKv::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); @@ -345,8 +345,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const { word2.bits.num_records = (major_ver < 8) ? image.desc.width : 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.u32_all = 0; word3.bits.dst_sel_x = swizzle.x; word3.bits.dst_sel_y = swizzle.y; @@ -356,7 +355,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const { word3.bits.data_format = image_prop.data_format; word3.bits.atc = atc_access; word3.bits.element_size = image_prop.element_size; - word3.bits.type = image_lut_.MapGeometry(image.desc.geometry); + word3.bits.type = ImageLut().MapGeometry(image.desc.geometry); word3.bits.mtype = mtype; image.srd[0] = word0.u32_all; @@ -401,8 +400,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const { word2.bits.perf_mod = 0; word2.bits.interlaced = 0; - const Swizzle swizzle = - image_lut_.MapSwizzle(image.desc.format.channel_order); + const Swizzle swizzle = ImageLut().MapSwizzle(image.desc.format.channel_order); word3.u32_all = 0; word3.bits.dst_sel_x = swizzle.x; word3.bits.dst_sel_y = swizzle.y; @@ -410,7 +408,7 @@ hsa_status_t ImageManagerKv::PopulateImageSrd(Image& image) const { word3.bits.dst_sel_w = swizzle.w; word3.bits.tiling_index = out.tileIndex; word3.bits.pow2_pad = (IsPowerOfTwo(row_pitch_size) && IsPowerOfTwo(image.desc.height)) ? 1 : 0; - word3.bits.type = image_lut_.MapGeometry(image.desc.geometry); + word3.bits.type = ImageLut().MapGeometry(image.desc.geometry); word3.bits.atc = atc_access; const bool image_array = @@ -459,14 +457,12 @@ hsa_status_t ImageManagerKv::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(&image.srd[3]); word3->bits.dst_sel_x = swizzle.x; @@ -481,8 +477,7 @@ hsa_status_t ImageManagerKv::ModifyImageSrd( word1->bits.data_format = image_prop.data_format; word1->bits.num_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(&image.srd[3]); word3->bits.dst_sel_x = swizzle.x; diff --git a/runtime/hsa-runtime/image/image_manager_kv.h b/runtime/hsa-runtime/image/image_manager_kv.h index 617ae7720c..60b0fc0a4b 100755 --- a/runtime/hsa-runtime/image/image_manager_kv.h +++ b/runtime/hsa-runtime/image/image_manager_kv.h @@ -141,7 +141,7 @@ class ImageManagerKv : public ImageManager { BlitQueue& BlitQueueInit(); - ImageLutKv image_lut_; + virtual const ImageLutKv& ImageLut() const { return image_lut_; }; ADDR_HANDLE addr_lib_; @@ -162,6 +162,7 @@ class ImageManagerKv : public ImageManager { std::mutex lock_; private: + ImageLutKv image_lut_; DISALLOW_COPY_AND_ASSIGN(ImageManagerKv); }; diff --git a/runtime/hsa-runtime/image/image_manager_nv.cpp b/runtime/hsa-runtime/image/image_manager_nv.cpp index 5d0f297bbd..2c3b8f501c 100644 --- a/runtime/hsa-runtime/image/image_manager_nv.cpp +++ b/runtime/hsa-runtime/image/image_manager_nv.cpp @@ -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(&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(&image.srd[3]); word3->bits.DST_SEL_X = swizzle.x; @@ -538,8 +531,7 @@ hsa_status_t ImageManagerNv::ModifyImageSrd( reinterpret_cast(&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(&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(&image_view->srd[1]); num_format_original = word1->bits.FORMAT; diff --git a/runtime/hsa-runtime/image/resource_gfx11.h b/runtime/hsa-runtime/image/resource_gfx11.h index 158b55b855..0f3111345d 100644 --- a/runtime/hsa-runtime/image/resource_gfx11.h +++ b/runtime/hsa-runtime/image/resource_gfx11.h @@ -809,20 +809,21 @@ TEX_BC_Swizzle_ZYXW = 0x00000004, TEX_BC_Swizzle_YXWZ = 0x00000005, } TEX_BC_SWIZZLE; -typedef struct metadata_amd_nv_s { - uint32_t version; // Must be 1 - uint32_t vendorID; // AMD - SQ_IMG_RSRC_WORD0 word0; - SQ_IMG_RSRC_WORD1 word1; - SQ_IMG_RSRC_WORD2 word2; - SQ_IMG_RSRC_WORD3 word3; - SQ_IMG_RSRC_WORD4 word4; - SQ_IMG_RSRC_WORD5 word5; - SQ_IMG_RSRC_WORD6 word6; - SQ_IMG_RSRC_WORD7 word7; - uint32_t mip_offsets[0]; -} metadata_amd_nv_t; +typedef struct metadata_amd_gfx11_s { + uint32_t version; // Must be 1 + uint32_t vendorID; // AMD + SQ_IMG_RSRC_WORD0 word0; + SQ_IMG_RSRC_WORD1 word1; + SQ_IMG_RSRC_WORD2 word2; + SQ_IMG_RSRC_WORD3 word3; + SQ_IMG_RSRC_WORD4 word4; + SQ_IMG_RSRC_WORD5 word5; + SQ_IMG_RSRC_WORD6 word6; + SQ_IMG_RSRC_WORD7 word7; + uint32_t mip_offsets[0]; +} metadata_amd_gfx11_t; } // namespace image } // namespace rocr #endif // EXT_IMAGE_RESOURCE_GFX11_H_ +