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 =
"__kernel void sample_kernel( read_only %s input,%s __global float *xOffsets, __global float *yOffsets, __global %s%s *results %s)\n"
"{\n"
"%s"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
"%s\n"
"__kernel void sample_kernel( read_only %s input,%s __global float "
"*xOffsets, __global float *yOffsets, __global %s%s *results %s)\n"
"{\n"
"%s"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, imageSampler, coords %s);\n"
"}";
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"
"{\n"
"%s"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
"%s\n"
"__kernel void sample_kernel( read_write %s input,%s __global float "
"*xOffsets, __global float *yOffsets, __global %s%s *results %s)\n"
"{\n"
"%s"
" int tidX = get_global_id(0), tidY = get_global_id(1);\n"
"%s"
"%s"
" results[offset] = read_image%s( input, coords %s);\n"
"}";
const char *intCoordKernelSource =
" 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,
(format->image_channel_order == CL_DEPTH) ? "image2d_depth_t" : "image2d_t",
samplerArg, get_explicit_type_name( outputType ),
sprintf(programSrc, KernelSourcePattern,
gTestMipmaps
? "#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",
gTestMipmaps?", float lod":" ",
samplerVar,
gTestMipmaps? lodOffsetSource : offsetSource,
floatCoords ? floatKernelSource : intCoordKernelSource,
readFormat,
gTestMipmaps?", lod":" ");
gTestMipmaps ? ", float lod" : " ", samplerVar,
gTestMipmaps ? lodOffsetSource : offsetSource,
floatCoords ? floatKernelSource : intCoordKernelSource, readFormat,
gTestMipmaps ? ", lod" : " ");
ptr = programSrc;
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,