|
| 1 | +From 8e988b0da81d4113bc8a7891e62afad16d396b19 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alexey Sotkin < [email protected]> |
| 3 | +Date: Mon, 27 Jan 2020 12:25:03 +0300 |
| 4 | +Subject: [PATCH] Fix support for cl_khr_mipmap_image_writes |
| 5 | + |
| 6 | +Text of the extension is available here: |
| 7 | +https://github.com/KhronosGroup/OpenCL-Docs/blob/master/ext/cl_khr_mipmap_image.asciidoc |
| 8 | + |
| 9 | +Patch by Ilya Mashkov |
| 10 | + |
| 11 | +Differential Revision: https://reviews.llvm.org/D71460 |
| 12 | +--- |
| 13 | + include/clang/Basic/OpenCLExtensions.def | 1 + |
| 14 | + lib/Headers/opencl-c.h | 18 ++++++++++-------- |
| 15 | + test/SemaOpenCL/extension-version.cl | 12 ++++++++++++ |
| 16 | + 3 files changed, 23 insertions(+), 8 deletions(-) |
| 17 | + |
| 18 | +diff --git a/include/clang/Basic/OpenCLExtensions.def b/include/clang/Basic/OpenCLExtensions.def |
| 19 | +index 5e7d2cb..c0ba156 100644 |
| 20 | +--- a/include/clang/Basic/OpenCLExtensions.def |
| 21 | ++++ b/include/clang/Basic/OpenCLExtensions.def |
| 22 | +@@ -71,6 +71,7 @@ OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U) |
| 23 | + OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U) |
| 24 | + OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U) |
| 25 | + OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U) |
| 26 | ++OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U) |
| 27 | + OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U) |
| 28 | + OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U) |
| 29 | + OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U) |
| 30 | +diff --git a/lib/Headers/opencl-c.h b/lib/Headers/opencl-c.h |
| 31 | +index 3d3dfb7..514c710 100644 |
| 32 | +--- a/lib/Headers/opencl-c.h |
| 33 | ++++ b/lib/Headers/opencl-c.h |
| 34 | +@@ -15032,7 +15032,7 @@ void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, flo |
| 35 | + |
| 36 | + // OpenCL Extension v2.0 s9.18 - Mipmaps |
| 37 | + #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 |
| 38 | +-#ifdef cl_khr_mipmap_image |
| 39 | ++#if defined(cl_khr_mipmap_image_writes) |
| 40 | + void __ovld write_imagef(write_only image1d_t image, int coord, int lod, float4 color); |
| 41 | + void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 color); |
| 42 | + void __ovld write_imageui(write_only image1d_t image, int coord, int lod, uint4 color); |
| 43 | +@@ -15049,15 +15049,16 @@ void __ovld write_imagef(write_only image2d_array_t image_array, int4 coord, int |
| 44 | + void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, int lod, int4 color); |
| 45 | + void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, int lod, uint4 color); |
| 46 | + |
| 47 | +-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float color); |
| 48 | +-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float color); |
| 49 | ++void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float depth); |
| 50 | ++void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float depth); |
| 51 | + |
| 52 | + #ifdef cl_khr_3d_image_writes |
| 53 | + void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, float4 color); |
| 54 | + void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 color); |
| 55 | + void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color); |
| 56 | +-#endif |
| 57 | +-#endif //cl_khr_mipmap_image |
| 58 | ++#endif //cl_khr_3d_image_writes |
| 59 | ++ |
| 60 | ++#endif //defined(cl_khr_mipmap_image_writes) |
| 61 | + #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 |
| 62 | + |
| 63 | + // Image write functions for half4 type |
| 64 | +@@ -15106,7 +15107,7 @@ void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, flo |
| 65 | + #endif //cl_khr_depth_images |
| 66 | + |
| 67 | + #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0 |
| 68 | +-#ifdef cl_khr_mipmap_image |
| 69 | ++#if defined(cl_khr_mipmap_image_writes) |
| 70 | + void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color); |
| 71 | + void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color); |
| 72 | + void __ovld write_imageui(read_write image1d_t image, int coord, int lod, uint4 color); |
| 73 | +@@ -15130,8 +15131,9 @@ void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, int |
| 74 | + void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, float4 color); |
| 75 | + void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 color); |
| 76 | + void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 color); |
| 77 | +-#endif |
| 78 | +-#endif //cl_khr_mipmap_image |
| 79 | ++#endif //cl_khr_3d_image_writes |
| 80 | ++ |
| 81 | ++#endif //cl_khr_mipmap_image_writes |
| 82 | + #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0 |
| 83 | + |
| 84 | + // Image write functions for half4 type |
| 85 | +diff --git a/test/SemaOpenCL/extension-version.cl b/test/SemaOpenCL/extension-version.cl |
| 86 | +index d976cfb..dcac956 100644 |
| 87 | +--- a/test/SemaOpenCL/extension-version.cl |
| 88 | ++++ b/test/SemaOpenCL/extension-version.cl |
| 89 | +@@ -243,6 +243,18 @@ |
| 90 | + #pragma OPENCL EXTENSION cl_khr_mipmap_image : enable |
| 91 | + |
| 92 | + #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) |
| 93 | ++#ifndef cl_khr_mipmap_image_writes |
| 94 | ++#error "Missing cl_khr_mipmap_image_writes define" |
| 95 | ++#endif |
| 96 | ++#else |
| 97 | ++#ifdef cl_khr_mipmap_image_writes |
| 98 | ++#error "Incorrect cl_khr_mipmap_image_writes define" |
| 99 | ++#endif |
| 100 | ++// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image_writes' - ignoring}} |
| 101 | ++#endif |
| 102 | ++#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable |
| 103 | ++ |
| 104 | ++#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200) |
| 105 | + #ifndef cl_khr_srgb_image_writes |
| 106 | + #error "Missing cl_khr_srgb_image_writes define" |
| 107 | + #endif |
| 108 | +-- |
| 109 | +2.7.4 |
| 110 | + |
0 commit comments