From d1e2ac57fe359672e596bb4a3b8674f84d22bd04 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Fri, 28 May 2021 21:49:50 -0400 Subject: [PATCH] New snapshot test for global variables --- tests/in/globals.param.ron | 3 +++ tests/in/globals.wgsl | 9 +++++++++ tests/in/interface.wgsl | 2 +- tests/in/interpolate.wgsl | 2 ++ tests/out/globals.Compute.glsl | 11 +++++++++++ tests/out/globals.msl | 12 ++++++++++++ tests/out/globals.spvasm | 26 ++++++++++++++++++++++++++ tests/out/globals.wgsl | 8 ++++++++ tests/snapshots.rs | 4 ++++ 9 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 tests/in/globals.param.ron create mode 100644 tests/in/globals.wgsl create mode 100644 tests/out/globals.Compute.glsl create mode 100644 tests/out/globals.msl create mode 100644 tests/out/globals.spvasm create mode 100644 tests/out/globals.wgsl diff --git a/tests/in/globals.param.ron b/tests/in/globals.param.ron new file mode 100644 index 0000000000..8b306e5b7d --- /dev/null +++ b/tests/in/globals.param.ron @@ -0,0 +1,3 @@ +( + spv_version: (1, 0), +) diff --git a/tests/in/globals.wgsl b/tests/in/globals.wgsl new file mode 100644 index 0000000000..3f20e53efc --- /dev/null +++ b/tests/in/globals.wgsl @@ -0,0 +1,9 @@ +// Global variable & constant declarations + +let Foo: bool = true; + +var wg : array; + +[[stage(compute), workgroup_size(1)]] +fn main() { +} diff --git a/tests/in/interface.wgsl b/tests/in/interface.wgsl index e56634e67c..18b0607023 100644 --- a/tests/in/interface.wgsl +++ b/tests/in/interface.wgsl @@ -1,4 +1,4 @@ -// Testing various parts of the pipeline interface: locations, built-ins, bindings, and entry points +// Testing various parts of the pipeline interface: locations, built-ins, and entry points struct VertexOutput { [[builtin(position)]] position: vec4; diff --git a/tests/in/interpolate.wgsl b/tests/in/interpolate.wgsl index 51eb4fde74..dcb8a66c5a 100644 --- a/tests/in/interpolate.wgsl +++ b/tests/in/interpolate.wgsl @@ -1,3 +1,5 @@ +//TODO: mere with "interface"? + struct FragmentInput { [[builtin(position)]] position: vec4; [[location(0), interpolate(flat)]] flat : u32; diff --git a/tests/out/globals.Compute.glsl b/tests/out/globals.Compute.glsl new file mode 100644 index 0000000000..63328eab18 --- /dev/null +++ b/tests/out/globals.Compute.glsl @@ -0,0 +1,11 @@ +#version 310 es + +precision highp float; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + + +void main() { + return; +} + diff --git a/tests/out/globals.msl b/tests/out/globals.msl new file mode 100644 index 0000000000..638fa22ede --- /dev/null +++ b/tests/out/globals.msl @@ -0,0 +1,12 @@ +#include +#include + +constexpr constant bool Foo = true; +struct type2 { + float inner[10]; +}; + +kernel void main1( +) { + return; +} diff --git a/tests/out/globals.spvasm b/tests/out/globals.spvasm new file mode 100644 index 0000000000..0078cf2e8f --- /dev/null +++ b/tests/out/globals.spvasm @@ -0,0 +1,26 @@ +; SPIR-V +; Version: 1.0 +; Generator: rspirv +; Bound: 15 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %12 "main" +OpExecutionMode %12 LocalSize 1 1 1 +OpDecorate %8 ArrayStride 4 +%2 = OpTypeVoid +%4 = OpTypeBool +%3 = OpConstantTrue %4 +%6 = OpTypeInt 32 1 +%5 = OpConstant %6 10 +%7 = OpTypeFloat 32 +%8 = OpTypeArray %7 %5 +%10 = OpTypePointer Workgroup %8 +%9 = OpVariable %10 Workgroup +%13 = OpTypeFunction %2 +%12 = OpFunction %2 None %13 +%11 = OpLabel +OpBranch %14 +%14 = OpLabel +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/globals.wgsl b/tests/out/globals.wgsl new file mode 100644 index 0000000000..87ce46054a --- /dev/null +++ b/tests/out/globals.wgsl @@ -0,0 +1,8 @@ +let Foo: bool = true; + +var wg: array; + +[[stage(compute), workgroup_size(1, 1, 1)]] +fn main() { + return; +} diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 6126b46597..4453309d34 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -293,6 +293,10 @@ fn convert_wgsl() { ), //TODO: GLSL https://github.com/gfx-rs/naga/issues/874 ("interface", Targets::SPIRV | Targets::METAL | Targets::WGSL), + ( + "globals", + Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::WGSL, + ), ]; for &(name, targets) in inputs.iter() {