From 3992a26e84dddfdb4b0c3029392e58a277488140 Mon Sep 17 00:00:00 2001 From: Sean Stirling Date: Tue, 17 Oct 2023 14:21:10 +0100 Subject: [PATCH 1/5] [Bindless][CUDA] Add support for cubemaps Add enum to ur_mem_type_t to represent cubemap image type Add device aspects for cubemap support: - UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP - UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP Add structs/enums for cubemap sampling: - ur_exp_sampler_cubemap_properties_t struct to enable seamless filtering between cubemap faces - ur_exp_sampler_cubemap_filter_mode_t enum to enable distinguishing between cubemap seamless filtering options --- include/ur_api.h | 48 +++++++++-- include/ur_print.h | 16 ++++ include/ur_print.hpp | 86 +++++++++++++++++++ scripts/core/EXP-BINDLESS-IMAGES.rst | 15 ++++ scripts/core/exp-bindless-images.yml | 41 +++++++++ source/adapters/cuda/device.cpp | 8 ++ source/adapters/cuda/image.cpp | 21 ++++- source/adapters/cuda/sampler.cpp | 5 ++ source/adapters/cuda/sampler.hpp | 8 +- source/loader/layers/validation/ur_valddi.cpp | 2 +- source/loader/ur_libapi.cpp | 2 +- source/loader/ur_print.cpp | 16 ++++ source/ur_api.cpp | 2 +- tools/urinfo/urinfo.hpp | 5 ++ 14 files changed, 260 insertions(+), 15 deletions(-) diff --git a/include/ur_api.h b/include/ur_api.h index 13e84bcdda..7f59e15f6e 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -278,6 +278,7 @@ typedef enum ur_structure_type_t { UR_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR = 0x2003, ///< ::ur_exp_file_descriptor_t UR_STRUCTURE_TYPE_EXP_WIN32_HANDLE = 0x2004, ///< ::ur_exp_win32_handle_t UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES = 0x2005, ///< ::ur_exp_sampler_addr_modes_t + UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES = 0x2006, ///< ::ur_exp_sampler_cubemap_properties_t /// @cond UR_STRUCTURE_TYPE_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1625,6 +1626,10 @@ typedef enum ur_device_info_t { ///< semaphore resources UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP = 0x200F, ///< [::ur_bool_t] returns true if the device supports exporting internal ///< event resources + UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP = 0x2010, ///< [::ur_bool_t] returns true if the device supports allocating and + ///< accessing cubemap resources + UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP = 0x2011, ///< [::ur_bool_t] returns true if the device supports sampling cubemapped + ///< images across face boundaries /// @cond UR_DEVICE_INFO_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -1650,7 +1655,7 @@ typedef enum ur_device_info_t { /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName` +/// + `::UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE @@ -2421,13 +2426,14 @@ typedef enum ur_mem_flag_t { /////////////////////////////////////////////////////////////////////////////// /// @brief Memory types typedef enum ur_mem_type_t { - UR_MEM_TYPE_BUFFER = 0, ///< Buffer object - UR_MEM_TYPE_IMAGE2D = 1, ///< 2D image object - UR_MEM_TYPE_IMAGE3D = 2, ///< 3D image object - UR_MEM_TYPE_IMAGE2D_ARRAY = 3, ///< 2D image array object - UR_MEM_TYPE_IMAGE1D = 4, ///< 1D image object - UR_MEM_TYPE_IMAGE1D_ARRAY = 5, ///< 1D image array object - UR_MEM_TYPE_IMAGE1D_BUFFER = 6, ///< 1D image buffer object + UR_MEM_TYPE_BUFFER = 0, ///< Buffer object + UR_MEM_TYPE_IMAGE2D = 1, ///< 2D image object + UR_MEM_TYPE_IMAGE3D = 2, ///< 3D image object + UR_MEM_TYPE_IMAGE2D_ARRAY = 3, ///< 2D image array object + UR_MEM_TYPE_IMAGE1D = 4, ///< 1D image object + UR_MEM_TYPE_IMAGE1D_ARRAY = 5, ///< 1D image array object + UR_MEM_TYPE_IMAGE1D_BUFFER = 6, ///< 1D image buffer object + UR_MEM_TYPE_IMAGE_CUBEMAP_EXP = 0x2000, ///< Experimental cubemap image object /// @cond UR_MEM_TYPE_FORCE_UINT32 = 0x7fffffff /// @endcond @@ -7241,6 +7247,17 @@ typedef enum ur_exp_image_copy_flag_t { /// @brief Bit Mask for validating ur_exp_image_copy_flags_t #define UR_EXP_IMAGE_COPY_FLAGS_MASK 0xfffffff8 +/////////////////////////////////////////////////////////////////////////////// +/// @brief Sampler cubemap seamless filtering mode. +typedef enum ur_exp_sampler_cubemap_filter_mode_t { + UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_DISJOINTED = 0, ///< Disable seamless filtering + UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_SEAMLESS = 1, ///< Enable Seamless filtering + /// @cond + UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_FORCE_UINT32 = 0x7fffffff + /// @endcond + +} ur_exp_sampler_cubemap_filter_mode_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief File descriptor typedef struct ur_exp_file_descriptor_t { @@ -7295,6 +7312,21 @@ typedef struct ur_exp_sampler_addr_modes_t { } ur_exp_sampler_addr_modes_t; +/////////////////////////////////////////////////////////////////////////////// +/// @brief Describes cubemap sampler properties +/// +/// @details +/// - Specify these properties in ::urSamplerCreate via ::ur_sampler_desc_t +/// as part of a `pNext` chain. +typedef struct ur_exp_sampler_cubemap_properties_t { + ur_structure_type_t stype; ///< [in] type of this structure, must be + ///< ::UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES + void *pNext; ///< [in,out][optional] pointer to extension-specific structure + ur_exp_sampler_cubemap_filter_mode_t cubemapFilterMode; ///< [in] enables or disables seamless cubemap filtering between cubemap + ///< faces + +} ur_exp_sampler_cubemap_properties_t; + /////////////////////////////////////////////////////////////////////////////// /// @brief Describes an interop memory resource descriptor typedef struct ur_exp_interop_mem_desc_t { diff --git a/include/ur_print.h b/include/ur_print.h index ae80817092..ecb85cb519 100644 --- a/include/ur_print.h +++ b/include/ur_print.h @@ -882,6 +882,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintUsmMigrationFlags(enum ur_usm_migrati /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL urPrintExpImageCopyFlags(enum ur_exp_image_copy_flag_t value, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_sampler_cubemap_filter_mode_t enum +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintExpSamplerCubemapFilterMode(enum ur_exp_sampler_cubemap_filter_mode_t value, char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_exp_file_descriptor_t struct /// @returns @@ -914,6 +922,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urPrintExpSamplerMipProperties(const struct /// - `buff_size < out_size` UR_APIEXPORT ur_result_t UR_APICALL urPrintExpSamplerAddrModes(const struct ur_exp_sampler_addr_modes_t params, char *buffer, const size_t buff_size, size_t *out_size); +/////////////////////////////////////////////////////////////////////////////// +/// @brief Print ur_exp_sampler_cubemap_properties_t struct +/// @returns +/// - ::UR_RESULT_SUCCESS +/// - ::UR_RESULT_ERROR_INVALID_SIZE +/// - `buff_size < out_size` +UR_APIEXPORT ur_result_t UR_APICALL urPrintExpSamplerCubemapProperties(const struct ur_exp_sampler_cubemap_properties_t params, char *buffer, const size_t buff_size, size_t *out_size); + /////////////////////////////////////////////////////////////////////////////// /// @brief Print ur_exp_interop_mem_desc_t struct /// @returns diff --git a/include/ur_print.hpp b/include/ur_print.hpp index a773af3166..07df5a1874 100644 --- a/include/ur_print.hpp +++ b/include/ur_print.hpp @@ -320,10 +320,12 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_execution_info_t value inline std::ostream &operator<<(std::ostream &os, enum ur_map_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_usm_migration_flag_t value); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_image_copy_flag_t value); +inline std::ostream &operator<<(std::ostream &os, enum ur_exp_sampler_cubemap_filter_mode_t value); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_file_descriptor_t params); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_win32_handle_t params); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_sampler_mip_properties_t params); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_sampler_addr_modes_t params); +inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_sampler_cubemap_properties_t params); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_interop_mem_desc_t params); inline std::ostream &operator<<(std::ostream &os, [[maybe_unused]] const struct ur_exp_interop_semaphore_desc_t params); inline std::ostream &operator<<(std::ostream &os, enum ur_exp_command_buffer_info_t value); @@ -1068,6 +1070,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_structure_type_t value case UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES: os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES"; break; + case UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES: + os << "UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES"; + break; default: os << "unknown enumerator"; break; @@ -1319,6 +1324,11 @@ inline ur_result_t printStruct(std::ostream &os, const void *ptr) { const ur_exp_sampler_addr_modes_t *pstruct = (const ur_exp_sampler_addr_modes_t *)ptr; printPtr(os, pstruct); } break; + + case UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES: { + const ur_exp_sampler_cubemap_properties_t *pstruct = (const ur_exp_sampler_cubemap_properties_t *)ptr; + printPtr(os, pstruct); + } break; default: os << "unknown enumerator"; return UR_RESULT_ERROR_INVALID_ENUMERATION; @@ -2546,6 +2556,12 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_device_info_t value) { case UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP: os << "UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP"; break; + case UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP: + os << "UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP"; + break; + case UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP: + os << "UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP"; + break; default: os << "unknown enumerator"; break; @@ -4150,6 +4166,30 @@ inline ur_result_t printTagged(std::ostream &os, const void *ptr, ur_device_info os << ")"; } break; + case UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return UR_RESULT_ERROR_INVALID_SIZE; + } + os << (const void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; + case UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP: { + const ur_bool_t *tptr = (const ur_bool_t *)ptr; + if (sizeof(ur_bool_t) > size) { + os << "invalid size (is: " << size << ", expected: >=" << sizeof(ur_bool_t) << ")"; + return UR_RESULT_ERROR_INVALID_SIZE; + } + os << (const void *)(tptr) << " ("; + + os << *tptr; + + os << ")"; + } break; default: os << "unknown enumerator"; return UR_RESULT_ERROR_INVALID_ENUMERATION; @@ -5326,6 +5366,9 @@ inline std::ostream &operator<<(std::ostream &os, enum ur_mem_type_t value) { case UR_MEM_TYPE_IMAGE1D_BUFFER: os << "UR_MEM_TYPE_IMAGE1D_BUFFER"; break; + case UR_MEM_TYPE_IMAGE_CUBEMAP_EXP: + os << "UR_MEM_TYPE_IMAGE_CUBEMAP_EXP"; + break; default: os << "unknown enumerator"; break; @@ -9137,6 +9180,24 @@ inline ur_result_t printFlag(std::ostream &os, uint32_ } } // namespace ur::details /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_sampler_cubemap_filter_mode_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, enum ur_exp_sampler_cubemap_filter_mode_t value) { + switch (value) { + case UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_DISJOINTED: + os << "UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_DISJOINTED"; + break; + case UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_SEAMLESS: + os << "UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_SEAMLESS"; + break; + default: + os << "unknown enumerator"; + break; + } + return os; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_exp_file_descriptor_t type /// @returns /// std::ostream & @@ -9259,6 +9320,31 @@ inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_sampler_ad return os; } /////////////////////////////////////////////////////////////////////////////// +/// @brief Print operator for the ur_exp_sampler_cubemap_properties_t type +/// @returns +/// std::ostream & +inline std::ostream &operator<<(std::ostream &os, const struct ur_exp_sampler_cubemap_properties_t params) { + os << "(struct ur_exp_sampler_cubemap_properties_t){"; + + os << ".stype = "; + + os << (params.stype); + + os << ", "; + os << ".pNext = "; + + ur::details::printStruct(os, + (params.pNext)); + + os << ", "; + os << ".cubemapFilterMode = "; + + os << (params.cubemapFilterMode); + + os << "}"; + return os; +} +/////////////////////////////////////////////////////////////////////////////// /// @brief Print operator for the ur_exp_interop_mem_desc_t type /// @returns /// std::ostream & diff --git a/scripts/core/EXP-BINDLESS-IMAGES.rst b/scripts/core/EXP-BINDLESS-IMAGES.rst index fe6a1ac32b..af90c1ea0f 100644 --- a/scripts/core/EXP-BINDLESS-IMAGES.rst +++ b/scripts/core/EXP-BINDLESS-IMAGES.rst @@ -50,6 +50,7 @@ Runtime: * Sampled images * Unsampled images * Mipmaps + * Cubemaps * USM backed images * Interoperability support @@ -69,6 +70,7 @@ Enums ${X}_STRUCTURE_TYPE_EXP_FILE_DESCRIPTOR ${X}_STRUCTURE_TYPE_EXP_WIN32_HANDLE ${X}_STRUCTURE_TYPE_EXP_SAMPLER_ADDR_MODES + ${X}_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES * ${x}_device_info_t * ${X}_DEVICE_INFO_BINDLESS_IMAGES_SUPPORT_EXP @@ -87,6 +89,8 @@ Enums * ${X}_DEVICE_INFO_INTEROP_MEMORY_EXPORT_SUPPORT_EXP * ${X}_DEVICE_INFO_INTEROP_SEMAPHORE_IMPORT_SUPPORT_EXP * ${X}_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP + * ${X}_DEVICE_INFO_CUBEMAP_SUPPORT_EXP + * ${X}_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP * ${x}_command_t * ${X}_COMMAND_INTEROP_SEMAPHORE_WAIT_EXP @@ -97,6 +101,10 @@ Enums * ${X}_EXP_IMAGE_COPY_FLAG_DEVICE_TO_HOST * ${X}_EXP_IMAGE_COPY_FLAG_DEVICE_TO_DEVICE +* ${x}_exp_sampler_cubemap_filter_mode_t + * ${X}_EXP_SAMPLER_CUBEMAP_FILTER_MODE_SEAMLESS + * ${X}_EXP_SAMPLER_CUBEMAP_FILTER_MODE_DISJOINTED + * ${x}_function_t * ${X}_FUNCTION_USM_PITCHED_ALLOC_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_UNSAMPLED_IMAGE_HANDLE_DESTROY_EXP @@ -117,6 +125,9 @@ Enums * ${X}_FUNCTION_BINDLESS_IMAGES_WAIT_EXTERNAL_SEMAPHORE_EXP * ${X}_FUNCTION_BINDLESS_IMAGES_SIGNAL_EXTERNAL_SEMAPHORE_EXP +* ${x}_mem_type_t + * ${X}_MEM_TYPE_IMAGE_CUBEMAP_EXP + Types ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * ${x}_exp_sampler_mip_properties_t @@ -129,6 +140,7 @@ Types * ${x}_exp_file_descriptor_t * ${x}_exp_win32_handle_t * ${x}_exp_sampler_addr_modes_t +* ${x}_exp_sampler_cubemap_properties_t Functions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -184,6 +196,9 @@ Changelog +------------------------------------------------------------------------+ | 9.0 | Remove layered image properties struct. | +------------------------------------------------------------------------+ +| 10.0 | Added cubemap image type, sampling properties, and device | +| | queries. | ++----------+-------------------------------------------------------------+ Contributors -------------------------------------------------------------------------------- diff --git a/scripts/core/exp-bindless-images.yml b/scripts/core/exp-bindless-images.yml index d2e508c4a7..a6f17b1a74 100644 --- a/scripts/core/exp-bindless-images.yml +++ b/scripts/core/exp-bindless-images.yml @@ -86,6 +86,12 @@ etors: - name: INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP value: "0x200F" desc: "[$x_bool_t] returns true if the device supports exporting internal event resources" + - name: CUBEMAP_SUPPORT_EXP + value: "0x2010" + desc: "[$x_bool_t] returns true if the device supports allocating and accessing cubemap resources" + - name: CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP + value: "0x2011" + desc: "[$x_bool_t] returns true if the device supports sampling cubemapped images across face boundaries" --- #-------------------------------------------------------------------------- type: enum extend: true @@ -110,6 +116,9 @@ etors: - name: EXP_SAMPLER_ADDR_MODES desc: $x_exp_sampler_addr_modes_t value: "0x2005" + - name: EXP_SAMPLER_CUBEMAP_PROPERTIES + desc: $x_exp_sampler_cubemap_properties_t + value: "0x2006" --- #-------------------------------------------------------------------------- type: enum extend: true @@ -135,6 +144,25 @@ etors: - name: DEVICE_TO_DEVICE desc: "Device to device" --- #-------------------------------------------------------------------------- +type: enum +extend: True +desc: "Memory types" +name: $x_mem_type_t +etors: + - name: IMAGE_CUBEMAP_EXP + value: "0x2000" + desc: "Experimental cubemap image object" +--- #-------------------------------------------------------------------------- +type: enum +desc: "Sampler cubemap seamless filtering mode." +class: $xBindlessImages +name: $x_exp_sampler_cubemap_filter_mode_t +etors: + - name: DISJOINTED + desc: "Disable seamless filtering" + - name: SEAMLESS + desc: "Enable Seamless filtering" +--- #-------------------------------------------------------------------------- type: struct desc: "File descriptor" name: $x_exp_file_descriptor_t @@ -189,6 +217,19 @@ members: desc: "[in] Specify the address mode of the sampler per dimension" --- #-------------------------------------------------------------------------- type: struct +desc: "Describes cubemap sampler properties" +details: + - Specify these properties in $xSamplerCreate via $x_sampler_desc_t as part + of a `pNext` chain. +class: $xBindlessImages +name: $x_exp_sampler_cubemap_properties_t +base: $x_base_properties_t +members: + - type: $x_exp_sampler_cubemap_filter_mode_t + name: cubemapFilterMode + desc: "[in] enables or disables seamless cubemap filtering between cubemap faces" +--- #-------------------------------------------------------------------------- +type: struct desc: "Describes an interop memory resource descriptor" class: $xBindlessImages name: $x_exp_interop_mem_desc_t diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index 56addc4eef..69665fb456 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -917,6 +917,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice, // CUDA does not support exporting semaphores or events. return ReturnValue(false); } + case UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP: { + // CUDA supports cubemaps. + return ReturnValue(true); + } + case UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP: { + // CUDA supports cubemap seamless filtering. + return ReturnValue(true); + } case UR_DEVICE_INFO_DEVICE_ID: { int Value = 0; UR_CHECK_ERROR(cuDeviceGetAttribute( diff --git a/source/adapters/cuda/image.cpp b/source/adapters/cuda/image.cpp index 8d2610626e..b9cc832a02 100644 --- a/source/adapters/cuda/image.cpp +++ b/source/adapters/cuda/image.cpp @@ -244,7 +244,8 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, /// Sampler property layout: /// | | /// ----------------------------------- - /// | 31 30 ... 12 | N/A + /// | 31 30 ... 13 | N/A + /// | 12 | cubemap filter mode /// | 11 | mip filter mode /// | 10 9 8 | addressing mode 3 /// | 7 6 5 | addressing mode 2 @@ -306,6 +307,13 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler, // This flag prevents this behaviour. ImageTexDesc.flags |= CU_TRSF_READ_AS_INTEGER; + // Cubemap attributes + ur_exp_sampler_cubemap_filter_mode_t CubemapFilterModeProp = + hSampler->getCubemapFilterMode(); + if (CubemapFilterModeProp == UR_EXP_SAMPLER_CUBEMAP_FILTER_MODE_SEAMLESS) { + ImageTexDesc.flags |= CU_TRSF_SEAMLESS_CUBEMAP; + } + CUtexObject Texture; UR_CHECK_ERROR( cuTexObjectCreate(&Texture, &ResourceDesc, &ImageTexDesc, nullptr)); @@ -418,6 +426,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageAllocateExp( array_desc.Depth = pImageDesc->arraySize; array_desc.Flags |= CUDA_ARRAY3D_LAYERED; break; + case UR_MEM_TYPE_IMAGE_CUBEMAP_EXP: + array_desc.Height = pImageDesc->height; + array_desc.Depth = pImageDesc->arraySize; // Should be 6 ONLY + array_desc.Flags |= CUDA_ARRAY3D_CUBEMAP; + break; default: return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -715,7 +728,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( cpy_desc.Depth = copyExtent.depth; UR_CHECK_ERROR(cuMemcpy3DAsync(&cpy_desc, Stream)); } else if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY || - pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { + pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY || + pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { CUDA_MEMCPY3D cpy_desc = {}; cpy_desc.srcXInBytes = srcOffset.x * PixelSizeBytes; cpy_desc.srcY = srcOffset.y; @@ -798,7 +812,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urBindlessImagesImageCopyExp( cpy_desc.Depth = copyExtent.depth; UR_CHECK_ERROR(cuMemcpy3DAsync(&cpy_desc, Stream)); } else if (pImageDesc->type == UR_MEM_TYPE_IMAGE1D_ARRAY || - pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY) { + pImageDesc->type == UR_MEM_TYPE_IMAGE2D_ARRAY || + pImageDesc->type == UR_MEM_TYPE_IMAGE_CUBEMAP_EXP) { CUDA_MEMCPY3D cpy_desc = {}; cpy_desc.srcXInBytes = srcOffset.x; cpy_desc.srcY = srcOffset.y; diff --git a/source/adapters/cuda/sampler.cpp b/source/adapters/cuda/sampler.cpp index bbbf9d86f0..904c529fd2 100644 --- a/source/adapters/cuda/sampler.cpp +++ b/source/adapters/cuda/sampler.cpp @@ -44,6 +44,11 @@ urSamplerCreate(ur_context_handle_t hContext, const ur_sampler_desc_t *pDesc, Sampler->Props |= SamplerAddrModes->addrModes[0] << 2; Sampler->Props |= SamplerAddrModes->addrModes[1] << 5; Sampler->Props |= SamplerAddrModes->addrModes[2] << 8; + } else if (BaseDesc->stype == + UR_STRUCTURE_TYPE_EXP_SAMPLER_CUBEMAP_PROPERTIES) { + const ur_exp_sampler_cubemap_properties_t *SamplerCubemapProperties = + reinterpret_cast(pNext); + Sampler->Props |= SamplerCubemapProperties->cubemapFilterMode << 12; } pNext = const_cast(BaseDesc->pNext); } diff --git a/source/adapters/cuda/sampler.hpp b/source/adapters/cuda/sampler.hpp index 11121e3ecf..4823541c73 100644 --- a/source/adapters/cuda/sampler.hpp +++ b/source/adapters/cuda/sampler.hpp @@ -15,7 +15,8 @@ /// Sampler property layout: /// | | /// ----------------------------------- -/// | 31 30 ... 12 | N/A +/// | 31 30 ... 13 | N/A +/// | 12 | cubemap filter mode /// | 11 | mip filter mode /// | 10 9 8 | addressing mode 3 /// | 7 6 5 | addressing mode 2 @@ -60,4 +61,9 @@ struct ur_sampler_handle_t_ { ur_sampler_filter_mode_t getMipFilterMode() const noexcept { return static_cast((Props >> 11) & 0b1); } + + ur_exp_sampler_cubemap_filter_mode_t getCubemapFilterMode() const noexcept { + return static_cast((Props >> 12) & + 0b1); + } }; diff --git a/source/loader/layers/validation/ur_valddi.cpp b/source/loader/layers/validation/ur_valddi.cpp index 54793995c4..c3b009a724 100644 --- a/source/loader/layers/validation/ur_valddi.cpp +++ b/source/loader/layers/validation/ur_valddi.cpp @@ -496,7 +496,7 @@ __urdlllocal ur_result_t UR_APICALL urDeviceGetInfo( return UR_RESULT_ERROR_INVALID_NULL_POINTER; } - if (UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName) { + if (UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP < propName) { return UR_RESULT_ERROR_INVALID_ENUMERATION; } diff --git a/source/loader/ur_libapi.cpp b/source/loader/ur_libapi.cpp index 6c18993c51..01cc285752 100644 --- a/source/loader/ur_libapi.cpp +++ b/source/loader/ur_libapi.cpp @@ -842,7 +842,7 @@ ur_result_t UR_APICALL urDeviceGetSelected( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName` +/// + `::UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE diff --git a/source/loader/ur_print.cpp b/source/loader/ur_print.cpp index 7facba104f..9c3b6f1277 100644 --- a/source/loader/ur_print.cpp +++ b/source/loader/ur_print.cpp @@ -887,6 +887,14 @@ ur_result_t urPrintExpImageCopyFlags(enum ur_exp_image_copy_flag_t value, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintExpSamplerCubemapFilterMode( + enum ur_exp_sampler_cubemap_filter_mode_t value, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << value; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintExpFileDescriptor(const struct ur_exp_file_descriptor_t params, char *buffer, const size_t buff_size, @@ -921,6 +929,14 @@ urPrintExpSamplerAddrModes(const struct ur_exp_sampler_addr_modes_t params, return str_copy(&ss, buffer, buff_size, out_size); } +ur_result_t urPrintExpSamplerCubemapProperties( + const struct ur_exp_sampler_cubemap_properties_t params, char *buffer, + const size_t buff_size, size_t *out_size) { + std::stringstream ss; + ss << params; + return str_copy(&ss, buffer, buff_size, out_size); +} + ur_result_t urPrintExpInteropMemDesc(const struct ur_exp_interop_mem_desc_t params, char *buffer, const size_t buff_size, diff --git a/source/ur_api.cpp b/source/ur_api.cpp index 8765880c21..e3b1ba0481 100644 --- a/source/ur_api.cpp +++ b/source/ur_api.cpp @@ -736,7 +736,7 @@ ur_result_t UR_APICALL urDeviceGetSelected( /// - ::UR_RESULT_ERROR_INVALID_NULL_HANDLE /// + `NULL == hDevice` /// - ::UR_RESULT_ERROR_INVALID_ENUMERATION -/// + `::UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP < propName` +/// + `::UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP < propName` /// - ::UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION /// + If `propName` is not supported by the adapter. /// - ::UR_RESULT_ERROR_INVALID_SIZE diff --git a/tools/urinfo/urinfo.hpp b/tools/urinfo/urinfo.hpp index 15894cafb8..9745eed6cb 100644 --- a/tools/urinfo/urinfo.hpp +++ b/tools/urinfo/urinfo.hpp @@ -378,5 +378,10 @@ inline void printDeviceInfos(ur_device_handle_t hDevice, std::cout << prefix; printDeviceInfo( hDevice, UR_DEVICE_INFO_INTEROP_SEMAPHORE_EXPORT_SUPPORT_EXP); + std::cout << prefix; + printDeviceInfo(hDevice, UR_DEVICE_INFO_CUBEMAP_SUPPORT_EXP); + std::cout << prefix; + printDeviceInfo( + hDevice, UR_DEVICE_INFO_CUBEMAP_SEAMLESS_FILTERING_SUPPORT_EXP); } } // namespace urinfo From 2ad811022b7fccfdc8d9ab38d112436f16d05336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Tue, 2 Apr 2024 15:04:30 +0200 Subject: [PATCH 2/5] Bump jinja and its dependencies' versions and add comment about xz-utils. --- third_party/deps.yml | 1 + third_party/requirements.txt | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/third_party/deps.yml b/third_party/deps.yml index af9e48ebbb..80c2fa109c 100644 --- a/third_party/deps.yml +++ b/third_party/deps.yml @@ -33,6 +33,7 @@ dependencies: - openssl=3.1.1 - pkg-config=0.29.2 - rhash=1.4.3 + # don't upgrade xz utils due to CVE-2024-3094 - xz=5.2.6 - zlib=1.2.13 - zstd=1.5.2 diff --git a/third_party/requirements.txt b/third_party/requirements.txt index e2bb3bdcd3..0211d29d6b 100644 --- a/third_party/requirements.txt +++ b/third_party/requirements.txt @@ -12,10 +12,10 @@ docutils==0.15.2 exhale==0.3.0 idna==2.8 imagesize==1.1.0 -Jinja2==2.11.3 +Jinja2==3.1.3 lxml==4.9.3 Mako==1.3.0 -MarkupSafe==1.1.1 +MarkupSafe==2.1.5 packaging==19.2 Pygments==2.17.2 pyparsing==2.4.5 From 38b984919b7e83de64917b2a0926ce0028b37f2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stolarczuk?= Date: Fri, 9 Feb 2024 17:18:45 +0100 Subject: [PATCH 3/5] Remove redundant semicolons It's only to silence errors, found on gcc in Ubuntu 20.04: "error: extra ';' [-Werror=pedantic] --- test/conformance/testing/include/uur/raii.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/conformance/testing/include/uur/raii.h b/test/conformance/testing/include/uur/raii.h index e664f491c1..e4f456ec36 100644 --- a/test/conformance/testing/include/uur/raii.h +++ b/test/conformance/testing/include/uur/raii.h @@ -108,7 +108,7 @@ using Program = Wrapper; using Kernel = Wrapper; using Queue = Wrapper; using Event = Wrapper; -}; // namespace raii -}; // namespace uur +} // namespace raii +} // namespace uur #endif // UUR_RAII_H_INCLUDED From e548dc1ed556fb542cd7268e01fb573456bbc033 Mon Sep 17 00:00:00 2001 From: Martin Morrison-Grant Date: Mon, 8 Apr 2024 14:24:57 +0100 Subject: [PATCH 4/5] [CTS] Fix Coverity warning: Add a & before auto so object is not copied unnecessarily. --- test/conformance/usm/helpers.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/conformance/usm/helpers.h b/test/conformance/usm/helpers.h index e8176c13b1..26958208e3 100644 --- a/test/conformance/usm/helpers.h +++ b/test/conformance/usm/helpers.h @@ -19,8 +19,8 @@ inline std::string printUSMAllocTestString( const auto device_handle = std::get<0>(info.param); const auto platform_device_name = uur::GetPlatformAndDeviceName(device_handle); - const auto usmDeviceAllocParams = std::get<1>(info.param); - const auto BoolParam = std::get<0>(usmDeviceAllocParams); + const auto &usmDeviceAllocParams = std::get<1>(info.param); + const auto &BoolParam = std::get<0>(usmDeviceAllocParams); std::stringstream ss; ss << BoolParam.name << (BoolParam.value ? "Enabled" : "Disabled"); From 5c30079919c36e1b206a73fe9cd28b3f49193a08 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Mon, 8 Apr 2024 23:20:19 -0700 Subject: [PATCH 5/5] [OpenCL] Revert urMemBufferCreate extension function lookup error This commit reverts the urMemBufferCreate changes for returning function lookup error in https://github.com/oneapi-src/unified-runtime/pull/1448 as the function had a fallback path which is no longer taken. Signed-off-by: Larsen, Steffen --- source/adapters/opencl/memory.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/adapters/opencl/memory.cpp b/source/adapters/opencl/memory.cpp index 5de850f1e2..2397e2b5f9 100644 --- a/source/adapters/opencl/memory.cpp +++ b/source/adapters/opencl/memory.cpp @@ -232,11 +232,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemBufferCreate( clCreateBufferWithPropertiesINTEL_fn FuncPtr = nullptr; cl_context CLContext = cl_adapter::cast(hContext); // First we need to look up the function pointer - UR_RETURN_ON_FAILURE( + RetErr = cl_ext::getExtFuncFromContext( CLContext, cl_ext::ExtFuncPtrCache->clCreateBufferWithPropertiesINTELCache, - cl_ext::CreateBufferWithPropertiesName, &FuncPtr)); + cl_ext::CreateBufferWithPropertiesName, &FuncPtr); if (FuncPtr) { std::vector PropertiesIntel; auto Prop = static_cast(pProperties->pNext);