Raw10/12 CTS tests (#1830)

Add support for cl_ext_image_raw10_raw12 testing
on test_image_streams.

Signed-off-by: John Kesapides <john.kesapides@arm.com>
This commit is contained in:
John Kesapides
2024-05-21 16:44:28 +01:00
committed by GitHub
parent 0353c0bdbe
commit fb39357911
7 changed files with 196 additions and 11 deletions

View File

@@ -202,6 +202,8 @@ const char *GetChannelTypeName(cl_channel_type type)
case CL_SFIXED14_APPLE: return "CL_SFIXED14_APPLE";
#endif
case CL_UNORM_INT24: return "CL_UNORM_INT24";
case CL_UNSIGNED_INT_RAW10_EXT: return "CL_UNSIGNED_INT_RAW10_EXT";
case CL_UNSIGNED_INT_RAW12_EXT: return "CL_UNSIGNED_INT_RAW12_EXT";
default: return NULL;
}
}

View File

@@ -288,6 +288,9 @@ uint32_t get_pixel_size(const cl_image_format *format)
return get_format_channel_count(format) * sizeof(cl_float);
case CL_UNORM_INT_101010_2: return 4;
case CL_UNSIGNED_INT_RAW10_EXT:
case CL_UNSIGNED_INT_RAW12_EXT: return 2;
default: return 0;
}
}

View File

@@ -191,6 +191,42 @@ cl_uint compute_max_mip_levels(size_t width, size_t height, size_t depth);
cl_ulong compute_mipmapped_image_size(image_descriptor imageInfo);
size_t compute_mip_level_offset(image_descriptor *imageInfo, size_t lod);
constexpr size_t RAW10_EXT_CLUMP_SIZE = 5;
constexpr size_t RAW10_EXT_CLUMP_NUM_PIXELS = 4;
constexpr size_t RAW12_EXT_CLUMP_SIZE = 3;
constexpr size_t RAW12_EXT_CLUMP_NUM_PIXELS = 2;
inline bool is_width_compatible(image_descriptor imageInfo)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT
&& (imageInfo.width % RAW10_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT
&& (imageInfo.width % RAW12_EXT_CLUMP_NUM_PIXELS) != 0)
{
return false;
}
return true;
}
inline size_t calculate_row_pitch(image_descriptor imageInfo, size_t pixelSize)
{
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW10_EXT)
{
return (imageInfo.width * RAW10_EXT_CLUMP_SIZE)
/ RAW10_EXT_CLUMP_NUM_PIXELS;
}
if (imageInfo.format->image_channel_data_type == CL_UNSIGNED_INT_RAW12_EXT)
{
return (imageInfo.width * RAW12_EXT_CLUMP_SIZE)
/ RAW12_EXT_CLUMP_NUM_PIXELS;
}
return imageInfo.width * pixelSize;
}
template <class T>
void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
int y, int z, T *outData, int lod)
@@ -255,10 +291,24 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
// Advance to the right spot
char *ptr = (char *)imageData;
size_t pixelSize = get_pixel_size(format);
ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;
switch (format->image_channel_data_type)
{
case CL_UNSIGNED_INT_RAW10_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW10_EXT_CLUMP_NUM_PIXELS) * RAW10_EXT_CLUMP_SIZE;
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
ptr += z * slice_pitch_lod + y * row_pitch_lod
+ (x / RAW12_EXT_CLUMP_NUM_PIXELS) * RAW12_EXT_CLUMP_SIZE;
break;
}
default: {
size_t pixelSize = get_pixel_size(format);
ptr += z * slice_pitch_lod + y * row_pitch_lod + x * pixelSize;
break;
}
}
// OpenCL only supports reading floats from certain formats
switch (format->image_channel_data_type)
{
@@ -377,6 +427,26 @@ void read_image_pixel(void *imageData, image_descriptor *imageInfo, int x,
break;
}
#endif
case CL_UNSIGNED_INT_RAW10_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW10_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 1;
uint16_t hi_val = dPtr[i] << 2;
uint16_t lo_val = (dPtr[4] & (0x3 << bit_index)) >> bit_index;
tempData[0] = (T)(hi_val | lo_val);
break;
}
case CL_UNSIGNED_INT_RAW12_EXT: {
cl_uchar *dPtr = (cl_uchar *)ptr;
i = x % RAW12_EXT_CLUMP_NUM_PIXELS;
uint8_t bit_index = i << 2;
uint16_t hi_val = dPtr[i] << 4;
uint16_t lo_val = (dPtr[2] & (0xF << bit_index)) >> bit_index;
tempData[0] = (T)(hi_val | lo_val);
break;
}
}