From 12f7237e4060388494c549623f4a640327b7ca08 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 14 Nov 2023 17:46:05 -0800 Subject: 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 Co-authored-by: Yong He --- tests/glsl/struct-construct.slang | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tests/glsl/struct-construct.slang (limited to 'tests/glsl/struct-construct.slang') 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 +} + -- cgit v1.2.3