From 2c777f79f00939453cbb73fa3b837d4d0fc02501 Mon Sep 17 00:00:00 2001 From: Andy Leiserson Date: Wed, 2 Apr 2025 08:52:40 -0700 Subject: [PATCH] [naga wgsl-in] `vecN()` constructors and `let` type conversions (#7367) * Support `vecN()` constructors (fixes #7356) * Apply automatic conversions to the initializer for `let` bindings --- CHANGELOG.md | 1 + naga/src/front/wgsl/lower/construction.rs | 22 +- naga/src/front/wgsl/lower/mod.rs | 48 +- naga/src/proc/mod.rs | 2 + naga/tests/in/wgsl/abstract-types-const.wgsl | 27 +- naga/tests/in/wgsl/abstract-types-let.toml | 1 + naga/tests/in/wgsl/abstract-types-let.wgsl | 115 +++ naga/tests/in/wgsl/abstract-types-var.wgsl | 52 +- naga/tests/in/wgsl/constructors.wgsl | 9 +- naga/tests/in/wgsl/conversions.wgsl | 16 + naga/tests/in/wgsl/type-inference.wgsl | 64 ++ naga/tests/naga/wgsl_errors.rs | 6 +- .../out/glsl/constructors.main.Compute.glsl | 4 + .../out/glsl/conversions.main.Compute.glsl | 16 + .../out/glsl/type-inference.main.Compute.glsl | 50 ++ naga/tests/out/hlsl/constructors.hlsl | 4 + naga/tests/out/hlsl/conversions.hlsl | 10 + naga/tests/out/hlsl/conversions.ron | 12 + naga/tests/out/hlsl/type-inference.hlsl | 48 ++ naga/tests/out/hlsl/type-inference.ron | 12 + naga/tests/out/msl/abstract-types-const.msl | 25 +- naga/tests/out/msl/abstract-types-let.msl | 131 +++ naga/tests/out/msl/abstract-types-var.msl | 194 +++-- naga/tests/out/msl/constructors.msl | 16 +- naga/tests/out/msl/conversions.msl | 14 + naga/tests/out/msl/type-inference.msl | 48 ++ .../tests/out/spv/abstract-types-const.spvasm | 93 +- naga/tests/out/spv/abstract-types-let.spvasm | 144 ++++ naga/tests/out/spv/abstract-types-var.spvasm | 797 ++++++++++-------- naga/tests/out/spv/constructors.spvasm | 138 +-- naga/tests/out/spv/conversions.spvasm | 23 + naga/tests/out/spv/math-functions.spvasm | 48 +- naga/tests/out/spv/operators.spvasm | 142 ++-- naga/tests/out/spv/type-inference.spvasm | 72 ++ naga/tests/out/wgsl/abstract-types-const.wgsl | 19 +- naga/tests/out/wgsl/abstract-types-let.wgsl | 112 +++ naga/tests/out/wgsl/abstract-types-var.wgsl | 188 +++-- naga/tests/out/wgsl/constructors.wgsl | 4 + naga/tests/out/wgsl/conversions.wgsl | 9 + naga/tests/out/wgsl/type-inference.wgsl | 43 + 40 files changed, 2028 insertions(+), 751 deletions(-) create mode 100644 naga/tests/in/wgsl/abstract-types-let.toml create mode 100644 naga/tests/in/wgsl/abstract-types-let.wgsl create mode 100644 naga/tests/in/wgsl/conversions.wgsl create mode 100644 naga/tests/in/wgsl/type-inference.wgsl create mode 100644 naga/tests/out/glsl/conversions.main.Compute.glsl create mode 100644 naga/tests/out/glsl/type-inference.main.Compute.glsl create mode 100644 naga/tests/out/hlsl/conversions.hlsl create mode 100644 naga/tests/out/hlsl/conversions.ron create mode 100644 naga/tests/out/hlsl/type-inference.hlsl create mode 100644 naga/tests/out/hlsl/type-inference.ron create mode 100644 naga/tests/out/msl/abstract-types-let.msl create mode 100644 naga/tests/out/msl/conversions.msl create mode 100644 naga/tests/out/msl/type-inference.msl create mode 100644 naga/tests/out/spv/abstract-types-let.spvasm create mode 100644 naga/tests/out/spv/conversions.spvasm create mode 100644 naga/tests/out/spv/type-inference.spvasm create mode 100644 naga/tests/out/wgsl/abstract-types-let.wgsl create mode 100644 naga/tests/out/wgsl/conversions.wgsl create mode 100644 naga/tests/out/wgsl/type-inference.wgsl diff --git a/CHANGELOG.md b/CHANGELOG.md index 54c4780f6..3de1a4423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -239,6 +239,7 @@ By @wumpf in [#7144](https://github.com/gfx-rs/wgpu/pull/7144) - Allow WGSL const declarations to have abstract types. By @jamienicol in [#7055](https://github.com/gfx-rs/wgpu/pull/7055) and [#7222](https://github.com/gfx-rs/wgpu/pull/7222). - Allows override-sized arrays to resolve to the same size without causing the type arena to panic. By @KentSlaney in [#7082](https://github.com/gfx-rs/wgpu/pull/7082). - Allow abstract types to be used for WGSL switch statement selector and case selector expressions. By @jamienicol in [#7250](https://github.com/gfx-rs/wgpu/pull/7250). +- Apply automatic conversions to `let` declarations, and accept `vecN()` as a constructor for vectors (in any context). By @andyleiserson in [#7367](https://github.com/gfx-rs/wgpu/pull/7367). #### General diff --git a/naga/src/front/wgsl/lower/construction.rs b/naga/src/front/wgsl/lower/construction.rs index fe5f4655e..286a893b9 100644 --- a/naga/src/front/wgsl/lower/construction.rs +++ b/naga/src/front/wgsl/lower/construction.rs @@ -167,11 +167,25 @@ impl<'source> Lowerer<'source, '_> { // Empty constructor (Components::None, dst_ty) => match dst_ty { Constructor::Type((result_ty, _)) => { - return ctx.append_expression(crate::Expression::ZeroValue(result_ty), span) + expr = crate::Expression::ZeroValue(result_ty); } - Constructor::PartialVector { .. } - | Constructor::PartialMatrix { .. } - | Constructor::PartialArray => { + Constructor::PartialVector { size } => { + // vec2(), vec3(), vec4() return vectors of abstractInts; the same + // is not true of the similar constructors for matrices or arrays. + // See https://www.w3.org/TR/WGSL/#vec2-builtin et seq. + let result_ty = ctx.module.types.insert( + crate::Type { + name: None, + inner: crate::TypeInner::Vector { + size, + scalar: crate::Scalar::ABSTRACT_INT, + }, + }, + span, + ); + expr = crate::Expression::ZeroValue(result_ty); + } + Constructor::PartialMatrix { .. } | Constructor::PartialArray => { // We have no arguments from which to infer the result type, so // partial constructors aren't acceptable here. return Err(Box::new(Error::TypeNotInferable(ty_span))); diff --git a/naga/src/front/wgsl/lower/mod.rs b/naga/src/front/wgsl/lower/mod.rs index af44242f1..909299f65 100644 --- a/naga/src/front/wgsl/lower/mod.rs +++ b/naga/src/front/wgsl/lower/mod.rs @@ -1490,41 +1490,39 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let mut emitter = Emitter::default(); emitter.start(&ctx.function.expressions); - let value = - self.expression(l.init, &mut ctx.as_expression(block, &mut emitter))?; + let explicit_ty = l + .ty + .map(|ty| self.resolve_ast_type(ty, &mut ctx.as_const(block, &mut emitter))) + .transpose()?; + + let mut ectx = ctx.as_expression(block, &mut emitter); + + let (_ty, initializer) = self.type_and_init( + l.name, + Some(l.init), + explicit_ty, + AbstractRule::Concretize, + &mut ectx, + )?; + + // We passed `Some()` to `type_and_init`, so we + // will get a lowered initializer expression back. + let initializer = + initializer.expect("type_and_init did not return an initializer"); // The WGSL spec says that any expression that refers to a // `let`-bound variable is not a const expression. This // affects when errors must be reported, so we can't even // treat suitable `let` bindings as constant as an // optimization. - ctx.local_expression_kind_tracker.force_non_const(value); - - let explicit_ty = l - .ty - .map(|ty| self.resolve_ast_type(ty, &mut ctx.as_const(block, &mut emitter))) - .transpose()?; - - if let Some(ty) = explicit_ty { - let mut ctx = ctx.as_expression(block, &mut emitter); - let init_ty = ctx.register_type(value)?; - if !ctx.module.types[ty] - .inner - .equivalent(&ctx.module.types[init_ty].inner, &ctx.module.types) - { - return Err(Box::new(Error::InitializationTypeMismatch { - name: l.name.span, - expected: ctx.type_to_string(ty), - got: ctx.type_to_string(init_ty), - })); - } - } + ctx.local_expression_kind_tracker + .force_non_const(initializer); block.extend(emitter.finish(&ctx.function.expressions)); ctx.local_table - .insert(l.handle, Declared::Runtime(Typed::Plain(value))); + .insert(l.handle, Declared::Runtime(Typed::Plain(initializer))); ctx.named_expressions - .insert(value, (l.name.name.to_string(), l.name.span)); + .insert(initializer, (l.name.name.to_string(), l.name.span)); return Ok(()); } diff --git a/naga/src/proc/mod.rs b/naga/src/proc/mod.rs index 787a2f1a6..49089fda0 100644 --- a/naga/src/proc/mod.rs +++ b/naga/src/proc/mod.rs @@ -119,6 +119,8 @@ impl crate::Literal { (value, crate::ScalarKind::Sint, 8) => Some(Self::I64(value as _)), (1, crate::ScalarKind::Bool, crate::BOOL_WIDTH) => Some(Self::Bool(true)), (0, crate::ScalarKind::Bool, crate::BOOL_WIDTH) => Some(Self::Bool(false)), + (value, crate::ScalarKind::AbstractInt, 8) => Some(Self::AbstractInt(value as _)), + (value, crate::ScalarKind::AbstractFloat, 8) => Some(Self::AbstractFloat(value as _)), _ => None, } } diff --git a/naga/tests/in/wgsl/abstract-types-const.wgsl b/naga/tests/in/wgsl/abstract-types-const.wgsl index 0cf20b5d2..73be56a3a 100644 --- a/naga/tests/in/wgsl/abstract-types-const.wgsl +++ b/naga/tests/in/wgsl/abstract-types-const.wgsl @@ -12,8 +12,11 @@ // - all parameters' types are considered. // - all parameters are converted to the consensus type. -const xvupaiai: vec2 = vec2(42, 43); -const xvfpaiai: vec2 = vec2(44, 45); +const xvipaiai: vec2 = vec2(42, 43); +const xvupaiai: vec2 = vec2(44, 45); +const xvfpaiai: vec2 = vec2(46, 47); +const xvfpafaf: vec2 = vec2(48.0, 49.0); +const xvfpaiaf: vec2 = vec2(48, 49.0); const xvupuai: vec2 = vec2(42u, 43); const xvupaiu: vec2 = vec2(42, 43u); @@ -21,6 +24,11 @@ const xvupaiu: vec2 = vec2(42, 43u); const xvuuai: vec2 = vec2(42u, 43); const xvuaiu: vec2 = vec2(42, 43u); +const xvip____: vec2 = vec2(); +const xvup____: vec2 = vec2(); +const xvfp____: vec2 = vec2(); +const xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + const xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); const xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); const xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -41,9 +49,15 @@ const ivfs_af = vec2(1.0); const iafafaf = array(1.0, 2.0); const iafaiai = array(1, 2); -const iafpafaf = array(1.0, 2.0); -const iafpaiaf = array(1, 2.0); +const iaipaiai = array(1, 2); +const iafpaiaf = array(1, 2.0); const iafpafai = array(1.0, 2); +const iafpafaf = array(1.0, 2.0); + +const xaipaiai: array = array(1, 2); +const xaupaiai: array = array(1, 2); +const xafpaiaf: array = array(1, 2.0); +const xafpafai: array = array(1.0, 2); const xafpafaf: array = array(1.0, 2.0); struct S { @@ -61,6 +75,11 @@ const saf_iai: S = S(1.0, 1i, 1); const safai_u: S = S(1.0, 1, 1u); const safaiai: S = S(1.0, 1, 1); +const xvisai: vec2 = vec2(1); +const xvusai: vec2 = vec2(1); +const xvfsai: vec2 = vec2(1); +const xvfsaf: vec2 = vec2(1.0); + // Vector construction with spreads const ivfr_f__f = vec3(vec2(1.0f, 2.0f), 3.0f); const ivfr_f_af = vec3(vec2(1.0f, 2.0f), 3.0 ); diff --git a/naga/tests/in/wgsl/abstract-types-let.toml b/naga/tests/in/wgsl/abstract-types-let.toml new file mode 100644 index 000000000..881b2333f --- /dev/null +++ b/naga/tests/in/wgsl/abstract-types-let.toml @@ -0,0 +1 @@ +targets = "SPIRV | METAL | GLSL | WGSL" diff --git a/naga/tests/in/wgsl/abstract-types-let.wgsl b/naga/tests/in/wgsl/abstract-types-let.wgsl new file mode 100644 index 000000000..667f11513 --- /dev/null +++ b/naga/tests/in/wgsl/abstract-types-let.wgsl @@ -0,0 +1,115 @@ +// i/x: type inferred / explicit +// vX/mX/aX: vector / matrix / array of X +// where X: u/i/f: u32 / i32 / f32 +// s: vector splat +// r: vector spread (vector arg to vector constructor) +// p: "partial" constructor (type parameter inferred) +// u/i/f/ai/af: u32 / i32 / f32 / abstract float / abstract integer as parameter +// _: just for alignment + +// Ensure that: +// - the inferred type is correct. +// - all parameters' types are considered. +// - all parameters are converted to the consensus type. + +fn all_constant_arguments() { + let xvipaiai: vec2 = vec2(42, 43); + let xvupaiai: vec2 = vec2(44, 45); + let xvfpaiai: vec2 = vec2(46, 47); + let xvfpafaf: vec2 = vec2(48.0, 49.0); + let xvfpaiaf: vec2 = vec2(48, 49.0); + + let xvupuai: vec2 = vec2(42u, 43); + let xvupaiu: vec2 = vec2(42, 43u); + + let xvuuai: vec2 = vec2(42u, 43); + let xvuaiu: vec2 = vec2(42, 43u); + + let xvip____: vec2 = vec2(); + let xvup____: vec2 = vec2(); + let xvfp____: vec2 = vec2(); + let xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + + let xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); + let xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); + let xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); + let xmfpaiaiafai: mat2x2 = mat2x2(1, 2, 3.0, 4); + let xmfpaiaiaiaf: mat2x2 = mat2x2(1, 2, 3, 4.0); + + let xmfp_faiaiai: mat2x2 = mat2x2(1.0f, 2, 3, 4); + let xmfpai_faiai: mat2x2 = mat2x2(1, 2.0f, 3, 4); + let xmfpaiai_fai: mat2x2 = mat2x2(1, 2, 3.0f, 4); + let xmfpaiaiai_f: mat2x2 = mat2x2(1, 2, 3, 4.0f); + + let xvispai: vec2 = vec2(1); + let xvfspaf: vec2 = vec2(1.0); + let xvis_ai: vec2 = vec2(1); + let xvus_ai: vec2 = vec2(1); + let xvfs_ai: vec2 = vec2(1); + let xvfs_af: vec2 = vec2(1.0); + + let xafafaf: array = array(1.0, 2.0); + let xaf_faf: array = array(1.0f, 2.0); + let xafaf_f: array = array(1.0, 2.0f); + let xafaiai: array = array(1, 2); + let xai_iai: array = array(1i, 2); + let xaiai_i: array = array(1, 2i); + + let xaipaiai: array = array(1, 2); + let xafpaiai: array = array(1, 2); + let xafpaiaf: array = array(1, 2.0); + let xafpafai: array = array(1.0, 2); + let xafpafaf: array = array(1.0, 2.0); + + let xavipai: array, 1> = array(vec3(1)); + let xavfpai: array, 1> = array(vec3(1)); + let xavfpaf: array, 1> = array(vec3(1.0)); + + // Construction with splats + let xvisai: vec2 = vec2(1); + let xvusai: vec2 = vec2(1); + let xvfsai: vec2 = vec2(1); + let xvfsaf: vec2 = vec2(1.0); + + let iaipaiai = array(1, 2); + let iafpaiaf = array(1, 2.0); + let iafpafai = array(1.0, 2); + let iafpafaf = array(1.0, 2.0); +} + +fn mixed_constant_and_runtime_arguments() { + var u: u32; + var i: i32; + var f: f32; + + let xvupuai: vec2 = vec2(u, 43); + let xvupaiu: vec2 = vec2(42, u); + let xvfpfai: vec2 = vec2(f, 47); // differs slightly from const version + let xvfpfaf: vec2 = vec2(f, 49.0); + + let xvuuai: vec2 = vec2(u, 43); + let xvuaiu: vec2 = vec2(42, u); + + let xmfp_faiaiai: mat2x2 = mat2x2(f, 2, 3, 4); + let xmfpai_faiai: mat2x2 = mat2x2(1, f, 3, 4); + let xmfpaiai_fai: mat2x2 = mat2x2(1, 2, f, 4); + let xmfpaiaiai_f: mat2x2 = mat2x2(1, 2, 3, f); + + let xaf_faf: array = array(f, 2.0); + let xafaf_f: array = array(1.0, f); + let xaf_fai: array = array(f, 2); + let xafai_f: array = array(1, f); + let xai_iai: array = array(i, 2); + let xaiai_i: array = array(1, i); + + let xafp_faf: array = array(f, 2.0); + let xafpaf_f: array = array(1.0, f); + let xafp_fai: array = array(f, 2); + let xafpai_f: array = array(1, f); + let xaip_iai: array = array(i, 2); + let xaipai_i: array = array(1, i); + + let xvisi: vec2 = vec2(i); + let xvusu: vec2 = vec2(u); + let xvfsf: vec2 = vec2(f); +} diff --git a/naga/tests/in/wgsl/abstract-types-var.wgsl b/naga/tests/in/wgsl/abstract-types-var.wgsl index e12a14b37..8820431da 100644 --- a/naga/tests/in/wgsl/abstract-types-var.wgsl +++ b/naga/tests/in/wgsl/abstract-types-var.wgsl @@ -15,6 +15,8 @@ var xvipaiai: vec2 = vec2(42, 43); var xvupaiai: vec2 = vec2(44, 45); var xvfpaiai: vec2 = vec2(46, 47); +var xvfpafaf: vec2 = vec2(48.0, 49.0); +var xvfpaiaf: vec2 = vec2(48, 49.0); var xvupuai: vec2 = vec2(42u, 43); var xvupaiu: vec2 = vec2(42, 43u); @@ -22,6 +24,11 @@ var xvupaiu: vec2 = vec2(42, 43u); var xvuuai: vec2 = vec2(42u, 43); var xvuaiu: vec2 = vec2(42, 43u); +var xvip____: vec2 = vec2(); +var xvup____: vec2 = vec2(); +var xvfp____: vec2 = vec2(); +var xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + var xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); var xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); var xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -38,7 +45,8 @@ var xvfs_af: vec2 = vec2(1.0); var xafafaf: array = array(1.0, 2.0); var xafaiai: array = array(1, 2); -var xafpaiai: array = array(1, 2); +var xaipaiai: array = array(1, 2); +var xaupaiai: array = array(1, 2); var xafpaiaf: array = array(1, 2.0); var xafpafai: array = array(1.0, 2); var xafpafaf: array = array(1.0, 2.0); @@ -47,6 +55,12 @@ var xavipai: array, 1> = array(vec3(1)); var xavfpai: array, 1> = array(vec3(1)); var xavfpaf: array, 1> = array(vec3(1.0)); +// Construction with splats +var xvisai: vec2 = vec2(1); +var xvusai: vec2 = vec2(1); +var xvfsai: vec2 = vec2(1); +var xvfsaf: vec2 = vec2(1.0); + var ivispai = vec2(1); var ivfspaf = vec2(1.0); var ivis_ai = vec2(1); @@ -70,6 +84,8 @@ fn all_constant_arguments() { var xvipaiai: vec2 = vec2(42, 43); var xvupaiai: vec2 = vec2(44, 45); var xvfpaiai: vec2 = vec2(46, 47); + var xvfpafaf: vec2 = vec2(48.0, 49.0); + var xvfpaiaf: vec2 = vec2(48, 49.0); var xvupuai: vec2 = vec2(42u, 43); var xvupaiu: vec2 = vec2(42, 43u); @@ -77,6 +93,11 @@ fn all_constant_arguments() { var xvuuai: vec2 = vec2(42u, 43); var xvuaiu: vec2 = vec2(42, 43u); + var xvip____: vec2 = vec2(); + var xvup____: vec2 = vec2(); + var xvfp____: vec2 = vec2(); + var xmfp____: mat2x2f = mat2x2(vec2(), vec2()); + var xmfpaiaiaiai: mat2x2 = mat2x2(1, 2, 3, 4); var xmfpafaiaiai: mat2x2 = mat2x2(1.0, 2, 3, 4); var xmfpaiafaiai: mat2x2 = mat2x2(1, 2.0, 3, 4); @@ -112,6 +133,12 @@ fn all_constant_arguments() { var xavfpai: array, 1> = array(vec3(1)); var xavfpaf: array, 1> = array(vec3(1.0)); + // Construction with splats + var xvisai: vec2 = vec2(1); + var xvusai: vec2 = vec2(1); + var xvfsai: vec2 = vec2(1); + var xvfsaf: vec2 = vec2(1.0); + var iaipaiai = array(1, 2); var iafpaiaf = array(1, 2.0); var iafpafai = array(1.0, 2); @@ -121,6 +148,8 @@ fn all_constant_arguments() { xvipaiai = vec2(42, 43); xvupaiai = vec2(44, 45); xvfpaiai = vec2(46, 47); + xvfpafaf = vec2(48.0, 49.0); + xvfpaiaf = vec2(48, 49.0); xvupuai = vec2(42u, 43); xvupaiu = vec2(42, 43u); @@ -128,6 +157,11 @@ fn all_constant_arguments() { xvuuai = vec2(42u, 43); xvuaiu = vec2(42, 43u); + xvip____ = vec2(); + xvup____ = vec2(); + xvfp____ = vec2(); + xmfp____ = mat2x2(vec2(), vec2()); + xmfpaiaiaiai = mat2x2(1, 2, 3, 4); xmfpafaiaiai = mat2x2(1.0, 2, 3, 4); xmfpaiafaiai = mat2x2(1, 2.0, 3, 4); @@ -163,6 +197,12 @@ fn all_constant_arguments() { xavfpai = array(vec3(1)); xavfpaf = array(vec3(1.0)); + // Construction with splats + xvisai = vec2(1); + xvusai = vec2(1); + xvfsai = vec2(1); + xvfsaf = vec2(1.0); + iaipaiai = array(1, 2); iafpaiaf = array(1, 2.0); iafpafai = array(1.0, 2); @@ -176,6 +216,8 @@ fn mixed_constant_and_runtime_arguments() { var xvupuai: vec2 = vec2(u, 43); var xvupaiu: vec2 = vec2(42, u); + var xvfpfai: vec2 = vec2(f, 47); // differs slightly from const version + var xvfpfaf: vec2 = vec2(f, 49.0); var xvuuai: vec2 = vec2(u, 43); var xvuaiu: vec2 = vec2(42, u); @@ -199,6 +241,10 @@ fn mixed_constant_and_runtime_arguments() { var xaip_iai: array = array(i, 2); var xaipai_i: array = array(1, i); + var xvisi: vec2 = vec2(i); + var xvusu: vec2 = vec2(u); + var xvfsf: vec2 = vec2(f); + // Assignments to all of the above. xvupuai = vec2(u, 43); xvupaiu = vec2(42, u); @@ -224,4 +270,8 @@ fn mixed_constant_and_runtime_arguments() { xafpai_f = array(1, f); xaip_iai = array(i, 2); xaipai_i = array(1, i); + + xvisi = vec2(i); + xvusu = vec2(u); + xvfsf = vec2(f); } diff --git a/naga/tests/in/wgsl/constructors.wgsl b/naga/tests/in/wgsl/constructors.wgsl index 8157ebbf8..6033c1921 100644 --- a/naga/tests/in/wgsl/constructors.wgsl +++ b/naga/tests/in/wgsl/constructors.wgsl @@ -3,7 +3,7 @@ struct Foo { b: i32, } -// const const1 = vec3(0.0); // TODO: this is now a splat and we need to const eval it +const const1 = vec3(0.0); const const2 = vec3(0.0, 1.0, 2.0); const const3 = mat2x2(0.0, 1.0, 2.0, 3.0); const const4 = array, 1>(mat2x2(0.0, 1.0, 2.0, 3.0)); @@ -19,9 +19,8 @@ const cz6 = array(); const cz7 = Foo(); // constructors that infer their type from their parameters -// TODO: these also contain splats -// const cp1 = vec2(0u); -// const cp2 = mat2x2(vec2(0.), vec2(0.)); +const cp1 = vec2(0u); +const cp2 = mat2x2(vec2(0.), vec2(0.)); const cp3 = array(0, 1, 2, 3); @compute @workgroup_size(1) @@ -49,6 +48,8 @@ fn main() { let zvc5 = mat2x2(); let zvc6 = array(); let zvc7 = Foo(); + let zvc8: vec2 = vec2(); + let zvc9: vec2 = vec2(); // constructors that infer their type from their parameters let cit0 = vec2(0u); diff --git a/naga/tests/in/wgsl/conversions.wgsl b/naga/tests/in/wgsl/conversions.wgsl new file mode 100644 index 000000000..1209236a7 --- /dev/null +++ b/naga/tests/in/wgsl/conversions.wgsl @@ -0,0 +1,16 @@ +// Conversion of initializer expressions +// (the abstract-types-* tests have a bunch more like this) +const ic0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + +// Conversion by value constructors +//let vc0 = i32(1.0); // https://github.com/gfx-rs/wgpu/issues/7312 +// etc. (also create the locals versions below) + +@compute @workgroup_size(1) +fn main() { + const ic0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + + let lc0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); + + var vc0: vec2f = vec2(1, 1) + vec2(1.0, 1.0); +} diff --git a/naga/tests/in/wgsl/type-inference.wgsl b/naga/tests/in/wgsl/type-inference.wgsl new file mode 100644 index 000000000..627445793 --- /dev/null +++ b/naga/tests/in/wgsl/type-inference.wgsl @@ -0,0 +1,64 @@ +const g0 = 1; +const g1 = 1u; +const g2 = 1.0; +const g3 = 1.0f; +const g4 = vec4(); +const g5 = vec4(1i); +const g6 = mat2x2(vec2(), vec2()); +const g7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + +@compute @workgroup_size(1) +fn main() { + // Expose some constants that wouldn't otherwise be in the output + // because they don't have concrete types. + var g0x = g0; + var g2x = g2; + var g7x = g7; + + const c0 = 1; + const c1 = 1u; + const c2 = 1.0; + const c3 = 1.0f; + const c4 = vec4(); + const c5 = vec4(1i); + const c6 = mat2x2(vec2(), vec2()); + const c7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + + // Local constants are not emitted in most cases. + // See logic for `Statement::Emit` in `back::wgsl::Writer::write_stmt`. + var c0x = c0; + var c1x = c1; + var c2x = c2; + var c3x = c3; + var c4x = c4; + var c5x = c5; + var c6x = c6; + var c7x = c7; + + let l0 = 1; + let l1 = 1u; + let l2 = 1.0; + let l3 = 1.0f; + let l4 = vec4(); + let l5 = vec4(1i); + let l6 = mat2x2(vec2(), vec2()); + let l7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); + + // Let bindings that evaluate to literals or a `ZeroValue` expression are + // not emitted. See `ConstantEvaluator::append_expr`. `vec4(1i)` is emitted + // because it is translated to a `Splat` expression. + var l0x = l0; + var l1x = l1; + var l2x = l2; + var l3x = l3; + var l4x = l4; + + var v0 = 1; + var v1 = 1u; + var v2 = 1.0; + var v3 = 1.0f; + var v4 = vec4(); + var v5 = vec4(1i); + var v6 = mat2x2(vec2(), vec2()); + var v7 = mat2x2(vec2(1.0, 1), vec2(1, 1)); +} diff --git a/naga/tests/naga/wgsl_errors.rs b/naga/tests/naga/wgsl_errors.rs index 3f649c601..56133cbed 100644 --- a/naga/tests/naga/wgsl_errors.rs +++ b/naga/tests/naga/wgsl_errors.rs @@ -202,14 +202,14 @@ fn type_not_inferable() { check( r#" fn x() { - _ = vec2(); + _ = mat2x2(); } "#, r#"error: type can't be inferred ┌─ wgsl:3:21 │ -3 │ _ = vec2(); - │ ^^^^ type can't be inferred +3 │ _ = mat2x2(); + │ ^^^^^^ type can't be inferred "#, ); diff --git a/naga/tests/out/glsl/constructors.main.Compute.glsl b/naga/tests/out/glsl/constructors.main.Compute.glsl index ef31b76d9..baa772e5b 100644 --- a/naga/tests/out/glsl/constructors.main.Compute.glsl +++ b/naga/tests/out/glsl/constructors.main.Compute.glsl @@ -9,6 +9,7 @@ struct Foo { vec4 a; int b; }; +const vec3 const1_ = vec3(0.0); const mat2x2 const3_ = mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0)); const mat2x2 const4_[1] = mat2x2[1](mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0))); const bool cz0_ = false; @@ -19,6 +20,7 @@ const uvec2 cz4_ = uvec2(0u); const mat2x2 cz5_ = mat2x2(0.0); const Foo cz6_[3] = Foo[3](Foo(vec4(0.0), 0), Foo(vec4(0.0), 0), Foo(vec4(0.0), 0)); const Foo cz7_ = Foo(vec4(0.0), 0); +const uvec2 cp1_ = uvec2(0u); void main() { @@ -26,6 +28,8 @@ void main() { foo = Foo(vec4(1.0), 1); mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); mat4x4 m1_ = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + uvec2 zvc8_ = uvec2(0u, 0u); + vec2 zvc9_ = vec2(0.0, 0.0); uvec2 cit0_ = uvec2(0u); mat2x2 cit1_ = mat2x2(vec2(0.0), vec2(0.0)); int cit2_[4] = int[4](0, 1, 2, 3); diff --git a/naga/tests/out/glsl/conversions.main.Compute.glsl b/naga/tests/out/glsl/conversions.main.Compute.glsl new file mode 100644 index 000000000..99f739cd6 --- /dev/null +++ b/naga/tests/out/glsl/conversions.main.Compute.glsl @@ -0,0 +1,16 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const vec2 ic0_ = vec2(2.0, 2.0); + + +void main() { + vec2 vc0_ = vec2(2.0, 2.0); + vec2 lc0_ = vec2(2.0, 2.0); + return; +} + diff --git a/naga/tests/out/glsl/type-inference.main.Compute.glsl b/naga/tests/out/glsl/type-inference.main.Compute.glsl new file mode 100644 index 000000000..08c9f63e3 --- /dev/null +++ b/naga/tests/out/glsl/type-inference.main.Compute.glsl @@ -0,0 +1,50 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +const uint g1_ = 1u; +const float g3_ = 1.0; +const ivec4 g4_ = ivec4(0); +const ivec4 g5_ = ivec4(1); +const mat2x2 g6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + + +void main() { + int g0x = 1; + float g2x = 1.0; + mat2x2 g7x = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + int c0x = 1; + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + ivec4 c4x = ivec4(0); + ivec4 c5x = ivec4(1); + mat2x2 c6x = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 c7x = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + int l0x = 0; + uint l1x = 0u; + float l2x = 0.0; + float l3x = 0.0; + ivec4 l4x = ivec4(0); + int v0_ = 1; + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + ivec4 v4_ = ivec4(0); + ivec4 v5_ = ivec4(1); + mat2x2 v6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 v7_ = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + ivec4 l5_ = ivec4(1); + mat2x2 l6_ = mat2x2(vec2(0.0, 0.0), vec2(0.0, 0.0)); + mat2x2 l7_ = mat2x2(vec2(1.0, 1.0), vec2(1.0, 1.0)); + l0x = 1; + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = ivec4(0); + return; +} + diff --git a/naga/tests/out/hlsl/constructors.hlsl b/naga/tests/out/hlsl/constructors.hlsl index e21548b7a..31cc241e2 100644 --- a/naga/tests/out/hlsl/constructors.hlsl +++ b/naga/tests/out/hlsl/constructors.hlsl @@ -45,6 +45,7 @@ Foo ZeroValueFoo() { return (Foo)0; } +static const float3 const1_ = (0.0).xxx; static const float2x2 const3_ = float2x2(float2(0.0, 1.0), float2(2.0, 3.0)); static const float2x2 const4_[1] = Constructarray1_float2x2_(float2x2(float2(0.0, 1.0), float2(2.0, 3.0))); static const bool cz0_ = ZeroValuebool(); @@ -55,6 +56,7 @@ static const uint2 cz4_ = ZeroValueuint2(); static const float2x2 cz5_ = ZeroValuefloat2x2(); static const Foo cz6_[3] = ZeroValuearray3_Foo_(); static const Foo cz7_ = ZeroValueFoo(); +static const uint2 cp1_ = (0u).xx; Foo ConstructFoo(float4 arg0, int arg1) { Foo ret = (Foo)0; @@ -81,6 +83,8 @@ void main() foo = ConstructFoo((1.0).xxxx, int(1)); float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)); float4x4 m1_ = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0)); + uint2 zvc8_ = uint2(0u, 0u); + float2 zvc9_ = float2(0.0, 0.0); uint2 cit0_ = (0u).xx; float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx); int cit2_[4] = Constructarray4_int_(int(0), int(1), int(2), int(3)); diff --git a/naga/tests/out/hlsl/conversions.hlsl b/naga/tests/out/hlsl/conversions.hlsl new file mode 100644 index 000000000..97b1c74df --- /dev/null +++ b/naga/tests/out/hlsl/conversions.hlsl @@ -0,0 +1,10 @@ +static const float2 ic0_ = float2(2.0, 2.0); + +[numthreads(1, 1, 1)] +void main() +{ + float2 vc0_ = float2(2.0, 2.0); + + float2 lc0_ = float2(2.0, 2.0); + return; +} diff --git a/naga/tests/out/hlsl/conversions.ron b/naga/tests/out/hlsl/conversions.ron new file mode 100644 index 000000000..a07b03300 --- /dev/null +++ b/naga/tests/out/hlsl/conversions.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/naga/tests/out/hlsl/type-inference.hlsl b/naga/tests/out/hlsl/type-inference.hlsl new file mode 100644 index 000000000..400b6f32f --- /dev/null +++ b/naga/tests/out/hlsl/type-inference.hlsl @@ -0,0 +1,48 @@ +int4 ZeroValueint4() { + return (int4)0; +} + +static const uint g1_ = 1u; +static const float g3_ = 1.0; +static const int4 g4_ = ZeroValueint4(); +static const int4 g5_ = (int(1)).xxxx; +static const float2x2 g6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + +[numthreads(1, 1, 1)] +void main() +{ + int g0x = int(1); + float g2x = 1.0; + float2x2 g7x = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + int c0x = int(1); + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + int4 c4x = ZeroValueint4(); + int4 c5x = (int(1)).xxxx; + float2x2 c6x = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 c7x = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + int l0x = (int)0; + uint l1x = (uint)0; + float l2x = (float)0; + float l3x = (float)0; + int4 l4x = (int4)0; + int v0_ = int(1); + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + int4 v4_ = ZeroValueint4(); + int4 v5_ = (int(1)).xxxx; + float2x2 v6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 v7_ = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + + int4 l5_ = (int(1)).xxxx; + float2x2 l6_ = float2x2(float2(0.0, 0.0), float2(0.0, 0.0)); + float2x2 l7_ = float2x2(float2(1.0, 1.0), float2(1.0, 1.0)); + l0x = int(1); + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = ZeroValueint4(); + return; +} diff --git a/naga/tests/out/hlsl/type-inference.ron b/naga/tests/out/hlsl/type-inference.ron new file mode 100644 index 000000000..a07b03300 --- /dev/null +++ b/naga/tests/out/hlsl/type-inference.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/naga/tests/out/msl/abstract-types-const.msl b/naga/tests/out/msl/abstract-types-const.msl index 35efedb44..69463268c 100644 --- a/naga/tests/out/msl/abstract-types-const.msl +++ b/naga/tests/out/msl/abstract-types-const.msl @@ -7,17 +7,30 @@ using metal::uint; struct type_7 { float inner[2]; }; +struct type_8 { + int inner[2]; +}; +struct type_9 { + uint inner[2]; +}; struct S { float f; int i; uint u; }; -constant metal::uint2 xvupaiai = metal::uint2(42u, 43u); -constant metal::float2 xvfpaiai = metal::float2(44.0, 45.0); +constant metal::int2 xvipaiai = metal::int2(42, 43); +constant metal::uint2 xvupaiai = metal::uint2(44u, 45u); +constant metal::float2 xvfpaiai = metal::float2(46.0, 47.0); +constant metal::float2 xvfpafaf = metal::float2(48.0, 49.0); +constant metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); constant metal::uint2 xvupuai = metal::uint2(42u, 43u); constant metal::uint2 xvupaiu = metal::uint2(42u, 43u); constant metal::uint2 xvuuai = metal::uint2(42u, 43u); constant metal::uint2 xvuaiu = metal::uint2(42u, 43u); +constant metal::int2 xvip = metal::int2(0, 0); +constant metal::uint2 xvup = metal::uint2(0u, 0u); +constant metal::float2 xvfp = metal::float2(0.0, 0.0); +constant metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); constant metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); constant metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); constant metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -29,6 +42,10 @@ constant metal::float2 ivfs_ai = metal::float2(1.0); constant metal::float2 ivfs_af = metal::float2(1.0); constant type_7 iafafaf = type_7 {1.0, 2.0}; constant type_7 iafaiai = type_7 {1.0, 2.0}; +constant type_8 xaipaiai = type_8 {1, 2}; +constant type_9 xaupaiai = type_9 {1u, 2u}; +constant type_7 xafpaiaf = type_7 {1.0, 2.0}; +constant type_7 xafpafai = type_7 {1.0, 2.0}; constant type_7 xafpafaf = type_7 {1.0, 2.0}; constant S s_f_i_u = S {1.0, 1, 1u}; constant S s_f_iai = S {1.0, 1, 1u}; @@ -38,6 +55,10 @@ constant S saf_i_u = S {1.0, 1, 1u}; constant S saf_iai = S {1.0, 1, 1u}; constant S safai_u = S {1.0, 1, 1u}; constant S safaiai = S {1.0, 1, 1u}; +constant metal::int2 xvisai = metal::int2(1); +constant metal::uint2 xvusai = metal::uint2(1u); +constant metal::float2 xvfsai = metal::float2(1.0); +constant metal::float2 xvfsaf = metal::float2(1.0); constant metal::float3 ivfr_f_f = metal::float3(metal::float2(1.0, 2.0), 3.0); constant metal::float3 ivfr_f_af = metal::float3(metal::float2(1.0, 2.0), 3.0); constant metal::float3 ivfraf_f = metal::float3(metal::float2(1.0, 2.0), 3.0); diff --git a/naga/tests/out/msl/abstract-types-let.msl b/naga/tests/out/msl/abstract-types-let.msl new file mode 100644 index 000000000..4c89b8e6b --- /dev/null +++ b/naga/tests/out/msl/abstract-types-let.msl @@ -0,0 +1,131 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +struct type_7 { + float inner[2]; +}; +struct type_8 { + int inner[2]; +}; +struct type_10 { + metal::int3 inner[1]; +}; +struct type_12 { + metal::float3 inner[1]; +}; + +void all_constant_arguments( +) { + metal::int2 xvipaiai = metal::int2(42, 43); + metal::uint2 xvupaiai = metal::uint2(44u, 45u); + metal::float2 xvfpaiai = metal::float2(46.0, 47.0); + metal::float2 xvfpafaf = metal::float2(48.0, 49.0); + metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); + metal::uint2 xvupuai = metal::uint2(42u, 43u); + metal::uint2 xvupaiu = metal::uint2(42u, 43u); + metal::uint2 xvuuai = metal::uint2(42u, 43u); + metal::uint2 xvuaiu = metal::uint2(42u, 43u); + metal::int2 xvip = metal::int2(0, 0); + metal::uint2 xvup = metal::uint2(0u, 0u); + metal::float2 xvfp = metal::float2(0.0, 0.0); + metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiafai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiaiaf = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfp_faiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpai_faiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiai_fai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::float2x2 xmfpaiaiai_f = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); + metal::int2 xvispai = metal::int2(1); + metal::float2 xvfspaf = metal::float2(1.0); + metal::int2 xvis_ai = metal::int2(1); + metal::uint2 xvus_ai = metal::uint2(1u); + metal::float2 xvfs_ai = metal::float2(1.0); + metal::float2 xvfs_af = metal::float2(1.0); + type_7 xafafaf = type_7 {1.0, 2.0}; + type_7 xaf_faf = type_7 {1.0, 2.0}; + type_7 xafaf_f = type_7 {1.0, 2.0}; + type_7 xafaiai = type_7 {1.0, 2.0}; + type_8 xai_iai = type_8 {1, 2}; + type_8 xaiai_i = type_8 {1, 2}; + type_8 xaipaiai = type_8 {1, 2}; + type_7 xafpaiai = type_7 {1.0, 2.0}; + type_7 xafpaiaf = type_7 {1.0, 2.0}; + type_7 xafpafai = type_7 {1.0, 2.0}; + type_7 xafpafaf = type_7 {1.0, 2.0}; + type_10 xavipai = type_10 {metal::int3(1)}; + type_12 xavfpai = type_12 {metal::float3(1.0)}; + type_12 xavfpaf = type_12 {metal::float3(1.0)}; + metal::int2 xvisai = metal::int2(1); + metal::uint2 xvusai = metal::uint2(1u); + metal::float2 xvfsai = metal::float2(1.0); + metal::float2 xvfsaf = metal::float2(1.0); + type_8 iaipaiai = type_8 {1, 2}; + type_7 iafpaiaf = type_7 {1.0, 2.0}; + type_7 iafpafai = type_7 {1.0, 2.0}; + type_7 iafpafaf = type_7 {1.0, 2.0}; + return; +} + +void mixed_constant_and_runtime_arguments( +) { + uint u = {}; + int i = {}; + float f = {}; + uint _e3 = u; + metal::uint2 xvupuai_1 = metal::uint2(_e3, 43u); + uint _e6 = u; + metal::uint2 xvupaiu_1 = metal::uint2(42u, _e6); + float _e9 = f; + metal::float2 xvfpfai = metal::float2(_e9, 47.0); + float _e12 = f; + metal::float2 xvfpfaf = metal::float2(_e12, 49.0); + uint _e15 = u; + metal::uint2 xvuuai_1 = metal::uint2(_e15, 43u); + uint _e18 = u; + metal::uint2 xvuaiu_1 = metal::uint2(42u, _e18); + float _e21 = f; + metal::float2x2 xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e21, 2.0), metal::float2(3.0, 4.0)); + float _e28 = f; + metal::float2x2 xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e28), metal::float2(3.0, 4.0)); + float _e35 = f; + metal::float2x2 xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e35, 4.0)); + float _e42 = f; + metal::float2x2 xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e42)); + float _e49 = f; + type_7 xaf_faf_1 = type_7 {_e49, 2.0}; + float _e52 = f; + type_7 xafaf_f_1 = type_7 {1.0, _e52}; + float _e55 = f; + type_7 xaf_fai = type_7 {_e55, 2.0}; + float _e58 = f; + type_7 xafai_f = type_7 {1.0, _e58}; + int _e61 = i; + type_8 xai_iai_1 = type_8 {_e61, 2}; + int _e64 = i; + type_8 xaiai_i_1 = type_8 {1, _e64}; + float _e67 = f; + type_7 xafp_faf = type_7 {_e67, 2.0}; + float _e70 = f; + type_7 xafpaf_f = type_7 {1.0, _e70}; + float _e73 = f; + type_7 xafp_fai = type_7 {_e73, 2.0}; + float _e76 = f; + type_7 xafpai_f = type_7 {1.0, _e76}; + int _e79 = i; + type_8 xaip_iai = type_8 {_e79, 2}; + int _e82 = i; + type_8 xaipai_i = type_8 {1, _e82}; + int _e85 = i; + metal::int2 xvisi = metal::int2(_e85); + uint _e87 = u; + metal::uint2 xvusu = metal::uint2(_e87); + float _e89 = f; + metal::float2 xvfsf = metal::float2(_e89); + return; +} diff --git a/naga/tests/out/msl/abstract-types-var.msl b/naga/tests/out/msl/abstract-types-var.msl index da88a396e..efb7998dd 100644 --- a/naga/tests/out/msl/abstract-types-var.msl +++ b/naga/tests/out/msl/abstract-types-var.msl @@ -10,10 +10,13 @@ struct type_7 { struct type_8 { int inner[2]; }; -struct type_10 { +struct type_9 { + uint inner[2]; +}; +struct type_11 { metal::int3 inner[1]; }; -struct type_12 { +struct type_13 { metal::float3 inner[1]; }; @@ -22,10 +25,16 @@ void all_constant_arguments( metal::int2 xvipaiai = metal::int2(42, 43); metal::uint2 xvupaiai = metal::uint2(44u, 45u); metal::float2 xvfpaiai = metal::float2(46.0, 47.0); + metal::float2 xvfpafaf = metal::float2(48.0, 49.0); + metal::float2 xvfpaiaf = metal::float2(48.0, 49.0); metal::uint2 xvupuai = metal::uint2(42u, 43u); metal::uint2 xvupaiu = metal::uint2(42u, 43u); metal::uint2 xvuuai = metal::uint2(42u, 43u); metal::uint2 xvuaiu = metal::uint2(42u, 43u); + metal::int2 xvip = metal::int2(0, 0); + metal::uint2 xvup = metal::uint2(0u, 0u); + metal::float2 xvfp = metal::float2(0.0, 0.0); + metal::float2x2 xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); metal::float2x2 xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); metal::float2x2 xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); metal::float2x2 xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -52,9 +61,13 @@ void all_constant_arguments( type_7 xafpaiaf = type_7 {1.0, 2.0}; type_7 xafpafai = type_7 {1.0, 2.0}; type_7 xafpafaf = type_7 {1.0, 2.0}; - type_10 xavipai = type_10 {metal::int3(1)}; - type_12 xavfpai = type_12 {metal::float3(1.0)}; - type_12 xavfpaf = type_12 {metal::float3(1.0)}; + type_11 xavipai = type_11 {metal::int3(1)}; + type_13 xavfpai = type_13 {metal::float3(1.0)}; + type_13 xavfpaf = type_13 {metal::float3(1.0)}; + metal::int2 xvisai = metal::int2(1); + metal::uint2 xvusai = metal::uint2(1u); + metal::float2 xvfsai = metal::float2(1.0); + metal::float2 xvfsaf = metal::float2(1.0); type_8 iaipaiai = type_8 {1, 2}; type_7 iafpaiaf = type_7 {1.0, 2.0}; type_7 iafpafai = type_7 {1.0, 2.0}; @@ -62,10 +75,16 @@ void all_constant_arguments( xvipaiai = metal::int2(42, 43); xvupaiai = metal::uint2(44u, 45u); xvfpaiai = metal::float2(46.0, 47.0); + xvfpafaf = metal::float2(48.0, 49.0); + xvfpaiaf = metal::float2(48.0, 49.0); xvupuai = metal::uint2(42u, 43u); xvupaiu = metal::uint2(42u, 43u); xvuuai = metal::uint2(42u, 43u); xvuaiu = metal::uint2(42u, 43u); + xvip = metal::int2(0, 0); + xvup = metal::uint2(0u, 0u); + xvfp = metal::float2(0.0, 0.0); + xmfp = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); xmfpaiaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); xmfpafaiaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); xmfpaiafaiai = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, 4.0)); @@ -92,9 +111,13 @@ void all_constant_arguments( xafpaiaf = type_7 {1.0, 2.0}; xafpafai = type_7 {1.0, 2.0}; xafpafaf = type_7 {1.0, 2.0}; - xavipai = type_10 {metal::int3(1)}; - xavfpai = type_12 {metal::float3(1.0)}; - xavfpaf = type_12 {metal::float3(1.0)}; + xavipai = type_11 {metal::int3(1)}; + xavfpai = type_13 {metal::float3(1.0)}; + xavfpaf = type_13 {metal::float3(1.0)}; + xvisai = metal::int2(1); + xvusai = metal::uint2(1u); + xvfsai = metal::float2(1.0); + xvfsaf = metal::float2(1.0); iaipaiai = type_8 {1, 2}; iafpaiaf = type_7 {1.0, 2.0}; iafpafai = type_7 {1.0, 2.0}; @@ -109,6 +132,8 @@ void mixed_constant_and_runtime_arguments( float f = {}; metal::uint2 xvupuai_1 = {}; metal::uint2 xvupaiu_1 = {}; + metal::float2 xvfpfai = {}; + metal::float2 xvfpfaf = {}; metal::uint2 xvuuai_1 = {}; metal::uint2 xvuaiu_1 = {}; metal::float2x2 xmfp_faiaiai_1 = {}; @@ -127,85 +152,104 @@ void mixed_constant_and_runtime_arguments( type_7 xafpai_f = {}; type_8 xaip_iai = {}; type_8 xaipai_i = {}; + metal::int2 xvisi = {}; + metal::uint2 xvusu = {}; + metal::float2 xvfsf = {}; uint _e3 = u; xvupuai_1 = metal::uint2(_e3, 43u); uint _e7 = u; xvupaiu_1 = metal::uint2(42u, _e7); - uint _e11 = u; - xvuuai_1 = metal::uint2(_e11, 43u); - uint _e15 = u; - xvuaiu_1 = metal::uint2(42u, _e15); - float _e19 = f; - xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e19, 2.0), metal::float2(3.0, 4.0)); + float _e11 = f; + xvfpfai = metal::float2(_e11, 47.0); + float _e15 = f; + xvfpfaf = metal::float2(_e15, 49.0); + uint _e19 = u; + xvuuai_1 = metal::uint2(_e19, 43u); + uint _e23 = u; + xvuaiu_1 = metal::uint2(42u, _e23); float _e27 = f; - xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e27), metal::float2(3.0, 4.0)); + xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e27, 2.0), metal::float2(3.0, 4.0)); float _e35 = f; - xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e35, 4.0)); + xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e35), metal::float2(3.0, 4.0)); float _e43 = f; - xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e43)); + xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e43, 4.0)); float _e51 = f; - xaf_faf_1 = type_7 {_e51, 2.0}; - float _e55 = f; - xafaf_f_1 = type_7 {1.0, _e55}; + xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e51)); float _e59 = f; - xaf_fai = type_7 {_e59, 2.0}; + xaf_faf_1 = type_7 {_e59, 2.0}; float _e63 = f; - xafai_f = type_7 {1.0, _e63}; - int _e67 = i; - xai_iai_1 = type_8 {_e67, 2}; - int _e71 = i; - xaiai_i_1 = type_8 {1, _e71}; - float _e75 = f; - xafp_faf = type_7 {_e75, 2.0}; - float _e79 = f; - xafpaf_f = type_7 {1.0, _e79}; + xafaf_f_1 = type_7 {1.0, _e63}; + float _e67 = f; + xaf_fai = type_7 {_e67, 2.0}; + float _e71 = f; + xafai_f = type_7 {1.0, _e71}; + int _e75 = i; + xai_iai_1 = type_8 {_e75, 2}; + int _e79 = i; + xaiai_i_1 = type_8 {1, _e79}; float _e83 = f; - xafp_fai = type_7 {_e83, 2.0}; + xafp_faf = type_7 {_e83, 2.0}; float _e87 = f; - xafpai_f = type_7 {1.0, _e87}; - int _e91 = i; - xaip_iai = type_8 {_e91, 2}; - int _e95 = i; - xaipai_i = type_8 {1, _e95}; - uint _e99 = u; - xvupuai_1 = metal::uint2(_e99, 43u); - uint _e102 = u; - xvupaiu_1 = metal::uint2(42u, _e102); - uint _e105 = u; - xvuuai_1 = metal::uint2(_e105, 43u); - uint _e108 = u; - xvuaiu_1 = metal::uint2(42u, _e108); - float _e111 = f; - xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e111, 2.0), metal::float2(3.0, 4.0)); - float _e118 = f; - xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e118), metal::float2(3.0, 4.0)); - float _e125 = f; - xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e125, 4.0)); - float _e132 = f; - xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e132)); - float _e139 = f; - xaf_faf_1 = type_7 {_e139, 2.0}; + xafpaf_f = type_7 {1.0, _e87}; + float _e91 = f; + xafp_fai = type_7 {_e91, 2.0}; + float _e95 = f; + xafpai_f = type_7 {1.0, _e95}; + int _e99 = i; + xaip_iai = type_8 {_e99, 2}; + int _e103 = i; + xaipai_i = type_8 {1, _e103}; + int _e107 = i; + xvisi = metal::int2(_e107); + uint _e110 = u; + xvusu = metal::uint2(_e110); + float _e113 = f; + xvfsf = metal::float2(_e113); + uint _e116 = u; + xvupuai_1 = metal::uint2(_e116, 43u); + uint _e119 = u; + xvupaiu_1 = metal::uint2(42u, _e119); + uint _e122 = u; + xvuuai_1 = metal::uint2(_e122, 43u); + uint _e125 = u; + xvuaiu_1 = metal::uint2(42u, _e125); + float _e128 = f; + xmfp_faiaiai_1 = metal::float2x2(metal::float2(_e128, 2.0), metal::float2(3.0, 4.0)); + float _e135 = f; + xmfpai_faiai_1 = metal::float2x2(metal::float2(1.0, _e135), metal::float2(3.0, 4.0)); float _e142 = f; - xafaf_f_1 = type_7 {1.0, _e142}; - float _e145 = f; - xaf_fai = type_7 {_e145, 2.0}; - float _e148 = f; - xafai_f = type_7 {1.0, _e148}; - int _e151 = i; - xai_iai_1 = type_8 {_e151, 2}; - int _e154 = i; - xaiai_i_1 = type_8 {1, _e154}; - float _e157 = f; - xafp_faf = type_7 {_e157, 2.0}; - float _e160 = f; - xafpaf_f = type_7 {1.0, _e160}; - float _e163 = f; - xafp_fai = type_7 {_e163, 2.0}; - float _e166 = f; - xafpai_f = type_7 {1.0, _e166}; - int _e169 = i; - xaip_iai = type_8 {_e169, 2}; - int _e172 = i; - xaipai_i = type_8 {1, _e172}; + xmfpaiai_fai_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(_e142, 4.0)); + float _e149 = f; + xmfpaiaiai_f_1 = metal::float2x2(metal::float2(1.0, 2.0), metal::float2(3.0, _e149)); + float _e156 = f; + xaf_faf_1 = type_7 {_e156, 2.0}; + float _e159 = f; + xafaf_f_1 = type_7 {1.0, _e159}; + float _e162 = f; + xaf_fai = type_7 {_e162, 2.0}; + float _e165 = f; + xafai_f = type_7 {1.0, _e165}; + int _e168 = i; + xai_iai_1 = type_8 {_e168, 2}; + int _e171 = i; + xaiai_i_1 = type_8 {1, _e171}; + float _e174 = f; + xafp_faf = type_7 {_e174, 2.0}; + float _e177 = f; + xafpaf_f = type_7 {1.0, _e177}; + float _e180 = f; + xafp_fai = type_7 {_e180, 2.0}; + float _e183 = f; + xafpai_f = type_7 {1.0, _e183}; + int _e186 = i; + xaip_iai = type_8 {_e186, 2}; + int _e189 = i; + xaipai_i = type_8 {1, _e189}; + int _e192 = i; + xvisi = metal::int2(_e192); + uint _e194 = u; + xvusu = metal::uint2(_e194); + float _e196 = f; + xvfsf = metal::float2(_e196); return; } diff --git a/naga/tests/out/msl/constructors.msl b/naga/tests/out/msl/constructors.msl index 3e2c09622..a1d1c8a2e 100644 --- a/naga/tests/out/msl/constructors.msl +++ b/naga/tests/out/msl/constructors.msl @@ -8,25 +8,27 @@ struct Foo { metal::float4 a; int b; }; -struct type_5 { +struct type_6 { metal::float2x2 inner[1]; }; -struct type_9 { +struct type_10 { Foo inner[3]; }; -struct type_11 { +struct type_12 { int inner[4]; }; +constant metal::float3 const1_ = metal::float3(0.0); constant metal::float2x2 const3_ = metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0)); -constant type_5 const4_ = type_5 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))}; +constant type_6 const4_ = type_6 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))}; constant bool cz0_ = bool {}; constant int cz1_ = int {}; constant uint cz2_ = uint {}; constant float cz3_ = float {}; constant metal::uint2 cz4_ = metal::uint2 {}; constant metal::float2x2 cz5_ = metal::float2x2 {}; -constant type_9 cz6_ = type_9 {}; +constant type_10 cz6_ = type_10 {}; constant Foo cz7_ = Foo {}; +constant metal::uint2 cp1_ = metal::uint2(0u); kernel void main_( ) { @@ -34,9 +36,11 @@ kernel void main_( foo = Foo {metal::float4(1.0), 1}; metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0)); metal::float4x4 m1_ = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0)); + metal::uint2 zvc8_ = metal::uint2(0u, 0u); + metal::float2 zvc9_ = metal::float2(0.0, 0.0); metal::uint2 cit0_ = metal::uint2(0u); metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0)); - type_11 cit2_ = type_11 {0, 1, 2, 3}; + type_12 cit2_ = type_12 {0, 1, 2, 3}; metal::uint2 ic4_ = metal::uint2(0u, 0u); metal::float2x3 ic5_ = metal::float2x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); return; diff --git a/naga/tests/out/msl/conversions.msl b/naga/tests/out/msl/conversions.msl new file mode 100644 index 000000000..9af4956b0 --- /dev/null +++ b/naga/tests/out/msl/conversions.msl @@ -0,0 +1,14 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +constant metal::float2 ic0_ = metal::float2(2.0, 2.0); + +kernel void main_( +) { + metal::float2 vc0_ = metal::float2(2.0, 2.0); + metal::float2 lc0_ = metal::float2(2.0, 2.0); + return; +} diff --git a/naga/tests/out/msl/type-inference.msl b/naga/tests/out/msl/type-inference.msl new file mode 100644 index 000000000..aa0b1ff8b --- /dev/null +++ b/naga/tests/out/msl/type-inference.msl @@ -0,0 +1,48 @@ +// language: metal1.0 +#include +#include + +using metal::uint; + +constant uint g1_ = 1u; +constant float g3_ = 1.0; +constant metal::int4 g4_ = metal::int4 {}; +constant metal::int4 g5_ = metal::int4(1); +constant metal::float2x2 g6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + +kernel void main_( +) { + int g0x = 1; + float g2x = 1.0; + metal::float2x2 g7x = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + int c0x = 1; + uint c1x = 1u; + float c2x = 1.0; + float c3x = 1.0; + metal::int4 c4x = metal::int4 {}; + metal::int4 c5x = metal::int4(1); + metal::float2x2 c6x = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 c7x = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + int l0x = {}; + uint l1x = {}; + float l2x = {}; + float l3x = {}; + metal::int4 l4x = {}; + int v0_ = 1; + uint v1_ = 1u; + float v2_ = 1.0; + float v3_ = 1.0; + metal::int4 v4_ = metal::int4 {}; + metal::int4 v5_ = metal::int4(1); + metal::float2x2 v6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 v7_ = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + metal::int4 l5_ = metal::int4(1); + metal::float2x2 l6_ = metal::float2x2(metal::float2(0.0, 0.0), metal::float2(0.0, 0.0)); + metal::float2x2 l7_ = metal::float2x2(metal::float2(1.0, 1.0), metal::float2(1.0, 1.0)); + l0x = 1; + l1x = 1u; + l2x = 1.0; + l3x = 1.0; + l4x = metal::int4 {}; + return; +} diff --git a/naga/tests/out/spv/abstract-types-const.spvasm b/naga/tests/out/spv/abstract-types-const.spvasm index af8cfb028..b1da55273 100644 --- a/naga/tests/out/spv/abstract-types-const.spvasm +++ b/naga/tests/out/spv/abstract-types-const.spvasm @@ -1,46 +1,69 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 36 +; Bound: 57 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpDecorate %10 ArrayStride 4 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 4 -OpMemberDecorate %12 2 Offset 8 +OpDecorate %12 ArrayStride 4 +OpDecorate %13 ArrayStride 4 +OpMemberDecorate %14 0 Offset 0 +OpMemberDecorate %14 1 Offset 4 +OpMemberDecorate %14 2 Offset 8 %2 = OpTypeVoid -%3 = OpTypeInt 32 0 +%3 = OpTypeInt 32 1 %4 = OpTypeVector %3 2 -%5 = OpTypeFloat 32 +%5 = OpTypeInt 32 0 %6 = OpTypeVector %5 2 -%7 = OpTypeMatrix %6 2 -%8 = OpTypeInt 32 1 -%9 = OpTypeVector %8 2 -%11 = OpConstant %3 2 -%10 = OpTypeArray %5 %11 -%12 = OpTypeStruct %5 %8 %3 -%13 = OpTypeVector %5 3 -%14 = OpConstant %3 42 -%15 = OpConstant %3 43 -%16 = OpConstantComposite %4 %14 %15 -%17 = OpConstant %5 44.0 -%18 = OpConstant %5 45.0 -%19 = OpConstantComposite %6 %17 %18 -%20 = OpConstant %5 1.0 -%21 = OpConstant %5 2.0 -%22 = OpConstantComposite %6 %20 %21 -%23 = OpConstant %5 3.0 -%24 = OpConstant %5 4.0 -%25 = OpConstantComposite %6 %23 %24 -%26 = OpConstantComposite %7 %22 %25 -%27 = OpConstant %8 1 -%28 = OpConstantComposite %9 %27 %27 -%29 = OpConstant %3 1 -%30 = OpConstantComposite %4 %29 %29 -%31 = OpConstantComposite %6 %20 %20 -%32 = OpConstantComposite %10 %20 %21 -%33 = OpConstantComposite %12 %20 %27 %29 -%34 = OpConstantComposite %13 %20 %21 %23 -%35 = OpConstantComposite %6 %21 %23 \ No newline at end of file +%7 = OpTypeFloat 32 +%8 = OpTypeVector %7 2 +%9 = OpTypeMatrix %8 2 +%11 = OpConstant %5 2 +%10 = OpTypeArray %7 %11 +%12 = OpTypeArray %3 %11 +%13 = OpTypeArray %5 %11 +%14 = OpTypeStruct %7 %3 %5 +%15 = OpTypeVector %7 3 +%16 = OpConstant %3 42 +%17 = OpConstant %3 43 +%18 = OpConstantComposite %4 %16 %17 +%19 = OpConstant %5 44 +%20 = OpConstant %5 45 +%21 = OpConstantComposite %6 %19 %20 +%22 = OpConstant %7 46.0 +%23 = OpConstant %7 47.0 +%24 = OpConstantComposite %8 %22 %23 +%25 = OpConstant %7 48.0 +%26 = OpConstant %7 49.0 +%27 = OpConstantComposite %8 %25 %26 +%28 = OpConstant %5 42 +%29 = OpConstant %5 43 +%30 = OpConstantComposite %6 %28 %29 +%31 = OpConstant %3 0 +%32 = OpConstantComposite %4 %31 %31 +%33 = OpConstant %5 0 +%34 = OpConstantComposite %6 %33 %33 +%35 = OpConstant %7 0.0 +%36 = OpConstantComposite %8 %35 %35 +%37 = OpConstantComposite %9 %36 %36 +%38 = OpConstant %7 1.0 +%39 = OpConstant %7 2.0 +%40 = OpConstantComposite %8 %38 %39 +%41 = OpConstant %7 3.0 +%42 = OpConstant %7 4.0 +%43 = OpConstantComposite %8 %41 %42 +%44 = OpConstantComposite %9 %40 %43 +%45 = OpConstant %3 1 +%46 = OpConstantComposite %4 %45 %45 +%47 = OpConstant %5 1 +%48 = OpConstantComposite %6 %47 %47 +%49 = OpConstantComposite %8 %38 %38 +%50 = OpConstantComposite %10 %38 %39 +%51 = OpConstant %3 2 +%52 = OpConstantComposite %12 %45 %51 +%53 = OpConstantComposite %13 %47 %11 +%54 = OpConstantComposite %14 %38 %45 %47 +%55 = OpConstantComposite %15 %38 %39 %41 +%56 = OpConstantComposite %8 %39 %41 \ No newline at end of file diff --git a/naga/tests/out/spv/abstract-types-let.spvasm b/naga/tests/out/spv/abstract-types-let.spvasm new file mode 100644 index 000000000..af8da8707 --- /dev/null +++ b/naga/tests/out/spv/abstract-types-let.spvasm @@ -0,0 +1,144 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 128 +OpCapability Shader +OpCapability Linkage +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpDecorate %10 ArrayStride 4 +OpDecorate %12 ArrayStride 4 +OpDecorate %14 ArrayStride 16 +OpDecorate %17 ArrayStride 16 +%2 = OpTypeVoid +%3 = OpTypeInt 32 1 +%4 = OpTypeVector %3 2 +%5 = OpTypeInt 32 0 +%6 = OpTypeVector %5 2 +%7 = OpTypeFloat 32 +%8 = OpTypeVector %7 2 +%9 = OpTypeMatrix %8 2 +%11 = OpConstant %5 2 +%10 = OpTypeArray %7 %11 +%12 = OpTypeArray %3 %11 +%13 = OpTypeVector %3 3 +%15 = OpConstant %5 1 +%14 = OpTypeArray %13 %15 +%16 = OpTypeVector %7 3 +%17 = OpTypeArray %16 %15 +%20 = OpTypeFunction %2 +%21 = OpConstant %3 42 +%22 = OpConstant %3 43 +%23 = OpConstantComposite %4 %21 %22 +%24 = OpConstant %5 44 +%25 = OpConstant %5 45 +%26 = OpConstantComposite %6 %24 %25 +%27 = OpConstant %7 46.0 +%28 = OpConstant %7 47.0 +%29 = OpConstantComposite %8 %27 %28 +%30 = OpConstant %7 48.0 +%31 = OpConstant %7 49.0 +%32 = OpConstantComposite %8 %30 %31 +%33 = OpConstant %5 42 +%34 = OpConstant %5 43 +%35 = OpConstantComposite %6 %33 %34 +%36 = OpConstant %3 0 +%37 = OpConstantComposite %4 %36 %36 +%38 = OpConstant %5 0 +%39 = OpConstantComposite %6 %38 %38 +%40 = OpConstant %7 0.0 +%41 = OpConstantComposite %8 %40 %40 +%42 = OpConstantComposite %9 %41 %41 +%43 = OpConstant %7 1.0 +%44 = OpConstant %7 2.0 +%45 = OpConstantComposite %8 %43 %44 +%46 = OpConstant %7 3.0 +%47 = OpConstant %7 4.0 +%48 = OpConstantComposite %8 %46 %47 +%49 = OpConstantComposite %9 %45 %48 +%50 = OpConstant %3 1 +%51 = OpConstantComposite %4 %50 %50 +%52 = OpConstantComposite %8 %43 %43 +%53 = OpConstantComposite %6 %15 %15 +%54 = OpConstantComposite %10 %43 %44 +%55 = OpConstant %3 2 +%56 = OpConstantComposite %12 %50 %55 +%57 = OpConstantComposite %13 %50 %50 %50 +%58 = OpConstantComposite %14 %57 +%59 = OpConstantComposite %16 %43 %43 %43 +%60 = OpConstantComposite %17 %59 +%65 = OpTypePointer Function %5 +%66 = OpConstantNull %5 +%68 = OpTypePointer Function %3 +%69 = OpConstantNull %3 +%71 = OpTypePointer Function %7 +%72 = OpConstantNull %7 +%19 = OpFunction %2 None %20 +%18 = OpLabel +OpBranch %61 +%61 = OpLabel +OpReturn +OpFunctionEnd +%63 = OpFunction %2 None %20 +%62 = OpLabel +%64 = OpVariable %65 Function %66 +%67 = OpVariable %68 Function %69 +%70 = OpVariable %71 Function %72 +OpBranch %73 +%73 = OpLabel +%74 = OpLoad %5 %64 +%75 = OpCompositeConstruct %6 %74 %34 +%76 = OpLoad %5 %64 +%77 = OpCompositeConstruct %6 %33 %76 +%78 = OpLoad %7 %70 +%79 = OpCompositeConstruct %8 %78 %28 +%80 = OpLoad %7 %70 +%81 = OpCompositeConstruct %8 %80 %31 +%82 = OpLoad %5 %64 +%83 = OpCompositeConstruct %6 %82 %34 +%84 = OpLoad %5 %64 +%85 = OpCompositeConstruct %6 %33 %84 +%86 = OpLoad %7 %70 +%87 = OpCompositeConstruct %8 %86 %44 +%88 = OpCompositeConstruct %9 %87 %48 +%89 = OpLoad %7 %70 +%90 = OpCompositeConstruct %8 %43 %89 +%91 = OpCompositeConstruct %9 %90 %48 +%92 = OpLoad %7 %70 +%93 = OpCompositeConstruct %8 %92 %47 +%94 = OpCompositeConstruct %9 %45 %93 +%95 = OpLoad %7 %70 +%96 = OpCompositeConstruct %8 %46 %95 +%97 = OpCompositeConstruct %9 %45 %96 +%98 = OpLoad %7 %70 +%99 = OpCompositeConstruct %10 %98 %44 +%100 = OpLoad %7 %70 +%101 = OpCompositeConstruct %10 %43 %100 +%102 = OpLoad %7 %70 +%103 = OpCompositeConstruct %10 %102 %44 +%104 = OpLoad %7 %70 +%105 = OpCompositeConstruct %10 %43 %104 +%106 = OpLoad %3 %67 +%107 = OpCompositeConstruct %12 %106 %55 +%108 = OpLoad %3 %67 +%109 = OpCompositeConstruct %12 %50 %108 +%110 = OpLoad %7 %70 +%111 = OpCompositeConstruct %10 %110 %44 +%112 = OpLoad %7 %70 +%113 = OpCompositeConstruct %10 %43 %112 +%114 = OpLoad %7 %70 +%115 = OpCompositeConstruct %10 %114 %44 +%116 = OpLoad %7 %70 +%117 = OpCompositeConstruct %10 %43 %116 +%118 = OpLoad %3 %67 +%119 = OpCompositeConstruct %12 %118 %55 +%120 = OpLoad %3 %67 +%121 = OpCompositeConstruct %12 %50 %120 +%122 = OpLoad %3 %67 +%123 = OpCompositeConstruct %4 %122 %122 +%124 = OpLoad %5 %64 +%125 = OpCompositeConstruct %6 %124 %124 +%126 = OpLoad %7 %70 +%127 = OpCompositeConstruct %8 %126 %126 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/abstract-types-var.spvasm b/naga/tests/out/spv/abstract-types-var.spvasm index 3c3f42b74..37354c2fc 100644 --- a/naga/tests/out/spv/abstract-types-var.spvasm +++ b/naga/tests/out/spv/abstract-types-var.spvasm @@ -1,15 +1,16 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 290 +; Bound: 350 OpCapability Shader OpCapability Linkage %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpDecorate %10 ArrayStride 4 OpDecorate %12 ArrayStride 4 -OpDecorate %14 ArrayStride 16 -OpDecorate %17 ArrayStride 16 +OpDecorate %13 ArrayStride 4 +OpDecorate %15 ArrayStride 16 +OpDecorate %18 ArrayStride 16 %2 = OpTypeVoid %3 = OpTypeInt 32 1 %4 = OpTypeVector %3 2 @@ -21,366 +22,444 @@ OpDecorate %17 ArrayStride 16 %11 = OpConstant %5 2 %10 = OpTypeArray %7 %11 %12 = OpTypeArray %3 %11 -%13 = OpTypeVector %3 3 -%15 = OpConstant %5 1 -%14 = OpTypeArray %13 %15 -%16 = OpTypeVector %7 3 -%17 = OpTypeArray %16 %15 -%18 = OpConstant %3 42 -%19 = OpConstant %3 43 -%20 = OpConstantComposite %4 %18 %19 -%21 = OpConstant %5 44 -%22 = OpConstant %5 45 -%23 = OpConstantComposite %6 %21 %22 -%24 = OpConstant %7 46.0 -%25 = OpConstant %7 47.0 -%26 = OpConstantComposite %8 %24 %25 -%27 = OpConstant %5 42 -%28 = OpConstant %5 43 -%29 = OpConstantComposite %6 %27 %28 -%30 = OpConstant %7 1.0 -%31 = OpConstant %7 2.0 -%32 = OpConstantComposite %8 %30 %31 -%33 = OpConstant %7 3.0 -%34 = OpConstant %7 4.0 -%35 = OpConstantComposite %8 %33 %34 -%36 = OpConstantComposite %9 %32 %35 -%37 = OpConstant %3 1 -%38 = OpConstantComposite %4 %37 %37 -%39 = OpConstantComposite %8 %30 %30 -%40 = OpConstantComposite %6 %15 %15 -%41 = OpConstantComposite %10 %30 %31 -%42 = OpConstant %3 2 -%43 = OpConstantComposite %12 %37 %42 -%44 = OpConstantComposite %13 %37 %37 %37 -%45 = OpConstantComposite %14 %44 -%46 = OpConstantComposite %16 %30 %30 %30 -%47 = OpConstantComposite %17 %46 -%49 = OpTypePointer Private %4 -%48 = OpVariable %49 Private %20 -%51 = OpTypePointer Private %6 -%50 = OpVariable %51 Private %23 -%53 = OpTypePointer Private %8 -%52 = OpVariable %53 Private %26 -%54 = OpVariable %51 Private %29 -%55 = OpVariable %51 Private %29 -%56 = OpVariable %51 Private %29 -%57 = OpVariable %51 Private %29 -%59 = OpTypePointer Private %9 -%58 = OpVariable %59 Private %36 -%60 = OpVariable %59 Private %36 -%61 = OpVariable %59 Private %36 -%62 = OpVariable %59 Private %36 -%63 = OpVariable %59 Private %36 -%64 = OpVariable %49 Private %38 -%65 = OpVariable %53 Private %39 -%66 = OpVariable %49 Private %38 -%67 = OpVariable %51 Private %40 -%68 = OpVariable %53 Private %39 -%69 = OpVariable %53 Private %39 -%71 = OpTypePointer Private %10 -%70 = OpVariable %71 Private %41 -%72 = OpVariable %71 Private %41 -%74 = OpTypePointer Private %12 -%73 = OpVariable %74 Private %43 -%75 = OpVariable %71 Private %41 -%76 = OpVariable %71 Private %41 -%77 = OpVariable %71 Private %41 -%79 = OpTypePointer Private %14 -%78 = OpVariable %79 Private %45 -%81 = OpTypePointer Private %17 -%80 = OpVariable %81 Private %47 -%82 = OpVariable %81 Private %47 -%83 = OpVariable %49 Private %38 -%84 = OpVariable %53 Private %39 -%85 = OpVariable %49 Private %38 -%86 = OpVariable %51 Private %40 -%87 = OpVariable %53 Private %39 -%88 = OpVariable %53 Private %39 -%89 = OpVariable %71 Private %41 -%90 = OpVariable %71 Private %41 -%91 = OpVariable %74 Private %43 -%92 = OpVariable %71 Private %41 -%93 = OpVariable %71 Private %41 -%94 = OpVariable %71 Private %41 -%95 = OpVariable %79 Private %45 -%96 = OpVariable %79 Private %45 -%97 = OpVariable %81 Private %47 -%100 = OpTypeFunction %2 -%102 = OpTypePointer Function %4 -%104 = OpTypePointer Function %6 -%106 = OpTypePointer Function %8 -%112 = OpTypePointer Function %9 -%128 = OpTypePointer Function %10 -%133 = OpTypePointer Function %12 -%141 = OpTypePointer Function %14 -%143 = OpTypePointer Function %17 -%153 = OpTypePointer Function %5 -%154 = OpConstantNull %5 -%156 = OpTypePointer Function %3 -%157 = OpConstantNull %3 -%159 = OpTypePointer Function %7 -%160 = OpConstantNull %7 -%162 = OpConstantNull %6 -%164 = OpConstantNull %6 -%166 = OpConstantNull %6 -%168 = OpConstantNull %6 -%170 = OpConstantNull %9 -%172 = OpConstantNull %9 -%174 = OpConstantNull %9 -%176 = OpConstantNull %9 -%178 = OpConstantNull %10 -%180 = OpConstantNull %10 -%182 = OpConstantNull %10 -%184 = OpConstantNull %10 -%186 = OpConstantNull %12 -%188 = OpConstantNull %12 -%190 = OpConstantNull %10 -%192 = OpConstantNull %10 -%194 = OpConstantNull %10 -%196 = OpConstantNull %10 -%198 = OpConstantNull %12 -%200 = OpConstantNull %12 -%99 = OpFunction %2 None %100 -%98 = OpLabel -%148 = OpVariable %128 Function %41 -%145 = OpVariable %133 Function %43 -%140 = OpVariable %141 Function %45 -%137 = OpVariable %128 Function %41 -%134 = OpVariable %133 Function %43 -%130 = OpVariable %128 Function %41 -%126 = OpVariable %106 Function %39 -%123 = OpVariable %102 Function %38 -%120 = OpVariable %112 Function %36 -%117 = OpVariable %112 Function %36 -%114 = OpVariable %112 Function %36 -%110 = OpVariable %104 Function %29 -%107 = OpVariable %104 Function %29 -%101 = OpVariable %102 Function %20 -%146 = OpVariable %128 Function %41 -%142 = OpVariable %143 Function %47 -%138 = OpVariable %128 Function %41 -%135 = OpVariable %133 Function %43 -%131 = OpVariable %128 Function %41 -%127 = OpVariable %128 Function %41 -%124 = OpVariable %104 Function %40 -%121 = OpVariable %102 Function %38 -%118 = OpVariable %112 Function %36 -%115 = OpVariable %112 Function %36 -%111 = OpVariable %112 Function %36 -%108 = OpVariable %104 Function %29 -%103 = OpVariable %104 Function %23 -%147 = OpVariable %128 Function %41 -%144 = OpVariable %143 Function %47 -%139 = OpVariable %128 Function %41 -%136 = OpVariable %128 Function %41 -%132 = OpVariable %133 Function %43 -%129 = OpVariable %128 Function %41 -%125 = OpVariable %106 Function %39 -%122 = OpVariable %106 Function %39 -%119 = OpVariable %112 Function %36 -%116 = OpVariable %112 Function %36 -%113 = OpVariable %112 Function %36 -%109 = OpVariable %104 Function %29 -%105 = OpVariable %106 Function %26 -OpBranch %149 -%149 = OpLabel -OpStore %101 %20 -OpStore %103 %23 -OpStore %105 %26 -OpStore %107 %29 -OpStore %108 %29 -OpStore %109 %29 -OpStore %110 %29 -OpStore %111 %36 -OpStore %113 %36 -OpStore %114 %36 -OpStore %115 %36 -OpStore %116 %36 -OpStore %117 %36 -OpStore %118 %36 -OpStore %119 %36 -OpStore %120 %36 -OpStore %121 %38 -OpStore %122 %39 -OpStore %123 %38 -OpStore %124 %40 -OpStore %125 %39 -OpStore %126 %39 -OpStore %127 %41 -OpStore %129 %41 -OpStore %130 %41 -OpStore %131 %41 -OpStore %132 %43 -OpStore %134 %43 -OpStore %135 %43 -OpStore %136 %41 -OpStore %137 %41 -OpStore %138 %41 -OpStore %139 %41 -OpStore %140 %45 +%13 = OpTypeArray %5 %11 +%14 = OpTypeVector %3 3 +%16 = OpConstant %5 1 +%15 = OpTypeArray %14 %16 +%17 = OpTypeVector %7 3 +%18 = OpTypeArray %17 %16 +%19 = OpConstant %3 42 +%20 = OpConstant %3 43 +%21 = OpConstantComposite %4 %19 %20 +%22 = OpConstant %5 44 +%23 = OpConstant %5 45 +%24 = OpConstantComposite %6 %22 %23 +%25 = OpConstant %7 46.0 +%26 = OpConstant %7 47.0 +%27 = OpConstantComposite %8 %25 %26 +%28 = OpConstant %7 48.0 +%29 = OpConstant %7 49.0 +%30 = OpConstantComposite %8 %28 %29 +%31 = OpConstant %5 42 +%32 = OpConstant %5 43 +%33 = OpConstantComposite %6 %31 %32 +%34 = OpConstant %3 0 +%35 = OpConstantComposite %4 %34 %34 +%36 = OpConstant %5 0 +%37 = OpConstantComposite %6 %36 %36 +%38 = OpConstant %7 0.0 +%39 = OpConstantComposite %8 %38 %38 +%40 = OpConstantComposite %9 %39 %39 +%41 = OpConstant %7 1.0 +%42 = OpConstant %7 2.0 +%43 = OpConstantComposite %8 %41 %42 +%44 = OpConstant %7 3.0 +%45 = OpConstant %7 4.0 +%46 = OpConstantComposite %8 %44 %45 +%47 = OpConstantComposite %9 %43 %46 +%48 = OpConstant %3 1 +%49 = OpConstantComposite %4 %48 %48 +%50 = OpConstantComposite %8 %41 %41 +%51 = OpConstantComposite %6 %16 %16 +%52 = OpConstantComposite %10 %41 %42 +%53 = OpConstant %3 2 +%54 = OpConstantComposite %12 %48 %53 +%55 = OpConstantComposite %13 %16 %11 +%56 = OpConstantComposite %14 %48 %48 %48 +%57 = OpConstantComposite %15 %56 +%58 = OpConstantComposite %17 %41 %41 %41 +%59 = OpConstantComposite %18 %58 +%61 = OpTypePointer Private %4 +%60 = OpVariable %61 Private %21 +%63 = OpTypePointer Private %6 +%62 = OpVariable %63 Private %24 +%65 = OpTypePointer Private %8 +%64 = OpVariable %65 Private %27 +%66 = OpVariable %65 Private %30 +%67 = OpVariable %65 Private %30 +%68 = OpVariable %63 Private %33 +%69 = OpVariable %63 Private %33 +%70 = OpVariable %63 Private %33 +%71 = OpVariable %63 Private %33 +%72 = OpVariable %61 Private %35 +%73 = OpVariable %63 Private %37 +%74 = OpVariable %65 Private %39 +%76 = OpTypePointer Private %9 +%75 = OpVariable %76 Private %40 +%77 = OpVariable %76 Private %47 +%78 = OpVariable %76 Private %47 +%79 = OpVariable %76 Private %47 +%80 = OpVariable %76 Private %47 +%81 = OpVariable %76 Private %47 +%82 = OpVariable %61 Private %49 +%83 = OpVariable %65 Private %50 +%84 = OpVariable %61 Private %49 +%85 = OpVariable %63 Private %51 +%86 = OpVariable %65 Private %50 +%87 = OpVariable %65 Private %50 +%89 = OpTypePointer Private %10 +%88 = OpVariable %89 Private %52 +%90 = OpVariable %89 Private %52 +%92 = OpTypePointer Private %12 +%91 = OpVariable %92 Private %54 +%94 = OpTypePointer Private %13 +%93 = OpVariable %94 Private %55 +%95 = OpVariable %89 Private %52 +%96 = OpVariable %89 Private %52 +%97 = OpVariable %89 Private %52 +%99 = OpTypePointer Private %15 +%98 = OpVariable %99 Private %57 +%101 = OpTypePointer Private %18 +%100 = OpVariable %101 Private %59 +%102 = OpVariable %101 Private %59 +%103 = OpVariable %61 Private %49 +%104 = OpVariable %63 Private %51 +%105 = OpVariable %65 Private %50 +%106 = OpVariable %65 Private %50 +%107 = OpVariable %61 Private %49 +%108 = OpVariable %65 Private %50 +%109 = OpVariable %61 Private %49 +%110 = OpVariable %63 Private %51 +%111 = OpVariable %65 Private %50 +%112 = OpVariable %65 Private %50 +%113 = OpVariable %89 Private %52 +%114 = OpVariable %89 Private %52 +%115 = OpVariable %92 Private %54 +%116 = OpVariable %89 Private %52 +%117 = OpVariable %89 Private %52 +%118 = OpVariable %89 Private %52 +%119 = OpVariable %99 Private %57 +%120 = OpVariable %99 Private %57 +%121 = OpVariable %101 Private %59 +%124 = OpTypeFunction %2 +%126 = OpTypePointer Function %4 +%128 = OpTypePointer Function %6 +%130 = OpTypePointer Function %8 +%141 = OpTypePointer Function %9 +%158 = OpTypePointer Function %10 +%163 = OpTypePointer Function %12 +%171 = OpTypePointer Function %15 +%173 = OpTypePointer Function %18 +%187 = OpTypePointer Function %5 +%188 = OpConstantNull %5 +%190 = OpTypePointer Function %3 +%191 = OpConstantNull %3 +%193 = OpTypePointer Function %7 +%194 = OpConstantNull %7 +%196 = OpConstantNull %6 +%198 = OpConstantNull %6 +%200 = OpConstantNull %8 +%202 = OpConstantNull %8 +%204 = OpConstantNull %6 +%206 = OpConstantNull %6 +%208 = OpConstantNull %9 +%210 = OpConstantNull %9 +%212 = OpConstantNull %9 +%214 = OpConstantNull %9 +%216 = OpConstantNull %10 +%218 = OpConstantNull %10 +%220 = OpConstantNull %10 +%222 = OpConstantNull %10 +%224 = OpConstantNull %12 +%226 = OpConstantNull %12 +%228 = OpConstantNull %10 +%230 = OpConstantNull %10 +%232 = OpConstantNull %10 +%234 = OpConstantNull %10 +%236 = OpConstantNull %12 +%238 = OpConstantNull %12 +%240 = OpConstantNull %4 +%242 = OpConstantNull %6 +%244 = OpConstantNull %8 +%123 = OpFunction %2 None %124 +%122 = OpLabel +%181 = OpVariable %158 Function %52 +%178 = OpVariable %130 Function %50 +%175 = OpVariable %126 Function %49 +%170 = OpVariable %171 Function %57 +%167 = OpVariable %158 Function %52 +%164 = OpVariable %163 Function %54 +%160 = OpVariable %158 Function %52 +%156 = OpVariable %130 Function %50 +%153 = OpVariable %126 Function %49 +%150 = OpVariable %141 Function %47 +%147 = OpVariable %141 Function %47 +%144 = OpVariable %141 Function %47 +%140 = OpVariable %141 Function %40 +%137 = OpVariable %126 Function %35 +%134 = OpVariable %128 Function %33 +%131 = OpVariable %130 Function %30 +%125 = OpVariable %126 Function %21 +%182 = OpVariable %158 Function %52 +%179 = OpVariable %163 Function %54 +%176 = OpVariable %128 Function %51 +%172 = OpVariable %173 Function %59 +%168 = OpVariable %158 Function %52 +%165 = OpVariable %163 Function %54 +%161 = OpVariable %158 Function %52 +%157 = OpVariable %158 Function %52 +%154 = OpVariable %128 Function %51 +%151 = OpVariable %126 Function %49 +%148 = OpVariable %141 Function %47 +%145 = OpVariable %141 Function %47 +%142 = OpVariable %141 Function %47 +%138 = OpVariable %128 Function %37 +%135 = OpVariable %128 Function %33 +%132 = OpVariable %130 Function %30 +%127 = OpVariable %128 Function %24 +%180 = OpVariable %158 Function %52 +%177 = OpVariable %130 Function %50 +%174 = OpVariable %173 Function %59 +%169 = OpVariable %158 Function %52 +%166 = OpVariable %158 Function %52 +%162 = OpVariable %163 Function %54 +%159 = OpVariable %158 Function %52 +%155 = OpVariable %130 Function %50 +%152 = OpVariable %130 Function %50 +%149 = OpVariable %141 Function %47 +%146 = OpVariable %141 Function %47 +%143 = OpVariable %141 Function %47 +%139 = OpVariable %130 Function %39 +%136 = OpVariable %128 Function %33 +%133 = OpVariable %128 Function %33 +%129 = OpVariable %130 Function %27 +OpBranch %183 +%183 = OpLabel +OpStore %125 %21 +OpStore %127 %24 +OpStore %129 %27 +OpStore %131 %30 +OpStore %132 %30 +OpStore %133 %33 +OpStore %134 %33 +OpStore %135 %33 +OpStore %136 %33 +OpStore %137 %35 +OpStore %138 %37 +OpStore %139 %39 +OpStore %140 %40 OpStore %142 %47 +OpStore %143 %47 OpStore %144 %47 -OpStore %145 %43 -OpStore %146 %41 -OpStore %147 %41 -OpStore %148 %41 +OpStore %145 %47 +OpStore %146 %47 +OpStore %147 %47 +OpStore %148 %47 +OpStore %149 %47 +OpStore %150 %47 +OpStore %151 %49 +OpStore %152 %50 +OpStore %153 %49 +OpStore %154 %51 +OpStore %155 %50 +OpStore %156 %50 +OpStore %157 %52 +OpStore %159 %52 +OpStore %160 %52 +OpStore %161 %52 +OpStore %162 %54 +OpStore %164 %54 +OpStore %165 %54 +OpStore %166 %52 +OpStore %167 %52 +OpStore %168 %52 +OpStore %169 %52 +OpStore %170 %57 +OpStore %172 %59 +OpStore %174 %59 +OpStore %175 %49 +OpStore %176 %51 +OpStore %177 %50 +OpStore %178 %50 +OpStore %179 %54 +OpStore %180 %52 +OpStore %181 %52 +OpStore %182 %52 OpReturn OpFunctionEnd -%151 = OpFunction %2 None %100 -%150 = OpLabel -%199 = OpVariable %133 Function %200 -%193 = OpVariable %128 Function %194 -%187 = OpVariable %133 Function %188 -%181 = OpVariable %128 Function %182 -%175 = OpVariable %112 Function %176 -%169 = OpVariable %112 Function %170 -%163 = OpVariable %104 Function %164 -%155 = OpVariable %156 Function %157 -%197 = OpVariable %133 Function %198 -%191 = OpVariable %128 Function %192 -%185 = OpVariable %133 Function %186 -%179 = OpVariable %128 Function %180 -%173 = OpVariable %112 Function %174 -%167 = OpVariable %104 Function %168 -%161 = OpVariable %104 Function %162 -%152 = OpVariable %153 Function %154 +%185 = OpFunction %2 None %124 +%184 = OpLabel +%239 = OpVariable %126 Function %240 +%233 = OpVariable %158 Function %234 +%227 = OpVariable %158 Function %228 +%221 = OpVariable %158 Function %222 +%215 = OpVariable %158 Function %216 +%209 = OpVariable %141 Function %210 +%203 = OpVariable %128 Function %204 +%197 = OpVariable %128 Function %198 +%189 = OpVariable %190 Function %191 +%243 = OpVariable %130 Function %244 +%237 = OpVariable %163 Function %238 +%231 = OpVariable %158 Function %232 +%225 = OpVariable %163 Function %226 +%219 = OpVariable %158 Function %220 +%213 = OpVariable %141 Function %214 +%207 = OpVariable %141 Function %208 +%201 = OpVariable %130 Function %202 %195 = OpVariable %128 Function %196 -%189 = OpVariable %128 Function %190 -%183 = OpVariable %128 Function %184 -%177 = OpVariable %128 Function %178 -%171 = OpVariable %112 Function %172 -%165 = OpVariable %104 Function %166 -%158 = OpVariable %159 Function %160 -OpBranch %201 -%201 = OpLabel -%202 = OpLoad %5 %152 -%203 = OpCompositeConstruct %6 %202 %28 -OpStore %161 %203 -%204 = OpLoad %5 %152 -%205 = OpCompositeConstruct %6 %27 %204 -OpStore %163 %205 -%206 = OpLoad %5 %152 -%207 = OpCompositeConstruct %6 %206 %28 -OpStore %165 %207 -%208 = OpLoad %5 %152 -%209 = OpCompositeConstruct %6 %27 %208 -OpStore %167 %209 -%210 = OpLoad %7 %158 -%211 = OpCompositeConstruct %8 %210 %31 -%212 = OpCompositeConstruct %9 %211 %35 -OpStore %169 %212 -%213 = OpLoad %7 %158 -%214 = OpCompositeConstruct %8 %30 %213 -%215 = OpCompositeConstruct %9 %214 %35 -OpStore %171 %215 -%216 = OpLoad %7 %158 -%217 = OpCompositeConstruct %8 %216 %34 -%218 = OpCompositeConstruct %9 %32 %217 -OpStore %173 %218 -%219 = OpLoad %7 %158 -%220 = OpCompositeConstruct %8 %33 %219 -%221 = OpCompositeConstruct %9 %32 %220 -OpStore %175 %221 -%222 = OpLoad %7 %158 -%223 = OpCompositeConstruct %10 %222 %31 -OpStore %177 %223 -%224 = OpLoad %7 %158 -%225 = OpCompositeConstruct %10 %30 %224 -OpStore %179 %225 -%226 = OpLoad %7 %158 -%227 = OpCompositeConstruct %10 %226 %31 -OpStore %181 %227 -%228 = OpLoad %7 %158 -%229 = OpCompositeConstruct %10 %30 %228 -OpStore %183 %229 -%230 = OpLoad %3 %155 -%231 = OpCompositeConstruct %12 %230 %42 -OpStore %185 %231 -%232 = OpLoad %3 %155 -%233 = OpCompositeConstruct %12 %37 %232 -OpStore %187 %233 -%234 = OpLoad %7 %158 -%235 = OpCompositeConstruct %10 %234 %31 -OpStore %189 %235 -%236 = OpLoad %7 %158 -%237 = OpCompositeConstruct %10 %30 %236 -OpStore %191 %237 -%238 = OpLoad %7 %158 -%239 = OpCompositeConstruct %10 %238 %31 -OpStore %193 %239 -%240 = OpLoad %7 %158 -%241 = OpCompositeConstruct %10 %30 %240 -OpStore %195 %241 -%242 = OpLoad %3 %155 -%243 = OpCompositeConstruct %12 %242 %42 -OpStore %197 %243 -%244 = OpLoad %3 %155 -%245 = OpCompositeConstruct %12 %37 %244 -OpStore %199 %245 -%246 = OpLoad %5 %152 -%247 = OpCompositeConstruct %6 %246 %28 -OpStore %161 %247 -%248 = OpLoad %5 %152 -%249 = OpCompositeConstruct %6 %27 %248 -OpStore %163 %249 -%250 = OpLoad %5 %152 -%251 = OpCompositeConstruct %6 %250 %28 -OpStore %165 %251 -%252 = OpLoad %5 %152 -%253 = OpCompositeConstruct %6 %27 %252 -OpStore %167 %253 -%254 = OpLoad %7 %158 -%255 = OpCompositeConstruct %8 %254 %31 -%256 = OpCompositeConstruct %9 %255 %35 -OpStore %169 %256 -%257 = OpLoad %7 %158 -%258 = OpCompositeConstruct %8 %30 %257 -%259 = OpCompositeConstruct %9 %258 %35 -OpStore %171 %259 -%260 = OpLoad %7 %158 -%261 = OpCompositeConstruct %8 %260 %34 -%262 = OpCompositeConstruct %9 %32 %261 -OpStore %173 %262 -%263 = OpLoad %7 %158 -%264 = OpCompositeConstruct %8 %33 %263 -%265 = OpCompositeConstruct %9 %32 %264 -OpStore %175 %265 -%266 = OpLoad %7 %158 -%267 = OpCompositeConstruct %10 %266 %31 -OpStore %177 %267 -%268 = OpLoad %7 %158 -%269 = OpCompositeConstruct %10 %30 %268 -OpStore %179 %269 -%270 = OpLoad %7 %158 -%271 = OpCompositeConstruct %10 %270 %31 -OpStore %181 %271 -%272 = OpLoad %7 %158 -%273 = OpCompositeConstruct %10 %30 %272 -OpStore %183 %273 -%274 = OpLoad %3 %155 -%275 = OpCompositeConstruct %12 %274 %42 -OpStore %185 %275 -%276 = OpLoad %3 %155 -%277 = OpCompositeConstruct %12 %37 %276 -OpStore %187 %277 -%278 = OpLoad %7 %158 -%279 = OpCompositeConstruct %10 %278 %31 -OpStore %189 %279 -%280 = OpLoad %7 %158 -%281 = OpCompositeConstruct %10 %30 %280 -OpStore %191 %281 -%282 = OpLoad %7 %158 -%283 = OpCompositeConstruct %10 %282 %31 -OpStore %193 %283 -%284 = OpLoad %7 %158 -%285 = OpCompositeConstruct %10 %30 %284 -OpStore %195 %285 -%286 = OpLoad %3 %155 -%287 = OpCompositeConstruct %12 %286 %42 -OpStore %197 %287 -%288 = OpLoad %3 %155 -%289 = OpCompositeConstruct %12 %37 %288 -OpStore %199 %289 +%186 = OpVariable %187 Function %188 +%241 = OpVariable %128 Function %242 +%235 = OpVariable %163 Function %236 +%229 = OpVariable %158 Function %230 +%223 = OpVariable %163 Function %224 +%217 = OpVariable %158 Function %218 +%211 = OpVariable %141 Function %212 +%205 = OpVariable %128 Function %206 +%199 = OpVariable %130 Function %200 +%192 = OpVariable %193 Function %194 +OpBranch %245 +%245 = OpLabel +%246 = OpLoad %5 %186 +%247 = OpCompositeConstruct %6 %246 %32 +OpStore %195 %247 +%248 = OpLoad %5 %186 +%249 = OpCompositeConstruct %6 %31 %248 +OpStore %197 %249 +%250 = OpLoad %7 %192 +%251 = OpCompositeConstruct %8 %250 %26 +OpStore %199 %251 +%252 = OpLoad %7 %192 +%253 = OpCompositeConstruct %8 %252 %29 +OpStore %201 %253 +%254 = OpLoad %5 %186 +%255 = OpCompositeConstruct %6 %254 %32 +OpStore %203 %255 +%256 = OpLoad %5 %186 +%257 = OpCompositeConstruct %6 %31 %256 +OpStore %205 %257 +%258 = OpLoad %7 %192 +%259 = OpCompositeConstruct %8 %258 %42 +%260 = OpCompositeConstruct %9 %259 %46 +OpStore %207 %260 +%261 = OpLoad %7 %192 +%262 = OpCompositeConstruct %8 %41 %261 +%263 = OpCompositeConstruct %9 %262 %46 +OpStore %209 %263 +%264 = OpLoad %7 %192 +%265 = OpCompositeConstruct %8 %264 %45 +%266 = OpCompositeConstruct %9 %43 %265 +OpStore %211 %266 +%267 = OpLoad %7 %192 +%268 = OpCompositeConstruct %8 %44 %267 +%269 = OpCompositeConstruct %9 %43 %268 +OpStore %213 %269 +%270 = OpLoad %7 %192 +%271 = OpCompositeConstruct %10 %270 %42 +OpStore %215 %271 +%272 = OpLoad %7 %192 +%273 = OpCompositeConstruct %10 %41 %272 +OpStore %217 %273 +%274 = OpLoad %7 %192 +%275 = OpCompositeConstruct %10 %274 %42 +OpStore %219 %275 +%276 = OpLoad %7 %192 +%277 = OpCompositeConstruct %10 %41 %276 +OpStore %221 %277 +%278 = OpLoad %3 %189 +%279 = OpCompositeConstruct %12 %278 %53 +OpStore %223 %279 +%280 = OpLoad %3 %189 +%281 = OpCompositeConstruct %12 %48 %280 +OpStore %225 %281 +%282 = OpLoad %7 %192 +%283 = OpCompositeConstruct %10 %282 %42 +OpStore %227 %283 +%284 = OpLoad %7 %192 +%285 = OpCompositeConstruct %10 %41 %284 +OpStore %229 %285 +%286 = OpLoad %7 %192 +%287 = OpCompositeConstruct %10 %286 %42 +OpStore %231 %287 +%288 = OpLoad %7 %192 +%289 = OpCompositeConstruct %10 %41 %288 +OpStore %233 %289 +%290 = OpLoad %3 %189 +%291 = OpCompositeConstruct %12 %290 %53 +OpStore %235 %291 +%292 = OpLoad %3 %189 +%293 = OpCompositeConstruct %12 %48 %292 +OpStore %237 %293 +%294 = OpLoad %3 %189 +%295 = OpCompositeConstruct %4 %294 %294 +OpStore %239 %295 +%296 = OpLoad %5 %186 +%297 = OpCompositeConstruct %6 %296 %296 +OpStore %241 %297 +%298 = OpLoad %7 %192 +%299 = OpCompositeConstruct %8 %298 %298 +OpStore %243 %299 +%300 = OpLoad %5 %186 +%301 = OpCompositeConstruct %6 %300 %32 +OpStore %195 %301 +%302 = OpLoad %5 %186 +%303 = OpCompositeConstruct %6 %31 %302 +OpStore %197 %303 +%304 = OpLoad %5 %186 +%305 = OpCompositeConstruct %6 %304 %32 +OpStore %203 %305 +%306 = OpLoad %5 %186 +%307 = OpCompositeConstruct %6 %31 %306 +OpStore %205 %307 +%308 = OpLoad %7 %192 +%309 = OpCompositeConstruct %8 %308 %42 +%310 = OpCompositeConstruct %9 %309 %46 +OpStore %207 %310 +%311 = OpLoad %7 %192 +%312 = OpCompositeConstruct %8 %41 %311 +%313 = OpCompositeConstruct %9 %312 %46 +OpStore %209 %313 +%314 = OpLoad %7 %192 +%315 = OpCompositeConstruct %8 %314 %45 +%316 = OpCompositeConstruct %9 %43 %315 +OpStore %211 %316 +%317 = OpLoad %7 %192 +%318 = OpCompositeConstruct %8 %44 %317 +%319 = OpCompositeConstruct %9 %43 %318 +OpStore %213 %319 +%320 = OpLoad %7 %192 +%321 = OpCompositeConstruct %10 %320 %42 +OpStore %215 %321 +%322 = OpLoad %7 %192 +%323 = OpCompositeConstruct %10 %41 %322 +OpStore %217 %323 +%324 = OpLoad %7 %192 +%325 = OpCompositeConstruct %10 %324 %42 +OpStore %219 %325 +%326 = OpLoad %7 %192 +%327 = OpCompositeConstruct %10 %41 %326 +OpStore %221 %327 +%328 = OpLoad %3 %189 +%329 = OpCompositeConstruct %12 %328 %53 +OpStore %223 %329 +%330 = OpLoad %3 %189 +%331 = OpCompositeConstruct %12 %48 %330 +OpStore %225 %331 +%332 = OpLoad %7 %192 +%333 = OpCompositeConstruct %10 %332 %42 +OpStore %227 %333 +%334 = OpLoad %7 %192 +%335 = OpCompositeConstruct %10 %41 %334 +OpStore %229 %335 +%336 = OpLoad %7 %192 +%337 = OpCompositeConstruct %10 %336 %42 +OpStore %231 %337 +%338 = OpLoad %7 %192 +%339 = OpCompositeConstruct %10 %41 %338 +OpStore %233 %339 +%340 = OpLoad %3 %189 +%341 = OpCompositeConstruct %12 %340 %53 +OpStore %235 %341 +%342 = OpLoad %3 %189 +%343 = OpCompositeConstruct %12 %48 %342 +OpStore %237 %343 +%344 = OpLoad %3 %189 +%345 = OpCompositeConstruct %4 %344 %344 +OpStore %239 %345 +%346 = OpLoad %5 %186 +%347 = OpCompositeConstruct %6 %346 %346 +OpStore %241 %347 +%348 = OpLoad %7 %192 +%349 = OpCompositeConstruct %8 %348 %348 +OpStore %243 %349 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/constructors.spvasm b/naga/tests/out/spv/constructors.spvasm index afa7deded..233cb2735 100644 --- a/naga/tests/out/spv/constructors.spvasm +++ b/naga/tests/out/spv/constructors.spvasm @@ -1,84 +1,86 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 68 +; Bound: 70 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %38 "main" -OpExecutionMode %38 LocalSize 1 1 1 +OpEntryPoint GLCompute %41 "main" +OpExecutionMode %41 LocalSize 1 1 1 OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 -OpDecorate %9 ArrayStride 16 -OpDecorate %14 ArrayStride 32 -OpDecorate %17 ArrayStride 4 +OpDecorate %10 ArrayStride 16 +OpDecorate %15 ArrayStride 32 +OpDecorate %18 ArrayStride 4 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 %5 = OpTypeInt 32 1 %6 = OpTypeStruct %4 %5 -%8 = OpTypeVector %3 2 -%7 = OpTypeMatrix %8 2 -%11 = OpTypeInt 32 0 -%10 = OpConstant %11 1 -%9 = OpTypeArray %7 %10 -%12 = OpTypeBool -%13 = OpTypeVector %11 2 -%15 = OpConstant %11 3 -%14 = OpTypeArray %6 %15 -%16 = OpTypeMatrix %4 4 -%18 = OpConstant %11 4 -%17 = OpTypeArray %5 %18 -%20 = OpTypeVector %3 3 -%19 = OpTypeMatrix %20 2 +%7 = OpTypeVector %3 3 +%9 = OpTypeVector %3 2 +%8 = OpTypeMatrix %9 2 +%12 = OpTypeInt 32 0 +%11 = OpConstant %12 1 +%10 = OpTypeArray %8 %11 +%13 = OpTypeBool +%14 = OpTypeVector %12 2 +%16 = OpConstant %12 3 +%15 = OpTypeArray %6 %16 +%17 = OpTypeMatrix %4 4 +%19 = OpConstant %12 4 +%18 = OpTypeArray %5 %19 +%20 = OpTypeMatrix %7 2 %21 = OpConstant %3 0.0 -%22 = OpConstant %3 1.0 -%23 = OpConstant %3 2.0 -%24 = OpConstant %3 3.0 -%25 = OpConstantComposite %8 %21 %22 -%26 = OpConstantComposite %8 %23 %24 -%27 = OpConstantComposite %7 %25 %26 -%28 = OpConstantComposite %9 %27 -%29 = OpConstantNull %12 -%30 = OpConstantNull %5 -%31 = OpConstantNull %11 -%32 = OpConstantNull %3 -%33 = OpConstantNull %13 -%34 = OpConstantNull %7 -%35 = OpConstantNull %14 -%36 = OpConstantNull %6 -%39 = OpTypeFunction %2 -%40 = OpConstantComposite %4 %22 %22 %22 %22 -%41 = OpConstant %5 1 -%42 = OpConstantComposite %6 %40 %41 -%43 = OpConstantComposite %8 %22 %21 -%44 = OpConstantComposite %7 %43 %25 -%45 = OpConstantComposite %4 %22 %21 %21 %21 -%46 = OpConstantComposite %4 %21 %22 %21 %21 -%47 = OpConstantComposite %4 %21 %21 %22 %21 -%48 = OpConstantComposite %4 %21 %21 %21 %22 -%49 = OpConstantComposite %16 %45 %46 %47 %48 -%50 = OpConstant %11 0 -%51 = OpConstantComposite %13 %50 %50 -%52 = OpConstantComposite %8 %21 %21 -%53 = OpConstantComposite %7 %52 %52 -%54 = OpConstant %5 0 -%55 = OpConstant %5 2 -%56 = OpConstant %5 3 -%57 = OpConstantComposite %17 %54 %41 %55 %56 -%58 = OpConstantFalse %12 -%59 = OpConstantComposite %13 %50 %50 -%60 = OpConstantComposite %20 %21 %21 %21 -%61 = OpConstantComposite %19 %60 %60 -%62 = OpConstantNull %19 -%63 = OpConstantTrue %12 -%65 = OpTypePointer Function %6 -%66 = OpConstantNull %6 -%38 = OpFunction %2 None %39 -%37 = OpLabel -%64 = OpVariable %65 Function %66 -OpBranch %67 -%67 = OpLabel -OpStore %64 %42 +%22 = OpConstantComposite %7 %21 %21 %21 +%23 = OpConstant %3 1.0 +%24 = OpConstant %3 2.0 +%25 = OpConstant %3 3.0 +%26 = OpConstantComposite %9 %21 %23 +%27 = OpConstantComposite %9 %24 %25 +%28 = OpConstantComposite %8 %26 %27 +%29 = OpConstantComposite %10 %28 +%30 = OpConstantNull %13 +%31 = OpConstantNull %5 +%32 = OpConstantNull %12 +%33 = OpConstantNull %3 +%34 = OpConstantNull %14 +%35 = OpConstantNull %8 +%36 = OpConstantNull %15 +%37 = OpConstantNull %6 +%38 = OpConstant %12 0 +%39 = OpConstantComposite %14 %38 %38 +%42 = OpTypeFunction %2 +%43 = OpConstantComposite %4 %23 %23 %23 %23 +%44 = OpConstant %5 1 +%45 = OpConstantComposite %6 %43 %44 +%46 = OpConstantComposite %9 %23 %21 +%47 = OpConstantComposite %8 %46 %26 +%48 = OpConstantComposite %4 %23 %21 %21 %21 +%49 = OpConstantComposite %4 %21 %23 %21 %21 +%50 = OpConstantComposite %4 %21 %21 %23 %21 +%51 = OpConstantComposite %4 %21 %21 %21 %23 +%52 = OpConstantComposite %17 %48 %49 %50 %51 +%53 = OpConstantComposite %14 %38 %38 +%54 = OpConstantComposite %9 %21 %21 +%55 = OpConstantComposite %9 %21 %21 +%56 = OpConstantComposite %8 %55 %55 +%57 = OpConstant %5 0 +%58 = OpConstant %5 2 +%59 = OpConstant %5 3 +%60 = OpConstantComposite %18 %57 %44 %58 %59 +%61 = OpConstantFalse %13 +%62 = OpConstantComposite %7 %21 %21 %21 +%63 = OpConstantComposite %20 %62 %62 +%64 = OpConstantNull %20 +%65 = OpConstantTrue %13 +%67 = OpTypePointer Function %6 +%68 = OpConstantNull %6 +%41 = OpFunction %2 None %42 +%40 = OpLabel +%66 = OpVariable %67 Function %68 +OpBranch %69 +%69 = OpLabel +OpStore %66 %45 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/conversions.spvasm b/naga/tests/out/spv/conversions.spvasm new file mode 100644 index 000000000..5dae778e1 --- /dev/null +++ b/naga/tests/out/spv/conversions.spvasm @@ -0,0 +1,23 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 13 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %8 "main" +OpExecutionMode %8 LocalSize 1 1 1 +%2 = OpTypeVoid +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 2 +%5 = OpConstant %4 2.0 +%6 = OpConstantComposite %3 %5 %5 +%9 = OpTypeFunction %2 +%11 = OpTypePointer Function %3 +%8 = OpFunction %2 None %9 +%7 = OpLabel +%10 = OpVariable %11 Function %6 +OpBranch %12 +%12 = OpLabel +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/spv/math-functions.spvasm b/naga/tests/out/spv/math-functions.spvasm index cfdab1f73..a85644d45 100644 --- a/naga/tests/out/spv/math-functions.spvasm +++ b/naga/tests/out/spv/math-functions.spvasm @@ -20,24 +20,24 @@ OpMemberDecorate %15 1 Offset 16 %2 = OpTypeVoid %3 = OpTypeFloat 32 %4 = OpTypeVector %3 4 -%6 = OpTypeInt 32 1 -%5 = OpTypeVector %6 4 -%7 = OpTypeVector %6 2 +%5 = OpTypeInt 32 1 +%6 = OpTypeVector %5 4 +%7 = OpTypeVector %5 2 %9 = OpTypeInt 32 0 %8 = OpTypeVector %9 2 %10 = OpTypeVector %3 2 %11 = OpTypeStruct %3 %3 %12 = OpTypeStruct %10 %10 %13 = OpTypeStruct %4 %4 -%14 = OpTypeStruct %3 %6 -%15 = OpTypeStruct %4 %5 +%14 = OpTypeStruct %3 %5 +%15 = OpTypeStruct %4 %6 %16 = OpTypeVector %3 3 %19 = OpTypeFunction %2 %20 = OpConstant %3 1.0 %21 = OpConstant %3 0.0 %22 = OpConstantComposite %4 %21 %21 %21 %21 -%23 = OpConstant %6 -1 -%24 = OpConstantComposite %5 %23 %23 %23 %23 +%23 = OpConstant %5 -1 +%24 = OpConstantComposite %6 %23 %23 %23 %23 %25 = OpConstant %3 -1.0 %26 = OpConstantComposite %4 %25 %25 %25 %25 %27 = OpConstantNull %7 @@ -45,19 +45,19 @@ OpMemberDecorate %15 1 Offset 16 %29 = OpConstantComposite %7 %23 %23 %30 = OpConstant %9 0 %31 = OpConstantComposite %8 %30 %30 -%32 = OpConstant %6 0 +%32 = OpConstant %5 0 %33 = OpConstantComposite %7 %32 %32 %34 = OpConstant %9 32 -%35 = OpConstant %6 32 +%35 = OpConstant %5 32 %36 = OpConstantComposite %8 %34 %34 %37 = OpConstantComposite %7 %35 %35 %38 = OpConstant %9 31 %39 = OpConstantComposite %8 %38 %38 -%40 = OpConstant %6 2 +%40 = OpConstant %5 2 %41 = OpConstant %3 2.0 %42 = OpConstantComposite %10 %20 %41 -%43 = OpConstant %6 3 -%44 = OpConstant %6 4 +%43 = OpConstant %5 3 +%44 = OpConstant %5 4 %45 = OpConstantComposite %7 %43 %44 %46 = OpConstant %3 1.5 %47 = OpConstantComposite %10 %46 %46 @@ -66,7 +66,7 @@ OpMemberDecorate %15 1 Offset 16 %50 = OpConstantComposite %16 %20 %20 %20 %51 = OpConstantComposite %4 %20 %20 %20 %20 %58 = OpConstantComposite %4 %20 %20 %20 %20 -%61 = OpConstantNull %6 +%61 = OpConstantNull %5 %18 = OpFunction %2 None %19 %17 = OpLabel OpBranch %52 @@ -77,14 +77,14 @@ OpBranch %52 %56 = OpExtInst %4 %1 Radians %22 %57 = OpExtInst %4 %1 FClamp %22 %22 %58 %59 = OpExtInst %4 %1 Refract %22 %22 %20 -%62 = OpCompositeExtract %6 %27 0 -%63 = OpCompositeExtract %6 %27 0 -%64 = OpIMul %6 %62 %63 -%65 = OpIAdd %6 %61 %64 -%66 = OpCompositeExtract %6 %27 1 -%67 = OpCompositeExtract %6 %27 1 -%68 = OpIMul %6 %66 %67 -%60 = OpIAdd %6 %65 %68 +%62 = OpCompositeExtract %5 %27 0 +%63 = OpCompositeExtract %5 %27 0 +%64 = OpIMul %5 %62 %63 +%65 = OpIAdd %5 %61 %64 +%66 = OpCompositeExtract %5 %27 1 +%67 = OpCompositeExtract %5 %27 1 +%68 = OpIMul %5 %66 %67 +%60 = OpIAdd %5 %65 %68 %69 = OpExtInst %3 %1 Ldexp %20 %40 %70 = OpExtInst %10 %1 Ldexp %42 %45 %71 = OpExtInst %11 %1 ModfStruct %46 @@ -103,10 +103,10 @@ OpBranch %52 %84 = OpExtInst %14 %1 FrexpStruct %46 %85 = OpCompositeExtract %3 %84 0 %86 = OpExtInst %14 %1 FrexpStruct %46 -%87 = OpCompositeExtract %6 %86 1 +%87 = OpCompositeExtract %5 %86 1 %88 = OpExtInst %15 %1 FrexpStruct %48 -%89 = OpCompositeExtract %5 %88 1 -%90 = OpCompositeExtract %6 %89 0 +%89 = OpCompositeExtract %6 %88 1 +%90 = OpCompositeExtract %5 %89 0 %91 = OpQuantizeToF16 %3 %20 %92 = OpQuantizeToF16 %10 %49 %93 = OpQuantizeToF16 %16 %50 diff --git a/naga/tests/out/spv/operators.spvasm b/naga/tests/out/spv/operators.spvasm index 0ffb7dc36..687f8eddc 100644 --- a/naga/tests/out/spv/operators.spvasm +++ b/naga/tests/out/spv/operators.spvasm @@ -17,12 +17,12 @@ OpDecorate %509 BuiltIn WorkgroupId %7 = OpTypeVector %8 4 %9 = OpTypeVector %3 2 %10 = OpTypeVector %3 3 -%11 = OpTypeMatrix %10 3 -%12 = OpTypeMatrix %10 4 -%13 = OpTypeMatrix %4 3 -%14 = OpTypeVector %5 3 -%16 = OpTypeInt 32 0 -%15 = OpTypeVector %16 3 +%12 = OpTypeInt 32 0 +%11 = OpTypeVector %12 3 +%13 = OpTypeMatrix %10 3 +%14 = OpTypeMatrix %10 4 +%15 = OpTypeMatrix %4 3 +%16 = OpTypeVector %5 3 %17 = OpConstant %3 1.0 %18 = OpConstantComposite %4 %17 %17 %17 %17 %19 = OpConstant %3 0.0 @@ -71,37 +71,37 @@ OpDecorate %509 BuiltIn WorkgroupId %127 = OpConstantComposite %7 %28 %28 %28 %28 %128 = OpConstantComposite %7 %30 %30 %30 %30 %139 = OpTypeFunction %5 %5 %5 -%151 = OpTypeFunction %16 %16 %16 -%155 = OpConstant %16 0 -%157 = OpConstant %16 1 +%151 = OpTypeFunction %12 %12 %12 +%155 = OpConstant %12 0 +%157 = OpConstant %12 1 %160 = OpTypeVector %5 2 %162 = OpTypeFunction %160 %160 %160 %166 = OpConstantComposite %160 %29 %29 %168 = OpConstantComposite %160 %60 %60 %169 = OpConstantComposite %160 %61 %61 %174 = OpConstantComposite %160 %23 %23 -%178 = OpTypeFunction %15 %15 %15 -%182 = OpConstantComposite %15 %155 %155 %155 -%184 = OpConstantComposite %15 %157 %157 %157 -%223 = OpTypeVector %16 2 +%178 = OpTypeFunction %11 %11 %11 +%182 = OpConstantComposite %11 %155 %155 %155 +%184 = OpConstantComposite %11 %157 %157 %157 +%223 = OpTypeVector %12 2 %225 = OpTypeFunction %223 %223 %223 %229 = OpConstantComposite %223 %155 %155 %231 = OpConstantComposite %223 %157 %157 -%243 = OpConstant %16 2 +%243 = OpConstant %12 2 %244 = OpConstantComposite %160 %82 %82 -%245 = OpConstantComposite %15 %243 %243 %243 +%245 = OpConstantComposite %11 %243 %243 %243 %246 = OpConstantComposite %4 %76 %76 %76 %76 %247 = OpConstantComposite %4 %17 %17 %17 %17 %248 = OpConstantComposite %223 %243 %243 -%249 = OpConstantNull %11 -%250 = OpConstantNull %12 +%249 = OpConstantNull %13 +%250 = OpConstantNull %14 %251 = OpConstantComposite %10 %76 %76 %76 -%252 = OpConstantNull %13 -%416 = OpConstantNull %14 +%252 = OpConstantNull %15 +%416 = OpConstantNull %16 %418 = OpTypePointer Function %5 %419 = OpConstantNull %5 -%421 = OpTypePointer Function %14 -%510 = OpTypePointer Input %15 +%421 = OpTypePointer Function %16 +%510 = OpTypePointer Input %11 %509 = OpVariable %510 Input %513 = OpConstantComposite %10 %17 %17 %17 %26 = OpFunction %4 None %27 @@ -211,13 +211,13 @@ OpFunctionEnd %149 = OpSDiv %5 %140 %148 OpReturnValue %149 OpFunctionEnd -%150 = OpFunction %16 None %151 -%152 = OpFunctionParameter %16 -%153 = OpFunctionParameter %16 +%150 = OpFunction %12 None %151 +%152 = OpFunctionParameter %12 +%153 = OpFunctionParameter %12 %154 = OpLabel %156 = OpIEqual %8 %153 %155 -%158 = OpSelect %16 %156 %157 %153 -%159 = OpUDiv %16 %152 %158 +%158 = OpSelect %12 %156 %157 %153 +%159 = OpUDiv %12 %152 %158 OpReturnValue %159 OpFunctionEnd %161 = OpFunction %160 None %162 @@ -233,13 +233,13 @@ OpFunctionEnd %176 = OpSDiv %160 %163 %175 OpReturnValue %176 OpFunctionEnd -%177 = OpFunction %15 None %178 -%179 = OpFunctionParameter %15 -%180 = OpFunctionParameter %15 +%177 = OpFunction %11 None %178 +%179 = OpFunctionParameter %11 +%180 = OpFunctionParameter %11 %181 = OpLabel %183 = OpIEqual %115 %180 %182 -%185 = OpSelect %15 %183 %184 %180 -%186 = OpUDiv %15 %179 %185 +%185 = OpSelect %11 %183 %184 %180 +%186 = OpUDiv %11 %179 %185 OpReturnValue %186 OpFunctionEnd %187 = OpFunction %5 None %139 @@ -255,13 +255,13 @@ OpFunctionEnd %197 = OpSRem %5 %188 %196 OpReturnValue %197 OpFunctionEnd -%198 = OpFunction %16 None %151 -%199 = OpFunctionParameter %16 -%200 = OpFunctionParameter %16 +%198 = OpFunction %12 None %151 +%199 = OpFunctionParameter %12 +%200 = OpFunctionParameter %12 %201 = OpLabel %202 = OpIEqual %8 %200 %155 -%203 = OpSelect %16 %202 %157 %200 -%204 = OpUMod %16 %199 %203 +%203 = OpSelect %12 %202 %157 %200 +%204 = OpUMod %12 %199 %203 OpReturnValue %204 OpFunctionEnd %205 = OpFunction %160 None %162 @@ -277,13 +277,13 @@ OpFunctionEnd %215 = OpSRem %160 %206 %214 OpReturnValue %215 OpFunctionEnd -%216 = OpFunction %15 None %178 -%217 = OpFunctionParameter %15 -%218 = OpFunctionParameter %15 +%216 = OpFunction %11 None %178 +%217 = OpFunctionParameter %11 +%218 = OpFunctionParameter %11 %219 = OpLabel %220 = OpIEqual %115 %218 %182 -%221 = OpSelect %15 %220 %184 %218 -%222 = OpUMod %15 %217 %221 +%221 = OpSelect %11 %220 %184 %218 +%222 = OpUMod %11 %217 %221 OpReturnValue %222 OpFunctionEnd %224 = OpFunction %223 None %225 @@ -312,34 +312,34 @@ OpBranch %253 %255 = OpSNegate %160 %174 %256 = OpFNegate %9 %97 %257 = OpIAdd %5 %82 %23 -%258 = OpIAdd %16 %243 %157 +%258 = OpIAdd %12 %243 %157 %259 = OpFAdd %3 %76 %17 %260 = OpIAdd %160 %244 %174 -%261 = OpIAdd %15 %245 %184 +%261 = OpIAdd %11 %245 %184 %262 = OpFAdd %4 %246 %247 %263 = OpISub %5 %82 %23 -%264 = OpISub %16 %243 %157 +%264 = OpISub %12 %243 %157 %265 = OpFSub %3 %76 %17 %266 = OpISub %160 %244 %174 -%267 = OpISub %15 %245 %184 +%267 = OpISub %11 %245 %184 %268 = OpFSub %4 %246 %247 %269 = OpIMul %5 %82 %23 -%270 = OpIMul %16 %243 %157 +%270 = OpIMul %12 %243 %157 %271 = OpFMul %3 %76 %17 %272 = OpIMul %160 %244 %174 -%273 = OpIMul %15 %245 %184 +%273 = OpIMul %11 %245 %184 %274 = OpFMul %4 %246 %247 %275 = OpFunctionCall %5 %138 %82 %23 -%276 = OpFunctionCall %16 %150 %243 %157 +%276 = OpFunctionCall %12 %150 %243 %157 %277 = OpFDiv %3 %76 %17 %278 = OpFunctionCall %160 %161 %244 %174 -%279 = OpFunctionCall %15 %177 %245 %184 +%279 = OpFunctionCall %11 %177 %245 %184 %280 = OpFDiv %4 %246 %247 %281 = OpFunctionCall %5 %187 %82 %23 -%282 = OpFunctionCall %16 %198 %243 %157 +%282 = OpFunctionCall %12 %198 %243 %157 %283 = OpFRem %3 %76 %17 %284 = OpFunctionCall %160 %205 %244 %174 -%285 = OpFunctionCall %15 %216 %245 %184 +%285 = OpFunctionCall %11 %216 %245 %184 %286 = OpFRem %4 %246 %247 OpBranch %287 %287 = OpLabel @@ -388,7 +388,7 @@ OpBranch %288 %330 = OpCompositeExtract %10 %249 2 %331 = OpCompositeExtract %10 %249 2 %332 = OpFAdd %10 %330 %331 -%323 = OpCompositeConstruct %11 %326 %329 %332 +%323 = OpCompositeConstruct %13 %326 %329 %332 %334 = OpCompositeExtract %10 %249 0 %335 = OpCompositeExtract %10 %249 0 %336 = OpFSub %10 %334 %335 @@ -398,12 +398,12 @@ OpBranch %288 %340 = OpCompositeExtract %10 %249 2 %341 = OpCompositeExtract %10 %249 2 %342 = OpFSub %10 %340 %341 -%333 = OpCompositeConstruct %11 %336 %339 %342 -%343 = OpMatrixTimesScalar %11 %249 %17 -%344 = OpMatrixTimesScalar %11 %249 %76 +%333 = OpCompositeConstruct %13 %336 %339 %342 +%343 = OpMatrixTimesScalar %13 %249 %17 +%344 = OpMatrixTimesScalar %13 %249 %76 %345 = OpMatrixTimesVector %10 %250 %247 %346 = OpVectorTimesMatrix %4 %251 %250 -%347 = OpMatrixTimesMatrix %11 %250 %252 +%347 = OpMatrixTimesMatrix %13 %250 %252 OpReturn OpFunctionEnd %349 = OpFunction %2 None %122 @@ -411,29 +411,29 @@ OpFunctionEnd OpBranch %350 %350 = OpLabel %351 = OpNot %5 %23 -%352 = OpNot %16 %157 +%352 = OpNot %12 %157 %353 = OpNot %160 %174 -%354 = OpNot %15 %184 +%354 = OpNot %11 %184 %355 = OpBitwiseOr %5 %82 %23 -%356 = OpBitwiseOr %16 %243 %157 +%356 = OpBitwiseOr %12 %243 %157 %357 = OpBitwiseOr %160 %244 %174 -%358 = OpBitwiseOr %15 %245 %184 +%358 = OpBitwiseOr %11 %245 %184 %359 = OpBitwiseAnd %5 %82 %23 -%360 = OpBitwiseAnd %16 %243 %157 +%360 = OpBitwiseAnd %12 %243 %157 %361 = OpBitwiseAnd %160 %244 %174 -%362 = OpBitwiseAnd %15 %245 %184 +%362 = OpBitwiseAnd %11 %245 %184 %363 = OpBitwiseXor %5 %82 %23 -%364 = OpBitwiseXor %16 %243 %157 +%364 = OpBitwiseXor %12 %243 %157 %365 = OpBitwiseXor %160 %244 %174 -%366 = OpBitwiseXor %15 %245 %184 +%366 = OpBitwiseXor %11 %245 %184 %367 = OpShiftLeftLogical %5 %82 %157 -%368 = OpShiftLeftLogical %16 %243 %157 +%368 = OpShiftLeftLogical %12 %243 %157 %369 = OpShiftLeftLogical %160 %244 %231 -%370 = OpShiftLeftLogical %15 %245 %184 +%370 = OpShiftLeftLogical %11 %245 %184 %371 = OpShiftRightArithmetic %5 %82 %157 -%372 = OpShiftRightLogical %16 %243 %157 +%372 = OpShiftRightLogical %12 %243 %157 %373 = OpShiftRightArithmetic %160 %244 %231 -%374 = OpShiftRightLogical %15 %245 %184 +%374 = OpShiftRightLogical %11 %245 %184 OpReturn OpFunctionEnd %376 = OpFunction %2 None %122 @@ -591,13 +591,13 @@ OpReturn OpFunctionEnd %512 = OpFunction %2 None %122 %508 = OpLabel -%511 = OpLoad %15 %509 +%511 = OpLoad %11 %509 OpBranch %514 %514 = OpLabel %515 = OpFunctionCall %4 %26 -%516 = OpCompositeExtract %16 %511 0 +%516 = OpCompositeExtract %12 %511 0 %517 = OpConvertUToF %3 %516 -%518 = OpCompositeExtract %16 %511 1 +%518 = OpCompositeExtract %12 %511 1 %519 = OpBitcast %5 %518 %520 = OpFunctionCall %4 %74 %517 %519 %521 = OpFunctionCall %10 %112 %513 diff --git a/naga/tests/out/spv/type-inference.spvasm b/naga/tests/out/spv/type-inference.spvasm new file mode 100644 index 000000000..adcaa8094 --- /dev/null +++ b/naga/tests/out/spv/type-inference.spvasm @@ -0,0 +1,72 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 57 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %18 "main" +OpExecutionMode %18 LocalSize 1 1 1 +%2 = OpTypeVoid +%3 = OpTypeInt 32 0 +%4 = OpTypeFloat 32 +%5 = OpTypeInt 32 1 +%6 = OpTypeVector %5 4 +%8 = OpTypeVector %4 2 +%7 = OpTypeMatrix %8 2 +%9 = OpConstant %3 1 +%10 = OpConstant %4 1.0 +%11 = OpConstantNull %6 +%12 = OpConstant %5 1 +%13 = OpConstantComposite %6 %12 %12 %12 %12 +%14 = OpConstant %4 0.0 +%15 = OpConstantComposite %8 %14 %14 +%16 = OpConstantComposite %7 %15 %15 +%19 = OpTypeFunction %2 +%20 = OpConstantComposite %8 %10 %10 +%21 = OpConstantComposite %7 %20 %20 +%23 = OpTypePointer Function %5 +%25 = OpTypePointer Function %4 +%27 = OpTypePointer Function %7 +%30 = OpTypePointer Function %3 +%34 = OpTypePointer Function %6 +%39 = OpConstantNull %5 +%41 = OpConstantNull %3 +%43 = OpConstantNull %4 +%45 = OpConstantNull %4 +%47 = OpConstantNull %6 +%18 = OpFunction %2 None %19 +%17 = OpLabel +%54 = OpVariable %27 Function %16 +%51 = OpVariable %25 Function %10 +%48 = OpVariable %23 Function %12 +%42 = OpVariable %25 Function %43 +%37 = OpVariable %27 Function %21 +%33 = OpVariable %34 Function %11 +%29 = OpVariable %30 Function %9 +%24 = OpVariable %25 Function %10 +%53 = OpVariable %34 Function %13 +%50 = OpVariable %25 Function %10 +%46 = OpVariable %34 Function %47 +%40 = OpVariable %30 Function %41 +%36 = OpVariable %27 Function %16 +%32 = OpVariable %25 Function %10 +%28 = OpVariable %23 Function %12 +%22 = OpVariable %23 Function %12 +%55 = OpVariable %27 Function %21 +%52 = OpVariable %34 Function %11 +%49 = OpVariable %30 Function %9 +%44 = OpVariable %25 Function %45 +%38 = OpVariable %23 Function %39 +%35 = OpVariable %34 Function %13 +%31 = OpVariable %25 Function %10 +%26 = OpVariable %27 Function %21 +OpBranch %56 +%56 = OpLabel +OpStore %38 %12 +OpStore %40 %9 +OpStore %42 %10 +OpStore %44 %10 +OpStore %46 %11 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/naga/tests/out/wgsl/abstract-types-const.wgsl b/naga/tests/out/wgsl/abstract-types-const.wgsl index 649740f8c..5807ce098 100644 --- a/naga/tests/out/wgsl/abstract-types-const.wgsl +++ b/naga/tests/out/wgsl/abstract-types-const.wgsl @@ -4,12 +4,19 @@ struct S { u: u32, } -const xvupaiai: vec2 = vec2(42u, 43u); -const xvfpaiai: vec2 = vec2(44f, 45f); +const xvipaiai: vec2 = vec2(42i, 43i); +const xvupaiai: vec2 = vec2(44u, 45u); +const xvfpaiai: vec2 = vec2(46f, 47f); +const xvfpafaf: vec2 = vec2(48f, 49f); +const xvfpaiaf: vec2 = vec2(48f, 49f); const xvupuai: vec2 = vec2(42u, 43u); const xvupaiu: vec2 = vec2(42u, 43u); const xvuuai: vec2 = vec2(42u, 43u); const xvuaiu: vec2 = vec2(42u, 43u); +const xvip: vec2 = vec2(0i, 0i); +const xvup: vec2 = vec2(0u, 0u); +const xvfp: vec2 = vec2(0f, 0f); +const xmfp: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); const xmfpaiaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); const xmfpafaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); const xmfpaiafaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -21,6 +28,10 @@ const ivfs_ai: vec2 = vec2(1f); const ivfs_af: vec2 = vec2(1f); const iafafaf: array = array(1f, 2f); const iafaiai: array = array(1f, 2f); +const xaipaiai: array = array(1i, 2i); +const xaupaiai: array = array(1u, 2u); +const xafpaiaf: array = array(1f, 2f); +const xafpafai: array = array(1f, 2f); const xafpafaf: array = array(1f, 2f); const s_f_i_u: S = S(1f, 1i, 1u); const s_f_iai: S = S(1f, 1i, 1u); @@ -30,6 +41,10 @@ const saf_i_u: S = S(1f, 1i, 1u); const saf_iai: S = S(1f, 1i, 1u); const safai_u: S = S(1f, 1i, 1u); const safaiai: S = S(1f, 1i, 1u); +const xvisai: vec2 = vec2(1i); +const xvusai: vec2 = vec2(1u); +const xvfsai: vec2 = vec2(1f); +const xvfsaf: vec2 = vec2(1f); const ivfr_f_f: vec3 = vec3(vec2(1f, 2f), 3f); const ivfr_f_af: vec3 = vec3(vec2(1f, 2f), 3f); const ivfraf_f: vec3 = vec3(vec2(1f, 2f), 3f); diff --git a/naga/tests/out/wgsl/abstract-types-let.wgsl b/naga/tests/out/wgsl/abstract-types-let.wgsl new file mode 100644 index 000000000..ea9cc2d3f --- /dev/null +++ b/naga/tests/out/wgsl/abstract-types-let.wgsl @@ -0,0 +1,112 @@ +fn all_constant_arguments() { + let xvipaiai = vec2(42i, 43i); + let xvupaiai = vec2(44u, 45u); + let xvfpaiai = vec2(46f, 47f); + let xvfpafaf = vec2(48f, 49f); + let xvfpaiaf = vec2(48f, 49f); + let xvupuai = vec2(42u, 43u); + let xvupaiu = vec2(42u, 43u); + let xvuuai = vec2(42u, 43u); + let xvuaiu = vec2(42u, 43u); + let xvip = vec2(0i, 0i); + let xvup = vec2(0u, 0u); + let xvfp = vec2(0f, 0f); + let xmfp = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + let xmfpaiaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpafaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiafaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiafai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiaiaf = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfp_faiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpai_faiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiai_fai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xmfpaiaiai_f = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); + let xvispai = vec2(1i); + let xvfspaf = vec2(1f); + let xvis_ai = vec2(1i); + let xvus_ai = vec2(1u); + let xvfs_ai = vec2(1f); + let xvfs_af = vec2(1f); + let xafafaf = array(1f, 2f); + let xaf_faf = array(1f, 2f); + let xafaf_f = array(1f, 2f); + let xafaiai = array(1f, 2f); + let xai_iai = array(1i, 2i); + let xaiai_i = array(1i, 2i); + let xaipaiai = array(1i, 2i); + let xafpaiai = array(1f, 2f); + let xafpaiaf = array(1f, 2f); + let xafpafai = array(1f, 2f); + let xafpafaf = array(1f, 2f); + let xavipai = array, 1>(vec3(1i)); + let xavfpai = array, 1>(vec3(1f)); + let xavfpaf = array, 1>(vec3(1f)); + let xvisai = vec2(1i); + let xvusai = vec2(1u); + let xvfsai = vec2(1f); + let xvfsaf = vec2(1f); + let iaipaiai = array(1i, 2i); + let iafpaiaf = array(1f, 2f); + let iafpafai = array(1f, 2f); + let iafpafaf = array(1f, 2f); + return; +} + +fn mixed_constant_and_runtime_arguments() { + var u: u32; + var i: i32; + var f: f32; + + let _e3 = u; + let xvupuai_1 = vec2(_e3, 43u); + let _e6 = u; + let xvupaiu_1 = vec2(42u, _e6); + let _e9 = f; + let xvfpfai = vec2(_e9, 47f); + let _e12 = f; + let xvfpfaf = vec2(_e12, 49f); + let _e15 = u; + let xvuuai_1 = vec2(_e15, 43u); + let _e18 = u; + let xvuaiu_1 = vec2(42u, _e18); + let _e21 = f; + let xmfp_faiaiai_1 = mat2x2(vec2(_e21, 2f), vec2(3f, 4f)); + let _e28 = f; + let xmfpai_faiai_1 = mat2x2(vec2(1f, _e28), vec2(3f, 4f)); + let _e35 = f; + let xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e35, 4f)); + let _e42 = f; + let xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e42)); + let _e49 = f; + let xaf_faf_1 = array(_e49, 2f); + let _e52 = f; + let xafaf_f_1 = array(1f, _e52); + let _e55 = f; + let xaf_fai = array(_e55, 2f); + let _e58 = f; + let xafai_f = array(1f, _e58); + let _e61 = i; + let xai_iai_1 = array(_e61, 2i); + let _e64 = i; + let xaiai_i_1 = array(1i, _e64); + let _e67 = f; + let xafp_faf = array(_e67, 2f); + let _e70 = f; + let xafpaf_f = array(1f, _e70); + let _e73 = f; + let xafp_fai = array(_e73, 2f); + let _e76 = f; + let xafpai_f = array(1f, _e76); + let _e79 = i; + let xaip_iai = array(_e79, 2i); + let _e82 = i; + let xaipai_i = array(1i, _e82); + let _e85 = i; + let xvisi = vec2(_e85); + let _e87 = u; + let xvusu = vec2(_e87); + let _e89 = f; + let xvfsf = vec2(_e89); + return; +} + diff --git a/naga/tests/out/wgsl/abstract-types-var.wgsl b/naga/tests/out/wgsl/abstract-types-var.wgsl index 58d5f414f..505cc2598 100644 --- a/naga/tests/out/wgsl/abstract-types-var.wgsl +++ b/naga/tests/out/wgsl/abstract-types-var.wgsl @@ -1,10 +1,16 @@ var xvipaiai_1: vec2 = vec2(42i, 43i); var xvupaiai_1: vec2 = vec2(44u, 45u); var xvfpaiai_1: vec2 = vec2(46f, 47f); +var xvfpafaf_1: vec2 = vec2(48f, 49f); +var xvfpaiaf_1: vec2 = vec2(48f, 49f); var xvupuai_2: vec2 = vec2(42u, 43u); var xvupaiu_2: vec2 = vec2(42u, 43u); var xvuuai_2: vec2 = vec2(42u, 43u); var xvuaiu_2: vec2 = vec2(42u, 43u); +var xvip_1: vec2 = vec2(0i, 0i); +var xvup_1: vec2 = vec2(0u, 0u); +var xvfp_1: vec2 = vec2(0f, 0f); +var xmfp_1: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); var xmfpaiaiaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpafaiaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpaiafaiai_1: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -18,13 +24,18 @@ var xvfs_ai_1: vec2 = vec2(1f); var xvfs_af_1: vec2 = vec2(1f); var xafafaf_1: array = array(1f, 2f); var xafaiai_1: array = array(1f, 2f); -var xafpaiai_1: array = array(1i, 2i); +var xaipaiai_1: array = array(1i, 2i); +var xaupaiai: array = array(1u, 2u); var xafpaiaf_1: array = array(1f, 2f); var xafpafai_1: array = array(1f, 2f); var xafpafaf_1: array = array(1f, 2f); var xavipai_1: array, 1> = array, 1>(vec3(1i)); var xavfpai_1: array, 1> = array, 1>(vec3(1f)); var xavfpaf_1: array, 1> = array, 1>(vec3(1f)); +var xvisai_1: vec2 = vec2(1i); +var xvusai_1: vec2 = vec2(1u); +var xvfsai_1: vec2 = vec2(1f); +var xvfsaf_1: vec2 = vec2(1f); var ivispai: vec2 = vec2(1i); var ivfspaf: vec2 = vec2(1f); var ivis_ai: vec2 = vec2(1i); @@ -45,10 +56,16 @@ fn all_constant_arguments() { var xvipaiai: vec2 = vec2(42i, 43i); var xvupaiai: vec2 = vec2(44u, 45u); var xvfpaiai: vec2 = vec2(46f, 47f); + var xvfpafaf: vec2 = vec2(48f, 49f); + var xvfpaiaf: vec2 = vec2(48f, 49f); var xvupuai: vec2 = vec2(42u, 43u); var xvupaiu: vec2 = vec2(42u, 43u); var xvuuai: vec2 = vec2(42u, 43u); var xvuaiu: vec2 = vec2(42u, 43u); + var xvip: vec2 = vec2(0i, 0i); + var xvup: vec2 = vec2(0u, 0u); + var xvfp: vec2 = vec2(0f, 0f); + var xmfp: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); var xmfpaiaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpafaiaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); var xmfpaiafaiai: mat2x2 = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -78,6 +95,10 @@ fn all_constant_arguments() { var xavipai: array, 1> = array, 1>(vec3(1i)); var xavfpai: array, 1> = array, 1>(vec3(1f)); var xavfpaf: array, 1> = array, 1>(vec3(1f)); + var xvisai: vec2 = vec2(1i); + var xvusai: vec2 = vec2(1u); + var xvfsai: vec2 = vec2(1f); + var xvfsaf: vec2 = vec2(1f); var iaipaiai: array = array(1i, 2i); var iafpaiaf: array = array(1f, 2f); var iafpafai: array = array(1f, 2f); @@ -86,10 +107,16 @@ fn all_constant_arguments() { xvipaiai = vec2(42i, 43i); xvupaiai = vec2(44u, 45u); xvfpaiai = vec2(46f, 47f); + xvfpafaf = vec2(48f, 49f); + xvfpaiaf = vec2(48f, 49f); xvupuai = vec2(42u, 43u); xvupaiu = vec2(42u, 43u); xvuuai = vec2(42u, 43u); xvuaiu = vec2(42u, 43u); + xvip = vec2(0i, 0i); + xvup = vec2(0u, 0u); + xvfp = vec2(0f, 0f); + xmfp = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); xmfpaiaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); xmfpafaiaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); xmfpaiafaiai = mat2x2(vec2(1f, 2f), vec2(3f, 4f)); @@ -119,6 +146,10 @@ fn all_constant_arguments() { xavipai = array, 1>(vec3(1i)); xavfpai = array, 1>(vec3(1f)); xavfpaf = array, 1>(vec3(1f)); + xvisai = vec2(1i); + xvusai = vec2(1u); + xvfsai = vec2(1f); + xvfsaf = vec2(1f); iaipaiai = array(1i, 2i); iafpaiaf = array(1f, 2f); iafpafai = array(1f, 2f); @@ -132,6 +163,8 @@ fn mixed_constant_and_runtime_arguments() { var f: f32; var xvupuai_1: vec2; var xvupaiu_1: vec2; + var xvfpfai: vec2; + var xvfpfaf: vec2; var xvuuai_1: vec2; var xvuaiu_1: vec2; var xmfp_faiaiai_1: mat2x2; @@ -150,87 +183,106 @@ fn mixed_constant_and_runtime_arguments() { var xafpai_f: array; var xaip_iai: array; var xaipai_i: array; + var xvisi: vec2; + var xvusu: vec2; + var xvfsf: vec2; let _e3 = u; xvupuai_1 = vec2(_e3, 43u); let _e7 = u; xvupaiu_1 = vec2(42u, _e7); - let _e11 = u; - xvuuai_1 = vec2(_e11, 43u); - let _e15 = u; - xvuaiu_1 = vec2(42u, _e15); - let _e19 = f; - xmfp_faiaiai_1 = mat2x2(vec2(_e19, 2f), vec2(3f, 4f)); + let _e11 = f; + xvfpfai = vec2(_e11, 47f); + let _e15 = f; + xvfpfaf = vec2(_e15, 49f); + let _e19 = u; + xvuuai_1 = vec2(_e19, 43u); + let _e23 = u; + xvuaiu_1 = vec2(42u, _e23); let _e27 = f; - xmfpai_faiai_1 = mat2x2(vec2(1f, _e27), vec2(3f, 4f)); + xmfp_faiaiai_1 = mat2x2(vec2(_e27, 2f), vec2(3f, 4f)); let _e35 = f; - xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e35, 4f)); + xmfpai_faiai_1 = mat2x2(vec2(1f, _e35), vec2(3f, 4f)); let _e43 = f; - xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e43)); + xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e43, 4f)); let _e51 = f; - xaf_faf_1 = array(_e51, 2f); - let _e55 = f; - xafaf_f_1 = array(1f, _e55); + xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e51)); let _e59 = f; - xaf_fai = array(_e59, 2f); + xaf_faf_1 = array(_e59, 2f); let _e63 = f; - xafai_f = array(1f, _e63); - let _e67 = i; - xai_iai_1 = array(_e67, 2i); - let _e71 = i; - xaiai_i_1 = array(1i, _e71); - let _e75 = f; - xafp_faf = array(_e75, 2f); - let _e79 = f; - xafpaf_f = array(1f, _e79); + xafaf_f_1 = array(1f, _e63); + let _e67 = f; + xaf_fai = array(_e67, 2f); + let _e71 = f; + xafai_f = array(1f, _e71); + let _e75 = i; + xai_iai_1 = array(_e75, 2i); + let _e79 = i; + xaiai_i_1 = array(1i, _e79); let _e83 = f; - xafp_fai = array(_e83, 2f); + xafp_faf = array(_e83, 2f); let _e87 = f; - xafpai_f = array(1f, _e87); - let _e91 = i; - xaip_iai = array(_e91, 2i); - let _e95 = i; - xaipai_i = array(1i, _e95); - let _e99 = u; - xvupuai_1 = vec2(_e99, 43u); - let _e102 = u; - xvupaiu_1 = vec2(42u, _e102); - let _e105 = u; - xvuuai_1 = vec2(_e105, 43u); - let _e108 = u; - xvuaiu_1 = vec2(42u, _e108); - let _e111 = f; - xmfp_faiaiai_1 = mat2x2(vec2(_e111, 2f), vec2(3f, 4f)); - let _e118 = f; - xmfpai_faiai_1 = mat2x2(vec2(1f, _e118), vec2(3f, 4f)); - let _e125 = f; - xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e125, 4f)); - let _e132 = f; - xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e132)); - let _e139 = f; - xaf_faf_1 = array(_e139, 2f); + xafpaf_f = array(1f, _e87); + let _e91 = f; + xafp_fai = array(_e91, 2f); + let _e95 = f; + xafpai_f = array(1f, _e95); + let _e99 = i; + xaip_iai = array(_e99, 2i); + let _e103 = i; + xaipai_i = array(1i, _e103); + let _e107 = i; + xvisi = vec2(_e107); + let _e110 = u; + xvusu = vec2(_e110); + let _e113 = f; + xvfsf = vec2(_e113); + let _e116 = u; + xvupuai_1 = vec2(_e116, 43u); + let _e119 = u; + xvupaiu_1 = vec2(42u, _e119); + let _e122 = u; + xvuuai_1 = vec2(_e122, 43u); + let _e125 = u; + xvuaiu_1 = vec2(42u, _e125); + let _e128 = f; + xmfp_faiaiai_1 = mat2x2(vec2(_e128, 2f), vec2(3f, 4f)); + let _e135 = f; + xmfpai_faiai_1 = mat2x2(vec2(1f, _e135), vec2(3f, 4f)); let _e142 = f; - xafaf_f_1 = array(1f, _e142); - let _e145 = f; - xaf_fai = array(_e145, 2f); - let _e148 = f; - xafai_f = array(1f, _e148); - let _e151 = i; - xai_iai_1 = array(_e151, 2i); - let _e154 = i; - xaiai_i_1 = array(1i, _e154); - let _e157 = f; - xafp_faf = array(_e157, 2f); - let _e160 = f; - xafpaf_f = array(1f, _e160); - let _e163 = f; - xafp_fai = array(_e163, 2f); - let _e166 = f; - xafpai_f = array(1f, _e166); - let _e169 = i; - xaip_iai = array(_e169, 2i); - let _e172 = i; - xaipai_i = array(1i, _e172); + xmfpaiai_fai_1 = mat2x2(vec2(1f, 2f), vec2(_e142, 4f)); + let _e149 = f; + xmfpaiaiai_f_1 = mat2x2(vec2(1f, 2f), vec2(3f, _e149)); + let _e156 = f; + xaf_faf_1 = array(_e156, 2f); + let _e159 = f; + xafaf_f_1 = array(1f, _e159); + let _e162 = f; + xaf_fai = array(_e162, 2f); + let _e165 = f; + xafai_f = array(1f, _e165); + let _e168 = i; + xai_iai_1 = array(_e168, 2i); + let _e171 = i; + xaiai_i_1 = array(1i, _e171); + let _e174 = f; + xafp_faf = array(_e174, 2f); + let _e177 = f; + xafpaf_f = array(1f, _e177); + let _e180 = f; + xafp_fai = array(_e180, 2f); + let _e183 = f; + xafpai_f = array(1f, _e183); + let _e186 = i; + xaip_iai = array(_e186, 2i); + let _e189 = i; + xaipai_i = array(1i, _e189); + let _e192 = i; + xvisi = vec2(_e192); + let _e194 = u; + xvusu = vec2(_e194); + let _e196 = f; + xvfsf = vec2(_e196); return; } diff --git a/naga/tests/out/wgsl/constructors.wgsl b/naga/tests/out/wgsl/constructors.wgsl index 039b4f971..bcab8e699 100644 --- a/naga/tests/out/wgsl/constructors.wgsl +++ b/naga/tests/out/wgsl/constructors.wgsl @@ -3,6 +3,7 @@ struct Foo { b: i32, } +const const1_: vec3 = vec3(0f); const const3_: mat2x2 = mat2x2(vec2(0f, 1f), vec2(2f, 3f)); const const4_: array, 1> = array, 1>(mat2x2(vec2(0f, 1f), vec2(2f, 3f))); const cz0_: bool = bool(); @@ -13,6 +14,7 @@ const cz4_: vec2 = vec2(); const cz5_: mat2x2 = mat2x2(); const cz6_: array = array(); const cz7_: Foo = Foo(); +const cp1_: vec2 = vec2(0u); @compute @workgroup_size(1, 1, 1) fn main() { @@ -21,6 +23,8 @@ fn main() { foo = Foo(vec4(1f), 1i); let m0_ = mat2x2(vec2(1f, 0f), vec2(0f, 1f)); let m1_ = mat4x4(vec4(1f, 0f, 0f, 0f), vec4(0f, 1f, 0f, 0f), vec4(0f, 0f, 1f, 0f), vec4(0f, 0f, 0f, 1f)); + let zvc8_ = vec2(0u, 0u); + let zvc9_ = vec2(0f, 0f); let cit0_ = vec2(0u); let cit1_ = mat2x2(vec2(0f), vec2(0f)); let cit2_ = array(0i, 1i, 2i, 3i); diff --git a/naga/tests/out/wgsl/conversions.wgsl b/naga/tests/out/wgsl/conversions.wgsl new file mode 100644 index 000000000..2d24e5a53 --- /dev/null +++ b/naga/tests/out/wgsl/conversions.wgsl @@ -0,0 +1,9 @@ +const ic0_: vec2 = vec2(2f, 2f); + +@compute @workgroup_size(1, 1, 1) +fn main() { + var vc0_: vec2 = vec2(2f, 2f); + + let lc0_ = vec2(2f, 2f); + return; +} diff --git a/naga/tests/out/wgsl/type-inference.wgsl b/naga/tests/out/wgsl/type-inference.wgsl new file mode 100644 index 000000000..487752bb2 --- /dev/null +++ b/naga/tests/out/wgsl/type-inference.wgsl @@ -0,0 +1,43 @@ +const g1_: u32 = 1u; +const g3_: f32 = 1f; +const g4_: vec4 = vec4(); +const g5_: vec4 = vec4(1i); +const g6_: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + +@compute @workgroup_size(1, 1, 1) +fn main() { + var g0x: i32 = 1i; + var g2x: f32 = 1f; + var g7x: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + var c0x: i32 = 1i; + var c1x: u32 = 1u; + var c2x: f32 = 1f; + var c3x: f32 = 1f; + var c4x: vec4 = vec4(); + var c5x: vec4 = vec4(1i); + var c6x: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + var c7x: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + var l0x: i32; + var l1x: u32; + var l2x: f32; + var l3x: f32; + var l4x: vec4; + var v0_: i32 = 1i; + var v1_: u32 = 1u; + var v2_: f32 = 1f; + var v3_: f32 = 1f; + var v4_: vec4 = vec4(); + var v5_: vec4 = vec4(1i); + var v6_: mat2x2 = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + var v7_: mat2x2 = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + + let l5_ = vec4(1i); + let l6_ = mat2x2(vec2(0f, 0f), vec2(0f, 0f)); + let l7_ = mat2x2(vec2(1f, 1f), vec2(1f, 1f)); + l0x = 1i; + l1x = 1u; + l2x = 1f; + l3x = 1f; + l4x = vec4(); + return; +}