Standalone: Implement -D and -U for preprocessor macros.
Works for both GLSL and HLSL. Fixes #87.
This commit is contained in:
47
Test/baseResults/glsl.-D-U.frag.out
Normal file
47
Test/baseResults/glsl.-D-U.frag.out
Normal file
@@ -0,0 +1,47 @@
|
||||
glsl.-D-U.frag
|
||||
Shader version: 450
|
||||
0:? Sequence
|
||||
0:7 Function Definition: main( ( global void)
|
||||
0:7 Function Parameters:
|
||||
0:10 Sequence
|
||||
0:10 move second child to first child ( temp 4-component vector of float)
|
||||
0:10 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:10 Constant:
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:16 Post-Increment ( temp 4-component vector of float)
|
||||
0:16 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:24 vector scale second child into first child ( temp 4-component vector of float)
|
||||
0:24 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:24 Constant:
|
||||
0:24 3.000000
|
||||
0:? Linker Objects
|
||||
0:? 'color' (layout( location=0) out 4-component vector of float)
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 450
|
||||
0:? Sequence
|
||||
0:7 Function Definition: main( ( global void)
|
||||
0:7 Function Parameters:
|
||||
0:10 Sequence
|
||||
0:10 move second child to first child ( temp 4-component vector of float)
|
||||
0:10 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:10 Constant:
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:10 1.000000
|
||||
0:16 Post-Increment ( temp 4-component vector of float)
|
||||
0:16 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:24 vector scale second child into first child ( temp 4-component vector of float)
|
||||
0:24 'color' (layout( location=0) out 4-component vector of float)
|
||||
0:24 Constant:
|
||||
0:24 3.000000
|
||||
0:? Linker Objects
|
||||
0:? 'color' (layout( location=0) out 4-component vector of float)
|
||||
|
||||
65
Test/baseResults/hlsl.-D-U.frag.out
Normal file
65
Test/baseResults/hlsl.-D-U.frag.out
Normal file
@@ -0,0 +1,65 @@
|
||||
hlsl.-D-U.frag
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:7 Function Definition: @main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:9 move second child to first child ( temp 4-component vector of float)
|
||||
0:9 'color' ( global 4-component vector of float)
|
||||
0:9 Constant:
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:15 subtract second child into first child ( temp 4-component vector of float)
|
||||
0:15 'color' ( global 4-component vector of float)
|
||||
0:15 Constant:
|
||||
0:15 5.000000
|
||||
0:21 Post-Increment ( temp 4-component vector of float)
|
||||
0:21 'color' ( global 4-component vector of float)
|
||||
0:29 vector scale second child into first child ( temp 4-component vector of float)
|
||||
0:29 'color' ( global 4-component vector of float)
|
||||
0:29 Constant:
|
||||
0:29 3.000000
|
||||
0:7 Function Definition: main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'color' ( global 4-component vector of float)
|
||||
|
||||
|
||||
Linked fragment stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
gl_FragCoord origin is upper left
|
||||
0:? Sequence
|
||||
0:7 Function Definition: @main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:9 move second child to first child ( temp 4-component vector of float)
|
||||
0:9 'color' ( global 4-component vector of float)
|
||||
0:9 Constant:
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:9 1.000000
|
||||
0:15 subtract second child into first child ( temp 4-component vector of float)
|
||||
0:15 'color' ( global 4-component vector of float)
|
||||
0:15 Constant:
|
||||
0:15 5.000000
|
||||
0:21 Post-Increment ( temp 4-component vector of float)
|
||||
0:21 'color' ( global 4-component vector of float)
|
||||
0:29 vector scale second child into first child ( temp 4-component vector of float)
|
||||
0:29 'color' ( global 4-component vector of float)
|
||||
0:29 Constant:
|
||||
0:29 3.000000
|
||||
0:7 Function Definition: main( ( temp void)
|
||||
0:7 Function Parameters:
|
||||
0:? Sequence
|
||||
0:7 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'color' ( global 4-component vector of float)
|
||||
|
||||
32
Test/glsl.-D-U.frag
Normal file
32
Test/glsl.-D-U.frag
Normal file
@@ -0,0 +1,32 @@
|
||||
#version 450
|
||||
|
||||
#define IN_SHADER
|
||||
|
||||
layout(location=0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if FOO==200
|
||||
color = vec4(1.0);
|
||||
#else
|
||||
#error expected FOO 200
|
||||
#endif
|
||||
|
||||
#ifdef IN_SHADER
|
||||
color++;
|
||||
#else
|
||||
#error IN_SHADER was undef
|
||||
#endif
|
||||
|
||||
#ifdef UNDEFED
|
||||
#error UNDEFED defined
|
||||
#else
|
||||
color *= 3.0;
|
||||
#endif
|
||||
|
||||
#if MUL == 400
|
||||
color *= MUL;
|
||||
#else
|
||||
#error bad MUL
|
||||
#endif
|
||||
}
|
||||
31
Test/hlsl.-D-U.frag
Normal file
31
Test/hlsl.-D-U.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
#define IN_SHADER
|
||||
|
||||
static float4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
#if FOO==200
|
||||
color = 1.0;
|
||||
#else
|
||||
#error expected FOO 200
|
||||
#endif
|
||||
|
||||
#ifdef FOO
|
||||
color -= 5.0;
|
||||
#else
|
||||
#error expected FOO 200
|
||||
#endif
|
||||
|
||||
#ifdef IN_SHADER
|
||||
color++;
|
||||
#else
|
||||
#error IN_SHADER was undef
|
||||
#endif
|
||||
|
||||
#ifdef UNDEFED
|
||||
#error UNDEFED defined
|
||||
#else
|
||||
color *= 3.0;
|
||||
#endif
|
||||
}
|
||||
@@ -119,6 +119,14 @@ diff -b $BASEDIR/include.vert.out $TARGETDIR/include.vert.out || HASERROR=1
|
||||
$EXE -D -e main -H -Iinc1/path1 -Iinc1/path2 hlsl.dashI.vert > $TARGETDIR/hlsl.dashI.vert.out
|
||||
diff -b $BASEDIR/hlsl.dashI.vert.out $TARGETDIR/hlsl.dashI.vert.out || HASERROR=1
|
||||
|
||||
#
|
||||
# Testing -D and -U
|
||||
#
|
||||
$EXE -DUNDEFED -UIN_SHADER -DFOO=200 -i -l -UUNDEFED -DMUL=FOO*2 glsl.-D-U.frag > $TARGETDIR/glsl.-D-U.frag.out
|
||||
diff -b $BASEDIR/glsl.-D-U.frag.out $TARGETDIR/glsl.-D-U.frag.out || HASERROR=1
|
||||
$EXE -D -e main -V -i -DUNDEFED -UIN_SHADER -DFOO=200 -UUNDEFED hlsl.-D-U.frag > $TARGETDIR/hlsl.-D-U.frag.out
|
||||
diff -b $BASEDIR/hlsl.-D-U.frag.out $TARGETDIR/hlsl.-D-U.frag.out || HASERROR=1
|
||||
|
||||
#
|
||||
# Final checking
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user