diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp index 770509b49d..e5be19b3b4 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa.cpp @@ -427,6 +427,7 @@ hsa_status_t hsa_system_get_major_extension_table(uint16_t extension, uint16_t v ext_table.hsa_ext_image_get_capability_with_layout = hsa_ext_image_get_capability_with_layout; ext_table.hsa_ext_image_data_get_info_with_layout = hsa_ext_image_data_get_info_with_layout; ext_table.hsa_ext_image_create_with_layout = hsa_ext_image_create_with_layout; + ext_table.hsa_ext_sampler_create_v2 = hsa_ext_sampler_create_v2; memcpy(table, &ext_table, Min(sizeof(ext_table), table_length)); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp index 8e42cae8b5..77f95d6b61 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_api_trace.cpp @@ -88,7 +88,7 @@ void HsaApiTable::Init() { constexpr size_t expected_core_api_table_size = 1016; constexpr size_t expected_amd_ext_table_size = 584; - constexpr size_t expected_image_ext_table_size = 120; + constexpr size_t expected_image_ext_table_size = 128; constexpr size_t expected_finalizer_ext_table_size = 64; constexpr size_t expected_tools_table_size = 64; constexpr size_t expected_pc_sampling_ext_table_size = 72; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp index 8271176e2a..c2e302c512 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/runtime/hsa_ext_interface.cpp @@ -425,6 +425,13 @@ hsa_status_t hsa_ext_sampler_create( .hsa_ext_sampler_create_fn(agent, sampler_descriptor, sampler); } +hsa_status_t hsa_ext_sampler_create_v2( + hsa_agent_t agent, const hsa_ext_sampler_descriptor_v2_t* sampler_descriptor, + hsa_ext_sampler_t* sampler) { + return rocr::core::Runtime::runtime_singleton_->extensions_.image_api + .hsa_ext_sampler_create_v2_fn(agent, sampler_descriptor, sampler); +} + hsa_status_t hsa_ext_sampler_destroy(hsa_agent_t agent, hsa_ext_sampler_t sampler) { return rocr::core::Runtime::runtime_singleton_->extensions_.image_api diff --git a/projects/rocr-runtime/runtime/hsa-runtime/hsacore.so.def b/projects/rocr-runtime/runtime/hsa-runtime/hsacore.so.def index 6f1a019fbc..4e0ba80cf2 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/hsacore.so.def +++ b/projects/rocr-runtime/runtime/hsa-runtime/hsacore.so.def @@ -208,6 +208,7 @@ global: hsa_ext_image_clear; hsa_ext_image_destroy; hsa_ext_sampler_create; + hsa_ext_sampler_create_v2; hsa_ext_sampler_destroy; hsa_ext_image_get_capability_with_layout; hsa_ext_image_data_get_info_with_layout; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/hsa_ext_image.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/hsa_ext_image.cpp index c2d23d19c3..1e9dd8696c 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/hsa_ext_image.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/hsa_ext_image.cpp @@ -261,6 +261,27 @@ hsa_status_t hsa_ext_sampler_create(hsa_agent_t agent, return HSA_STATUS_ERROR_INVALID_AGENT; } + if (sampler_descriptor == NULL || sampler == NULL) { + return HSA_STATUS_ERROR_INVALID_ARGUMENT; + } + hsa_ext_sampler_descriptor_v2_t sampler_descriptor_v2 = { + sampler_descriptor->coordinate_mode, + sampler_descriptor->filter_mode, + {sampler_descriptor->address_mode, + sampler_descriptor->address_mode, sampler_descriptor->address_mode} + }; + return ImageRuntime::instance()->CreateSamplerHandle(agent, sampler_descriptor_v2, *sampler); + CATCH; +} + +hsa_status_t hsa_ext_sampler_create_v2(hsa_agent_t agent, + const hsa_ext_sampler_descriptor_v2_t* sampler_descriptor, + hsa_ext_sampler_t* sampler) { + TRY; + if (agent.handle == 0) { + return HSA_STATUS_ERROR_INVALID_AGENT; + } + if (sampler_descriptor == NULL || sampler == NULL) { return HSA_STATUS_ERROR_INVALID_ARGUMENT; } @@ -397,6 +418,8 @@ void LoadImage(core::ImageExtTableInternal* image_api, image_api->hsa_amd_image_get_info_max_dim_fn = hsa_amd_image_get_info_max_dim; + image_api->hsa_ext_sampler_create_v2_fn = hsa_ext_sampler_create_v2; + *interface_api = hsa_amd_image_create; } diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager.h b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager.h index d63461c8f5..d5b876e7bf 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager.h @@ -134,6 +134,34 @@ class ImageManager { static void FormatPattern(const hsa_ext_image_format_t& format, const void* pattern_in, void* pattern_out); + template + static inline hsa_status_t convertAddressMode(dstT &word, + const hsa_ext_sampler_addressing_mode32_t address_mode[3]) { + srcT clamp[3]; + for (int i = 0; i < 3; i++) { + switch (address_mode[i]) { + case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: + clamp[i] = srcT::SQ_TEX_CLAMP_LAST_TEXEL; + break; + case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: + clamp[i] = srcT::SQ_TEX_CLAMP_BORDER; + break; + case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: + clamp[i] = srcT::SQ_TEX_MIRROR; + break; + case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: + case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: + clamp[i] = srcT::SQ_TEX_WRAP; + break; + default: + return HSA_STATUS_ERROR_INVALID_ARGUMENT; + } + } + word.bits.CLAMP_X = static_cast(clamp[0]); + word.bits.CLAMP_Y = static_cast(clamp[1]); + word.bits.CLAMP_Z = static_cast(clamp[2]); + return HSA_STATUS_SUCCESS; + } private: DISALLOW_COPY_AND_ASSIGN(ImageManager); }; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_ai.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_ai.cpp index feab7a337a..3beefe586c 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_ai.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_ai.cpp @@ -452,7 +452,7 @@ hsa_status_t ImageManagerAi::ModifyImageSrd( } hsa_status_t ImageManagerAi::PopulateSamplerSrd(Sampler& sampler) const { - const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc; + const hsa_ext_sampler_descriptor_v2_t &sampler_descriptor = sampler.desc; SQ_IMG_SAMP_WORD0 word0; SQ_IMG_SAMP_WORD1 word1; @@ -460,25 +460,9 @@ hsa_status_t ImageManagerAi::PopulateSamplerSrd(Sampler& sampler) const { SQ_IMG_SAMP_WORD3 word3; word0.u32All = 0; - switch (sampler_descriptor.address_mode) { - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_LAST_TEXEL); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_BORDER); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_MIRROR); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: - case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_WRAP); - break; - default: - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - word0.bits.CLAMP_Y = word0.bits.CLAMP_X; - word0.bits.CLAMP_Z = word0.bits.CLAMP_X; + hsa_status_t status = convertAddressMode + (word0, sampler_descriptor.address_modes); + if (status != HSA_STATUS_SUCCESS) return status; word0.bits.FORCE_UNNORMALIZED = (sampler_descriptor.coordinate_mode == HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx11.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx11.cpp index 427dab3863..ba70fa65b7 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx11.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_gfx11.cpp @@ -572,7 +572,7 @@ hsa_status_t ImageManagerGfx11::ModifyImageSrd( } hsa_status_t ImageManagerGfx11::PopulateSamplerSrd(Sampler& sampler) const { - const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc; + const hsa_ext_sampler_descriptor_v2_t &sampler_descriptor = sampler.desc; SQ_IMG_SAMP_WORD0 word0; SQ_IMG_SAMP_WORD1 word1; @@ -580,25 +580,9 @@ hsa_status_t ImageManagerGfx11::PopulateSamplerSrd(Sampler& sampler) const { SQ_IMG_SAMP_WORD3 word3; word0.u32All = 0; - switch (sampler_descriptor.address_mode) { - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_LAST_TEXEL); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_BORDER); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_MIRROR); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: - case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_WRAP); - break; - default: - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - word0.bits.CLAMP_Y = word0.bits.CLAMP_X; - word0.bits.CLAMP_Z = word0.bits.CLAMP_X; + hsa_status_t status = convertAddressMode + (word0, sampler_descriptor.address_modes); + if (status != HSA_STATUS_SUCCESS) return status; word0.bits.FORCE_UNNORMALIZED = (sampler_descriptor.coordinate_mode == HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED); 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 a755c6ac50..a573d69911 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 @@ -595,7 +595,7 @@ hsa_status_t ImageManagerGfx12::ModifyImageSrd( } hsa_status_t ImageManagerGfx12::PopulateSamplerSrd(Sampler& sampler) const { - const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc; + const hsa_ext_sampler_descriptor_v2_t &sampler_descriptor = sampler.desc; SQ_IMG_SAMP_WORD0 word0; SQ_IMG_SAMP_WORD1 word1; @@ -603,25 +603,9 @@ hsa_status_t ImageManagerGfx12::PopulateSamplerSrd(Sampler& sampler) const { SQ_IMG_SAMP_WORD3 word3; word0.u32All = 0; - switch (sampler_descriptor.address_mode) { - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_LAST_TEXEL); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_BORDER); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_MIRROR); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: - case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_WRAP); - break; - default: - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - word0.bits.CLAMP_Y = word0.bits.CLAMP_X; - word0.bits.CLAMP_Z = word0.bits.CLAMP_X; + hsa_status_t status = convertAddressMode + (word0, sampler_descriptor.address_modes); + if (status != HSA_STATUS_SUCCESS) return status; word0.bits.FORCE_UNNORMALIZED = (sampler_descriptor.coordinate_mode == HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_kv.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_kv.cpp index 5d3750e06f..9b34b325f1 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_kv.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_kv.cpp @@ -518,7 +518,7 @@ hsa_status_t ImageManagerKv::ModifyImageSrd( } hsa_status_t ImageManagerKv::PopulateSamplerSrd(Sampler& sampler) const { - const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc; + const hsa_ext_sampler_descriptor_v2_t &sampler_descriptor = sampler.desc; SQ_IMG_SAMP_WORD0 word0; SQ_IMG_SAMP_WORD1 word1; @@ -526,25 +526,9 @@ hsa_status_t ImageManagerKv::PopulateSamplerSrd(Sampler& sampler) const { SQ_IMG_SAMP_WORD3 word3; word0.u32_all = 0; - switch (sampler_descriptor.address_mode) { - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - word0.bits.clamp_x = static_cast(SQ_TEX_CLAMP_LAST_TEXEL); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: - word0.bits.clamp_x = static_cast(SQ_TEX_CLAMP_BORDER); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - word0.bits.clamp_x = static_cast(SQ_TEX_MIRROR); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: - case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: - word0.bits.clamp_x = static_cast(SQ_TEX_WRAP); - break; - default: - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - word0.bits.clamp_y = word0.bits.clamp_x; - word0.bits.clamp_z = word0.bits.clamp_x; + hsa_status_t status = convertAddressMode + (word0, sampler_descriptor.address_modes); + if (status != HSA_STATUS_SUCCESS) return status; word0.bits.force_unormalized = (sampler_descriptor.coordinate_mode == HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_nv.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_nv.cpp index cb897f196a..3675e3d626 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_nv.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_manager_nv.cpp @@ -565,7 +565,7 @@ hsa_status_t ImageManagerNv::ModifyImageSrd( } hsa_status_t ImageManagerNv::PopulateSamplerSrd(Sampler& sampler) const { - const hsa_ext_sampler_descriptor_t sampler_descriptor = sampler.desc; + const hsa_ext_sampler_descriptor_v2_t &sampler_descriptor = sampler.desc; SQ_IMG_SAMP_WORD0 word0; SQ_IMG_SAMP_WORD1 word1; @@ -573,25 +573,9 @@ hsa_status_t ImageManagerNv::PopulateSamplerSrd(Sampler& sampler) const { SQ_IMG_SAMP_WORD3 word3; word0.u32All = 0; - switch (sampler_descriptor.address_mode) { - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_LAST_TEXEL); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_CLAMP_TO_BORDER: - word0.bits.CLAMP_X = static_cast(SQ_TEX_CLAMP_BORDER); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_MIRROR); - break; - case HSA_EXT_SAMPLER_ADDRESSING_MODE_UNDEFINED: - case HSA_EXT_SAMPLER_ADDRESSING_MODE_REPEAT: - word0.bits.CLAMP_X = static_cast(SQ_TEX_WRAP); - break; - default: - return HSA_STATUS_ERROR_INVALID_ARGUMENT; - } - word0.bits.CLAMP_Y = word0.bits.CLAMP_X; - word0.bits.CLAMP_Z = word0.bits.CLAMP_X; + hsa_status_t status = convertAddressMode + (word0, sampler_descriptor.address_modes); + if (status != HSA_STATUS_SUCCESS) return status; word0.bits.FORCE_UNNORMALIZED = (sampler_descriptor.coordinate_mode == HSA_EXT_SAMPLER_COORDINATE_MODE_UNNORMALIZED); diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.cpp b/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.cpp index a7cd66d035..178e306852 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.cpp @@ -533,7 +533,7 @@ hsa_status_t ImageRuntime::FillImage( hsa_status_t ImageRuntime::CreateSamplerHandle( hsa_agent_t component, - const hsa_ext_sampler_descriptor_t& sampler_descriptor, + const hsa_ext_sampler_descriptor_v2_t& sampler_descriptor, hsa_ext_sampler_t& sampler_handle) { sampler_handle.handle = 0; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.h b/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.h index ebb2b5b794..c8386fe1f1 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/image_runtime.h @@ -131,7 +131,7 @@ class ImageRuntime { /// @brief Create device sampler object and return its handle. hsa_status_t CreateSamplerHandle( hsa_agent_t component, - const hsa_ext_sampler_descriptor_t& sampler_descriptor, + const hsa_ext_sampler_descriptor_v2_t& sampler_descriptor, hsa_ext_sampler_t& sampler); /// @brief Destroy the device sampler object referenced by the handle. diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/inc/hsa_ext_image_impl.h b/projects/rocr-runtime/runtime/hsa-runtime/image/inc/hsa_ext_image_impl.h index 70c2a35ca8..484d99ee8e 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/inc/hsa_ext_image_impl.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/inc/hsa_ext_image_impl.h @@ -94,6 +94,10 @@ hsa_status_t hsa_ext_sampler_create(hsa_agent_t agent, const hsa_ext_sampler_descriptor_t* sampler_descriptor, hsa_ext_sampler_t* sampler); +hsa_status_t hsa_ext_sampler_create_v2(hsa_agent_t agent, + const hsa_ext_sampler_descriptor_v2_t* sampler_descriptor, + hsa_ext_sampler_t* sampler); + hsa_status_t hsa_ext_sampler_destroy(hsa_agent_t agent, hsa_ext_sampler_t sampler); hsa_status_t hsa_ext_image_get_capability_with_layout(hsa_agent_t agent, diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/resource.h b/projects/rocr-runtime/runtime/hsa-runtime/image/resource.h index f6add6a37c..309b96635d 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/resource.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/resource.h @@ -199,7 +199,7 @@ public: hsa_agent_t component; // HSA sampler descriptor of the image object. - hsa_ext_sampler_descriptor_t desc; + hsa_ext_sampler_descriptor_v2_t desc; } Sampler; } // namespace image diff --git a/projects/rocr-runtime/runtime/hsa-runtime/image/resource_kv.h b/projects/rocr-runtime/runtime/hsa-runtime/image/resource_kv.h index 4de908d2e8..523c17294f 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/image/resource_kv.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/image/resource_kv.h @@ -299,9 +299,9 @@ union SQ_IMG_RSRC_WORD7 { union SQ_IMG_SAMP_WORD0 { struct { #if defined(LITTLEENDIAN_CPU) - unsigned int clamp_x : 3; - unsigned int clamp_y : 3; - unsigned int clamp_z : 3; + unsigned int CLAMP_X : 3; + unsigned int CLAMP_Y : 3; + unsigned int CLAMP_Z : 3; unsigned int max_aniso_ratio : 3; unsigned int depth_compare_func : 3; unsigned int force_unormalized : 1; @@ -325,9 +325,9 @@ union SQ_IMG_SAMP_WORD0 { unsigned int force_unormalized : 1; unsigned int depth_compare_func : 3; unsigned int max_aniso_ratio : 3; - unsigned int clamp_z : 3; - unsigned int clamp_y : 3; - unsigned int clamp_x : 3; + unsigned int CLAMP_Z : 3; + unsigned int CLAMP_Y : 3; + unsigned int CLAMP_X : 3; #endif } bitfields, bits; unsigned int u32_all; diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h index e0063e6dab..7e4de55ac8 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace.h @@ -176,6 +176,8 @@ struct ImageExtTable { decltype(hsa_ext_image_get_capability_with_layout)* hsa_ext_image_get_capability_with_layout_fn; decltype(hsa_ext_image_data_get_info_with_layout)* hsa_ext_image_data_get_info_with_layout_fn; decltype(hsa_ext_image_create_with_layout)* hsa_ext_image_create_with_layout_fn; + decltype(hsa_ext_sampler_create_v2)* hsa_ext_sampler_create_v2_fn; + }; // Table to export HSA PC Sampling Extension Apis diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace_version.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace_version.h index 2033f0bc2e..af03a57988 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace_version.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_api_trace_version.h @@ -60,7 +60,9 @@ #define HSA_CORE_API_TABLE_STEP_VERSION 0x00 #define HSA_AMD_EXT_API_TABLE_STEP_VERSION 0x04 #define HSA_FINALIZER_API_TABLE_STEP_VERSION 0x00 -#define HSA_IMAGE_API_TABLE_STEP_VERSION 0x00 +#define HSA_IMAGE_API_TABLE_STEP_VERSION 0x01 +// Rocprofiler just checks HSA_MAGE_EXT_API_TABLE_STEP_VERSION +#define HSA_IMAGE_EXT_API_TABLE_STEP_VERSION HSA_IMAGE_API_TABLE_STEP_VERSION #define HSA_AQLPROFILE_API_TABLE_STEP_VERSION 0x00 #define HSA_TOOLS_API_TABLE_STEP_VERSION 0x00 #define HSA_PC_SAMPLING_API_TABLE_STEP_VERSION 0x00 diff --git a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h index b25f168395..cad9b50820 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h +++ b/projects/rocr-runtime/runtime/hsa-runtime/inc/hsa_ext_image.h @@ -1090,8 +1090,8 @@ hsa_status_t HSA_API hsa_ext_image_clear( /** * @brief Sampler handle. Samplers are populated by - * ::hsa_ext_sampler_create. Sampler handles are only unique within an - * agent, not across agents. + * ::hsa_ext_sampler_create or ::hsa_ext_sampler_create_v2. Sampler handles are only unique + * within an agent, not across agents. */ typedef struct hsa_ext_sampler_s { /** @@ -1218,9 +1218,30 @@ typedef struct hsa_ext_sampler_descriptor_s { * coordinates. */ hsa_ext_sampler_addressing_mode32_t address_mode; - } hsa_ext_sampler_descriptor_t; +/** + * @brief Implementation independent sampler descriptor v2 which supports + * different address modes in X, Y and Z axises. + */ +typedef struct hsa_ext_sampler_descriptor_v2_s { + /** + * Sampler coordinate mode describes the normalization of image coordinates. + */ + hsa_ext_sampler_coordinate_mode32_t coordinate_mode; + + /** + * Sampler filter type describes the type of sampling performed. + */ + hsa_ext_sampler_filter_mode32_t filter_mode; + + /** + * Sampler address mode describes the processing of out-of-range image + * coordinates. + */ + hsa_ext_sampler_addressing_mode32_t address_modes[3]; // in X, Y and Z axises +} hsa_ext_sampler_descriptor_v2_t; + /** * @brief Create an agent specific sampler handle for a given agent * independent sampler descriptor and agent. @@ -1256,7 +1277,42 @@ hsa_status_t HSA_API hsa_ext_sampler_create( hsa_ext_sampler_t *sampler); /** - * @brief Destroy a sampler handle previously created using ::hsa_ext_sampler_create. + * @brief Create an agent specific sampler handle for a given agent + * independent sampler descriptor v2 and agent. + * + * @param[in] agent Agent to be associated with the sampler handle created. + * + * @param[in] sampler_descriptor v2 Pointer to a sampler descriptor. Must not be + * NULL. + * + * @param[out] sampler Memory location where the HSA runtime stores the newly + * created sampler handle. Must not be NULL. + * + * @retval ::HSA_STATUS_SUCCESS The function has been executed successfully. + * + * @retval ::HSA_STATUS_ERROR_NOT_INITIALIZED The HSA runtime has not been + * initialized. + * + * @retval ::HSA_STATUS_ERROR_INVALID_AGENT The agent is invalid. + * + * @retval ::HSA_EXT_STATUS_ERROR_SAMPLER_DESCRIPTOR_UNSUPPORTED The + * @p agent does not have the capability to support the properties + * specified by @p sampler_descriptor or it is invalid. + * + * @retval ::HSA_STATUS_ERROR_OUT_OF_RESOURCES The HSA runtime failed to allocate + * the required resources. + * + * @retval ::HSA_STATUS_ERROR_INVALID_ARGUMENT @p sampler_descriptor is NULL, or + * @p sampler is NULL. + */ +hsa_status_t HSA_API hsa_ext_sampler_create_v2( + hsa_agent_t agent, + const hsa_ext_sampler_descriptor_v2_t *sampler_descriptor, + hsa_ext_sampler_t *sampler); + +/** + * @brief Destroy a sampler handle previously created using ::hsa_ext_sampler_create or + * ::hsa_ext_sampler_create_v2. * * @details The sampler handle should not be destroyed while there are * references to it queued for execution or currently being used in a @@ -1444,6 +1500,11 @@ typedef struct hsa_ext_images_1_pfn_s { size_t image_data_slice_pitch, hsa_ext_image_t *image); + hsa_status_t (*hsa_ext_sampler_create_v2)( + hsa_agent_t agent, + const hsa_ext_sampler_descriptor_v2_t *sampler_descriptor, + hsa_ext_sampler_t *sampler); + } hsa_ext_images_1_pfn_t; /** @} */