1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
|
From 217edc52822845ad70eb39e95871f90d14d1dac6 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.xyz>
Date: Wed, 21 Oct 2020 12:55:24 +0200
Subject: [PATCH] glslang: update for new glslang versioning scheme
This updates our checks to use the new header locations as introduced in
https://github.com/KhronosGroup/glslang/pull/2277. Fortunately, it seems
that the new version scheme is backwards compatible with the old one, so
we don't need any excessively complicated logic updates.
Fixes https://github.com/haasn/libplacebo/issues/83
---
src/glsl/glslang.cc | 9 +++++----
src/meson.build | 19 ++++++++++++++++---
2 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/src/glsl/glslang.cc b/src/glsl/glslang.cc
index 3b17a4e..01ad0fa 100644
--- a/src/glsl/glslang.cc
+++ b/src/glsl/glslang.cc
@@ -15,6 +15,8 @@
* License along with libplacebo. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config_internal.h"
+
#include <assert.h>
#include <pthread.h>
@@ -23,7 +25,6 @@ extern "C" {
}
#include <glslang/Include/ResourceLimits.h>
-#include <glslang/Include/revision.h>
#include <glslang/Public/ShaderLang.h>
#include <SPIRV/GlslangToSpv.h>
@@ -36,7 +37,7 @@ static int pl_glslang_refcount;
int pl_glslang_version(void)
{
- return GLSLANG_PATCH_LEVEL;
+ return GLSLANG_VERSION_PATCH;
}
bool pl_glslang_init(void)
@@ -78,7 +79,7 @@ struct pl_glslang_res *pl_glslang_compile(const char *glsl, uint32_t api_ver,
if (api_ver >= EShTargetVulkan_1_1)
spirv_version = EShTargetSpv_1_3;
-#if GLSLANG_PATCH_LEVEL >= 3667
+#if GLSLANG_VERSION_PATCH >= 3667
if (api_ver >= EShTargetVulkan_1_2)
spirv_version = EShTargetSpv_1_5;
#endif
@@ -200,7 +201,7 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
-#if GLSLANG_PATCH_LEVEL >= 2892
+#if GLSLANG_VERSION_PATCH >= 2892
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
diff --git a/src/meson.build b/src/meson.build
index 5a77cea..dcb8137 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -83,9 +83,20 @@ else
endif
if glslang_found
- glslang_ver = cxx.get_define('GLSLANG_PATCH_LEVEL',
- prefix: '#include <glslang/Include/revision.h>'
- ).to_int()
+ glslang_header_old = 'glslang/Include/revision.h'
+ glslang_header_new = 'glslang/build_info.h'
+
+ if cc.has_header(glslang_header_new)
+ glslang_ver = cxx.get_define('GLSLANG_VERSION_PATCH',
+ prefix: '#include <' + glslang_header_new + '>'
+ ).to_int()
+ elif cc.has_header(glslang_header_old)
+ glslang_ver = cxx.get_define('GLSLANG_PATCH_LEVEL',
+ prefix: '#include <' + glslang_header_old+ '>'
+ ).to_int()
+ else
+ error('No glslang version header found?')
+ endif
if glslang_ver >= glslang_min_ver
# glslang must be linked against pthreads on platforms where pthreads is
@@ -108,6 +119,8 @@ if glslang_found
add_project_arguments('-I' + i, language: 'cpp')
endforeach
+ conf_internal.set('GLSLANG_VERSION_PATCH', glslang_ver)
+
else
error('glslang revision @0@ too old! Must be at least @1@'
.format(glslang_ver, glslang_min_ver))
--
GitLab
From fc1e8dd6c8be5c9bfc0d7387b7ad6d8320f1a9ae Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.xyz>
Date: Wed, 28 Oct 2020 14:20:47 +0100
Subject: [PATCH] glslang: refactor version checks to respect semantic
versioning
Seems like glslang upstream is more than happy to make their patch level
go back down to 0 now. To handle the mishmash of old and new versioning
schemes, we map the old patch level to version 0.0.x, which ensures it's
forwards-compatible with the new versioning scheme (that was fortunately
introduced after every relevant check of ours).
Fixes https://github.com/haasn/libplacebo/issues/83 again, properly this
time.
---
src/glsl/glslang.cc | 13 ++++++++++---
src/meson.build | 30 ++++++++++++++++++++++++------
2 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/src/glsl/glslang.cc b/src/glsl/glslang.cc
index 01ad0fa..f701acc 100644
--- a/src/glsl/glslang.cc
+++ b/src/glsl/glslang.cc
@@ -30,6 +30,11 @@ extern "C" {
#include "glslang.h"
+#define GLSLANG_VERSION_CHECK(major, minor, patch) \
+ (((major) < GLSLANG_VERSION_MAJOR) || ((major) == GLSLANG_VERSION_MAJOR && \
+ (((minor) < GLSLANG_VERSION_MINOR) || ((minor) == GLSLANG_VERSION_MINOR && \
+ ((patch) <= GLSLANG_VERSION_PATCH)))))
+
using namespace glslang;
static pthread_mutex_t pl_glslang_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -37,7 +42,9 @@ static int pl_glslang_refcount;
int pl_glslang_version(void)
{
- return GLSLANG_VERSION_PATCH;
+ return (GLSLANG_VERSION_MAJOR & 0xFF) << 24 |
+ (GLSLANG_VERSION_MINOR & 0xFF) << 16 |
+ (GLSLANG_VERSION_PATCH & 0xFFFF);
}
bool pl_glslang_init(void)
@@ -79,7 +86,7 @@ struct pl_glslang_res *pl_glslang_compile(const char *glsl, uint32_t api_ver,
if (api_ver >= EShTargetVulkan_1_1)
spirv_version = EShTargetSpv_1_3;
-#if GLSLANG_VERSION_PATCH >= 3667
+#if GLSLANG_VERSION_CHECK(0, 0, 3667)
if (api_ver >= EShTargetVulkan_1_2)
spirv_version = EShTargetSpv_1_5;
#endif
@@ -201,7 +208,7 @@ const TBuiltInResource DefaultTBuiltInResource = {
/* .MaxCullDistances = */ 8,
/* .MaxCombinedClipAndCullDistances = */ 8,
/* .MaxSamples = */ 4,
-#if GLSLANG_VERSION_PATCH >= 2892
+#if GLSLANG_VERSION_CHECK(0, 0, 2892)
/* .maxMeshOutputVerticesNV = */ 256,
/* .maxMeshOutputPrimitivesNV = */ 512,
/* .maxMeshWorkGroupSizeX_NV = */ 32,
diff --git a/src/meson.build b/src/meson.build
index dcb8137..412697d 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -49,7 +49,7 @@ endif
# work-arounds for glslang braindeath
glslang_combined = disabler()
-glslang_min_ver = 2763
+glslang_min_ver = '>=0.0.2763'
glslang_req = get_option('glslang')
if glslang_req.auto() and shaderc.found()
@@ -87,18 +87,34 @@ if glslang_found
glslang_header_new = 'glslang/build_info.h'
if cc.has_header(glslang_header_new)
- glslang_ver = cxx.get_define('GLSLANG_VERSION_PATCH',
+ glslang_ver_major = cxx.get_define('GLSLANG_VERSION_MAJOR',
+ prefix: '#include <' + glslang_header_new + '>'
+ ).to_int()
+ glslang_ver_minor = cxx.get_define('GLSLANG_VERSION_MINOR',
+ prefix: '#include <' + glslang_header_new + '>'
+ ).to_int()
+ glslang_ver_patch = cxx.get_define('GLSLANG_VERSION_PATCH',
prefix: '#include <' + glslang_header_new + '>'
).to_int()
elif cc.has_header(glslang_header_old)
- glslang_ver = cxx.get_define('GLSLANG_PATCH_LEVEL',
+ # This is technically incorrect, but since we don't care about major
+ # versions for this version range, it's an acceptable substitute
+ glslang_ver_major = 0
+ glslang_ver_minor = 0
+ glslang_ver_patch = cxx.get_define('GLSLANG_PATCH_LEVEL',
prefix: '#include <' + glslang_header_old+ '>'
).to_int()
else
error('No glslang version header found?')
endif
- if glslang_ver >= glslang_min_ver
+ glslang_ver = '@0@.@1@.@2@'.format(
+ glslang_ver_major,
+ glslang_ver_minor,
+ glslang_ver_patch,
+ )
+
+ if glslang_ver.version_compare(glslang_min_ver)
# glslang must be linked against pthreads on platforms where pthreads is
# available. Because of their horrible architecture, gcc can't do it
# automatically, and for some reason dependency('threads') (which uses
@@ -119,10 +135,12 @@ if glslang_found
add_project_arguments('-I' + i, language: 'cpp')
endforeach
- conf_internal.set('GLSLANG_VERSION_PATCH', glslang_ver)
+ conf_internal.set('GLSLANG_VERSION_MAJOR', glslang_ver_major)
+ conf_internal.set('GLSLANG_VERSION_MINOR', glslang_ver_minor)
+ conf_internal.set('GLSLANG_VERSION_PATCH', glslang_ver_patch)
else
- error('glslang revision @0@ too old! Must be at least @1@'
+ error('glslang version @0@ too old! Must be at least @1@'
.format(glslang_ver, glslang_min_ver))
endif
endif
--
GitLab
|