Enable mipmap extension pragmas (#1349)

* Enable mipmap pragmas where appopriate.

* clang-format changes.
This commit is contained in:
Jeremy Kemp
2022-05-17 16:52:40 +01:00
committed by GitHub
parent 6e6249fb48
commit d54954c7cf
10 changed files with 296 additions and 225 deletions

View File

@@ -39,24 +39,28 @@ static size_t reduceImageSizeRange(size_t maxDimSize) {
} }
const char *read2DKernelSourcePattern = const char *read2DKernelSourcePattern =
"__kernel void sample_kernel( read_only %s input,%s __global float *xOffsets, __global float *yOffsets, __global %s%s *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_only %s input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global %s%s *results %s)\n"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "{\n"
"%s" "%s"
"%s" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n" "%s"
"}"; "%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
const char *read_write2DKernelSourcePattern = const char *read_write2DKernelSourcePattern =
"__kernel void sample_kernel( read_write %s input,%s __global float *xOffsets, __global float *yOffsets, __global %s%s *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_write %s input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global %s%s *results %s)\n"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "{\n"
"%s" "%s"
"%s" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
" results[offset] = read_image%s( input, coords %s);\n" "%s"
"}"; "%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
const char *intCoordKernelSource = const char *intCoordKernelSource =
" int2 coords = (int2)( xOffsets[offset], yOffsets[offset]);\n"; " int2 coords = (int2)( xOffsets[offset], yOffsets[offset]);\n";
@@ -1691,16 +1695,18 @@ int test_read_image_set_2D(cl_device_id device, cl_context context,
} }
sprintf( programSrc, KernelSourcePattern, sprintf(programSrc, KernelSourcePattern,
(format->image_channel_order == CL_DEPTH) ? "image2d_depth_t" : "image2d_t", gTestMipmaps
samplerArg, get_explicit_type_name( outputType ), ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable"
: "",
(format->image_channel_order == CL_DEPTH) ? "image2d_depth_t"
: "image2d_t",
samplerArg, get_explicit_type_name(outputType),
(format->image_channel_order == CL_DEPTH) ? "" : "4", (format->image_channel_order == CL_DEPTH) ? "" : "4",
gTestMipmaps?", float lod":" ", gTestMipmaps ? ", float lod" : " ", samplerVar,
samplerVar, gTestMipmaps ? lodOffsetSource : offsetSource,
gTestMipmaps? lodOffsetSource : offsetSource, floatCoords ? floatKernelSource : intCoordKernelSource, readFormat,
floatCoords ? floatKernelSource : intCoordKernelSource, gTestMipmaps ? ", lod" : " ");
readFormat,
gTestMipmaps?", lod":" ");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -26,24 +26,28 @@
#endif #endif
const char *read1DKernelSourcePattern = const char *read1DKernelSourcePattern =
"__kernel void sample_kernel( read_only image1d_t input,%s __global float *xOffsets, __global %s4 *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_only image1d_t input,%s __global float "
"%s" "*xOffsets, __global %s4 *results %s)\n"
" int tidX = get_global_id(0);\n" "{\n"
" int offset = tidX;\n" "%s"
"%s" " int tidX = get_global_id(0);\n"
" results[offset] = read_image%s( input, imageSampler, coord %s);\n" " int offset = tidX;\n"
"}"; "%s"
" results[offset] = read_image%s( input, imageSampler, coord %s);\n"
"}";
const char *read_write1DKernelSourcePattern = const char *read_write1DKernelSourcePattern =
"__kernel void sample_kernel( read_write image1d_t input,%s __global float *xOffsets, __global %s4 *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_write image1d_t input,%s __global float "
"%s" "*xOffsets, __global %s4 *results %s)\n"
" int tidX = get_global_id(0);\n" "{\n"
" int offset = tidX;\n" "%s"
"%s" " int tidX = get_global_id(0);\n"
" results[offset] = read_image%s( input, coord %s);\n" " int offset = tidX;\n"
"}"; "%s"
" results[offset] = read_image%s( input, coord %s);\n"
"}";
const char *int1DCoordKernelSource = const char *int1DCoordKernelSource =
" int coord = xOffsets[offset];\n"; " int coord = xOffsets[offset];\n";
@@ -1075,14 +1079,14 @@ int test_read_image_set_1D(cl_device_id device, cl_context context,
{ {
KernelSourcePattern = read1DKernelSourcePattern; KernelSourcePattern = read1DKernelSourcePattern;
} }
sprintf( programSrc, sprintf(programSrc, KernelSourcePattern,
KernelSourcePattern, gTestMipmaps
samplerArg, get_explicit_type_name( outputType ), ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable"
gTestMipmaps ? ", float lod" : "", : "",
samplerVar, samplerArg, get_explicit_type_name(outputType),
gTestMipmaps ? ", float lod" : "", samplerVar,
floatCoords ? float1DKernelSource : int1DCoordKernelSource, floatCoords ? float1DKernelSource : int1DCoordKernelSource,
readFormat, readFormat, gTestMipmaps ? ", lod" : "");
gTestMipmaps ? ", lod" : "" );
ptr = programSrc; ptr = programSrc;

View File

@@ -25,24 +25,28 @@
#endif #endif
const char *read1DArrayKernelSourcePattern = const char *read1DArrayKernelSourcePattern =
"__kernel void sample_kernel( read_only image1d_array_t input,%s __global float *xOffsets, __global float *yOffsets, __global %s4 *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_only image1d_array_t input,%s __global "
"%s" "float *xOffsets, __global float *yOffsets, __global %s4 *results %s)\n"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "{\n"
"%s" "%s"
"%s" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n" "%s"
"}"; "%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
const char *read_write1DArrayKernelSourcePattern = const char *read_write1DArrayKernelSourcePattern =
"__kernel void sample_kernel( read_write image1d_array_t input,%s __global float *xOffsets, __global float *yOffsets, __global %s4 *results %s )\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_write image1d_array_t input,%s __global "
"%s" "float *xOffsets, __global float *yOffsets, __global %s4 *results %s )\n"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "{\n"
"%s" "%s"
"%s" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
" results[offset] = read_image%s( input, coords %s);\n" "%s"
"}"; "%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
const char *offset1DArrayKernelSource = const char *offset1DArrayKernelSource =
" int offset = tidY*get_image_width(input) + tidX;\n"; " int offset = tidY*get_image_width(input) + tidX;\n";
@@ -1180,15 +1184,15 @@ int test_read_image_set_1D_array(cl_device_id device, cl_context context,
KernelSourcePattern = read_write1DArrayKernelSourcePattern; KernelSourcePattern = read_write1DArrayKernelSourcePattern;
} }
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern,
samplerArg, get_explicit_type_name( outputType ), gTestMipmaps ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable"
gTestMipmaps ? ", float lod" : "", : "",
samplerVar, samplerArg, get_explicit_type_name(outputType),
gTestMipmaps ? offset1DArrayLodKernelSource : offset1DArrayKernelSource, gTestMipmaps ? ", float lod" : "", samplerVar,
floatCoords ? floatKernelSource1DArray : intCoordKernelSource1DArray, gTestMipmaps ? offset1DArrayLodKernelSource : offset1DArrayKernelSource,
readFormat, floatCoords ? floatKernelSource1DArray : intCoordKernelSource1DArray,
gTestMipmaps ? ", lod" : "" ); readFormat, gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -41,24 +41,32 @@ static size_t reduceImageDepth(size_t maxDepth) {
} }
const char *read2DArrayKernelSourcePattern = const char *read2DArrayKernelSourcePattern =
"__kernel void sample_kernel( read_only %s input,%s __global float *xOffsets, __global float *yOffsets, __global float *zOffsets, __global %s%s *results %s )\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_only %s input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global float *zOffsets, __global "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s%s *results %s )\n"
"%s" "{\n"
"%s" "%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
const char *read_write2DArrayKernelSourcePattern = const char *read_write2DArrayKernelSourcePattern =
"__kernel void sample_kernel( read_write %s input,%s __global float *xOffsets, __global float *yOffsets, __global float *zOffsets, __global %s%s *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_write %s input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global float *zOffsets, __global "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s%s *results %s)\n"
"%s" "{\n"
"%s" "%s"
" results[offset] = read_image%s( input, coords %s);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
const char* offset2DarraySource =" int offset = tidZ*get_image_width(input)*get_image_height(input) + tidY*get_image_width(input) + tidX;\n"; const char* offset2DarraySource =" int offset = tidZ*get_image_width(input)*get_image_height(input) + tidY*get_image_width(input) + tidX;\n";
const char* offset2DarraySourceLod = const char* offset2DarraySourceLod =
@@ -1412,17 +1420,16 @@ int test_read_image_set_2D_array(cl_device_id device, cl_context context,
} }
// Construct the source // Construct the source
sprintf( programSrc, sprintf(programSrc, KernelSourcePattern,
KernelSourcePattern, gTestMipmaps
imageType, ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable"
samplerArg, get_explicit_type_name( outputType ), : "",
imageElement, imageType, samplerArg, get_explicit_type_name(outputType),
gTestMipmaps ? ", float lod" : " ", imageElement, gTestMipmaps ? ", float lod" : " ", samplerVar,
samplerVar,
gTestMipmaps ? offset2DarraySourceLod : offset2DarraySource, gTestMipmaps ? offset2DarraySourceLod : offset2DarraySource,
floatCoords ? float2DArrayUnnormalizedCoordKernelSource : int2DArrayCoordKernelSource, floatCoords ? float2DArrayUnnormalizedCoordKernelSource
readFormat, : int2DArrayCoordKernelSource,
gTestMipmaps ? ", lod" : " " ); readFormat, gTestMipmaps ? ", lod" : " ");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -36,24 +36,32 @@ static size_t reduceImageDepth(size_t maxDimSize, RandomSeed& seed) {
const char *read3DKernelSourcePattern = const char *read3DKernelSourcePattern =
"__kernel void sample_kernel( read_only image3d_t input,%s __global float *xOffsets, __global float *yOffsets, __global float *zOffsets, __global %s4 *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_only image3d_t input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global float *zOffsets, __global "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s4 *results %s)\n"
"%s" "{\n"
"%s" "%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
const char *read_write3DKernelSourcePattern = const char *read_write3DKernelSourcePattern =
"__kernel void sample_kernel( read_write image3d_t input,%s __global float *xOffsets, __global float *yOffsets, __global float *zOffsets, __global %s4 *results %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( read_write image3d_t input,%s __global float "
"%s" "*xOffsets, __global float *yOffsets, __global float *zOffsets, __global "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s4 *results %s)\n"
"%s" "{\n"
"%s" "%s"
" results[offset] = read_image%s( input, coords %s);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
const char *offset3DKernelSource = const char *offset3DKernelSource =
" int offset = tidZ*get_image_width(input)*get_image_height(input) + tidY*get_image_width(input) + tidX;\n"; " int offset = tidZ*get_image_width(input)*get_image_height(input) + tidY*get_image_width(input) + tidX;\n";
@@ -137,15 +145,16 @@ int test_read_image_set_3D(cl_device_id device, cl_context context,
KernelSourcePattern = read_write3DKernelSourcePattern; KernelSourcePattern = read_write3DKernelSourcePattern;
} }
sprintf( programSrc, sprintf(programSrc, KernelSourcePattern,
KernelSourcePattern, gTestMipmaps
samplerArg, get_explicit_type_name( outputType ), ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable"
gTestMipmaps? ", float lod": " ", : "",
samplerVar, samplerArg, get_explicit_type_name(outputType),
gTestMipmaps? offset3DLodKernelSource: offset3DKernelSource, gTestMipmaps ? ", float lod" : " ", samplerVar,
floatCoords ? float3DUnnormalizedCoordKernelSource : int3DCoordKernelSource, gTestMipmaps ? offset3DLodKernelSource : offset3DKernelSource,
readFormat, floatCoords ? float3DUnnormalizedCoordKernelSource
gTestMipmaps? ",lod":" "); : int3DCoordKernelSource,
readFormat, gTestMipmaps ? ",lod" : " ");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -27,20 +27,24 @@ extern bool validate_float_write_results( float *expected, float *actual, image_
extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor* imageInfo ); extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor* imageInfo );
const char *readwrite1DKernelSourcePattern = const char *readwrite1DKernelSourcePattern =
"__kernel void sample_kernel( __global %s4 *input, read_write image1d_t output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, read_write image1d_t "
" int tidX = get_global_id(0);\n" "output %s)\n"
" int offset = tidX;\n" "{\n"
" write_image%s( output, tidX %s, input[ offset ]);\n" " int tidX = get_global_id(0);\n"
"}"; " int offset = tidX;\n"
" write_image%s( output, tidX %s, input[ offset ]);\n"
"}";
const char *write1DKernelSourcePattern = const char *write1DKernelSourcePattern =
"__kernel void sample_kernel( __global %s4 *input, write_only image1d_t output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, write_only image1d_t "
" int tidX = get_global_id(0);\n" "output %s)\n"
" int offset = tidX;\n" "{\n"
" write_image%s( output, tidX %s, input[ offset ]);\n" " int tidX = get_global_id(0);\n"
"}"; " int offset = tidX;\n"
" write_image%s( output, tidX %s, input[ offset ]);\n"
"}";
int test_write_image_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_kernel kernel, int test_write_image_1D( cl_device_id device, cl_context context, cl_command_queue queue, cl_kernel kernel,
image_descriptor *imageInfo, ExplicitType inputType, MTdata d ) image_descriptor *imageInfo, ExplicitType inputType, MTdata d )
@@ -614,12 +618,14 @@ int test_write_image_1D_set(cl_device_id device, cl_context context,
KernelSourcePattern = readwrite1DKernelSourcePattern; KernelSourcePattern = readwrite1DKernelSourcePattern;
} }
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern,
get_explicit_type_name( inputType ), gTestMipmaps
gTestMipmaps ? ", int lod" : "", ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable\n#pragma "
readFormat, "OPENCL EXTENSION cl_khr_mipmap_image_writes: enable"
gTestMipmaps ? ", lod" :"" ); : "",
get_explicit_type_name(inputType), gTestMipmaps ? ", int lod" : "",
readFormat, gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -27,20 +27,24 @@ extern bool validate_float_write_results( float *expected, float *actual, image_
extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo ); extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo );
const char *readwrite1DArrayKernelSourcePattern = const char *readwrite1DArrayKernelSourcePattern =
"__kernel void sample_kernel( __global %s4 *input, read_write image1d_array_t output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, read_write "
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "image1d_array_t output %s)\n"
"%s" "{\n"
" write_image%s( output, (int2)( tidX, tidY )%s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"}"; "%s"
" write_image%s( output, (int2)( tidX, tidY )%s, input[ offset ]);\n"
"}";
const char *write1DArrayKernelSourcePattern = const char *write1DArrayKernelSourcePattern =
"__kernel void sample_kernel( __global %s4 *input, write_only image1d_array_t output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, write_only "
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "image1d_array_t output %s)\n"
"%s" "{\n"
" write_image%s( output, (int2)( tidX, tidY ) %s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"}"; "%s"
" write_image%s( output, (int2)( tidX, tidY ) %s, input[ offset ]);\n"
"}";
const char *offset1DArraySource = const char *offset1DArraySource =
" int offset = tidY*get_image_width(output) + tidX;\n"; " int offset = tidY*get_image_width(output) + tidX;\n";
@@ -637,13 +641,15 @@ int test_write_image_1D_array_set(cl_device_id device, cl_context context,
} }
// Construct the source // Construct the source
// Construct the source // Construct the source
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern,
get_explicit_type_name( inputType ), gTestMipmaps
gTestMipmaps ? ", int lod" : "", ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable\n#pragma "
gTestMipmaps ? offset1DArrayLodSource : offset1DArraySource, "OPENCL EXTENSION cl_khr_mipmap_image_writes: enable"
readFormat, : "",
gTestMipmaps ? ", lod" :"" ); get_explicit_type_name(inputType), gTestMipmaps ? ", int lod" : "",
gTestMipmaps ? offset1DArrayLodSource : offset1DArraySource, readFormat,
gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -49,20 +49,28 @@ static size_t reduceImageDepth(size_t maxDepth) {
} }
const char *write2DArrayKernelSourcePattern = const char *write2DArrayKernelSourcePattern =
"__kernel void sample_kernel( __global %s%s *input, write_only %s output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s%s *input, write_only %s output "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s)\n"
"%s" "{\n"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset "
"]);\n"
"}";
const char *readwrite2DArrayKernelSourcePattern = const char *readwrite2DArrayKernelSourcePattern =
"__kernel void sample_kernel( __global %s%s *input, read_write %s output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s%s *input, read_write %s output "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "%s)\n"
"%s" "{\n"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset ] );\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset "
"] );\n"
"}";
const char *offset2DArrayKernelSource = const char *offset2DArrayKernelSource =
" int offset = tidZ*get_image_width(output)*get_image_height(output) + tidY*get_image_width(output) + tidX;\n"; " int offset = tidZ*get_image_width(output)*get_image_height(output) + tidY*get_image_width(output) + tidX;\n";
@@ -671,15 +679,19 @@ int test_write_image_2D_array_set(cl_device_id device, cl_context context,
} }
// Construct the source // Construct the source
// Construct the source // Construct the source
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern,
get_explicit_type_name( inputType ), gTestMipmaps
(format->image_channel_order == CL_DEPTH) ? "" : "4", ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable\n#pragma "
(format->image_channel_order == CL_DEPTH) ? "image2d_array_depth_t" : "image2d_array_t", "OPENCL EXTENSION cl_khr_mipmap_image_writes: enable"
gTestMipmaps ? " , int lod" : "", : "",
gTestMipmaps ? offset2DArrayLodKernelSource : offset2DArrayKernelSource, get_explicit_type_name(inputType),
readFormat, (format->image_channel_order == CL_DEPTH) ? "" : "4",
gTestMipmaps ? ", lod" : "" ); (format->image_channel_order == CL_DEPTH) ? "image2d_array_depth_t"
: "image2d_array_t",
gTestMipmaps ? " , int lod" : "",
gTestMipmaps ? offset2DArrayLodKernelSource : offset2DArrayKernelSource,
readFormat, gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -46,22 +46,30 @@ static size_t reduceImageDepth(size_t maxDimSize, MTdata& seed) {
const char *write3DKernelSourcePattern = const char *write3DKernelSourcePattern =
"%s" "%s"
"__kernel void sample_kernel( __global %s4 *input, write_only image3d_t output %s )\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, write_only image3d_t "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "output %s )\n"
"%s" "{\n"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset "
"]);\n"
"}";
const char *readwrite3DKernelSourcePattern = const char *readwrite3DKernelSourcePattern =
"%s" "%s"
"__kernel void sample_kernel( __global %s4 *input, read_write image3d_t output %s )\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s4 *input, read_write image3d_t "
" int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = get_global_id(2);\n" "output %s )\n"
"%s" "{\n"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1), tidZ = "
"}"; "get_global_id(2);\n"
"%s"
" write_image%s( output, (int4)( tidX, tidY, tidZ, 0 ) %s, input[ offset "
"]);\n"
"}";
const char *khr3DWritesPragma = const char *khr3DWritesPragma =
"#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable\n"; "#pragma OPENCL EXTENSION cl_khr_3d_image_writes : enable\n";
@@ -678,14 +686,15 @@ int test_write_image_3D_set(cl_device_id device, cl_context context,
} }
// Construct the source // Construct the source
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern, khr3DWritesPragma,
gTestMipmaps ? "" : khr3DWritesPragma, gTestMipmaps
get_explicit_type_name( inputType ), ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable\n#pragma "
gTestMipmaps ? ", int lod" : "", "OPENCL EXTENSION cl_khr_mipmap_image_writes: enable"
gTestMipmaps ? offset3DLodSource : offset3DSource, : "",
readFormat, get_explicit_type_name(inputType), gTestMipmaps ? ", int lod" : "",
gTestMipmaps ? ", lod" : "" ); gTestMipmaps ? offset3DLodSource : offset3DSource, readFormat,
gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,

View File

@@ -47,20 +47,24 @@ extern bool validate_float_write_results( float *expected, float *actual, image_
extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo ); extern bool validate_half_write_results( cl_half *expected, cl_half *actual, image_descriptor *imageInfo );
const char *writeKernelSourcePattern = const char *writeKernelSourcePattern =
"__kernel void sample_kernel( __global %s%s *input, write_only %s output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s%s *input, write_only %s output "
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "%s)\n"
"%s" "{\n"
" write_image%s( output, (int2)( tidX, tidY ) %s, input[ offset ]);\n" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"}"; "%s"
" write_image%s( output, (int2)( tidX, tidY ) %s, input[ offset ]);\n"
"}";
const char *read_writeKernelSourcePattern = const char *read_writeKernelSourcePattern =
"__kernel void sample_kernel( __global %s%s *input, read_write %s output %s)\n" "%s\n"
"{\n" "__kernel void sample_kernel( __global %s%s *input, read_write %s output "
" int tidX = get_global_id(0), tidY = get_global_id(1);\n" "%s)\n"
"%s" "{\n"
" write_image%s( output, (int2)( tidX, tidY )%s, input[ offset ] );\n" " int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"}"; "%s"
" write_image%s( output, (int2)( tidX, tidY )%s, input[ offset ] );\n"
"}";
const char *offset2DKernelSource = const char *offset2DKernelSource =
" int offset = tidY*get_image_width(output) + tidX;\n"; " int offset = tidY*get_image_width(output) + tidX;\n";
@@ -728,15 +732,19 @@ int test_write_image_set(cl_device_id device, cl_context context,
} }
// Construct the source // Construct the source
sprintf( programSrc, sprintf(
KernelSourcePattern, programSrc, KernelSourcePattern,
get_explicit_type_name( inputType ), gTestMipmaps
(format->image_channel_order == CL_DEPTH) ? "" : "4", ? "#pragma OPENCL EXTENSION cl_khr_mipmap_image: enable\n#pragma "
(format->image_channel_order == CL_DEPTH) ? "image2d_depth_t" : "image2d_t", "OPENCL EXTENSION cl_khr_mipmap_image_writes: enable"
gTestMipmaps ? ", int lod" : "", : "",
gTestMipmaps ? offset2DLodKernelSource : offset2DKernelSource, get_explicit_type_name(inputType),
readFormat, (format->image_channel_order == CL_DEPTH) ? "" : "4",
gTestMipmaps ? ", lod" : "" ); (format->image_channel_order == CL_DEPTH) ? "image2d_depth_t"
: "image2d_t",
gTestMipmaps ? ", int lod" : "",
gTestMipmaps ? offset2DLodKernelSource : offset2DKernelSource,
readFormat, gTestMipmaps ? ", lod" : "");
ptr = programSrc; ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr, error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,