Skip to content

Commit c1b0697

Browse files
committed
Add support for cl_khr_mipmap_image_writes
1 parent e604963 commit c1b0697

File tree

2 files changed

+110
-1
lines changed

2 files changed

+110
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ if(NOT USE_PREBUILT_LLVM)
8282

8383
if(NOT LLVM_EXTERNAL_CLANG_SOURCE_DIR)
8484
set(CLANG_SOURCE_DIR ${LLVM_SOURCE_DIR}/tools/clang)
85+
set(CLANG_BASE_REVISION origin/release_90)
8586
elseif(EXISTS "${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/CMakeLists.txt")
8687
set(CLANG_SOURCE_DIR "${LLVM_EXTERNAL_CLANG_SOURCE_DIR}")
88+
set(CLANG_BASE_REVISION origin/release/9.x)
8789
endif()
8890
if(EXISTS ${CLANG_SOURCE_DIR})
8991
message(STATUS "Using Clang source code direcotry: ${CLANG_SOURCE_DIR}")
@@ -118,7 +120,6 @@ if(NOT USE_PREBUILT_LLVM)
118120
)
119121
endif()
120122

121-
set(CLANG_BASE_REVISION master)
122123
set(SPIRV_BASE_REVISION master)
123124
set(TARGET_BRANCH "ocl-open-90")
124125

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
From 1ed55ebdc8181c67b9cf1cfa3a977f069413dd89 Mon Sep 17 00:00:00 2001
2+
From: Ilya Mashkov <[email protected]>
3+
Date: Thu, 12 Dec 2019 14:33:41 +0300
4+
Subject: [PATCH] Add support for cl_khr_mipmap_image_writes
5+
6+
---
7+
clang/include/clang/Basic/OpenCLExtensions.def | 1 +
8+
clang/lib/Headers/opencl-c.h | 22 ++++++++++++++--------
9+
clang/test/SemaOpenCL/extension-version.cl | 12 ++++++++++++
10+
3 files changed, 27 insertions(+), 8 deletions(-)
11+
12+
diff --git a/clang/include/clang/Basic/OpenCLExtensions.def b/clang/include/clang/Basic/OpenCLExtensions.def
13+
index 5536a6e..5174815 100644
14+
--- a/clang/include/clang/Basic/OpenCLExtensions.def
15+
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
16+
@@ -70,6 +70,7 @@ OPENCLEXT_INTERNAL(cl_khr_spir, 120, ~0U)
17+
OPENCLEXT_INTERNAL(cl_khr_egl_event, 200, ~0U)
18+
OPENCLEXT_INTERNAL(cl_khr_egl_image, 200, ~0U)
19+
OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
20+
+OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
21+
OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
22+
OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
23+
OPENCLEXT_INTERNAL(cl_khr_terminate_context, 200, ~0U)
24+
diff --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
25+
index 06c5ab6..d3ae0dd 100644
26+
--- a/clang/lib/Headers/opencl-c.h
27+
+++ b/clang/lib/Headers/opencl-c.h
28+
@@ -14682,7 +14682,8 @@ void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, flo
29+
30+
// OpenCL Extension v2.0 s9.18 - Mipmaps
31+
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
32+
-#ifdef cl_khr_mipmap_image
33+
+#if defined(cl_khr_mipmap_image_writes)
34+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
35+
void __ovld write_imagef(write_only image1d_t image, int coord, int lod, float4 color);
36+
void __ovld write_imagei(write_only image1d_t image, int coord, int lod, int4 color);
37+
void __ovld write_imageui(write_only image1d_t image, int coord, int lod, uint4 color);
38+
@@ -14699,15 +14700,17 @@ void __ovld write_imagef(write_only image2d_array_t image_array, int4 coord, int
39+
void __ovld write_imagei(write_only image2d_array_t image_array, int4 coord, int lod, int4 color);
40+
void __ovld write_imageui(write_only image2d_array_t image_array, int4 coord, int lod, uint4 color);
41+
42+
-void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float color);
43+
-void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float color);
44+
+void __ovld write_imagef(write_only image2d_depth_t image, int2 coord, int lod, float depth);
45+
+void __ovld write_imagef(write_only image2d_array_depth_t image, int4 coord, int lod, float depth);
46+
47+
#ifdef cl_khr_3d_image_writes
48+
void __ovld write_imagef(write_only image3d_t image, int4 coord, int lod, float4 color);
49+
void __ovld write_imagei(write_only image3d_t image, int4 coord, int lod, int4 color);
50+
void __ovld write_imageui(write_only image3d_t image, int4 coord, int lod, uint4 color);
51+
-#endif
52+
-#endif //cl_khr_mipmap_image
53+
+#endif //cl_khr_3d_image_writes
54+
+
55+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
56+
+#endif //defined(cl_khr_mipmap_image_writes)
57+
#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
58+
59+
// Image write functions for half4 type
60+
@@ -14756,7 +14759,8 @@ void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, flo
61+
#endif //cl_khr_depth_images
62+
63+
#if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
64+
-#ifdef cl_khr_mipmap_image
65+
+#ifdef cl_khr_mipmap_image_writes
66+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : begin
67+
void __ovld write_imagef(read_write image1d_t image, int coord, int lod, float4 color);
68+
void __ovld write_imagei(read_write image1d_t image, int coord, int lod, int4 color);
69+
void __ovld write_imageui(read_write image1d_t image, int coord, int lod, uint4 color);
70+
@@ -14780,8 +14784,10 @@ void __ovld write_imagef(read_write image2d_array_depth_t image, int4 coord, int
71+
void __ovld write_imagef(read_write image3d_t image, int4 coord, int lod, float4 color);
72+
void __ovld write_imagei(read_write image3d_t image, int4 coord, int lod, int4 color);
73+
void __ovld write_imageui(read_write image3d_t image, int4 coord, int lod, uint4 color);
74+
-#endif
75+
-#endif //cl_khr_mipmap_image
76+
+#endif //cl_khr_3d_image_writes
77+
+
78+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : end
79+
+#endif //cl_khr_mipmap_image_writes
80+
#endif //defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
81+
82+
// Image write functions for half4 type
83+
diff --git a/clang/test/SemaOpenCL/extension-version.cl b/clang/test/SemaOpenCL/extension-version.cl
84+
index 19d0884..0e6bbb7 100644
85+
--- a/clang/test/SemaOpenCL/extension-version.cl
86+
+++ b/clang/test/SemaOpenCL/extension-version.cl
87+
@@ -243,6 +243,18 @@
88+
#pragma OPENCL EXTENSION cl_khr_mipmap_image : enable
89+
90+
#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
91+
+#ifndef cl_khr_mipmap_image_writes
92+
+#error "Missing cl_khr_mipmap_image_writes define"
93+
+#endif
94+
+#else
95+
+#ifdef cl_khr_mipmap_image_writes
96+
+#error "Incorrect cl_khr_mipmap_image_writes define"
97+
+#endif
98+
+// expected-warning@+2{{unsupported OpenCL extension 'cl_khr_mipmap_image_writes' - ignoring}}
99+
+#endif
100+
+#pragma OPENCL EXTENSION cl_khr_mipmap_image_writes : enable
101+
+
102+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
103+
#ifndef cl_khr_srgb_image_writes
104+
#error "Missing cl_khr_srgb_image_writes define"
105+
#endif
106+
--
107+
2.7.4
108+

0 commit comments

Comments
 (0)