diff options
| author | Yong He <yonghe@outlook.com> | 2023-11-14 17:46:05 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-14 17:46:05 -0800 |
| commit | 12f7237e4060388494c549623f4a640327b7ca08 (patch) | |
| tree | 407c0f8d20b4ccd49ae5df57f84c8f9a310f7055 /tests | |
| parent | c71b12775c8b13ea2b181e42c04b8db55b10fb2f (diff) | |
Add GLSL Compatibility. (#3321)
* Parse glsl buffer blocks to GLSLInterfaceBlockDecl
* Parse glsl local size layout declarations
* Parse (and ignore) glsl version directives
* spelling
* Better l-value interpretation for glsl interface blocks
* Better l-value interpretation for glsl interface blocks
* Add compile flag for enabling glsl
* Parse and ignore precision modifiers.
* Automatically import `glsl` module for compatiblity.
* Complete vector and matrix types for glsl
* Remove generated file from repo
* Bump .gitignore
* do not mark out globals as params
* Synthesize entrypoint layout from global inout vars.
* update test result.
* Allow HLSL semantic on global variables.
* Fix.
* Fix test.
* Fix win32 compile error.
* Add more builtin input/output and texture intrinsics.
* Add struct/array constructor syntax.
* Skip `#extension` lines.
* overide operator * for matrix/vector multiplication.
* Add `matrixCompMult`.
* Parse modifiers in for loop init var declr.
* Add more glsl intrinsics, add stage into to var layout.
* Allow `int[3] x` syntax.
* Fix array type syntax.
---------
Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected | 2 | ||||
| -rw-r--r-- | tests/glsl/basic-fragment-2.slang | 16 | ||||
| -rw-r--r-- | tests/glsl/basic-fragment.slang | 22 | ||||
| -rw-r--r-- | tests/glsl/basic-vertex.slang | 39 | ||||
| -rw-r--r-- | tests/glsl/flat-in.slang | 23 | ||||
| -rw-r--r-- | tests/glsl/loop-modifier.slang | 14 | ||||
| -rw-r--r-- | tests/glsl/matrix-mul.slang | 19 | ||||
| -rw-r--r-- | tests/glsl/out-builtin-block-redeclaration.slang | 20 | ||||
| -rw-r--r-- | tests/glsl/struct-construct.slang | 23 | ||||
| -rw-r--r-- | tests/ir/string-literal.slang | 3 | ||||
| -rw-r--r-- | tests/ir/string-literal.slang.expected | 20 |
11 files changed, 179 insertions, 22 deletions
diff --git a/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected index fef4b78de..81fa57fc9 100644 --- a/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected +++ b/tests/diagnostics/command-line/explicit-implicit-stage-mismatch.vert.expected @@ -1,7 +1,7 @@ result code = -1 standard error = { (0): warning 32: the stage specified for entry point 'main' ('pixel') does not match the stage implied by the source file name ('vertex') -(0): error 11: the Slang compiler does not support GLSL as a source language +(0): error 11: the Slang compiler does not support GLSL as a source language by default, please use -allow-glsl } standard output = { } diff --git a/tests/glsl/basic-fragment-2.slang b/tests/glsl/basic-fragment-2.slang new file mode 100644 index 000000000..c958b54b0 --- /dev/null +++ b/tests/glsl/basic-fragment-2.slang @@ -0,0 +1,16 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage fragment -entry main -allow-glsl + +#version 450 core +layout(location = 0) out mediump vec4 o_color; +layout(location = 0) in highp vec2 v_texCoord; +layout(location = 1) in highp float v_lodBias; +layout(set = 0, binding = 0) uniform highp usampler2D u_sampler; +layout(set = 0, binding = 1) uniform buf0 { highp vec4 u_scale; }; +layout(set = 0, binding = 2) uniform buf1 { highp vec4 u_bias; }; + +void main() +{ + o_color = vec4(texelFetch(u_sampler, ivec2(v_texCoord), int(v_lodBias))) * u_scale + u_bias; + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/basic-fragment.slang b/tests/glsl/basic-fragment.slang new file mode 100644 index 000000000..ce5c8d485 --- /dev/null +++ b/tests/glsl/basic-fragment.slang @@ -0,0 +1,22 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage fragment -entry main -allow-glsl +#version 310 es +precision highp float; +precision highp int; + +bool isOk (uint a, uint b) { return (a == b); } +layout(location = 0) out mediump vec4 dEQP_FragColor; +layout(location = 0) flat in float in0; +layout(binding = 0, std140) uniform Reference +{ + uint out0; +} ref; +uint out0; + +void main() +{ + out0 = uint(in0); + bool RES = isOk(out0, ref.out0); + dEQP_FragColor = vec4(RES, RES, RES, 1.0); + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/basic-vertex.slang b/tests/glsl/basic-vertex.slang new file mode 100644 index 000000000..b050f3f60 --- /dev/null +++ b/tests/glsl/basic-vertex.slang @@ -0,0 +1,39 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl +#version 310 es +layout(location = 0) in highp vec4 a_position; +layout(location = 1) in highp vec4 a_coords; +layout(location = 0) out mediump vec3 v_color; +layout(std140, set = 0, binding = 0) uniform buff0 { + mediump int ui_zero; +}; +layout(std140, set = 0, binding = 1) uniform buff1 { + mediump int ui_one; +}; +layout(std140, set = 0, binding = 2) uniform buff2 { + mediump int ui_two; +}; +layout(std140, set = 0, binding = 3) uniform buff3 { + mediump int ui_three; +}; +layout(std140, set = 0, binding = 4) uniform buff4 { + mediump int ui_four; +}; +layout(std140, set = 0, binding = 5) uniform buff5 { + mediump int ui_five; +}; +layout(std140, set = 0, binding = 6) uniform buff6 { + mediump int ui_six; +}; + +void main() +{ + gl_Position = a_position; + mediump vec4 coords = a_coords; + mediump vec4 res = coords; + mediump int i = 0; + for (;;) { res = res.yzwx + vec4(1.0); if (i == 1) break; i++; } + res -= vec4(2); + v_color = res.rgb; + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/flat-in.slang b/tests/glsl/flat-in.slang new file mode 100644 index 000000000..4ca68df37 --- /dev/null +++ b/tests/glsl/flat-in.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage fragment -entry main -allow-glsl + +#version 310 es +precision highp float; +precision highp int; + +layout(location = 0) out mediump vec4 dEQP_FragColor; + +bool isOk (uint a, uint b) { return (a == b); } + +layout(location = 0) flat in uint out0; +layout(binding = 0, std140) uniform Reference +{ + uint out0; +} ref; + +void main() +{ + bool RES = isOk(out0, ref.out0); + dEQP_FragColor = vec4(RES, RES, RES, 1.0); + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/loop-modifier.slang b/tests/glsl/loop-modifier.slang new file mode 100644 index 000000000..e02ab5b8c --- /dev/null +++ b/tests/glsl/loop-modifier.slang @@ -0,0 +1,14 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl +#version 310 es +layout(location = 0) in highp vec4 a_position; + +void main() +{ + vec4 a = 0; + for (highp int i = 0; i < 5; i++) + a += vec4(i); + gl_Position = a; + + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/matrix-mul.slang b/tests/glsl/matrix-mul.slang new file mode 100644 index 000000000..6ac6613f2 --- /dev/null +++ b/tests/glsl/matrix-mul.slang @@ -0,0 +1,19 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl +#version 310 es +layout(location = 0) in highp vec4 a_position; + +layout(std140, set = 0, binding = 0) uniform buff0 { + mat4x4 m1; + mat4x4 m2; +}; + + +void main() +{ + gl_Position = m1 * m2 * a_position; + + // CHECK: OpEntryPoint + // CHECK: OpMatrixTimesMatrix + // CHECK: OpMatrixTimesVector +} + diff --git a/tests/glsl/out-builtin-block-redeclaration.slang b/tests/glsl/out-builtin-block-redeclaration.slang new file mode 100644 index 000000000..7a2bfc1c9 --- /dev/null +++ b/tests/glsl/out-builtin-block-redeclaration.slang @@ -0,0 +1,20 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl + +#version 450 core +layout(location = 0) in highp vec4 a_position; +layout(location = 4) in highp vec2 a_in0; +layout(location = 5) in highp float a_in1; +layout(location = 0) out highp vec2 v_texCoord; +layout(location = 1) out highp float v_lodBias; +out gl_PerVertex { + vec4 gl_Position; +}; + +void main() +{ + gl_Position = a_position; + v_texCoord = a_in0; + v_lodBias = a_in1; + // CHECK: OpEntryPoint +} + diff --git a/tests/glsl/struct-construct.slang b/tests/glsl/struct-construct.slang new file mode 100644 index 000000000..a1538ed9b --- /dev/null +++ b/tests/glsl/struct-construct.slang @@ -0,0 +1,23 @@ +//TEST:SIMPLE(filecheck=CHECK): -target spirv -stage vertex -entry main -allow-glsl + +#version 310 es +layout(location = 0) in highp vec4 a_position; +layout(location = 1) in highp vec4 a_coords; +layout(location = 0) out mediump vec4 v_color; +layout (std140, set = 0, binding = 0) uniform buffer0 { int ui_one; }; + +struct S { + mediump float a; + mediump vec3 b; + int c; +}; + +void main (void) +{ + S s = S(a_coords.x, vec3(0.0), ui_one); + s.b = a_coords.yzw; + v_color = vec4(s.a, s.b.x, s.b.y, s.c); + gl_Position = a_position; + // CHECK: OpEntryPoint +} + diff --git a/tests/ir/string-literal.slang b/tests/ir/string-literal.slang index 224d64b7a..be05f6a8d 100644 --- a/tests/ir/string-literal.slang +++ b/tests/ir/string-literal.slang @@ -1,5 +1,6 @@ -//TEST(compute):SIMPLE:-dump-ir -stage compute -entry main +//TEST(compute):SIMPLE(filecheck=CHECK):-dump-ir -stage compute -entry main +// CHECK: global_hashed_string_literals("Hello \t\n\0x083 World") [numthreads(1, 1, 1)] void main( uint tid : SV_DispatchThreadIndex) diff --git a/tests/ir/string-literal.slang.expected b/tests/ir/string-literal.slang.expected deleted file mode 100644 index 6f414b0da..000000000 --- a/tests/ir/string-literal.slang.expected +++ /dev/null @@ -1,20 +0,0 @@ -result code = 0 -standard error = { -### LOWER-TO-IR: -undefined -[entryPoint(6 : Int, "main", "string-literal")] -[numThreads(1 : Int, 1 : Int, 1 : Int)] -[export("_S3tu04mainp1puV")] -[nameHint("main")] -func %main : Func(Void, UInt) -{ -block %1( - [nameHint("tid")] - param %tid : UInt): - return_val(void_constant) -} -global_hashed_string_literals("Hello \t\n\0x083 World") -### -} -standard output = { -} |
