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 "../common.h"
|
||||||
#include "test_cl_ext_image_buffer.hpp"
|
#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(
|
static int get_image_requirement_alignment(
|
||||||
cl_device_id device, cl_context context, cl_mem_flags flags,
|
cl_device_id device, cl_context context, cl_mem_flags flags,
|
||||||
const cl_image_format* image_format, const cl_image_desc* image_desc,
|
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;
|
return TEST_SKIPPED_ITSELF;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cl_mem_object_type> imageTypes{
|
cl_uint row_pitch_alignment_2d = 0;
|
||||||
CL_MEM_OBJECT_IMAGE1D, CL_MEM_OBJECT_IMAGE2D,
|
cl_int err = clGetDeviceInfo(device, CL_DEVICE_IMAGE_PITCH_ALIGNMENT,
|
||||||
CL_MEM_OBJECT_IMAGE3D, CL_MEM_OBJECT_IMAGE1D_BUFFER,
|
sizeof(row_pitch_alignment_2d),
|
||||||
CL_MEM_OBJECT_IMAGE1D_ARRAY, CL_MEM_OBJECT_IMAGE2D_ARRAY
|
&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,
|
std::vector<cl_mem_flags> flagTypes{ CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY,
|
||||||
CL_MEM_READ_WRITE,
|
CL_MEM_READ_WRITE,
|
||||||
@@ -91,55 +99,43 @@ int image2d_from_buffer_positive(cl_device_id device, cl_context context,
|
|||||||
|
|
||||||
for (auto flagType : flagTypes)
|
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, CL_MEM_OBJECT_IMAGE2D, formatList,
|
||||||
|
flagType)
|
||||||
|
|| formatList.size() == 0)
|
||||||
{
|
{
|
||||||
/* Get the list of supported image formats */
|
test_fail("Failure to get supported formats list\n");
|
||||||
std::vector<cl_image_format> formatList;
|
}
|
||||||
if (TEST_PASS
|
|
||||||
!= get_format_list(context, imageType, formatList, flagType)
|
for (auto format : formatList)
|
||||||
|| formatList.size() == 0)
|
{
|
||||||
|
cl_image_desc image_desc = { 0 };
|
||||||
|
image_desc_init(&image_desc, CL_MEM_OBJECT_IMAGE2D);
|
||||||
|
|
||||||
|
cl_mem_flags flag = (flagType == CL_MEM_KERNEL_READ_AND_WRITE)
|
||||||
|
? CL_MEM_READ_WRITE
|
||||||
|
: flagType;
|
||||||
|
|
||||||
|
size_t row_pitch_alignment = 0;
|
||||||
|
size_t base_address_alignment = 0;
|
||||||
|
|
||||||
|
int get_error = get_image_requirement_alignment(
|
||||||
|
device, context, flag, &format, &image_desc,
|
||||||
|
&row_pitch_alignment, nullptr, &base_address_alignment);
|
||||||
|
if (TEST_PASS != get_error)
|
||||||
{
|
{
|
||||||
test_fail("Failure to get supported formats list\n");
|
return get_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
cl_uint row_pitch_alignment_2d = 0;
|
const size_t element_size =
|
||||||
cl_int err =
|
get_format_size(context, &format, CL_MEM_OBJECT_IMAGE2D, flag);
|
||||||
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;
|
if (is_power_of_two(element_size))
|
||||||
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 };
|
/* Alignments in pixels vs bytes */
|
||||||
image_desc_init(&image_desc, imageType);
|
|
||||||
|
|
||||||
cl_mem_flags flag = (flagType == CL_MEM_KERNEL_READ_AND_WRITE)
|
|
||||||
? CL_MEM_READ_WRITE
|
|
||||||
: flagType;
|
|
||||||
|
|
||||||
size_t row_pitch_alignment = 0;
|
|
||||||
size_t base_address_alignment = 0;
|
|
||||||
|
|
||||||
int get_error = get_image_requirement_alignment(
|
|
||||||
device, context, flag, &format, &image_desc,
|
|
||||||
&row_pitch_alignment, nullptr, &base_address_alignment);
|
|
||||||
if (TEST_PASS != get_error)
|
|
||||||
{
|
|
||||||
return get_error;
|
|
||||||
}
|
|
||||||
|
|
||||||
const size_t element_size =
|
|
||||||
get_format_size(context, &format, imageType, flag);
|
|
||||||
|
|
||||||
/* Alignements in pixels vs bytes */
|
|
||||||
if (base_address_alignment
|
if (base_address_alignment
|
||||||
> base_address_alignment_2d * element_size)
|
> base_address_alignment_2d * element_size)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user