Skip to content

Commit 69d0137

Browse files
committed
[SYCL][Bindless][UR] adding the image_color_space struct
1 parent 26ae9ea commit 69d0137

2 files changed

Lines changed: 19 additions & 13 deletions

File tree

sycl/include/sycl/ext/oneapi/bindless_images_descriptor.hpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ enum class image_type : unsigned int {
5151
cubemap = 3,
5252
gather = 4,
5353
};
54-
54+
/// image color space enum
55+
enum class image_color_space : uint32_t {
56+
linear = 0,
57+
srgb = 1,
58+
};
5559
/// A struct to describe the properties of an image.
5660
struct image_descriptor {
5761
size_t width{0};
@@ -62,7 +66,7 @@ struct image_descriptor {
6266
image_type type{image_type::standard};
6367
unsigned int num_levels{1};
6468
unsigned int array_size{1};
65-
std::optional<image_channel_order> channel_order;
69+
image_color_space color_space = image_color_space::linear;
6670
image_descriptor() = default;
6771

6872
image_descriptor(range<1> dims, unsigned int num_channels,
@@ -128,19 +132,18 @@ struct image_descriptor {
128132
throw sycl::exception(sycl::errc::invalid,
129133
"Images must have 1, 2, 3, or 4 channels.");
130134
}
131-
if (channel_order.has_value() &&
132-
channel_order.value() == image_channel_order::ext_oneapi_srgba) {
133-
if (num_channels != 4) {
135+
if (color_space == image_color_space::srgb) {
136+
if (num_channels != 4) {
134137
throw sycl::exception(
135138
sycl::errc::invalid,
136-
"ext_oneapi_srgba channel order requires num_channels == 4");
137-
}
138-
if (channel_type != image_channel_type::unorm_int8) {
139+
"sRGB color space requires num_channels == 4");
140+
}
141+
if (channel_type != image_channel_type::unorm_int8) {
139142
throw sycl::exception(
140143
sycl::errc::invalid,
141-
"ext_oneapi_srgba channel order requires unorm_int8 channel type");
142-
}
144+
"sRGB color space requires unorm_int8 channel type");
143145
}
146+
}
144147
switch (this->type) {
145148
case image_type::standard:
146149
if (this->array_size > 1) {

sycl/source/detail/bindless_images.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,13 @@ void populate_ur_structs(const image_descriptor &desc, ur_image_desc_t &urDesc,
5050

5151
urFormat = {};
5252
urFormat.channelType = sycl::detail::convertChannelType(desc.channel_type);
53-
urFormat.channelOrder =
54-
sycl::detail::convertChannelOrder(desc.channel_order.value_or(
53+
if (desc.color_space == image_color_space::srgb) {
54+
urFormat.channelOrder = UR_IMAGE_CHANNEL_ORDER_SRGBA;
55+
} else {
56+
urFormat.channelOrder = sycl::detail::convertChannelOrder(
5557
sycl::ext::oneapi::experimental::detail::
56-
get_image_default_channel_order(desc.num_channels)));
58+
get_image_default_channel_order(desc.num_channels));
59+
}
5760
}
5861

5962
detail::image_mem_impl::image_mem_impl(const image_descriptor &desc,

0 commit comments

Comments
 (0)