21 template <info::device Param>
24 return Value >= 1 &&
std::all_of(Devices.cbegin(), Devices.cend(),
25 [Value](
const device &Dev) {
26 return Value <= Dev.get_info<Param>();
30 template <
typename T,
typename... Args>
static bool checkAnyImpl(T) {
34 template <
typename ValT,
typename VarT,
typename... Args>
35 static bool checkAnyImpl(ValT Value, VarT Variant, Args... Arguments) {
36 return (Value == Variant) ? true :
checkAnyImpl(Value, Arguments...);
39 template <
typename T,
typename... Args>
40 static bool checkAny(
const T Value, Args... Arguments) {
46 case image_channel_order::a:
47 case image_channel_order::r:
48 case image_channel_order::rx:
49 case image_channel_order::intensity:
50 case image_channel_order::luminance:
52 case image_channel_order::rg:
53 case image_channel_order::rgx:
54 case image_channel_order::ra:
56 case image_channel_order::rgb:
58 case image_channel_order::rgbx:
59 case image_channel_order::rgba:
60 case image_channel_order::argb:
61 case image_channel_order::bgra:
62 case image_channel_order::abgr:
63 case image_channel_order::ext_oneapi_srgba:
66 assert(
false &&
"Unhandled image channel order");
74 case image_channel_type::snorm_int8:
75 case image_channel_type::unorm_int8:
76 case image_channel_type::signed_int8:
77 case image_channel_type::unsigned_int8:
80 case image_channel_type::snorm_int16:
81 case image_channel_type::unorm_int16:
82 case image_channel_type::signed_int16:
83 case image_channel_type::unsigned_int16:
84 case image_channel_type::fp16:
85 Retval = 2 * NumChannels;
87 case image_channel_type::signed_int32:
88 case image_channel_type::unsigned_int32:
89 case image_channel_type::fp32:
90 Retval = 4 * NumChannels;
92 case image_channel_type::unorm_short_565:
93 case image_channel_type::unorm_short_555:
96 case image_channel_type::unorm_int_101010:
103 assert(((Retval - 1) & Retval) == 0);
109 case image_channel_order::a:
111 case image_channel_order::r:
113 case image_channel_order::rx:
115 case image_channel_order::rg:
117 case image_channel_order::rgx:
119 case image_channel_order::ra:
121 case image_channel_order::rgb:
123 case image_channel_order::rgbx:
125 case image_channel_order::rgba:
127 case image_channel_order::argb:
129 case image_channel_order::bgra:
131 case image_channel_order::intensity:
133 case image_channel_order::luminance:
135 case image_channel_order::abgr:
137 case image_channel_order::ext_oneapi_srgba:
140 assert(
false &&
"Unhandled image_channel_order");
147 return image_channel_order::a;
149 return image_channel_order::r;
151 return image_channel_order::rx;
153 return image_channel_order::rg;
155 return image_channel_order::rgx;
157 return image_channel_order::ra;
159 return image_channel_order::rgb;
161 return image_channel_order::rgbx;
163 return image_channel_order::rgba;
165 return image_channel_order::argb;
167 return image_channel_order::bgra;
169 return image_channel_order::intensity;
171 return image_channel_order::luminance;
173 return image_channel_order::abgr;
175 return image_channel_order::ext_oneapi_srgba;
177 assert(
false &&
"Unhandled image_channel_order");
183 case image_channel_type::snorm_int8:
185 case image_channel_type::snorm_int16:
187 case image_channel_type::unorm_int8:
189 case image_channel_type::unorm_int16:
191 case image_channel_type::unorm_short_565:
193 case image_channel_type::unorm_short_555:
195 case image_channel_type::unorm_int_101010:
197 case image_channel_type::signed_int8:
199 case image_channel_type::signed_int16:
201 case image_channel_type::signed_int32:
203 case image_channel_type::unsigned_int8:
205 case image_channel_type::unsigned_int16:
207 case image_channel_type::unsigned_int32:
209 case image_channel_type::fp16:
211 case image_channel_type::fp32:
214 assert(
false &&
"Unhandled image_channel_order");
221 return image_channel_type::snorm_int8;
223 return image_channel_type::snorm_int16;
225 return image_channel_type::unorm_int8;
227 return image_channel_type::unorm_int16;
229 return image_channel_type::unorm_short_565;
231 return image_channel_type::unorm_short_555;
233 return image_channel_type::unorm_int_101010;
235 return image_channel_type::signed_int8;
237 return image_channel_type::signed_int16;
239 return image_channel_type::signed_int32;
241 return image_channel_type::unsigned_int8;
243 return image_channel_type::unsigned_int16;
245 return image_channel_type::unsigned_int32;
247 return image_channel_type::fp16;
249 return image_channel_type::fp32;
251 assert(
false &&
"Unhandled image_channel_order");
255 template <
typename T>
259 RT::PiMem Mem = pi::cast<RT::PiMem>(InteropMemObject);
264 template <
int Dimensions>
266 cl_mem MemObject,
const context &SyclContext,
event AvailableEvent,
267 std::unique_ptr<SYCLMemObjAllocator> Allocator)
268 :
BaseT(MemObject, SyclContext,
std::move(AvailableEvent),
269 std::move(Allocator)),
301 template <
int Dimensions>
303 bool InitFromUserData,
void *HostPtr,
305 bool HostPtrReadOnly =
false;
306 BaseT::determineHostPtr(Context, InitFromUserData, HostPtr, HostPtrReadOnly);
309 assert(checkImageDesc(Desc, Context, HostPtr) &&
310 "The check an image desc failed.");
313 assert(checkImageFormat(Format, Context) &&
314 "The check an image format failed.");
317 std::move(Context),
this, HostPtr, HostPtrReadOnly, BaseT::getSize(),
318 Desc, Format, BaseT::MInteropEvent, BaseT::MInteropContext, MProps,
322 template <
int Dimensions>
328 !checkImageValueRange<info::device::image2d_max_width>(
330 throw invalid_parameter_error(
331 "For a 1D/2D image/image array, the width must be a Value >= 1 and "
332 "<= info::device::image2d_max_width",
333 PI_ERROR_INVALID_VALUE);
336 !checkImageValueRange<info::device::image3d_max_width>(
338 throw invalid_parameter_error(
339 "For a 3D image, the width must be a Value >= 1 and <= "
340 "info::device::image3d_max_width",
341 PI_ERROR_INVALID_VALUE);
345 !checkImageValueRange<info::device::image2d_max_height>(
347 throw invalid_parameter_error(
"For a 2D image or image array, the height "
348 "must be a Value >= 1 and <= "
349 "info::device::image2d_max_height",
350 PI_ERROR_INVALID_VALUE);
353 !checkImageValueRange<info::device::image3d_max_height>(
355 throw invalid_parameter_error(
356 "For a 3D image, the heightmust be a Value >= 1 and <= "
357 "info::device::image3d_max_height",
358 PI_ERROR_INVALID_VALUE);
361 !checkImageValueRange<info::device::image3d_max_depth>(
363 throw invalid_parameter_error(
364 "For a 3D image, the depth must be a Value >= 1 and <= "
365 "info::device::image2d_max_depth",
366 PI_ERROR_INVALID_VALUE);
370 !checkImageValueRange<info::device::image_max_array_size>(
372 throw invalid_parameter_error(
373 "For a 1D and 2D image array, the array_size must be a "
374 "Value >= 1 and <= info::device::image_max_array_size.",
375 PI_ERROR_INVALID_VALUE);
378 throw invalid_parameter_error(
379 "The row_pitch must be 0 if host_ptr is nullptr.",
380 PI_ERROR_INVALID_VALUE);
383 throw invalid_parameter_error(
384 "The slice_pitch must be 0 if host_ptr is nullptr.",
385 PI_ERROR_INVALID_VALUE);
388 throw invalid_parameter_error(
"The mip_levels must be 0.",
389 PI_ERROR_INVALID_VALUE);
392 throw invalid_parameter_error(
"The num_samples must be 0.",
393 PI_ERROR_INVALID_VALUE);
395 if (
nullptr != Desc.
buffer)
396 throw invalid_parameter_error(
397 "The buffer must be nullptr, because SYCL does not support "
398 "image creation from memory objects.",
399 PI_ERROR_INVALID_VALUE);
404 template <
int Dimensions>
415 throw invalid_parameter_error(
416 "CL_INTENSITY or CL_LUMINANCE format can only be used if channel "
417 "data type = CL_UNORM_INT8, CL_UNORM_INT16, CL_SNORM_INT8, "
418 "CL_SNORM_INT16, CL_HALF_FLOAT, or CL_FLOAT.",
419 PI_ERROR_INVALID_VALUE);
427 throw invalid_parameter_error(
428 "type = CL_UNORM_SHORT_565, CL_UNORM_SHORT_555 or "
429 "CL_UNORM_INT_101010."
430 "These channel types can only be used with CL_RGB or CL_RGBx channel "
432 PI_ERROR_INVALID_VALUE);
440 throw invalid_parameter_error(
441 "CL_ARGB, CL_BGRA, CL_ABGR These formats can only be used if "
442 "channel data type = CL_UNORM_INT8, CL_SNORM_INT8, CL_SIGNED_INT8 "
443 "or CL_UNSIGNED_INT8.",
444 PI_ERROR_INVALID_VALUE);
449 template <
int Dimensions>
451 image_impl<Dimensions>::getDevices(
const ContextImplPtr Context) {
455 template class image_impl<1>;
456 template class image_impl<2>;
457 template class image_impl<3>;