glslang preprocessing: Add -E option to print out preprocessed GLSL, and do the work needed to generate a preprocessed stream. From Andrew Woloszyn <awoloszyn@google.com>.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@31508 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
9288f46b95
commit
c555dddd53
23 changed files with 609 additions and 55 deletions
18
Test/baseResults/preprocessor.edge_cases.vert.out
Normal file
18
Test/baseResults/preprocessor.edge_cases.vert.out
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void main(){
|
||||
gl_Position = vec4(3 + 2 + 2 * 4 + 2 + 3 * 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
Test/baseResults/preprocessor.errors.vert.out
Normal file
18
Test/baseResults/preprocessor.errors.vert.out
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#error This should show up in pp output .
|
||||
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
Test/baseResults/preprocessor.extensions.vert.out
Normal file
14
Test/baseResults/preprocessor.extensions.vert.out
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 310 es
|
||||
|
||||
#extension GL_OES_texture_3D : enable
|
||||
#extension GL_EXT_frag_depth : disable
|
||||
#extension GL_EXT_gpu_shader5 : require
|
||||
#extension GL_EXT_shader_texture_image_samples : warn
|
||||
|
||||
#extension unknown_extension : require
|
||||
|
||||
int main(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
23
Test/baseResults/preprocessor.function_macro.vert.out
Normal file
23
Test/baseResults/preprocessor.function_macro.vert.out
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main(){
|
||||
gl_Position = vec4(3 + 1, 3 + 4, 3 + 1);
|
||||
gl_Position = vec4(1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12);
|
||||
gl_Position = vec4(4 + 3 + 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
26
Test/baseResults/preprocessor.line.vert.out
Normal file
26
Test/baseResults/preprocessor.line.vert.out
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#line 300
|
||||
|
||||
#line 2
|
||||
|
||||
#line 10
|
||||
|
||||
#line 2
|
||||
|
||||
#line 0
|
||||
|
||||
#line 4
|
||||
|
||||
#line 8
|
||||
|
||||
void main(){
|
||||
gl_Position = vec4(10);
|
||||
}
|
||||
#line 8 4
|
||||
|
||||
#line 12 3
|
||||
|
||||
#line 1
|
||||
|
||||
|
||||
|
||||
|
||||
14
Test/baseResults/preprocessor.pragma.vert.out
Normal file
14
Test/baseResults/preprocessor.pragma.vert.out
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
#version 310 es
|
||||
|
||||
#pragma optimize(on)
|
||||
#pragma optimize(off)
|
||||
#pragma debug(on)
|
||||
#pragma debug(off)
|
||||
|
||||
#pragma undefined_pragma(x,4)
|
||||
|
||||
int main(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
25
Test/baseResults/preprocessor.simple.vert.out
Normal file
25
Test/baseResults/preprocessor.simple.vert.out
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float fn(float x){ return x + 4.0;}
|
||||
|
||||
int main(){
|
||||
gl_Position = vec4(1);
|
||||
gl_Position = clamp(1, 2, 3);
|
||||
gl_Position = vec4(1);
|
||||
gl_Position = vec4(1, 2);
|
||||
gl_Position = vec4(fn(3));
|
||||
}
|
||||
|
||||
|
||||
|
||||
15
Test/preprocessor.edge_cases.vert
Normal file
15
Test/preprocessor.edge_cases.vert
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 310 es
|
||||
#define X(Y) /*
|
||||
*/ Y + 2
|
||||
|
||||
#define Y(Z) 2 * Z// asdf
|
||||
|
||||
#define Z(Y) /*
|
||||
*/ \
|
||||
2 /*
|
||||
*/ + 3 \
|
||||
* Y
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(X(3) + Y(4) + Z(2));
|
||||
}
|
||||
15
Test/preprocessor.errors.vert
Normal file
15
Test/preprocessor.errors.vert
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#version 310 es
|
||||
|
||||
#define X
|
||||
|
||||
#if X
|
||||
#if Y
|
||||
#error This should not show up in pp output.
|
||||
#endif
|
||||
#error This should show up in pp output.
|
||||
#else
|
||||
#error This should not show up in pp output.
|
||||
#endif
|
||||
|
||||
int main() {
|
||||
}
|
||||
12
Test/preprocessor.extensions.vert
Normal file
12
Test/preprocessor.extensions.vert
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#version 310 es
|
||||
|
||||
#extension GL_OES_texture_3D: enable
|
||||
#extension GL_EXT_frag_depth: disable
|
||||
#extension GL_EXT_gpu_shader5: require
|
||||
#extension GL_EXT_shader_texture_image_samples: warn
|
||||
|
||||
#extension unknown_extension: require
|
||||
|
||||
int main() {
|
||||
}
|
||||
|
||||
20
Test/preprocessor.function_macro.vert
Normal file
20
Test/preprocessor.function_macro.vert
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#version 310 es
|
||||
|
||||
|
||||
#define X(n) n + 1
|
||||
#define Y(n, z) n + z
|
||||
#define Z(f) X(f)
|
||||
|
||||
#define REALLY_LONG_MACRO_NAME_WITH_MANY_PARAMETERS(X1, X2, X3, X4, X5, X6, X7,\
|
||||
X8, X9, X10, X11, X12) X1+X2+X3+X4+X5+X6+X7+X8+X9+X10+X11+X12
|
||||
|
||||
#define A(\
|
||||
Y\
|
||||
)\
|
||||
4 + 3 + Y
|
||||
|
||||
int main() {
|
||||
gl_Position = vec4(X(3), Y(3, 4), Z(3));
|
||||
gl_Position = vec4(REALLY_LONG_MACRO_NAME_WITH_MANY_PARAMETERS(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
|
||||
gl_Position = vec4(A(3));
|
||||
}
|
||||
39
Test/preprocessor.line.vert
Normal file
39
Test/preprocessor.line.vert
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
#line 300
|
||||
|
||||
#line 2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#line __LINE__ + 3
|
||||
|
||||
|
||||
#line __FILE__ + 2
|
||||
|
||||
#line __FILE__ * __LINE__
|
||||
|
||||
|
||||
#define X 4
|
||||
|
||||
#line X
|
||||
|
||||
#undef X
|
||||
|
||||
#define X(y) y + 3 + 2
|
||||
|
||||
#line X(3)
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(__LINE__);
|
||||
}
|
||||
|
||||
#line X(3) 4
|
||||
|
||||
#define Z(y, q) \
|
||||
y*q*2 q
|
||||
|
||||
#line Z(2, 3)
|
||||
|
||||
#line 1
|
||||
|
||||
11
Test/preprocessor.pragma.vert
Normal file
11
Test/preprocessor.pragma.vert
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#version 310 es
|
||||
|
||||
#pragma optimize(on)
|
||||
#pragma optimize(off)
|
||||
#pragma debug(on)
|
||||
#pragma debug(off)
|
||||
|
||||
#pragma undefined_pragma(x, 4)
|
||||
|
||||
int main() {
|
||||
}
|
||||
22
Test/preprocessor.simple.vert
Normal file
22
Test/preprocessor.simple.vert
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#version 310 es
|
||||
#define X 1
|
||||
#define Y clamp
|
||||
#define Z X
|
||||
|
||||
#define F 1, 2
|
||||
|
||||
#define make_function \
|
||||
float fn ( float x ) \
|
||||
{\
|
||||
return x + 4.0; \
|
||||
}
|
||||
|
||||
make_function
|
||||
|
||||
int main() {
|
||||
gl_Position = vec4(X);
|
||||
gl_Position = Y(1, 2, 3);
|
||||
gl_Position = vec4(Z);
|
||||
gl_Position = vec4(F);
|
||||
gl_Position = vec4(fn(3));
|
||||
}
|
||||
|
|
@ -54,6 +54,16 @@ while read t; do
|
|||
esac
|
||||
done < test-spirv-list
|
||||
|
||||
#
|
||||
# Preprocessor tests
|
||||
#
|
||||
while read t; do
|
||||
echo Running Preprocessor $t...
|
||||
b=`basename $t`
|
||||
$EXE -E $t > $TARGETDIR/$b.out
|
||||
diff -b $BASEDIR/$b.out $TARGETDIR/$b.out || HASERROR=1
|
||||
done < test-preprocessor-list
|
||||
|
||||
#
|
||||
# grouped shaders for bulk (faster) tests
|
||||
#
|
||||
|
|
|
|||
7
Test/test-preprocessor-list
Normal file
7
Test/test-preprocessor-list
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
preprocessor.edge_cases.vert
|
||||
preprocessor.errors.vert
|
||||
preprocessor.extensions.vert
|
||||
preprocessor.function_macro.vert
|
||||
preprocessor.line.vert
|
||||
preprocessor.pragma.vert
|
||||
preprocessor.simple.vert
|
||||
|
|
@ -14,7 +14,6 @@ spv.double.comp
|
|||
spv.100ops.frag
|
||||
spv.130.frag
|
||||
spv.140.frag
|
||||
spv.140.vert
|
||||
spv.150.geom
|
||||
spv.150.vert
|
||||
spv.300BuiltIns.vert
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue