From bb3ab6f796f049230b77f49d3dc1ef03577cb0a3 Mon Sep 17 00:00:00 2001 From: Connor Fitzgerald Date: Mon, 15 Jun 2026 17:41:38 -0400 Subject: [PATCH] Add GLSL output to naga snapshots (#9204) --- Cargo.lock | 1 + naga/Cargo.toml | 1 + naga/tests/naga/snapshots.rs | 132 ++- naga/tests/out/spv/spv-barrier.spvasm.glsl | 18 + .../tests/out/spv/spv-fetch_depth.spvasm.glsl | 36 + naga/tests/out/spv/spv-per-vertex.spvasm.glsl | 20 + .../out/spv/spv-subgroup-barrier.spvasm.glsl | 15 + .../spv/wgsl-6220-break-from-loop.spvasm.glsl | 27 + .../wgsl-6438-conflicting-idents.spvasm.glsl | 41 + ...wgsl-6772-unpack-expr-accesses.spvasm.glsl | 9 + .../wgsl-7048-multiple-dynamic-1.spvasm.glsl | 13 + .../wgsl-7048-multiple-dynamic-2.spvasm.glsl | 12 + .../wgsl-7048-multiple-dynamic-3.spvasm.glsl | 58 ++ .../spv/wgsl-7995-unicode-idents.spvasm.glsl | 17 + ...iple-local-invocation-index-id.spvasm.glsl | 23 + .../wgsl-9489-loop-local-var-init.spvasm.glsl | 58 ++ .../wgsl-abstract-types-builtins.spvasm.glsl | 62 ++ .../spv/wgsl-abstract-types-const.spvasm.glsl | 1 + ...-abstract-types-function-calls.spvasm.glsl | 82 ++ .../spv/wgsl-abstract-types-let.spvasm.glsl | 20 + .../wgsl-abstract-types-operators.spvasm.glsl | 65 ++ .../wgsl-abstract-types-return.spvasm.glsl | 47 + .../spv/wgsl-abstract-types-var.spvasm.glsl | 239 +++++ naga/tests/out/spv/wgsl-access.spvasm.glsl | 17 + .../spv/wgsl-aliased-ray-query.spvasm.glsl | 161 ++++ .../out/spv/wgsl-array-in-ctor.spvasm.glsl | 17 + ...-array-in-function-return-type.spvasm.glsl | 20 + ...sl-atomicCompareExchange-int64.spvasm.glsl | 157 ++++ .../wgsl-atomicCompareExchange.spvasm.glsl | 145 +++ .../spv/wgsl-atomicOps-float32.spvasm.glsl | 48 + .../wgsl-atomicOps-int64-min-max.spvasm.glsl | 48 + .../out/spv/wgsl-atomicOps-int64.spvasm.glsl | 153 ++++ naga/tests/out/spv/wgsl-atomicOps.spvasm.glsl | 147 ++++ .../spv/wgsl-atomicTexture-int64.spvasm.glsl | 19 + .../out/spv/wgsl-atomicTexture.spvasm.glsl | 22 + .../out/spv/wgsl-barycentrics.spvasm.glsl | 27 + .../out/spv/wgsl-binding-arrays.spvasm.glsl | 131 +++ .../wgsl-binding-buffer-arrays.spvasm.glsl | 58 ++ naga/tests/out/spv/wgsl-bitcast.spvasm.glsl | 25 + naga/tests/out/spv/wgsl-bits.spvasm.glsl | 89 ++ naga/tests/out/spv/wgsl-boids.spvasm.glsl | 122 +++ ...nds-check-image-restrict-depth.spvasm.glsl | 37 + ...sl-bounds-check-image-restrict.spvasm.glsl | 85 ++ ...-bounds-check-image-rzsw-depth.spvasm.glsl | 100 +++ .../wgsl-bounds-check-image-rzsw.spvasm.glsl | 178 ++++ .../wgsl-bounds-check-restrict.spvasm.glsl | 110 +++ .../spv/wgsl-bounds-check-zero.spvasm.glsl | 205 +++++ naga/tests/out/spv/wgsl-break-if.spvasm.glsl | 81 ++ .../out/spv/wgsl-clip-distances.spvasm.glsl | 18 + naga/tests/out/spv/wgsl-collatz.spvasm.glsl | 54 ++ .../out/spv/wgsl-const-exprs.spvasm.glsl | 133 +++ .../out/spv/wgsl-constructors.spvasm.glsl | 15 + .../out/spv/wgsl-control-flow.spvasm.glsl | 393 +++++++++ .../wgsl-conversion-float-to-int.spvasm.glsl | 173 ++++ .../out/spv/wgsl-conversions.spvasm.glsl | 8 + .../spv/wgsl-cooperative-matrix.spvasm.glsl | 25 + naga/tests/out/spv/wgsl-cross.spvasm.glsl | 7 + ...wgsl-debug-symbol-large-source.spvasm.glsl | 833 ++++++++++++++++++ .../spv/wgsl-debug-symbol-simple.spvasm.glsl | 79 ++ .../spv/wgsl-debug-symbol-terrain.spvasm.glsl | 833 ++++++++++++++++++ .../tests/out/spv/wgsl-draw-index.spvasm.glsl | 12 + .../tests/out/spv/wgsl-dualsource.spvasm.glsl | 17 + ...-early-depth-test-conservative.spvasm.glsl | 8 + .../wgsl-early-depth-test-force.spvasm.glsl | 10 + naga/tests/out/spv/wgsl-empty-if.spvasm.glsl | 7 + naga/tests/out/spv/wgsl-empty.spvasm.glsl | 7 + naga/tests/out/spv/wgsl-extra.spvasm.glsl | 37 + .../tests/out/spv/wgsl-f16-native.spvasm.glsl | 297 +++++++ .../out/spv/wgsl-f16-polyfill.spvasm.glsl | 297 +++++++ naga/tests/out/spv/wgsl-f16.spvasm.glsl | 172 ++++ naga/tests/out/spv/wgsl-f64.spvasm.glsl | 18 + .../out/spv/wgsl-fragment-output.spvasm.glsl | 99 +++ ...ctions-optimized-by-capability.spvasm.glsl | 2 + ...functions-optimized-by-version.spvasm.glsl | 2 + .../wgsl-functions-unoptimized.spvasm.glsl | 19 + naga/tests/out/spv/wgsl-functions.spvasm.glsl | 2 + naga/tests/out/spv/wgsl-globals.spvasm.glsl | 108 +++ naga/tests/out/spv/wgsl-image.spvasm.glsl | 370 ++++++++ .../out/spv/wgsl-index-by-value.spvasm.glsl | 32 + .../spv/wgsl-int-div-unchecked.spvasm.glsl | 11 + naga/tests/out/spv/wgsl-int16.spvasm.glsl | 182 ++++ naga/tests/out/spv/wgsl-int64.spvasm.glsl | 123 +++ .../spv/wgsl-interface.compute.spvasm.glsl | 38 + .../spv/wgsl-interface.fragment.spvasm.glsl | 41 + .../out/spv/wgsl-interface.vertex.spvasm.glsl | 42 + ...l-interface.vertex_two_structs.spvasm.glsl | 42 + .../out/spv/wgsl-interpolate.spvasm.glsl | 102 +++ .../spv/wgsl-interpolate_compat.spvasm.glsl | 96 ++ .../wgsl-mat2-uniform-alignment.spvasm.glsl | 30 + naga/tests/out/spv/wgsl-mat_cx2.spvasm.glsl | 196 +++++ .../out/spv/wgsl-mat_cx2_f16.spvasm.glsl | 218 +++++ naga/tests/out/spv/wgsl-mat_cx3.spvasm.glsl | 131 +++ .../out/spv/wgsl-math-functions.spvasm.glsl | 64 ++ ...sl-memory-decorations-coherent.spvasm.glsl | 18 + .../spv/wgsl-memory-decorations.spvasm.glsl | 29 + .../spv/wgsl-mesh-shader-empty.spvasm.glsl | 127 +++ .../spv/wgsl-mesh-shader-lines.spvasm.glsl | 127 +++ .../spv/wgsl-mesh-shader-points.spvasm.glsl | 127 +++ .../out/spv/wgsl-mesh-shader.spvasm.glsl | 511 +++++++++++ naga/tests/out/spv/wgsl-multiview.spvasm.glsl | 7 + naga/tests/out/spv/wgsl-operators.spvasm.glsl | 295 +++++++ ...es-atomicCompareExchangeWeak.f.spvasm.glsl | 21 + .../wgsl-overrides-ray-query.main.spvasm.glsl | 71 ++ .../out/spv/wgsl-overrides.main.spvasm.glsl | 16 + naga/tests/out/spv/wgsl-padding.spvasm.glsl | 45 + .../tests/out/spv/wgsl-per-vertex.spvasm.glsl | 11 + .../out/spv/wgsl-phony_assignment.spvasm.glsl | 17 + naga/tests/out/spv/wgsl-pointers.spvasm.glsl | 31 + .../tests/out/spv/wgsl-policy-mix.spvasm.glsl | 62 ++ .../out/spv/wgsl-primitive-index.spvasm.glsl | 9 + naga/tests/out/spv/wgsl-quad.spvasm.glsl | 76 ++ ...gsl-ray-query-no-init-tracking.spvasm.glsl | 322 +++++++ naga/tests/out/spv/wgsl-ray-query.spvasm.glsl | 322 +++++++ .../spv/wgsl-ray-tracing-pipeline.spvasm.glsl | 146 +++ naga/tests/out/spv/wgsl-select.spvasm.glsl | 10 + ...-separate-entry-points.compute.spvasm.glsl | 17 + ...separate-entry-points.fragment.spvasm.glsl | 17 + naga/tests/out/spv/wgsl-shadow.spvasm.glsl | 260 ++++++ naga/tests/out/spv/wgsl-skybox.spvasm.glsl | 78 ++ naga/tests/out/spv/wgsl-sprite.spvasm.glsl | 13 + naga/tests/out/spv/wgsl-standard.spvasm.glsl | 26 + .../out/spv/wgsl-storage-textures.spvasm.glsl | 38 + .../out/spv/wgsl-struct-layout.spvasm.glsl | 285 ++++++ .../out/spv/wgsl-subgroup-barrier.spvasm.glsl | 10 + .../spv/wgsl-subgroup-operations.spvasm.glsl | 21 + .../out/spv/wgsl-texture-arg.spvasm.glsl | 17 + .../out/spv/wgsl-type-inference.spvasm.glsl | 36 + ...-workgroup-uniform-load-atomic.spvasm.glsl | 76 ++ .../wgsl-workgroup-uniform-load.spvasm.glsl | 26 + .../spv/wgsl-workgroup-var-init.spvasm.glsl | 27 + 130 files changed, 11945 insertions(+), 4 deletions(-) create mode 100644 naga/tests/out/spv/spv-barrier.spvasm.glsl create mode 100644 naga/tests/out/spv/spv-fetch_depth.spvasm.glsl create mode 100644 naga/tests/out/spv/spv-per-vertex.spvasm.glsl create mode 100644 naga/tests/out/spv/spv-subgroup-barrier.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-6220-break-from-loop.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-6772-unpack-expr-accesses.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-7995-unicode-idents.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-8820-multiple-local-invocation-index-id.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-9489-loop-local-var-init.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-const.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-let.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-operators.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-return.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-abstract-types-var.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-access.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-aliased-ray-query.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-array-in-ctor.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicCompareExchange-int64.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicOps-float32.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicOps-int64-min-max.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicOps-int64.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicOps.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicTexture-int64.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-atomicTexture.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-barycentrics.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-binding-arrays.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-binding-buffer-arrays.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bitcast.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bits.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-boids.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-bounds-check-zero.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-break-if.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-clip-distances.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-collatz.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-const-exprs.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-constructors.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-control-flow.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-conversions.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-cooperative-matrix.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-cross.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-draw-index.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-dualsource.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-early-depth-test-conservative.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-early-depth-test-force.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-empty-if.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-empty.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-extra.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-f16-native.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-f16-polyfill.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-f16.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-f64.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-fragment-output.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-functions-unoptimized.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-functions.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-globals.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-image.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-index-by-value.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-int-div-unchecked.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-int16.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-int64.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interface.compute.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interface.fragment.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interface.vertex.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interpolate.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-interpolate_compat.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mat2-uniform-alignment.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mat_cx2.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mat_cx3.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-math-functions.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-memory-decorations-coherent.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-memory-decorations.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mesh-shader-empty.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mesh-shader-lines.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mesh-shader-points.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-mesh-shader.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-multiview.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-operators.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-overrides-atomicCompareExchangeWeak.f.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-overrides.main.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-padding.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-per-vertex.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-phony_assignment.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-pointers.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-policy-mix.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-primitive-index.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-quad.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-ray-query-no-init-tracking.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-ray-query.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-ray-tracing-pipeline.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-select.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-separate-entry-points.compute.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-shadow.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-skybox.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-sprite.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-standard.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-storage-textures.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-struct-layout.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-subgroup-barrier.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-subgroup-operations.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-texture-arg.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-type-inference.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-workgroup-uniform-load-atomic.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-workgroup-uniform-load.spvasm.glsl create mode 100644 naga/tests/out/spv/wgsl-workgroup-var-init.spvasm.glsl diff --git a/Cargo.lock b/Cargo.lock index d642815f6..7e374bfbd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2350,6 +2350,7 @@ dependencies = [ "arrayvec", "bit-set 0.10.0", "bitflags 2.11.1", + "bytemuck", "cfg-if", "cfg_aliases", "codespan-reporting", diff --git a/naga/Cargo.toml b/naga/Cargo.toml index 74aaa1b57..445ac3d98 100644 --- a/naga/Cargo.toml +++ b/naga/Cargo.toml @@ -110,6 +110,7 @@ unicode-ident = { workspace = true, optional = true } cfg_aliases.workspace = true [dev-dependencies] +bytemuck.workspace = true diff.workspace = true env_logger.workspace = true hashbrown = { workspace = true, features = ["serde"] } diff --git a/naga/tests/naga/snapshots.rs b/naga/tests/naga/snapshots.rs index ed1ebaae7..652304195 100644 --- a/naga/tests/naga/snapshots.rs +++ b/naga/tests/naga/snapshots.rs @@ -199,6 +199,117 @@ Note: this is an issue with snapshot configuration, not code. If you added a new } } +fn spirv_cross_stage_name(stage: naga::ShaderStage) -> &'static str { + match stage { + naga::ShaderStage::Vertex => "vert", + naga::ShaderStage::Fragment => "frag", + naga::ShaderStage::Compute => "comp", + naga::ShaderStage::Task => "task", + naga::ShaderStage::Mesh => "mesh", + naga::ShaderStage::RayGeneration => "rgen", + naga::ShaderStage::Miss => "rmiss", + naga::ShaderStage::AnyHit => "rahit", + naga::ShaderStage::ClosestHit => "rchit", + } +} + +fn run_spirv_cross( + spv_binary: &[u32], + entry_point: &str, + stage: naga::ShaderStage, +) -> Result { + use std::io::Write; + use std::process::{Command, Stdio}; + + let stage_name = spirv_cross_stage_name(stage); + let bytes: &[u8] = bytemuck::cast_slice(spv_binary); + + let mut child = Command::new("spirv-cross") + .args([ + "-V", + "--version", + "460", + "--entry", + entry_point, + "--stage", + stage_name, + "-", + ]) + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect( + "Failed to execute spirv-cross. Install it via the Vulkan SDK \ + or from https://github.com/KhronosGroup/SPIRV-Cross", + ); + + child.stdin.take().unwrap().write_all(bytes).unwrap(); + + let output = child.wait_with_output().unwrap(); + let stderr = String::from_utf8_lossy(&output.stderr).replace("\r\n", "\n"); + let stdout = String::from_utf8_lossy(&output.stdout).replace("\r\n", "\n"); + + if !output.status.success() { + let mut commented = String::from("// spirv-cross error:\n"); + for line in stderr.lines() { + commented.push_str(&format!("// {line}\n")); + } + Err(commented) + } else { + Ok(stdout) + } +} + +/// Writes GLSL output generated by SPIRV-Cross for the given SPIR-V binary. +/// +/// Behavior: +/// - For multiple entry points, each GLSL output is prefixed with a comment block +/// indicating the entry point name and shader stage (e.g., `// Entry point: "main" (frag) //`). +/// - For a single entry point, no header is added (cleaner output for single-shader files). +/// - On SPIRV-Cross failure, stderr is captured as commented lines in the output file, +/// and the function continues to write remaining entry points. This ensures test +/// snapshots are always generated even when translation fails. +/// - For a module with no entry points, a comment is written instead of an empty file. +fn write_spirv_cross_glsl( + input: &Input, + spv_binary: &[u32], + entry_points: &[(String, naga::ShaderStage)], + extension: &str, +) { + let multiple = entry_points.len() > 1; + let mut output = String::new(); + + if entry_points.is_empty() { + output.push_str("// No entry points; nothing to translate.\n"); + } + + for (i, (name, stage)) in entry_points.iter().enumerate() { + if multiple { + if i > 0 { + output.push('\n'); + } + let stage_name = spirv_cross_stage_name(*stage); + let inner = format!(" Entry point: \"{name}\" ({stage_name}) "); + let width = inner.len() + "//".len() * 2; + let bar: String = "/".repeat(width); + output.push_str(&bar); + output.push('\n'); + output.push_str(&format!("//{inner}//")); + output.push('\n'); + output.push_str(&bar); + output.push('\n'); + } + + match run_spirv_cross(spv_binary, name, *stage) { + Ok(glsl) => output.push_str(&glsl), + Err(err) => output.push_str(&err), + } + } + + input.write_output_file("spv", extension, output, DIR_OUT); +} + fn write_output_spv( input: &Input, module: &naga::Module, @@ -222,7 +333,7 @@ fn write_output_spv( entry_point: ep.name.clone(), shader_stage: ep.stage, }; - write_output_spv_inner( + let spv_binary = write_output_spv_inner( input, &module, &info, @@ -230,9 +341,21 @@ fn write_output_spv( Some(&pipeline_options), &format!("{}.spvasm", ep.name), ); + write_spirv_cross_glsl( + input, + &spv_binary, + &[(ep.name.clone(), ep.stage)], + &format!("{}.spvasm.glsl", ep.name), + ); } } else { - write_output_spv_inner(input, &module, &info, &options, None, "spvasm"); + let spv_binary = write_output_spv_inner(input, &module, &info, &options, None, "spvasm"); + let entry_points: Vec<(String, naga::ShaderStage)> = module + .entry_points + .iter() + .map(|ep| (ep.name.clone(), ep.stage)) + .collect(); + write_spirv_cross_glsl(input, &spv_binary, &entry_points, "spvasm.glsl"); } } @@ -243,12 +366,12 @@ fn write_output_spv_inner( options: &naga::back::spv::Options<'_>, pipeline_options: Option<&naga::back::spv::PipelineOptions>, extension: &str, -) { +) -> Vec { use naga::back::spv; use rspirv::binary::Disassemble; println!("Generating SPIR-V for {:?}", input.file_name); let spv = spv::write_vec(module, info, options, pipeline_options).unwrap(); - let dis = rspirv::dr::load_words(spv) + let dis = rspirv::dr::load_words(spv.clone()) .expect("Produced invalid SPIR-V") .disassemble(); // HACK escape CR/LF if source code is in side. @@ -259,6 +382,7 @@ fn write_output_spv_inner( dis }; input.write_output_file("spv", extension, dis, DIR_OUT); + spv } fn write_output_msl( diff --git a/naga/tests/out/spv/spv-barrier.spvasm.glsl b/naga/tests/out/spv/spv-barrier.spvasm.glsl new file mode 100644 index 000000000..1879f3ba9 --- /dev/null +++ b/naga/tests/out/spv/spv-barrier.spvasm.glsl @@ -0,0 +1,18 @@ +#version 460 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void _4() +{ + barrier(); + memoryBarrierBuffer(); + memoryBarrierImage(); + barrier(); + memoryBarrier(); + barrier(); +} + +void main() +{ + _4(); +} + diff --git a/naga/tests/out/spv/spv-fetch_depth.spvasm.glsl b/naga/tests/out/spv/spv-fetch_depth.spvasm.glsl new file mode 100644 index 000000000..870d16370 --- /dev/null +++ b/naga/tests/out/spv/spv-fetch_depth.spvasm.glsl @@ -0,0 +1,36 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require +layout(local_size_x = 32, local_size_y = 1, local_size_z = 1) in; + +struct _5 +{ + float _m0; +}; + +struct _8 +{ + uvec2 _m0; +}; + +layout(set = 0, binding = 0, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 1, std430) readonly buffer _15_14 +{ + _8 _m0; +} _14; + +layout(set = 0, binding = 2) uniform texture2D _17; + +void _20() +{ + _11._m0._m0 = vec4(texelFetch(_17, ivec2(_14._m0._m0), 0).x).x; +} + +void main() +{ + _20(); +} + diff --git a/naga/tests/out/spv/spv-per-vertex.spvasm.glsl b/naga/tests/out/spv/spv-per-vertex.spvasm.glsl new file mode 100644 index 000000000..bd897872b --- /dev/null +++ b/naga/tests/out/spv/spv-per-vertex.spvasm.glsl @@ -0,0 +1,20 @@ +#version 460 +#extension GL_EXT_fragment_shader_barycentric : require + +layout(location = 0) pervertexEXT in float _25[3]; +layout(location = 0) out vec4 _28; +float _9[3] = float[](0.0, 0.0, 0.0); +vec4 _12 = vec4(0.0); + +void _16() +{ + _12 = vec4(_9[0], _9[1], _9[2], 1.0); +} + +void main() +{ + _9 = _25; + _16(); + _28 = _12; +} + diff --git a/naga/tests/out/spv/spv-subgroup-barrier.spvasm.glsl b/naga/tests/out/spv/spv-subgroup-barrier.spvasm.glsl new file mode 100644 index 000000000..c3d21f7f5 --- /dev/null +++ b/naga/tests/out/spv/spv-subgroup-barrier.spvasm.glsl @@ -0,0 +1,15 @@ +#version 460 +#extension GL_KHR_shader_subgroup_basic : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +void _4() +{ + subgroupMemoryBarrier(); + subgroupBarrier(); +} + +void main() +{ + _4(); +} + diff --git a/naga/tests/out/spv/wgsl-6220-break-from-loop.spvasm.glsl b/naga/tests/out/spv/wgsl-6220-break-from-loop.spvasm.glsl new file mode 100644 index 000000000..3ffb974e0 --- /dev/null +++ b/naga/tests/out/spv/wgsl-6220-break-from-loop.spvasm.glsl @@ -0,0 +1,27 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _5() +{ + int _10 = 0; + uvec2 _27 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _27))) + { + break; + } + _27 -= uvec2(uint(_27.y == 0u), 1u); + if (!(_10 < 4)) + { + break; + } + break; + } +} + +void main() +{ + _5(); +} + diff --git a/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm.glsl b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm.glsl new file mode 100644 index 000000000..830f639b5 --- /dev/null +++ b/naga/tests/out/spv/wgsl-6438-conflicting-idents.spvasm.glsl @@ -0,0 +1,41 @@ +////////////////////////////// +// Entry point: "vs" (vert) // +////////////////////////////// +#version 460 + +struct _6 +{ + vec4 _m0; + vec2 _m1; +}; + +layout(location = 0) in vec2 _8; +layout(location = 0) out vec2 _13; + +void main() +{ + _6 _19 = _6(vec4(0.0), vec2(0.0)); + _19._m0 = vec4(_8, 0.0, 1.0); + gl_Position = _19._m0; + _13 = _19._m1; +} + + +////////////////////////////// +// Entry point: "fs" (frag) // +////////////////////////////// +#version 460 + +struct _6 +{ + vec4 _m0; + vec2 _m1; +}; + +layout(location = 0) out vec4 _32; + +void main() +{ + _32 = vec4(1.0, 0.0, 0.0, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-6772-unpack-expr-accesses.spvasm.glsl b/naga/tests/out/spv/wgsl-6772-unpack-expr-accesses.spvasm.glsl new file mode 100644 index 000000000..f26a015fe --- /dev/null +++ b/naga/tests/out/spv/wgsl-6772-unpack-expr-accesses.spvasm.glsl @@ -0,0 +1,9 @@ +#version 460 +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require +#extension GL_EXT_shader_8bit_storage : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm.glsl b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm.glsl new file mode 100644 index 000000000..9a13c9c9b --- /dev/null +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-1.spvasm.glsl @@ -0,0 +1,13 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const vec3 _13[2] = vec3[](vec3(0.0), vec3(0.0)); + +void main() +{ + vec4 _17 = vec4(0.0); + int _19 = 0; + int _21 = 0; + _17.x += (_13[_21].y * _13[_19].z); +} + diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm.glsl b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm.glsl new file mode 100644 index 000000000..ddc276597 --- /dev/null +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-2.spvasm.glsl @@ -0,0 +1,12 @@ +#version 460 + +const vec2 _17[2] = vec2[](vec2(0.0), vec2(0.0)); + +layout(location = 0) out vec4 _11; + +void main() +{ + int _19 = 0; + _11 = (_17[_19] * _17[_19]).xxyy; +} + diff --git a/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm.glsl b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm.glsl new file mode 100644 index 000000000..2fc47a3a8 --- /dev/null +++ b/naga/tests/out/spv/wgsl-7048-multiple-dynamic-3.spvasm.glsl @@ -0,0 +1,58 @@ +#version 460 + +struct _5 +{ + float _m0; + vec3 _m1; +}; + +const vec3 _93[12] = vec3[](vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); + +_5 _12(vec3 _10[12], uint _11) +{ + vec3 _21 = vec3(0.0); + vec3 _25 = vec3(0.0); + uint _19 = 0u; + uint _24 = 0u; + uvec2 _39 = uvec2(4294967295u); + uvec2 _67 = uvec2(4294967295u); + vec3 _58[12]; + for (;;) + { + if (all(equal(uvec2(0u), _39))) + { + break; + } + _39 -= uvec2(uint(_39.y == 0u), 1u); + if (!(_19 < _11)) + { + break; + } + _58 = _10; + _21 = _58[_19]; + _19++; + continue; + } + for (;;) + { + if (all(equal(uvec2(0u), _67))) + { + break; + } + _67 -= uvec2(uint(_67.y == 0u), 1u); + if (!(_24 < _11)) + { + break; + } + _58 = _10; + _25 = _58[_24]; + _24++; + continue; + } + return _5(0.0, vec3(0.0)); +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-7995-unicode-idents.spvasm.glsl b/naga/tests/out/spv/wgsl-7995-unicode-idents.spvasm.glsl new file mode 100644 index 000000000..818878bd0 --- /dev/null +++ b/naga/tests/out/spv/wgsl-7995-unicode-idents.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) readonly buffer _5_4 +{ + float _m0; +} _4; + +float _8() +{ + return _4._m0 + 9001.0; +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-8820-multiple-local-invocation-index-id.spvasm.glsl b/naga/tests/out/spv/wgsl-8820-multiple-local-invocation-index-id.spvasm.glsl new file mode 100644 index 000000000..be4808fa0 --- /dev/null +++ b/naga/tests/out/spv/wgsl-8820-multiple-local-invocation-index-id.spvasm.glsl @@ -0,0 +1,23 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _5 +{ + uvec3 _m0; + uint _m1; +}; + +shared uint _6; + +void main() +{ + _5 _9 = _5(gl_LocalInvocationID, gl_LocalInvocationIndex); + if (gl_LocalInvocationIndex == 0u) + { + _6 = 0u; + } + barrier(); + _6 = _9._m1 * 2u; + _6 += _9._m0.x; +} + diff --git a/naga/tests/out/spv/wgsl-9489-loop-local-var-init.spvasm.glsl b/naga/tests/out/spv/wgsl-9489-loop-local-var-init.spvasm.glsl new file mode 100644 index 000000000..462b78d1c --- /dev/null +++ b/naga/tests/out/spv/wgsl-9489-loop-local-var-init.spvasm.glsl @@ -0,0 +1,58 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) readonly buffer _11_10 +{ + float _m0[64]; +} _10; + +layout(set = 0, binding = 1, std430) buffer _14_13 +{ + float _m0[8]; +} _13; + +void main() +{ + vec4 _31 = vec4(0.0); + uint _29 = 0u; + vec4 _34 = vec4(0.0); + uvec2 _50 = uvec2(4294967295u); + uvec2 _71 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _50))) + { + break; + } + _50 -= uvec2(uint(_50.y == 0u), 1u); + if (!(_29 < 4u)) + { + break; + } + _31 = vec4(0.0); + _34 = vec4(0.0); + uint _36 = 0u; + for (;;) + { + if (all(equal(uvec2(0u), _71))) + { + break; + } + _71 -= uvec2(uint(_71.y == 0u), 1u); + if (!(_36 < 16u)) + { + break; + } + vec4 _95 = vec4(_10._m0[(_29 * 16u) + _36]); + _31 += _95; + _34 += _95; + _36++; + continue; + } + _13._m0[_29 * 2u] = _31.x; + _13._m0[(_29 * 2u) + 1u] = _34.x; + _29++; + continue; + } +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm.glsl new file mode 100644 index 000000000..f5c9fa7d7 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-builtins.spvasm.glsl @@ -0,0 +1,62 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + float _66 = 1.0; + float _63 = 1.0; + float _60 = 1.0; + float _57 = 1.0; + int _54 = 1; + float _51 = 1.0; + int _48 = 1; + float _45 = 1.0; + float _42 = 1.0; + float _39 = 1.0; + int _36 = 1; + int _33 = 1; + float _30 = 1.0; + float _27 = 1.0; + float _24 = 1.0; + float _21 = 1.0; + float _18 = 1.0; + float _15 = 1.0; + int _10 = 1; + float _64 = 1.0; + float _61 = 1.0; + float _58 = 1.0; + float _55 = 1.0; + float _52 = 1.0; + float _49 = 1.0; + int _46 = 1; + float _43 = 1.0; + float _40 = 1.0; + float _37 = 1.0; + int _34 = 1; + float _31 = 1.0; + float _28 = 1.0; + float _25 = 1.0; + float _22 = 1.0; + int _19 = 1; + float _16 = 1.0; + float _12 = 1.0; + float _65 = 1.0; + float _62 = 1.0; + float _59 = 1.0; + float _56 = 1.0; + int _53 = 1; + float _50 = 1.0; + float _47 = 1.0; + float _44 = 1.0; + float _41 = 1.0; + float _38 = 1.0; + int _35 = 1; + float _32 = 1.0; + float _29 = 1.0; + float _26 = 1.0; + float _23 = 1.0; + int _20 = 1; + float _17 = 1.0; + int _14 = 1; +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-const.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-const.spvasm.glsl new file mode 100644 index 000000000..0b206b7c5 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-const.spvasm.glsl @@ -0,0 +1 @@ +// No entry points; nothing to translate. diff --git a/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm.glsl new file mode 100644 index 000000000..73ba8f609 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-function-calls.spvasm.glsl @@ -0,0 +1,82 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _16(float _15) +{ +} + +void _21(int _20) +{ +} + +void _26(uint _25) +{ +} + +void _31(vec2 _30) +{ +} + +void _36(ivec2 _35) +{ +} + +void _41(uvec2 _40) +{ +} + +void _46(mat2 _45) +{ +} + +void _51(float _50[2]) +{ +} + +void _56(int _55[2]) +{ +} + +void _61(uint _60[2]) +{ +} + +void _67(float _65, int _66) +{ +} + +void main() +{ + _16(0.0); + _16(0.0); + _21(0); + _26(0u); + _16(0.0); + _16(0.0); + _21(0); + _26(0u); + _31(vec2(0.0)); + _31(vec2(0.0)); + _36(ivec2(0)); + _41(uvec2(0u)); + _31(vec2(0.0)); + _31(vec2(0.0)); + _36(ivec2(0)); + _41(uvec2(0u)); + _46(mat2(vec2(0.0), vec2(0.0))); + _46(mat2(vec2(0.0), vec2(0.0))); + _46(mat2(vec2(0.0), vec2(0.0))); + _51(float[](0.0, 0.0)); + _51(float[](0.0, 0.0)); + _56(int[](0, 0)); + _61(uint[](0u, 0u)); + _51(float[](0.0, 0.0)); + _51(float[](0.0, 0.0)); + _56(int[](0, 0)); + _61(uint[](0u, 0u)); + _67(0.0, 0); + _67(0.0, 0); + _67(0.0, 0); + _67(0.0, 0); +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-let.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-let.spvasm.glsl new file mode 100644 index 000000000..6c2619481 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-let.spvasm.glsl @@ -0,0 +1,20 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _19() +{ +} + +void _63() +{ + uint _64 = 0u; + int _67 = 0; + float _70 = 0.0; +} + +void main() +{ + _19(); + _63(); +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm.glsl new file mode 100644 index 000000000..28c1d2004 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-operators.spvasm.glsl @@ -0,0 +1,65 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +shared uint _17[64]; + +void _20() +{ + uint _63 = 0u; + uint _58 = 3u; + int _52 = 0; + float _47 = 0.0; + float _42 = 3.0; + float _38 = 3.0; + int _33 = 43; + int _67 = 0; + uint _61 = 0u; + int _56 = 0; + int _51 = 3; + float _45 = 0.0; + float _41 = 3.0; + float _37 = 3.0; + float _31 = 42.0; + int _65 = 0; + uint _59 = 0u; + int _54 = 0; + float _49 = 0.0; + float _43 = 0.0; + float _39 = 0.0; + uint _35 = 44u; + _39 = 1.0 + _31; + _43 = 1.0 + _31; + _45 = _31 + 2.0; + _47 = _31 + 2.0; + _49 = _31 + _31; + _52 = 1 + _33; + _54 = _33 + 2; + _56 = _33 + _33; + _59 = 1u + _35; + _61 = _35 + 2u; + _63 = _35 + _35; + _65 = 1 << int(_35); + _67 = 1 << int(_35); +} + +void _100() +{ +} + +void _105() +{ + int _107 = 1 - 1; +} + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _17 = uint[](0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u); + } + barrier(); + _20(); + _100(); + _105(); +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-return.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-return.spvasm.glsl new file mode 100644 index 000000000..b15d3c33d --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-return.spvasm.glsl @@ -0,0 +1,47 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +int _10() +{ + return 1; +} + +uint _15() +{ + return 1u; +} + +float _20() +{ + return 1.0; +} + +float _25() +{ + return 1.0; +} + +vec2 _28() +{ + return vec2(1.0); +} + +float[4] _33() +{ + return float[](1.0, 1.0, 1.0, 1.0); +} + +float _38() +{ + return 1.0; +} + +vec2 _41() +{ + return vec2(1.0); +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-abstract-types-var.spvasm.glsl b/naga/tests/out/spv/wgsl-abstract-types-var.spvasm.glsl new file mode 100644 index 000000000..99eff6b53 --- /dev/null +++ b/naga/tests/out/spv/wgsl-abstract-types-var.spvasm.glsl @@ -0,0 +1,239 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const float _52[2] = float[](1.0, 2.0); +const int _54[2] = int[](1, 2); +const uint _55[2] = uint[](1u, 2u); +const ivec3 _57[1] = ivec3[](ivec3(1)); +const vec3 _59[1] = vec3[](vec3(1.0)); + +ivec2 _60 = ivec2(42, 43); +uvec2 _62 = uvec2(44u, 45u); +vec2 _64 = vec2(46.0, 47.0); +vec2 _66 = vec2(48.0, 49.0); +vec2 _67 = vec2(48.0, 49.0); +uvec2 _68 = uvec2(42u, 43u); +uvec2 _69 = uvec2(42u, 43u); +uvec2 _70 = uvec2(42u, 43u); +uvec2 _71 = uvec2(42u, 43u); +ivec2 _72 = ivec2(0); +uvec2 _73 = uvec2(0u); +vec2 _74 = vec2(0.0); +mat2 _75 = mat2(vec2(0.0), vec2(0.0)); +mat2 _77 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); +mat2 _78 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); +mat2 _79 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); +mat2 _80 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); +mat2 _81 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); +ivec2 _82 = ivec2(1); +vec2 _83 = vec2(1.0); +ivec2 _84 = ivec2(1); +uvec2 _85 = uvec2(1u); +vec2 _86 = vec2(1.0); +vec2 _87 = vec2(1.0); +ivec2 _103 = ivec2(1); +uvec2 _104 = uvec2(1u); +vec2 _105 = vec2(1.0); +vec2 _106 = vec2(1.0); +ivec2 _107 = ivec2(1); +vec2 _108 = vec2(1.0); +ivec2 _109 = ivec2(1); +uvec2 _110 = uvec2(1u); +vec2 _111 = vec2(1.0); +vec2 _112 = vec2(1.0); + +void _123() +{ +} + +void _180() +{ + float _237[2] = _52; + vec2 _234 = vec2(1.0); + ivec2 _231 = ivec2(1); + ivec3 _226[1] = _57; + float _223[2] = _52; + int _220[2] = _54; + float _216[2] = _52; + vec2 _212 = vec2(1.0); + ivec2 _209 = ivec2(1); + mat2 _206 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _203 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _200 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _196 = mat2(vec2(0.0), vec2(0.0)); + ivec2 _193 = ivec2(0); + uvec2 _190 = uvec2(42u, 43u); + vec2 _187 = vec2(48.0, 49.0); + ivec2 _181 = ivec2(42, 43); + float _238[2] = _52; + int _235[2] = _54; + uvec2 _232 = uvec2(1u); + vec3 _228[1] = _59; + float _224[2] = _52; + int _221[2] = _54; + float _217[2] = _52; + float _213[2] = _52; + uvec2 _210 = uvec2(1u); + ivec2 _207 = ivec2(1); + mat2 _204 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _201 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _198 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + uvec2 _194 = uvec2(0u); + uvec2 _191 = uvec2(42u, 43u); + vec2 _188 = vec2(48.0, 49.0); + uvec2 _183 = uvec2(44u, 45u); + float _236[2] = _52; + vec2 _233 = vec2(1.0); + vec3 _230[1] = _59; + float _225[2] = _52; + float _222[2] = _52; + int _218[2] = _54; + float _215[2] = _52; + vec2 _211 = vec2(1.0); + vec2 _208 = vec2(1.0); + mat2 _205 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _202 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + mat2 _199 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + vec2 _195 = vec2(0.0); + uvec2 _192 = uvec2(42u, 43u); + uvec2 _189 = uvec2(42u, 43u); + vec2 _185 = vec2(46.0, 47.0); + _181 = ivec2(42, 43); + _183 = uvec2(44u, 45u); + _185 = vec2(46.0, 47.0); + _187 = vec2(48.0, 49.0); + _188 = vec2(48.0, 49.0); + _189 = uvec2(42u, 43u); + _190 = uvec2(42u, 43u); + _191 = uvec2(42u, 43u); + _192 = uvec2(42u, 43u); + _193 = ivec2(0); + _194 = uvec2(0u); + _195 = vec2(0.0); + _196 = mat2(vec2(0.0), vec2(0.0)); + _198 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _199 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _200 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _201 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _202 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _203 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _204 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _205 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _206 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + _207 = ivec2(1); + _208 = vec2(1.0); + _209 = ivec2(1); + _210 = uvec2(1u); + _211 = vec2(1.0); + _212 = vec2(1.0); + _213 = _52; + _215 = _52; + _216 = _52; + _217 = _52; + _218 = _54; + _220 = _54; + _221 = _54; + _222 = _52; + _223 = _52; + _224 = _52; + _225 = _52; + _226 = _57; + _228 = _59; + _230 = _59; + _231 = ivec2(1); + _232 = uvec2(1u); + _233 = vec2(1.0); + _234 = vec2(1.0); + _235 = _54; + _236 = _52; + _237 = _52; + _238 = _52; +} + +void _241() +{ + ivec2 _295 = ivec2(0); + float _289[2] = float[](0.0, 0.0); + float _283[2] = float[](0.0, 0.0); + float _277[2] = float[](0.0, 0.0); + float _271[2] = float[](0.0, 0.0); + mat2 _265 = mat2(vec2(0.0), vec2(0.0)); + uvec2 _259 = uvec2(0u); + uvec2 _253 = uvec2(0u); + int _245 = 0; + vec2 _299 = vec2(0.0); + int _293[2] = int[](0, 0); + float _287[2] = float[](0.0, 0.0); + int _281[2] = int[](0, 0); + float _275[2] = float[](0.0, 0.0); + mat2 _269 = mat2(vec2(0.0), vec2(0.0)); + mat2 _263 = mat2(vec2(0.0), vec2(0.0)); + vec2 _257 = vec2(0.0); + uvec2 _251 = uvec2(0u); + uint _242 = 0u; + uvec2 _297 = uvec2(0u); + int _291[2] = int[](0, 0); + float _285[2] = float[](0.0, 0.0); + int _279[2] = int[](0, 0); + float _273[2] = float[](0.0, 0.0); + mat2 _267 = mat2(vec2(0.0), vec2(0.0)); + uvec2 _261 = uvec2(0u); + vec2 _255 = vec2(0.0); + float _248 = 0.0; + _251 = uvec2(_242, 43u); + _253 = uvec2(42u, _242); + _255 = vec2(_248, 47.0); + _257 = vec2(_248, 49.0); + _259 = uvec2(_242, 43u); + _261 = uvec2(42u, _242); + _263 = mat2(vec2(_248, 2.0), vec2(3.0, 4.0)); + _265 = mat2(vec2(1.0, _248), vec2(3.0, 4.0)); + _267 = mat2(vec2(1.0, 2.0), vec2(_248, 4.0)); + _269 = mat2(vec2(1.0, 2.0), vec2(3.0, _248)); + _271 = float[](_248, 2.0); + _273 = float[](1.0, _248); + _275 = float[](_248, 2.0); + _277 = float[](1.0, _248); + _279 = int[](_245, 2); + _281 = int[](1, _245); + _283 = float[](_248, 2.0); + _285 = float[](1.0, _248); + _287 = float[](_248, 2.0); + _289 = float[](1.0, _248); + _291 = int[](_245, 2); + _293 = int[](1, _245); + _295 = ivec2(_245); + _297 = uvec2(_242); + _299 = vec2(_248); + _251 = uvec2(_242, 43u); + _253 = uvec2(42u, _242); + _259 = uvec2(_242, 43u); + _261 = uvec2(42u, _242); + _263 = mat2(vec2(_248, 2.0), vec2(3.0, 4.0)); + _265 = mat2(vec2(1.0, _248), vec2(3.0, 4.0)); + _267 = mat2(vec2(1.0, 2.0), vec2(_248, 4.0)); + _269 = mat2(vec2(1.0, 2.0), vec2(3.0, _248)); + _271 = float[](_248, 2.0); + _273 = float[](1.0, _248); + _275 = float[](_248, 2.0); + _277 = float[](1.0, _248); + _279 = int[](_245, 2); + _281 = int[](1, _245); + _283 = float[](_248, 2.0); + _285 = float[](1.0, _248); + _287 = float[](_248, 2.0); + _289 = float[](1.0, _248); + _291 = int[](_245, 2); + _293 = int[](1, _245); + _295 = ivec2(_245); + _297 = uvec2(_242); + _299 = vec2(_248); +} + +void main() +{ + _123(); + _180(); + _241(); +} + diff --git a/naga/tests/out/spv/wgsl-access.spvasm.glsl b/naga/tests/out/spv/wgsl-access.spvasm.glsl new file mode 100644 index 000000000..5500d404a --- /dev/null +++ b/naga/tests/out/spv/wgsl-access.spvasm.glsl @@ -0,0 +1,17 @@ +//////////////////////////////////// +// Entry point: "foo_vert" (vert) // +//////////////////////////////////// +// spirv-cross error: +// SPIRV-Cross threw an exception: Buffer block cannot be expressed as any of std430, std140, scalar, even with enhanced layouts. You can try flattening this block to support a more flexible layout. + +//////////////////////////////////// +// Entry point: "foo_frag" (frag) // +//////////////////////////////////// +// spirv-cross error: +// SPIRV-Cross threw an exception: Buffer block cannot be expressed as any of std430, std140, scalar, even with enhanced layouts. You can try flattening this block to support a more flexible layout. + +/////////////////////////////////////// +// Entry point: "foo_compute" (comp) // +/////////////////////////////////////// +// spirv-cross error: +// SPIRV-Cross threw an exception: Buffer block cannot be expressed as any of std430, std140, scalar, even with enhanced layouts. You can try flattening this block to support a more flexible layout. diff --git a/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm.glsl b/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm.glsl new file mode 100644 index 000000000..b0d2a943b --- /dev/null +++ b/naga/tests/out/spv/wgsl-aliased-ray-query.spvasm.glsl @@ -0,0 +1,161 @@ +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _8 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +struct _12 +{ + uint _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + uint _m6; + vec2 _m7; + bool _m8; + mat4x3 _m9; + mat4x3 _m10; +}; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _13; + +void _40(rayQueryEXT _41, accelerationStructureEXT _42, _8 _43, inout uint _44, out float _45) +{ + bool _70 = (_43._m0 & 256u) != 0u; + bool _78 = (_43._m0 & 16u) != 0u; + bool _81 = (_43._m0 & 32u) != 0u; + bool _89 = (_43._m0 & 1u) != 0u; + bool _92 = (_43._m0 & 2u) != 0u; + bool _95 = (_43._m0 & 64u) != 0u; + bool _98 = (_43._m0 & 128u) != 0u; + _45 = _43._m3; + if (((((((!((((((_92 && _89) || (_98 && _89)) || (_98 && _92)) || (_98 && _95)) || (_95 && _89)) || (_95 && _92))) && (_43._m2 <= _43._m3)) && (_43._m2 >= 0.0)) && (!(any(isnan(_43._m4)) || any(isinf(_43._m4))))) && (!(any(isnan(_43._m5)) || any(isinf(_43._m5))))) && (!(((_43._m0 & 512u) != 0u) && _70))) && (!(((_78 && _70) || (_81 && _70)) || (_81 && _78)))) + { + rayQueryInitializeEXT(_41, _42, _43._m0, _43._m1, _43._m4, _43._m2, _43._m5, _43._m3); + _44 = 1u; + } + else + { + } +} + +_12 _126(rayQueryEXT _127, uint _128) +{ + _12 _131 = _12(0u, 0.0, 0u, 0u, 0u, 0u, 0u, vec2(0.0), false, mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)), mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0))); + if ((!((_128 & 4u) != 0u)) && ((_128 & 2u) != 0u)) + { + uint _141 = rayQueryGetIntersectionTypeEXT(_127, bool(0u)); + uint _143 = (_141 == 0u) ? 1u : 3u; + _131._m0 = _143; + bool _145 = _143 != 0u; + if (_145) + { + uint _148 = rayQueryGetIntersectionInstanceCustomIndexEXT(_127, bool(0u)); + uint _149 = rayQueryGetIntersectionInstanceIdEXT(_127, bool(0u)); + uint _150 = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(_127, bool(0u)); + uint _151 = rayQueryGetIntersectionGeometryIndexEXT(_127, bool(0u)); + uint _152 = rayQueryGetIntersectionPrimitiveIndexEXT(_127, bool(0u)); + mat4x3 _153 = rayQueryGetIntersectionObjectToWorldEXT(_127, bool(0u)); + mat4x3 _154 = rayQueryGetIntersectionWorldToObjectEXT(_127, bool(0u)); + _131._m2 = _148; + _131._m3 = _149; + _131._m4 = _150; + _131._m5 = _151; + _131._m6 = _152; + _131._m9 = _153; + _131._m10 = _154; + if (_145) + { + float _169 = rayQueryGetIntersectionTEXT(_127, bool(0u)); + _131._m1 = _169; + vec2 _171 = rayQueryGetIntersectionBarycentricsEXT(_127, bool(0u)); + bool _172 = rayQueryGetIntersectionFrontFaceEXT(_127, bool(0u)); + _131._m7 = _171; + _131._m8 = _172; + } + } + } + return _131; +} + +void _185(rayQueryEXT _186, uint _187, float _188, float _189) +{ + if ((!((_187 & 4u) != 0u)) && ((_187 & 2u) != 0u)) + { + uint _202 = rayQueryGetIntersectionTypeEXT(_186, bool(0u)); + float _204 = rayQueryGetRayTMinEXT(_186); + uint _205 = rayQueryGetIntersectionTypeEXT(_186, bool(1u)); + float _192; + if (_205 == 0u) + { + _192 = _189; + } + else + { + float _211 = rayQueryGetIntersectionTEXT(_186, bool(0u)); + _192 = _211; + } + if (((_188 >= _204) && (_188 <= _192)) && (_202 == 1u)) + { + rayQueryGenerateIntersectionEXT(_186, _188); + } + } +} + +void _226(rayQueryEXT _227, uint _228) +{ + if ((!((_228 & 4u) != 0u)) && ((_228 & 2u) != 0u)) + { + uint _239 = rayQueryGetIntersectionTypeEXT(_227, bool(0u)); + if (_239 == 0u) + { + rayQueryConfirmIntersectionEXT(_227); + } + } +} + +void _245(rayQueryEXT _246, uint _247) +{ + if ((!((_247 & 4u) != 0u)) && ((_247 & 2u) != 0u)) + { + rayQueryTerminateEXT(_246); + } +} + +void main() +{ + uint _34 = 0u; + float _37 = 0.0; + rayQueryEXT _31; + _40(_31, _13, _8(4u, 255u, 0.100000001490116119384765625, 100.0, vec3(0.0), vec3(0.0, 1.0, 0.0)), _34, _37); + _12 _178 = _126(_31, _34); + if (_178._m0 == 3u) + { + _185(_31, _34, 10.0, _37); + return; + } + else + { + if (_178._m0 == 1u) + { + _226(_31, _34); + return; + } + else + { + _245(_31, _34); + return; + } + } +} + diff --git a/naga/tests/out/spv/wgsl-array-in-ctor.spvasm.glsl b/naga/tests/out/spv/wgsl-array-in-ctor.spvasm.glsl new file mode 100644 index 000000000..cb57d18e3 --- /dev/null +++ b/naga/tests/out/spv/wgsl-array-in-ctor.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + float _m0[2]; +}; + +layout(set = 0, binding = 0, std430) readonly buffer _9_8 +{ + _7 _m0; +} _8; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm.glsl b/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm.glsl new file mode 100644 index 000000000..b2a77e6eb --- /dev/null +++ b/naga/tests/out/spv/wgsl-array-in-function-return-type.spvasm.glsl @@ -0,0 +1,20 @@ +#version 460 + +layout(location = 0) out vec4 _26; + +float[2] _11() +{ + return float[](1.0, 2.0); +} + +float[3][2] _18() +{ + return float[][](_11(), _11(), _11()); +} + +void main() +{ + float _32[3][2] = _18(); + _26 = vec4(_32[0][0], _32[0][1], 0.0, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-atomicCompareExchange-int64.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicCompareExchange-int64.spvasm.glsl new file mode 100644 index 000000000..9d3713899 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicCompareExchange-int64.spvasm.glsl @@ -0,0 +1,157 @@ +//////////////////////////////////////////////////////////// +// Entry point: "test_atomic_compare_exchange_i64" (comp) // +//////////////////////////////////////////////////////////// +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_atomic_int64 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + int64_t _m0; + bool _m1; +}; + +struct _11 +{ + uint64_t _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _13_12 +{ + int64_t _m0[128]; +} _12; + +layout(set = 0, binding = 1, std430) buffer _16_15 +{ + uint64_t _m0[128]; +} _15; + +void main() +{ + uint _27 = 0u; + int64_t _29 = 0l; + bool _32 = false; + uvec2 _46 = uvec2(4294967295u); + uvec2 _73 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _46))) + { + break; + } + _46 -= uvec2(uint(_46.y == 0u), 1u); + if (!(_27 < 128u)) + { + break; + } + int64_t _66 = atomicAdd(_12._m0[_27], 0); + _29 = _66; + _32 = false; + for (;;) + { + if (all(equal(uvec2(0u), _73))) + { + break; + } + _73 -= uvec2(uint(_73.y == 0u), 1u); + if (!(!_32)) + { + break; + } + int64_t _93 = _29; + int64_t _96 = atomicCompSwap(_12._m0[_27], _93, _29 + 10l); + _10 _94 = _10(_96, _96 == _93); + _29 = _94._m0; + _32 = _94._m1; + continue; + } + _27++; + continue; + } +} + + +//////////////////////////////////////////////////////////// +// Entry point: "test_atomic_compare_exchange_u64" (comp) // +//////////////////////////////////////////////////////////// +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_atomic_int64 : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + int64_t _m0; + bool _m1; +}; + +struct _11 +{ + uint64_t _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _13_12 +{ + int64_t _m0[128]; +} _12; + +layout(set = 0, binding = 1, std430) buffer _16_15 +{ + uint64_t _m0[128]; +} _15; + +void main() +{ + uint _107 = 0u; + uint64_t _108 = 0ul; + bool _111 = false; + uvec2 _118 = uvec2(4294967295u); + uvec2 _143 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _118))) + { + break; + } + _118 -= uvec2(uint(_118.y == 0u), 1u); + if (!(_107 < 128u)) + { + break; + } + uint64_t _138 = atomicAdd(_15._m0[_107], 0); + _108 = _138; + _111 = false; + for (;;) + { + if (all(equal(uvec2(0u), _143))) + { + break; + } + _143 -= uvec2(uint(_143.y == 0u), 1u); + if (!(!_111)) + { + break; + } + uint64_t _163 = _108; + uint64_t _166 = atomicCompSwap(_15._m0[_107], _163, _108 + 10ul); + _11 _164 = _11(_166, _166 == _163); + _108 = _164._m0; + _111 = _164._m1; + continue; + } + _107++; + continue; + } +} + diff --git a/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm.glsl new file mode 100644 index 000000000..04c525f25 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicCompareExchange.spvasm.glsl @@ -0,0 +1,145 @@ +//////////////////////////////////////////////////////////// +// Entry point: "test_atomic_compare_exchange_i32" (comp) // +//////////////////////////////////////////////////////////// +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _9 +{ + int _m0; + bool _m1; +}; + +struct _10 +{ + uint _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _12_11 +{ + int _m0[128]; +} _11; + +layout(set = 0, binding = 1, std430) buffer _15_14 +{ + uint _m0[128]; +} _14; + +void main() +{ + uint _27 = 0u; + int _29 = 0; + bool _32 = false; + uvec2 _46 = uvec2(4294967295u); + uvec2 _72 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _46))) + { + break; + } + _46 -= uvec2(uint(_46.y == 0u), 1u); + if (!(_27 < 128u)) + { + break; + } + int _66 = atomicAdd(_11._m0[_27], 0); + _29 = _66; + _32 = false; + for (;;) + { + if (all(equal(uvec2(0u), _72))) + { + break; + } + _72 -= uvec2(uint(_72.y == 0u), 1u); + if (!(!_32)) + { + break; + } + int _94 = _29; + int _97 = atomicCompSwap(_11._m0[_27], _94, floatBitsToInt(intBitsToFloat(_29) + 1.0)); + _9 _95 = _9(_97, _97 == _94); + _29 = _95._m0; + _32 = _95._m1; + continue; + } + _27++; + continue; + } +} + + +//////////////////////////////////////////////////////////// +// Entry point: "test_atomic_compare_exchange_u32" (comp) // +//////////////////////////////////////////////////////////// +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _9 +{ + int _m0; + bool _m1; +}; + +struct _10 +{ + uint _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _12_11 +{ + int _m0[128]; +} _11; + +layout(set = 0, binding = 1, std430) buffer _15_14 +{ + uint _m0[128]; +} _14; + +void main() +{ + uint _107 = 0u; + uint _108 = 0u; + bool _110 = false; + uvec2 _117 = uvec2(4294967295u); + uvec2 _142 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _117))) + { + break; + } + _117 -= uvec2(uint(_117.y == 0u), 1u); + if (!(_107 < 128u)) + { + break; + } + uint _137 = atomicAdd(_14._m0[_107], 0u); + _108 = _137; + _110 = false; + for (;;) + { + if (all(equal(uvec2(0u), _142))) + { + break; + } + _142 -= uvec2(uint(_142.y == 0u), 1u); + if (!(!_110)) + { + break; + } + uint _164 = _108; + uint _167 = atomicCompSwap(_14._m0[_107], _164, floatBitsToUint(uintBitsToFloat(_108) + 1.0)); + _10 _165 = _10(_167, _167 == _164); + _108 = _165._m0; + _110 = _165._m1; + continue; + } + _107++; + continue; + } +} + diff --git a/naga/tests/out/spv/wgsl-atomicOps-float32.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicOps-float32.spvasm.glsl new file mode 100644 index 000000000..e704a9fb8 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicOps-float32.spvasm.glsl @@ -0,0 +1,48 @@ +#version 460 +#extension GL_EXT_shader_atomic_float : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + float _m0; + float _m1[2]; +}; + +layout(set = 0, binding = 0, std430) buffer _10_9 +{ + float _m0; +} _9; + +layout(set = 0, binding = 1, std430) buffer _13_12 +{ + float _m0[2]; +} _12; + +layout(set = 0, binding = 2, std430) buffer _16_15 +{ + _7 _m0; +} _15; + +void main() +{ + atomicExchange(_9._m0, 1.5); + atomicExchange(_12._m0[1u], 1.5); + atomicExchange(_15._m0._m0, 1.5); + atomicExchange(_15._m0._m1[1u], 1.5); + barrier(); + float _40 = atomicAdd(_9._m0, 0); + float _42 = atomicAdd(_12._m0[1u], 0); + float _44 = atomicAdd(_15._m0._m0, 0); + float _46 = atomicAdd(_15._m0._m1[1u], 0); + barrier(); + float _47 = atomicAdd(_9._m0, 1.5); + float _48 = atomicAdd(_12._m0[1u], 1.5); + float _50 = atomicAdd(_15._m0._m0, 1.5); + float _52 = atomicAdd(_15._m0._m1[1u], 1.5); + barrier(); + float _54 = atomicExchange(_9._m0, 1.5); + float _55 = atomicExchange(_12._m0[1u], 1.5); + float _57 = atomicExchange(_15._m0._m0, 1.5); + float _59 = atomicExchange(_15._m0._m1[1u], 1.5); +} + diff --git a/naga/tests/out/spv/wgsl-atomicOps-int64-min-max.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicOps-int64-min-max.spvasm.glsl new file mode 100644 index 000000000..c2926e805 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicOps-int64-min-max.spvasm.glsl @@ -0,0 +1,48 @@ +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_atomic_int64 : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + uint64_t _m0; + uint64_t _m1[2]; +}; + +layout(set = 0, binding = 0, std430) buffer _10_9 +{ + uint64_t _m0; +} _9; + +layout(set = 0, binding = 1, std430) buffer _13_12 +{ + uint64_t _m0[2]; +} _12; + +layout(set = 0, binding = 2, std430) buffer _16_15 +{ + _7 _m0; +} _15; + +layout(set = 0, binding = 3, std140) uniform _19_18 +{ + uint64_t _m0; +} _18; + +void main() +{ + uint64_t _39 = atomicMax(_9._m0, _18._m0); + uint64_t _44 = atomicMax(_12._m0[1u], 1ul + _18._m0); + uint64_t _47 = atomicMax(_15._m0._m0, 1ul); + uint64_t _51 = atomicMax(_15._m0._m1[1u], uint64_t(gl_LocalInvocationID.x)); + barrier(); + uint64_t _55 = atomicMin(_9._m0, _18._m0); + uint64_t _58 = atomicMin(_12._m0[1u], 1ul + _18._m0); + uint64_t _60 = atomicMin(_15._m0._m0, 1ul); + uint64_t _64 = atomicMin(_15._m0._m1[1u], uint64_t(gl_LocalInvocationID.x)); +} + diff --git a/naga/tests/out/spv/wgsl-atomicOps-int64.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicOps-int64.spvasm.glsl new file mode 100644 index 000000000..6380cebc2 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicOps-int64.spvasm.glsl @@ -0,0 +1,153 @@ +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_atomic_int64 : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +struct _8 +{ + uint64_t _m0; + int64_t _m1[2]; +}; + +struct _11 +{ + uint64_t _m0; + bool _m1; +}; + +struct _12 +{ + int64_t _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _14_13 +{ + uint64_t _m0; +} _13; + +layout(set = 0, binding = 1, std430) buffer _17_16 +{ + int64_t _m0[2]; +} _16; + +layout(set = 0, binding = 2, std430) buffer _20_19 +{ + _8 _m0; +} _19; + +shared uint64_t _22; +shared int64_t _24[2]; +shared _8 _26; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _22 = 0ul; + _24 = int64_t[](0l, 0l); + _26 = _8(0ul, int64_t[](0l, 0l)); + } + barrier(); + atomicExchange(_13._m0, 1ul); + atomicExchange(_16._m0[1u], 1l); + atomicExchange(_19._m0._m0, 1ul); + atomicExchange(_19._m0._m1[1u], 1l); + atomicExchange(_22, 1ul); + atomicExchange(_24[1u], 1l); + atomicExchange(_26._m0, 1ul); + atomicExchange(_26._m1[1u], 1l); + barrier(); + uint64_t _69 = atomicAdd(_13._m0, 0); + int64_t _71 = atomicAdd(_16._m0[1u], 0); + uint64_t _73 = atomicAdd(_19._m0._m0, 0); + int64_t _75 = atomicAdd(_19._m0._m1[1u], 0); + uint64_t _76 = atomicAdd(_22, 0); + int64_t _78 = atomicAdd(_24[1u], 0); + uint64_t _80 = atomicAdd(_26._m0, 0); + int64_t _82 = atomicAdd(_26._m1[1u], 0); + barrier(); + uint64_t _83 = atomicAdd(_13._m0, 1ul); + int64_t _84 = atomicAdd(_16._m0[1u], 1l); + uint64_t _86 = atomicAdd(_19._m0._m0, 1ul); + int64_t _88 = atomicAdd(_19._m0._m1[1u], 1l); + uint64_t _90 = atomicAdd(_22, 1ul); + int64_t _91 = atomicAdd(_24[1u], 1l); + uint64_t _93 = atomicAdd(_26._m0, 1ul); + int64_t _95 = atomicAdd(_26._m1[1u], 1l); + barrier(); + uint64_t _97 = atomicAdd(_13._m0, -1ul); + int64_t _98 = atomicAdd(_16._m0[1u], -1l); + uint64_t _100 = atomicAdd(_19._m0._m0, -1ul); + int64_t _102 = atomicAdd(_19._m0._m1[1u], -1l); + uint64_t _104 = atomicAdd(_22, -1ul); + int64_t _105 = atomicAdd(_24[1u], -1l); + uint64_t _107 = atomicAdd(_26._m0, -1ul); + int64_t _109 = atomicAdd(_26._m1[1u], -1l); + barrier(); + uint64_t _111 = atomicMax(_13._m0, 1ul); + int64_t _112 = atomicMax(_16._m0[1u], 1l); + uint64_t _114 = atomicMax(_19._m0._m0, 1ul); + int64_t _116 = atomicMax(_19._m0._m1[1u], 1l); + uint64_t _118 = atomicMax(_22, 1ul); + int64_t _119 = atomicMax(_24[1u], 1l); + uint64_t _121 = atomicMax(_26._m0, 1ul); + int64_t _123 = atomicMax(_26._m1[1u], 1l); + barrier(); + uint64_t _125 = atomicMin(_13._m0, 1ul); + int64_t _126 = atomicMin(_16._m0[1u], 1l); + uint64_t _128 = atomicMin(_19._m0._m0, 1ul); + int64_t _130 = atomicMin(_19._m0._m1[1u], 1l); + uint64_t _132 = atomicMin(_22, 1ul); + int64_t _133 = atomicMin(_24[1u], 1l); + uint64_t _135 = atomicMin(_26._m0, 1ul); + int64_t _137 = atomicMin(_26._m1[1u], 1l); + barrier(); + uint64_t _139 = atomicAnd(_13._m0, 1ul); + int64_t _140 = atomicAnd(_16._m0[1u], 1l); + uint64_t _142 = atomicAnd(_19._m0._m0, 1ul); + int64_t _144 = atomicAnd(_19._m0._m1[1u], 1l); + uint64_t _146 = atomicAnd(_22, 1ul); + int64_t _147 = atomicAnd(_24[1u], 1l); + uint64_t _149 = atomicAnd(_26._m0, 1ul); + int64_t _151 = atomicAnd(_26._m1[1u], 1l); + barrier(); + uint64_t _153 = atomicOr(_13._m0, 1ul); + int64_t _154 = atomicOr(_16._m0[1u], 1l); + uint64_t _156 = atomicOr(_19._m0._m0, 1ul); + int64_t _158 = atomicOr(_19._m0._m1[1u], 1l); + uint64_t _160 = atomicOr(_22, 1ul); + int64_t _161 = atomicOr(_24[1u], 1l); + uint64_t _163 = atomicOr(_26._m0, 1ul); + int64_t _165 = atomicOr(_26._m1[1u], 1l); + barrier(); + uint64_t _167 = atomicXor(_13._m0, 1ul); + int64_t _168 = atomicXor(_16._m0[1u], 1l); + uint64_t _170 = atomicXor(_19._m0._m0, 1ul); + int64_t _172 = atomicXor(_19._m0._m1[1u], 1l); + uint64_t _174 = atomicXor(_22, 1ul); + int64_t _175 = atomicXor(_24[1u], 1l); + uint64_t _177 = atomicXor(_26._m0, 1ul); + int64_t _179 = atomicXor(_26._m1[1u], 1l); + uint64_t _181 = atomicExchange(_13._m0, 1ul); + int64_t _182 = atomicExchange(_16._m0[1u], 1l); + uint64_t _184 = atomicExchange(_19._m0._m0, 1ul); + int64_t _186 = atomicExchange(_19._m0._m1[1u], 1l); + uint64_t _188 = atomicExchange(_22, 1ul); + int64_t _189 = atomicExchange(_24[1u], 1l); + uint64_t _191 = atomicExchange(_26._m0, 1ul); + int64_t _193 = atomicExchange(_26._m1[1u], 1l); + uint64_t _196 = atomicCompSwap(_13._m0, 1ul, 2ul); + int64_t _200 = atomicCompSwap(_16._m0[1u], 1l, 2l); + uint64_t _204 = atomicCompSwap(_19._m0._m0, 1ul, 2ul); + int64_t _208 = atomicCompSwap(_19._m0._m1[1u], 1l, 2l); + uint64_t _211 = atomicCompSwap(_22, 1ul, 2ul); + int64_t _215 = atomicCompSwap(_24[1u], 1l, 2l); + uint64_t _219 = atomicCompSwap(_26._m0, 1ul, 2ul); + int64_t _223 = atomicCompSwap(_26._m1[1u], 1l, 2l); +} + diff --git a/naga/tests/out/spv/wgsl-atomicOps.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicOps.spvasm.glsl new file mode 100644 index 000000000..5f93264d5 --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicOps.spvasm.glsl @@ -0,0 +1,147 @@ +#version 460 +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + uint _m0; + int _m1[2]; +}; + +struct _10 +{ + uint _m0; + bool _m1; +}; + +struct _11 +{ + int _m0; + bool _m1; +}; + +layout(set = 0, binding = 0, std430) buffer _13_12 +{ + uint _m0; +} _12; + +layout(set = 0, binding = 1, std430) buffer _16_15 +{ + int _m0[2]; +} _15; + +layout(set = 0, binding = 2, std430) buffer _19_18 +{ + _7 _m0; +} _18; + +shared uint _21; +shared int _23[2]; +shared _7 _25; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _21 = 0u; + _23 = int[](0, 0); + _25 = _7(0u, int[](0, 0)); + } + barrier(); + atomicExchange(_12._m0, 1u); + atomicExchange(_15._m0[1u], 1); + atomicExchange(_18._m0._m0, 1u); + atomicExchange(_18._m0._m1[1u], 1); + atomicExchange(_21, 1u); + atomicExchange(_23[1u], 1); + atomicExchange(_25._m0, 1u); + atomicExchange(_25._m1[1u], 1); + barrier(); + uint _63 = atomicAdd(_12._m0, 0u); + int _65 = atomicAdd(_15._m0[1u], 0); + uint _67 = atomicAdd(_18._m0._m0, 0u); + int _69 = atomicAdd(_18._m0._m1[1u], 0); + uint _70 = atomicAdd(_21, 0u); + int _72 = atomicAdd(_23[1u], 0); + uint _74 = atomicAdd(_25._m0, 0u); + int _76 = atomicAdd(_25._m1[1u], 0); + barrier(); + uint _77 = atomicAdd(_12._m0, 1u); + int _78 = atomicAdd(_15._m0[1u], 1); + uint _80 = atomicAdd(_18._m0._m0, 1u); + int _82 = atomicAdd(_18._m0._m1[1u], 1); + uint _84 = atomicAdd(_21, 1u); + int _85 = atomicAdd(_23[1u], 1); + uint _87 = atomicAdd(_25._m0, 1u); + int _89 = atomicAdd(_25._m1[1u], 1); + barrier(); + uint _91 = atomicAdd(_12._m0, -1u); + int _92 = atomicAdd(_15._m0[1u], -1); + uint _94 = atomicAdd(_18._m0._m0, -1u); + int _96 = atomicAdd(_18._m0._m1[1u], -1); + uint _98 = atomicAdd(_21, -1u); + int _99 = atomicAdd(_23[1u], -1); + uint _101 = atomicAdd(_25._m0, -1u); + int _103 = atomicAdd(_25._m1[1u], -1); + barrier(); + uint _105 = atomicMax(_12._m0, 1u); + int _106 = atomicMax(_15._m0[1u], 1); + uint _108 = atomicMax(_18._m0._m0, 1u); + int _110 = atomicMax(_18._m0._m1[1u], 1); + uint _112 = atomicMax(_21, 1u); + int _113 = atomicMax(_23[1u], 1); + uint _115 = atomicMax(_25._m0, 1u); + int _117 = atomicMax(_25._m1[1u], 1); + barrier(); + uint _119 = atomicMin(_12._m0, 1u); + int _120 = atomicMin(_15._m0[1u], 1); + uint _122 = atomicMin(_18._m0._m0, 1u); + int _124 = atomicMin(_18._m0._m1[1u], 1); + uint _126 = atomicMin(_21, 1u); + int _127 = atomicMin(_23[1u], 1); + uint _129 = atomicMin(_25._m0, 1u); + int _131 = atomicMin(_25._m1[1u], 1); + barrier(); + uint _133 = atomicAnd(_12._m0, 1u); + int _134 = atomicAnd(_15._m0[1u], 1); + uint _136 = atomicAnd(_18._m0._m0, 1u); + int _138 = atomicAnd(_18._m0._m1[1u], 1); + uint _140 = atomicAnd(_21, 1u); + int _141 = atomicAnd(_23[1u], 1); + uint _143 = atomicAnd(_25._m0, 1u); + int _145 = atomicAnd(_25._m1[1u], 1); + barrier(); + uint _147 = atomicOr(_12._m0, 1u); + int _148 = atomicOr(_15._m0[1u], 1); + uint _150 = atomicOr(_18._m0._m0, 1u); + int _152 = atomicOr(_18._m0._m1[1u], 1); + uint _154 = atomicOr(_21, 1u); + int _155 = atomicOr(_23[1u], 1); + uint _157 = atomicOr(_25._m0, 1u); + int _159 = atomicOr(_25._m1[1u], 1); + barrier(); + uint _161 = atomicXor(_12._m0, 1u); + int _162 = atomicXor(_15._m0[1u], 1); + uint _164 = atomicXor(_18._m0._m0, 1u); + int _166 = atomicXor(_18._m0._m1[1u], 1); + uint _168 = atomicXor(_21, 1u); + int _169 = atomicXor(_23[1u], 1); + uint _171 = atomicXor(_25._m0, 1u); + int _173 = atomicXor(_25._m1[1u], 1); + uint _175 = atomicExchange(_12._m0, 1u); + int _176 = atomicExchange(_15._m0[1u], 1); + uint _178 = atomicExchange(_18._m0._m0, 1u); + int _180 = atomicExchange(_18._m0._m1[1u], 1); + uint _182 = atomicExchange(_21, 1u); + int _183 = atomicExchange(_23[1u], 1); + uint _185 = atomicExchange(_25._m0, 1u); + int _187 = atomicExchange(_25._m1[1u], 1); + uint _190 = atomicCompSwap(_12._m0, 1u, 2u); + int _194 = atomicCompSwap(_15._m0[1u], 1, 2); + uint _198 = atomicCompSwap(_18._m0._m0, 1u, 2u); + int _202 = atomicCompSwap(_18._m0._m1[1u], 1, 2); + uint _205 = atomicCompSwap(_21, 1u, 2u); + int _209 = atomicCompSwap(_23[1u], 1, 2); + uint _213 = atomicCompSwap(_25._m0, 1u, 2u); + int _217 = atomicCompSwap(_25._m1[1u], 1, 2); +} + diff --git a/naga/tests/out/spv/wgsl-atomicTexture-int64.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicTexture-int64.spvasm.glsl new file mode 100644 index 000000000..5a9ee550c --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicTexture-int64.spvasm.glsl @@ -0,0 +1,19 @@ +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +#extension GL_EXT_shader_image_int64 : require +#extension GL_EXT_shader_atomic_int64 : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, r64ui) uniform u64image2D _9; + +void main() +{ + uint64_t _25 = imageAtomicMax(_9, ivec2(0), 1ul); + barrier(); + uint64_t _30 = imageAtomicMin(_9, ivec2(0), 1ul); +} + diff --git a/naga/tests/out/spv/wgsl-atomicTexture.spvasm.glsl b/naga/tests/out/spv/wgsl-atomicTexture.spvasm.glsl new file mode 100644 index 000000000..7a9620dad --- /dev/null +++ b/naga/tests/out/spv/wgsl-atomicTexture.spvasm.glsl @@ -0,0 +1,22 @@ +#version 460 +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, r32ui) uniform uimage2D _9; +layout(set = 0, binding = 1, r32i) uniform iimage2D _11; + +void main() +{ + uint _29 = imageAtomicMax(_9, ivec2(0), 1u); + uint _31 = imageAtomicMin(_9, ivec2(0), 1u); + uint _33 = imageAtomicAdd(_9, ivec2(0), 1u); + uint _35 = imageAtomicAnd(_9, ivec2(0), 1u); + uint _37 = imageAtomicOr(_9, ivec2(0), 1u); + uint _39 = imageAtomicXor(_9, ivec2(0), 1u); + int _42 = imageAtomicMax(_11, ivec2(0), 1); + int _44 = imageAtomicMin(_11, ivec2(0), 1); + int _46 = imageAtomicAdd(_11, ivec2(0), 1); + int _48 = imageAtomicAnd(_11, ivec2(0), 1); + int _50 = imageAtomicOr(_11, ivec2(0), 1); + int _52 = imageAtomicXor(_11, ivec2(0), 1); +} + diff --git a/naga/tests/out/spv/wgsl-barycentrics.spvasm.glsl b/naga/tests/out/spv/wgsl-barycentrics.spvasm.glsl new file mode 100644 index 000000000..85ac3a0d6 --- /dev/null +++ b/naga/tests/out/spv/wgsl-barycentrics.spvasm.glsl @@ -0,0 +1,27 @@ +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_fragment_shader_barycentric : require + +layout(location = 0) out vec4 _10; + +void main() +{ + _10 = vec4(gl_BaryCoordEXT, 1.0); +} + + +////////////////////////////////////////////////// +// Entry point: "fs_main_no_perspective" (frag) // +////////////////////////////////////////////////// +#version 460 +#extension GL_EXT_fragment_shader_barycentric : require + +layout(location = 0) out vec4 _20; + +void main() +{ + _20 = vec4(gl_BaryCoordNoPerspEXT, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-binding-arrays.spvasm.glsl b/naga/tests/out/spv/wgsl-binding-arrays.spvasm.glsl new file mode 100644 index 000000000..cf148f3da --- /dev/null +++ b/naga/tests/out/spv/wgsl-binding-arrays.spvasm.glsl @@ -0,0 +1,131 @@ +#version 460 +#extension GL_EXT_nonuniform_qualifier : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _4 +{ + uint _m0; +}; + +struct _21 +{ + uint _m0; +}; + +layout(set = 0, binding = 8, std140) uniform _43_42 +{ + _4 _m0; +} _42; + +layout(set = 0, binding = 0) uniform texture2D _24[10]; +layout(set = 0, binding = 1) uniform texture2D _28[5]; +layout(set = 0, binding = 2) uniform texture2DArray _30[5]; +layout(set = 0, binding = 3) uniform texture2DMS _32[5]; +layout(set = 0, binding = 4) uniform texture2D _34[5]; +layout(set = 0, binding = 5, rgba32f) uniform writeonly image2D _36[5]; +layout(set = 0, binding = 6) uniform sampler _38[5]; +layout(set = 0, binding = 7) uniform samplerShadow _40[5]; + +layout(location = 0) flat in uint _47; +layout(location = 0) out vec4 _50; + +void main() +{ + uvec2 _68 = uvec2(0u); + vec4 _72 = vec4(0.0); + uint _66 = 0u; + float _70 = 0.0; + uint _78 = _21(_47)._m0; + _68 += uvec2(textureSize(_24[0u], int(0u))); + _68 += uvec2(textureSize(_24[_42._m0._m0], int(0u))); + _68 += uvec2(textureSize(_24[nonuniformEXT(_78)], int(0u))); + _72 += textureGather(sampler2D(_28[0u], _38[0u]), vec2(0.0)); + _72 += textureGather(sampler2D(_28[_42._m0._m0], _38[_42._m0._m0]), vec2(0.0)); + _72 += textureGather(sampler2D(_28[_78], _38[_78]), vec2(0.0)); + _72 += textureGather(sampler2DShadow(_34[0u], _40[0u]), vec2(0.0), 0.0); + _72 += textureGather(sampler2DShadow(_34[_42._m0._m0], _40[_42._m0._m0]), vec2(0.0), 0.0); + _72 += textureGather(sampler2DShadow(_34[_78], _40[_78]), vec2(0.0), 0.0); + vec4 _162; + if (uint(0) < uint(textureQueryLevels(_24[0u]))) + { + if (all(lessThan(uvec2(ivec2(0)), uvec2(textureSize(_24[0u], 0))))) + { + _162 = texelFetch(_24[0u], ivec2(0), 0); + } + else + { + _162 = vec4(0.0); + } + } + else + { + _162 = vec4(0.0); + } + _72 += _162; + vec4 _176; + if (uint(0) < uint(textureQueryLevels(_24[_42._m0._m0]))) + { + if (all(lessThan(uvec2(ivec2(0)), uvec2(textureSize(_24[_42._m0._m0], 0))))) + { + _176 = texelFetch(_24[_42._m0._m0], ivec2(0), 0); + } + else + { + _176 = vec4(0.0); + } + } + else + { + _176 = vec4(0.0); + } + _72 += _176; + vec4 _190; + if (uint(0) < uint(textureQueryLevels(_24[nonuniformEXT(_78)]))) + { + if (all(lessThan(uvec2(ivec2(0)), uvec2(textureSize(_24[nonuniformEXT(_78)], 0))))) + { + _190 = texelFetch(_24[nonuniformEXT(_78)], ivec2(0), 0); + } + else + { + _190 = vec4(0.0); + } + } + else + { + _190 = vec4(0.0); + } + _72 += _190; + _66 += uvec3(textureSize(_30[0u], int(0u))).z; + _66 += uvec3(textureSize(_30[_42._m0._m0], int(0u))).z; + _66 += uvec3(textureSize(_30[nonuniformEXT(_78)], int(0u))).z; + _66 += uint(textureQueryLevels(_28[0u])); + _66 += uint(textureQueryLevels(_28[_42._m0._m0])); + _66 += uint(textureQueryLevels(_28[nonuniformEXT(_78)])); + _66 += uint(textureSamples(_32[0u])); + _66 += uint(textureSamples(_32[_42._m0._m0])); + _66 += uint(textureSamples(_32[nonuniformEXT(_78)])); + _72 += texture(sampler2D(_28[0u], _38[0u]), vec2(0.0)); + _72 += texture(sampler2D(_28[_42._m0._m0], _38[_42._m0._m0]), vec2(0.0)); + _72 += texture(sampler2D(_28[_78], _38[_78]), vec2(0.0)); + _72 += texture(sampler2D(_28[0u], _38[0u]), vec2(0.0), 0.0); + _72 += texture(sampler2D(_28[_42._m0._m0], _38[_42._m0._m0]), vec2(0.0), 0.0); + _72 += texture(sampler2D(_28[_78], _38[_78]), vec2(0.0), 0.0); + _70 += texture(sampler2DShadow(_34[0u], _40[0u]), vec3(vec2(0.0), 0.0)); + _70 += texture(sampler2DShadow(_34[_42._m0._m0], _40[_42._m0._m0]), vec3(vec2(0.0), 0.0)); + _70 += texture(sampler2DShadow(_34[_78], _40[_78]), vec3(vec2(0.0), 0.0)); + _70 += textureLod(sampler2DShadow(_34[0u], _40[0u]), vec3(vec2(0.0), 0.0), 0.0); + _70 += textureLod(sampler2DShadow(_34[_42._m0._m0], _40[_42._m0._m0]), vec3(vec2(0.0), 0.0), 0.0); + _70 += textureLod(sampler2DShadow(_34[_78], _40[_78]), vec3(vec2(0.0), 0.0), 0.0); + _72 += textureGrad(sampler2D(_28[0u], _38[0u]), vec2(0.0), vec2(0.0), vec2(0.0)); + _72 += textureGrad(sampler2D(_28[_42._m0._m0], _38[_42._m0._m0]), vec2(0.0), vec2(0.0), vec2(0.0)); + _72 += textureGrad(sampler2D(_28[_78], _38[_78]), vec2(0.0), vec2(0.0), vec2(0.0)); + _72 += textureLod(sampler2D(_28[0u], _38[0u]), vec2(0.0), 0.0); + _72 += textureLod(sampler2D(_28[_42._m0._m0], _38[_42._m0._m0]), vec2(0.0), 0.0); + _72 += textureLod(sampler2D(_28[_78], _38[_78]), vec2(0.0), 0.0); + imageStore(_36[0u], ivec2(0), _72); + imageStore(_36[_42._m0._m0], ivec2(0), _72); + imageStore(_36[nonuniformEXT(_78)], ivec2(0), _72); + _50 = (_72 + vec4(vec2(_68 + uvec2(_66)).xyxy)) + vec4(_70); +} + diff --git a/naga/tests/out/spv/wgsl-binding-buffer-arrays.spvasm.glsl b/naga/tests/out/spv/wgsl-binding-buffer-arrays.spvasm.glsl new file mode 100644 index 000000000..20d6858cf --- /dev/null +++ b/naga/tests/out/spv/wgsl-binding-buffer-arrays.spvasm.glsl @@ -0,0 +1,58 @@ +#version 460 +#extension GL_EXT_nonuniform_qualifier : require + +struct _4 +{ + uint _m0; +}; + +struct _10 +{ + uint _m0; +}; + +layout(set = 0, binding = 0, std430) readonly buffer _7_11 +{ + uint _m0; + int _m1[]; +} _11[10]; + +layout(set = 0, binding = 10, std140) uniform _16_15 +{ + _4 _m0; +} _15; + +layout(location = 0) flat in uint _20; +layout(location = 0) out uint _23; + +void main() +{ + uint _31 = 0u; + uint _37 = _10(_20)._m0; + _31 += _11[0u]._m0; + uint _52; + if (_15._m0._m0 < 1u) + { + _52 = _11[_15._m0._m0]._m0; + } + else + { + _52 = 0u; + } + _31 += _52; + uint _60; + if (_37 < 1u) + { + _60 = _11[nonuniformEXT(_37)]._m0; + } + else + { + _60 = 0u; + } + _31 += _60; + _31 += uint(_11[0u]._m1.length()); + _31 += uint(_11[_15._m0._m0]._m1.length()); + _31 += uint(_11[_37]._m1.length()); + _23 = _31; +} + diff --git a/naga/tests/out/spv/wgsl-bitcast.spvasm.glsl b/naga/tests/out/spv/wgsl-bitcast.spvasm.glsl new file mode 100644 index 000000000..b8f2d6d64 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bitcast.spvasm.glsl @@ -0,0 +1,25 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + vec2 _42 = vec2(0.0); + uvec2 _36 = uvec2(0u); + ivec2 _30 = ivec2(0); + vec3 _44 = vec3(0.0); + uvec3 _38 = uvec3(0u); + ivec3 _32 = ivec3(0); + vec4 _46 = vec4(0.0); + uvec4 _40 = uvec4(0u); + ivec4 _34 = ivec4(0); + _36 = uvec2(_30); + _38 = uvec3(_32); + _40 = uvec4(_34); + _30 = ivec2(_36); + _32 = ivec3(_38); + _34 = ivec4(_40); + _42 = intBitsToFloat(_30); + _44 = intBitsToFloat(_32); + _46 = intBitsToFloat(_34); +} + diff --git a/naga/tests/out/spv/wgsl-bits.spvasm.glsl b/naga/tests/out/spv/wgsl-bits.spvasm.glsl new file mode 100644 index 000000000..8ee8e3b92 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bits.spvasm.glsl @@ -0,0 +1,89 @@ +#version 460 +#extension GL_EXT_shader_explicit_arithmetic_types_int8 : require +#extension GL_EXT_shader_8bit_storage : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + vec4 _48 = vec4(0.0); + uvec3 _42 = uvec3(0u); + ivec4 _36 = ivec4(0); + int _30 = 0; + uvec4 _44 = uvec4(0u); + uint _38 = 0u; + ivec2 _32 = ivec2(0); + vec2 _46 = vec2(0.0); + uvec2 _40 = uvec2(0u); + ivec3 _34 = ivec3(0); + _38 = packSnorm4x8(_48); + _38 = packUnorm4x8(_48); + _38 = packSnorm2x16(_46); + _38 = packUnorm2x16(_46); + _38 = packHalf2x16(_46); + _38 = pack32(u8vec4(_36)); + _38 = pack32(u8vec4(_44)); + _38 = pack32(u8vec4(clamp(_36, ivec4(-128), ivec4(127)))); + _38 = pack32(u8vec4(clamp(_44, uvec4(0u), uvec4(255u)))); + _48 = unpackSnorm4x8(_38); + _48 = unpackUnorm4x8(_38); + _46 = unpackSnorm2x16(_38); + _46 = unpackUnorm2x16(_38); + _46 = unpackHalf2x16(_38); + _36 = ivec4(unpack8(_38)); + _44 = uvec4(unpack8(_38)); + uint _105 = min(5u, 32u); + _30 = bitfieldInsert(_30, _30, int(_105), int(min(10u, (32u - _105)))); + uint _111 = min(5u, 32u); + _32 = bitfieldInsert(_32, _32, int(_111), int(min(10u, (32u - _111)))); + uint _117 = min(5u, 32u); + _34 = bitfieldInsert(_34, _34, int(_117), int(min(10u, (32u - _117)))); + uint _123 = min(5u, 32u); + _36 = bitfieldInsert(_36, _36, int(_123), int(min(10u, (32u - _123)))); + uint _129 = min(5u, 32u); + _38 = bitfieldInsert(_38, _38, int(_129), int(min(10u, (32u - _129)))); + uint _135 = min(5u, 32u); + _40 = bitfieldInsert(_40, _40, int(_135), int(min(10u, (32u - _135)))); + uint _141 = min(5u, 32u); + _42 = bitfieldInsert(_42, _42, int(_141), int(min(10u, (32u - _141)))); + uint _147 = min(5u, 32u); + _44 = bitfieldInsert(_44, _44, int(_147), int(min(10u, (32u - _147)))); + uint _152 = min(5u, 32u); + _30 = bitfieldExtract(_30, int(_152), int(min(10u, (32u - _152)))); + uint _157 = min(5u, 32u); + _32 = bitfieldExtract(_32, int(_157), int(min(10u, (32u - _157)))); + uint _162 = min(5u, 32u); + _34 = bitfieldExtract(_34, int(_162), int(min(10u, (32u - _162)))); + uint _167 = min(5u, 32u); + _36 = bitfieldExtract(_36, int(_167), int(min(10u, (32u - _167)))); + uint _172 = min(5u, 32u); + _38 = bitfieldExtract(_38, int(_172), int(min(10u, (32u - _172)))); + uint _177 = min(5u, 32u); + _40 = bitfieldExtract(_40, int(_177), int(min(10u, (32u - _177)))); + uint _182 = min(5u, 32u); + _42 = bitfieldExtract(_42, int(_182), int(min(10u, (32u - _182)))); + uint _187 = min(5u, 32u); + _44 = bitfieldExtract(_44, int(_187), int(min(10u, (32u - _187)))); + _30 = findLSB(_30); + _40 = uvec2(findLSB(_40)); + _34 = findMSB(_34); + _42 = uvec3(findMSB(_42)); + _30 = findMSB(_30); + _38 = uint(findMSB(_38)); + _30 = bitCount(_30); + _32 = bitCount(_32); + _34 = bitCount(_34); + _36 = bitCount(_36); + _38 = uint(bitCount(_38)); + _40 = uvec2(bitCount(_40)); + _42 = uvec3(bitCount(_42)); + _44 = uvec4(bitCount(_44)); + _30 = bitfieldReverse(_30); + _32 = bitfieldReverse(_32); + _34 = bitfieldReverse(_34); + _36 = bitfieldReverse(_36); + _38 = bitfieldReverse(_38); + _40 = bitfieldReverse(_40); + _42 = bitfieldReverse(_42); + _44 = bitfieldReverse(_44); +} + diff --git a/naga/tests/out/spv/wgsl-boids.spvasm.glsl b/naga/tests/out/spv/wgsl-boids.spvasm.glsl new file mode 100644 index 000000000..223ed7011 --- /dev/null +++ b/naga/tests/out/spv/wgsl-boids.spvasm.glsl @@ -0,0 +1,122 @@ +#version 460 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct Particle +{ + vec2 pos; + vec2 vel; +}; + +struct SimParams +{ + float deltaT; + float rule1Distance; + float rule2Distance; + float rule3Distance; + float rule1Scale; + float rule2Scale; + float rule3Scale; +}; + +layout(set = 0, binding = 0, std140) uniform params +{ + SimParams _m0; +} params_1; + +layout(set = 0, binding = 1, std430) readonly buffer Particles +{ + Particle particles[]; +} particlesSrc; + +layout(set = 0, binding = 2, std430) buffer particlesDst +{ + Particle particles[]; +} particlesDst_1; + +void main() +{ + uint i = 0u; + int cVelCount = 0; + vec2 cVel = vec2(0.0); + vec2 vPos = vec2(0.0); + vec2 pos = vec2(0.0); + vec2 colVel = vec2(0.0); + vec2 vVel = vec2(0.0); + vec2 vel = vec2(0.0); + int cMassCount = 0; + vec2 cMass = vec2(0.0); + uvec2 loop_bound = uvec2(4294967295u); + if (gl_GlobalInvocationID.x >= 1500u) + { + return; + } + vPos = particlesSrc.particles[gl_GlobalInvocationID.x].pos; + vVel = particlesSrc.particles[gl_GlobalInvocationID.x].vel; + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (i >= 1500u) + { + break; + } + if (i == gl_GlobalInvocationID.x) + { + uint _144 = i; + i = _144 + 1u; + continue; + } + pos = particlesSrc.particles[i].pos; + vel = particlesSrc.particles[i].vel; + if (distance(pos, vPos) < params_1._m0.rule1Distance) + { + cMass += pos; + cMassCount++; + } + if (distance(pos, vPos) < params_1._m0.rule2Distance) + { + colVel -= (pos - vPos); + } + if (distance(pos, vPos) < params_1._m0.rule3Distance) + { + cVel += vel; + cVelCount++; + } + uint _144 = i; + i = _144 + 1u; + continue; + } + if (cMassCount > 0) + { + cMass = (cMass / vec2(float(cMassCount))) - vPos; + } + if (cVelCount > 0) + { + cVel /= vec2(float(cVelCount)); + } + vVel = ((vVel + (cMass * params_1._m0.rule1Scale)) + (colVel * params_1._m0.rule2Scale)) + (cVel * params_1._m0.rule3Scale); + vVel = normalize(vVel) * clamp(length(vVel), 0.0, 0.100000001490116119384765625); + vPos += (vVel * params_1._m0.deltaT); + if (vPos.x < (-1.0)) + { + vPos.x = 1.0; + } + if (vPos.x > 1.0) + { + vPos.x = -1.0; + } + if (vPos.y < (-1.0)) + { + vPos.y = 1.0; + } + if (vPos.y > 1.0) + { + vPos.y = -1.0; + } + particlesDst_1.particles[gl_GlobalInvocationID.x].pos = vPos; + particlesDst_1.particles[gl_GlobalInvocationID.x].vel = vVel; +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm.glsl new file mode 100644 index 000000000..1d55c0c65 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-image-restrict-depth.spvasm.glsl @@ -0,0 +1,37 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform texture2D image_depth_2d; +layout(set = 0, binding = 1) uniform texture2DArray image_depth_2d_array; +layout(set = 0, binding = 2) uniform texture2DMS image_depth_multisampled_2d; + +layout(location = 0) out vec4 _89; + +float test_textureLoad_depth_2d(ivec2 coords, int level) +{ + int _28 = int(min(uint(level), uint(textureQueryLevels(image_depth_2d) - 1))); + return texelFetch(image_depth_2d, ivec2(min(uvec2(coords), uvec2(textureSize(image_depth_2d, _28) - ivec2(1)))), _28).x; +} + +float test_textureLoad_depth_2d_array_u(ivec2 coords, uint index, int level) +{ + int _48 = int(min(uint(level), uint(textureQueryLevels(image_depth_2d_array) - 1))); + return texelFetch(image_depth_2d_array, ivec3(min(uvec3(ivec3(coords, int(index))), uvec3(textureSize(image_depth_2d_array, _48) - ivec3(1)))), _48).x; +} + +float test_textureLoad_depth_2d_array_s(ivec2 coords, int index, int level) +{ + int _66 = int(min(uint(level), uint(textureQueryLevels(image_depth_2d_array) - 1))); + return texelFetch(image_depth_2d_array, ivec3(min(uvec3(ivec3(coords, index)), uvec3(textureSize(image_depth_2d_array, _66) - ivec3(1)))), _66).x; +} + +float test_textureLoad_depth_multisampled_2d(ivec2 coords, int _sample) +{ + return texelFetch(image_depth_multisampled_2d, ivec2(min(uvec2(coords), uvec2(textureSize(image_depth_multisampled_2d) - ivec2(1)))), int(min(uint(_sample), uint(textureSamples(image_depth_multisampled_2d) - 1)))).x; +} + +void main() +{ + _89 = vec4(0.0); +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm.glsl new file mode 100644 index 000000000..8622362c7 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-image-restrict.spvasm.glsl @@ -0,0 +1,85 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 3) uniform texture3D image_3d; +layout(set = 0, binding = 4) uniform texture2DMS image_multisampled_2d; +layout(set = 0, binding = 5, rgba8) uniform writeonly image1D image_storage_1d; +layout(set = 0, binding = 6, rgba8) uniform writeonly image2D image_storage_2d; +layout(set = 0, binding = 7, rgba8) uniform writeonly image2DArray image_storage_2d_array; +layout(set = 0, binding = 8, rgba8) uniform writeonly image3D image_storage_3d; + +layout(location = 0) out vec4 _172; + +vec4 test_textureLoad_1d(int coords, int level) +{ + int _47 = int(min(uint(level), uint(textureQueryLevels(image_1d) - 1))); + return texelFetch(image_1d, int(min(uint(coords), uint(textureSize(image_1d, _47) - 1))), _47); +} + +vec4 test_textureLoad_2d(ivec2 coords, int level) +{ + int _61 = int(min(uint(level), uint(textureQueryLevels(image_2d) - 1))); + return texelFetch(image_2d, ivec2(min(uvec2(coords), uvec2(textureSize(image_2d, _61) - ivec2(1)))), _61); +} + +vec4 test_textureLoad_2d_array_u(ivec2 coords, uint index, int level) +{ + int _79 = int(min(uint(level), uint(textureQueryLevels(image_2d_array) - 1))); + return texelFetch(image_2d_array, ivec3(min(uvec3(ivec3(coords, int(index))), uvec3(textureSize(image_2d_array, _79) - ivec3(1)))), _79); +} + +vec4 test_textureLoad_2d_array_s(ivec2 coords, int index, int level) +{ + int _96 = int(min(uint(level), uint(textureQueryLevels(image_2d_array) - 1))); + return texelFetch(image_2d_array, ivec3(min(uvec3(ivec3(coords, index)), uvec3(textureSize(image_2d_array, _96) - ivec3(1)))), _96); +} + +vec4 test_textureLoad_3d(ivec3 coords, int level) +{ + int _111 = int(min(uint(level), uint(textureQueryLevels(image_3d) - 1))); + return texelFetch(image_3d, ivec3(min(uvec3(coords), uvec3(textureSize(image_3d, _111) - ivec3(1)))), _111); +} + +vec4 test_textureLoad_multisampled_2d(ivec2 coords, int _sample) +{ + return texelFetch(image_multisampled_2d, ivec2(min(uvec2(coords), uvec2(textureSize(image_multisampled_2d) - ivec2(1)))), int(min(uint(_sample), uint(textureSamples(image_multisampled_2d) - 1)))); +} + +void test_textureStore_1d(int coords, vec4 value) +{ + imageStore(image_storage_1d, coords, value); +} + +void test_textureStore_2d(ivec2 coords, vec4 value) +{ + imageStore(image_storage_2d, coords, value); +} + +void test_textureStore_2d_array_u(ivec2 coords, uint array_index, vec4 value) +{ + imageStore(image_storage_2d_array, ivec3(coords, int(array_index)), value); +} + +void test_textureStore_2d_array_s(ivec2 coords, int array_index, vec4 value) +{ + imageStore(image_storage_2d_array, ivec3(coords, array_index), value); +} + +void test_textureStore_3d(ivec3 coords, vec4 value) +{ + imageStore(image_storage_3d, coords, value); +} + +void main() +{ + test_textureStore_1d(0, vec4(0.0)); + test_textureStore_2d(ivec2(0), vec4(0.0)); + test_textureStore_2d_array_u(ivec2(0), 0u, vec4(0.0)); + test_textureStore_2d_array_s(ivec2(0), 0, vec4(0.0)); + test_textureStore_3d(ivec3(0), vec4(0.0)); + _172 = vec4(0.0); +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm.glsl new file mode 100644 index 000000000..fb9a6876d --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw-depth.spvasm.glsl @@ -0,0 +1,100 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform texture2D image_depth_2d; +layout(set = 0, binding = 1) uniform texture2DArray image_depth_2d_array; +layout(set = 0, binding = 2) uniform texture2DMS image_depth_multisampled_2d; + +layout(location = 0) out vec4 _100; + +float test_textureLoad_depth_2d(ivec2 coords, int level) +{ + vec4 _37; + if (uint(level) < uint(textureQueryLevels(image_depth_2d))) + { + if (all(lessThan(uvec2(coords), uvec2(textureSize(image_depth_2d, level))))) + { + _37 = texelFetch(image_depth_2d, coords, level); + } + else + { + _37 = vec4(0.0); + } + } + else + { + _37 = vec4(0.0); + } + return _37.x; +} + +float test_textureLoad_depth_2d_array_u(ivec2 coords, uint index, int level) +{ + ivec3 _49 = ivec3(coords, int(index)); + vec4 _60; + if (uint(level) < uint(textureQueryLevels(image_depth_2d_array))) + { + if (all(lessThan(uvec3(_49), uvec3(textureSize(image_depth_2d_array, level))))) + { + _60 = texelFetch(image_depth_2d_array, _49, level); + } + else + { + _60 = vec4(0.0); + } + } + else + { + _60 = vec4(0.0); + } + return _60.x; +} + +float test_textureLoad_depth_2d_array_s(ivec2 coords, int index, int level) +{ + ivec3 _70 = ivec3(coords, index); + vec4 _80; + if (uint(level) < uint(textureQueryLevels(image_depth_2d_array))) + { + if (all(lessThan(uvec3(_70), uvec3(textureSize(image_depth_2d_array, level))))) + { + _80 = texelFetch(image_depth_2d_array, _70, level); + } + else + { + _80 = vec4(0.0); + } + } + else + { + _80 = vec4(0.0); + } + return _80.x; +} + +float test_textureLoad_depth_multisampled_2d(ivec2 coords, int _sample) +{ + vec4 _97; + if (uint(_sample) < uint(textureSamples(image_depth_multisampled_2d))) + { + if (all(lessThan(uvec2(coords), uvec2(textureSize(image_depth_multisampled_2d))))) + { + _97 = texelFetch(image_depth_multisampled_2d, coords, _sample); + } + else + { + _97 = vec4(0.0); + } + } + else + { + _97 = vec4(0.0); + } + return _97.x; +} + +void main() +{ + _100 = vec4(0.0); +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm.glsl new file mode 100644 index 000000000..343f7b715 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-image-rzsw.spvasm.glsl @@ -0,0 +1,178 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 3) uniform texture3D image_3d; +layout(set = 0, binding = 4) uniform texture2DMS image_multisampled_2d; +layout(set = 0, binding = 5, rgba8) uniform writeonly image1D image_storage_1d; +layout(set = 0, binding = 6, rgba8) uniform writeonly image2D image_storage_2d; +layout(set = 0, binding = 7, rgba8) uniform writeonly image2DArray image_storage_2d_array; +layout(set = 0, binding = 8, rgba8) uniform writeonly image3D image_storage_3d; + +layout(location = 0) out vec4 _187; + +vec4 test_textureLoad_1d(int coords, int level) +{ + vec4 _54; + if (uint(level) < uint(textureQueryLevels(image_1d))) + { + if (uint(coords) < uint(textureSize(image_1d, level))) + { + _54 = texelFetch(image_1d, coords, level); + } + else + { + _54 = vec4(0.0); + } + } + else + { + _54 = vec4(0.0); + } + return _54; +} + +vec4 test_textureLoad_2d(ivec2 coords, int level) +{ + vec4 _72; + if (uint(level) < uint(textureQueryLevels(image_2d))) + { + if (all(lessThan(uvec2(coords), uvec2(textureSize(image_2d, level))))) + { + _72 = texelFetch(image_2d, coords, level); + } + else + { + _72 = vec4(0.0); + } + } + else + { + _72 = vec4(0.0); + } + return _72; +} + +vec4 test_textureLoad_2d_array_u(ivec2 coords, uint index, int level) +{ + ivec3 _82 = ivec3(coords, int(index)); + vec4 _93; + if (uint(level) < uint(textureQueryLevels(image_2d_array))) + { + if (all(lessThan(uvec3(_82), uvec3(textureSize(image_2d_array, level))))) + { + _93 = texelFetch(image_2d_array, _82, level); + } + else + { + _93 = vec4(0.0); + } + } + else + { + _93 = vec4(0.0); + } + return _93; +} + +vec4 test_textureLoad_2d_array_s(ivec2 coords, int index, int level) +{ + ivec3 _102 = ivec3(coords, index); + vec4 _112; + if (uint(level) < uint(textureQueryLevels(image_2d_array))) + { + if (all(lessThan(uvec3(_102), uvec3(textureSize(image_2d_array, level))))) + { + _112 = texelFetch(image_2d_array, _102, level); + } + else + { + _112 = vec4(0.0); + } + } + else + { + _112 = vec4(0.0); + } + return _112; +} + +vec4 test_textureLoad_3d(ivec3 coords, int level) +{ + vec4 _129; + if (uint(level) < uint(textureQueryLevels(image_3d))) + { + if (all(lessThan(uvec3(coords), uvec3(textureSize(image_3d, level))))) + { + _129 = texelFetch(image_3d, coords, level); + } + else + { + _129 = vec4(0.0); + } + } + else + { + _129 = vec4(0.0); + } + return _129; +} + +vec4 test_textureLoad_multisampled_2d(ivec2 coords, int _sample) +{ + vec4 _145; + if (uint(_sample) < uint(textureSamples(image_multisampled_2d))) + { + if (all(lessThan(uvec2(coords), uvec2(textureSize(image_multisampled_2d))))) + { + _145 = texelFetch(image_multisampled_2d, coords, _sample); + } + else + { + _145 = vec4(0.0); + } + } + else + { + _145 = vec4(0.0); + } + return _145; +} + +void test_textureStore_1d(int coords, vec4 value) +{ + imageStore(image_storage_1d, coords, value); +} + +void test_textureStore_2d(ivec2 coords, vec4 value) +{ + imageStore(image_storage_2d, coords, value); +} + +void test_textureStore_2d_array_u(ivec2 coords, uint array_index, vec4 value) +{ + imageStore(image_storage_2d_array, ivec3(coords, int(array_index)), value); +} + +void test_textureStore_2d_array_s(ivec2 coords, int array_index, vec4 value) +{ + imageStore(image_storage_2d_array, ivec3(coords, array_index), value); +} + +void test_textureStore_3d(ivec3 coords, vec4 value) +{ + imageStore(image_storage_3d, coords, value); +} + +void main() +{ + test_textureStore_1d(0, vec4(0.0)); + test_textureStore_2d(ivec2(0), vec4(0.0)); + test_textureStore_2d_array_u(ivec2(0), 0u, vec4(0.0)); + test_textureStore_2d_array_s(ivec2(0), 0, vec4(0.0)); + test_textureStore_3d(ivec3(0), vec4(0.0)); + _187 = vec4(0.0); +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm.glsl new file mode 100644 index 000000000..2609feaaf --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-restrict.spvasm.glsl @@ -0,0 +1,110 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer _10_12 +{ + float _m0[10]; + vec4 _m1; + mat3x4 _m2; + float _m3[]; +} _12; + +float _16(int _15) +{ + return _12._m0[min(uint(_15), 9u)]; +} + +float _28(int _27) +{ + return _12._m3[min(uint(_27), (uint(_12._m3.length()) - 1u))]; +} + +float _40(int _39) +{ + return _12._m1[min(uint(_39), 3u)]; +} + +float _49(vec4 _47, int _48) +{ + return _47[min(uint(_48), 3u)]; +} + +vec4 _56(int _55) +{ + return _12._m2[min(uint(_55), 2u)]; +} + +float _67(int _65, int _66) +{ + return _12._m2[min(uint(_65), 2u)][min(uint(_66), 3u)]; +} + +float _76(int _75) +{ + return _12._m0[min(uint(int(clamp(sin(float(_75) / 100.0) * 100.0, -2147483648.0, 2147483520.0))), 9u)]; +} + +float _91() +{ + return (_12._m0[9u] + _12._m1.w) + _12._m2[2u].w; +} + +void _105(int _103, float _104) +{ + _12._m0[min(uint(_103), 9u)] = _104; +} + +void _113(int _111, float _112) +{ + _12._m3[min(uint(_111), (uint(_12._m3.length()) - 1u))] = _112; +} + +void _122(int _120, float _121) +{ + _12._m1[min(uint(_120), 3u)] = _121; +} + +void _129(int _127, vec4 _128) +{ + _12._m2[min(uint(_127), 2u)] = _128; +} + +void _138(int _135, int _136, float _137) +{ + _12._m2[min(uint(_135), 2u)][min(uint(_136), 3u)] = _137; +} + +void _147(int _145, float _146) +{ + _12._m0[min(uint(int(clamp(sin(float(_145) / 100.0) * 100.0, -2147483648.0, 2147483520.0))), 9u)] = _146; +} + +void _159(float _158) +{ + _12._m0[9u] = _158; + _12._m1.w = _158; + _12._m2[2u].w = _158; +} + +float _166() +{ + return _12._m3[min(1000u, (uint(_12._m3.length()) - 1u))]; +} + +void _176(float _175) +{ + _12._m3[min(1000u, (uint(_12._m3.length()) - 1u))] = _175; +} + +void main() +{ + _105(1, 2.0); + _113(1, 2.0); + _122(1, 2.0); + _129(1, vec4(2.0, 3.0, 4.0, 5.0)); + _138(1, 2, 1.0); + _147(1, 1.0); + _159(1.0); + _176(1.0); +} + diff --git a/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm.glsl b/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm.glsl new file mode 100644 index 000000000..b38908a94 --- /dev/null +++ b/naga/tests/out/spv/wgsl-bounds-check-zero.spvasm.glsl @@ -0,0 +1,205 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer _10_12 +{ + float _m0[10]; + vec4 _m1; + mat3x4 _m2; + float _m3[]; +} _12; + +float _16(int _15) +{ + float _29; + if (uint(_15) < 10u) + { + _29 = _12._m0[_15]; + } + else + { + _29 = 0.0; + } + return _29; +} + +float _32(int _31) +{ + float _42; + if (uint(_31) < uint(_12._m3.length())) + { + _42 = _12._m3[_31]; + } + else + { + _42 = 0.0; + } + return _42; +} + +float _45(int _44) +{ + float _55; + if (uint(_44) < 4u) + { + _55 = _12._m1[_44]; + } + else + { + _55 = 0.0; + } + return _55; +} + +float _59(vec4 _57, int _58) +{ + float _66; + if (uint(_58) < 4u) + { + _66 = _57[_58]; + } + else + { + _66 = 0.0; + } + return _66; +} + +vec4 _69(int _68) +{ + vec4 _80; + if (uint(_68) < 3u) + { + _80 = _12._m2[_68]; + } + else + { + _80 = vec4(0.0); + } + return _80; +} + +float _84(int _82, int _83) +{ + float _94; + if ((uint(_83) < 4u) && (uint(_82) < 3u)) + { + _94 = _12._m2[_82][_83]; + } + else + { + _94 = 0.0; + } + return _94; +} + +float _97(int _96) +{ + int _107 = int(clamp(sin(float(_96) / 100.0) * 100.0, -2147483648.0, 2147483520.0)); + float _113; + if (uint(_107) < 10u) + { + _113 = _12._m0[_107]; + } + else + { + _113 = 0.0; + } + return _113; +} + +float _115() +{ + return (_12._m0[9u] + _12._m1.w) + _12._m2[2u].w; +} + +void _130(int _128, float _129) +{ + if (uint(_128) < 10u) + { + _12._m0[_128] = _129; + } +} + +void _140(int _138, float _139) +{ + if (uint(_138) < uint(_12._m3.length())) + { + _12._m3[_138] = _139; + } +} + +void _150(int _148, float _149) +{ + if (uint(_148) < 4u) + { + _12._m1[_148] = _149; + } +} + +void _159(int _157, vec4 _158) +{ + if (uint(_157) < 3u) + { + _12._m2[_157] = _158; + } +} + +void _170(int _167, int _168, float _169) +{ + if ((uint(_168) < 4u) && (uint(_167) < 3u)) + { + _12._m2[_167][_168] = _169; + } +} + +void _182(int _180, float _181) +{ + int _189 = int(clamp(sin(float(_180) / 100.0) * 100.0, -2147483648.0, 2147483520.0)); + if (uint(_189) < 10u) + { + _12._m0[_189] = _181; + } +} + +void _196(float _195) +{ + _12._m0[9u] = _195; + _12._m1.w = _195; + _12._m2[2u].w = _195; +} + +float _203() +{ + float _212; + if (1000u < uint(_12._m3.length())) + { + _212 = _12._m3[1000u]; + } + else + { + _212 = 0.0; + } + return _212; +} + +void _215(float _214) +{ + if (1000u < uint(_12._m3.length())) + { + _12._m3[1000u] = _214; + } +} + +void main() +{ + _130(1, 2.0); + _140(1, 2.0); + _150(1, 2.0); + _159(1, vec4(2.0, 3.0, 4.0, 5.0)); + _170(1, 2, 1.0); + _182(1, 1.0); + _196(1.0); + _215(1.0); +} + diff --git a/naga/tests/out/spv/wgsl-break-if.spvasm.glsl b/naga/tests/out/spv/wgsl-break-if.spvasm.glsl new file mode 100644 index 000000000..7412a46ab --- /dev/null +++ b/naga/tests/out/spv/wgsl-break-if.spvasm.glsl @@ -0,0 +1,81 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _6() +{ + uvec2 _22 = uvec2(4294967295u); + do + { + if (all(equal(uvec2(0u), _22))) + { + break; + } + _22 -= uvec2(uint(_22.y == 0u), 1u); + } while (!true); +} + +void _35(bool _34) +{ + bool _37 = false; + bool _40 = false; + uvec2 _47 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _47))) + { + break; + } + _47 -= uvec2(uint(_47.y == 0u), 1u); + _37 = _34; + _40 = _34 != _37; + if (_34 == _40) + { + break; + } + else + { + continue; + } + } +} + +void _64(bool _63) +{ + bool _65 = false; + bool _67 = false; + uvec2 _74 = uvec2(4294967295u); + do + { + if (all(equal(uvec2(0u), _74))) + { + break; + } + _74 -= uvec2(uint(_74.y == 0u), 1u); + _65 = _63; + _67 = _63 != _65; + } while (!(_63 == _67)); +} + +void _90() +{ + uint _92 = 0u; + uvec2 _99 = uvec2(4294967295u); + do + { + if (all(equal(uvec2(0u), _99))) + { + break; + } + _99 -= uvec2(uint(_99.y == 0u), 1u); + _92++; + } while (!(_92 == 5u)); +} + +void main() +{ + _6(); + _35(false); + _64(false); + _90(); +} + diff --git a/naga/tests/out/spv/wgsl-clip-distances.spvasm.glsl b/naga/tests/out/spv/wgsl-clip-distances.spvasm.glsl new file mode 100644 index 000000000..cc4b52e8e --- /dev/null +++ b/naga/tests/out/spv/wgsl-clip-distances.spvasm.glsl @@ -0,0 +1,18 @@ +#version 460 + +out float gl_ClipDistance[1]; + +struct _8 +{ + vec4 _m0; + float _m1[1]; +}; + +void main() +{ + _8 _17 = _8(vec4(0.0), float[](0.0)); + _17._m1[0u] = 0.5; + gl_Position = _17._m0; + gl_ClipDistance = _17._m1; +} + diff --git a/naga/tests/out/spv/wgsl-collatz.spvasm.glsl b/naga/tests/out/spv/wgsl-collatz.spvasm.glsl new file mode 100644 index 000000000..7e99132fe --- /dev/null +++ b/naga/tests/out/spv/wgsl-collatz.spvasm.glsl @@ -0,0 +1,54 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer PrimeIndices +{ + uint data[]; +} v_indices; + +uint naga_mod(uint lhs, uint rhs) +{ + return lhs % ((rhs == 0u) ? 1u : rhs); +} + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +uint collatz_iterations(uint n_base) +{ + uint n = 0u; + uint i = 0u; + uvec2 loop_bound = uvec2(4294967295u); + n = n_base; + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(n > 1u)) + { + break; + } + if (naga_mod(n, 2u) == 0u) + { + n = naga_div(n, 2u); + } + else + { + n = (3u * n) + 1u; + } + i++; + continue; + } + return i; +} + +void main() +{ + v_indices.data[gl_GlobalInvocationID.x] = collatz_iterations(v_indices.data[gl_GlobalInvocationID.x]); +} + diff --git a/naga/tests/out/spv/wgsl-const-exprs.spvasm.glsl b/naga/tests/out/spv/wgsl-const-exprs.spvasm.glsl new file mode 100644 index 000000000..ac41b9271 --- /dev/null +++ b/naga/tests/out/spv/wgsl-const-exprs.spvasm.glsl @@ -0,0 +1,133 @@ +#version 460 +layout(local_size_x = 2, local_size_y = 3, local_size_z = 1) in; + +const int _154[9] = int[](1, 2, 3, 4, 5, 6, 7, 8, 9); + +void _34() +{ + ivec4 _37 = ivec4(4, 3, 2, 1); +} + +void _41() +{ + int _42 = 2; +} + +void _46() +{ + int _48 = 6; +} + +void _51() +{ + ivec4 _60 = ivec4(0); + int _55 = 0; + int _59 = 70; + int _54 = 30; + int _57 = 0; + _55 = _54; + _57 = _55; + _60 = ivec4(_54, _55, _57, _59); +} + +void _71() +{ + ivec4 _74 = ivec4(-4); +} + +void _77() +{ + ivec4 _78 = ivec4(-4); +} + +uint _82(int _81) +{ + switch (_81) + { + case 0: + { + return 10u; + } + case 1: + { + return 20u; + } + case 2: + { + return 30u; + } + default: + { + return 0u; + } + } + return 0u; +} + +void _96() +{ + vec4 _100 = vec4(2.0, 1.0, 1.0, 1.0); +} + +void _104() +{ + float _105[2] = float[](0.0, 0.0); +} + +void _110() +{ + ivec3 _114 = ivec3(1); + ivec3 _116 = ivec3(0, 1, 2); + ivec3 _117 = ivec3(1, 0, 2); +} + +void _120() +{ + bool _128 = false; + bool _125 = true; + bool _121 = false; + bool _129 = true; + bool _126 = false; + bool _123 = true; + bool _127 = true; + bool _124 = false; +} + +void _132() +{ + int _142 = 70; + uint _138 = 4u; + int _144 = -4; + uint _141 = 12u; + int _137 = 4; + uint _143 = 70u; + int _140 = 12; +} + +void _148(uint _147) +{ + uint _158 = 1u; + int _161 = 0; + float _156 = 1.0; + int _159 = 0; + _159 = _154[_147]; + _161 = ivec4(1, 2, 3, 4)[_147]; +} + +void main() +{ + _34(); + _41(); + _46(); + _51(); + _71(); + _77(); + _96(); + _104(); + _110(); + _120(); + _132(); + _104(); + _148(1u); +} + diff --git a/naga/tests/out/spv/wgsl-constructors.spvasm.glsl b/naga/tests/out/spv/wgsl-constructors.spvasm.glsl new file mode 100644 index 000000000..56364a024 --- /dev/null +++ b/naga/tests/out/spv/wgsl-constructors.spvasm.glsl @@ -0,0 +1,15 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _6 +{ + vec4 _m0; + int _m1; +}; + +void main() +{ + _6 _66 = _6(vec4(0.0), 0); + _66 = _6(vec4(1.0), 1); +} + diff --git a/naga/tests/out/spv/wgsl-control-flow.spvasm.glsl b/naga/tests/out/spv/wgsl-control-flow.spvasm.glsl new file mode 100644 index 000000000..7ed99ab3e --- /dev/null +++ b/naga/tests/out/spv/wgsl-control-flow.spvasm.glsl @@ -0,0 +1,393 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _5() +{ + int _14 = 0; + memoryBarrierBuffer(); + barrier(); + barrier(); + groupMemoryBarrier(); + barrier(); + do + { + _14 = 1; + break; + } while(false); + switch (_14) + { + case 1: + { + _14 = 0; + break; + } + case 2: + { + _14 = 1; + break; + } + case 3: + case 4: + { + _14 = 2; + break; + } + case 5: + { + _14 = 3; + break; + } + default: + { + _14 = 4; + break; + } + } + switch (0u) + { + case 0u: + { + break; + } + default: + { + break; + } + } + switch (_14) + { + case 1: + { + _14 = 0; + break; + } + case 2: + { + _14 = 1; + break; + } + case 3: + { + _14 = 2; + break; + } + case 4: + { + break; + } + default: + { + _14 = 3; + break; + } + } + switch (_14) + { + case 1: + { + _14 = 0; + return; + } + case 2: + { + _14 = 1; + return; + } + case 3: + case 4: + { + _14 = 2; + return; + } + case 5: + case 6: + { + _14 = 3; + return; + } + default: + { + _14 = 4; + return; + } + } +} + +void _51(int _50) +{ + do + { + break; + } while(false); +} + +void _57() +{ + switch (0) + { + case 0: + { + break; + } + default: + { + break; + } + } +} + +void _63() +{ + switch (0u) + { + case 0u: + { + break; + } + default: + { + break; + } + } + switch (0u) + { + case 0u: + { + return; + } + default: + { + return; + } + } +} + +void _72() +{ + switch (0) + { + case 0: + { + return; + } + case 1: + { + return; + } + case 2: + { + return; + } + case 3: + { + return; + } + case 4: + { + return; + } + default: + { + return; + } + } +} + +void _83(int _82) +{ + uvec2 _96 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _96))) + { + break; + } + _96 -= uvec2(uint(_96.y == 0u), 1u); + switch (_82) + { + case 1: + { + continue; + } + default: + { + break; + } + } + continue; + } +} + +void _114(int _111, int _112, int _113) +{ + uvec2 _121 = uvec2(4294967295u); + uvec2 _143 = uvec2(4294967295u); + uvec2 _163 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _121))) + { + break; + } + _121 -= uvec2(uint(_121.y == 0u), 1u); + switch (_111) + { + case 1: + { + continue; + } + case 2: + { + switch (_112) + { + case 1: + { + continue; + } + default: + { + for (;;) + { + if (all(equal(uvec2(0u), _143))) + { + break; + } + _143 -= uvec2(uint(_143.y == 0u), 1u); + switch (_113) + { + case 1: + { + continue; + } + default: + { + break; + } + } + continue; + } + break; + } + } + break; + } + default: + { + break; + } + } + do + { + continue; + } while(false); + continue; + } + for (;;) + { + if (all(equal(uvec2(0u), _163))) + { + break; + } + _163 -= uvec2(uint(_163.y == 0u), 1u); + switch (_112) + { + default: + { + do + { + continue; + } while(false); + break; + } + } + continue; + } +} + +void _183(int _179, int _180, int _181, int _182) +{ + int _185 = 0; + uvec2 _191 = uvec2(4294967295u); + uvec2 _209 = uvec2(4294967295u); + for (;;) + { + if (all(equal(uvec2(0u), _191))) + { + break; + } + _191 -= uvec2(uint(_191.y == 0u), 1u); + switch (_179) + { + case 1: + { + _185 = 1; + break; + } + default: + { + break; + } + } + continue; + } + for (;;) + { + if (all(equal(uvec2(0u), _209))) + { + break; + } + _209 -= uvec2(uint(_209.y == 0u), 1u); + switch (_179) + { + case 1: + { + break; + } + case 2: + { + switch (_180) + { + case 1: + { + continue; + } + default: + { + switch (_181) + { + case 1: + { + _185 = 2; + break; + } + default: + { + break; + } + } + break; + } + } + break; + } + default: + { + break; + } + } + continue; + } +} + +void main() +{ + _5(); + _51(1); + _57(); + _63(); + _72(); + _83(1); + _114(1, 2, 3); + _183(1, 2, 3, 4); +} + diff --git a/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm.glsl b/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm.glsl new file mode 100644 index 000000000..9df091b90 --- /dev/null +++ b/naga/tests/out/spv/wgsl-conversion-float-to-int.spvasm.glsl @@ -0,0 +1,173 @@ +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _24() +{ + int64_t _73 = 9223372036854774784l; + uint _70 = 0u; + uint64_t _67 = 18446744073709549568ul; + int64_t _64 = int64_t(0x8000000000000000ul); + int64_t _61 = 9223371487098961920l; + uint _58 = 0u; + uint64_t _55 = 65504ul; + int64_t _50 = -65504l; + int _46 = 65504; + uint64_t _75 = 18446744073709549568ul; + int64_t _72 = int64_t(0x8000000000000000ul); + int _69 = 2147483647; + uint64_t _66 = 0ul; + uint64_t _63 = 18446742974197923840ul; + int64_t _60 = int64_t(0x8000000000000000ul); + int _57 = 2147483520; + uint64_t _53 = 0ul; + uint _49 = 65504u; + int _44 = -65504; + uint64_t _74 = 0ul; + uint _71 = 4294967295u; + int _68 = int(0x80000000); + int64_t _65 = 9223372036854774784l; + uint64_t _62 = 0ul; + uint _59 = 4294967040u; + int _56 = int(0x80000000); + int64_t _52 = 65504l; + uint _47 = 0u; +} + +int _79(float16_t _78) +{ + return int(clamp(_78, float16_t(-65504.0), float16_t(65504.0))); +} + +uint _86(float16_t _85) +{ + return uint(clamp(_85, float16_t(0.0), float16_t(65504.0))); +} + +int64_t _94(float16_t _93) +{ + return int64_t(clamp(_93, float16_t(-65504.0), float16_t(65504.0))); +} + +uint64_t _101(float16_t _100) +{ + return uint64_t(clamp(_100, float16_t(0.0), float16_t(65504.0))); +} + +int _108(float _107) +{ + return int(clamp(_107, -2147483648.0, 2147483520.0)); +} + +uint _117(float _116) +{ + return uint(clamp(_116, 0.0, 4294967040.0)); +} + +int64_t _126(float _125) +{ + return int64_t(clamp(_125, -9223372036854775808.0, 9223371487098961920.0)); +} + +uint64_t _135(float _134) +{ + return uint64_t(clamp(_134, 0.0, 18446742974197923840.0)); +} + +int _143(double _142) +{ + return int(clamp(_142, -2147483648.0lf, 2147483647.0lf)); +} + +uint _152(double _151) +{ + return uint(clamp(_151, 0.0lf, 4294967295.0lf)); +} + +int64_t _161(double _160) +{ + return int64_t(clamp(_160, -9223372036854775808.0lf, 9223372036854774784.0lf)); +} + +uint64_t _170(double _169) +{ + return uint64_t(clamp(_169, 0.0lf, 18446744073709549568.0lf)); +} + +ivec2 _178(f16vec2 _177) +{ + return ivec2(clamp(_177, f16vec2(float16_t(-65504.0)), f16vec2(float16_t(65504.0)))); +} + +uvec2 _187(f16vec2 _186) +{ + return uvec2(clamp(_186, f16vec2(float16_t(0.0)), f16vec2(float16_t(65504.0)))); +} + +i64vec2 _195(f16vec2 _194) +{ + return i64vec2(clamp(_194, f16vec2(float16_t(-65504.0)), f16vec2(float16_t(65504.0)))); +} + +u64vec2 _202(f16vec2 _201) +{ + return u64vec2(clamp(_201, f16vec2(float16_t(0.0)), f16vec2(float16_t(65504.0)))); +} + +ivec2 _209(vec2 _208) +{ + return ivec2(clamp(_208, vec2(-2147483648.0), vec2(2147483520.0))); +} + +uvec2 _218(vec2 _217) +{ + return uvec2(clamp(_217, vec2(0.0), vec2(4294967040.0))); +} + +i64vec2 _227(vec2 _226) +{ + return i64vec2(clamp(_226, vec2(-9223372036854775808.0), vec2(9223371487098961920.0))); +} + +u64vec2 _236(vec2 _235) +{ + return u64vec2(clamp(_235, vec2(0.0), vec2(18446742974197923840.0))); +} + +ivec2 _244(dvec2 _243) +{ + return ivec2(clamp(_243, dvec2(-2147483648.0lf), dvec2(2147483647.0lf))); +} + +uvec2 _253(dvec2 _252) +{ + return uvec2(clamp(_252, dvec2(0.0lf), dvec2(4294967295.0lf))); +} + +i64vec2 _262(dvec2 _261) +{ + return i64vec2(clamp(_261, dvec2(-9223372036854775808.0lf), dvec2(9223372036854774784.0lf))); +} + +u64vec2 _271(dvec2 _270) +{ + return u64vec2(clamp(_270, dvec2(0.0lf), dvec2(18446744073709549568.0lf))); +} + +void main() +{ + _24(); +} + diff --git a/naga/tests/out/spv/wgsl-conversions.spvasm.glsl b/naga/tests/out/spv/wgsl-conversions.spvasm.glsl new file mode 100644 index 000000000..1f0228087 --- /dev/null +++ b/naga/tests/out/spv/wgsl-conversions.spvasm.glsl @@ -0,0 +1,8 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + vec2 _10 = vec2(2.0); +} + diff --git a/naga/tests/out/spv/wgsl-cooperative-matrix.spvasm.glsl b/naga/tests/out/spv/wgsl-cooperative-matrix.spvasm.glsl new file mode 100644 index 000000000..0267bd446 --- /dev/null +++ b/naga/tests/out/spv/wgsl-cooperative-matrix.spvasm.glsl @@ -0,0 +1,25 @@ +#version 460 +#extension GL_KHR_cooperative_matrix : require +#extension GL_KHR_memory_scope_semantics : require +layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer _21_20 +{ + float _m0[]; +} _20; + +coopmat _14 = coopmat(0.0); +coopmat _17 = coopmat(0.0); + +void main() +{ + coopmat _28 = coopmat(0.0); + coopmat _31 = coopmat(0.0); + coopmat _37; + coopMatLoad(_37, _20._m0, 4u, 8u, gl_CooperativeMatrixLayoutColumnMajor); + _28 = _37; + _31 = coopMatMulAdd(_14, _17, _28, 0); + coopMatStore(_31, _20._m0, 0u, 8u, gl_CooperativeMatrixLayoutColumnMajor); + _28 = _31; +} + diff --git a/naga/tests/out/spv/wgsl-cross.spvasm.glsl b/naga/tests/out/spv/wgsl-cross.spvasm.glsl new file mode 100644 index 000000000..8f6ad1648 --- /dev/null +++ b/naga/tests/out/spv/wgsl-cross.spvasm.glsl @@ -0,0 +1,7 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm.glsl b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm.glsl new file mode 100644 index 000000000..6bf26906b --- /dev/null +++ b/naga/tests/out/spv/wgsl-debug-symbol-large-source.spvasm.glsl @@ -0,0 +1,833 @@ +/////////////////////////////////////////////// +// Entry point: "gen_terrain_compute" (comp) // +/////////////////////////////////////////////// +#version 460 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +vec2 index_to_p(uint vert_index, uvec2 chunk_size, ivec2 chunk_corner) +{ + float _328 = float(vert_index); + float _331 = float(chunk_size.x + 1u); + return vec2(_328 - _331 * trunc(_328 / _331), float(naga_div(vert_index, chunk_size.x + 1u))) + vec2(chunk_corner); +} + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +float fbm(vec2 p) +{ + float v = 0.0; + uint i = 0u; + vec2 x = vec2(0.0); + float a = 0.5; + uvec2 loop_bound = uvec2(4294967295u); + x = p * 0.00999999977648258209228515625; + mat2 _227 = mat2(vec2(0.877582550048828125, 0.47942554950714111328125), vec2(-0.47942554950714111328125, 0.877582550048828125)); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < 5u)) + { + break; + } + v += (a * snoise2(x)); + x = ((_227 * x) * 2.0) + vec2(100.0); + a *= 0.5; + i++; + continue; + } + return v; +} + +vec3 terrain_point(vec2 p, vec2 min_max_height) +{ + return vec3(p.x, mix(min_max_height.x, min_max_height.y, fbm(p)), p.y); +} + +Vertex terrain_vertex(vec2 p, vec2 min_max_height) +{ + vec3 _293 = terrain_point(p, min_max_height); + return Vertex(_293, (normalize(cross(terrain_point(p + vec2(0.0, 0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(0.100000001490116119384765625, 0.0), min_max_height) - _293)) + normalize(cross(terrain_point(p + vec2(0.0, -0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(-0.100000001490116119384765625, 0.0), min_max_height) - _293))) * 0.5); +} + +void main() +{ + vertices.data[gl_GlobalInvocationID.x] = terrain_vertex(index_to_p(gl_GlobalInvocationID.x, chunk_data_1._m0.chunk_size, chunk_data_1._m0.chunk_corner), chunk_data_1._m0.min_max_height); + uint _392 = gl_GlobalInvocationID.x * 6u; + if (_392 >= ((chunk_data_1._m0.chunk_size.x * chunk_data_1._m0.chunk_size.y) * 6u)) + { + return; + } + uint _407 = gl_GlobalInvocationID.x + naga_div(gl_GlobalInvocationID.x, chunk_data_1._m0.chunk_size.x); + uint _412 = (_407 + chunk_data_1._m0.chunk_size.x) + 1u; + uint _413 = _412 + 1u; + indices.data[_392] = _407; + indices.data[_392 + 1u] = _412; + indices.data[_392 + 2u] = _413; + indices.data[_392 + 3u] = _407; + indices.data[_392 + 4u] = _413; + indices.data[_392 + 5u] = _407 + 1u; +} + + +////////////////////////////////////////////// +// Entry point: "gen_terrain_vertex" (vert) // +////////////////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) flat out uint index; +layout(location = 1) out vec2 uv; + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +uint naga_mod(uint lhs, uint rhs) +{ + return lhs % ((rhs == 0u) ? 1u : rhs); +} + +void main() +{ + vec2 _458 = vec2(float(naga_mod(naga_div(uint(gl_VertexIndex) + 2u, 3u), 2u)), float(naga_mod(naga_div(uint(gl_VertexIndex) + 1u, 3u), 2u))); + GenVertexOutput _479 = GenVertexOutput(uint(clamp((_458.x * float(gen_data_1._m0.texture_size)) + (_458.y * float(gen_data_1._m0.texture_size)), 0.0, 4294967040.0)) + gen_data_1._m0.start_index, vec4(vec2(-1.0) + (_458 * 2.0), 0.0, 1.0), _458); + index = _479.index; + gl_Position = _479.position; + uv = _479.uv; +} + + +//////////////////////////////////////////////// +// Entry point: "gen_terrain_fragment" (frag) // +//////////////////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) flat in uint index; +layout(location = 1) in vec2 uv; +layout(location = 0) out uint vert_component; +layout(location = 1) out uint index_1; + +uint naga_mod(uint lhs, uint rhs) +{ + return lhs % ((rhs == 0u) ? 1u : rhs); +} + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +vec2 index_to_p(uint vert_index, uvec2 chunk_size, ivec2 chunk_corner) +{ + float _328 = float(vert_index); + float _331 = float(chunk_size.x + 1u); + return vec2(_328 - _331 * trunc(_328 / _331), float(naga_div(vert_index, chunk_size.x + 1u))) + vec2(chunk_corner); +} + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +float fbm(vec2 p) +{ + float v = 0.0; + uint i = 0u; + vec2 x = vec2(0.0); + float a = 0.5; + uvec2 loop_bound = uvec2(4294967295u); + x = p * 0.00999999977648258209228515625; + mat2 _227 = mat2(vec2(0.877582550048828125, 0.47942554950714111328125), vec2(-0.47942554950714111328125, 0.877582550048828125)); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < 5u)) + { + break; + } + v += (a * snoise2(x)); + x = ((_227 * x) * 2.0) + vec2(100.0); + a *= 0.5; + i++; + continue; + } + return v; +} + +vec3 terrain_point(vec2 p, vec2 min_max_height) +{ + return vec3(p.x, mix(min_max_height.x, min_max_height.y, fbm(p)), p.y); +} + +Vertex terrain_vertex(vec2 p, vec2 min_max_height) +{ + vec3 _293 = terrain_point(p, min_max_height); + return Vertex(_293, (normalize(cross(terrain_point(p + vec2(0.0, 0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(0.100000001490116119384765625, 0.0), min_max_height) - _293)) + normalize(cross(terrain_point(p + vec2(0.0, -0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(-0.100000001490116119384765625, 0.0), min_max_height) - _293))) * 0.5); +} + +void main() +{ + float vert_component_1 = 0.0; + uint index_2 = 0u; + GenVertexOutput _484 = GenVertexOutput(index, gl_FragCoord, uv); + uint _521 = uint(clamp((_484.uv.x * float(gen_data_1._m0.texture_size)) + (_484.uv.y * float(gen_data_1._m0.texture_size * gen_data_1._m0.texture_size)), 0.0, 4294967040.0)) + gen_data_1._m0.start_index; + uint _526 = uint(clamp(floor(float(_521) / 6.0), 0.0, 4294967040.0)); + uint _527 = naga_mod(_521, 6u); + Vertex _535 = terrain_vertex(index_to_p(_526, gen_data_1._m0.chunk_size, gen_data_1._m0.chunk_corner), gen_data_1._m0.min_max_height); + switch (_527) + { + case 0u: + { + vert_component_1 = _535.position.x; + break; + } + case 1u: + { + vert_component_1 = _535.position.y; + break; + } + case 2u: + { + vert_component_1 = _535.position.z; + break; + } + case 3u: + { + vert_component_1 = _535.normal.x; + break; + } + case 4u: + { + vert_component_1 = _535.normal.y; + break; + } + case 5u: + { + vert_component_1 = _535.normal.z; + break; + } + default: + { + break; + } + } + uint _559 = _526 + naga_div(_526, gen_data_1._m0.chunk_size.x); + uint _564 = (_559 + gen_data_1._m0.chunk_size.x) + 1u; + switch (_527) + { + case 0u: + case 3u: + { + index_2 = _559; + break; + } + case 2u: + case 4u: + { + index_2 = _564 + 1u; + break; + } + case 1u: + { + index_2 = _564; + break; + } + case 5u: + { + index_2 = _559 + 1u; + break; + } + default: + { + break; + } + } + index_2 = _484.index; + GenFragmentOutput _576 = GenFragmentOutput(floatBitsToUint(vert_component_1), index_2); + vert_component = _576.vert_component; + index_1 = _576.index; +} + + +/////////////////////////////////// +// Entry point: "vs_main" (vert) // +/////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) in vec3 position; +layout(location = 1) in vec3 normal; +layout(location = 0) out vec3 normal_1; +layout(location = 1) out vec3 world_pos; + +void main() +{ + Vertex _580 = Vertex(position, normal); + VertexOutput _602 = VertexOutput(camera_1._m0.view_proj * vec4(_580.position, 1.0), _580.normal, _580.position); + gl_Position = _602.clip_position; + normal_1 = _602.normal; + world_pos = _602.world_pos; +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) in vec3 normal; +layout(location = 1) in vec3 world_pos; +layout(location = 0) out vec4 _614; + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +vec3 color23(vec2 p) +{ + return vec3((snoise2(p) * 0.5) + 0.5, (snoise2(p + vec2(23.0, 32.0)) * 0.5) + 0.5, (snoise2(p + vec2(-43.0, 3.0)) * 0.5) + 0.5); +} + +void main() +{ + vec3 color = vec3(0.0); + VertexOutput _607 = VertexOutput(gl_FragCoord, normal, world_pos); + color = smoothstep(vec3(0.0), vec3(0.100000001490116119384765625), fract(_607.world_pos)); + color = mix(vec3(0.5, 0.100000001490116119384765625, 0.699999988079071044921875), vec3(0.20000000298023223876953125), vec3((color.x * color.y) * color.z)); + vec3 _654 = normalize(light_1._m0.position - _607.world_pos); + _614 = vec4((((light_1._m0.color * 0.100000001490116119384765625) + (light_1._m0.color * max(dot(_607.normal, _654), 0.0))) + (light_1._m0.color * pow(max(dot(_607.normal, normalize(normalize(camera_1._m0.view_pos.xyz - _607.world_pos) + _654)), 0.0), 32.0))) * color, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm.glsl b/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm.glsl new file mode 100644 index 000000000..d86ec9a43 --- /dev/null +++ b/naga/tests/out/spv/wgsl-debug-symbol-simple.spvasm.glsl @@ -0,0 +1,79 @@ +/////////////////////////////////// +// Entry point: "vs_main" (vert) // +/////////////////////////////////// +#version 460 + +struct VertexInput +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 color; +}; + +layout(location = 0) in vec3 position; +layout(location = 1) in vec3 color; +layout(location = 0) out vec3 color_1; + +void main() +{ + VertexOutput _out = VertexOutput(vec4(0.0), vec3(0.0)); + VertexInput _11 = VertexInput(position, color); + _out.color = _11.color; + _out.clip_position = vec4(_11.position, 1.0); + gl_Position = _out.clip_position; + color_1 = _out.color; +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 + +struct VertexInput +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 color; +}; + +layout(location = 0) in vec3 color; +layout(location = 0) out vec4 _48; + +void main() +{ + vec3 color_1 = vec3(0.0); + int i = 0; + float ii = 0.0; + uvec2 loop_bound = uvec2(4294967295u); + color_1 = VertexOutput(gl_FragCoord, color).color; + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < 10)) + { + break; + } + ii = float(i); + color_1.x += (ii * 0.001000000047497451305389404296875); + color_1.y += (ii * 0.00200000009499490261077880859375); + i++; + continue; + } + _48 = vec4(color_1, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm.glsl b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm.glsl new file mode 100644 index 000000000..6bf26906b --- /dev/null +++ b/naga/tests/out/spv/wgsl-debug-symbol-terrain.spvasm.glsl @@ -0,0 +1,833 @@ +/////////////////////////////////////////////// +// Entry point: "gen_terrain_compute" (comp) // +/////////////////////////////////////////////// +#version 460 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +vec2 index_to_p(uint vert_index, uvec2 chunk_size, ivec2 chunk_corner) +{ + float _328 = float(vert_index); + float _331 = float(chunk_size.x + 1u); + return vec2(_328 - _331 * trunc(_328 / _331), float(naga_div(vert_index, chunk_size.x + 1u))) + vec2(chunk_corner); +} + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +float fbm(vec2 p) +{ + float v = 0.0; + uint i = 0u; + vec2 x = vec2(0.0); + float a = 0.5; + uvec2 loop_bound = uvec2(4294967295u); + x = p * 0.00999999977648258209228515625; + mat2 _227 = mat2(vec2(0.877582550048828125, 0.47942554950714111328125), vec2(-0.47942554950714111328125, 0.877582550048828125)); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < 5u)) + { + break; + } + v += (a * snoise2(x)); + x = ((_227 * x) * 2.0) + vec2(100.0); + a *= 0.5; + i++; + continue; + } + return v; +} + +vec3 terrain_point(vec2 p, vec2 min_max_height) +{ + return vec3(p.x, mix(min_max_height.x, min_max_height.y, fbm(p)), p.y); +} + +Vertex terrain_vertex(vec2 p, vec2 min_max_height) +{ + vec3 _293 = terrain_point(p, min_max_height); + return Vertex(_293, (normalize(cross(terrain_point(p + vec2(0.0, 0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(0.100000001490116119384765625, 0.0), min_max_height) - _293)) + normalize(cross(terrain_point(p + vec2(0.0, -0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(-0.100000001490116119384765625, 0.0), min_max_height) - _293))) * 0.5); +} + +void main() +{ + vertices.data[gl_GlobalInvocationID.x] = terrain_vertex(index_to_p(gl_GlobalInvocationID.x, chunk_data_1._m0.chunk_size, chunk_data_1._m0.chunk_corner), chunk_data_1._m0.min_max_height); + uint _392 = gl_GlobalInvocationID.x * 6u; + if (_392 >= ((chunk_data_1._m0.chunk_size.x * chunk_data_1._m0.chunk_size.y) * 6u)) + { + return; + } + uint _407 = gl_GlobalInvocationID.x + naga_div(gl_GlobalInvocationID.x, chunk_data_1._m0.chunk_size.x); + uint _412 = (_407 + chunk_data_1._m0.chunk_size.x) + 1u; + uint _413 = _412 + 1u; + indices.data[_392] = _407; + indices.data[_392 + 1u] = _412; + indices.data[_392 + 2u] = _413; + indices.data[_392 + 3u] = _407; + indices.data[_392 + 4u] = _413; + indices.data[_392 + 5u] = _407 + 1u; +} + + +////////////////////////////////////////////// +// Entry point: "gen_terrain_vertex" (vert) // +////////////////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) flat out uint index; +layout(location = 1) out vec2 uv; + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +uint naga_mod(uint lhs, uint rhs) +{ + return lhs % ((rhs == 0u) ? 1u : rhs); +} + +void main() +{ + vec2 _458 = vec2(float(naga_mod(naga_div(uint(gl_VertexIndex) + 2u, 3u), 2u)), float(naga_mod(naga_div(uint(gl_VertexIndex) + 1u, 3u), 2u))); + GenVertexOutput _479 = GenVertexOutput(uint(clamp((_458.x * float(gen_data_1._m0.texture_size)) + (_458.y * float(gen_data_1._m0.texture_size)), 0.0, 4294967040.0)) + gen_data_1._m0.start_index, vec4(vec2(-1.0) + (_458 * 2.0), 0.0, 1.0), _458); + index = _479.index; + gl_Position = _479.position; + uv = _479.uv; +} + + +//////////////////////////////////////////////// +// Entry point: "gen_terrain_fragment" (frag) // +//////////////////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) flat in uint index; +layout(location = 1) in vec2 uv; +layout(location = 0) out uint vert_component; +layout(location = 1) out uint index_1; + +uint naga_mod(uint lhs, uint rhs) +{ + return lhs % ((rhs == 0u) ? 1u : rhs); +} + +uint naga_div(uint lhs, uint rhs) +{ + return lhs / ((rhs == 0u) ? 1u : rhs); +} + +vec2 index_to_p(uint vert_index, uvec2 chunk_size, ivec2 chunk_corner) +{ + float _328 = float(vert_index); + float _331 = float(chunk_size.x + 1u); + return vec2(_328 - _331 * trunc(_328 / _331), float(naga_div(vert_index, chunk_size.x + 1u))) + vec2(chunk_corner); +} + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +float fbm(vec2 p) +{ + float v = 0.0; + uint i = 0u; + vec2 x = vec2(0.0); + float a = 0.5; + uvec2 loop_bound = uvec2(4294967295u); + x = p * 0.00999999977648258209228515625; + mat2 _227 = mat2(vec2(0.877582550048828125, 0.47942554950714111328125), vec2(-0.47942554950714111328125, 0.877582550048828125)); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < 5u)) + { + break; + } + v += (a * snoise2(x)); + x = ((_227 * x) * 2.0) + vec2(100.0); + a *= 0.5; + i++; + continue; + } + return v; +} + +vec3 terrain_point(vec2 p, vec2 min_max_height) +{ + return vec3(p.x, mix(min_max_height.x, min_max_height.y, fbm(p)), p.y); +} + +Vertex terrain_vertex(vec2 p, vec2 min_max_height) +{ + vec3 _293 = terrain_point(p, min_max_height); + return Vertex(_293, (normalize(cross(terrain_point(p + vec2(0.0, 0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(0.100000001490116119384765625, 0.0), min_max_height) - _293)) + normalize(cross(terrain_point(p + vec2(0.0, -0.100000001490116119384765625), min_max_height) - _293, terrain_point(p + vec2(-0.100000001490116119384765625, 0.0), min_max_height) - _293))) * 0.5); +} + +void main() +{ + float vert_component_1 = 0.0; + uint index_2 = 0u; + GenVertexOutput _484 = GenVertexOutput(index, gl_FragCoord, uv); + uint _521 = uint(clamp((_484.uv.x * float(gen_data_1._m0.texture_size)) + (_484.uv.y * float(gen_data_1._m0.texture_size * gen_data_1._m0.texture_size)), 0.0, 4294967040.0)) + gen_data_1._m0.start_index; + uint _526 = uint(clamp(floor(float(_521) / 6.0), 0.0, 4294967040.0)); + uint _527 = naga_mod(_521, 6u); + Vertex _535 = terrain_vertex(index_to_p(_526, gen_data_1._m0.chunk_size, gen_data_1._m0.chunk_corner), gen_data_1._m0.min_max_height); + switch (_527) + { + case 0u: + { + vert_component_1 = _535.position.x; + break; + } + case 1u: + { + vert_component_1 = _535.position.y; + break; + } + case 2u: + { + vert_component_1 = _535.position.z; + break; + } + case 3u: + { + vert_component_1 = _535.normal.x; + break; + } + case 4u: + { + vert_component_1 = _535.normal.y; + break; + } + case 5u: + { + vert_component_1 = _535.normal.z; + break; + } + default: + { + break; + } + } + uint _559 = _526 + naga_div(_526, gen_data_1._m0.chunk_size.x); + uint _564 = (_559 + gen_data_1._m0.chunk_size.x) + 1u; + switch (_527) + { + case 0u: + case 3u: + { + index_2 = _559; + break; + } + case 2u: + case 4u: + { + index_2 = _564 + 1u; + break; + } + case 1u: + { + index_2 = _564; + break; + } + case 5u: + { + index_2 = _559 + 1u; + break; + } + default: + { + break; + } + } + index_2 = _484.index; + GenFragmentOutput _576 = GenFragmentOutput(floatBitsToUint(vert_component_1), index_2); + vert_component = _576.vert_component; + index_1 = _576.index; +} + + +/////////////////////////////////// +// Entry point: "vs_main" (vert) // +/////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) in vec3 position; +layout(location = 1) in vec3 normal; +layout(location = 0) out vec3 normal_1; +layout(location = 1) out vec3 world_pos; + +void main() +{ + Vertex _580 = Vertex(position, normal); + VertexOutput _602 = VertexOutput(camera_1._m0.view_proj * vec4(_580.position, 1.0), _580.normal, _580.position); + gl_Position = _602.clip_position; + normal_1 = _602.normal; + world_pos = _602.world_pos; +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 + +struct ChunkData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; +}; + +struct Vertex +{ + vec3 position; + vec3 normal; +}; + +struct GenData +{ + uvec2 chunk_size; + ivec2 chunk_corner; + vec2 min_max_height; + uint texture_size; + uint start_index; +}; + +struct GenVertexOutput +{ + uint index; + vec4 position; + vec2 uv; +}; + +struct GenFragmentOutput +{ + uint vert_component; + uint index; +}; + +struct Camera +{ + vec4 view_pos; + mat4 view_proj; +}; + +struct Light +{ + vec3 position; + vec3 color; +}; + +struct VertexOutput +{ + vec4 clip_position; + vec3 normal; + vec3 world_pos; +}; + +layout(set = 0, binding = 0, std140) uniform chunk_data +{ + ChunkData _m0; +} chunk_data_1; + +layout(set = 0, binding = 1, std430) buffer VertexBuffer +{ + Vertex data[]; +} vertices; + +layout(set = 0, binding = 2, std430) buffer IndexBuffer +{ + uint data[]; +} indices; + +layout(set = 0, binding = 0, std140) uniform gen_data +{ + GenData _m0; +} gen_data_1; + +layout(set = 0, binding = 0, std140) uniform camera +{ + Camera _m0; +} camera_1; + +layout(set = 1, binding = 0, std140) uniform light +{ + Light _m0; +} light_1; + +layout(set = 2, binding = 0) uniform texture2D t_diffuse; +layout(set = 2, binding = 1) uniform sampler s_diffuse; +layout(set = 2, binding = 2) uniform texture2D t_normal; +layout(set = 2, binding = 3) uniform sampler s_normal; + +layout(location = 0) in vec3 normal; +layout(location = 1) in vec3 world_pos; +layout(location = 0) out vec4 _614; + +vec3 permute3(vec3 x) +{ + vec3 _63 = ((x * 34.0) + vec3(1.0)) * x; + return _63 - vec3(289.0) * trunc(_63 / vec3(289.0)); +} + +float snoise2(vec2 v) +{ + vec2 i1 = vec2(0.0); + vec3 m = vec3(0.0); + vec2 i = vec2(0.0); + vec4 x12 = vec4(0.0); + i = floor(v + vec2(dot(v, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).yy))); + vec2 _103 = i; + vec2 _105 = i; + vec2 _109 = (v - _103) + vec2(dot(_105, vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xx)); + i1 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_109.x < _109.y)); + x12 = (_109.xyxy + vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).xxzz) - vec4(i1, 0.0, 0.0); + i = i - vec2(289.0) * trunc(i / vec2(289.0)); + m = max(vec3(0.5) - vec3(dot(_109, _109), dot(x12.xy, x12.xy), dot(x12.zw, x12.zw)), vec3(0.0)); + m *= m; + m *= m; + vec3 _169 = (fract(permute3((permute3(vec3(i.y) + vec3(0.0, i1.y, 1.0)) + vec3(i.x)) + vec3(0.0, i1.x, 1.0)) * vec4(0.211324870586395263671875, 0.3660254180431365966796875, -0.57735025882720947265625, 0.024390242993831634521484375).www) * 2.0) - vec3(1.0); + vec3 _171 = abs(_169) - vec3(0.5); + vec3 _174 = _169 - floor(_169 + vec3(0.5)); + m *= (vec3(1.792842864990234375) - (((_174 * _174) + (_171 * _171)) * 0.8537347316741943359375)); + return 130.0 * dot(m, vec3((_174.x * _109.x) + (_171.x * _109.y), (_174.yz * x12.xz) + (_171.yz * x12.yw))); +} + +vec3 color23(vec2 p) +{ + return vec3((snoise2(p) * 0.5) + 0.5, (snoise2(p + vec2(23.0, 32.0)) * 0.5) + 0.5, (snoise2(p + vec2(-43.0, 3.0)) * 0.5) + 0.5); +} + +void main() +{ + vec3 color = vec3(0.0); + VertexOutput _607 = VertexOutput(gl_FragCoord, normal, world_pos); + color = smoothstep(vec3(0.0), vec3(0.100000001490116119384765625), fract(_607.world_pos)); + color = mix(vec3(0.5, 0.100000001490116119384765625, 0.699999988079071044921875), vec3(0.20000000298023223876953125), vec3((color.x * color.y) * color.z)); + vec3 _654 = normalize(light_1._m0.position - _607.world_pos); + _614 = vec4((((light_1._m0.color * 0.100000001490116119384765625) + (light_1._m0.color * max(dot(_607.normal, _654), 0.0))) + (light_1._m0.color * pow(max(dot(_607.normal, normalize(normalize(camera_1._m0.view_pos.xyz - _607.world_pos) + _654)), 0.0), 32.0))) * color, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-draw-index.spvasm.glsl b/naga/tests/out/spv/wgsl-draw-index.spvasm.glsl new file mode 100644 index 000000000..bbc8b427a --- /dev/null +++ b/naga/tests/out/spv/wgsl-draw-index.spvasm.glsl @@ -0,0 +1,12 @@ +#version 460 + +struct _4 +{ + uint _m0; +}; + +void main() +{ + gl_Position = vec4(float(_4(uint(gl_DrawID))._m0), 1.0, 1.0, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-dualsource.spvasm.glsl b/naga/tests/out/spv/wgsl-dualsource.spvasm.glsl new file mode 100644 index 000000000..1a094c08b --- /dev/null +++ b/naga/tests/out/spv/wgsl-dualsource.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 + +struct _5 +{ + vec4 _m0; + vec4 _m1; +}; + +layout(location = 0, index = 0) out vec4 _7; +layout(location = 0, index = 1) out vec4 _9; + +void main() +{ + _7 = _5(vec4(0.4000000059604644775390625, 0.300000011920928955078125, 0.20000000298023223876953125, 0.100000001490116119384765625), vec4(0.89999997615814208984375, 0.800000011920928955078125, 0.699999988079071044921875, 0.60000002384185791015625))._m0; + _9 = _5(vec4(0.4000000059604644775390625, 0.300000011920928955078125, 0.20000000298023223876953125, 0.100000001490116119384765625), vec4(0.89999997615814208984375, 0.800000011920928955078125, 0.699999988079071044921875, 0.60000002384185791015625))._m1; +} + diff --git a/naga/tests/out/spv/wgsl-early-depth-test-conservative.spvasm.glsl b/naga/tests/out/spv/wgsl-early-depth-test-conservative.spvasm.glsl new file mode 100644 index 000000000..e73983fe8 --- /dev/null +++ b/naga/tests/out/spv/wgsl-early-depth-test-conservative.spvasm.glsl @@ -0,0 +1,8 @@ +#version 460 +layout(depth_less) out float gl_FragDepth; + +void main() +{ + gl_FragDepth = gl_FragCoord.z - 0.100000001490116119384765625; +} + diff --git a/naga/tests/out/spv/wgsl-early-depth-test-force.spvasm.glsl b/naga/tests/out/spv/wgsl-early-depth-test-force.spvasm.glsl new file mode 100644 index 000000000..3eab6c7d8 --- /dev/null +++ b/naga/tests/out/spv/wgsl-early-depth-test-force.spvasm.glsl @@ -0,0 +1,10 @@ +#version 460 +layout(early_fragment_tests) in; + +layout(location = 0) out vec4 _6; + +void main() +{ + _6 = vec4(0.4000000059604644775390625, 0.300000011920928955078125, 0.20000000298023223876953125, 0.100000001490116119384765625); +} + diff --git a/naga/tests/out/spv/wgsl-empty-if.spvasm.glsl b/naga/tests/out/spv/wgsl-empty-if.spvasm.glsl new file mode 100644 index 000000000..8f6ad1648 --- /dev/null +++ b/naga/tests/out/spv/wgsl-empty-if.spvasm.glsl @@ -0,0 +1,7 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-empty.spvasm.glsl b/naga/tests/out/spv/wgsl-empty.spvasm.glsl new file mode 100644 index 000000000..8f6ad1648 --- /dev/null +++ b/naga/tests/out/spv/wgsl-empty.spvasm.glsl @@ -0,0 +1,7 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-extra.spvasm.glsl b/naga/tests/out/spv/wgsl-extra.spvasm.glsl new file mode 100644 index 000000000..06fa88b52 --- /dev/null +++ b/naga/tests/out/spv/wgsl-extra.spvasm.glsl @@ -0,0 +1,37 @@ +#version 460 + +struct _6 +{ + uint _m0; + vec2 _m1; +}; + +struct _8 +{ + vec4 _m0; + uint _m1; +}; + +layout(push_constant, std430) uniform _10_9 +{ + _6 _m0; +} _9; + +layout(location = 0) in vec4 _14; +layout(location = 0) out vec4 _20; + +void main() +{ + _8 _13 = _8(_14, uint(gl_PrimitiveID)); + if (_13._m1 == _9._m0._m0) + { + _20 = _13._m0; + return; + } + else + { + _20 = vec4(vec3(1.0) - _13._m0.xyz, _13._m0.w); + return; + } +} + diff --git a/naga/tests/out/spv/wgsl-f16-native.spvasm.glsl b/naga/tests/out/spv/wgsl-f16-native.spvasm.glsl new file mode 100644 index 000000000..9485625c3 --- /dev/null +++ b/naga/tests/out/spv/wgsl-f16-native.spvasm.glsl @@ -0,0 +1,297 @@ +/////////////////////////////////////// +// Entry point: "test_direct" (frag) // +/////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float16_t scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in f16vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in f16vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in f16vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float16_t scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out f16vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out f16vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out f16vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _output.scalar_f16 = scalar_f16 + float16_t(1.0); + _output.scalar_f32 = scalar_f32 + 1.0; + _output.vec2_f16 = vec2_f16 + f16vec2(float16_t(1.0)); + _output.vec2_f32 = vec2_f32 + vec2(1.0); + _output.vec3_f16 = vec3_f16 + f16vec3(float16_t(1.0)); + _output.vec3_f32 = vec3_f32 + vec3(1.0); + _output.vec4_f16 = vec4_f16 + f16vec4(float16_t(1.0)); + _output.vec4_f32 = vec4_f32 + vec4(1.0); + scalar_f16_1 = _output.scalar_f16; + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = _output.vec2_f16; + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = _output.vec3_f16; + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = _output.vec4_f16; + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////// +// Entry point: "test_struct" (frag) // +/////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float16_t scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in f16vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in f16vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in f16vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float16_t scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out f16vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out f16vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out f16vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _111 = F16IO(scalar_f16, scalar_f32, vec2_f16, vec2_f32, vec3_f16, vec3_f32, vec4_f16, vec4_f32); + _output.scalar_f16 = _111.scalar_f16 + float16_t(1.0); + _output.scalar_f32 = _111.scalar_f32 + 1.0; + _output.vec2_f16 = _111.vec2_f16 + f16vec2(float16_t(1.0)); + _output.vec2_f32 = _111.vec2_f32 + vec2(1.0); + _output.vec3_f16 = _111.vec3_f16 + f16vec3(float16_t(1.0)); + _output.vec3_f32 = _111.vec3_f32 + vec3(1.0); + _output.vec4_f16 = _111.vec4_f16 + f16vec4(float16_t(1.0)); + _output.vec4_f32 = _111.vec4_f32 + vec4(1.0); + scalar_f16_1 = _output.scalar_f16; + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = _output.vec2_f16; + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = _output.vec3_f16; + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = _output.vec4_f16; + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////////// +// Entry point: "test_copy_input" (frag) // +/////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float16_t scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in f16vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in f16vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in f16vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float16_t scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out f16vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out f16vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out f16vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _input = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _input = F16IO(scalar_f16, scalar_f32, vec2_f16, vec2_f32, vec3_f16, vec3_f32, vec4_f16, vec4_f32); + _output.scalar_f16 = _input.scalar_f16 + float16_t(1.0); + _output.scalar_f32 = _input.scalar_f32 + 1.0; + _output.vec2_f16 = _input.vec2_f16 + f16vec2(float16_t(1.0)); + _output.vec2_f32 = _input.vec2_f32 + vec2(1.0); + _output.vec3_f16 = _input.vec3_f16 + f16vec3(float16_t(1.0)); + _output.vec3_f32 = _input.vec3_f32 + vec3(1.0); + _output.vec4_f16 = _input.vec4_f16 + f16vec4(float16_t(1.0)); + _output.vec4_f32 = _input.vec4_f32 + vec4(1.0); + scalar_f16_1 = _output.scalar_f16; + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = _output.vec2_f16; + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = _output.vec3_f16; + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = _output.vec4_f16; + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////////////// +// Entry point: "test_return_partial" (frag) // +/////////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float16_t scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in f16vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in f16vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in f16vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float16_t _264; + +void main() +{ + F16IO _input = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _input = F16IO(scalar_f16, scalar_f32, vec2_f16, vec2_f32, vec3_f16, vec3_f32, vec4_f16, vec4_f32); + _input.scalar_f16 = float16_t(0.0); + _264 = _input.scalar_f16; +} + + +///////////////////////////////////////////////// +// Entry point: "test_component_access" (frag) // +///////////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float16_t scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in f16vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in f16vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in f16vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float16_t scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out f16vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out f16vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out f16vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _274 = F16IO(scalar_f16, scalar_f32, vec2_f16, vec2_f32, vec3_f16, vec3_f32, vec4_f16, vec4_f32); + _output.vec2_f16.x = _274.vec2_f16.y; + _output.vec2_f16.y = _274.vec2_f16.x; + scalar_f16_1 = _output.scalar_f16; + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = _output.vec2_f16; + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = _output.vec3_f16; + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = _output.vec4_f16; + vec4_f32_1 = _output.vec4_f32; +} + diff --git a/naga/tests/out/spv/wgsl-f16-polyfill.spvasm.glsl b/naga/tests/out/spv/wgsl-f16-polyfill.spvasm.glsl new file mode 100644 index 000000000..74743df1e --- /dev/null +++ b/naga/tests/out/spv/wgsl-f16-polyfill.spvasm.glsl @@ -0,0 +1,297 @@ +/////////////////////////////////////// +// Entry point: "test_direct" (frag) // +/////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _output.scalar_f16 = float16_t(scalar_f16) + float16_t(1.0); + _output.scalar_f32 = scalar_f32 + 1.0; + _output.vec2_f16 = f16vec2(vec2_f16) + f16vec2(float16_t(1.0)); + _output.vec2_f32 = vec2_f32 + vec2(1.0); + _output.vec3_f16 = f16vec3(vec3_f16) + f16vec3(float16_t(1.0)); + _output.vec3_f32 = vec3_f32 + vec3(1.0); + _output.vec4_f16 = f16vec4(vec4_f16) + f16vec4(float16_t(1.0)); + _output.vec4_f32 = vec4_f32 + vec4(1.0); + scalar_f16_1 = float(_output.scalar_f16); + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = vec2(_output.vec2_f16); + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = vec3(_output.vec3_f16); + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = vec4(_output.vec4_f16); + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////// +// Entry point: "test_struct" (frag) // +/////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _111 = F16IO(float16_t(scalar_f16), scalar_f32, f16vec2(vec2_f16), vec2_f32, f16vec3(vec3_f16), vec3_f32, f16vec4(vec4_f16), vec4_f32); + _output.scalar_f16 = _111.scalar_f16 + float16_t(1.0); + _output.scalar_f32 = _111.scalar_f32 + 1.0; + _output.vec2_f16 = _111.vec2_f16 + f16vec2(float16_t(1.0)); + _output.vec2_f32 = _111.vec2_f32 + vec2(1.0); + _output.vec3_f16 = _111.vec3_f16 + f16vec3(float16_t(1.0)); + _output.vec3_f32 = _111.vec3_f32 + vec3(1.0); + _output.vec4_f16 = _111.vec4_f16 + f16vec4(float16_t(1.0)); + _output.vec4_f32 = _111.vec4_f32 + vec4(1.0); + scalar_f16_1 = float(_output.scalar_f16); + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = vec2(_output.vec2_f16); + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = vec3(_output.vec3_f16); + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = vec4(_output.vec4_f16); + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////////// +// Entry point: "test_copy_input" (frag) // +/////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _input = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _input = F16IO(float16_t(scalar_f16), scalar_f32, f16vec2(vec2_f16), vec2_f32, f16vec3(vec3_f16), vec3_f32, f16vec4(vec4_f16), vec4_f32); + _output.scalar_f16 = _input.scalar_f16 + float16_t(1.0); + _output.scalar_f32 = _input.scalar_f32 + 1.0; + _output.vec2_f16 = _input.vec2_f16 + f16vec2(float16_t(1.0)); + _output.vec2_f32 = _input.vec2_f32 + vec2(1.0); + _output.vec3_f16 = _input.vec3_f16 + f16vec3(float16_t(1.0)); + _output.vec3_f32 = _input.vec3_f32 + vec3(1.0); + _output.vec4_f16 = _input.vec4_f16 + f16vec4(float16_t(1.0)); + _output.vec4_f32 = _input.vec4_f32 + vec4(1.0); + scalar_f16_1 = float(_output.scalar_f16); + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = vec2(_output.vec2_f16); + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = vec3(_output.vec3_f16); + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = vec4(_output.vec4_f16); + vec4_f32_1 = _output.vec4_f32; +} + + +/////////////////////////////////////////////// +// Entry point: "test_return_partial" (frag) // +/////////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float _284; + +void main() +{ + F16IO _input = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + _input = F16IO(float16_t(scalar_f16), scalar_f32, f16vec2(vec2_f16), vec2_f32, f16vec3(vec3_f16), vec3_f32, f16vec4(vec4_f16), vec4_f32); + _input.scalar_f16 = float16_t(0.0); + _284 = float(_input.scalar_f16); +} + + +///////////////////////////////////////////////// +// Entry point: "test_component_access" (frag) // +///////////////////////////////////////////////// +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require + +struct F16IO +{ + float16_t scalar_f16; + float scalar_f32; + f16vec2 vec2_f16; + vec2 vec2_f32; + f16vec3 vec3_f16; + vec3 vec3_f32; + f16vec4 vec4_f16; + vec4 vec4_f32; +}; + +layout(location = 0) in float scalar_f16; +layout(location = 1) in float scalar_f32; +layout(location = 2) in vec2 vec2_f16; +layout(location = 3) in vec2 vec2_f32; +layout(location = 4) in vec3 vec3_f16; +layout(location = 5) in vec3 vec3_f32; +layout(location = 6) in vec4 vec4_f16; +layout(location = 7) in vec4 vec4_f32; +layout(location = 0) out float scalar_f16_1; +layout(location = 1) out float scalar_f32_1; +layout(location = 2) out vec2 vec2_f16_1; +layout(location = 3) out vec2 vec2_f32_1; +layout(location = 4) out vec3 vec3_f16_1; +layout(location = 5) out vec3 vec3_f32_1; +layout(location = 6) out vec4 vec4_f16_1; +layout(location = 7) out vec4 vec4_f32_1; + +void main() +{ + F16IO _output = F16IO(float16_t(0.0), 0.0, f16vec2(float16_t(0.0)), vec2(0.0), f16vec3(float16_t(0.0)), vec3(0.0), f16vec4(float16_t(0.0)), vec4(0.0)); + F16IO _295 = F16IO(float16_t(scalar_f16), scalar_f32, f16vec2(vec2_f16), vec2_f32, f16vec3(vec3_f16), vec3_f32, f16vec4(vec4_f16), vec4_f32); + _output.vec2_f16.x = _295.vec2_f16.y; + _output.vec2_f16.y = _295.vec2_f16.x; + scalar_f16_1 = float(_output.scalar_f16); + scalar_f32_1 = _output.scalar_f32; + vec2_f16_1 = vec2(_output.vec2_f16); + vec2_f32_1 = _output.vec2_f32; + vec3_f16_1 = vec3(_output.vec3_f16); + vec3_f32_1 = _output.vec3_f32; + vec4_f16_1 = vec4(_output.vec4_f16); + vec4_f32_1 = _output.vec4_f32; +} + diff --git a/naga/tests/out/spv/wgsl-f16.spvasm.glsl b/naga/tests/out/spv/wgsl-f16.spvasm.glsl new file mode 100644 index 000000000..690eaa5b9 --- /dev/null +++ b/naga/tests/out/spv/wgsl-f16.spvasm.glsl @@ -0,0 +1,172 @@ +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _19 +{ + uint _m0; + int _m1; + float _m2; + float16_t _m3; + f16vec2 _m4; + f16vec3 _m5; + f16vec4 _m6; + float16_t _m7; + f16mat2 _m8; + f16mat2x3 _m9; + f16mat2x4 _m10; + f16mat3x2 _m11; + f16mat3 _m12; + f16mat3x4 _m13; + f16mat4x2 _m14; + f16mat4x3 _m15; + f16mat4 _m16; +}; + +struct _22 +{ + float16_t _m0[2]; +}; + +struct _23 +{ + float16_t _m0; + float16_t _m1; + f16vec3 _m2; + float16_t _m3; + float16_t _m4; + uint _m5; +}; + +struct _24 +{ + uint _m0; + int _m1; + float _m2; + float16_t _m3; + f16vec2 _m4; + f16vec3 _m5; + f16vec4 _m6; + float16_t _m7; + f16vec2 _m8; + f16vec2 _m9; + f16mat2x3 _m10; + f16mat2x4 _m11; + f16vec2 _m12; + f16vec2 _m13; + f16vec2 _m14; + f16mat3 _m15; + f16mat3x4 _m16; + f16vec2 _m17; + f16vec2 _m18; + f16vec2 _m19; + f16vec2 _m20; + f16mat4x3 _m21; + f16mat4 _m22; +}; + +layout(set = 0, binding = 0, std140) uniform _30_29 +{ + _24 _m0; +} _29; + +layout(set = 0, binding = 1, std430) readonly buffer _33_32 +{ + _19 _m0; +} _32; + +layout(set = 0, binding = 2, std430) readonly buffer _36_35 +{ + _22 _m0; +} _35; + +layout(set = 0, binding = 3, std430) buffer _39_38 +{ + _19 _m0; +} _38; + +layout(set = 0, binding = 4, std430) buffer _42_41 +{ + _22 _m0; +} _41; + +float16_t _27 = float16_t(1.0); + +float16_t _46(float16_t _45) +{ + _23 _65 = _23(float16_t(0.0), float16_t(0.0), f16vec3(float16_t(0.0)), float16_t(0.0), float16_t(0.0), 0u); + float16_t _68 = float16_t(15.203125); + _68 += float16_t(-33344.0); + _68 += (_68 + float16_t(5.0)); + _68 += float16_t(_29._m0._m2 + float(_68)); + _68 += f16vec3(_29._m0._m3).z; + _38._m0._m1 = 65504; + _38._m0._m1 = -65504; + _38._m0._m0 = 65504u; + _38._m0._m0 = 0u; + _38._m0._m2 = 65504.0; + _38._m0._m2 = -65504.0; + _38._m0._m3 = _29._m0._m3 + _32._m0._m3; + _38._m0._m4 = _29._m0._m4 + _32._m0._m4; + _38._m0._m5 = _29._m0._m5 + _32._m0._m5; + _38._m0._m6 = _29._m0._m6 + _32._m0._m6; + f16mat2 _147 = f16mat2(_29._m0._m8, _29._m0._m9); + _38._m0._m8 = f16mat2(_147[0] + _32._m0._m8[0], _147[1] + _32._m0._m8[1]); + _38._m0._m9 = f16mat2x3(_29._m0._m10[0] + _32._m0._m9[0], _29._m0._m10[1] + _32._m0._m9[1]); + _38._m0._m10 = f16mat2x4(_29._m0._m11[0] + _32._m0._m10[0], _29._m0._m11[1] + _32._m0._m10[1]); + f16mat3x2 _199 = f16mat3x2(_29._m0._m12, _29._m0._m13, _29._m0._m14); + _38._m0._m11 = f16mat3x2(_199[0] + _32._m0._m11[0], _199[1] + _32._m0._m11[1], _199[2] + _32._m0._m11[2]); + _38._m0._m12 = f16mat3(_29._m0._m15[0] + _32._m0._m12[0], _29._m0._m15[1] + _32._m0._m12[1], _29._m0._m15[2] + _32._m0._m12[2]); + _38._m0._m13 = f16mat3x4(_29._m0._m16[0] + _32._m0._m13[0], _29._m0._m16[1] + _32._m0._m13[1], _29._m0._m16[2] + _32._m0._m13[2]); + f16mat4x2 _263 = f16mat4x2(_29._m0._m17, _29._m0._m18, _29._m0._m19, _29._m0._m20); + _38._m0._m14 = f16mat4x2(_263[0] + _32._m0._m14[0], _263[1] + _32._m0._m14[1], _263[2] + _32._m0._m14[2], _263[3] + _32._m0._m14[3]); + _38._m0._m15 = f16mat4x3(_29._m0._m21[0] + _32._m0._m15[0], _29._m0._m21[1] + _32._m0._m15[1], _29._m0._m21[2] + _32._m0._m15[2], _29._m0._m21[3] + _32._m0._m15[3]); + _38._m0._m16 = f16mat4(_29._m0._m22[0] + _32._m0._m16[0], _29._m0._m22[1] + _32._m0._m16[1], _29._m0._m22[2] + _32._m0._m16[2], _29._m0._m22[3] + _32._m0._m16[3]); + _41._m0._m0 = _35._m0._m0; + _68 += abs(_68); + _68 += clamp(_68, _68, _68); + _68 += dot(f16vec2(_68), f16vec2(_68)); + _68 += max(_68, _68); + _68 += min(_68, _68); + _68 += sign(_68); + _68 += float16_t(1.0); + _38._m0._m4 = f16vec2(vec2(_29._m0._m4)); + _38._m0._m5 = f16vec3(vec3(_29._m0._m5)); + _38._m0._m6 = f16vec4(vec4(_29._m0._m6)); + f16mat2 _381 = f16mat2(_29._m0._m8, _29._m0._m9); + mat2 _387 = mat2(vec2(_381[0]), vec2(_381[1])); + _38._m0._m8 = f16mat2(f16vec2(_387[0]), f16vec2(_387[1])); + mat2x3 _401 = mat2x3(vec3(_29._m0._m10[0]), vec3(_29._m0._m10[1])); + _38._m0._m9 = f16mat2x3(f16vec3(_401[0]), f16vec3(_401[1])); + mat2x4 _415 = mat2x4(vec4(_29._m0._m11[0]), vec4(_29._m0._m11[1])); + _38._m0._m10 = f16mat2x4(f16vec4(_415[0]), f16vec4(_415[1])); + f16mat3x2 _428 = f16mat3x2(_29._m0._m12, _29._m0._m13, _29._m0._m14); + mat3x2 _436 = mat3x2(vec2(_428[0]), vec2(_428[1]), vec2(_428[2])); + _38._m0._m11 = f16mat3x2(f16vec2(_436[0]), f16vec2(_436[1]), f16vec2(_436[2])); + mat3 _454 = mat3(vec3(_29._m0._m15[0]), vec3(_29._m0._m15[1]), vec3(_29._m0._m15[2])); + _38._m0._m12 = f16mat3(f16vec3(_454[0]), f16vec3(_454[1]), f16vec3(_454[2])); + mat3x4 _472 = mat3x4(vec4(_29._m0._m16[0]), vec4(_29._m0._m16[1]), vec4(_29._m0._m16[2])); + _38._m0._m13 = f16mat3x4(f16vec4(_472[0]), f16vec4(_472[1]), f16vec4(_472[2])); + f16mat4x2 _489 = f16mat4x2(_29._m0._m17, _29._m0._m18, _29._m0._m19, _29._m0._m20); + mat4x2 _499 = mat4x2(vec2(_489[0]), vec2(_489[1]), vec2(_489[2]), vec2(_489[3])); + _38._m0._m14 = f16mat4x2(f16vec2(_499[0]), f16vec2(_499[1]), f16vec2(_499[2]), f16vec2(_499[3])); + mat4x3 _521 = mat4x3(vec3(_29._m0._m21[0]), vec3(_29._m0._m21[1]), vec3(_29._m0._m21[2]), vec3(_29._m0._m21[3])); + _38._m0._m15 = f16mat4x3(f16vec3(_521[0]), f16vec3(_521[1]), f16vec3(_521[2]), f16vec3(_521[3])); + mat4 _543 = mat4(vec4(_29._m0._m22[0]), vec4(_29._m0._m22[1]), vec4(_29._m0._m22[2]), vec4(_29._m0._m22[3])); + _38._m0._m16 = f16mat4(f16vec4(_543[0]), f16vec4(_543[1]), f16vec4(_543[2]), f16vec4(_543[3])); + return _68; +} + +void main() +{ + float16_t _565 = _46(float16_t(2.0)); + _38._m0._m7 = _565; +} + diff --git a/naga/tests/out/spv/wgsl-f64.spvasm.glsl b/naga/tests/out/spv/wgsl-f64.spvasm.glsl new file mode 100644 index 000000000..f91db37d3 --- /dev/null +++ b/naga/tests/out/spv/wgsl-f64.spvasm.glsl @@ -0,0 +1,18 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +double _6 = 1.0lf; + +double _10(double _9) +{ + double _16 = 0.0lf; + double _19 = -1.0lf; + double _22 = 30.0lf + 400.0lf; + _16 = _22 + 5.0lf; + return ((_9 + _22) + 2.0lf) + 5.0lf; +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-fragment-output.spvasm.glsl b/naga/tests/out/spv/wgsl-fragment-output.spvasm.glsl new file mode 100644 index 000000000..3d944e9a8 --- /dev/null +++ b/naga/tests/out/spv/wgsl-fragment-output.spvasm.glsl @@ -0,0 +1,99 @@ +///////////////////////////////////////// +// Entry point: "main_vec4vec3" (frag) // +///////////////////////////////////////// +#version 460 + +struct _12 +{ + vec4 _m0; + ivec4 _m1; + uvec4 _m2; + vec3 _m3; + ivec3 _m4; + uvec3 _m5; +}; + +struct _16 +{ + vec2 _m0; + ivec2 _m1; + uvec2 _m2; + float _m3; + int _m4; + uint _m5; +}; + +layout(location = 0) out vec4 _18; +layout(location = 1) out ivec4 _20; +layout(location = 2) out uvec4 _22; +layout(location = 3) out vec3 _24; +layout(location = 4) out ivec3 _26; +layout(location = 5) out uvec3 _28; + +void main() +{ + _12 _41 = _12(vec4(0.0), ivec4(0), uvec4(0u), vec3(0.0), ivec3(0), uvec3(0u)); + _41._m0 = vec4(0.0); + _41._m1 = ivec4(0); + _41._m2 = uvec4(0u); + _41._m3 = vec3(0.0); + _41._m4 = ivec3(0); + _41._m5 = uvec3(0u); + _18 = _41._m0; + _20 = _41._m1; + _22 = _41._m2; + _24 = _41._m3; + _26 = _41._m4; + _28 = _41._m5; +} + + +/////////////////////////////////////////// +// Entry point: "main_vec2scalar" (frag) // +/////////////////////////////////////////// +#version 460 + +struct _12 +{ + vec4 _m0; + ivec4 _m1; + uvec4 _m2; + vec3 _m3; + ivec3 _m4; + uvec3 _m5; +}; + +struct _16 +{ + vec2 _m0; + ivec2 _m1; + uvec2 _m2; + float _m3; + int _m4; + uint _m5; +}; + +layout(location = 0) out vec2 _70; +layout(location = 1) out ivec2 _72; +layout(location = 2) out uvec2 _74; +layout(location = 3) out float _76; +layout(location = 4) out int _78; +layout(location = 5) out uint _80; + +void main() +{ + _16 _86 = _16(vec2(0.0), ivec2(0), uvec2(0u), 0.0, 0, 0u); + _86._m0 = vec2(0.0); + _86._m1 = ivec2(0); + _86._m2 = uvec2(0u); + _86._m3 = 0.0; + _86._m4 = 0; + _86._m5 = 0u; + _70 = _86._m0; + _72 = _86._m1; + _74 = _86._m2; + _76 = _86._m3; + _78 = _86._m4; + _80 = _86._m5; +} + diff --git a/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm.glsl b/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm.glsl new file mode 100644 index 000000000..b7bd52097 --- /dev/null +++ b/naga/tests/out/spv/wgsl-functions-optimized-by-capability.spvasm.glsl @@ -0,0 +1,2 @@ +// spirv-cross error: +// SPIRV-Cross threw an exception: Cannot resolve expression type. diff --git a/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm.glsl b/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm.glsl new file mode 100644 index 000000000..b7bd52097 --- /dev/null +++ b/naga/tests/out/spv/wgsl-functions-optimized-by-version.spvasm.glsl @@ -0,0 +1,2 @@ +// spirv-cross error: +// SPIRV-Cross threw an exception: Cannot resolve expression type. diff --git a/naga/tests/out/spv/wgsl-functions-unoptimized.spvasm.glsl b/naga/tests/out/spv/wgsl-functions-unoptimized.spvasm.glsl new file mode 100644 index 000000000..c41ebd130 --- /dev/null +++ b/naga/tests/out/spv/wgsl-functions-unoptimized.spvasm.glsl @@ -0,0 +1,19 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +uint _5() +{ + int _18 = int(1u); + int _19 = int(2u); + uint _39 = (((0u + (bitfieldExtract(3u, int(0u), int(8u)) * bitfieldExtract(4u, int(0u), int(8u)))) + (bitfieldExtract(3u, int(8u), int(8u)) * bitfieldExtract(4u, int(8u), int(8u)))) + (bitfieldExtract(3u, int(16u), int(8u)) * bitfieldExtract(4u, int(16u), int(8u)))) + (bitfieldExtract(3u, int(24u), int(8u)) * bitfieldExtract(4u, int(24u), int(8u))); + int _59 = int(5u + _39); + int _60 = int(6u + _39); + uint _76 = 7u + _39; + uint _77 = 8u + _39; + return (((0u + (bitfieldExtract(_76, int(0u), int(8u)) * bitfieldExtract(_77, int(0u), int(8u)))) + (bitfieldExtract(_76, int(8u), int(8u)) * bitfieldExtract(_77, int(8u), int(8u)))) + (bitfieldExtract(_76, int(16u), int(8u)) * bitfieldExtract(_77, int(16u), int(8u)))) + (bitfieldExtract(_76, int(24u), int(8u)) * bitfieldExtract(_77, int(24u), int(8u))); +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-functions.spvasm.glsl b/naga/tests/out/spv/wgsl-functions.spvasm.glsl new file mode 100644 index 000000000..b7bd52097 --- /dev/null +++ b/naga/tests/out/spv/wgsl-functions.spvasm.glsl @@ -0,0 +1,2 @@ +// spirv-cross error: +// SPIRV-Cross threw an exception: Cannot resolve expression type. diff --git a/naga/tests/out/spv/wgsl-globals.spvasm.glsl b/naga/tests/out/spv/wgsl-globals.spvasm.glsl new file mode 100644 index 000000000..2afb98211 --- /dev/null +++ b/naga/tests/out/spv/wgsl-globals.spvasm.glsl @@ -0,0 +1,108 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _9 +{ + vec3 _m0; + float _m1; +}; + +struct _25 +{ + vec2 _m0; + vec2 _m1; + vec2 _m2; +}; + +struct _26 +{ + vec2 _m0; + vec2 _m1; + vec2 _m2; + vec2 _m3; +}; + +layout(set = 0, binding = 1, std430) buffer _35_34 +{ + _9 _m0; +} _34; + +layout(set = 0, binding = 2, std430) readonly buffer _38_37 +{ + vec2 _m0[]; +} _37; + +layout(set = 0, binding = 3, std140) uniform _41_40 +{ + vec4 _m0[20]; +} _40; + +layout(set = 0, binding = 4, std140) uniform _44_43 +{ + vec3 _m0; +} _43; + +layout(set = 0, binding = 5, std140) uniform _47_46 +{ + _25 _m0; +} _46; + +layout(set = 0, binding = 6, std140) uniform _50_49 +{ + mat2x4 _m0[2][2]; +} _49; + +layout(set = 0, binding = 7, std140) uniform _53_52 +{ + _26 _m0[2][2]; +} _52; + +shared float _30[10]; +shared uint _32; + +void _57(vec3 _56) +{ +} + +void _61() +{ + int _72 = 1; + _34._m0._m0 = vec3(1.0); + _34._m0._m0.x = 1.0; + _34._m0._m0.x = 2.0; + _34._m0._m0[_72] = 3.0; + _57(_34._m0._m0); +} + +mat4x2 _96(_26 _98) +{ + return mat4x2(_98._m0, _98._m1, _98._m2, _98._m3); +} + +mat3x2 _105(_25 _107) +{ + return mat3x2(_107._m0, _107._m1, _107._m2); +} + +void main() +{ + float _131 = 1.0; + bool _133 = true; + if (gl_LocalInvocationIndex == 0u) + { + _30 = float[](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + _32 = 0u; + } + barrier(); + _61(); + _30[7u] = (_96(_52._m0[0u][0u]) * _49._m0[0u][0u][0u]).x; + _30[6u] = (_105(_46._m0) * _43._m0).x; + _30[5u] = _37._m0[1u].y; + _30[4u] = _40._m0[0u].w; + _30[3u] = _34._m0._m1; + _30[2u] = _34._m0._m0.x; + _34._m0._m1 = 4.0; + _30[1u] = float(uint(_37._m0.length())); + atomicExchange(_32, 2u); +} + diff --git a/naga/tests/out/spv/wgsl-image.spvasm.glsl b/naga/tests/out/spv/wgsl-image.spvasm.glsl new file mode 100644 index 000000000..d311a332c --- /dev/null +++ b/naga/tests/out/spv/wgsl-image.spvasm.glsl @@ -0,0 +1,370 @@ +//////////////////////////////// +// Entry point: "main" (comp) // +//////////////////////////////// +#version 460 +#extension GL_EXT_samplerless_texture_functions : require +layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +ivec2 naga_mod(ivec2 lhs, ivec2 rhs) +{ + bvec2 _79 = equal(rhs, ivec2(0)); + bvec2 _84 = equal(lhs, ivec2(int(0x80000000))); + bvec2 _85 = equal(rhs, ivec2(-1)); + bvec2 _86 = bvec2(_84.x && _85.x, _84.y && _85.y); + return lhs - mix(rhs, ivec2(1), bvec2(_79.x || _86.x, _79.y || _86.y)) * (lhs / mix(rhs, ivec2(1), bvec2(_79.x || _86.x, _79.y || _86.y))); +} + +void main() +{ + ivec2 _114 = naga_mod(ivec2(uvec2(imageSize(image_storage_src)) * gl_LocalInvocationID.xy), ivec2(10, 20)); + uvec4 _162 = imageLoad(image_storage_src, ivec2(uvec2(_114))); + imageStore(image_dst, _114.x, (((texelFetch(image_mipmapped_src, _114, int(gl_LocalInvocationID.z)) + texelFetch(image_multisampled_src, _114, int(gl_LocalInvocationID.z))) + imageLoad(image_storage_src, _114)) + texelFetch(image_array_src, ivec3(_114, int(gl_LocalInvocationID.z)), int(gl_LocalInvocationID.z) + 1)) + texelFetch(image_array_src, ivec3(_114, int(gl_LocalInvocationID.z)), int(gl_LocalInvocationID.z) + 1)); + imageStore(image_dst, int(uint(_114.x)), (((texelFetch(image_mipmapped_src, ivec2(uvec2(_114)), int(gl_LocalInvocationID.z)) + texelFetch(image_multisampled_src, ivec2(uvec2(_114)), int(gl_LocalInvocationID.z))) + _162) + texelFetch(image_array_src, ivec3(uvec3(uvec2(_114), gl_LocalInvocationID.z)), int(gl_LocalInvocationID.z) + 1)) + texelFetch(image_array_src, ivec3(uvec3(uvec2(_114), uint(int(gl_LocalInvocationID.z)))), int(gl_LocalInvocationID.z) + 1)); +} + + +////////////////////////////////////// +// Entry point: "depth_load" (comp) // +////////////////////////////////////// +#version 460 +#extension GL_EXT_samplerless_texture_functions : require +layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +ivec2 naga_mod(ivec2 lhs, ivec2 rhs) +{ + bvec2 _79 = equal(rhs, ivec2(0)); + bvec2 _84 = equal(lhs, ivec2(int(0x80000000))); + bvec2 _85 = equal(rhs, ivec2(-1)); + bvec2 _86 = bvec2(_84.x && _85.x, _84.y && _85.y); + return lhs - mix(rhs, ivec2(1), bvec2(_79.x || _86.x, _79.y || _86.y)) * (lhs / mix(rhs, ivec2(1), bvec2(_79.x || _86.x, _79.y || _86.y))); +} + +void main() +{ + ivec2 _206 = naga_mod(ivec2(uvec2(imageSize(image_storage_src)) * gl_LocalInvocationID.xy), ivec2(10, 20)); + imageStore(image_dst, _206.x, uvec4(uint(clamp(texelFetch(image_depth_multisampled_src, _206, int(gl_LocalInvocationID.z)).x, 0.0, 4294967040.0)))); +} + + +/////////////////////////////////// +// Entry point: "queries" (vert) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +void main() +{ + uint _230 = uint(textureSize(image_1d, int(0u))); + gl_Position = vec4(float((((((((((_230 + uvec2(textureSize(image_2d, int(0u))).y) + uvec2(textureSize(image_2d, 1)).y) + uvec3(textureSize(image_2d_array, int(0u))).xy.y) + uvec3(textureSize(image_2d_array, 1)).xy.y) + uvec2(textureSize(image_cube, int(0u))).y) + uvec2(textureSize(image_cube, 1)).y) + uvec3(textureSize(image_cube_array, int(0u))).xx.y) + uvec3(textureSize(image_cube_array, 1)).xx.y) + uvec3(textureSize(image_3d, int(0u))).z) + uvec3(textureSize(image_3d, 1)).z)); +} + + +////////////////////////////////////////// +// Entry point: "levels_queries" (vert) // +////////////////////////////////////////// +#version 460 +#extension GL_EXT_samplerless_texture_functions : require + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +void main() +{ + gl_Position = vec4(float(((((((uvec3(textureSize(image_2d_array, int(0u))).z + uvec3(textureSize(image_cube_array, int(0u))).z) + uint(textureSamples(image_aa))) + uint(textureQueryLevels(image_2d))) + uint(textureQueryLevels(image_2d_array))) + uint(textureQueryLevels(image_3d))) + uint(textureQueryLevels(image_cube))) + uint(textureQueryLevels(image_cube_array)))); +} + + +////////////////////////////////////////// +// Entry point: "texture_sample" (frag) // +////////////////////////////////////////// +#version 460 +#extension GL_EXT_samplerless_texture_functions : require +#extension GL_EXT_spirv_intrinsics : require + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +layout(location = 0) out vec4 _302; + +spirv_instruction(set = "GLSL.std.450", id = 81) float spvNClamp(float, float, float); +spirv_instruction(set = "GLSL.std.450", id = 81) vec2 spvNClamp(vec2, vec2, vec2); +spirv_instruction(set = "GLSL.std.450", id = 81) vec3 spvNClamp(vec3, vec3, vec3); +spirv_instruction(set = "GLSL.std.450", id = 81) vec4 spvNClamp(vec4, vec4, vec4); + +void main() +{ + vec4 a = vec4(0.0); + a += texture(sampler1D(image_1d, sampler_reg), 0.5); + a += texture(sampler2D(image_2d, sampler_reg), vec2(0.5)); + a += textureOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1)); + a += textureLod(sampler2D(image_2d, sampler_reg), vec2(0.5), 2.2999999523162841796875); + a += textureLodOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), 2.2999999523162841796875, ivec2(3, 1)); + a += textureOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1), 2.0); + vec2 _351 = vec2(0.5) / vec2(uvec2(textureSize(image_2d, int(0u)))); + a += textureLod(sampler2D(image_2d, sampler_reg), spvNClamp(vec2(0.5), _351, vec2(1.0) - _351), 0.0); + float _361 = float(0u); + a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _361)); + float _367 = float(0u); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _367), ivec2(3, 1)); + float _373 = float(0u); + a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _373), 2.2999999523162841796875); + float _379 = float(0u); + a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _379), 2.2999999523162841796875, ivec2(3, 1)); + float _385 = float(0u); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _385), ivec2(3, 1), 2.0); + float _391 = float(0); + a += texture(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _391)); + float _397 = float(0); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _397), ivec2(3, 1)); + float _403 = float(0); + a += textureLod(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _403), 2.2999999523162841796875); + float _409 = float(0); + a += textureLodOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _409), 2.2999999523162841796875, ivec2(3, 1)); + float _415 = float(0); + a += textureOffset(sampler2DArray(image_2d_array, sampler_reg), vec3(vec2(0.5), _415), ivec2(3, 1), 2.0); + float _422 = float(0u); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _422)); + float _428 = float(0u); + a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _428), 2.2999999523162841796875); + float _434 = float(0u); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _434), 2.0); + float _440 = float(0); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _440)); + float _446 = float(0); + a += textureLod(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _446), 2.2999999523162841796875); + float _452 = float(0); + a += texture(samplerCubeArray(image_cube_array, sampler_reg), vec4(vec3(0.5), _452), 2.0); + _302 = a; +} + + +///////////////////////////////////////////////////// +// Entry point: "texture_sample_comparison" (frag) // +///////////////////////////////////////////////////// +#version 460 + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform samplerShadow sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +layout(location = 0) out float _459; + +void main() +{ + float a = 0.0; + a += texture(sampler2DShadow(image_2d_depth, sampler_cmp), vec3(vec2(0.5), 0.5)); + float _477 = float(0u); + a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _477), 0.5)); + float _483 = float(0); + a += texture(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _483), 0.5)); + a += texture(samplerCubeShadow(image_cube_depth, sampler_cmp), vec4(vec3(0.5), 0.5)); + a += textureLod(sampler2DShadow(image_2d_depth, sampler_cmp), vec3(vec2(0.5), 0.5), 0.0); + float _498 = float(0u); + a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _498), 0.5), vec2(0.0), vec2(0.0)); + float _504 = float(0); + a += textureGrad(sampler2DArrayShadow(image_2d_array_depth, sampler_cmp), vec4(vec3(vec2(0.5), _504), 0.5), vec2(0.0), vec2(0.0)); + a += textureGrad(samplerCubeShadow(image_cube_depth, sampler_cmp), vec4(vec3(0.5), 0.5), vec3(0.0), vec3(0.0)); + _459 = a; +} + + +////////////////////////////////// +// Entry point: "gather" (frag) // +////////////////////////////////// +#version 460 + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform samplerShadow sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +layout(location = 0) out vec4 _515; + +void main() +{ + _515 = (((textureGather(sampler2D(image_2d, sampler_reg), vec2(0.5), int(1u)) + textureGatherOffset(sampler2D(image_2d, sampler_reg), vec2(0.5), ivec2(3, 1), int(3u))) + textureGather(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5)) + textureGatherOffset(sampler2DShadow(image_2d_depth, sampler_cmp), vec2(0.5), 0.5, ivec2(3, 1))) + (vec4(textureGather(usampler2D(image_2d_u32, sampler_reg), vec2(0.5))) + vec4(textureGather(isampler2D(image_2d_i32, sampler_reg), vec2(0.5)))); +} + + +/////////////////////////////////////////////// +// Entry point: "depth_no_comparison" (frag) // +/////////////////////////////////////////////// +#version 460 + +layout(set = 0, binding = 0) uniform utexture2D image_mipmapped_src; +layout(set = 0, binding = 3) uniform utexture2DMS image_multisampled_src; +layout(set = 0, binding = 4) uniform texture2DMS image_depth_multisampled_src; +layout(set = 0, binding = 1, rgba8ui) uniform readonly uimage2D image_storage_src; +layout(set = 0, binding = 5) uniform utexture2DArray image_array_src; +layout(set = 0, binding = 6, r32ui) uniform readonly uimage1D image_dup_src; +layout(set = 0, binding = 7) uniform utexture1D image_1d_src; +layout(set = 0, binding = 2, r32ui) uniform writeonly uimage1D image_dst; +layout(set = 0, binding = 0) uniform texture1D image_1d; +layout(set = 0, binding = 1) uniform texture2D image_2d; +layout(set = 0, binding = 2) uniform utexture2D image_2d_u32; +layout(set = 0, binding = 3) uniform itexture2D image_2d_i32; +layout(set = 0, binding = 4) uniform texture2DArray image_2d_array; +layout(set = 0, binding = 5) uniform textureCube image_cube; +layout(set = 0, binding = 6) uniform textureCubeArray image_cube_array; +layout(set = 0, binding = 7) uniform texture3D image_3d; +layout(set = 0, binding = 8) uniform texture2DMS image_aa; +layout(set = 1, binding = 0) uniform sampler sampler_reg; +layout(set = 1, binding = 1) uniform sampler sampler_cmp; +layout(set = 1, binding = 2) uniform texture2D image_2d_depth; +layout(set = 1, binding = 3) uniform texture2DArray image_2d_array_depth; +layout(set = 1, binding = 4) uniform textureCube image_cube_depth; + +layout(location = 0) out vec4 _549; + +void main() +{ + float _561 = float(1); + _549 = (vec4(texture(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5)).x) + textureGather(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5))) + vec4(textureLod(sampler2DShadow(image_2d_depth, sampler_reg), vec2(0.5), _561).x); +} + diff --git a/naga/tests/out/spv/wgsl-index-by-value.spvasm.glsl b/naga/tests/out/spv/wgsl-index-by-value.spvasm.glsl new file mode 100644 index 000000000..b9db28642 --- /dev/null +++ b/naga/tests/out/spv/wgsl-index-by-value.spvasm.glsl @@ -0,0 +1,32 @@ +#version 460 + +const int _36[2][2] = int[][](int[](1, 2), int[](3, 4)); +const int _65[5] = int[](1, 2, 3, 4, 5); + +int _17(int _15[5], int _16) +{ + int _21[5] = _15; + return _21[_16]; +} + +int _28(int _26, int _27) +{ + return _36[_26][_27]; +} + +float _45(int _43, int _44) +{ + mat2 _56 = mat2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + return _56[_43][_44]; +} + +vec4 _62(uint _61) +{ + return vec4(ivec4(_65[_61])); +} + +void main() +{ + gl_Position = _62(uint(gl_VertexIndex)); +} + diff --git a/naga/tests/out/spv/wgsl-int-div-unchecked.spvasm.glsl b/naga/tests/out/spv/wgsl-int-div-unchecked.spvasm.glsl new file mode 100644 index 000000000..7421a703b --- /dev/null +++ b/naga/tests/out/spv/wgsl-int-div-unchecked.spvasm.glsl @@ -0,0 +1,11 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + int _13 = 5 / 2; + int _14 = 5 - 2 * (5 / 2); + uint _15 = 5u / 2u; + uint _16 = 5u % 2u; +} + diff --git a/naga/tests/out/spv/wgsl-int16.spvasm.glsl b/naga/tests/out/spv/wgsl-int16.spvasm.glsl new file mode 100644 index 000000000..e96f51aa0 --- /dev/null +++ b/naga/tests/out/spv/wgsl-int16.spvasm.glsl @@ -0,0 +1,182 @@ +#version 460 +#extension GL_EXT_shader_explicit_arithmetic_types_int16 : require +#extension GL_EXT_shader_16bit_storage : require +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_EXT_shader_subgroup_extended_types_int16 : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_shuffle : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct _14 +{ + uint _m0; + int _m1; + float _m2; + uint16_t _m3; + u16vec2 _m4; + u16vec3 _m5; + u16vec4 _m6; + int16_t _m7; + i16vec2 _m8; + i16vec3 _m9; + i16vec4 _m10; + uint16_t _m11; +}; + +struct _18 +{ + uint16_t _m0[2]; + int16_t _m1[2]; +}; + +layout(set = 0, binding = 0, std140) uniform _27_26 +{ + _14 _m0; +} _26; + +layout(set = 0, binding = 1, std430) readonly buffer _30_29 +{ + _14 _m0; +} _29; + +layout(set = 0, binding = 2, std430) readonly buffer _33_32 +{ + _18 _m0; +} _32; + +layout(set = 0, binding = 3, std430) buffer _36_35 +{ + _14 _m0; +} _35; + +layout(set = 0, binding = 4, std430) buffer _39_38 +{ + _18 _m0; +} _38; + +int16_t _24 = 1s; +shared uint16_t _41; + +uint16_t _240(uint16_t _242, uint16_t _243) +{ + return _242 / ((_243 == 0us) ? 1us : _243); +} + +uint16_t _249(uint16_t _250, uint16_t _251) +{ + return _250 % ((_251 == 0us) ? 1us : _251); +} + +uint16_t _258(uint16_t _257) +{ + uint16_t _271 = 20us; + _271 += 5us; + _271 += uint16_t(_26._m0._m0); + _271 += uint16_t(_26._m0._m1); + _271 += u16vec3(_26._m0._m3).z; + _35._m0._m3 = _26._m0._m3 + _29._m0._m3; + _35._m0._m4 = _26._m0._m4 + _29._m0._m4; + _35._m0._m5 = _26._m0._m5 + _29._m0._m5; + _35._m0._m6 = _26._m0._m6 + _29._m0._m6; + _38._m0._m0 = _32._m0._m0; + uint16_t _332 = _271; + _271 = _332; + _271 = max(_271, _271); + _271 = min(_271, _271); + _271 = min(max(_271, _271), _271); + _271 -= 1us; + _271 *= 2us; + _271 = _240(_271, 3us); + _271 = _249(_271, 4us); + _271 &= 255us; + _271 |= 16us; + _271 ^= 1us; + _35._m0._m0 = uint(_271); + _35._m0._m1 = int(int16_t(_271)); + _35._m0._m2 = float(_271); + _271 = uint16_t(_35._m0._m0); + return _271; +} + +int16_t _43(int16_t _45, int16_t _46) +{ + return _45 / (((_46 == 0s) || ((_45 == (-32768s)) && (_46 == (-1s)))) ? 1s : _46); +} + +int16_t _59(int16_t _60, int16_t _61) +{ + return _60 - (((_61 == 0s) || ((_60 == (-32768s)) && (_61 == (-1s)))) ? 1s : _61) * (_60 / (((_61 == 0s) || ((_60 == (-32768s)) && (_61 == (-1s)))) ? 1s : _61)); +} + +int16_t _72(int16_t _71) +{ + int16_t _94 = 20s; + int16_t _96[4] = int16_t[](1s, 2s, 3s, 4s); + _94 += 5s; + _94 += int16_t(_26._m0._m0); + _94 += int16_t(_26._m0._m1); + _94 += i16vec3(_26._m0._m7).z; + _35._m0._m7 = _26._m0._m7 + _29._m0._m7; + _35._m0._m8 = _26._m0._m8 + _29._m0._m8; + _35._m0._m9 = _26._m0._m9 + _29._m0._m9; + _35._m0._m10 = _26._m0._m10 + _29._m0._m10; + _38._m0._m1 = _32._m0._m1; + _94 = abs(_94); + _94 = max(_94, _94); + _94 = min(_94, _94); + _94 = min(max(_94, _94), _94); + _94 = sign(_94); + _94 -= 1s; + _94 *= 2s; + _94 = _43(_94, 3s); + _94 = _59(_94, 4s); + _94 &= 255s; + _94 |= 16s; + _94 ^= 1s; + _94 = _94 << 2u; + _94 = _94 >> 1u; + _94 = -_94; + _94 = (_94 < 0s) ? 2s : 1s; + _96[0u] = _94; + _94 = _96[1u]; + _94 = _96[1u]; + _35._m0._m0 = uint(uint16_t(_94)); + _35._m0._m1 = int(_94); + _35._m0._m2 = float(_94); + _94 = int16_t(_35._m0._m0); + _94 = int16_t(uint16_t(_94)); + _35._m0._m8 = (_26._m0._m8 + _26._m0._m8) * i16vec2(2); + return _94; +} + +void main() +{ + int16_t _384 = 0s; + uint16_t _386 = 0us; + if (gl_LocalInvocationIndex == 0u) + { + _41 = 0us; + } + barrier(); + _41 = 0us; + uint16_t _397 = _258(67us); + int16_t _398 = _72(60s); + _35._m0._m11 = _397 + uint16_t(_398); + _384 = int16_t(gl_SubgroupInvocationID); + _384 = subgroupAdd(_384); + _384 = subgroupMul(_384); + _384 = subgroupMin(_384); + _384 = subgroupMax(_384); + _384 = subgroupExclusiveAdd(_384); + _384 = subgroupInclusiveAdd(_384); + _384 = subgroupBroadcastFirst(_384); + _384 = subgroupShuffle(_384, 4u); + _386 = uint16_t(gl_SubgroupInvocationID); + _386 = subgroupAdd(_386); + _386 = subgroupMin(_386); + _386 = subgroupMax(_386); + _35._m0._m7 = _384; + _35._m0._m3 = _386; +} + diff --git a/naga/tests/out/spv/wgsl-int64.spvasm.glsl b/naga/tests/out/spv/wgsl-int64.spvasm.glsl new file mode 100644 index 000000000..8dc81e086 --- /dev/null +++ b/naga/tests/out/spv/wgsl-int64.spvasm.glsl @@ -0,0 +1,123 @@ +#version 460 +#if defined(GL_ARB_gpu_shader_int64) +#extension GL_ARB_gpu_shader_int64 : require +#else +#error No extension available for 64-bit integers. +#endif +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _14 +{ + uint _m0; + int _m1; + float _m2; + uint64_t _m3; + u64vec2 _m4; + u64vec3 _m5; + u64vec4 _m6; + int64_t _m7; + i64vec2 _m8; + i64vec3 _m9; + i64vec4 _m10; + uint64_t _m11; +}; + +struct _18 +{ + uint64_t _m0[2]; + int64_t _m1[2]; +}; + +layout(set = 0, binding = 0, std140) uniform _24_23 +{ + _14 _m0; +} _23; + +layout(set = 0, binding = 1, std430) readonly buffer _27_26 +{ + _14 _m0; +} _26; + +layout(set = 0, binding = 2, std430) readonly buffer _30_29 +{ + _18 _m0; +} _29; + +layout(set = 0, binding = 3, std430) buffer _33_32 +{ + _14 _m0; +} _32; + +layout(set = 0, binding = 4, std430) buffer _36_35 +{ + _18 _m0; +} _35; + +int64_t _21 = 1l; + +uint64_t _222(uint64_t _221) +{ + uint64_t _232 = 20ul; + _232 += ((31ul + 18446744073709551615ul) - 18446744073709551615ul); + _232 += (_232 + 5ul); + _232 += uint64_t(_23._m0._m0 + uint(_232)); + _232 += uint64_t(uint(_23._m0._m1 + int(_232))); + _232 += uint64_t(clamp(_23._m0._m2 + float(_232), 0.0, 18446742974197923840.0)); + _232 += u64vec3(_23._m0._m3).z; + _232 += uint64_t(_23._m0._m7); + _232 += u64vec2(_23._m0._m8).y; + _232 += u64vec3(_23._m0._m9).z; + _232 += u64vec4(_23._m0._m10).w; + _32._m0._m3 = _23._m0._m3 + _26._m0._m3; + _32._m0._m4 = _23._m0._m4 + _26._m0._m4; + _32._m0._m5 = _23._m0._m5 + _26._m0._m5; + _32._m0._m6 = _23._m0._m6 + _26._m0._m6; + _35._m0._m0 = _29._m0._m0; + uint64_t _333 = _232; + _232 += _333; + _232 += min(max(_232, _232), _232); + u64vec2 _344 = u64vec2(_232); + u64vec2 _346 = u64vec2(_232); + _232 += ((0ul + (_344.x * _346.x)) + (_344.y * _346.y)); + _232 += max(_232, _232); + _232 += min(_232, _232); + return _232; +} + +int64_t _40(int64_t _39) +{ + int64_t _57 = 20l; + _57 += ((31l - 1002003004005006l) + (-9223372036854775807l)); + _57 += (_57 + 5l); + _57 += int64_t(int(_23._m0._m0 + uint(_57))); + _57 += int64_t(_23._m0._m1 + int(_57)); + _57 += int64_t(clamp(_23._m0._m2 + float(_57), -9223372036854775808.0, 9223371487098961920.0)); + _57 += i64vec3(_23._m0._m7).z; + _57 += int64_t(_23._m0._m3); + _57 += i64vec2(_23._m0._m4).y; + _57 += i64vec3(_23._m0._m5).z; + _57 += i64vec4(_23._m0._m6).w; + _57 += int64_t(0x8000000000000000ul); + _32._m0._m7 = _23._m0._m7 + _26._m0._m7; + _32._m0._m8 = _23._m0._m8 + _26._m0._m8; + _32._m0._m9 = _23._m0._m9 + _26._m0._m9; + _32._m0._m10 = _23._m0._m10 + _26._m0._m10; + _35._m0._m1 = _29._m0._m1; + _57 += abs(_57); + _57 += min(max(_57, _57), _57); + i64vec2 _192 = i64vec2(_57); + i64vec2 _194 = i64vec2(_57); + _57 += ((0l + (_192.x * _194.x)) + (_192.y * _194.y)); + _57 += max(_57, _57); + _57 += min(_57, _57); + _57 += sign(_57); + return _57; +} + +void main() +{ + uint64_t _379 = _222(67ul); + int64_t _380 = _40(60l); + _32._m0._m11 = _379 + uint64_t(_380); +} + diff --git a/naga/tests/out/spv/wgsl-interface.compute.spvasm.glsl b/naga/tests/out/spv/wgsl-interface.compute.spvasm.glsl new file mode 100644 index 000000000..8b93537da --- /dev/null +++ b/naga/tests/out/spv/wgsl-interface.compute.spvasm.glsl @@ -0,0 +1,38 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _5 +{ + vec4 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + uint _m1; + float _m2; +}; + +struct _12 +{ + uint _m0; +}; + +struct _13 +{ + uint _m0; +}; + +shared uint _14[1]; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _14 = uint[](0u); + } + barrier(); + _14[0u] = (((gl_GlobalInvocationID.x + gl_LocalInvocationID.x) + gl_LocalInvocationIndex) + gl_WorkGroupID.x) + gl_NumWorkGroups.x; +} + diff --git a/naga/tests/out/spv/wgsl-interface.fragment.spvasm.glsl b/naga/tests/out/spv/wgsl-interface.fragment.spvasm.glsl new file mode 100644 index 000000000..b98e0c40b --- /dev/null +++ b/naga/tests/out/spv/wgsl-interface.fragment.spvasm.glsl @@ -0,0 +1,41 @@ +#version 460 + +struct _5 +{ + vec4 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + uint _m1; + float _m2; +}; + +struct _12 +{ + uint _m0; +}; + +struct _13 +{ + uint _m0; +}; + +layout(location = 1) in float _19; +layout(location = 0) out float _34; + +void main() +{ + _7 _44 = _7(_5(gl_FragCoord, _19)._m1, uint(gl_SampleMaskIn) & (1u << uint(gl_SampleID)), float(gl_FrontFacing)); + gl_FragDepth = _44._m0; + gl_FragDepth = clamp(gl_FragDepth, 0.0, 1.0); + uint _48 = _44._m1; + for (int i = 0; i < int(_0); i++) + { + gl_SampleMask[i] = int(_48[i]); + } + _34 = _44._m2; +} + diff --git a/naga/tests/out/spv/wgsl-interface.vertex.spvasm.glsl b/naga/tests/out/spv/wgsl-interface.vertex.spvasm.glsl new file mode 100644 index 000000000..9906204e4 --- /dev/null +++ b/naga/tests/out/spv/wgsl-interface.vertex.spvasm.glsl @@ -0,0 +1,42 @@ +#version 460 + +invariant gl_Position; + +struct _5 +{ + vec4 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + uint _m1; + float _m2; +}; + +struct _12 +{ + uint _m0; +}; + +struct _13 +{ + uint _m0; +}; + +layout(location = 10) in uint _20; +layout(location = 1) out float _24; + +void main() +{ + gl_PointSize = 1.0; + uint _32 = uint(gl_VertexIndex) + uint(gl_InstanceIndex); + uint _33 = _32 + _20; + float _34 = float(_33); + _5 _35 = _5(vec4(1.0), _34); + vec4 _36 = _35._m0; + gl_Position = _36; + _24 = _35._m1; +} + diff --git a/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm.glsl b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm.glsl new file mode 100644 index 000000000..624ee07ba --- /dev/null +++ b/naga/tests/out/spv/wgsl-interface.vertex_two_structs.spvasm.glsl @@ -0,0 +1,42 @@ +#version 460 + +invariant gl_Position; + +struct _5 +{ + vec4 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + uint _m1; + float _m2; +}; + +struct _12 +{ + uint _m0; +}; + +struct _13 +{ + uint _m0; +}; + +void main() +{ + uint _31 = 2u; + _12 _15 = _12(uint(gl_VertexIndex)); + _13 _19 = _13(uint(gl_InstanceIndex)); + gl_PointSize = 1.0; + uint _34 = _15._m0; + float _35 = float(_34); + uint _36 = _19._m0; + float _37 = float(_36); + float _39 = float(_31); + vec4 _40 = vec4(_35, _37, _39, 0.0); + gl_Position = _40; +} + diff --git a/naga/tests/out/spv/wgsl-interpolate.spvasm.glsl b/naga/tests/out/spv/wgsl-interpolate.spvasm.glsl new file mode 100644 index 000000000..632b151e4 --- /dev/null +++ b/naga/tests/out/spv/wgsl-interpolate.spvasm.glsl @@ -0,0 +1,102 @@ +///////////////////////////////////// +// Entry point: "vert_main" (vert) // +///////////////////////////////////// +#version 460 + +struct FragmentInput +{ + vec4 position; + uint _flat; + uint flat_first; + uint flat_either; + float _linear; + vec2 linear_centroid; + vec3 linear_sample; + vec3 linear_center; + vec4 perspective; + float perspective_centroid; + float perspective_sample; + float perspective_center; +}; + +layout(location = 0) flat out uint _flat; +layout(location = 1) flat out uint flat_first; +layout(location = 2) flat out uint flat_either; +layout(location = 3) noperspective out float _linear; +layout(location = 4) noperspective centroid out vec2 linear_centroid; +layout(location = 6) noperspective sample out vec3 linear_sample; +layout(location = 7) noperspective out vec3 linear_center; +layout(location = 8) out vec4 perspective; +layout(location = 9) centroid out float perspective_centroid; +layout(location = 10) sample out float perspective_sample; +layout(location = 11) out float perspective_center; + +void main() +{ + FragmentInput _out = FragmentInput(vec4(0.0), 0u, 0u, 0u, 0.0, vec2(0.0), vec3(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0, 0.0); + gl_PointSize = 1.0; + _out.position = vec4(2.0, 4.0, 5.0, 6.0); + _out._flat = 8u; + _out.flat_first = 9u; + _out.flat_either = 10u; + _out._linear = 27.0; + _out.linear_centroid = vec2(64.0, 125.0); + _out.linear_sample = vec3(216.0, 343.0, 512.0); + _out.linear_center = vec3(255.0, 511.0, 1024.0); + _out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); + _out.perspective_centroid = 2197.0; + _out.perspective_sample = 2744.0; + _out.perspective_center = 2812.0; + gl_Position = _out.position; + gl_Position.y = -gl_Position.y; + _flat = _out._flat; + flat_first = _out.flat_first; + flat_either = _out.flat_either; + _linear = _out._linear; + linear_centroid = _out.linear_centroid; + linear_sample = _out.linear_sample; + linear_center = _out.linear_center; + perspective = _out.perspective; + perspective_centroid = _out.perspective_centroid; + perspective_sample = _out.perspective_sample; + perspective_center = _out.perspective_center; +} + + +///////////////////////////////////// +// Entry point: "frag_main" (frag) // +///////////////////////////////////// +#version 460 + +struct FragmentInput +{ + vec4 position; + uint _flat; + uint flat_first; + uint flat_either; + float _linear; + vec2 linear_centroid; + vec3 linear_sample; + vec3 linear_center; + vec4 perspective; + float perspective_centroid; + float perspective_sample; + float perspective_center; +}; + +layout(location = 0) flat in uint _flat; +layout(location = 1) flat in uint flat_first; +layout(location = 2) flat in uint flat_either; +layout(location = 3) noperspective in float _linear; +layout(location = 4) noperspective centroid in vec2 linear_centroid; +layout(location = 6) noperspective sample in vec3 linear_sample; +layout(location = 7) noperspective in vec3 linear_center; +layout(location = 8) in vec4 perspective; +layout(location = 9) centroid in float perspective_centroid; +layout(location = 10) sample in float perspective_sample; +layout(location = 11) in float perspective_center; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-interpolate_compat.spvasm.glsl b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm.glsl new file mode 100644 index 000000000..54139dcbc --- /dev/null +++ b/naga/tests/out/spv/wgsl-interpolate_compat.spvasm.glsl @@ -0,0 +1,96 @@ +///////////////////////////////////// +// Entry point: "vert_main" (vert) // +///////////////////////////////////// +#version 460 + +struct FragmentInput +{ + vec4 position; + uint _flat; + uint flat_either; + float _linear; + vec2 linear_centroid; + vec3 linear_sample; + vec3 linear_center; + vec4 perspective; + float perspective_centroid; + float perspective_sample; + float perspective_center; +}; + +layout(location = 0) flat out uint _flat; +layout(location = 2) flat out uint flat_either; +layout(location = 3) noperspective out float _linear; +layout(location = 4) noperspective centroid out vec2 linear_centroid; +layout(location = 6) noperspective sample out vec3 linear_sample; +layout(location = 7) noperspective out vec3 linear_center; +layout(location = 8) out vec4 perspective; +layout(location = 9) centroid out float perspective_centroid; +layout(location = 10) sample out float perspective_sample; +layout(location = 11) out float perspective_center; + +void main() +{ + FragmentInput _out = FragmentInput(vec4(0.0), 0u, 0u, 0.0, vec2(0.0), vec3(0.0), vec3(0.0), vec4(0.0), 0.0, 0.0, 0.0); + gl_PointSize = 1.0; + _out.position = vec4(2.0, 4.0, 5.0, 6.0); + _out._flat = 8u; + _out.flat_either = 10u; + _out._linear = 27.0; + _out.linear_centroid = vec2(64.0, 125.0); + _out.linear_sample = vec3(216.0, 343.0, 512.0); + _out.linear_center = vec3(255.0, 511.0, 1024.0); + _out.perspective = vec4(729.0, 1000.0, 1331.0, 1728.0); + _out.perspective_centroid = 2197.0; + _out.perspective_sample = 2744.0; + _out.perspective_center = 2812.0; + gl_Position = _out.position; + gl_Position.y = -gl_Position.y; + _flat = _out._flat; + flat_either = _out.flat_either; + _linear = _out._linear; + linear_centroid = _out.linear_centroid; + linear_sample = _out.linear_sample; + linear_center = _out.linear_center; + perspective = _out.perspective; + perspective_centroid = _out.perspective_centroid; + perspective_sample = _out.perspective_sample; + perspective_center = _out.perspective_center; +} + + +///////////////////////////////////// +// Entry point: "frag_main" (frag) // +///////////////////////////////////// +#version 460 + +struct FragmentInput +{ + vec4 position; + uint _flat; + uint flat_either; + float _linear; + vec2 linear_centroid; + vec3 linear_sample; + vec3 linear_center; + vec4 perspective; + float perspective_centroid; + float perspective_sample; + float perspective_center; +}; + +layout(location = 0) flat in uint _flat; +layout(location = 2) flat in uint flat_either; +layout(location = 3) noperspective in float _linear; +layout(location = 4) noperspective centroid in vec2 linear_centroid; +layout(location = 6) noperspective sample in vec3 linear_sample; +layout(location = 7) noperspective in vec3 linear_center; +layout(location = 8) in vec4 perspective; +layout(location = 9) centroid in float perspective_centroid; +layout(location = 10) sample in float perspective_sample; +layout(location = 11) in float perspective_center; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-mat2-uniform-alignment.spvasm.glsl b/naga/tests/out/spv/wgsl-mat2-uniform-alignment.spvasm.glsl new file mode 100644 index 000000000..770150775 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mat2-uniform-alignment.spvasm.glsl @@ -0,0 +1,30 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + int _m0; + mat2 _m1; +}; + +struct _8 +{ + int _m0; + vec2 _m1; + vec2 _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _10_9 +{ + _8 _m0; +} _9; + +_7 _12(_8 _14) +{ + return _7(_14._m0, mat2(_14._m1, _14._m2)); +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-mat_cx2.spvasm.glsl b/naga/tests/out/spv/wgsl-mat_cx2.spvasm.glsl new file mode 100644 index 000000000..1c99510c6 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mat_cx2.spvasm.glsl @@ -0,0 +1,196 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct StructWithMat +{ + mat2 m; +}; + +struct StructWithArrayOfStructOfMat +{ + StructWithMat a[4]; +}; + +struct std140_mat2x2_f32_ +{ + vec2 col0; + vec2 col1; +}; + +struct std140_StructWithMat +{ + vec2 m_col0; + vec2 m_col1; +}; + +struct std140_StructWithArrayOfStructOfMat +{ + std140_StructWithMat a[4]; +}; + +layout(set = 0, binding = 0, std430) buffer s_m +{ + mat2 _m0; +} s_m_1; + +layout(set = 0, binding = 1, std140) uniform u_m +{ + std140_mat2x2_f32_ _m0; +} u_m_1; + +layout(set = 1, binding = 0, std430) buffer s_sm +{ + StructWithMat _m0; +} s_sm_1; + +layout(set = 1, binding = 1, std140) uniform u_sm +{ + std140_StructWithMat _m0; +} u_sm_1; + +layout(set = 2, binding = 0, std430) buffer s_am +{ + mat2 _m0[4]; +} s_am_1; + +layout(set = 2, binding = 1, std140) uniform u_am +{ + std140_mat2x2_f32_ _m0[4]; +} u_am_1; + +layout(set = 3, binding = 0, std430) buffer s_sasm +{ + StructWithArrayOfStructOfMat _m0; +} s_sasm_1; + +layout(set = 3, binding = 1, std140) uniform u_sasm +{ + std140_StructWithArrayOfStructOfMat _m0; +} u_sasm_1; + +mat2 mat2x2_f32_from_std140(std140_mat2x2_f32_ _45) +{ + return mat2(_45.col0, _45.col1); +} + +vec2 mat2x2_f32_get_column(mat2 _51, uint _52) +{ + vec2 _61; + switch (_52) + { + case 0u: + { + _61 = _51[0]; + break; + } + case 1u: + { + _61 = _51[1]; + break; + } + default: + { + break; // unreachable workaround + } + } + return _61; +} + +void access_m() +{ + int idx = 1; + idx--; + s_m_1._m0 = mat2x2_f32_from_std140(u_m_1._m0); + s_m_1._m0[0u] = u_m_1._m0.col0; + s_m_1._m0[idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_m_1._m0), uint(idx)); + s_m_1._m0[0u].x = u_m_1._m0.col0.x; + s_m_1._m0[0u][idx] = u_m_1._m0.col0[idx]; + s_m_1._m0[idx].x = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_m_1._m0), uint(idx)).x; + s_m_1._m0[idx][idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_m_1._m0), uint(idx))[idx]; +} + +StructWithMat StructWithMat_from_std140(std140_StructWithMat _139) +{ + return StructWithMat(mat2(_139.m_col0, _139.m_col1)); +} + +void access_sm() +{ + int idx = 1; + idx--; + s_sm_1._m0 = StructWithMat_from_std140(u_sm_1._m0); + s_sm_1._m0.m = mat2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1); + s_sm_1._m0.m[0u] = u_sm_1._m0.m_col0; + s_sm_1._m0.m[idx] = mat2x2_f32_get_column(mat2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1), uint(idx)); + s_sm_1._m0.m[0u].x = u_sm_1._m0.m_col0.x; + s_sm_1._m0.m[0u][idx] = u_sm_1._m0.m_col0[idx]; + s_sm_1._m0.m[idx].x = mat2x2_f32_get_column(mat2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1), uint(idx)).x; + s_sm_1._m0.m[idx][idx] = mat2x2_f32_get_column(mat2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1), uint(idx))[idx]; +} + +mat2[4] array_mat2x2_f32_4_from_std140(std140_mat2x2_f32_ _232[4]) +{ + return mat2[](mat2x2_f32_from_std140(_232[0]), mat2x2_f32_from_std140(_232[1]), mat2x2_f32_from_std140(_232[2]), mat2x2_f32_from_std140(_232[3])); +} + +void access_am() +{ + int idx = 1; + idx--; + s_am_1._m0 = array_mat2x2_f32_4_from_std140(u_am_1._m0); + s_am_1._m0[0u] = mat2x2_f32_from_std140(u_am_1._m0[0u]); + s_am_1._m0[idx] = mat2x2_f32_from_std140(u_am_1._m0[idx]); + s_am_1._m0[0u][0u] = u_am_1._m0[0u].col0; + s_am_1._m0[0u][idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[0u]), uint(idx)); + s_am_1._m0[idx][0u] = u_am_1._m0[idx].col0; + s_am_1._m0[idx][idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[idx]), uint(idx)); + s_am_1._m0[0u][0u].x = u_am_1._m0[0u].col0.x; + s_am_1._m0[0u][0u][idx] = u_am_1._m0[0u].col0[idx]; + s_am_1._m0[0u][idx].x = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[0u]), uint(idx)).x; + s_am_1._m0[0u][idx][idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[0u]), uint(idx))[idx]; + s_am_1._m0[idx][0u].x = u_am_1._m0[idx].col0.x; + s_am_1._m0[idx][0u][idx] = u_am_1._m0[idx].col0[idx]; + s_am_1._m0[idx][idx].x = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[idx]), uint(idx)).x; + s_am_1._m0[idx][idx][idx] = mat2x2_f32_get_column(mat2x2_f32_from_std140(u_am_1._m0[idx]), uint(idx))[idx]; +} + +StructWithMat[4] array_StructWithMat_4_from_std140(std140_StructWithMat _409[4]) +{ + return StructWithMat[](StructWithMat_from_std140(_409[0]), StructWithMat_from_std140(_409[1]), StructWithMat_from_std140(_409[2]), StructWithMat_from_std140(_409[3])); +} + +StructWithArrayOfStructOfMat StructWithArrayOfStructOfMat_from_std140(std140_StructWithArrayOfStructOfMat _404) +{ + return StructWithArrayOfStructOfMat(array_StructWithMat_4_from_std140(_404.a)); +} + +void access_sasm() +{ + int idx = 1; + idx--; + s_sasm_1._m0 = StructWithArrayOfStructOfMat_from_std140(u_sasm_1._m0); + s_sasm_1._m0.a = array_StructWithMat_4_from_std140(u_sasm_1._m0.a); + s_sasm_1._m0.a[0u].m = mat2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1); + s_sasm_1._m0.a[idx].m = mat2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1); + s_sasm_1._m0.a[0u].m[0u] = u_sasm_1._m0.a[0u].m_col0; + s_sasm_1._m0.a[0u].m[idx] = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1), uint(idx)); + s_sasm_1._m0.a[idx].m[0u] = u_sasm_1._m0.a[idx].m_col0; + s_sasm_1._m0.a[idx].m[idx] = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1), uint(idx)); + s_sasm_1._m0.a[0u].m[0u].x = u_sasm_1._m0.a[0u].m_col0.x; + s_sasm_1._m0.a[0u].m[0u][idx] = u_sasm_1._m0.a[0u].m_col0[idx]; + s_sasm_1._m0.a[0u].m[idx].x = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1), uint(idx)).x; + s_sasm_1._m0.a[0u].m[idx][idx] = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1), uint(idx))[idx]; + s_sasm_1._m0.a[idx].m[0u].x = u_sasm_1._m0.a[idx].m_col0.x; + s_sasm_1._m0.a[idx].m[0u][idx] = u_sasm_1._m0.a[idx].m_col0[idx]; + s_sasm_1._m0.a[idx].m[idx].x = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1), uint(idx)).x; + s_sasm_1._m0.a[idx].m[idx][idx] = mat2x2_f32_get_column(mat2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1), uint(idx))[idx]; +} + +void main() +{ + access_m(); + access_sm(); + access_am(); + access_sasm(); +} + diff --git a/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm.glsl b/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm.glsl new file mode 100644 index 000000000..cc2d0df0c --- /dev/null +++ b/naga/tests/out/spv/wgsl-mat_cx2_f16.spvasm.glsl @@ -0,0 +1,218 @@ +#version 460 +#if defined(GL_AMD_gpu_shader_half_float) +#extension GL_AMD_gpu_shader_half_float : require +#elif defined(GL_EXT_shader_explicit_arithmetic_types_float16) +#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require +#else +#error No extension available for FP16. +#endif +#extension GL_EXT_shader_16bit_storage : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct StructWithMat +{ + f16mat4x2 m; +}; + +struct StructWithArrayOfStructOfMat +{ + StructWithMat a[4]; +}; + +struct std140_mat4x2_f16_ +{ + f16vec2 col0; + f16vec2 col1; + f16vec2 col2; + f16vec2 col3; +}; + +struct std140_StructWithMat +{ + f16vec2 m_col0; + f16vec2 m_col1; + f16vec2 m_col2; + f16vec2 m_col3; +}; + +struct std140_StructWithArrayOfStructOfMat +{ + std140_StructWithMat a[4]; +}; + +layout(set = 0, binding = 0, std430) buffer s_m +{ + f16mat4x2 _m0; +} s_m_1; + +layout(set = 0, binding = 1, std140) uniform u_m +{ + std140_mat4x2_f16_ _m0; +} u_m_1; + +layout(set = 1, binding = 0, std430) buffer s_sm +{ + StructWithMat _m0; +} s_sm_1; + +layout(set = 1, binding = 1, std140) uniform u_sm +{ + std140_StructWithMat _m0; +} u_sm_1; + +layout(set = 2, binding = 0, std430) buffer s_am +{ + f16mat4x2 _m0[4]; +} s_am_1; + +layout(set = 2, binding = 1, std140) uniform u_am +{ + std140_mat4x2_f16_ _m0[4]; +} u_am_1; + +layout(set = 3, binding = 0, std430) buffer s_sasm +{ + StructWithArrayOfStructOfMat _m0; +} s_sasm_1; + +layout(set = 3, binding = 1, std140) uniform u_sasm +{ + std140_StructWithArrayOfStructOfMat _m0; +} u_sasm_1; + +f16mat4x2 mat4x2_f16_from_std140(std140_mat4x2_f16_ _45) +{ + return f16mat4x2(_45.col0, _45.col1, _45.col2, _45.col3); +} + +f16vec2 mat4x2_f16_get_column(f16mat4x2 _53, uint _54) +{ + f16vec2 _67; + switch (_54) + { + case 0u: + { + _67 = _53[0]; + break; + } + case 1u: + { + _67 = _53[1]; + break; + } + case 2u: + { + _67 = _53[2]; + break; + } + case 3u: + { + _67 = _53[3]; + break; + } + default: + { + break; // unreachable workaround + } + } + return _67; +} + +void access_m() +{ + int idx = 1; + idx--; + s_m_1._m0 = mat4x2_f16_from_std140(u_m_1._m0); + s_m_1._m0[0u] = u_m_1._m0.col0; + s_m_1._m0[idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_m_1._m0), uint(idx)); + s_m_1._m0[0u].x = u_m_1._m0.col0.x; + s_m_1._m0[0u][idx] = u_m_1._m0.col0[idx]; + s_m_1._m0[idx].x = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_m_1._m0), uint(idx)).x; + s_m_1._m0[idx][idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_m_1._m0), uint(idx))[idx]; +} + +StructWithMat StructWithMat_from_std140(std140_StructWithMat _145) +{ + return StructWithMat(f16mat4x2(_145.m_col0, _145.m_col1, _145.m_col2, _145.m_col3)); +} + +void access_sm() +{ + int idx = 1; + idx--; + s_sm_1._m0 = StructWithMat_from_std140(u_sm_1._m0); + s_sm_1._m0.m = f16mat4x2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1, u_sm_1._m0.m_col2, u_sm_1._m0.m_col3); + s_sm_1._m0.m[0u] = u_sm_1._m0.m_col0; + s_sm_1._m0.m[idx] = mat4x2_f16_get_column(f16mat4x2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1, u_sm_1._m0.m_col2, u_sm_1._m0.m_col3), uint(idx)); + s_sm_1._m0.m[0u].x = u_sm_1._m0.m_col0.x; + s_sm_1._m0.m[0u][idx] = u_sm_1._m0.m_col0[idx]; + s_sm_1._m0.m[idx].x = mat4x2_f16_get_column(f16mat4x2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1, u_sm_1._m0.m_col2, u_sm_1._m0.m_col3), uint(idx)).x; + s_sm_1._m0.m[idx][idx] = mat4x2_f16_get_column(f16mat4x2(u_sm_1._m0.m_col0, u_sm_1._m0.m_col1, u_sm_1._m0.m_col2, u_sm_1._m0.m_col3), uint(idx))[idx]; +} + +f16mat4x2[4] array_mat4x2_f16_4_from_std140(std140_mat4x2_f16_ _258[4]) +{ + return f16mat4x2[](mat4x2_f16_from_std140(_258[0]), mat4x2_f16_from_std140(_258[1]), mat4x2_f16_from_std140(_258[2]), mat4x2_f16_from_std140(_258[3])); +} + +void access_am() +{ + int idx = 1; + idx--; + s_am_1._m0 = array_mat4x2_f16_4_from_std140(u_am_1._m0); + s_am_1._m0[0u] = mat4x2_f16_from_std140(u_am_1._m0[0u]); + s_am_1._m0[idx] = mat4x2_f16_from_std140(u_am_1._m0[idx]); + s_am_1._m0[0u][0u] = u_am_1._m0[0u].col0; + s_am_1._m0[0u][idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[0u]), uint(idx)); + s_am_1._m0[idx][0u] = u_am_1._m0[idx].col0; + s_am_1._m0[idx][idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[idx]), uint(idx)); + s_am_1._m0[0u][0u].x = u_am_1._m0[0u].col0.x; + s_am_1._m0[0u][0u][idx] = u_am_1._m0[0u].col0[idx]; + s_am_1._m0[0u][idx].x = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[0u]), uint(idx)).x; + s_am_1._m0[0u][idx][idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[0u]), uint(idx))[idx]; + s_am_1._m0[idx][0u].x = u_am_1._m0[idx].col0.x; + s_am_1._m0[idx][0u][idx] = u_am_1._m0[idx].col0[idx]; + s_am_1._m0[idx][idx].x = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[idx]), uint(idx)).x; + s_am_1._m0[idx][idx][idx] = mat4x2_f16_get_column(mat4x2_f16_from_std140(u_am_1._m0[idx]), uint(idx))[idx]; +} + +StructWithMat[4] array_StructWithMat_4_from_std140(std140_StructWithMat _435[4]) +{ + return StructWithMat[](StructWithMat_from_std140(_435[0]), StructWithMat_from_std140(_435[1]), StructWithMat_from_std140(_435[2]), StructWithMat_from_std140(_435[3])); +} + +StructWithArrayOfStructOfMat StructWithArrayOfStructOfMat_from_std140(std140_StructWithArrayOfStructOfMat _430) +{ + return StructWithArrayOfStructOfMat(array_StructWithMat_4_from_std140(_430.a)); +} + +void access_sasm() +{ + int idx = 1; + idx--; + s_sasm_1._m0 = StructWithArrayOfStructOfMat_from_std140(u_sasm_1._m0); + s_sasm_1._m0.a = array_StructWithMat_4_from_std140(u_sasm_1._m0.a); + s_sasm_1._m0.a[0u].m = f16mat4x2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1, u_sasm_1._m0.a[0u].m_col2, u_sasm_1._m0.a[0u].m_col3); + s_sasm_1._m0.a[idx].m = f16mat4x2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1, u_sasm_1._m0.a[idx].m_col2, u_sasm_1._m0.a[idx].m_col3); + s_sasm_1._m0.a[0u].m[0u] = u_sasm_1._m0.a[0u].m_col0; + s_sasm_1._m0.a[0u].m[idx] = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1, u_sasm_1._m0.a[0u].m_col2, u_sasm_1._m0.a[0u].m_col3), uint(idx)); + s_sasm_1._m0.a[idx].m[0u] = u_sasm_1._m0.a[idx].m_col0; + s_sasm_1._m0.a[idx].m[idx] = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1, u_sasm_1._m0.a[idx].m_col2, u_sasm_1._m0.a[idx].m_col3), uint(idx)); + s_sasm_1._m0.a[0u].m[0u].x = u_sasm_1._m0.a[0u].m_col0.x; + s_sasm_1._m0.a[0u].m[0u][idx] = u_sasm_1._m0.a[0u].m_col0[idx]; + s_sasm_1._m0.a[0u].m[idx].x = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1, u_sasm_1._m0.a[0u].m_col2, u_sasm_1._m0.a[0u].m_col3), uint(idx)).x; + s_sasm_1._m0.a[0u].m[idx][idx] = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[0u].m_col0, u_sasm_1._m0.a[0u].m_col1, u_sasm_1._m0.a[0u].m_col2, u_sasm_1._m0.a[0u].m_col3), uint(idx))[idx]; + s_sasm_1._m0.a[idx].m[0u].x = u_sasm_1._m0.a[idx].m_col0.x; + s_sasm_1._m0.a[idx].m[0u][idx] = u_sasm_1._m0.a[idx].m_col0[idx]; + s_sasm_1._m0.a[idx].m[idx].x = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1, u_sasm_1._m0.a[idx].m_col2, u_sasm_1._m0.a[idx].m_col3), uint(idx)).x; + s_sasm_1._m0.a[idx].m[idx][idx] = mat4x2_f16_get_column(f16mat4x2(u_sasm_1._m0.a[idx].m_col0, u_sasm_1._m0.a[idx].m_col1, u_sasm_1._m0.a[idx].m_col2, u_sasm_1._m0.a[idx].m_col3), uint(idx))[idx]; +} + +void main() +{ + access_m(); + access_sm(); + access_am(); + access_sasm(); +} + diff --git a/naga/tests/out/spv/wgsl-mat_cx3.spvasm.glsl b/naga/tests/out/spv/wgsl-mat_cx3.spvasm.glsl new file mode 100644 index 000000000..b6a2e0ec0 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mat_cx3.spvasm.glsl @@ -0,0 +1,131 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + mat3 _m0; +}; + +struct _12 +{ + _7 _m0[4]; +}; + +layout(set = 0, binding = 0, std430) buffer _14_13 +{ + mat3 _m0; +} _13; + +layout(set = 0, binding = 1, std140) uniform _17_16 +{ + mat3 _m0; +} _16; + +layout(set = 1, binding = 0, std430) buffer _20_19 +{ + _7 _m0; +} _19; + +layout(set = 1, binding = 1, std140) uniform _23_22 +{ + _7 _m0; +} _22; + +layout(set = 2, binding = 0, std430) buffer _26_25 +{ + mat3 _m0[4]; +} _25; + +layout(set = 2, binding = 1, std140) uniform _29_28 +{ + mat3 _m0[4]; +} _28; + +layout(set = 3, binding = 0, std430) buffer _32_31 +{ + _12 _m0; +} _31; + +layout(set = 3, binding = 1, std140) uniform _35_34 +{ + _12 _m0; +} _34; + +void _38() +{ + int _46 = 1; + _46--; + _13._m0 = _16._m0; + _13._m0[0u] = _16._m0[0u]; + _13._m0[_46] = _16._m0[_46]; + _13._m0[0u].x = _16._m0[0u].x; + _13._m0[0u][_46] = _16._m0[0u][_46]; + _13._m0[_46].x = _16._m0[_46].x; + _13._m0[_46][_46] = _16._m0[_46][_46]; +} + +void _103() +{ + int _108 = 1; + _108--; + _19._m0 = _22._m0; + _19._m0._m0 = _22._m0._m0; + _19._m0._m0[0u] = _22._m0._m0[0u]; + _19._m0._m0[_108] = _22._m0._m0[_108]; + _19._m0._m0[0u].x = _22._m0._m0[0u].x; + _19._m0._m0[0u][_108] = _22._m0._m0[0u][_108]; + _19._m0._m0[_108].x = _22._m0._m0[_108].x; + _19._m0._m0[_108][_108] = _22._m0._m0[_108][_108]; +} + +void _165() +{ + int _170 = 1; + _170--; + _25._m0 = _28._m0; + _25._m0[0u] = _28._m0[0u]; + _25._m0[_170] = _28._m0[_170]; + _25._m0[0u][0u] = _28._m0[0u][0u]; + _25._m0[0u][_170] = _28._m0[0u][_170]; + _25._m0[_170][0u] = _28._m0[_170][0u]; + _25._m0[_170][_170] = _28._m0[_170][_170]; + _25._m0[0u][0u].x = _28._m0[0u][0u].x; + _25._m0[0u][0u][_170] = _28._m0[0u][0u][_170]; + _25._m0[0u][_170].x = _28._m0[0u][_170].x; + _25._m0[0u][_170][_170] = _28._m0[0u][_170][_170]; + _25._m0[_170][0u].x = _28._m0[_170][0u].x; + _25._m0[_170][0u][_170] = _28._m0[_170][0u][_170]; + _25._m0[_170][_170].x = _28._m0[_170][_170].x; + _25._m0[_170][_170][_170] = _28._m0[_170][_170][_170]; +} + +void _298() +{ + int _303 = 1; + _303--; + _31._m0 = _34._m0; + _31._m0._m0 = _34._m0._m0; + _31._m0._m0[0u]._m0 = _34._m0._m0[0u]._m0; + _31._m0._m0[_303]._m0 = _34._m0._m0[_303]._m0; + _31._m0._m0[0u]._m0[0u] = _34._m0._m0[0u]._m0[0u]; + _31._m0._m0[0u]._m0[_303] = _34._m0._m0[0u]._m0[_303]; + _31._m0._m0[_303]._m0[0u] = _34._m0._m0[_303]._m0[0u]; + _31._m0._m0[_303]._m0[_303] = _34._m0._m0[_303]._m0[_303]; + _31._m0._m0[0u]._m0[0u].x = _34._m0._m0[0u]._m0[0u].x; + _31._m0._m0[0u]._m0[0u][_303] = _34._m0._m0[0u]._m0[0u][_303]; + _31._m0._m0[0u]._m0[_303].x = _34._m0._m0[0u]._m0[_303].x; + _31._m0._m0[0u]._m0[_303][_303] = _34._m0._m0[0u]._m0[_303][_303]; + _31._m0._m0[_303]._m0[0u].x = _34._m0._m0[_303]._m0[0u].x; + _31._m0._m0[_303]._m0[0u][_303] = _34._m0._m0[_303]._m0[0u][_303]; + _31._m0._m0[_303]._m0[_303].x = _34._m0._m0[_303]._m0[_303].x; + _31._m0._m0[_303]._m0[_303][_303] = _34._m0._m0[_303]._m0[_303][_303]; +} + +void main() +{ + _38(); + _103(); + _165(); + _298(); +} + diff --git a/naga/tests/out/spv/wgsl-math-functions.spvasm.glsl b/naga/tests/out/spv/wgsl-math-functions.spvasm.glsl new file mode 100644 index 000000000..e28372c67 --- /dev/null +++ b/naga/tests/out/spv/wgsl-math-functions.spvasm.glsl @@ -0,0 +1,64 @@ +#version 460 + +struct _11 +{ + float _m0; + float _m1; +}; + +struct _12 +{ + vec2 _m0; + vec2 _m1; +}; + +struct _13 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _14 +{ + float _m0; + int _m1; +}; + +struct _15 +{ + vec4 _m0; + ivec4 _m1; +}; + +void main() +{ + float _53 = degrees(1.0); + float _54 = radians(1.0); + vec4 _55 = degrees(vec4(0.0)); + vec4 _56 = radians(vec4(0.0)); + vec4 _57 = clamp(vec4(0.0), vec4(0.0), vec4(1.0)); + vec4 _59 = refract(vec4(0.0), vec4(0.0), 1.0); + float _60 = ldexp(1.0, 2); + vec2 _61 = ldexp(vec2(1.0, 2.0), ivec2(3, 4)); + _11 _62; + _62._m0 = modf(1.5, _62._m1); + _11 _63; + _63._m0 = modf(1.5, _63._m1); + _11 _65; + _65._m0 = modf(1.5, _65._m1); + _12 _67; + _67._m0 = modf(vec2(1.5), _67._m1); + _13 _68; + _68._m0 = modf(vec4(1.5), _68._m1); + _12 _71; + _71._m0 = modf(vec2(1.5), _71._m1); + _14 _74; + _74._m0 = frexp(1.5, _74._m1); + _14 _75; + _75._m0 = frexp(1.5, _75._m1); + _14 _77; + _77._m0 = frexp(1.5, _77._m1); + _15 _79; + _79._m0 = frexp(vec4(1.5), _79._m1); +} + diff --git a/naga/tests/out/spv/wgsl-memory-decorations-coherent.spvasm.glsl b/naga/tests/out/spv/wgsl-memory-decorations-coherent.spvasm.glsl new file mode 100644 index 000000000..b051f860e --- /dev/null +++ b/naga/tests/out/spv/wgsl-memory-decorations-coherent.spvasm.glsl @@ -0,0 +1,18 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) coherent buffer _5_6 +{ + uint _m0[]; +} _6; + +layout(set = 0, binding = 1, std430) buffer _5_8 +{ + uint _m0[]; +} _8; + +void main() +{ + _6._m0[0u] = _8._m0[0u]; +} + diff --git a/naga/tests/out/spv/wgsl-memory-decorations.spvasm.glsl b/naga/tests/out/spv/wgsl-memory-decorations.spvasm.glsl new file mode 100644 index 000000000..5bdeadcfb --- /dev/null +++ b/naga/tests/out/spv/wgsl-memory-decorations.spvasm.glsl @@ -0,0 +1,29 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) coherent buffer _5_6 +{ + uint _m0[]; +} _6; + +layout(set = 0, binding = 1, std430) buffer _5_8 +{ + uint _m0[]; +} _8; + +layout(set = 0, binding = 2, std430) coherent buffer _5_9 +{ + uint _m0[]; +} _9; + +layout(set = 0, binding = 3, std430) buffer _5_10 +{ + uint _m0[]; +} _10; + +void main() +{ + _6._m0[0u] = _8._m0[0u]; + _9._m0[0u] = _10._m0[0u]; +} + diff --git a/naga/tests/out/spv/wgsl-mesh-shader-empty.spvasm.glsl b/naga/tests/out/spv/wgsl-mesh-shader-empty.spvasm.glsl new file mode 100644 index 000000000..fd1f7f559 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mesh-shader-empty.spvasm.glsl @@ -0,0 +1,127 @@ +/////////////////////////////////// +// Entry point: "ts_main" (task) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _9 +{ + uvec3 _m0; +}; + +struct _14 +{ + _7 _m0[3]; + _9 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _42 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _15; + +uvec3 _20() +{ + if (gl_LocalInvocationIndex == 0u) + { + _15 = _4(0u); + } + barrier(); + return uvec3(1u); +} + +void main() +{ + uvec3 _39 = _20(); + barrier(); + _42 _49; + umulExtended(_39.x, _39.y, _49._m1, _49._m0); + _42 _51; + umulExtended(_49._m0, _39.z, _51._m1, _51._m0); + uvec3 _64 = ((((((_51._m0 > 1024u) || (_39.x > 256u)) || (_39.y > 256u)) || (_39.z > 256u)) || (_49._m1 != 0u)) || (_51._m1 != 0u)) ? uvec3(0u) : _39; + EmitMeshTasksEXT(_64.x, _64.y, _64.z); +} + + +/////////////////////////////////// +// Entry point: "ms_main" (mesh) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 3, max_primitives = 1, triangles) out; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _9 +{ + uvec3 _m0; +}; + +struct _14 +{ + _7 _m0[3]; + _9 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _42 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _15; +shared _14 _17; + +void _78() +{ + if (gl_LocalInvocationIndex == 0u) + { + _17 = _14(_7[](_7(vec4(0.0)), _7(vec4(0.0)), _7(vec4(0.0))), _9[](_9(uvec3(0u))), 0u, 0u); + } + barrier(); +} + +void main() +{ + _78(); + barrier(); + uint _97 = min(_17._m2, 3u); + uint _100 = min(_17._m3, 1u); + SetMeshOutputsEXT(_97, _100); + for (uint _89 = gl_LocalInvocationIndex; _89 < _97; _89 += 64u) + { + gl_MeshVerticesEXT[_89].gl_Position = _17._m0[_89]._m0; + } + for (uint _90 = gl_LocalInvocationIndex; _90 < _100; _90 += 64u) + { + gl_PrimitiveTriangleIndicesEXT[_90] = _17._m1[_90]._m0; + } +} + diff --git a/naga/tests/out/spv/wgsl-mesh-shader-lines.spvasm.glsl b/naga/tests/out/spv/wgsl-mesh-shader-lines.spvasm.glsl new file mode 100644 index 000000000..5ca04e344 --- /dev/null +++ b/naga/tests/out/spv/wgsl-mesh-shader-lines.spvasm.glsl @@ -0,0 +1,127 @@ +/////////////////////////////////// +// Entry point: "ts_main" (task) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _9 +{ + uvec2 _m0; +}; + +struct _15 +{ + _7 _m0[2]; + _9 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _42 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _16; + +uvec3 _21() +{ + if (gl_LocalInvocationIndex == 0u) + { + _16 = _4(0u); + } + barrier(); + return uvec3(1u); +} + +void main() +{ + uvec3 _39 = _21(); + barrier(); + _42 _49; + umulExtended(_39.x, _39.y, _49._m1, _49._m0); + _42 _51; + umulExtended(_49._m0, _39.z, _51._m1, _51._m0); + uvec3 _64 = ((((((_51._m0 > 1024u) || (_39.x > 256u)) || (_39.y > 256u)) || (_39.z > 256u)) || (_49._m1 != 0u)) || (_51._m1 != 0u)) ? uvec3(0u) : _39; + EmitMeshTasksEXT(_64.x, _64.y, _64.z); +} + + +/////////////////////////////////// +// Entry point: "ms_main" (mesh) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 2, max_primitives = 1, lines) out; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _9 +{ + uvec2 _m0; +}; + +struct _15 +{ + _7 _m0[2]; + _9 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _42 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _16; +shared _15 _18; + +void _78() +{ + if (gl_LocalInvocationIndex == 0u) + { + _18 = _15(_7[](_7(vec4(0.0)), _7(vec4(0.0))), _9[](_9(uvec2(0u))), 0u, 0u); + } + barrier(); +} + +void main() +{ + _78(); + barrier(); + uint _97 = min(_18._m2, 2u); + uint _101 = min(_18._m3, 1u); + SetMeshOutputsEXT(_97, _101); + for (uint _89 = gl_LocalInvocationIndex; _89 < _97; _89 += 64u) + { + gl_MeshVerticesEXT[_89].gl_Position = _18._m0[_89]._m0; + } + for (uint _90 = gl_LocalInvocationIndex; _90 < _101; _90 += 64u) + { + gl_PrimitiveLineIndicesEXT[_90] = _18._m1[_90]._m0; + } +} + diff --git a/naga/tests/out/spv/wgsl-mesh-shader-points.spvasm.glsl b/naga/tests/out/spv/wgsl-mesh-shader-points.spvasm.glsl new file mode 100644 index 000000000..144f214ba --- /dev/null +++ b/naga/tests/out/spv/wgsl-mesh-shader-points.spvasm.glsl @@ -0,0 +1,127 @@ +/////////////////////////////////// +// Entry point: "ts_main" (task) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _8 +{ + uint _m0; +}; + +struct _13 +{ + _7 _m0[1]; + _8 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _41 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _14; + +uvec3 _19() +{ + if (gl_LocalInvocationIndex == 0u) + { + _14 = _4(0u); + } + barrier(); + return uvec3(1u); +} + +void main() +{ + uvec3 _38 = _19(); + barrier(); + _41 _48; + umulExtended(_38.x, _38.y, _48._m1, _48._m0); + _41 _50; + umulExtended(_48._m0, _38.z, _50._m1, _50._m0); + uvec3 _63 = ((((((_50._m0 > 1024u) || (_38.x > 256u)) || (_38.y > 256u)) || (_38.z > 256u)) || (_48._m1 != 0u)) || (_50._m1 != 0u)) ? uvec3(0u) : _38; + EmitMeshTasksEXT(_63.x, _63.y, _63.z); +} + + +/////////////////////////////////// +// Entry point: "ms_main" (mesh) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 1, max_primitives = 1, points) out; + +struct _4 +{ + uint _m0; +}; + +struct _7 +{ + vec4 _m0; +}; + +struct _8 +{ + uint _m0; +}; + +struct _13 +{ + _7 _m0[1]; + _8 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _41 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _4 _14; +shared _13 _16; + +void _77() +{ + if (gl_LocalInvocationIndex == 0u) + { + _16 = _13(_7[](_7(vec4(0.0))), _8[](_8(0u)), 0u, 0u); + } + barrier(); +} + +void main() +{ + _77(); + barrier(); + uint _96 = min(_16._m2, 1u); + uint _100 = min(_16._m3, 1u); + SetMeshOutputsEXT(_96, _100); + for (uint _88 = gl_LocalInvocationIndex; _88 < _96; _88 += 64u) + { + gl_MeshVerticesEXT[_88].gl_Position = _16._m0[_88]._m0; + } + for (uint _89 = gl_LocalInvocationIndex; _89 < _100; _89 += 64u) + { + gl_PrimitivePointIndicesEXT[_89] = _16._m1[_89]._m0; + } +} + diff --git a/naga/tests/out/spv/wgsl-mesh-shader.spvasm.glsl b/naga/tests/out/spv/wgsl-mesh-shader.spvasm.glsl new file mode 100644 index 000000000..ca21a2c1f --- /dev/null +++ b/naga/tests/out/spv/wgsl-mesh-shader.spvasm.glsl @@ -0,0 +1,511 @@ +/////////////////////////////////// +// Entry point: "ts_main" (task) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _6 _17; +shared float _19; + +void _32(bool _31) +{ + _17._m1 = _31; +} + +bool _24() +{ + return _17._m1; +} + +uvec3 _37() +{ + if (gl_LocalInvocationIndex == 0u) + { + _17 = _6(vec4(0.0), false); + _19 = 0.0; + } + barrier(); + _19 = 1.0; + _17._m0 = vec4(1.0, 1.0, 0.0, 1.0); + _32(true); + _17._m1 = _24(); + return uvec3(1u); +} + +void main() +{ + uvec3 _65 = _37(); + barrier(); + _68 _75; + umulExtended(_65.x, _65.y, _75._m1, _75._m0); + _68 _77; + umulExtended(_75._m0, _65.z, _77._m1, _77._m0); + uvec3 _90 = ((((((_77._m0 > 1024u) || (_65.x > 256u)) || (_65.y > 256u)) || (_65.z > 256u)) || (_75._m1 != 0u)) || (_77._m1 != 0u)) ? uvec3(0u) : _65; + EmitMeshTasksEXT(_90.x, _90.y, _90.z); +} + + +//////////////////////////////////////// +// Entry point: "ts_divergent" (task) // +//////////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +taskPayloadSharedEXT _6 _17; + +uvec3 _98() +{ + if (gl_LocalInvocationIndex == 0u) + { + _17 = _6(vec4(0.0), false); + } + barrier(); + if (gl_LocalInvocationID.x == 0u) + { + _17._m0 = vec4(1.0, 1.0, 0.0, 1.0); + _17._m1 = true; + return uvec3(1u); + } + return uvec3(2u); +} + +void main() +{ + uvec3 _115 = _98(); + barrier(); + _68 _122; + umulExtended(_115.x, _115.y, _122._m1, _122._m0); + _68 _124; + umulExtended(_122._m0, _115.z, _124._m1, _124._m0); + uvec3 _137 = ((((((_124._m0 > 1024u) || (_115.x > 256u)) || (_115.y > 256u)) || (_115.z > 256u)) || (_122._m1 != 0u)) || (_124._m1 != 0u)) ? uvec3(0u) : _115; + EmitMeshTasksEXT(_137.x, _137.y, _137.z); +} + + +/////////////////////////////////// +// Entry point: "ms_main" (mesh) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 3, max_primitives = 1, triangles) out; + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +layout(location = 0) out vec4 _153[3]; +layout(location = 1) perprimitiveEXT out vec4 _159[1]; +taskPayloadSharedEXT _6 _17; +shared float _19; +shared _16 _21; + +bool _24() +{ + return _17._m1; +} + +void _160() +{ + if (gl_LocalInvocationIndex == 0u) + { + _19 = 0.0; + _21 = _16(_7[](_7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0))), _10[](_10(uvec3(0u), false, vec4(0.0))), 0u, 0u); + } + barrier(); + _21._m2 = 3u; + _21._m3 = 1u; + _19 = 2.0; + _21._m0[0u]._m0 = vec4(0.0, 1.0, 0.0, 1.0); + _21._m0[0u]._m1 = vec4(0.0, 1.0, 0.0, 1.0) * _17._m0; + _21._m0[1u]._m0 = vec4(-1.0, -1.0, 0.0, 1.0); + _21._m0[1u]._m1 = vec4(0.0, 0.0, 1.0, 1.0) * _17._m0; + _21._m0[2u]._m0 = vec4(1.0, -1.0, 0.0, 1.0); + _21._m0[2u]._m1 = vec4(1.0, 0.0, 0.0, 1.0) * _17._m0; + _21._m1[0u]._m0 = uvec3(0u, 1u, 2u); + _21._m1[0u]._m1 = !_24(); + _21._m1[0u]._m2 = vec4(1.0, 0.0, 1.0, 1.0); +} + +void main() +{ + _160(); + barrier(); + uint _217 = min(_21._m2, 3u); + uint _220 = min(_21._m3, 1u); + SetMeshOutputsEXT(_217, _220); + for (uint _210 = gl_LocalInvocationIndex; _210 < _217; _210++) + { + gl_MeshVerticesEXT[_210].gl_Position = _21._m0[_210]._m0; + _153[_210] = _21._m0[_210]._m1; + } + for (uint _211 = gl_LocalInvocationIndex; _211 < _220; _211++) + { + gl_PrimitiveTriangleIndicesEXT[_211] = _21._m1[_211]._m0; + gl_MeshPrimitivesEXT[_211].gl_CullPrimitiveEXT = _21._m1[_211]._m1; + _159[_211] = _21._m1[_211]._m2; + } +} + + +//////////////////////////////////// +// Entry point: "ms_no_ts" (mesh) // +//////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 3, max_primitives = 1, triangles) out; + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +layout(location = 0) out vec4 _273[3]; +layout(location = 1) perprimitiveEXT out vec4 _279[1]; +shared float _19; +shared _16 _21; + +void _280() +{ + if (gl_LocalInvocationIndex == 0u) + { + _19 = 0.0; + _21 = _16(_7[](_7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0))), _10[](_10(uvec3(0u), false, vec4(0.0))), 0u, 0u); + } + barrier(); + _21._m2 = 3u; + _21._m3 = 1u; + _19 = 2.0; + _21._m0[0u]._m0 = vec4(0.0, 1.0, 0.0, 1.0); + _21._m0[0u]._m1 = vec4(0.0, 1.0, 0.0, 1.0); + _21._m0[1u]._m0 = vec4(-1.0, -1.0, 0.0, 1.0); + _21._m0[1u]._m1 = vec4(0.0, 0.0, 1.0, 1.0); + _21._m0[2u]._m0 = vec4(1.0, -1.0, 0.0, 1.0); + _21._m0[2u]._m1 = vec4(1.0, 0.0, 0.0, 1.0); + _21._m1[0u]._m0 = uvec3(0u, 1u, 2u); + _21._m1[0u]._m1 = false; + _21._m1[0u]._m2 = vec4(1.0, 0.0, 1.0, 1.0); +} + +void main() +{ + _280(); + barrier(); + uint _308 = min(_21._m2, 3u); + uint _311 = min(_21._m3, 1u); + SetMeshOutputsEXT(_308, _311); + for (uint _302 = gl_LocalInvocationIndex; _302 < _308; _302++) + { + gl_MeshVerticesEXT[_302].gl_Position = _21._m0[_302]._m0; + _273[_302] = _21._m0[_302]._m1; + } + for (uint _303 = gl_LocalInvocationIndex; _303 < _311; _303++) + { + gl_PrimitiveTriangleIndicesEXT[_303] = _21._m1[_303]._m0; + gl_MeshPrimitivesEXT[_303].gl_CullPrimitiveEXT = _21._m1[_303]._m1; + _279[_303] = _21._m1[_303]._m2; + } +} + + +//////////////////////////////////////// +// Entry point: "ms_divergent" (mesh) // +//////////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require +layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in; +layout(max_vertices = 3, max_primitives = 1, triangles) out; + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +layout(location = 0) out vec4 _363[3]; +layout(location = 1) perprimitiveEXT out vec4 _369[1]; +shared float _19; +shared _16 _21; + +void _370() +{ + if (gl_LocalInvocationIndex == 0u) + { + _19 = 0.0; + _21 = _16(_7[](_7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0)), _7(vec4(0.0), vec4(0.0))), _10[](_10(uvec3(0u), false, vec4(0.0))), 0u, 0u); + } + barrier(); + if (gl_LocalInvocationID.x == 0u) + { + _21._m2 = 3u; + _21._m3 = 1u; + _19 = 2.0; + _21._m0[0u]._m0 = vec4(0.0, 1.0, 0.0, 1.0); + _21._m0[0u]._m1 = vec4(0.0, 1.0, 0.0, 1.0); + _21._m0[1u]._m0 = vec4(-1.0, -1.0, 0.0, 1.0); + _21._m0[1u]._m1 = vec4(0.0, 0.0, 1.0, 1.0); + _21._m0[2u]._m0 = vec4(1.0, -1.0, 0.0, 1.0); + _21._m0[2u]._m1 = vec4(1.0, 0.0, 0.0, 1.0); + _21._m1[0u]._m0 = uvec3(0u, 1u, 2u); + _21._m1[0u]._m1 = false; + _21._m1[0u]._m2 = vec4(1.0, 0.0, 1.0, 1.0); + return; + } + else + { + return; + } +} + +void main() +{ + _370(); + barrier(); + uint _402 = min(_21._m2, 3u); + uint _405 = min(_21._m3, 1u); + SetMeshOutputsEXT(_402, _405); + for (uint _396 = gl_LocalInvocationIndex; _396 < _402; _396 += 2u) + { + gl_MeshVerticesEXT[_396].gl_Position = _21._m0[_396]._m0; + _363[_396] = _21._m0[_396]._m1; + } + for (uint _397 = gl_LocalInvocationIndex; _397 < _405; _397 += 2u) + { + gl_PrimitiveTriangleIndicesEXT[_397] = _21._m1[_397]._m0; + gl_MeshPrimitivesEXT[_397].gl_CullPrimitiveEXT = _21._m1[_397]._m1; + _369[_397] = _21._m1[_397]._m2; + } +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 +#extension GL_EXT_mesh_shader : require + +struct _6 +{ + vec4 _m0; + bool _m1; +}; + +struct _7 +{ + vec4 _m0; + vec4 _m1; +}; + +struct _10 +{ + uvec3 _m0; + bool _m1; + vec4 _m2; +}; + +struct _11 +{ + vec4 _m0; +}; + +struct _16 +{ + _7 _m0[3]; + _10 _m1[1]; + uint _m2; + uint _m3; +}; + +struct _68 +{ + uint _m0; + uint _m1; +}; + +layout(location = 0) in vec4 _448; +layout(location = 1) perprimitiveEXT in vec4 _451; +layout(location = 0) out vec4 _453; + +void main() +{ + _453 = _7(gl_FragCoord, _448)._m1 * _11(_451)._m0; +} + diff --git a/naga/tests/out/spv/wgsl-multiview.spvasm.glsl b/naga/tests/out/spv/wgsl-multiview.spvasm.glsl new file mode 100644 index 000000000..6d7449e95 --- /dev/null +++ b/naga/tests/out/spv/wgsl-multiview.spvasm.glsl @@ -0,0 +1,7 @@ +#version 460 +#extension GL_EXT_multiview : require + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-operators.spvasm.glsl b/naga/tests/out/spv/wgsl-operators.spvasm.glsl new file mode 100644 index 000000000..e4335007c --- /dev/null +++ b/naga/tests/out/spv/wgsl-operators.spvasm.glsl @@ -0,0 +1,295 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +vec4 _26() +{ + vec4 _36 = mix(vec4(0.0), vec4(1.0), vec4(0.5)); + return ((((vec4(ivec4(int(true)) + ivec4(0)) + vec4(bvec4(true))) + _36) + mix(vec4(0.0), vec4(1.0), vec4(0.100000001490116119384765625))) + vec4(intBitsToFloat(1))) + intBitsToFloat(ivec4(1)); +} + +ivec4 _50(ivec4 _52, ivec4 _53) +{ + bvec4 _56 = equal(_53, ivec4(0)); + bvec4 _61 = equal(_52, ivec4(int(0x80000000))); + bvec4 _62 = equal(_53, ivec4(-1)); + bvec4 _63 = bvec4(_61.x && _62.x, _61.y && _62.y, _61.z && _62.z, _61.w && _62.w); + return _52 - mix(_53, ivec4(1), bvec4(_56.x || _63.x, _56.y || _63.y, _56.z || _63.z, _56.w || _63.w)) * (_52 / mix(_53, ivec4(1), bvec4(_56.x || _63.x, _56.y || _63.y, _56.z || _63.z, _56.w || _63.w))); +} + +vec4 _71(float _69, int _70) +{ + return (((vec2(2.0) + vec2(_69)) - vec2(4.0)) / vec2(8.0)).xyxy + vec4(_50(ivec4(_70), ivec4(2))); +} + +vec2 _92() +{ + vec2 _97 = vec2(2.0); + _97 += vec2(1.0); + _97 -= vec2(3.0); + _97 /= vec2(4.0); + return _97; +} + +vec3 _109(vec3 _108) +{ + return vec3(notEqual(_108, vec3(0.0))); +} + +bool _118() +{ + return true; +} + +bool _122() +{ + return false; +} + +bool _125() +{ + return true; +} + +bool _128() +{ + return false; +} + +void _131() +{ + bool _148 = false; + bool _142 = false; + bool _152 = false; + bool _146 = false; + bool _139 = false; + bool _150 = false; + bool _144 = false; + if (!true) + { + _139 = false; + } + else + { + _139 = true; + } + if (true) + { + _142 = false; + } + else + { + _142 = false; + } + if (!false) + { + _144 = false; + } + else + { + _144 = true; + } + if (!_118()) + { + _146 = _122(); + } + else + { + _146 = true; + } + if (_146) + { + if (!_125()) + { + _150 = _128(); + } + else + { + _150 = true; + } + _148 = _150; + } + else + { + _148 = false; + } + if (false) + { + _152 = _122(); + } + else + { + _152 = true; + } +} + +int _199(int _201, int _202) +{ + return _201 / (((_202 == 0) || ((_201 == int(0x80000000)) && (_202 == (-1)))) ? 1 : _202); +} + +uint _211(uint _213, uint _214) +{ + return _213 / ((_214 == 0u) ? 1u : _214); +} + +ivec2 _222(ivec2 _224, ivec2 _225) +{ + bvec2 _228 = equal(_225, ivec2(0)); + bvec2 _231 = equal(_224, ivec2(int(0x80000000))); + bvec2 _232 = equal(_225, ivec2(-1)); + bvec2 _233 = bvec2(_231.x && _232.x, _231.y && _232.y); + return _224 / mix(_225, ivec2(1), bvec2(_228.x || _233.x, _228.y || _233.y)); +} + +uvec3 _238(uvec3 _240, uvec3 _241) +{ + return _240 / mix(_241, uvec3(1u), equal(_241, uvec3(0u))); +} + +int _248(int _249, int _250) +{ + return _249 - (((_250 == 0) || ((_249 == int(0x80000000)) && (_250 == (-1)))) ? 1 : _250) * (_249 / (((_250 == 0) || ((_249 == int(0x80000000)) && (_250 == (-1)))) ? 1 : _250)); +} + +uint _259(uint _260, uint _261) +{ + return _260 % ((_261 == 0u) ? 1u : _261); +} + +ivec2 _266(ivec2 _267, ivec2 _268) +{ + bvec2 _270 = equal(_268, ivec2(0)); + bvec2 _271 = equal(_267, ivec2(int(0x80000000))); + bvec2 _272 = equal(_268, ivec2(-1)); + bvec2 _273 = bvec2(_271.x && _272.x, _271.y && _272.y); + return _267 - mix(_268, ivec2(1), bvec2(_270.x || _273.x, _270.y || _273.y)) * (_267 / mix(_268, ivec2(1), bvec2(_270.x || _273.x, _270.y || _273.y))); +} + +uvec3 _277(uvec3 _278, uvec3 _279) +{ + return _278 % mix(_279, uvec3(1u), equal(_279, uvec3(0u))); +} + +uvec2 _285(uvec2 _287, uvec2 _288) +{ + return _287 / mix(_288, uvec2(1u), equal(_288, uvec2(0u))); +} + +uvec2 _295(uvec2 _296, uvec2 _297) +{ + return _296 % mix(_297, uvec2(1u), equal(_297, uvec2(0u))); +} + +void _303() +{ + int _315 = 0; + int _318 = 0; + float _321 = -1.0; + ivec2 _322 = -ivec2(1); + vec2 _323 = -vec2(1.0); + int _324 = 2 + 1; + uint _325 = 2u + 1u; + float _326 = 2.0 + 1.0; + ivec2 _327 = ivec2(2) + ivec2(1); + uvec3 _328 = uvec3(2u) + uvec3(1u); + vec4 _329 = vec4(2.0) + vec4(1.0); + int _330 = 2 - 1; + uint _331 = 2u - 1u; + float _332 = 2.0 - 1.0; + ivec2 _333 = ivec2(2) - ivec2(1); + uvec3 _334 = uvec3(2u) - uvec3(1u); + vec4 _335 = vec4(2.0) - vec4(1.0); + int _336 = 2 * 1; + uint _337 = 2u * 1u; + float _338 = 2.0 * 1.0; + ivec2 _339 = ivec2(2) * ivec2(1); + uvec3 _340 = uvec3(2u) * uvec3(1u); + vec4 _341 = vec4(2.0) * vec4(1.0); + float _344 = 2.0 / 1.0; + vec4 _347 = vec4(2.0) / vec4(1.0); + float _350 = 2.0 - 1.0 * trunc(2.0 / 1.0); + vec4 _353 = vec4(2.0) - vec4(1.0) * trunc(vec4(2.0) / vec4(1.0)); + ivec2 _356 = ivec2(2) + ivec2(1); + ivec2 _357 = ivec2(2) + ivec2(1); + uvec2 _358 = uvec2(2u) + uvec2(1u); + uvec2 _359 = uvec2(2u) + uvec2(1u); + vec2 _360 = vec2(2.0) + vec2(1.0); + vec2 _361 = vec2(2.0) + vec2(1.0); + ivec2 _362 = ivec2(2) - ivec2(1); + ivec2 _363 = ivec2(2) - ivec2(1); + uvec2 _364 = uvec2(2u) - uvec2(1u); + uvec2 _365 = uvec2(2u) - uvec2(1u); + vec2 _366 = vec2(2.0) - vec2(1.0); + vec2 _367 = vec2(2.0) - vec2(1.0); + vec2 _376 = vec2(2.0) * 1.0; + vec2 _377 = vec2(1.0) * 2.0; + vec2 _382 = vec2(2.0) / vec2(1.0); + vec2 _383 = vec2(2.0) / vec2(1.0); + vec2 _388 = vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0)); + vec2 _389 = vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0)); + mat3 _390 = mat3(vec3(0.0), vec3(0.0), vec3(0.0)) * 1.0; + mat3 _391 = mat3(vec3(0.0), vec3(0.0), vec3(0.0)) * 2.0; + vec3 _392 = mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)) * vec4(1.0); + vec4 _393 = vec3(2.0) * mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)); + _318 = _315 + int(0x80000000); +} + +void _397() +{ +} + +void _424() +{ +} + +void _463() +{ + int _465 = 0; + ivec3 _467 = ivec3(0); + _465 = 1; + _465++; + _465--; + _465 *= _465; + _465 = _199(_465, _465); + _465 = _248(_465, 1); + _465 &= 0; + _465 |= 0; + _465 ^= 0; + _465 = _465 << int(2u); + _465 = _465 >> int(1u); + _465++; + _465--; + _467.y++; + _467.y--; +} + +void _505() +{ + int _507 = -1; + int _508 = -1; + int _510 = -1; + int _512 = -1; + int _514 = -1; + int _517 = -1; + int _521 = -1; + int _526 = -1; + float _531 = -1.0; + float _532 = -1.0; + float _534 = -1.0; + float _536 = -1.0; + float _538 = -1.0; + float _541 = -1.0; + float _545 = -1.0; + float _550 = -1.0; +} + +void main() +{ + _131(); + _303(); + _397(); + _424(); + _463(); + _505(); +} + diff --git a/naga/tests/out/spv/wgsl-overrides-atomicCompareExchangeWeak.f.spvasm.glsl b/naga/tests/out/spv/wgsl-overrides-atomicCompareExchangeWeak.f.spvasm.glsl new file mode 100644 index 000000000..3b9968e93 --- /dev/null +++ b/naga/tests/out/spv/wgsl-overrides-atomicCompareExchangeWeak.f.spvasm.glsl @@ -0,0 +1,21 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _6 +{ + uint _m0; + bool _m1; +}; + +shared uint _8; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _8 = 0u; + } + barrier(); + uint _27 = atomicCompSwap(_8, 2u, 1u); +} + diff --git a/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm.glsl b/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm.glsl new file mode 100644 index 000000000..ed750a55f --- /dev/null +++ b/naga/tests/out/spv/wgsl-overrides-ray-query.main.spvasm.glsl @@ -0,0 +1,71 @@ +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _8 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _10; + +void _37(rayQueryEXT _38, accelerationStructureEXT _39, _8 _40, inout uint _41, out float _42) +{ + bool _68 = (_40._m0 & 256u) != 0u; + bool _76 = (_40._m0 & 16u) != 0u; + bool _79 = (_40._m0 & 32u) != 0u; + bool _88 = (_40._m0 & 1u) != 0u; + bool _91 = (_40._m0 & 2u) != 0u; + bool _94 = (_40._m0 & 64u) != 0u; + bool _97 = (_40._m0 & 128u) != 0u; + _42 = _40._m3; + if (((((((!((((((_91 && _88) || (_97 && _88)) || (_97 && _91)) || (_97 && _94)) || (_94 && _88)) || (_94 && _91))) && (_40._m2 <= _40._m3)) && (_40._m2 >= 0.0)) && (!(any(isnan(_40._m4)) || any(isinf(_40._m4))))) && (!(any(isnan(_40._m5)) || any(isinf(_40._m5))))) && (!(((_40._m0 & 512u) != 0u) && _68))) && (!(((_76 && _68) || (_79 && _68)) || (_79 && _76)))) + { + rayQueryInitializeEXT(_38, _39, _40._m0, _40._m1, _40._m4, _40._m2, _40._m5, _40._m3); + _41 = 1u; + } + else + { + } +} + +bool _144(rayQueryEXT _145, inout uint _146) +{ + bool _148 = false; + if ((_146 & 1u) != 0u) + { + bool _155 = rayQueryProceedEXT(_145); + _148 = _155; + _146 |= (_155 ? 2u : 6u); + } + return _148; +} + +void main() +{ + uint _30 = 0u; + float _33 = 0.0; + uvec2 _130 = uvec2(4294967295u); + rayQueryEXT _27; + _37(_27, _10, _8(4u, 255u, 34.0, 38.0, vec3(46.0), vec3(58.0, 62.0, 74.0)), _30, _33); + for (;;) + { + if (all(equal(uvec2(0u), _130))) + { + break; + } + _130 -= uvec2(uint(_130.y == 0u), 1u); + bool _141 = _144(_27, _30); + if (!_141) + { + break; + } + continue; + } +} + diff --git a/naga/tests/out/spv/wgsl-overrides.main.spvasm.glsl b/naga/tests/out/spv/wgsl-overrides.main.spvasm.glsl new file mode 100644 index 000000000..4d06e2ebd --- /dev/null +++ b/naga/tests/out/spv/wgsl-overrides.main.spvasm.glsl @@ -0,0 +1,16 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +float _17 = 11.0; +float _19 = 0.0; + +void main() +{ + float _25 = 23.0; + bool _27 = false; + float _30 = 0.0; + _27 = true; + _30 = _17 * 10.0; + _19 = 1.10000002384185791015625; +} + diff --git a/naga/tests/out/spv/wgsl-padding.spvasm.glsl b/naga/tests/out/spv/wgsl-padding.spvasm.glsl new file mode 100644 index 000000000..196def880 --- /dev/null +++ b/naga/tests/out/spv/wgsl-padding.spvasm.glsl @@ -0,0 +1,45 @@ +#version 460 + +struct S +{ + vec3 a; +}; + +struct Test +{ + S a; + float b; +}; + +struct Test2 +{ + vec3 a[2]; + float b; +}; + +struct Test3 +{ + mat4x3 a; + float b; +}; + +layout(set = 0, binding = 0, std140) uniform input1 +{ + Test _m0; +} input1_1; + +layout(set = 0, binding = 1, std140) uniform input2 +{ + Test2 _m0; +} input2_1; + +layout(set = 0, binding = 2, std140) uniform input3 +{ + Test3 _m0; +} input3_1; + +void main() +{ + gl_Position = ((vec4(1.0) * input1_1._m0.b) * input2_1._m0.b) * input3_1._m0.b; +} + diff --git a/naga/tests/out/spv/wgsl-per-vertex.spvasm.glsl b/naga/tests/out/spv/wgsl-per-vertex.spvasm.glsl new file mode 100644 index 000000000..0d96d512f --- /dev/null +++ b/naga/tests/out/spv/wgsl-per-vertex.spvasm.glsl @@ -0,0 +1,11 @@ +#version 460 +#extension GL_EXT_fragment_shader_barycentric : require + +layout(location = 0) pervertexEXT in float _9[3]; +layout(location = 0) out vec4 _12; + +void main() +{ + _12 = vec4(_9[0], _9[1], _9[2], 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-phony_assignment.spvasm.glsl b/naga/tests/out/spv/wgsl-phony_assignment.spvasm.glsl new file mode 100644 index 000000000..4f4628aec --- /dev/null +++ b/naga/tests/out/spv/wgsl-phony_assignment.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std140) uniform _8_7 +{ + float _m0; +} _7; + +int _11() +{ + return 5; +} + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-pointers.spvasm.glsl b/naga/tests/out/spv/wgsl-pointers.spvasm.glsl new file mode 100644 index 000000000..0eb45bf3c --- /dev/null +++ b/naga/tests/out/spv/wgsl-pointers.spvasm.glsl @@ -0,0 +1,31 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, std430) buffer DynamicArray +{ + uint arr[]; +} dynamic_array; + +void f() +{ + mat2 v = mat2(vec2(0.0), vec2(0.0)); + v[0u] = vec2(10.0); +} + +void index_unsized(int i, uint v) +{ + dynamic_array.arr[i] += v; +} + +void index_dynamic_array(int i, uint v) +{ + dynamic_array.arr[i] += v; +} + +void main() +{ + f(); + index_unsized(1, 1u); + index_dynamic_array(1, 1u); +} + diff --git a/naga/tests/out/spv/wgsl-policy-mix.spvasm.glsl b/naga/tests/out/spv/wgsl-policy-mix.spvasm.glsl new file mode 100644 index 000000000..4033276d5 --- /dev/null +++ b/naga/tests/out/spv/wgsl-policy-mix.spvasm.glsl @@ -0,0 +1,62 @@ +#version 460 +#extension GL_EXT_samplerless_texture_functions : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct InStorage +{ + vec4 a[10]; +}; + +struct InUniform +{ + vec4 a[20]; +}; + +const float _34[40] = float[](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); +const vec4 _52[2] = vec4[](vec4(0.7070000171661376953125, 0.0, 0.0, 1.0), vec4(0.0, 0.7070000171661376953125, 0.0, 1.0)); + +layout(set = 0, binding = 0, std430) readonly buffer in_storage +{ + InStorage _m0; +} in_storage_1; + +layout(set = 0, binding = 1, std140) uniform in_uniform +{ + InUniform _m0; +} in_uniform_1; + +layout(set = 0, binding = 2) uniform texture2DArray image_2d_array; + +shared float in_workgroup[30]; + +vec4 mock_function(ivec2 c, int i, int l) +{ + ivec3 _66 = ivec3(c, i); + vec4 _79; + if (uint(l) < uint(textureQueryLevels(image_2d_array))) + { + if (all(lessThan(uvec3(_66), uvec3(textureSize(image_2d_array, l))))) + { + _79 = texelFetch(image_2d_array, _66, l); + } + else + { + _79 = vec4(0.0); + } + } + else + { + _79 = vec4(0.0); + } + return ((((in_storage_1._m0.a[i] + in_uniform_1._m0.a[i]) + _79) + vec4(in_workgroup[min(uint(i), 29u)])) + vec4(_34[min(uint(i), 39u)])) + _52[min(uint(i), 1u)]; +} + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + in_workgroup = float[](0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0); + } + barrier(); +} + diff --git a/naga/tests/out/spv/wgsl-primitive-index.spvasm.glsl b/naga/tests/out/spv/wgsl-primitive-index.spvasm.glsl new file mode 100644 index 000000000..9d586b9cd --- /dev/null +++ b/naga/tests/out/spv/wgsl-primitive-index.spvasm.glsl @@ -0,0 +1,9 @@ +#version 460 + +layout(location = 0) out vec4 _10; + +void main() +{ + _10 = vec4(float(uint(gl_PrimitiveID)), 1.0, 1.0, 1.0); +} + diff --git a/naga/tests/out/spv/wgsl-quad.spvasm.glsl b/naga/tests/out/spv/wgsl-quad.spvasm.glsl new file mode 100644 index 000000000..31c770ee3 --- /dev/null +++ b/naga/tests/out/spv/wgsl-quad.spvasm.glsl @@ -0,0 +1,76 @@ +///////////////////////////////////// +// Entry point: "vert_main" (vert) // +///////////////////////////////////// +#version 460 + +struct VertexOutput +{ + vec2 uv; + vec4 position; +}; + +layout(set = 0, binding = 0) uniform texture2D u_texture; +layout(set = 0, binding = 1) uniform sampler u_sampler; + +layout(location = 0) in vec2 pos; +layout(location = 1) in vec2 uv; +layout(location = 0) out vec2 uv_1; + +void main() +{ + VertexOutput _32 = VertexOutput(uv, vec4(pos * 1.2000000476837158203125, 0.0, 1.0)); + uv_1 = _32.uv; + gl_Position = _32.position; + gl_Position.y = -gl_Position.y; +} + + +///////////////////////////////////// +// Entry point: "frag_main" (frag) // +///////////////////////////////////// +#version 460 + +struct VertexOutput +{ + vec2 uv; + vec4 position; +}; + +layout(set = 0, binding = 0) uniform texture2D u_texture; +layout(set = 0, binding = 1) uniform sampler u_sampler; + +layout(location = 0) in vec2 uv; +layout(location = 0) out vec4 _44; + +void main() +{ + vec4 _51 = texture(sampler2D(u_texture, u_sampler), uv); + if (_51.w == 0.0) + { + discard; + } + _44 = _51 * _51.w; +} + + +//////////////////////////////////// +// Entry point: "fs_extra" (frag) // +//////////////////////////////////// +#version 460 + +struct VertexOutput +{ + vec2 uv; + vec4 position; +}; + +layout(set = 0, binding = 0) uniform texture2D u_texture; +layout(set = 0, binding = 1) uniform sampler u_sampler; + +layout(location = 0) out vec4 _60; + +void main() +{ + _60 = vec4(0.0, 0.5, 0.0, 0.5); +} + diff --git a/naga/tests/out/spv/wgsl-ray-query-no-init-tracking.spvasm.glsl b/naga/tests/out/spv/wgsl-ray-query-no-init-tracking.spvasm.glsl new file mode 100644 index 000000000..fcc6f8726 --- /dev/null +++ b/naga/tests/out/spv/wgsl-ray-query-no-init-tracking.spvasm.glsl @@ -0,0 +1,322 @@ +//////////////////////////////// +// Entry point: "main" (comp) // +//////////////////////////////// +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + uint _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + uint _m6; + vec2 _m7; + bool _m8; + mat4x3 _m9; + mat4x3 _m10; +}; + +struct _12 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +struct _13 +{ + uint _m0; + vec3 _m1; +}; + +layout(set = 0, binding = 1, std430) buffer _18_17 +{ + _13 _m0; +} _17; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _15; + +void _42(rayQueryEXT _43, accelerationStructureEXT _44, _12 _45, inout uint _46, out float _47) +{ + bool _72 = (_45._m0 & 256u) != 0u; + bool _80 = (_45._m0 & 16u) != 0u; + bool _83 = (_45._m0 & 32u) != 0u; + bool _92 = (_45._m0 & 1u) != 0u; + bool _95 = (_45._m0 & 2u) != 0u; + bool _98 = (_45._m0 & 64u) != 0u; + bool _101 = (_45._m0 & 128u) != 0u; + _47 = _45._m3; + if (((((((!((((((_95 && _92) || (_101 && _92)) || (_101 && _95)) || (_101 && _98)) || (_98 && _92)) || (_98 && _95))) && (_45._m2 <= _45._m3)) && (_45._m2 >= 0.0)) && (!(any(isnan(_45._m4)) || any(isinf(_45._m4))))) && (!(any(isnan(_45._m5)) || any(isinf(_45._m5))))) && (!(((_45._m0 & 512u) != 0u) && _72))) && (!(((_80 && _72) || (_83 && _72)) || (_83 && _80)))) + { + rayQueryInitializeEXT(_43, _44, _45._m0, _45._m1, _45._m4, _45._m2, _45._m5, _45._m3); + _46 = 1u; + } + else + { + } +} + +bool _148(rayQueryEXT _149, inout uint _150) +{ + bool _152 = false; + if ((_150 & 1u) != 0u) + { + bool _159 = rayQueryProceedEXT(_149); + _152 = _159; + _150 |= (_159 ? 2u : 6u); + } + return _152; +} + +_10 _172(rayQueryEXT _173, uint _174) +{ + _10 _177 = _10(0u, 0.0, 0u, 0u, 0u, 0u, 0u, vec2(0.0), false, mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)), mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0))); + if (((_174 & 4u) != 0u) && ((_174 & 2u) != 0u)) + { + uint _186 = rayQueryGetIntersectionTypeEXT(_173, bool(1u)); + _177._m0 = _186; + bool _188 = _186 != 0u; + if (_188) + { + uint _191 = rayQueryGetIntersectionInstanceCustomIndexEXT(_173, bool(1u)); + uint _192 = rayQueryGetIntersectionInstanceIdEXT(_173, bool(1u)); + uint _193 = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(_173, bool(1u)); + uint _194 = rayQueryGetIntersectionGeometryIndexEXT(_173, bool(1u)); + uint _195 = rayQueryGetIntersectionPrimitiveIndexEXT(_173, bool(1u)); + mat4x3 _196 = rayQueryGetIntersectionObjectToWorldEXT(_173, bool(1u)); + mat4x3 _197 = rayQueryGetIntersectionWorldToObjectEXT(_173, bool(1u)); + _177._m2 = _191; + _177._m3 = _192; + _177._m4 = _193; + _177._m5 = _194; + _177._m6 = _195; + _177._m9 = _196; + _177._m10 = _197; + float _212 = rayQueryGetIntersectionTEXT(_173, bool(1u)); + _177._m1 = _212; + if (_188) + { + vec2 _214 = rayQueryGetIntersectionBarycentricsEXT(_173, bool(1u)); + bool _215 = rayQueryGetIntersectionFrontFaceEXT(_173, bool(1u)); + _177._m7 = _214; + _177._m8 = _215; + } + } + } + return _177; +} + +_10 _25(vec3 _21, vec3 _22, accelerationStructureEXT _23) +{ + uint _34 = 0u; + float _37 = 0.0; + uvec2 _134 = uvec2(4294967295u); + rayQueryEXT _31; + _42(_31, _23, _12(4u, 255u, 0.100000001490116119384765625, 100.0, _21, _22), _34, _37); + for (;;) + { + if (all(equal(uvec2(0u), _134))) + { + break; + } + _134 -= uvec2(uint(_134.y == 0u), 1u); + bool _145 = _148(_31, _34); + if (!_145) + { + break; + } + continue; + } + return _172(_31, _34); +} + +vec3 _225(vec3 _223, _10 _224) +{ + return normalize(_223 - (_224._m9 * vec4(normalize((_224._m10 * vec4(_223, 1.0)).xy) * 2.400000095367431640625, 0.0, 1.0))); +} + +void main() +{ + _10 _250 = _25(vec3(0.0), vec3(0.0, 1.0, 0.0), _15); + _17._m0._m0 = uint(_250._m0 == 0u); + _17._m0._m1 = _225(vec3(0.0, 1.0, 0.0) * _250._m1, _250); +} + + +////////////////////////////////////////// +// Entry point: "main_candidate" (comp) // +////////////////////////////////////////// +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + uint _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + uint _m6; + vec2 _m7; + bool _m8; + mat4x3 _m9; + mat4x3 _m10; +}; + +struct _12 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +struct _13 +{ + uint _m0; + vec3 _m1; +}; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _15; + +void _42(rayQueryEXT _43, accelerationStructureEXT _44, _12 _45, inout uint _46, out float _47) +{ + bool _72 = (_45._m0 & 256u) != 0u; + bool _80 = (_45._m0 & 16u) != 0u; + bool _83 = (_45._m0 & 32u) != 0u; + bool _92 = (_45._m0 & 1u) != 0u; + bool _95 = (_45._m0 & 2u) != 0u; + bool _98 = (_45._m0 & 64u) != 0u; + bool _101 = (_45._m0 & 128u) != 0u; + _47 = _45._m3; + if (((((((!((((((_95 && _92) || (_101 && _92)) || (_101 && _95)) || (_101 && _98)) || (_98 && _92)) || (_98 && _95))) && (_45._m2 <= _45._m3)) && (_45._m2 >= 0.0)) && (!(any(isnan(_45._m4)) || any(isinf(_45._m4))))) && (!(any(isnan(_45._m5)) || any(isinf(_45._m5))))) && (!(((_45._m0 & 512u) != 0u) && _72))) && (!(((_80 && _72) || (_83 && _72)) || (_83 && _80)))) + { + rayQueryInitializeEXT(_43, _44, _45._m0, _45._m1, _45._m4, _45._m2, _45._m5, _45._m3); + _46 = 1u; + } + else + { + } +} + +_10 _271(rayQueryEXT _272, uint _273) +{ + _10 _275 = _10(0u, 0.0, 0u, 0u, 0u, 0u, 0u, vec2(0.0), false, mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)), mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0))); + if ((!((_273 & 4u) != 0u)) && ((_273 & 2u) != 0u)) + { + uint _285 = rayQueryGetIntersectionTypeEXT(_272, bool(0u)); + uint _287 = (_285 == 0u) ? 1u : 3u; + _275._m0 = _287; + bool _289 = _287 != 0u; + if (_289) + { + uint _292 = rayQueryGetIntersectionInstanceCustomIndexEXT(_272, bool(0u)); + uint _293 = rayQueryGetIntersectionInstanceIdEXT(_272, bool(0u)); + uint _294 = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(_272, bool(0u)); + uint _295 = rayQueryGetIntersectionGeometryIndexEXT(_272, bool(0u)); + uint _296 = rayQueryGetIntersectionPrimitiveIndexEXT(_272, bool(0u)); + mat4x3 _297 = rayQueryGetIntersectionObjectToWorldEXT(_272, bool(0u)); + mat4x3 _298 = rayQueryGetIntersectionWorldToObjectEXT(_272, bool(0u)); + _275._m2 = _292; + _275._m3 = _293; + _275._m4 = _294; + _275._m5 = _295; + _275._m6 = _296; + _275._m9 = _297; + _275._m10 = _298; + if (_289) + { + float _309 = rayQueryGetIntersectionTEXT(_272, bool(0u)); + _275._m1 = _309; + vec2 _311 = rayQueryGetIntersectionBarycentricsEXT(_272, bool(0u)); + bool _312 = rayQueryGetIntersectionFrontFaceEXT(_272, bool(0u)); + _275._m7 = _311; + _275._m8 = _312; + } + } + } + return _275; +} + +void _323(rayQueryEXT _324, uint _325, float _326, float _327) +{ + if ((!((_325 & 4u) != 0u)) && ((_325 & 2u) != 0u)) + { + uint _340 = rayQueryGetIntersectionTypeEXT(_324, bool(0u)); + float _342 = rayQueryGetRayTMinEXT(_324); + uint _343 = rayQueryGetIntersectionTypeEXT(_324, bool(1u)); + float _330; + if (_343 == 0u) + { + _330 = _327; + } + else + { + float _349 = rayQueryGetIntersectionTEXT(_324, bool(0u)); + _330 = _349; + } + if (((_326 >= _342) && (_326 <= _330)) && (_340 == 1u)) + { + rayQueryGenerateIntersectionEXT(_324, _326); + } + } +} + +void _364(rayQueryEXT _365, uint _366) +{ + if ((!((_366 & 4u) != 0u)) && ((_366 & 2u) != 0u)) + { + uint _377 = rayQueryGetIntersectionTypeEXT(_365, bool(0u)); + if (_377 == 0u) + { + rayQueryConfirmIntersectionEXT(_365); + } + } +} + +void _383(rayQueryEXT _384, uint _385) +{ + if ((!((_385 & 4u) != 0u)) && ((_385 & 2u) != 0u)) + { + rayQueryTerminateEXT(_384); + } +} + +void main() +{ + uint _267 = 0u; + float _268 = 0.0; + rayQueryEXT _266; + _42(_266, _15, _12(4u, 255u, 0.100000001490116119384765625, 100.0, vec3(0.0), vec3(0.0, 1.0, 0.0)), _267, _268); + _10 _316 = _271(_266, _267); + if (_316._m0 == 3u) + { + _323(_266, _267, 10.0, _268); + return; + } + else + { + if (_316._m0 == 1u) + { + _364(_266, _267); + return; + } + else + { + _383(_266, _267); + return; + } + } +} + diff --git a/naga/tests/out/spv/wgsl-ray-query.spvasm.glsl b/naga/tests/out/spv/wgsl-ray-query.spvasm.glsl new file mode 100644 index 000000000..fcc6f8726 --- /dev/null +++ b/naga/tests/out/spv/wgsl-ray-query.spvasm.glsl @@ -0,0 +1,322 @@ +//////////////////////////////// +// Entry point: "main" (comp) // +//////////////////////////////// +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + uint _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + uint _m6; + vec2 _m7; + bool _m8; + mat4x3 _m9; + mat4x3 _m10; +}; + +struct _12 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +struct _13 +{ + uint _m0; + vec3 _m1; +}; + +layout(set = 0, binding = 1, std430) buffer _18_17 +{ + _13 _m0; +} _17; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _15; + +void _42(rayQueryEXT _43, accelerationStructureEXT _44, _12 _45, inout uint _46, out float _47) +{ + bool _72 = (_45._m0 & 256u) != 0u; + bool _80 = (_45._m0 & 16u) != 0u; + bool _83 = (_45._m0 & 32u) != 0u; + bool _92 = (_45._m0 & 1u) != 0u; + bool _95 = (_45._m0 & 2u) != 0u; + bool _98 = (_45._m0 & 64u) != 0u; + bool _101 = (_45._m0 & 128u) != 0u; + _47 = _45._m3; + if (((((((!((((((_95 && _92) || (_101 && _92)) || (_101 && _95)) || (_101 && _98)) || (_98 && _92)) || (_98 && _95))) && (_45._m2 <= _45._m3)) && (_45._m2 >= 0.0)) && (!(any(isnan(_45._m4)) || any(isinf(_45._m4))))) && (!(any(isnan(_45._m5)) || any(isinf(_45._m5))))) && (!(((_45._m0 & 512u) != 0u) && _72))) && (!(((_80 && _72) || (_83 && _72)) || (_83 && _80)))) + { + rayQueryInitializeEXT(_43, _44, _45._m0, _45._m1, _45._m4, _45._m2, _45._m5, _45._m3); + _46 = 1u; + } + else + { + } +} + +bool _148(rayQueryEXT _149, inout uint _150) +{ + bool _152 = false; + if ((_150 & 1u) != 0u) + { + bool _159 = rayQueryProceedEXT(_149); + _152 = _159; + _150 |= (_159 ? 2u : 6u); + } + return _152; +} + +_10 _172(rayQueryEXT _173, uint _174) +{ + _10 _177 = _10(0u, 0.0, 0u, 0u, 0u, 0u, 0u, vec2(0.0), false, mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)), mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0))); + if (((_174 & 4u) != 0u) && ((_174 & 2u) != 0u)) + { + uint _186 = rayQueryGetIntersectionTypeEXT(_173, bool(1u)); + _177._m0 = _186; + bool _188 = _186 != 0u; + if (_188) + { + uint _191 = rayQueryGetIntersectionInstanceCustomIndexEXT(_173, bool(1u)); + uint _192 = rayQueryGetIntersectionInstanceIdEXT(_173, bool(1u)); + uint _193 = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(_173, bool(1u)); + uint _194 = rayQueryGetIntersectionGeometryIndexEXT(_173, bool(1u)); + uint _195 = rayQueryGetIntersectionPrimitiveIndexEXT(_173, bool(1u)); + mat4x3 _196 = rayQueryGetIntersectionObjectToWorldEXT(_173, bool(1u)); + mat4x3 _197 = rayQueryGetIntersectionWorldToObjectEXT(_173, bool(1u)); + _177._m2 = _191; + _177._m3 = _192; + _177._m4 = _193; + _177._m5 = _194; + _177._m6 = _195; + _177._m9 = _196; + _177._m10 = _197; + float _212 = rayQueryGetIntersectionTEXT(_173, bool(1u)); + _177._m1 = _212; + if (_188) + { + vec2 _214 = rayQueryGetIntersectionBarycentricsEXT(_173, bool(1u)); + bool _215 = rayQueryGetIntersectionFrontFaceEXT(_173, bool(1u)); + _177._m7 = _214; + _177._m8 = _215; + } + } + } + return _177; +} + +_10 _25(vec3 _21, vec3 _22, accelerationStructureEXT _23) +{ + uint _34 = 0u; + float _37 = 0.0; + uvec2 _134 = uvec2(4294967295u); + rayQueryEXT _31; + _42(_31, _23, _12(4u, 255u, 0.100000001490116119384765625, 100.0, _21, _22), _34, _37); + for (;;) + { + if (all(equal(uvec2(0u), _134))) + { + break; + } + _134 -= uvec2(uint(_134.y == 0u), 1u); + bool _145 = _148(_31, _34); + if (!_145) + { + break; + } + continue; + } + return _172(_31, _34); +} + +vec3 _225(vec3 _223, _10 _224) +{ + return normalize(_223 - (_224._m9 * vec4(normalize((_224._m10 * vec4(_223, 1.0)).xy) * 2.400000095367431640625, 0.0, 1.0))); +} + +void main() +{ + _10 _250 = _25(vec3(0.0), vec3(0.0, 1.0, 0.0), _15); + _17._m0._m0 = uint(_250._m0 == 0u); + _17._m0._m1 = _225(vec3(0.0, 1.0, 0.0) * _250._m1, _250); +} + + +////////////////////////////////////////// +// Entry point: "main_candidate" (comp) // +////////////////////////////////////////// +#version 460 +#extension GL_EXT_ray_query : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _10 +{ + uint _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + uint _m6; + vec2 _m7; + bool _m8; + mat4x3 _m9; + mat4x3 _m10; +}; + +struct _12 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +struct _13 +{ + uint _m0; + vec3 _m1; +}; + +layout(set = 0, binding = 0) uniform accelerationStructureEXT _15; + +void _42(rayQueryEXT _43, accelerationStructureEXT _44, _12 _45, inout uint _46, out float _47) +{ + bool _72 = (_45._m0 & 256u) != 0u; + bool _80 = (_45._m0 & 16u) != 0u; + bool _83 = (_45._m0 & 32u) != 0u; + bool _92 = (_45._m0 & 1u) != 0u; + bool _95 = (_45._m0 & 2u) != 0u; + bool _98 = (_45._m0 & 64u) != 0u; + bool _101 = (_45._m0 & 128u) != 0u; + _47 = _45._m3; + if (((((((!((((((_95 && _92) || (_101 && _92)) || (_101 && _95)) || (_101 && _98)) || (_98 && _92)) || (_98 && _95))) && (_45._m2 <= _45._m3)) && (_45._m2 >= 0.0)) && (!(any(isnan(_45._m4)) || any(isinf(_45._m4))))) && (!(any(isnan(_45._m5)) || any(isinf(_45._m5))))) && (!(((_45._m0 & 512u) != 0u) && _72))) && (!(((_80 && _72) || (_83 && _72)) || (_83 && _80)))) + { + rayQueryInitializeEXT(_43, _44, _45._m0, _45._m1, _45._m4, _45._m2, _45._m5, _45._m3); + _46 = 1u; + } + else + { + } +} + +_10 _271(rayQueryEXT _272, uint _273) +{ + _10 _275 = _10(0u, 0.0, 0u, 0u, 0u, 0u, 0u, vec2(0.0), false, mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0)), mat4x3(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0))); + if ((!((_273 & 4u) != 0u)) && ((_273 & 2u) != 0u)) + { + uint _285 = rayQueryGetIntersectionTypeEXT(_272, bool(0u)); + uint _287 = (_285 == 0u) ? 1u : 3u; + _275._m0 = _287; + bool _289 = _287 != 0u; + if (_289) + { + uint _292 = rayQueryGetIntersectionInstanceCustomIndexEXT(_272, bool(0u)); + uint _293 = rayQueryGetIntersectionInstanceIdEXT(_272, bool(0u)); + uint _294 = rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(_272, bool(0u)); + uint _295 = rayQueryGetIntersectionGeometryIndexEXT(_272, bool(0u)); + uint _296 = rayQueryGetIntersectionPrimitiveIndexEXT(_272, bool(0u)); + mat4x3 _297 = rayQueryGetIntersectionObjectToWorldEXT(_272, bool(0u)); + mat4x3 _298 = rayQueryGetIntersectionWorldToObjectEXT(_272, bool(0u)); + _275._m2 = _292; + _275._m3 = _293; + _275._m4 = _294; + _275._m5 = _295; + _275._m6 = _296; + _275._m9 = _297; + _275._m10 = _298; + if (_289) + { + float _309 = rayQueryGetIntersectionTEXT(_272, bool(0u)); + _275._m1 = _309; + vec2 _311 = rayQueryGetIntersectionBarycentricsEXT(_272, bool(0u)); + bool _312 = rayQueryGetIntersectionFrontFaceEXT(_272, bool(0u)); + _275._m7 = _311; + _275._m8 = _312; + } + } + } + return _275; +} + +void _323(rayQueryEXT _324, uint _325, float _326, float _327) +{ + if ((!((_325 & 4u) != 0u)) && ((_325 & 2u) != 0u)) + { + uint _340 = rayQueryGetIntersectionTypeEXT(_324, bool(0u)); + float _342 = rayQueryGetRayTMinEXT(_324); + uint _343 = rayQueryGetIntersectionTypeEXT(_324, bool(1u)); + float _330; + if (_343 == 0u) + { + _330 = _327; + } + else + { + float _349 = rayQueryGetIntersectionTEXT(_324, bool(0u)); + _330 = _349; + } + if (((_326 >= _342) && (_326 <= _330)) && (_340 == 1u)) + { + rayQueryGenerateIntersectionEXT(_324, _326); + } + } +} + +void _364(rayQueryEXT _365, uint _366) +{ + if ((!((_366 & 4u) != 0u)) && ((_366 & 2u) != 0u)) + { + uint _377 = rayQueryGetIntersectionTypeEXT(_365, bool(0u)); + if (_377 == 0u) + { + rayQueryConfirmIntersectionEXT(_365); + } + } +} + +void _383(rayQueryEXT _384, uint _385) +{ + if ((!((_385 & 4u) != 0u)) && ((_385 & 2u) != 0u)) + { + rayQueryTerminateEXT(_384); + } +} + +void main() +{ + uint _267 = 0u; + float _268 = 0.0; + rayQueryEXT _266; + _42(_266, _15, _12(4u, 255u, 0.100000001490116119384765625, 100.0, vec3(0.0), vec3(0.0, 1.0, 0.0)), _267, _268); + _10 _316 = _271(_266, _267); + if (_316._m0 == 3u) + { + _323(_266, _267, 10.0, _268); + return; + } + else + { + if (_316._m0 == 1u) + { + _364(_266, _267); + return; + } + else + { + _383(_266, _267); + return; + } + } +} + diff --git a/naga/tests/out/spv/wgsl-ray-tracing-pipeline.spvasm.glsl b/naga/tests/out/spv/wgsl-ray-tracing-pipeline.spvasm.glsl new file mode 100644 index 000000000..8d502f52b --- /dev/null +++ b/naga/tests/out/spv/wgsl-ray-tracing-pipeline.spvasm.glsl @@ -0,0 +1,146 @@ +//////////////////////////////////////// +// Entry point: "ray_gen_main" (rgen) // +//////////////////////////////////////// +#version 460 +#extension GL_EXT_ray_tracing : require + +struct _4 +{ + uint _m0; + uint _m1; +}; + +struct _9 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +layout(location = 0) rayPayloadEXT _4 _11; +layout(set = 0, binding = 0) uniform accelerationStructureEXT _13; +layout(location = 1) rayPayloadInEXT _4 _15; + +void _49(accelerationStructureEXT _50, _9 _51) +{ + bool _77 = (_51._m0 & 256u) != 0u; + bool _85 = (_51._m0 & 16u) != 0u; + bool _88 = (_51._m0 & 32u) != 0u; + bool _97 = (_51._m0 & 1u) != 0u; + bool _100 = (_51._m0 & 2u) != 0u; + bool _103 = (_51._m0 & 64u) != 0u; + bool _106 = (_51._m0 & 128u) != 0u; + if (((((((!((((((_100 && _97) || (_106 && _97)) || (_106 && _100)) || (_106 && _103)) || (_103 && _97)) || (_103 && _100))) && (_51._m2 <= _51._m3)) && (_51._m2 >= 0.0)) && (!(any(isnan(_51._m4)) || any(isinf(_51._m4))))) && (!(any(isnan(_51._m5)) || any(isinf(_51._m5))))) && (!(((_51._m0 & 512u) != 0u) && _77))) && (!(((_85 && _77) || (_88 && _77)) || (_88 && _85)))) + { + traceRayEXT(_50, _51._m0, _51._m1, 0u, 0u, 0u, _51._m4, _51._m2, _51._m5, _51._m3, 0); + } + else + { + } +} + +void main() +{ + _11 = _4(0u, 0u); + vec3 _40 = vec3(gl_LaunchIDEXT) / vec3(gl_LaunchSizeEXT); + _49(_13, _9(0u, 255u, 0.00999999977648258209228515625, 100.0, vec3(0.0), vec3(0.0, 1.0, 0.0) + ((vec3(_40.x, 0.0, _40.y) * 2.0) - vec3(1.0)))); +} + + +///////////////////////////////// +// Entry point: "miss" (rmiss) // +///////////////////////////////// +#version 460 +#extension GL_EXT_ray_tracing : require + +struct _4 +{ + uint _m0; + uint _m1; +}; + +struct _9 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +layout(location = 0) rayPayloadEXT _4 _11; +layout(set = 0, binding = 0) uniform accelerationStructureEXT _13; +layout(location = 1) rayPayloadInEXT _4 _15; + +void main() +{ +} + + +///////////////////////////////////////// +// Entry point: "any_hit_main" (rahit) // +///////////////////////////////////////// +#version 460 +#extension GL_EXT_ray_tracing : require + +struct _4 +{ + uint _m0; + uint _m1; +}; + +struct _9 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +layout(location = 0) rayPayloadEXT _4 _11; +layout(set = 0, binding = 0) uniform accelerationStructureEXT _13; +layout(location = 1) rayPayloadInEXT _4 _15; + +void main() +{ + _15._m0++; + _15._m1 = uint(gl_InstanceCustomIndexEXT); +} + + +///////////////////////////////////////////// +// Entry point: "closest_hit_main" (rchit) // +///////////////////////////////////////////// +#version 460 +#extension GL_EXT_ray_tracing : require + +struct _4 +{ + uint _m0; + uint _m1; +}; + +struct _9 +{ + uint _m0; + uint _m1; + float _m2; + float _m3; + vec3 _m4; + vec3 _m5; +}; + +layout(location = 0) rayPayloadEXT _4 _11; +layout(set = 0, binding = 0) uniform accelerationStructureEXT _13; +layout(location = 1) rayPayloadInEXT _4 _15; + +void main() +{ +} + diff --git a/naga/tests/out/spv/wgsl-select.spvasm.glsl b/naga/tests/out/spv/wgsl-select.spvasm.glsl new file mode 100644 index 000000000..38fa8d18d --- /dev/null +++ b/naga/tests/out/spv/wgsl-select.spvasm.glsl @@ -0,0 +1,10 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + ivec2 _17 = ivec2(1, 2); + vec2 _19 = vec2(0.0); + _19 = mix(vec2(1.0, 0.0), vec2(0.0, 1.0), bvec2(_17.x < _17.y)); +} + diff --git a/naga/tests/out/spv/wgsl-separate-entry-points.compute.spvasm.glsl b/naga/tests/out/spv/wgsl-separate-entry-points.compute.spvasm.glsl new file mode 100644 index 000000000..3fac18520 --- /dev/null +++ b/naga/tests/out/spv/wgsl-separate-entry-points.compute.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void _6() +{ + memoryBarrierBuffer(); + barrier(); + barrier(); + groupMemoryBarrier(); + barrier(); +} + +void main() +{ + _6(); +} + diff --git a/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm.glsl b/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm.glsl new file mode 100644 index 000000000..5a6f96bdb --- /dev/null +++ b/naga/tests/out/spv/wgsl-separate-entry-points.fragment.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 + +layout(location = 0) out vec4 _14; + +void _6() +{ + float _10 = dFdx(0.0); + float _11 = dFdy(0.0); + float _12 = fwidth(0.0); +} + +void main() +{ + _6(); + _14 = vec4(0.0); +} + diff --git a/naga/tests/out/spv/wgsl-shadow.spvasm.glsl b/naga/tests/out/spv/wgsl-shadow.spvasm.glsl new file mode 100644 index 000000000..82ed48bbd --- /dev/null +++ b/naga/tests/out/spv/wgsl-shadow.spvasm.glsl @@ -0,0 +1,260 @@ +/////////////////////////////////// +// Entry point: "vs_main" (vert) // +/////////////////////////////////// +#version 460 + +struct Globals +{ + mat4 view_proj; + uvec4 num_lights; +}; + +struct Entity +{ + mat4 world; + vec4 color; +}; + +struct VertexOutput +{ + vec4 proj_position; + vec3 world_normal; + vec4 world_position; +}; + +struct Light +{ + mat4 proj; + vec4 pos; + vec4 color; +}; + +layout(set = 0, binding = 0, std140) uniform u_globals +{ + Globals _m0; +} u_globals_1; + +layout(set = 1, binding = 0, std140) uniform u_entity +{ + Entity _m0; +} u_entity_1; + +layout(set = 0, binding = 1, std430) readonly buffer s_lights +{ + Light _m0[]; +} s_lights_1; + +layout(set = 0, binding = 1, std140) uniform u_lights +{ + Light _m0[10]; +} u_lights_1; + +layout(set = 0, binding = 2) uniform texture2DArray t_shadow; +layout(set = 0, binding = 3) uniform sampler sampler_shadow; + +layout(location = 0) in ivec4 position; +layout(location = 1) in ivec4 normal; +layout(location = 0) out vec3 world_normal; +layout(location = 1) out vec4 world_position; + +void main() +{ + VertexOutput _out = VertexOutput(vec4(0.0), vec3(0.0), vec4(0.0)); + vec4 _102 = u_entity_1._m0.world * vec4(position); + _out.world_normal = mat3(u_entity_1._m0.world[0].xyz, u_entity_1._m0.world[1].xyz, u_entity_1._m0.world[2].xyz) * vec3(normal.xyz); + _out.world_position = _102; + _out.proj_position = u_globals_1._m0.view_proj * _102; + gl_Position = _out.proj_position; + gl_Position.y = -gl_Position.y; + world_normal = _out.world_normal; + world_position = _out.world_position; +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 + +struct Globals +{ + mat4 view_proj; + uvec4 num_lights; +}; + +struct Entity +{ + mat4 world; + vec4 color; +}; + +struct VertexOutput +{ + vec4 proj_position; + vec3 world_normal; + vec4 world_position; +}; + +struct Light +{ + mat4 proj; + vec4 pos; + vec4 color; +}; + +layout(set = 0, binding = 0, std140) uniform u_globals +{ + Globals _m0; +} u_globals_1; + +layout(set = 1, binding = 0, std140) uniform u_entity +{ + Entity _m0; +} u_entity_1; + +layout(set = 0, binding = 1, std430) readonly buffer s_lights +{ + Light _m0[]; +} s_lights_1; + +layout(set = 0, binding = 1, std140) uniform u_lights +{ + Light _m0[10]; +} u_lights_1; + +layout(set = 0, binding = 2) uniform texture2DArray t_shadow; +layout(set = 0, binding = 3) uniform samplerShadow sampler_shadow; + +layout(location = 0) in vec3 world_normal; +layout(location = 1) in vec4 world_position; +layout(location = 0) out vec4 _142; + +float fetch_shadow(uint light_id, vec4 homogeneous_coords) +{ + if (homogeneous_coords.w <= 0.0) + { + return 1.0; + } + float _61 = 1.0 / homogeneous_coords.w; + return textureGrad(sampler2DArrayShadow(t_shadow, sampler_shadow), vec4(vec3(((homogeneous_coords.xy * vec2(0.5, -0.5)) * _61) + vec2(0.5), float(int(light_id))), homogeneous_coords.z * _61), vec2(0.0), vec2(0.0)); +} + +void main() +{ + vec3 color = vec3(0.0500000007450580596923828125); + uint i = 0u; + uvec2 loop_bound = uvec2(4294967295u); + VertexOutput _133 = VertexOutput(gl_FragCoord, world_normal, world_position); + vec3 _155 = normalize(_133.world_normal); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < min(u_globals_1._m0.num_lights.x, 10u))) + { + break; + } + color += (s_lights_1._m0[i].color.xyz * (fetch_shadow(i, s_lights_1._m0[i].proj * _133.world_position) * max(0.0, dot(_155, normalize(s_lights_1._m0[i].pos.xyz - _133.world_position.xyz))))); + i++; + continue; + } + _142 = vec4(color, 1.0) * u_entity_1._m0.color; +} + + +/////////////////////////////////////////////////// +// Entry point: "fs_main_without_storage" (frag) // +/////////////////////////////////////////////////// +#version 460 + +struct Globals +{ + mat4 view_proj; + uvec4 num_lights; +}; + +struct Entity +{ + mat4 world; + vec4 color; +}; + +struct VertexOutput +{ + vec4 proj_position; + vec3 world_normal; + vec4 world_position; +}; + +struct Light +{ + mat4 proj; + vec4 pos; + vec4 color; +}; + +layout(set = 0, binding = 0, std140) uniform u_globals +{ + Globals _m0; +} u_globals_1; + +layout(set = 1, binding = 0, std140) uniform u_entity +{ + Entity _m0; +} u_entity_1; + +layout(set = 0, binding = 1, std430) readonly buffer s_lights +{ + Light _m0[]; +} s_lights_1; + +layout(set = 0, binding = 1, std140) uniform u_lights +{ + Light _m0[10]; +} u_lights_1; + +layout(set = 0, binding = 2) uniform texture2DArray t_shadow; +layout(set = 0, binding = 3) uniform samplerShadow sampler_shadow; + +layout(location = 0) in vec3 world_normal; +layout(location = 1) in vec4 world_position; +layout(location = 0) out vec4 _227; + +float fetch_shadow(uint light_id, vec4 homogeneous_coords) +{ + if (homogeneous_coords.w <= 0.0) + { + return 1.0; + } + float _61 = 1.0 / homogeneous_coords.w; + return textureGrad(sampler2DArrayShadow(t_shadow, sampler_shadow), vec4(vec3(((homogeneous_coords.xy * vec2(0.5, -0.5)) * _61) + vec2(0.5), float(int(light_id))), homogeneous_coords.z * _61), vec2(0.0), vec2(0.0)); +} + +void main() +{ + vec3 color = vec3(0.0500000007450580596923828125); + uint i = 0u; + uvec2 loop_bound = uvec2(4294967295u); + VertexOutput _220 = VertexOutput(gl_FragCoord, world_normal, world_position); + vec3 _239 = normalize(_220.world_normal); + for (;;) + { + if (all(equal(uvec2(0u), loop_bound))) + { + break; + } + loop_bound -= uvec2(uint(loop_bound.y == 0u), 1u); + if (!(i < min(u_globals_1._m0.num_lights.x, 10u))) + { + break; + } + color += (u_lights_1._m0[i].color.xyz * (fetch_shadow(i, u_lights_1._m0[i].proj * _220.world_position) * max(0.0, dot(_239, normalize(u_lights_1._m0[i].pos.xyz - _220.world_position.xyz))))); + i++; + continue; + } + _227 = vec4(color, 1.0) * u_entity_1._m0.color; +} + diff --git a/naga/tests/out/spv/wgsl-skybox.spvasm.glsl b/naga/tests/out/spv/wgsl-skybox.spvasm.glsl new file mode 100644 index 000000000..4de7c1e5d --- /dev/null +++ b/naga/tests/out/spv/wgsl-skybox.spvasm.glsl @@ -0,0 +1,78 @@ +/////////////////////////////////// +// Entry point: "vs_main" (vert) // +/////////////////////////////////// +#version 460 + +struct _6 +{ + vec4 _m0; + vec3 _m1; +}; + +struct _8 +{ + mat4 _m0; + mat4 _m1; +}; + +layout(set = 0, binding = 0, std140) uniform _15_14 +{ + _8 _m0; +} _14; + +layout(set = 0, binding = 1) uniform textureCube _17; +layout(set = 0, binding = 2) uniform sampler _19; + +layout(location = 0) out vec3 _44; + +int _21(int _23, int _24) +{ + return _23 / (((_24 == 0) || ((_23 == int(0x80000000)) && (_24 == (-1)))) ? 1 : _24); +} + +void main() +{ + int _55 = 0; + int _58 = 0; + _55 = _21(int(uint(gl_VertexIndex)), 2); + _58 = int(uint(gl_VertexIndex)) & 1; + vec4 _73 = vec4((float(_55) * 4.0) - 1.0, (float(_58) * 4.0) - 1.0, 0.0, 1.0); + _6 _94 = _6(_73, transpose(mat3(_14._m0._m1[0u].xyz, _14._m0._m1[1u].xyz, _14._m0._m1[2u].xyz)) * (_14._m0._m0 * _73).xyz); + gl_Position = _94._m0; + _44 = _94._m1; +} + + +/////////////////////////////////// +// Entry point: "fs_main" (frag) // +/////////////////////////////////// +#version 460 + +struct _6 +{ + vec4 _m0; + vec3 _m1; +}; + +struct _8 +{ + mat4 _m0; + mat4 _m1; +}; + +layout(set = 0, binding = 0, std140) uniform _15_14 +{ + _8 _m0; +} _14; + +layout(set = 0, binding = 1) uniform textureCube _17; +layout(set = 0, binding = 2) uniform sampler _19; + +layout(location = 0) in vec3 _102; +layout(location = 0) out vec4 _105; + +void main() +{ + _105 = texture(samplerCube(_17, _19), _6(gl_FragCoord, _102)._m1); +} + diff --git a/naga/tests/out/spv/wgsl-sprite.spvasm.glsl b/naga/tests/out/spv/wgsl-sprite.spvasm.glsl new file mode 100644 index 000000000..e41b51386 --- /dev/null +++ b/naga/tests/out/spv/wgsl-sprite.spvasm.glsl @@ -0,0 +1,13 @@ +#version 460 + +layout(set = 0, binding = 0) uniform texture2D _8; +layout(set = 0, binding = 1) uniform sampler _10; + +layout(location = 0) in vec2 _13; +layout(location = 0) out vec4 _16; + +void main() +{ + _16 = texture(sampler2D(_8, _10), _13); +} + diff --git a/naga/tests/out/spv/wgsl-standard.spvasm.glsl b/naga/tests/out/spv/wgsl-standard.spvasm.glsl new file mode 100644 index 000000000..1ec772c77 --- /dev/null +++ b/naga/tests/out/spv/wgsl-standard.spvasm.glsl @@ -0,0 +1,26 @@ +#version 460 + +layout(location = 0) out vec4 _15; + +bool _7() +{ + return true; +} + +void main() +{ + vec4 _19 = vec4(0.0); + vec4 _22 = vec4(0.0); + vec4 _24 = vec4(0.0); + _19 = dFdxCoarse(gl_FragCoord); + _22 = dFdyCoarse(gl_FragCoord); + _24 = fwidthCoarse(gl_FragCoord); + _19 = dFdxFine(gl_FragCoord); + _22 = dFdyFine(gl_FragCoord); + _24 = fwidthFine(gl_FragCoord); + _19 = dFdx(gl_FragCoord); + _22 = dFdy(gl_FragCoord); + _24 = fwidth(gl_FragCoord); + _15 = (_19 + _22) * _24; +} + diff --git a/naga/tests/out/spv/wgsl-storage-textures.spvasm.glsl b/naga/tests/out/spv/wgsl-storage-textures.spvasm.glsl new file mode 100644 index 000000000..1340ddecb --- /dev/null +++ b/naga/tests/out/spv/wgsl-storage-textures.spvasm.glsl @@ -0,0 +1,38 @@ +////////////////////////////////// +// Entry point: "csLoad" (comp) // +////////////////////////////////// +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, r32f) uniform readonly image2D _7; +layout(set = 0, binding = 1, rg32f) uniform readonly image2D _9; +layout(set = 0, binding = 2, rgba32f) uniform readonly image2D _11; +layout(set = 1, binding = 0, r32f) uniform writeonly image2D _13; +layout(set = 1, binding = 1, rg32f) uniform writeonly image2D _14; +layout(set = 1, binding = 2, rgba32f) uniform writeonly image2D _15; + +void main() +{ +} + + +/////////////////////////////////// +// Entry point: "csStore" (comp) // +/////////////////////////////////// +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(set = 0, binding = 0, r32f) uniform readonly image2D _7; +layout(set = 0, binding = 1, rg32f) uniform readonly image2D _9; +layout(set = 0, binding = 2, rgba32f) uniform readonly image2D _11; +layout(set = 1, binding = 0, r32f) uniform writeonly image2D _13; +layout(set = 1, binding = 1, rg32f) uniform writeonly image2D _14; +layout(set = 1, binding = 2, rgba32f) uniform writeonly image2D _15; + +void main() +{ + imageStore(_13, ivec2(uvec2(0u)), vec4(0.0)); + imageStore(_14, ivec2(uvec2(0u)), vec4(0.0)); + imageStore(_15, ivec2(uvec2(0u)), vec4(0.0)); +} + diff --git a/naga/tests/out/spv/wgsl-struct-layout.spvasm.glsl b/naga/tests/out/spv/wgsl-struct-layout.spvasm.glsl new file mode 100644 index 000000000..cbba0a89f --- /dev/null +++ b/naga/tests/out/spv/wgsl-struct-layout.spvasm.glsl @@ -0,0 +1,285 @@ +/////////////////////////////////////////// +// Entry point: "no_padding_frag" (frag) // +/////////////////////////////////////////// +#version 460 + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +layout(location = 0) in vec3 _22; +layout(location = 1) in float _25; +layout(location = 0) out vec4 _28; + +void main() +{ + _28 = vec4(0.0); +} + + +/////////////////////////////////////////// +// Entry point: "no_padding_vert" (vert) // +/////////////////////////////////////////// +#version 460 + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +layout(location = 0) in vec3 _37; +layout(location = 1) in float _39; + +void main() +{ + gl_Position = vec4(0.0); +} + + +/////////////////////////////////////////// +// Entry point: "no_padding_comp" (comp) // +/////////////////////////////////////////// +#version 460 +layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in; + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +void main() +{ + _5 _52 = _5(vec3(0.0), 0.0); + _52 = _8._m0; + _52 = _11._m0; +} + + +////////////////////////////////////////////// +// Entry point: "needs_padding_frag" (frag) // +////////////////////////////////////////////// +#version 460 + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +layout(location = 0) in float _60; +layout(location = 1) in vec3 _62; +layout(location = 2) in float _64; +layout(location = 0) out vec4 _66; + +void main() +{ + _66 = vec4(0.0); +} + + +////////////////////////////////////////////// +// Entry point: "needs_padding_vert" (vert) // +////////////////////////////////////////////// +#version 460 + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +layout(location = 0) in float _71; +layout(location = 1) in vec3 _73; +layout(location = 2) in float _75; + +void main() +{ + gl_Position = vec4(0.0); +} + + +////////////////////////////////////////////// +// Entry point: "needs_padding_comp" (comp) // +////////////////////////////////////////////// +#version 460 +layout(local_size_x = 16, local_size_y = 1, local_size_z = 1) in; + +struct _5 +{ + vec3 _m0; + float _m1; +}; + +struct _7 +{ + float _m0; + vec3 _m1; + float _m2; +}; + +layout(set = 0, binding = 0, std140) uniform _9_8 +{ + _5 _m0; +} _8; + +layout(set = 0, binding = 1, std430) buffer _12_11 +{ + _5 _m0; +} _11; + +layout(set = 0, binding = 2, std140) uniform _15_14 +{ + _7 _m0; +} _14; + +layout(set = 0, binding = 3, std430) buffer _18_17 +{ + _7 _m0; +} _17; + +void main() +{ + _7 _86 = _7(0.0, vec3(0.0), 0.0); + _86 = _14._m0; + _86 = _17._m0; +} + diff --git a/naga/tests/out/spv/wgsl-subgroup-barrier.spvasm.glsl b/naga/tests/out/spv/wgsl-subgroup-barrier.spvasm.glsl new file mode 100644 index 000000000..eda1b001e --- /dev/null +++ b/naga/tests/out/spv/wgsl-subgroup-barrier.spvasm.glsl @@ -0,0 +1,10 @@ +#version 460 +#extension GL_KHR_shader_subgroup_basic : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + subgroupMemoryBarrier(); + subgroupBarrier(); +} + diff --git a/naga/tests/out/spv/wgsl-subgroup-operations.spvasm.glsl b/naga/tests/out/spv/wgsl-subgroup-operations.spvasm.glsl new file mode 100644 index 000000000..3221012f4 --- /dev/null +++ b/naga/tests/out/spv/wgsl-subgroup-operations.spvasm.glsl @@ -0,0 +1,21 @@ +#version 460 +#extension GL_KHR_shader_subgroup_basic : require +#extension GL_KHR_shader_subgroup_ballot : require +#extension GL_KHR_shader_subgroup_vote : require +#extension GL_KHR_shader_subgroup_arithmetic : require +#extension GL_KHR_shader_subgroup_shuffle : require +#extension GL_KHR_shader_subgroup_shuffle_relative : require +#extension GL_KHR_shader_subgroup_quad : require +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct _4 +{ + uint _m0; + uint _m1; +}; + +void main() +{ + _4 _7 = _4(gl_NumSubgroups, gl_SubgroupSize); +} + diff --git a/naga/tests/out/spv/wgsl-texture-arg.spvasm.glsl b/naga/tests/out/spv/wgsl-texture-arg.spvasm.glsl new file mode 100644 index 000000000..732ac16dc --- /dev/null +++ b/naga/tests/out/spv/wgsl-texture-arg.spvasm.glsl @@ -0,0 +1,17 @@ +#version 460 + +layout(set = 0, binding = 0) uniform texture2D Texture; +layout(set = 0, binding = 1) uniform sampler Sampler; + +layout(location = 0) out vec4 _27; + +vec4 test(texture2D Passed_Texture, sampler Passed_Sampler) +{ + return texture(sampler2D(Passed_Texture, Passed_Sampler), vec2(0.0)); +} + +void main() +{ + _27 = test(Texture, Sampler); +} + diff --git a/naga/tests/out/spv/wgsl-type-inference.spvasm.glsl b/naga/tests/out/spv/wgsl-type-inference.spvasm.glsl new file mode 100644 index 000000000..cfd8a7c6f --- /dev/null +++ b/naga/tests/out/spv/wgsl-type-inference.spvasm.glsl @@ -0,0 +1,36 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +void main() +{ + mat2 _54 = mat2(vec2(0.0), vec2(0.0)); + float _51 = 1.0; + int _48 = 1; + float _42 = 0.0; + mat2 _37 = mat2(vec2(1.0), vec2(1.0)); + ivec4 _33 = ivec4(0); + uint _29 = 1u; + float _24 = 1.0; + ivec4 _53 = ivec4(1); + float _50 = 1.0; + ivec4 _46 = ivec4(0); + uint _40 = 0u; + mat2 _36 = mat2(vec2(0.0), vec2(0.0)); + float _32 = 1.0; + int _28 = 1; + int _22 = 1; + mat2 _55 = mat2(vec2(1.0), vec2(1.0)); + ivec4 _52 = ivec4(0); + uint _49 = 1u; + float _44 = 0.0; + int _38 = 0; + ivec4 _35 = ivec4(1); + float _31 = 1.0; + mat2 _26 = mat2(vec2(1.0), vec2(1.0)); + _38 = 1; + _40 = 1u; + _42 = 1.0; + _44 = 1.0; + _46 = ivec4(0); +} + diff --git a/naga/tests/out/spv/wgsl-workgroup-uniform-load-atomic.spvasm.glsl b/naga/tests/out/spv/wgsl-workgroup-uniform-load-atomic.spvasm.glsl new file mode 100644 index 000000000..c6b43192e --- /dev/null +++ b/naga/tests/out/spv/wgsl-workgroup-uniform-load-atomic.spvasm.glsl @@ -0,0 +1,76 @@ +#version 460 +layout(local_size_x = 64, local_size_y = 1, local_size_z = 1) in; + +struct _7 +{ + uint _m0; + int _m1[2]; +}; + +shared uint _10; +shared int _12; +shared _7 _14; + +void main() +{ + bool _31 = false; + bool _34 = false; + bool _36 = false; + if (gl_LocalInvocationIndex == 0u) + { + _10 = 0u; + _12 = 0; + _14 = _7(0u, int[](0, 0)); + } + barrier(); + uint _56 = atomicOr(_10, uint((gl_WorkGroupID.x + (gl_WorkGroupID.y * 32768u)) >= 64u)); + int _58 = atomicAdd(_12, 1); + atomicExchange(_14._m0, 1u); + int _61 = atomicAdd(_14._m1[0u], 1); + barrier(); + barrier(); + uint _63 = atomicAdd(_10, 0u); + barrier(); + barrier(); + int _64 = atomicAdd(_12, 0); + barrier(); + barrier(); + uint _66 = atomicAdd(_14._m0, 0u); + barrier(); + barrier(); + int _68 = atomicAdd(_14._m1[0u], 0); + barrier(); + if (_63 == 0u) + { + _31 = _64 > 0; + } + else + { + _31 = false; + } + if (_31) + { + _34 = _66 > 0u; + } + else + { + _34 = false; + } + if (_34) + { + _36 = _68 > 0; + } + else + { + _36 = false; + } + if (_36) + { + return; + } + else + { + return; + } +} + diff --git a/naga/tests/out/spv/wgsl-workgroup-uniform-load.spvasm.glsl b/naga/tests/out/spv/wgsl-workgroup-uniform-load.spvasm.glsl new file mode 100644 index 000000000..f13b5fa40 --- /dev/null +++ b/naga/tests/out/spv/wgsl-workgroup-uniform-load.spvasm.glsl @@ -0,0 +1,26 @@ +#version 460 +layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; + +shared int _8[128]; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + _8 = int[](0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + } + barrier(); + barrier(); + int _33 = _8[gl_WorkGroupID.x]; + barrier(); + if (_33 > 10) + { + barrier(); + return; + } + else + { + return; + } +} + diff --git a/naga/tests/out/spv/wgsl-workgroup-var-init.spvasm.glsl b/naga/tests/out/spv/wgsl-workgroup-var-init.spvasm.glsl new file mode 100644 index 000000000..4e3ddf9ae --- /dev/null +++ b/naga/tests/out/spv/wgsl-workgroup-var-init.spvasm.glsl @@ -0,0 +1,27 @@ +#version 460 +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct WStruct +{ + uint arr[512]; + int atom; + int atom_arr[8][8]; +}; + +layout(set = 0, binding = 0, std430) buffer _output +{ + uint _m0[512]; +} _output_1; + +shared WStruct w_mem; + +void main() +{ + if (gl_LocalInvocationIndex == 0u) + { + w_mem = WStruct(uint[](0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u), 0, int[][](int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0), int[](0, 0, 0, 0, 0, 0, 0, 0))); + } + barrier(); + _output_1._m0 = w_mem.arr; +} +