@@ -913,21 +913,7 @@ inline std::pair<image_data, sampling_info> &get_img_info_map(
913913 img_info_map;
914914 return img_info_map[handle];
915915}
916- inline image_mem_wrapper *&get_img_mem_map (
917- const sycl::ext::oneapi::experimental::sampled_image_handle handle) {
918- static std::map<sycl::ext::oneapi::experimental::sampled_image_handle,
919- image_mem_wrapper *, sampled_image_handle_compare>
920- img_mem_map;
921- return img_mem_map[handle];
922- }
923916
924- inline image_mem_wrapper *&get_img_mem_map (
925- const sycl::ext::oneapi::experimental::unsampled_image_handle handle) {
926- static std::map<sycl::ext::oneapi::experimental::unsampled_image_handle,
927- image_mem_wrapper *, sampled_image_handle_compare>
928- img_mem_map;
929- return img_mem_map[handle];
930- }
931917static inline size_t
932918get_ele_size (const sycl::ext::oneapi::experimental::image_descriptor &decs) {
933919 size_t channel_size;
@@ -1185,6 +1171,56 @@ inline bool check_duplicate_entries(int count, T **entries) {
11851171}
11861172} // namespace detail
11871173
1174+ // / Get image_mem_wrapper according to sampled image handle.
1175+ // / \param [in] handle The bindless image handle.
1176+ // / \returns The image_mem_wrapper of sampled image.
1177+ inline image_mem_wrapper *&get_img_mem (
1178+ const sycl::ext::oneapi::experimental::sampled_image_handle handle) {
1179+ static std::map<sycl::ext::oneapi::experimental::sampled_image_handle,
1180+ image_mem_wrapper *, detail::sampled_image_handle_compare>
1181+ img_mem_map;
1182+ return img_mem_map[handle];
1183+ }
1184+
1185+ // / Get image_mem_wrapper according to unsampled image handle.
1186+ // / \param [in] handle The unsampled bindless image handle.
1187+ // / \returns The image_mem_wrapper of unsampled image.
1188+ inline image_mem_wrapper *&get_img_mem (
1189+ const sycl::ext::oneapi::experimental::unsampled_image_handle handle) {
1190+ static std::map<sycl::ext::oneapi::experimental::unsampled_image_handle,
1191+ image_mem_wrapper *, detail::sampled_image_handle_compare>
1192+ img_mem_map;
1193+ return img_mem_map[handle];
1194+ }
1195+
1196+ // / Associate an image memory wrapper with a bindless unsampled image handle in
1197+ // / the global registry.
1198+ // /
1199+ // / Inserts or updates an entry in the internal image memory map, using the
1200+ // / specified bindless unsampled image handle as the key and the provided image
1201+ // / memory wrapper as the mapped value.
1202+ // / \param [in] handle The unsampled bindless image handle.
1203+ // / \param [in] img_mem The image_mem_wrapper associated with the unsampled handle.
1204+ static inline void set_img_mem (
1205+ const sycl::ext::oneapi::experimental::unsampled_image_handle handle,
1206+ image_mem_wrapper *img_mem) {
1207+ dpct::experimental::get_img_mem (handle) = img_mem;
1208+ }
1209+
1210+ // / Associate an image memory wrapper with a bindless sampled image handle in
1211+ // / the global registry.
1212+ // /
1213+ // / Inserts or updates an entry in the internal image memory map, using the
1214+ // / specified bindless unsampled image handle as the key and the provided image
1215+ // / memory wrapper as the mapped value.
1216+ // / \param [in] handle The sampled bindless image handle.
1217+ // / \param [in] img_mem The image_mem_wrapper associated with the sampled handle.
1218+ static inline void set_img_mem (
1219+ const sycl::ext::oneapi::experimental::sampled_image_handle handle,
1220+ image_mem_wrapper *img_mem) {
1221+ dpct::experimental::get_img_mem (handle) = img_mem;
1222+ }
1223+
11881224#ifdef _WIN32
11891225// / Map the resource memories to mem handles
11901226// / \param [in] count The count of resources to map.
@@ -1393,7 +1429,7 @@ create_bindless_image(image_data data, sampling_info info,
13931429 data.get_channel (), data.get_x () / data.get_channel ().get_total_size ());
13941430 auto img = sycl::ext::oneapi::experimental::create_image (
13951431 mem->get_handle (), samp, mem->get_desc (), q);
1396- detail::get_img_mem_map (img) = mem;
1432+ set_img_mem (img, mem) ;
13971433 auto ptr = data.get_data_ptr ();
13981434#ifdef DPCT_USM_LEVEL_NONE
13991435 q.ext_oneapi_copy (get_buffer (ptr).get_host_access ().get_pointer (),
@@ -1411,7 +1447,7 @@ create_bindless_image(image_data data, sampling_info info,
14111447 new image_mem_wrapper (data.get_channel (), data.get_x (), data.get_y ());
14121448 auto img = sycl::ext::oneapi::experimental::create_image (
14131449 mem->get_handle (), samp, mem->get_desc (), q);
1414- detail::get_img_mem_map (img) = mem;
1450+ set_img_mem (img, mem) ;
14151451 q.ext_oneapi_copy (
14161452 get_buffer (data.get_data_ptr ()).get_host_access ().get_pointer (),
14171453 mem->get_handle (), mem->get_desc ())
@@ -1455,7 +1491,7 @@ create_bindless_image(image_data data, sycl::queue q = get_default_queue()) {
14551491 data.get_channel (), data.get_x () / data.get_channel ().get_total_size ());
14561492 auto img = sycl::ext::oneapi::experimental::create_image (
14571493 mem->get_handle (), mem->get_desc (), q);
1458- detail::get_img_mem_map (img) = mem;
1494+ set_img_mem (img, mem) ;
14591495 auto ptr = data.get_data_ptr ();
14601496#ifdef DPCT_USM_LEVEL_NONE
14611497 q.ext_oneapi_copy (get_buffer (ptr).get_host_access ().get_pointer (),
@@ -1471,7 +1507,7 @@ create_bindless_image(image_data data, sycl::queue q = get_default_queue()) {
14711507 new image_mem_wrapper (data.get_channel (), data.get_x (), data.get_y ());
14721508 auto img = sycl::ext::oneapi::experimental::create_image (
14731509 mem->get_handle (), mem->get_desc (), q);
1474- detail::get_img_mem_map (img) = mem;
1510+ set_img_mem (img, mem) ;
14751511#ifdef DPCT_USM_LEVEL_NONE
14761512 q.ext_oneapi_copy (
14771513 get_buffer (data.get_data_ptr ()).get_host_access ().get_pointer (),
@@ -1505,7 +1541,7 @@ create_bindless_image(image_data data, sycl::queue q = get_default_queue()) {
15051541template <class T >
15061542static inline void destroy_bindless_image (T handle,
15071543 sycl::queue q = get_default_queue()) {
1508- auto &mem = detail::get_img_mem_map (handle);
1544+ auto &mem = get_img_mem (handle);
15091545 if (mem) {
15101546 delete mem;
15111547 mem = nullptr ;
@@ -1556,7 +1592,7 @@ class bindless_image_wrapper_base {
15561592 auto mem = new image_mem_wrapper (channel, size);
15571593 _img = sycl::ext::oneapi::experimental::create_image (
15581594 mem->get_handle (), samp, mem->get_desc (), q);
1559- detail::get_img_mem_map (_img) = mem;
1595+ set_img_mem (_img, mem) ;
15601596 auto ptr = data;
15611597#ifdef DPCT_USM_LEVEL_NONE
15621598 q.ext_oneapi_copy (get_buffer (data).get_host_access ().get_pointer (),
@@ -1590,7 +1626,7 @@ class bindless_image_wrapper_base {
15901626 auto mem = new image_mem_wrapper (desc);
15911627 _img = sycl::ext::oneapi::experimental::create_image (mem->get_handle (),
15921628 samp, *desc, q);
1593- detail::get_img_mem_map (_img) = mem;
1629+ set_img_mem (_img, mem) ;
15941630 q.ext_oneapi_copy (get_buffer (ptr).get_host_access ().get_pointer (),
15951631 mem->get_handle (), mem->get_desc ())
15961632 .wait ();
@@ -1760,7 +1796,7 @@ class bindless_image_wrapper_base {
17601796 // / Get mipmap memory wrapper attached the bindless image
17611797 // / \return The mipmap memory wrapper
17621798 inline image_mem_wrapper *get_attached_mipmap_data (void ) {
1763- auto mem = detail::get_img_mem_map (_img);
1799+ auto mem = get_img_mem (_img);
17641800
17651801 if (mem->get_image_type () !=
17661802 sycl::ext::oneapi::experimental::image_type::mipmap)
0 commit comments