mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
Image2d_from_buffer_positive comparison fix (#1569)
Only check against 2D image types as per the spec. Move some device checks out of the loop. Only perform the checks when element_size is a power of two. Signed-off-by: John Kesapides <john.kesapides@arm.com>
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include "../common.h"
|
||||
#include "test_cl_ext_image_buffer.hpp"
|
||||
|
||||
static inline bool is_power_of_two(size_t num) { return !(num & (num - 1)); }
|
||||
|
||||
static int get_image_requirement_alignment(
|
||||
cl_device_id device, cl_context context, cl_mem_flags flags,
|
||||
const cl_image_format* image_format, const cl_image_desc* image_desc,
|
||||
@@ -79,11 +81,17 @@ int image2d_from_buffer_positive(cl_device_id device, cl_context context,
|
||||
return TEST_SKIPPED_ITSELF;
|
||||
}
|
||||
|
||||
std::vector<cl_mem_object_type> imageTypes{
|
||||
CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE2D,
|
||||
CL_MEM_OBJECT_IMAGE3D, CL_MEM_OBJECT_IMAGE1D_BUFFER,
|
||||
CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY
|
||||
};
|
||||
cl_uint row_pitch_alignment_2d = 0;
|
||||
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
|
||||
sizeof(row_pitch_alignment_2d),
|
||||
&row_pitch_alignment_2d, nullptr);
|
||||
test_error(err, "Error clGetDeviceInfo");
|
||||
|
||||
cl_uint base_address_alignment_2d = 0;
|
||||
err = clGetDeviceInfo(device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
|
||||
sizeof(base_address_alignment_2d),
|
||||
&base_address_alignment_2d, nullptr);
|
||||
test_error(err, "Error clGetDeviceInfo");
|
||||
|
||||
std::vector<cl_mem_flags> flagTypes{ CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY,
|
||||
CL_MEM_READ_WRITE,
|
||||
@@ -91,35 +99,21 @@ int image2d_from_buffer_positive(cl_device_id device, cl_context context,
|
||||
|
||||
for (auto flagType : flagTypes)
|
||||
{
|
||||
for (auto imageType : imageTypes)
|
||||
{
|
||||
|
||||
/* Get the list of supported image formats */
|
||||
std::vector<cl_image_format> formatList;
|
||||
if (TEST_PASS
|
||||
!= get_format_list(context, imageType, formatList, flagType)
|
||||
!= get_format_list(context, CL_MEM_OBJECT_IMAGE2D, formatList,
|
||||
flagType)
|
||||
|| formatList.size() == 0)
|
||||
{
|
||||
test_fail("Failure to get supported formats list\n");
|
||||
}
|
||||
|
||||
cl_uint row_pitch_alignment_2d = 0;
|
||||
cl_int err =
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
|
||||
sizeof(row_pitch_alignment_2d),
|
||||
&row_pitch_alignment_2d, nullptr);
|
||||
test_error(err, "Error clGetDeviceInfo");
|
||||
|
||||
cl_uint base_address_alignment_2d = 0;
|
||||
err =
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT,
|
||||
sizeof(base_address_alignment_2d),
|
||||
&base_address_alignment_2d, nullptr);
|
||||
test_error(err, "Error clGetDeviceInfo");
|
||||
|
||||
for (auto format : formatList)
|
||||
{
|
||||
cl_image_desc image_desc = { 0 };
|
||||
image_desc_init(&image_desc, imageType);
|
||||
image_desc_init(&image_desc, CL_MEM_OBJECT_IMAGE2D);
|
||||
|
||||
cl_mem_flags flag = (flagType == CL_MEM_KERNEL_READ_AND_WRITE)
|
||||
? CL_MEM_READ_WRITE
|
||||
@@ -137,9 +131,11 @@ int image2d_from_buffer_positive(cl_device_id device, cl_context context,
|
||||
}
|
||||
|
||||
const size_t element_size =
|
||||
get_format_size(context, &format, imageType, flag);
|
||||
get_format_size(context, &format, CL_MEM_OBJECT_IMAGE2D, flag);
|
||||
|
||||
/* Alignements in pixels vs bytes */
|
||||
if (is_power_of_two(element_size))
|
||||
{
|
||||
/* Alignments in pixels vs bytes */
|
||||
if (base_address_alignment
|
||||
> base_address_alignment_2d * element_size)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user