From 92c30dc1de70dce10dd641352b9155d34edcd58d Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 19 Apr 2023 14:55:07 +0200 Subject: [PATCH 01/37] [wgsl-in] eagerly evaluate const-expressions [wgsl-in] support const-expressions in attributes allow `Splat` as an evaluated const-expression type --- src/back/glsl/mod.rs | 47 +- src/back/hlsl/writer.rs | 31 +- src/back/msl/writer.rs | 90 +- src/back/spv/writer.rs | 21 +- src/front/glsl/builtins.rs | 2 +- src/front/glsl/context.rs | 2 +- src/front/glsl/error.rs | 8 +- src/front/glsl/mod.rs | 1 - src/front/glsl/parser.rs | 2 +- src/front/glsl/parser/declarations.rs | 2 +- src/front/glsl/parser/functions.rs | 7 +- src/front/glsl/types.rs | 21 +- src/front/mod.rs | 3 + src/front/wgsl/error.rs | 55 +- src/front/wgsl/lower/construction.rs | 8 +- src/front/wgsl/lower/mod.rs | 302 +++-- src/front/wgsl/parse/ast.rs | 43 +- src/front/wgsl/parse/mod.rs | 127 +- src/front/wgsl/tests.rs | 10 +- .../constant_evaluator.rs} | 909 ++++++++----- src/proc/mod.rs | 47 +- src/valid/expression.rs | 6 + tests/out/glsl/constructors.main.Compute.glsl | 7 +- .../cubeArrayShadow.fragment.Fragment.glsl | 4 +- .../glsl/image.texture_sample.Fragment.glsl | 136 +- tests/out/glsl/operators.main.Compute.glsl | 112 +- tests/out/hlsl/constructors.hlsl | 7 +- tests/out/hlsl/image.hlsl | 140 +- tests/out/hlsl/operators.hlsl | 112 +- tests/out/ir/access.ron | 11 + tests/out/ir/collatz.ron | 6 +- tests/out/msl/constructors.msl | 7 +- tests/out/msl/image.msl | 136 +- tests/out/msl/operators.msl | 112 +- tests/out/spv/constructors.spvasm | 9 +- tests/out/spv/debug-symbol-terrain.spvasm | 1135 ++++++++--------- tests/out/spv/image.spvasm | 569 +++++---- tests/out/spv/operators.spvasm | 1026 +++++++-------- tests/out/wgsl/constructors.wgsl | 7 +- tests/out/wgsl/image.wgsl | 136 +- tests/out/wgsl/module-scope.wgsl | 3 +- tests/out/wgsl/operators.wgsl | 112 +- tests/out/wgsl/type-alias.wgsl | 2 +- tests/wgsl-errors.rs | 134 +- 44 files changed, 2907 insertions(+), 2760 deletions(-) rename src/{front/glsl/constants.rs => proc/constant_evaluator.rs} (52%) diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index 86b1aecd06..12d358bb80 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -1709,7 +1709,7 @@ impl<'a, W: Write> Writer<'a, W> { arg: Handle, arg1: Handle, size: usize, - ctx: &back::FunctionCtx<'_>, + ctx: &back::FunctionCtx, ) -> BackendResult { // Write parantheses around the dot product expression to prevent operators // with different precedences from applying earlier. @@ -2254,9 +2254,12 @@ impl<'a, W: Write> Writer<'a, W> { /// [`Expression`]: crate::Expression /// [`Module`]: crate::Module fn write_const_expr(&mut self, expr: Handle) -> BackendResult { - self.write_possibly_const_expr(expr, &self.module.const_expressions, |writer, expr| { - writer.write_const_expr(expr) - }) + self.write_possibly_const_expr( + expr, + &self.module.const_expressions, + |expr| &self.info[expr], + |writer, expr| writer.write_const_expr(expr), + ) } /// Write [`Expression`] variants that can occur in both runtime and const expressions. @@ -2277,13 +2280,15 @@ impl<'a, W: Write> Writer<'a, W> { /// Adds no newlines or leading/trailing whitespace /// /// [`Expression`]: crate::Expression - fn write_possibly_const_expr( - &mut self, + fn write_possibly_const_expr<'w, I, E>( + &'w mut self, expr: Handle, expressions: &crate::Arena, + info: I, write_expression: E, ) -> BackendResult where + I: Fn(Handle) -> &'w proc::TypeResolution, E: Fn(&mut Self, Handle) -> BackendResult, { use crate::Expression; @@ -2331,6 +2336,14 @@ impl<'a, W: Write> Writer<'a, W> { } write!(self.out, ")")? } + // `Splat` needs to actually write down a vector, it's not always inferred in GLSL. + Expression::Splat { size: _, value } => { + let resolved = info(expr).inner_with(&self.module.types); + self.write_value_type(resolved)?; + write!(self.out, "(")?; + write_expression(self, value)?; + write!(self.out, ")")? + } _ => unreachable!(), } @@ -2344,7 +2357,7 @@ impl<'a, W: Write> Writer<'a, W> { fn write_expr( &mut self, expr: Handle, - ctx: &back::FunctionCtx<'_>, + ctx: &back::FunctionCtx, ) -> BackendResult { use crate::Expression; @@ -2357,10 +2370,14 @@ impl<'a, W: Write> Writer<'a, W> { Expression::Literal(_) | Expression::Constant(_) | Expression::ZeroValue(_) - | Expression::Compose { .. } => { - self.write_possibly_const_expr(expr, ctx.expressions, |writer, expr| { - writer.write_expr(expr, ctx) - })?; + | Expression::Compose { .. } + | Expression::Splat { .. } => { + self.write_possibly_const_expr( + expr, + ctx.expressions, + |expr| &ctx.info[expr].ty, + |writer, expr| writer.write_expr(expr, ctx), + )?; } // `Access` is applied to arrays, vectors and matrices and is written as indexing Expression::Access { base, index } => { @@ -2407,14 +2424,6 @@ impl<'a, W: Write> Writer<'a, W> { ref other => return Err(Error::Custom(format!("Cannot index {other:?}"))), } } - // `Splat` needs to actually write down a vector, it's not always inferred in GLSL. - Expression::Splat { size: _, value } => { - let resolved = ctx.info[expr].ty.inner_with(&self.module.types); - self.write_value_type(resolved)?; - write!(self.out, "(")?; - self.write_expr(value, ctx)?; - write!(self.out, ")")? - } // `Swizzle` adds a few letters behind the dot. Expression::Swizzle { size, diff --git a/src/back/hlsl/writer.rs b/src/back/hlsl/writer.rs index e9809bd2d4..a2e0d2fefa 100644 --- a/src/back/hlsl/writer.rs +++ b/src/back/hlsl/writer.rs @@ -2078,6 +2078,19 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } write!(self.out, ")")?; } + Expression::Splat { size, value } => { + // hlsl is not supported one value constructor + // if we write, for example, int4(0), dxc returns error: + // error: too few elements in vector initialization (expected 4 elements, have 1) + let number_of_components = match size { + crate::VectorSize::Bi => "xx", + crate::VectorSize::Tri => "xxx", + crate::VectorSize::Quad => "xxxx", + }; + write!(self.out, "(")?; + write_expression(self, value)?; + write!(self.out, ").{number_of_components}")? + } _ => unreachable!(), } @@ -2135,7 +2148,8 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { Expression::Literal(_) | Expression::Constant(_) | Expression::ZeroValue(_) - | Expression::Compose { .. } => { + | Expression::Compose { .. } + | Expression::Splat { .. } => { self.write_possibly_const_expression( module, expr, @@ -2423,7 +2437,9 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(offset) = offset { write!(self.out, ", ")?; + write!(self.out, "int2(")?; // work around https://github.com/microsoft/DirectXShaderCompiler/issues/5082#issuecomment-1540147807 self.write_const_expression(module, offset)?; + write!(self.out, ")")?; } write!(self.out, ")")?; @@ -3154,19 +3170,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { self.write_expr(module, argument, func_ctx)?; write!(self.out, ")")? } - Expression::Splat { size, value } => { - // hlsl is not supported one value constructor - // if we write, for example, int4(0), dxc returns error: - // error: too few elements in vector initialization (expected 4 elements, have 1) - let number_of_components = match size { - crate::VectorSize::Bi => "xx", - crate::VectorSize::Tri => "xxx", - crate::VectorSize::Quad => "xxxx", - }; - write!(self.out, "(")?; - self.write_expr(module, value, func_ctx)?; - write!(self.out, ").{number_of_components}")? - } Expression::Select { condition, accept, diff --git a/src/back/msl/writer.rs b/src/back/msl/writer.rs index 77231a286d..fee917b035 100644 --- a/src/back/msl/writer.rs +++ b/src/back/msl/writer.rs @@ -501,6 +501,7 @@ struct ExpressionContext<'a> { origin: FunctionOrigin, info: &'a valid::FunctionInfo, module: &'a crate::Module, + mod_info: &'a valid::ModuleInfo, pipeline_options: &'a PipelineOptions, policies: index::BoundsCheckPolicies, @@ -571,7 +572,6 @@ impl<'a> ExpressionContext<'a> { struct StatementContext<'a> { expression: ExpressionContext<'a>, - mod_info: &'a valid::ModuleInfo, result_struct: Option<&'a str>, } @@ -604,25 +604,26 @@ impl Writer { parameters: impl Iterator>, context: &ExpressionContext, ) -> BackendResult { - self.put_call_parameters_impl(parameters, |writer, expr| { + self.put_call_parameters_impl(parameters, context, |writer, context, expr| { writer.put_expression(expr, context, true) }) } - fn put_call_parameters_impl( + fn put_call_parameters_impl( &mut self, parameters: impl Iterator>, + ctx: &C, put_expression: E, ) -> BackendResult where - E: Fn(&mut Self, Handle) -> BackendResult, + E: Fn(&mut Self, &C, Handle) -> BackendResult, { write!(self.out, "(")?; for (i, handle) in parameters.enumerate() { if i != 0 { write!(self.out, ", ")?; } - put_expression(self, handle)?; + put_expression(self, ctx, handle)?; } write!(self.out, ")")?; Ok(()) @@ -1213,24 +1214,33 @@ impl Writer { &mut self, expr_handle: Handle, module: &crate::Module, + mod_info: &valid::ModuleInfo, ) -> BackendResult { self.put_possibly_const_expression( expr_handle, &module.const_expressions, module, - |writer, expr| writer.put_const_expression(expr, module), + mod_info, + &(module, mod_info), + |&(_, mod_info), expr| &mod_info[expr], + |writer, &(module, _), expr| writer.put_const_expression(expr, module, mod_info), ) } - fn put_possibly_const_expression( + #[allow(clippy::too_many_arguments)] + fn put_possibly_const_expression( &mut self, expr_handle: Handle, expressions: &crate::Arena, module: &crate::Module, + mod_info: &valid::ModuleInfo, + ctx: &C, + get_expr_ty: I, put_expression: E, ) -> BackendResult where - E: Fn(&mut Self, Handle) -> BackendResult, + I: Fn(&C, Handle) -> &TypeResolution, + E: Fn(&mut Self, &C, Handle) -> BackendResult, { match expressions[expr_handle] { crate::Expression::Literal(literal) => match literal { @@ -1263,7 +1273,7 @@ impl Writer { if constant.name.is_some() { write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; } else { - self.put_const_expression(constant.init, module)?; + self.put_const_expression(constant.init, module, mod_info)?; } } crate::Expression::ZeroValue(ty) => { @@ -1291,7 +1301,11 @@ impl Writer { crate::TypeInner::Scalar { .. } | crate::TypeInner::Vector { .. } | crate::TypeInner::Matrix { .. } => { - self.put_call_parameters_impl(components.iter().copied(), put_expression)?; + self.put_call_parameters_impl( + components.iter().copied(), + ctx, + put_expression, + )?; } crate::TypeInner::Array { .. } | crate::TypeInner::Struct { .. } => { write!(self.out, " {{")?; @@ -1303,13 +1317,23 @@ impl Writer { if self.struct_member_pads.contains(&(ty, index as u32)) { write!(self.out, "{{}}, ")?; } - put_expression(self, component)?; + put_expression(self, ctx, component)?; } write!(self.out, "}}")?; } _ => return Err(Error::UnsupportedCompose(ty)), } } + crate::Expression::Splat { size, value } => { + let scalar_kind = match *get_expr_ty(ctx, value).inner_with(&module.types) { + crate::TypeInner::Scalar { kind, .. } => kind, + _ => return Err(Error::Validation), + }; + put_numeric_type(&mut self.out, scalar_kind, &[size])?; + write!(self.out, "(")?; + put_expression(self, ctx, value)?; + write!(self.out, ")")?; + } _ => unreachable!(), } @@ -1350,12 +1374,16 @@ impl Writer { crate::Expression::Literal(_) | crate::Expression::Constant(_) | crate::Expression::ZeroValue(_) - | crate::Expression::Compose { .. } => { + | crate::Expression::Compose { .. } + | crate::Expression::Splat { .. } => { self.put_possibly_const_expression( expr_handle, &context.function.expressions, context.module, - |writer, expr| writer.put_expression(expr, context, true), + context.mod_info, + context, + |context, expr: Handle| &context.info[expr].ty, + |writer, context, expr| writer.put_expression(expr, context, true), )?; } crate::Expression::Access { base, .. } @@ -1385,16 +1413,6 @@ impl Writer { self.put_access_chain(expr_handle, policy, context)?; } } - crate::Expression::Splat { size, value } => { - let scalar_kind = match *context.resolve_type(value) { - crate::TypeInner::Scalar { kind, .. } => kind, - _ => return Err(Error::Validation), - }; - put_numeric_type(&mut self.out, scalar_kind, &[size])?; - write!(self.out, "(")?; - self.put_expression(value, context, true)?; - write!(self.out, ")")?; - } crate::Expression::Swizzle { size, vector, @@ -1469,7 +1487,7 @@ impl Writer { if let Some(offset) = offset { write!(self.out, ", ")?; - self.put_const_expression(offset, context.module)?; + self.put_const_expression(offset, context.module, context.mod_info)?; } match gather { @@ -2792,7 +2810,7 @@ impl Writer { } // follow-up with any global resources used let mut separate = !arguments.is_empty(); - let fun_info = &context.mod_info[function]; + let fun_info = &context.expression.mod_info[function]; let mut supports_array_length = false; for (handle, var) in context.expression.module.global_variables.iter() { if fun_info[handle].is_empty() { @@ -3131,7 +3149,7 @@ impl Writer { }; self.write_type_defs(module)?; - self.write_global_constants(module)?; + self.write_global_constants(module, info)?; self.write_functions(module, info, options, pipeline_options) } @@ -3338,7 +3356,11 @@ impl Writer { } /// Writes all named constants - fn write_global_constants(&mut self, module: &crate::Module) -> BackendResult { + fn write_global_constants( + &mut self, + module: &crate::Module, + mod_info: &valid::ModuleInfo, + ) -> BackendResult { let constants = module.constants.iter().filter(|&(_, c)| c.name.is_some()); for (handle, constant) in constants { @@ -3352,7 +3374,7 @@ impl Writer { }; let name = &self.names[&NameKey::Constant(handle)]; write!(self.out, "constant {ty_name} {name} = ")?; - self.put_const_expression(constant.init, module)?; + self.put_const_expression(constant.init, module, mod_info)?; writeln!(self.out, ";")?; } @@ -3549,7 +3571,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_const_expression(value, module, mod_info)?; } None => { write!(self.out, " = {{}}")?; @@ -3569,9 +3591,9 @@ impl Writer { policies: options.bounds_check_policies, guarded_indices, module, + mod_info, pipeline_options, }, - mod_info, result_struct: None, }; self.named_expressions.clear(); @@ -3958,7 +3980,7 @@ impl Writer { } if let Some(value) = var.init { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_const_expression(value, module, mod_info)?; } writeln!(self.out)?; } @@ -4014,7 +4036,7 @@ impl Writer { match var.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_const_expression(value, module, mod_info)?; writeln!(self.out, ";")?; } None => { @@ -4106,7 +4128,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_const_expression(value, module, mod_info)?; } None => { write!(self.out, " = {{}}")?; @@ -4126,9 +4148,9 @@ impl Writer { policies: options.bounds_check_policies, guarded_indices, module, + mod_info, pipeline_options, }, - mod_info, result_struct: Some(&stage_out_name), }; self.named_expressions.clear(); diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 8cad9c4d27..4be19cce66 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -198,11 +198,15 @@ impl Writer { } } - pub(super) fn get_expression_type_id(&mut self, tr: &TypeResolution) -> Word { - let lookup_ty = match *tr { + pub(super) fn get_expression_lookup_type(&mut self, tr: &TypeResolution) -> LookupType { + match *tr { TypeResolution::Handle(ty_handle) => LookupType::Handle(ty_handle), TypeResolution::Value(ref inner) => LookupType::Local(make_local(inner).unwrap()), - }; + } + } + + pub(super) fn get_expression_type_id(&mut self, tr: &TypeResolution) -> Word { + let lookup_ty = self.get_expression_lookup_type(tr); self.get_type_id(lookup_ty) } @@ -1242,6 +1246,7 @@ impl Writer { &mut self, handle: Handle, ir_module: &crate::Module, + mod_info: &ModuleInfo, ) -> Result { let id = match ir_module.const_expressions[handle] { crate::Expression::Literal(literal) => self.get_constant_scalar(literal), @@ -1260,6 +1265,14 @@ impl Writer { .collect(); self.get_constant_composite(LookupType::Handle(ty), component_ids.as_slice()) } + crate::Expression::Splat { size, value } => { + let value_id = self.constant_ids[value.index()]; + let component_ids = &[value_id; 4][..size as usize]; + + let ty = self.get_expression_lookup_type(&mod_info[handle]); + + self.get_constant_composite(ty, component_ids) + } _ => unreachable!(), }; @@ -1878,7 +1891,7 @@ impl Writer { self.constant_ids .resize(ir_module.const_expressions.len(), 0); for (handle, _) in ir_module.const_expressions.iter() { - self.write_constant_expr(handle, ir_module)?; + self.write_constant_expr(handle, ir_module, mod_info)?; } debug_assert!(self.constant_ids.iter().all(|&id| id != 0)); diff --git a/src/front/glsl/builtins.rs b/src/front/glsl/builtins.rs index 811be65cce..ff386e2e1e 100644 --- a/src/front/glsl/builtins.rs +++ b/src/front/glsl/builtins.rs @@ -1795,7 +1795,7 @@ impl MacroCall { true => { let offset_arg = args[num_args]; num_args += 1; - match ctx.solve_constant(offset_arg, meta) { + match ctx.eval_constant(offset_arg, meta) { Ok(v) => Some(v), Err(e) => { frontend.errors.push(e); diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 407619c3d2..ffdc2bd978 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -519,7 +519,7 @@ impl<'a> Context<'a> { // Don't try to generate `AccessIndex` if in a LHS position, since it // wouldn't produce a pointer. ExprPos::Lhs => None, - _ => self.solve_constant(index, index_meta).ok(), + _ => self.eval_constant(index, index_meta).ok(), }; let base = self diff --git a/src/front/glsl/error.rs b/src/front/glsl/error.rs index 46b3aecd08..d6e3586687 100644 --- a/src/front/glsl/error.rs +++ b/src/front/glsl/error.rs @@ -1,5 +1,5 @@ -use super::{constants::ConstantSolvingError, token::TokenValue}; -use crate::Span; +use super::token::TokenValue; +use crate::{proc::ConstantEvaluatorError, Span}; use pp_rs::token::PreprocessorError; use std::borrow::Cow; use thiserror::Error; @@ -116,8 +116,8 @@ pub enum ErrorKind { InternalError(&'static str), } -impl From for ErrorKind { - fn from(err: ConstantSolvingError) -> Self { +impl From for ErrorKind { + fn from(err: ConstantEvaluatorError) -> Self { ErrorKind::SemanticError(err.to_string().into()) } } diff --git a/src/front/glsl/mod.rs b/src/front/glsl/mod.rs index f8f554bf2d..4ce0dc4783 100644 --- a/src/front/glsl/mod.rs +++ b/src/front/glsl/mod.rs @@ -22,7 +22,6 @@ use parser::ParsingContext; mod ast; mod builtins; -mod constants; mod context; mod error; mod functions; diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index 1a3b5a9086..075dce17e0 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -226,7 +226,7 @@ impl<'source> ParsingContext<'source> { let expr = self.parse_conditional(frontend, &mut ctx, &mut stmt_ctx, None)?; let (root, meta) = ctx.lower_expect(stmt_ctx, frontend, expr, ExprPos::Rhs)?; - Ok((ctx.solve_constant(root, meta)?, meta)) + Ok((ctx.eval_constant(root, meta)?, meta)) } } diff --git a/src/front/glsl/parser/declarations.rs b/src/front/glsl/parser/declarations.rs index 2abd67672b..75e18ea3b6 100644 --- a/src/front/glsl/parser/declarations.rs +++ b/src/front/glsl/parser/declarations.rs @@ -241,7 +241,7 @@ impl<'source> ParsingContext<'source> { let is_const = ctx.qualifiers.storage.0 == StorageQualifier::Const; let maybe_const_expr = if ctx.external { if let Some((root, meta)) = init { - match ctx.ctx.solve_constant(root, meta) { + match ctx.ctx.eval_constant(root, meta) { Ok(res) => Some(res), // If the declaration is external (global scope) and is constant qualified // then the initializer must be a constant expression diff --git a/src/front/glsl/parser/functions.rs b/src/front/glsl/parser/functions.rs index 200afc78fd..91b7787875 100644 --- a/src/front/glsl/parser/functions.rs +++ b/src/front/glsl/parser/functions.rs @@ -187,11 +187,8 @@ impl<'source> ParsingContext<'source> { TokenValue::Case => { self.bump(frontend)?; - let mut stmt = ctx.stmt_ctx(); - let expr = self.parse_expression(frontend, ctx, &mut stmt)?; - let (root, meta) = - ctx.lower_expect(stmt, frontend, expr, ExprPos::Rhs)?; - let const_expr = ctx.solve_constant(root, meta)?; + let (const_expr, meta) = + self.parse_constant_expression(frontend, ctx.module)?; match ctx.module.const_expressions[const_expr] { Expression::Literal(Literal::I32(value)) => match uint { diff --git a/src/front/glsl/types.rs b/src/front/glsl/types.rs index a91a0a9f28..a8bb047e47 100644 --- a/src/front/glsl/types.rs +++ b/src/front/glsl/types.rs @@ -1,4 +1,4 @@ -use super::{constants::ConstantSolver, context::Context, Error, ErrorKind, Result, Span}; +use super::{context::Context, Error, ErrorKind, Result, Span}; use crate::{ proc::ResolveContext, Bytes, Expression, Handle, ImageClass, ImageDimension, ScalarKind, Type, TypeInner, VectorSize, @@ -305,19 +305,28 @@ impl Context<'_> { }) } - pub(crate) fn solve_constant( + pub(crate) fn eval_constant( &mut self, root: Handle, meta: Span, ) -> Result> { - let mut solver = ConstantSolver { + let mut solver = crate::proc::ConstantEvaluator { types: &mut self.module.types, - expressions: &self.expressions, + expressions: &mut self.module.const_expressions, constants: &mut self.module.constants, - const_expressions: &mut self.module.const_expressions, + const_expressions: Some(&self.expressions), + append: None::< + Box< + dyn FnMut( + &mut crate::Arena, + Expression, + Span, + ) -> Handle, + >, + >, }; - solver.solve(root).map_err(|e| Error { + solver.eval(root).map_err(|e| Error { kind: e.into(), meta, }) diff --git a/src/front/mod.rs b/src/front/mod.rs index 1f16ff6378..faebde4e24 100644 --- a/src/front/mod.rs +++ b/src/front/mod.rs @@ -34,6 +34,9 @@ impl Emitter { } self.start_len = Some(arena.len()); } + const fn is_running(&self) -> bool { + self.start_len.is_some() + } #[must_use] fn finish( &mut self, diff --git a/src/front/wgsl/error.rs b/src/front/wgsl/error.rs index f7bed6cdf9..93fff04906 100644 --- a/src/front/wgsl/error.rs +++ b/src/front/wgsl/error.rs @@ -1,5 +1,5 @@ use crate::front::wgsl::parse::lexer::Token; -use crate::proc::{Alignment, ResolveError}; +use crate::proc::{Alignment, ConstantEvaluatorError, ResolveError}; use crate::{SourceLocation, Span}; use codespan_reporting::diagnostic::{Diagnostic, Label}; use codespan_reporting::files::SimpleFile; @@ -98,8 +98,6 @@ impl std::error::Error for ParseError { pub enum ExpectedToken<'a> { Token(Token<'a>), Identifier, - Number, - Integer, /// Expected: constant, parenthesized expression, identifier PrimaryExpression, /// Expected: assignment, increment/decrement expression @@ -141,10 +139,6 @@ pub enum Error<'a> { UnexpectedComponents(Span), UnexpectedOperationInConstContext(Span), BadNumber(Span, NumberError), - /// A negative signed integer literal where both signed and unsigned, - /// but only non-negative literals are allowed. - NegativeInt(Span), - BadU32Constant(Span), BadMatrixScalarKind(Span, crate::ScalarKind, u8), BadAccessor(Span), BadTexture(Span), @@ -240,9 +234,11 @@ pub enum Error<'a> { FunctionReturnsVoid(Span), InvalidWorkGroupUniformLoad(Span), Other, - ExpectedArraySize(Span), - NonPositiveArrayLength(Span), + ExpectedConstExprConcreteIntegerScalar(Span), + ExpectedNonNegative(Span), + ExpectedPositiveArrayLength(Span), MissingWorkgroupSize(Span), + ConstantEvaluatorError(ConstantEvaluatorError, Span), } impl<'a> Error<'a> { @@ -271,8 +267,6 @@ impl<'a> Error<'a> { } } ExpectedToken::Identifier => "identifier".to_string(), - ExpectedToken::Number => "32-bit signed integer literal".to_string(), - ExpectedToken::Integer => "unsigned/signed integer literal".to_string(), ExpectedToken::PrimaryExpression => "expression".to_string(), ExpectedToken::Assignment => "assignment or increment/decrement".to_string(), ExpectedToken::SwitchItem => "switch item ('case' or 'default') or a closing curly bracket to signify the end of the switch statement ('}')".to_string(), @@ -306,22 +300,6 @@ impl<'a> Error<'a> { labels: vec![(bad_span, err.to_string().into())], notes: vec![], }, - Error::NegativeInt(bad_span) => ParseError { - message: format!( - "expected non-negative integer literal, found `{}`", - &source[bad_span], - ), - labels: vec![(bad_span, "expected non-negative integer".into())], - notes: vec![], - }, - Error::BadU32Constant(bad_span) => ParseError { - message: format!( - "expected unsigned integer constant expression, found `{}`", - &source[bad_span], - ), - labels: vec![(bad_span, "expected unsigned integer".into())], - notes: vec![], - }, Error::BadMatrixScalarKind(span, kind, width) => ParseError { message: format!( "matrix scalar type must be floating-point, but found `{}`", @@ -694,15 +672,24 @@ impl<'a> Error<'a> { labels: vec![], notes: vec![], }, - Error::ExpectedArraySize(span) => ParseError { - message: "array element count must resolve to an integer scalar (u32 or i32)" - .to_string(), - labels: vec![(span, "must resolve to u32/i32".into())], + Error::ExpectedConstExprConcreteIntegerScalar(span) => ParseError { + message: "must be a const-expression that resolves to a concrete integer scalar (u32 or i32)".to_string(), + labels: vec![(span, "must resolve to u32 or i32".into())], + notes: vec![], + }, + Error::ExpectedNonNegative(span) => ParseError { + message: "must be non-negative (>= 0)".to_string(), + labels: vec![(span, "must be non-negative".into())], + notes: vec![], + }, + Error::ExpectedPositiveArrayLength(span) => ParseError { + message: "array element count must be positive (> 0)".to_string(), + labels: vec![(span, "must be positive".into())], notes: vec![], }, - Error::NonPositiveArrayLength(span) => ParseError { - message: "array element count must be greater than zero".to_string(), - labels: vec![(span, "must be greater than zero".into())], + Error::ConstantEvaluatorError(ref e, span) => ParseError { + message: e.to_string(), + labels: vec![(span, "see msg".into())], notes: vec![], }, Error::MissingWorkgroupSize(span) => ParseError { diff --git a/src/front/wgsl/lower/construction.rs b/src/front/wgsl/lower/construction.rs index 3b4830b058..970f63dca7 100644 --- a/src/front/wgsl/lower/construction.rs +++ b/src/front/wgsl/lower/construction.rs @@ -197,7 +197,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { // Empty constructor (Components::None, dst_ty) => match dst_ty { ConcreteConstructor::Type(ty, _) => { - return Ok(ctx.interrupt_emitter(crate::Expression::ZeroValue(ty), span)) + return ctx.append_expression(crate::Expression::ZeroValue(ty), span) } _ => return Err(Error::TypeNotInferrable(ty_span)), }, @@ -408,7 +408,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Default::default(), ) }) - .collect(); + .collect::, _>>()?; let ty = ctx.ensure_type_exists(crate::TypeInner::Matrix { columns, @@ -523,7 +523,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { _ => return Err(Error::TypeNotConstructible(ty_span)), }; - let expr = ctx.append_expression(expr, span); + let expr = ctx.append_expression(expr, span)?; Ok(expr) } @@ -585,7 +585,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let size = match size { ast::ArraySize::Constant(expr) => { let const_expr = self.expression(expr, ctx.as_const())?; - crate::ArraySize::Constant(ctx.array_length(const_expr)?) + crate::ArraySize::Constant(ctx.as_const().array_length(const_expr)?) } ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, }; diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 56d8709708..3a78f0f2bd 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -5,7 +5,9 @@ use crate::front::wgsl::index::Index; use crate::front::wgsl::parse::number::Number; use crate::front::wgsl::parse::{ast, conv}; use crate::front::{Emitter, Typifier}; -use crate::proc::{ensure_block_returns, Alignment, Layouter, ResolveContext, TypeResolution}; +use crate::proc::{ + ensure_block_returns, Alignment, ConstantEvaluator, Layouter, ResolveContext, TypeResolution, +}; use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span}; mod construction; @@ -327,17 +329,66 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { &mut self, expr: crate::Expression, span: Span, - ) -> Handle { + ) -> Result, Error<'source>> { match self.expr_type { - ExpressionContextType::Runtime(ref mut ctx) => ctx.naga_expressions.append(expr, span), - ExpressionContextType::Constant => self.module.const_expressions.append(expr, span), + ExpressionContextType::Runtime(ref mut rctx) => { + let mut eval = ConstantEvaluator { + types: &mut self.module.types, + constants: &self.module.constants, + expressions: rctx.naga_expressions, + const_expressions: Some(&self.module.const_expressions), + append: Some( + |arena: &mut Arena, expr: crate::Expression, span| { + let is_running = rctx.emitter.is_running(); + let needs_pre_emit = expr.needs_pre_emit(); + if is_running && needs_pre_emit { + rctx.block.extend(rctx.emitter.finish(arena)); + } + let h = arena.append(expr, span); + if is_running && needs_pre_emit { + rctx.emitter.start(arena); + } + h + }, + ), + }; + + match eval.try_eval_and_append(&expr, span) { + Ok(expr) => Ok(expr), + Err(_) => Ok(rctx.naga_expressions.append(expr, span)), + } + } + ExpressionContextType::Constant => { + let mut eval = ConstantEvaluator { + types: &mut self.module.types, + constants: &self.module.constants, + expressions: &mut self.module.const_expressions, + const_expressions: None, + append: None::< + Box< + dyn FnMut( + &mut Arena, + crate::Expression, + Span, + ) -> Handle, + >, + >, + }; + + eval.try_eval_and_append(&expr, span) + .map_err(|e| Error::ConstantEvaluatorError(e, span)) + } } } - fn get_expression(&self, handle: Handle) -> &crate::Expression { + fn const_access(&self, handle: Handle) -> Option { match self.expr_type { - ExpressionContextType::Runtime(ref ctx) => &ctx.naga_expressions[handle], - ExpressionContextType::Constant => &self.module.const_expressions[handle], + ExpressionContextType::Runtime(ref ctx) => self + .module + .to_ctx() + .eval_expr_to_u32_from(handle, ctx.naga_expressions) + .ok(), + ExpressionContextType::Constant => self.module.to_ctx().eval_expr_to_u32(handle).ok(), } } @@ -366,34 +417,52 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } fn array_length( - &self, + &mut self, const_expr: Handle, ) -> Result> { - let span = self.module.const_expressions.get_span(const_expr); - let len = self - .module - .to_ctx() - .eval_expr_to_u32(const_expr) - .map_err(|err| match err { - crate::proc::U32EvalError::NonConst => Error::ExpectedArraySize(span), - crate::proc::U32EvalError::Negative => Error::NonPositiveArrayLength(span), - })?; - NonZeroU32::new(len).ok_or(Error::NonPositiveArrayLength(span)) + match self.expr_type { + ExpressionContextType::Runtime(_) => { + unreachable!() + } + ExpressionContextType::Constant => { + let span = self.module.const_expressions.get_span(const_expr); + let len = + self.module + .to_ctx() + .eval_expr_to_u32(const_expr) + .map_err(|err| match err { + crate::proc::U32EvalError::NonConst => { + Error::ExpectedConstExprConcreteIntegerScalar(span) + } + crate::proc::U32EvalError::Negative => { + Error::ExpectedPositiveArrayLength(span) + } + })?; + NonZeroU32::new(len).ok_or(Error::ExpectedPositiveArrayLength(span)) + } + } } fn gather_component( - &self, + &mut self, expr: Handle, gather_span: Span, ) -> Result> { match self.expr_type { - ExpressionContextType::Runtime(ref ctx) => { - let expr_span = ctx.naga_expressions.get_span(expr); + ExpressionContextType::Runtime(ref rctx) => { + let expr_span = rctx.naga_expressions.get_span(expr); let index = self .module .to_ctx() - .eval_expr_to_u32_from(expr, ctx.naga_expressions) - .map_err(|_| Error::InvalidGatherComponent(expr_span))?; + .eval_expr_to_u32_from(expr, rctx.naga_expressions) + .map_err(|err| match err { + crate::proc::U32EvalError::NonConst => { + Error::ExpectedConstExprConcreteIntegerScalar(expr_span) + } + crate::proc::U32EvalError::Negative => { + Error::ExpectedNonNegative(expr_span) + } + })?; crate::SwizzleComponent::XYZW .get(index as usize) .copied() @@ -543,13 +612,13 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { value: *right, }, self.get_expression_span(*right), - ); + )?; } (&crate::TypeInner::Scalar { .. }, &crate::TypeInner::Vector { size, .. }) => { *left = self.append_expression( crate::Expression::Splat { size, value: *left }, self.get_expression_span(*left), - ); + )?; } _ => {} } @@ -566,7 +635,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { &mut self, expression: crate::Expression, span: Span, - ) -> Handle { + ) -> Result, Error<'source>> { match self.expr_type { ExpressionContextType::Runtime(ref mut rctx) => { rctx.block @@ -588,7 +657,10 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { /// /// If `expr` is has type `ref`, perform a load to produce a value of type /// `T`. Otherwise, return `expr` unchanged. - fn apply_load_rule(&mut self, expr: TypedExpression) -> Handle { + fn apply_load_rule( + &mut self, + expr: TypedExpression, + ) -> Result, Error<'source>> { if expr.is_reference { let load = crate::Expression::Load { pointer: expr.handle, @@ -596,7 +668,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { let span = self.get_expression_span(expr.handle); self.append_expression(load, span) } else { - expr.handle + Ok(expr.handle) } } @@ -831,11 +903,20 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .map(|init| self.expression(init, ctx.as_const())) .transpose()?; + let binding = if let Some(ref binding) = v.binding { + Some(crate::ResourceBinding { + group: self.const_u32(binding.group, ctx.as_const())?.0, + binding: self.const_u32(binding.binding, ctx.as_const())?.0, + }) + } else { + None + }; + let handle = ctx.module.global_variables.append( crate::GlobalVariable { name: Some(v.name.name.to_string()), space: v.space, - binding: v.binding.clone(), + binding, ty, init, }, @@ -930,7 +1011,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(crate::FunctionArgument { name: Some(arg.name.name.to_string()), ty, - binding: self.interpolate_default(&arg.binding, ty, ctx.reborrow()), + binding: self.binding(&arg.binding, ty, ctx.reborrow())?, }) }) .collect::, _>>()?; @@ -939,11 +1020,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .result .as_ref() .map(|res| { - self.resolve_ast_type(res.ty, ctx.reborrow()) - .map(|ty| crate::FunctionResult { - ty, - binding: self.interpolate_default(&res.binding, ty, ctx.reborrow()), - }) + let ty = self.resolve_ast_type(res.ty, ctx.reborrow())?; + Ok(crate::FunctionResult { + ty, + binding: self.binding(&res.binding, ty, ctx.reborrow())?, + }) }) .transpose()?; @@ -980,11 +1061,24 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }; if let Some(ref entry) = f.entry_point { + let workgroup_size = if let Some(workgroup_size) = entry.workgroup_size { + // TODO: replace with try_map once stabilized + let mut workgroup_size_out = [1; 3]; + for (i, size) in workgroup_size.into_iter().enumerate() { + if let Some(size_expr) = size { + workgroup_size_out[i] = self.const_u32(size_expr, ctx.as_const())?.0; + } + } + workgroup_size_out + } else { + [0; 3] + }; + ctx.module.entry_points.push(crate::EntryPoint { name: f.name.name.to_string(), stage: entry.stage, early_depth_test: entry.early_depth_test, - workgroup_size: entry.workgroup_size.unwrap_or([0, 0, 0]), + workgroup_size, function, }); Ok(LoweredGlobalDecl::EntryPoint) @@ -1106,9 +1200,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { stmt.span, ); - let handle = ctx - .as_expression(block, &mut emitter) - .interrupt_emitter(crate::Expression::LocalVariable(var), Span::UNDEFINED); + let handle = ctx.as_expression(block, &mut emitter).interrupt_emitter( + crate::Expression::LocalVariable(var), + Span::UNDEFINED, + )?; block.extend(emitter.finish(ctx.naga_expressions)); ctx.local_table.insert( v.handle, @@ -1168,19 +1263,24 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .map(|case| { Ok(crate::SwitchCase { value: match case.value { - ast::SwitchValue::I32(value) if !uint => { - crate::SwitchValue::I32(value) - } - ast::SwitchValue::U32(value) if uint => { - crate::SwitchValue::U32(value) + ast::SwitchValue::Expr(expr) => { + let expr = self.expression(expr, ctx.as_global().as_const())?; + match ctx.module.to_ctx().eval_expr_to_literal(expr) { + Some(crate::Literal::I32(value)) if !uint => { + crate::SwitchValue::I32(value) + } + Some(crate::Literal::U32(value)) if uint => { + crate::SwitchValue::U32(value) + } + _ => { + return Err(Error::InvalidSwitchValue { + uint, + span: ctx.module.const_expressions.get_span(expr), + }); + } + } } ast::SwitchValue::Default => crate::SwitchValue::Default, - _ => { - return Err(Error::InvalidSwitchValue { - uint, - span: case.value_span, - }); - } }, body: self.block(&case.body, ctx.reborrow())?, fall_through: case.fall_through, @@ -1261,7 +1361,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let value = match op { Some(op) => { let mut ctx = ctx.as_expression(block, &mut emitter); - let mut left = ctx.apply_load_rule(expr); + let mut left = ctx.apply_load_rule(expr)?; ctx.binary_op_splat(op, &mut left, &mut value)?; ctx.append_expression( crate::Expression::Binary { @@ -1270,7 +1370,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { right: value, }, stmt.span, - ) + )? } None => value, }; @@ -1319,7 +1419,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }; let right = - ectx.interrupt_emitter(crate::Expression::Literal(literal), Span::UNDEFINED); + ectx.interrupt_emitter(crate::Expression::Literal(literal), Span::UNDEFINED)?; let rctx = ectx.runtime_expression_ctx(stmt.span)?; let left = rctx.naga_expressions.append( crate::Expression::Load { @@ -1358,7 +1458,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { mut ctx: ExpressionContext<'source, '_, '_>, ) -> Result, Error<'source>> { let expr = self.expression_for_reference(expr, ctx.reborrow())?; - Ok(ctx.apply_load_rule(expr)) + ctx.apply_load_rule(expr) } fn expression_for_reference( @@ -1380,7 +1480,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } ast::Literal::Bool(b) => crate::Literal::Bool(b), }; - let handle = ctx.interrupt_emitter(crate::Expression::Literal(literal), span); + let handle = ctx.interrupt_emitter(crate::Expression::Literal(literal), span)?; return Ok(TypedExpression::non_reference(handle)); } ast::Expression::Ident(ast::IdentExpr::Local(local)) => { @@ -1403,7 +1503,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; - let handle = ctx.interrupt_emitter(expr, span); + let handle = ctx.interrupt_emitter(expr, span)?; Ok(TypedExpression { handle, is_reference, @@ -1483,16 +1583,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { )); } - if let crate::Expression::Literal(lit) = *ctx.get_expression(index) { - let span = ctx.get_expression_span(index); - let index = match lit { - crate::Literal::U32(index) => Ok(index), - crate::Literal::I32(index) => { - u32::try_from(index).map_err(|_| Error::BadU32Constant(span)) - } - _ => Err(Error::BadU32Constant(span)), - }?; - + if let Some(index) = ctx.const_access(index) { ( crate::Expression::AccessIndex { base: expr.handle, @@ -1572,7 +1663,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let vector = ctx.apply_load_rule(TypedExpression { handle, is_reference, - }); + })?; ( crate::Expression::Swizzle { @@ -1625,7 +1716,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; - let handle = ctx.append_expression(expr, span); + let handle = ctx.append_expression(expr, span)?; Ok(TypedExpression { handle, is_reference, @@ -1921,7 +2012,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { _ => return Err(Error::InvalidAtomicOperandType(value_span)), }; - let result = ctx.interrupt_emitter(expression, span); + let result = ctx.interrupt_emitter(expression, span)?; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block.push( crate::Statement::Atomic { @@ -1973,7 +2064,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let result = ctx.interrupt_emitter( crate::Expression::WorkGroupUniformLoadResult { ty: result_ty }, span, - ); + )?; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block.push( crate::Statement::WorkGroupUniformLoad { pointer, result }, @@ -2126,8 +2217,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let query = self.ray_query_pointer(args.next()?, ctx.reborrow())?; args.finish()?; - let result = ctx - .interrupt_emitter(crate::Expression::RayQueryProceedResult, span); + let result = ctx.interrupt_emitter( + crate::Expression::RayQueryProceedResult, + span, + )?; let fun = crate::RayQueryFunction::Proceed { result }; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block @@ -2161,7 +2254,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; - let expr = ctx.append_expression(expr, span); + let expr = ctx.append_expression(expr, span)?; Ok(Some(expr)) } } @@ -2214,7 +2307,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { comparison: false, }, span, - ); + )?; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block.push( crate::Statement::Atomic { @@ -2367,7 +2460,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let member_min_size = self.layouter[ty].size; let member_min_alignment = self.layouter[ty].alignment; - let member_size = if let Some((size, span)) = member.size { + let member_size = if let Some(size_expr) = member.size { + let (size, span) = self.const_u32(size_expr, ctx.as_const())?; if size < member_min_size { return Err(Error::SizeAttributeTooLow(span, member_min_size)); } else { @@ -2377,7 +2471,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { member_min_size }; - let member_alignment = if let Some((align, span)) = member.align { + let member_alignment = if let Some(align_expr) = member.align { + let (align, span) = self.const_u32(align_expr, ctx.as_const())?; if let Some(alignment) = Alignment::new(align) { if alignment < member_min_alignment { return Err(Error::AlignAttributeTooLow(span, member_min_alignment)); @@ -2391,7 +2486,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { member_min_alignment }; - let binding = self.interpolate_default(&member.binding, ty, ctx.reborrow()); + let binding = self.binding(&member.binding, ty, ctx.reborrow())?; offset = member_alignment.round_up(offset); struct_alignment = struct_alignment.max(member_alignment); @@ -2422,6 +2517,26 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(handle) } + fn const_u32( + &mut self, + expr: Handle>, + mut ctx: ExpressionContext<'source, '_, '_>, + ) -> Result<(u32, Span), Error<'source>> { + let expr = self.expression(expr, ctx.reborrow())?; + let span = ctx.module.const_expressions.get_span(expr); + let value = ctx + .module + .to_ctx() + .eval_expr_to_u32(expr) + .map_err(|err| match err { + crate::proc::U32EvalError::NonConst => { + Error::ExpectedConstExprConcreteIntegerScalar(span) + } + crate::proc::U32EvalError::Negative => Error::ExpectedNonNegative(span), + })?; + Ok((value, span)) + } + /// Return a Naga `Handle` representing the front-end type `handle`. fn resolve_ast_type( &mut self, @@ -2507,18 +2622,31 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(ctx.ensure_type_exists(inner)) } - fn interpolate_default( + fn binding( &mut self, - binding: &Option, + binding: &Option>, ty: Handle, - ctx: GlobalContext<'source, '_, '_>, - ) -> Option { - let mut binding = binding.clone(); - if let Some(ref mut binding) = binding { - binding.apply_default_interpolation(&ctx.module.types[ty].inner); - } - - binding + mut ctx: GlobalContext<'source, '_, '_>, + ) -> Result, Error<'source>> { + Ok(match *binding { + Some(ast::Binding::BuiltIn(b)) => Some(crate::Binding::BuiltIn(b)), + Some(ast::Binding::Location { + location, + second_blend_source, + interpolation, + sampling, + }) => { + let mut binding = crate::Binding::Location { + location: self.const_u32(location, ctx.as_const())?.0, + second_blend_source, + interpolation, + sampling, + }; + binding.apply_default_interpolation(&ctx.module.types[ty].inner); + Some(binding) + } + None => None, + }) } fn ray_query_pointer( diff --git a/src/front/wgsl/parse/ast.rs b/src/front/wgsl/parse/ast.rs index fca7457f05..f88e880a3f 100644 --- a/src/front/wgsl/parse/ast.rs +++ b/src/front/wgsl/parse/ast.rs @@ -89,21 +89,21 @@ pub enum GlobalDeclKind<'a> { pub struct FunctionArgument<'a> { pub name: Ident<'a>, pub ty: Handle>, - pub binding: Option, + pub binding: Option>, pub handle: Handle, } #[derive(Debug)] pub struct FunctionResult<'a> { pub ty: Handle>, - pub binding: Option, + pub binding: Option>, } #[derive(Debug)] -pub struct EntryPoint { +pub struct EntryPoint<'a> { pub stage: crate::ShaderStage, pub early_depth_test: Option, - pub workgroup_size: Option<[u32; 3]>, + pub workgroup_size: Option<[Option>>; 3]>, } #[cfg(doc)] @@ -111,7 +111,7 @@ use crate::front::wgsl::lower::{RuntimeExpressionContext, StatementContext}; #[derive(Debug)] pub struct Function<'a> { - pub entry_point: Option, + pub entry_point: Option>, pub name: Ident<'a>, pub arguments: Vec>, pub result: Option>, @@ -145,11 +145,28 @@ pub struct Function<'a> { pub body: Block<'a>, } +#[derive(Debug)] +pub enum Binding<'a> { + BuiltIn(crate::BuiltIn), + Location { + location: Handle>, + second_blend_source: bool, + interpolation: Option, + sampling: Option, + }, +} + +#[derive(Debug)] +pub struct ResourceBinding<'a> { + pub group: Handle>, + pub binding: Handle>, +} + #[derive(Debug)] pub struct GlobalVariable<'a> { pub name: Ident<'a>, pub space: crate::AddressSpace, - pub binding: Option, + pub binding: Option>, pub ty: Handle>, pub init: Option>>, } @@ -158,9 +175,9 @@ pub struct GlobalVariable<'a> { pub struct StructMember<'a> { pub name: Ident<'a>, pub ty: Handle>, - pub binding: Option, - pub align: Option<(u32, Span)>, - pub size: Option<(u32, Span)>, + pub binding: Option>, + pub align: Option>>, + pub size: Option>>, } #[derive(Debug)] @@ -292,16 +309,14 @@ pub enum StatementKind<'a> { } #[derive(Debug)] -pub enum SwitchValue { - I32(i32), - U32(u32), +pub enum SwitchValue<'a> { + Expr(Handle>), Default, } #[derive(Debug)] pub struct SwitchCase<'a> { - pub value: SwitchValue, - pub value_span: Span, + pub value: SwitchValue<'a>, pub body: Block<'a>, pub fall_through: bool, } diff --git a/src/front/wgsl/parse/mod.rs b/src/front/wgsl/parse/mod.rs index 325a8e690a..74738ab231 100644 --- a/src/front/wgsl/parse/mod.rs +++ b/src/front/wgsl/parse/mod.rs @@ -141,8 +141,8 @@ impl ParsedAttribute { } #[derive(Default)] -struct BindingParser { - location: ParsedAttribute, +struct BindingParser<'a> { + location: ParsedAttribute>>, second_blend_source: ParsedAttribute, built_in: ParsedAttribute, interpolation: ParsedAttribute, @@ -150,18 +150,20 @@ struct BindingParser { invariant: ParsedAttribute, } -impl BindingParser { - fn parse<'a>( +impl<'a> BindingParser<'a> { + fn parse( &mut self, + parser: &mut Parser, lexer: &mut Lexer<'a>, name: &'a str, name_span: Span, + mut ctx: ExpressionContext<'a, '_, '_>, ) -> Result<(), Error<'a>> { match name { "location" => { lexer.expect(Token::Paren('('))?; self.location - .set(Parser::non_negative_i32_literal(lexer)?, name_span)?; + .set(parser.general_expression(lexer, ctx.reborrow())?, name_span)?; lexer.expect(Token::Paren(')'))?; } "builtin" => { @@ -194,7 +196,7 @@ impl BindingParser { Ok(()) } - fn finish<'a>(self, span: Span) -> Result, Error<'a>> { + fn finish(self, span: Span) -> Result>, Error<'a>> { match ( self.location.value, self.built_in.value, @@ -208,7 +210,7 @@ impl BindingParser { // `apply_default_interpolation` to ensure that the interpolation and // sampling have been explicitly specified on all vertex shader output and fragment // shader input user bindings, so leaving them potentially `None` here is fine. - Ok(Some(crate::Binding::Location { + Ok(Some(ast::Binding::Location { location, interpolation, sampling, @@ -216,13 +218,11 @@ impl BindingParser { })) } (None, Some(crate::BuiltIn::Position { .. }), None, None, invariant) => { - Ok(Some(crate::Binding::BuiltIn(crate::BuiltIn::Position { + Ok(Some(ast::Binding::BuiltIn(crate::BuiltIn::Position { invariant, }))) } - (None, Some(built_in), None, None, false) => { - Ok(Some(crate::Binding::BuiltIn(built_in))) - } + (None, Some(built_in), None, None, false) => Ok(Some(ast::Binding::BuiltIn(built_in))), (_, _, _, _, _) => Err(Error::InconsistentBinding(span)), } } @@ -255,41 +255,18 @@ impl Parser { lexer.span_from(initial) } - fn switch_value<'a>(lexer: &mut Lexer<'a>) -> Result<(ast::SwitchValue, Span), Error<'a>> { - let token_span = lexer.next(); - match token_span.0 { - Token::Word("default") => Ok((ast::SwitchValue::Default, token_span.1)), - Token::Number(Ok(Number::U32(num))) => Ok((ast::SwitchValue::U32(num), token_span.1)), - Token::Number(Ok(Number::I32(num))) => Ok((ast::SwitchValue::I32(num), token_span.1)), - Token::Number(Err(e)) => Err(Error::BadNumber(token_span.1, e)), - _ => Err(Error::Unexpected(token_span.1, ExpectedToken::Integer)), - } - } - - /// Parse a non-negative signed integer literal. - /// This is for attributes like `size`, `location` and others. - fn non_negative_i32_literal<'a>(lexer: &mut Lexer<'a>) -> Result> { - match lexer.next() { - (Token::Number(Ok(Number::I32(num))), span) => { - u32::try_from(num).map_err(|_| Error::NegativeInt(span)) - } - (Token::Number(Err(e)), span) => Err(Error::BadNumber(span, e)), - other => Err(Error::Unexpected(other.1, ExpectedToken::Number)), + fn switch_value<'a>( + &mut self, + lexer: &mut Lexer<'a>, + mut ctx: ExpressionContext<'a, '_, '_>, + ) -> Result, Error<'a>> { + if let Token::Word("default") = lexer.peek().0 { + let _ = lexer.next(); + return Ok(ast::SwitchValue::Default); } - } - /// Parse a non-negative integer literal that may be either signed or unsigned. - /// This is for the `workgroup_size` attribute and array lengths. - /// Note: these values should be no larger than [`i32::MAX`], but this is not checked here. - fn generic_non_negative_int_literal<'a>(lexer: &mut Lexer<'a>) -> Result> { - match lexer.next() { - (Token::Number(Ok(Number::I32(num))), span) => { - u32::try_from(num).map_err(|_| Error::NegativeInt(span)) - } - (Token::Number(Ok(Number::U32(num))), _) => Ok(num), - (Token::Number(Err(e)), span) => Err(Error::BadNumber(span, e)), - other => Err(Error::Unexpected(other.1, ExpectedToken::Number)), - } + let expr = self.general_expression(lexer, ctx.reborrow())?; + Ok(ast::SwitchValue::Expr(expr)) } /// Decide if we're looking at a construction expression, and return its @@ -1028,17 +1005,19 @@ impl Parser { match lexer.next_ident_with_span()? { ("size", name_span) => { lexer.expect(Token::Paren('('))?; - let (value, span) = lexer.capture_span(Self::non_negative_i32_literal)?; + let expr = self.general_expression(lexer, ctx.reborrow())?; lexer.expect(Token::Paren(')'))?; - size.set((value, span), name_span)?; + size.set(expr, name_span)?; } ("align", name_span) => { lexer.expect(Token::Paren('('))?; - let (value, span) = lexer.capture_span(Self::non_negative_i32_literal)?; + let expr = self.general_expression(lexer, ctx.reborrow())?; lexer.expect(Token::Paren(')'))?; - align.set((value, span), name_span)?; + align.set(expr, name_span)?; + } + (word, word_span) => { + bind_parser.parse(self, lexer, word, word_span, ctx.reborrow())? } - (word, word_span) => bind_parser.parse(lexer, word, word_span)?, } } @@ -1765,19 +1744,18 @@ impl Parser { match lexer.next() { (Token::Word("case"), _) => { // parse a list of values - let (value, value_span) = loop { - let (value, value_span) = Self::switch_value(lexer)?; + let value = loop { + let value = self.switch_value(lexer, ctx.reborrow())?; if lexer.skip(Token::Separator(',')) { if lexer.skip(Token::Separator(':')) { - break (value, value_span); + break value; } } else { lexer.skip(Token::Separator(':')); - break (value, value_span); + break value; } cases.push(ast::SwitchCase { value, - value_span, body: ast::Block::default(), fall_through: true, }); @@ -1787,17 +1765,15 @@ impl Parser { cases.push(ast::SwitchCase { value, - value_span, body, fall_through: false, }); } - (Token::Word("default"), value_span) => { + (Token::Word("default"), _) => { lexer.skip(Token::Separator(':')); let body = self.block(lexer, ctx.reborrow())?.0; cases.push(ast::SwitchCase { value: ast::SwitchValue::Default, - value_span, body, fall_through: false, }); @@ -2059,13 +2035,14 @@ impl Parser { fn varying_binding<'a>( &mut self, lexer: &mut Lexer<'a>, - ) -> Result, Error<'a>> { + mut ctx: ExpressionContext<'a, '_, '_>, + ) -> Result>, Error<'a>> { let mut bind_parser = BindingParser::default(); self.push_rule_span(Rule::Attribute, lexer); while lexer.skip(Token::Attribute) { let (word, span) = lexer.next_ident_with_span()?; - bind_parser.parse(lexer, word, span)?; + bind_parser.parse(self, lexer, word, span, ctx.reborrow())?; } let span = self.pop_rule_span(lexer); @@ -2106,7 +2083,7 @@ impl Parser { ExpectedToken::Token(Token::Separator(',')), )); } - let binding = self.varying_binding(lexer)?; + let binding = self.varying_binding(lexer, ctx.reborrow())?; let param_name = lexer.next_ident()?; @@ -2124,7 +2101,7 @@ impl Parser { } // read return type let result = if lexer.skip(Token::Arrow) && !lexer.skip(Token::Word("void")) { - let binding = self.varying_binding(lexer)?; + let binding = self.varying_binding(lexer, ctx.reborrow())?; let ty = self.type_decl(lexer, ctx.reborrow())?; Some(ast::FunctionResult { ty, binding }) } else { @@ -2169,17 +2146,26 @@ impl Parser { let (mut bind_index, mut bind_group) = (ParsedAttribute::default(), ParsedAttribute::default()); + let mut dependencies = FastIndexSet::default(); + let mut ctx = ExpressionContext { + expressions: &mut out.expressions, + local_table: &mut SymbolTable::default(), + locals: &mut Arena::new(), + types: &mut out.types, + unresolved: &mut dependencies, + }; + self.push_rule_span(Rule::Attribute, lexer); while lexer.skip(Token::Attribute) { match lexer.next_ident_with_span()? { ("binding", name_span) => { lexer.expect(Token::Paren('('))?; - bind_index.set(Self::non_negative_i32_literal(lexer)?, name_span)?; + bind_index.set(self.general_expression(lexer, ctx.reborrow())?, name_span)?; lexer.expect(Token::Paren(')'))?; } ("group", name_span) => { lexer.expect(Token::Paren('('))?; - bind_group.set(Self::non_negative_i32_literal(lexer)?, name_span)?; + bind_group.set(self.general_expression(lexer, ctx.reborrow())?, name_span)?; lexer.expect(Token::Paren(')'))?; } ("vertex", name_span) => { @@ -2194,9 +2180,9 @@ impl Parser { } ("workgroup_size", name_span) => { lexer.expect(Token::Paren('('))?; - let mut new_workgroup_size = [1u32; 3]; + let mut new_workgroup_size = [None; 3]; for (i, size) in new_workgroup_size.iter_mut().enumerate() { - *size = Self::generic_non_negative_int_literal(lexer)?; + *size = Some(self.general_expression(lexer, ctx.reborrow())?); match lexer.next() { (Token::Paren(')'), _) => break, (Token::Separator(','), _) if i != 2 => (), @@ -2228,7 +2214,7 @@ impl Parser { let attrib_span = self.pop_rule_span(lexer); match (bind_group.value, bind_index.value) { (Some(group), Some(index)) => { - binding = Some(crate::ResourceBinding { + binding = Some(ast::ResourceBinding { group, binding: index, }); @@ -2238,15 +2224,6 @@ impl Parser { (None, None) => {} } - let mut dependencies = FastIndexSet::default(); - let mut ctx = ExpressionContext { - expressions: &mut out.expressions, - local_table: &mut SymbolTable::default(), - locals: &mut Arena::new(), - types: &mut out.types, - unresolved: &mut dependencies, - }; - // read item let start = lexer.start_byte_offset(); let kind = match lexer.next() { diff --git a/src/front/wgsl/tests.rs b/src/front/wgsl/tests.rs index 828f1e3c71..9e3ba2fab6 100644 --- a/src/front/wgsl/tests.rs +++ b/src/front/wgsl/tests.rs @@ -402,9 +402,8 @@ fn binary_expression_mixed_scalar_and_vector_operands() { ] { let module = parse_str(&format!( " - const some_vec = vec3(1.0, 1.0, 1.0); @fragment - fn main() -> @location(0) vec4 {{ + fn main(@location(0) some_vec: vec3) -> @location(0) vec4 {{ if (all(1.0 {operand} some_vec)) {{ return vec4(0.0); }} @@ -431,7 +430,12 @@ fn binary_expression_mixed_scalar_and_vector_operands() { }) .count(); - assert_eq!(found_expressions, 1); + assert_eq!( + found_expressions, + 1, + "expected `{operand}` expression {} splat", + if expect_splat { "with" } else { "without" } + ); } let module = parse_str( diff --git a/src/front/glsl/constants.rs b/src/proc/constant_evaluator.rs similarity index 52% rename from src/front/glsl/constants.rs rename to src/proc/constant_evaluator.rs index 81ec6f3a8c..cf00b13de5 100644 --- a/src/front/glsl/constants.rs +++ b/src/proc/constant_evaluator.rs @@ -1,19 +1,23 @@ use crate::{ arena::{Arena, Handle, UniqueArena}, - ArraySize, BinaryOperator, Constant, Expression, Literal, ScalarKind, Type, TypeInner, + ArraySize, BinaryOperator, Constant, Expression, Literal, ScalarKind, Span, Type, TypeInner, UnaryOperator, }; #[derive(Debug)] -pub struct ConstantSolver<'a> { +pub struct ConstantEvaluator< + 'a, + F: FnMut(&mut Arena, Expression, Span) -> Handle, +> { pub types: &'a mut UniqueArena, - pub expressions: &'a Arena, - pub constants: &'a mut Arena, - pub const_expressions: &'a mut Arena, + pub constants: &'a Arena, + pub expressions: &'a mut Arena, + pub const_expressions: Option<&'a Arena>, + pub append: Option, } #[derive(Clone, Debug, PartialEq, thiserror::Error)] -pub enum ConstantSolvingError { +pub enum ConstantEvaluatorError { #[error("Constants cannot access function arguments")] FunctionArg, #[error("Constants cannot access global variables")] @@ -26,6 +30,8 @@ pub enum ConstantSolvingError { ArrayLengthDynamic, #[error("Constants cannot call functions")] Call, + #[error("Constants don't support workGroupUniformLoad")] + WorkGroupUniformLoadResult, #[error("Constants don't support atomic functions")] Atomic, #[error("Constants don't support relational functions")] @@ -62,6 +68,8 @@ pub enum ConstantSolvingError { SwizzleVectorOnly, #[error("Type is not constructible")] TypeNotConstructible, + #[error("Subexpression(s) are not constant")] + SubexpressionsAreNotConstant, #[error("Not implemented as constant expression: {0}")] NotImplemented(String), } @@ -72,38 +80,174 @@ pub enum ExprType { Constant, } -impl<'a> ConstantSolver<'a> { - pub fn solve( +// Access +// AccessIndex +// Splat +// Swizzle +// Unary +// Binary +// Select +// Relational +// Math +// As + +impl<'a, F: FnMut(&mut Arena, Expression, Span) -> Handle> + ConstantEvaluator<'a, F> +{ + fn check_and_get( &mut self, expr: Handle, - ) -> Result, ConstantSolvingError> { - self.solve_impl(expr, ExprType::Regular, true) + ) -> Result, ConstantEvaluatorError> { + match self.expressions[expr] { + Expression::Literal(_) + | Expression::ZeroValue(_) + | Expression::Compose { .. } + | Expression::Splat { .. } => Ok(expr), + Expression::Constant(c) => { + if let Some(const_expressions) = self.const_expressions { + self.copy_from(self.constants[c].init, const_expressions) + } else { + Ok(self.constants[c].init) + } + } + _ => Err(ConstantEvaluatorError::SubexpressionsAreNotConstant), + } } - pub fn solve_impl( + pub fn try_eval_and_append( + &mut self, + expr: &Expression, + span: Span, + ) -> Result, ConstantEvaluatorError> { + match *expr { + Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { + Ok(self.register_evaluated_expr(expr.clone(), span)) + } + Expression::Compose { ref components, .. } => { + for component in components { + self.check_and_get(*component)?; + } + Ok(self.register_evaluated_expr(expr.clone(), span)) + } + Expression::Splat { value, .. } => { + self.check_and_get(value)?; + Ok(self.register_evaluated_expr(expr.clone(), span)) + } + Expression::AccessIndex { base, index } => { + let base = self.check_and_get(base)?; + + self.access(base, index as usize, span) + } + Expression::Access { base, index } => { + let base = self.check_and_get(base)?; + let index = self.check_and_get(index)?; + + self.access(base, self.constant_index(index)?, span) + } + Expression::Swizzle { + size, + vector, + pattern, + } => { + let vector = self.check_and_get(vector)?; + + self.swizzle(size, span, vector, pattern) + } + Expression::Unary { expr, op } => { + let expr = self.check_and_get(expr)?; + + self.unary_op(op, expr, span) + } + Expression::Binary { left, right, op } => { + let left = self.check_and_get(left)?; + let right = self.check_and_get(right)?; + + self.binary_op(op, left, right, span) + } + Expression::Math { + fun, + arg, + arg1, + arg2, + arg3, + } => { + let arg = self.check_and_get(arg)?; + let arg1 = arg1.map(|arg| self.check_and_get(arg)).transpose()?; + let arg2 = arg2.map(|arg| self.check_and_get(arg)).transpose()?; + let arg3 = arg3.map(|arg| self.check_and_get(arg)).transpose()?; + + self.math(arg, arg1, arg2, arg3, fun, span) + } + Expression::As { + convert, + expr, + kind, + } => { + let expr = self.check_and_get(expr)?; + + match convert { + Some(width) => self.cast(expr, kind, width, span), + None => Err(ConstantEvaluatorError::Bitcast), + } + } + Expression::ArrayLength(expr) => { + let expr = self.check_and_get(expr)?; + + self.array_length(expr, span) + } + + Expression::Load { .. } => Err(ConstantEvaluatorError::Load), + Expression::Select { .. } => Err(ConstantEvaluatorError::Select), + Expression::LocalVariable(_) => Err(ConstantEvaluatorError::LocalVariable), + Expression::Derivative { .. } => Err(ConstantEvaluatorError::Derivative), + Expression::Relational { .. } => Err(ConstantEvaluatorError::Relational), + Expression::CallResult { .. } => Err(ConstantEvaluatorError::Call), + Expression::WorkGroupUniformLoadResult { .. } => { + Err(ConstantEvaluatorError::WorkGroupUniformLoadResult) + } + Expression::AtomicResult { .. } => Err(ConstantEvaluatorError::Atomic), + Expression::FunctionArgument(_) => Err(ConstantEvaluatorError::FunctionArg), + Expression::GlobalVariable(_) => Err(ConstantEvaluatorError::GlobalVariable), + Expression::ImageSample { .. } + | Expression::ImageLoad { .. } + | Expression::ImageQuery { .. } => Err(ConstantEvaluatorError::ImageExpression), + Expression::RayQueryProceedResult | Expression::RayQueryGetIntersection { .. } => { + Err(ConstantEvaluatorError::RayQueryExpression) + } + } + } + + pub fn eval( + &mut self, + expr: Handle, + ) -> Result, ConstantEvaluatorError> { + self.eval_impl(expr, ExprType::Regular, true) + } + + pub fn eval_impl( &mut self, expr: Handle, expr_type: ExprType, top_level: bool, - ) -> Result, ConstantSolvingError> { + ) -> Result, ConstantEvaluatorError> { let expressions = match expr_type { - ExprType::Regular => self.expressions, - ExprType::Constant => self.const_expressions, + ExprType::Regular => self.const_expressions.unwrap(), + ExprType::Constant => self.expressions, }; let span = expressions.get_span(expr); match expressions[expr] { ref expression @ (Expression::Literal(_) | Expression::ZeroValue(_)) => match expr_type { - ExprType::Regular => Ok(self.register_constant(expression.clone(), span)), + ExprType::Regular => Ok(self.register_evaluated_expr(expression.clone(), span)), ExprType::Constant => Ok(expr), }, Expression::Compose { ty, ref components } => match expr_type { ExprType::Regular => { let mut components = components.clone(); for component in &mut components { - *component = self.solve_impl(*component, expr_type, false)?; + *component = self.eval_impl(*component, expr_type, false)?; } - Ok(self.register_constant(Expression::Compose { ty, components }, span)) + Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) } ExprType::Constant => Ok(expr), }, @@ -111,118 +255,47 @@ impl<'a> ConstantSolver<'a> { if top_level { match expr_type { ExprType::Regular => { - Ok(self.register_constant(Expression::Constant(constant), span)) + Ok(self.register_evaluated_expr(Expression::Constant(constant), span)) } ExprType::Constant => Ok(expr), } } else { - self.solve_impl(self.constants[constant].init, ExprType::Constant, false) + self.eval_impl(self.constants[constant].init, ExprType::Constant, false) } } Expression::AccessIndex { base, index } => { - let base = self.solve_impl(base, expr_type, false)?; + let base = self.eval_impl(base, expr_type, false)?; + self.access(base, index as usize, span) } Expression::Access { base, index } => { - let base = self.solve_impl(base, expr_type, false)?; - let index = self.solve_impl(index, expr_type, false)?; + let base = self.eval_impl(base, expr_type, false)?; + let index = self.eval_impl(index, expr_type, false)?; self.access(base, self.constant_index(index)?, span) } - Expression::Splat { - size, - value: splat_value, - } => { - let value_constant = self.solve_impl(splat_value, expr_type, false)?; - let ty = match self.const_expressions[value_constant] { - Expression::Literal(literal) => { - let kind = literal.scalar_kind(); - let width = literal.width(); - self.types.insert( - Type { - name: None, - inner: TypeInner::Vector { size, kind, width }, - }, - span, - ) - } - Expression::ZeroValue(ty) => { - let inner = match self.types[ty].inner { - TypeInner::Scalar { kind, width } => { - TypeInner::Vector { size, kind, width } - } - _ => return Err(ConstantSolvingError::SplatScalarOnly), - }; - let res_ty = self.types.insert(Type { name: None, inner }, span); - let expr = Expression::ZeroValue(res_ty); - return Ok(self.register_constant(expr, span)); - } - _ => { - return Err(ConstantSolvingError::SplatScalarOnly); - } - }; + Expression::Splat { size, value } => { + let value = self.eval_impl(value, expr_type, false)?; - let expr = Expression::Compose { - ty, - components: vec![value_constant; size as usize], - }; - Ok(self.register_constant(expr, span)) + self.splat(value, size, span) } Expression::Swizzle { size, vector: src_vector, pattern, } => { - let src_constant = self.solve_impl(src_vector, expr_type, false)?; - - let mut get_dst_ty = |ty| match self.types[ty].inner { - crate::TypeInner::Vector { - size: _, - kind, - width, - } => Ok(self.types.insert( - Type { - name: None, - inner: crate::TypeInner::Vector { size, kind, width }, - }, - span, - )), - _ => Err(ConstantSolvingError::SwizzleVectorOnly), - }; + let src_constant = self.eval_impl(src_vector, expr_type, false)?; - match self.const_expressions[src_constant] { - Expression::ZeroValue(ty) => { - let dst_ty = get_dst_ty(ty)?; - let expr = Expression::ZeroValue(dst_ty); - Ok(self.register_constant(expr, span)) - } - Expression::Compose { - ty, - components: ref src_components, - } => { - let dst_ty = get_dst_ty(ty)?; - - let components = pattern - .iter() - .map(|&sc| src_components[sc as usize]) - .collect(); - let expr = Expression::Compose { - ty: dst_ty, - components, - }; - Ok(self.register_constant(expr, span)) - } - _ => Err(ConstantSolvingError::SwizzleVectorOnly), - } + self.swizzle(size, span, src_constant, pattern) } Expression::Unary { expr, op } => { - let expr_constant = self.solve_impl(expr, expr_type, false)?; + let expr_constant = self.eval_impl(expr, expr_type, false)?; self.unary_op(op, expr_constant, span) } Expression::Binary { left, right, op } => { - let left_constant = self.solve_impl(left, expr_type, false)?; - let right_constant = self.solve_impl(right, expr_type, false)?; + let left_constant = self.eval_impl(left, expr_type, false)?; + let right_constant = self.eval_impl(right, expr_type, false)?; self.binary_op(op, left_constant, right_constant, span) } @@ -233,122 +306,229 @@ impl<'a> ConstantSolver<'a> { arg2, arg3, } => { - let arg = self.solve_impl(arg, expr_type, false)?; + let arg = self.eval_impl(arg, expr_type, false)?; let arg1 = arg1 - .map(|arg| self.solve_impl(arg, expr_type, false)) + .map(|arg| self.eval_impl(arg, expr_type, false)) .transpose()?; let arg2 = arg2 - .map(|arg| self.solve_impl(arg, expr_type, false)) + .map(|arg| self.eval_impl(arg, expr_type, false)) .transpose()?; let arg3 = arg3 - .map(|arg| self.solve_impl(arg, expr_type, false)) + .map(|arg| self.eval_impl(arg, expr_type, false)) .transpose()?; - let const0 = &self.const_expressions[arg]; - let const1 = arg1.map(|arg| &self.const_expressions[arg]); - let const2 = arg2.map(|arg| &self.const_expressions[arg]); - let _const3 = arg3.map(|arg| &self.const_expressions[arg]); - - match fun { - crate::MathFunction::Pow => { - let literal = match (const0, const1.unwrap()) { - (&Expression::Literal(value0), &Expression::Literal(value1)) => { - match (value0, value1) { - (Literal::I32(a), Literal::I32(b)) => { - Literal::I32(a.pow(b as u32)) - } - (Literal::U32(a), Literal::U32(b)) => Literal::U32(a.pow(b)), - (Literal::F32(a), Literal::F32(b)) => Literal::F32(a.powf(b)), - _ => return Err(ConstantSolvingError::InvalidMathArg), - } - } - _ => return Err(ConstantSolvingError::InvalidMathArg), - }; - - let expr = Expression::Literal(literal); - Ok(self.register_constant(expr, span)) - } - crate::MathFunction::Clamp => { - let literal = match (const0, const1.unwrap(), const2.unwrap()) { - ( - &Expression::Literal(value0), - &Expression::Literal(value1), - &Expression::Literal(value2), - ) => match (value0, value1, value2) { - (Literal::I32(a), Literal::I32(b), Literal::I32(c)) => { - Literal::I32(a.clamp(b, c)) - } - (Literal::U32(a), Literal::U32(b), Literal::U32(c)) => { - Literal::U32(a.clamp(b, c)) - } - (Literal::F32(a), Literal::F32(b), Literal::F32(c)) => { - Literal::F32(glsl_float_clamp(a, b, c)) - } - _ => return Err(ConstantSolvingError::InvalidMathArg), - }, - _ => { - return Err(ConstantSolvingError::NotImplemented(format!( - "{fun:?} applied to vector values" - ))) - } - }; - - let expr = Expression::Literal(literal); - Ok(self.register_constant(expr, span)) - } - _ => Err(ConstantSolvingError::NotImplemented(format!("{fun:?}"))), - } + self.math(arg, arg1, arg2, arg3, fun, span) } Expression::As { convert, expr, kind, } => { - let expr_constant = self.solve_impl(expr, expr_type, false)?; + let expr_constant = self.eval_impl(expr, expr_type, false)?; match convert { Some(width) => self.cast(expr_constant, kind, width, span), - None => Err(ConstantSolvingError::Bitcast), + None => Err(ConstantEvaluatorError::Bitcast), } } Expression::ArrayLength(expr) => { - let array = self.solve_impl(expr, expr_type, false)?; - - match self.const_expressions[array] { - Expression::ZeroValue(ty) | Expression::Compose { ty, .. } => { - match self.types[ty].inner { - TypeInner::Array { size, .. } => match size { - crate::ArraySize::Constant(len) => { - let expr = Expression::Literal(Literal::U32(len.get())); - Ok(self.register_constant(expr, span)) - } - crate::ArraySize::Dynamic => { - Err(ConstantSolvingError::ArrayLengthDynamic) - } - }, - _ => Err(ConstantSolvingError::InvalidArrayLengthArg), - } - } - _ => Err(ConstantSolvingError::InvalidArrayLengthArg), - } + let array = self.eval_impl(expr, expr_type, false)?; + + self.array_length(array, span) } - Expression::Load { .. } => Err(ConstantSolvingError::Load), - Expression::Select { .. } => Err(ConstantSolvingError::Select), - Expression::LocalVariable(_) => Err(ConstantSolvingError::LocalVariable), - Expression::Derivative { .. } => Err(ConstantSolvingError::Derivative), - Expression::Relational { .. } => Err(ConstantSolvingError::Relational), - Expression::CallResult { .. } => Err(ConstantSolvingError::Call), + Expression::Load { .. } => Err(ConstantEvaluatorError::Load), + Expression::Select { .. } => Err(ConstantEvaluatorError::Select), + Expression::LocalVariable(_) => Err(ConstantEvaluatorError::LocalVariable), + Expression::Derivative { .. } => Err(ConstantEvaluatorError::Derivative), + Expression::Relational { .. } => Err(ConstantEvaluatorError::Relational), + Expression::CallResult { .. } => Err(ConstantEvaluatorError::Call), Expression::WorkGroupUniformLoadResult { .. } => unreachable!(), - Expression::AtomicResult { .. } => Err(ConstantSolvingError::Atomic), - Expression::FunctionArgument(_) => Err(ConstantSolvingError::FunctionArg), - Expression::GlobalVariable(_) => Err(ConstantSolvingError::GlobalVariable), + Expression::AtomicResult { .. } => Err(ConstantEvaluatorError::Atomic), + Expression::FunctionArgument(_) => Err(ConstantEvaluatorError::FunctionArg), + Expression::GlobalVariable(_) => Err(ConstantEvaluatorError::GlobalVariable), Expression::ImageSample { .. } | Expression::ImageLoad { .. } - | Expression::ImageQuery { .. } => Err(ConstantSolvingError::ImageExpression), + | Expression::ImageQuery { .. } => Err(ConstantEvaluatorError::ImageExpression), Expression::RayQueryProceedResult | Expression::RayQueryGetIntersection { .. } => { - Err(ConstantSolvingError::RayQueryExpression) + Err(ConstantEvaluatorError::RayQueryExpression) + } + } + } + + fn splat( + &mut self, + value: Handle, + size: crate::VectorSize, + span: Span, + ) -> Result, ConstantEvaluatorError> { + match self.expressions[value] { + Expression::Literal(literal) => { + let kind = literal.scalar_kind(); + let width = literal.width(); + let ty = self.types.insert( + Type { + name: None, + inner: TypeInner::Vector { size, kind, width }, + }, + span, + ); + let expr = Expression::Compose { + ty, + components: vec![value; size as usize], + }; + Ok(self.register_evaluated_expr(expr, span)) + } + Expression::ZeroValue(ty) => { + let inner = match self.types[ty].inner { + TypeInner::Scalar { kind, width } => TypeInner::Vector { size, kind, width }, + _ => return Err(ConstantEvaluatorError::SplatScalarOnly), + }; + let res_ty = self.types.insert(Type { name: None, inner }, span); + let expr = Expression::ZeroValue(res_ty); + Ok(self.register_evaluated_expr(expr, span)) } + _ => Err(ConstantEvaluatorError::SplatScalarOnly), + } + } + + fn swizzle( + &mut self, + size: crate::VectorSize, + span: Span, + src_constant: Handle, + pattern: [crate::SwizzleComponent; 4], + ) -> Result, ConstantEvaluatorError> { + let mut get_dst_ty = |ty| match self.types[ty].inner { + crate::TypeInner::Vector { + size: _, + kind, + width, + } => Ok(self.types.insert( + Type { + name: None, + inner: crate::TypeInner::Vector { size, kind, width }, + }, + span, + )), + _ => Err(ConstantEvaluatorError::SwizzleVectorOnly), + }; + + match self.expressions[src_constant] { + Expression::ZeroValue(ty) => { + let dst_ty = get_dst_ty(ty)?; + let expr = Expression::ZeroValue(dst_ty); + Ok(self.register_evaluated_expr(expr, span)) + } + Expression::Splat { value, .. } => { + let expr = Expression::Splat { size, value }; + Ok(self.register_evaluated_expr(expr, span)) + } + Expression::Compose { + ty, + components: ref src_components, + } => { + let dst_ty = get_dst_ty(ty)?; + + let components = pattern + .iter() + .take(size as usize) + .map(|&sc| src_components[sc as usize]) + .collect(); + let expr = Expression::Compose { + ty: dst_ty, + components, + }; + Ok(self.register_evaluated_expr(expr, span)) + } + _ => Err(ConstantEvaluatorError::SwizzleVectorOnly), + } + } + + fn math( + &mut self, + arg: Handle, + arg1: Option>, + arg2: Option>, + arg3: Option>, + fun: crate::MathFunction, + span: Span, + ) -> Result, ConstantEvaluatorError> { + let const0 = &self.expressions[arg]; + let const1 = arg1.map(|arg| &self.expressions[arg]); + let const2 = arg2.map(|arg| &self.expressions[arg]); + let _const3 = arg3.map(|arg| &self.expressions[arg]); + + match fun { + crate::MathFunction::Pow => { + let literal = match (const0, const1.unwrap()) { + (&Expression::Literal(value0), &Expression::Literal(value1)) => { + match (value0, value1) { + (Literal::I32(a), Literal::I32(b)) => Literal::I32(a.pow(b as u32)), + (Literal::U32(a), Literal::U32(b)) => Literal::U32(a.pow(b)), + (Literal::F32(a), Literal::F32(b)) => Literal::F32(a.powf(b)), + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + } + } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }; + + let expr = Expression::Literal(literal); + Ok(self.register_evaluated_expr(expr, span)) + } + crate::MathFunction::Clamp => { + let literal = match (const0, const1.unwrap(), const2.unwrap()) { + ( + &Expression::Literal(value0), + &Expression::Literal(value1), + &Expression::Literal(value2), + ) => match (value0, value1, value2) { + (Literal::I32(a), Literal::I32(b), Literal::I32(c)) => { + Literal::I32(a.clamp(b, c)) + } + (Literal::U32(a), Literal::U32(b), Literal::U32(c)) => { + Literal::U32(a.clamp(b, c)) + } + (Literal::F32(a), Literal::F32(b), Literal::F32(c)) => { + Literal::F32(glsl_float_clamp(a, b, c)) + } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }, + _ => { + return Err(ConstantEvaluatorError::NotImplemented(format!( + "{fun:?} applied to vector values" + ))) + } + }; + + let expr = Expression::Literal(literal); + Ok(self.register_evaluated_expr(expr, span)) + } + _ => Err(ConstantEvaluatorError::NotImplemented(format!("{fun:?}"))), + } + } + + fn array_length( + &mut self, + array: Handle, + span: Span, + ) -> Result, ConstantEvaluatorError> { + match self.expressions[array] { + Expression::ZeroValue(ty) | Expression::Compose { ty, .. } => { + match self.types[ty].inner { + TypeInner::Array { size, .. } => match size { + crate::ArraySize::Constant(len) => { + let expr = Expression::Literal(Literal::U32(len.get())); + Ok(self.register_evaluated_expr(expr, span)) + } + crate::ArraySize::Dynamic => { + Err(ConstantEvaluatorError::ArrayLengthDynamic) + } + }, + _ => Err(ConstantEvaluatorError::InvalidArrayLengthArg), + } + } + _ => Err(ConstantEvaluatorError::InvalidArrayLengthArg), } } @@ -356,60 +536,68 @@ impl<'a> ConstantSolver<'a> { &mut self, base: Handle, index: usize, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - match self.const_expressions[base] { + span: Span, + ) -> Result, ConstantEvaluatorError> { + match self.expressions[base] { Expression::ZeroValue(ty) => { let ty_inner = &self.types[ty].inner; let components = ty_inner .components() - .ok_or(ConstantSolvingError::InvalidAccessBase)?; + .ok_or(ConstantEvaluatorError::InvalidAccessBase)?; if index >= components as usize { - Err(ConstantSolvingError::InvalidAccessBase) + Err(ConstantEvaluatorError::InvalidAccessBase) } else { let ty_res = ty_inner .component_type(index) - .ok_or(ConstantSolvingError::InvalidAccessIndex)?; + .ok_or(ConstantEvaluatorError::InvalidAccessIndex)?; let ty = match ty_res { crate::proc::TypeResolution::Handle(ty) => ty, crate::proc::TypeResolution::Value(inner) => { self.types.insert(Type { name: None, inner }, span) } }; - Ok(self.register_constant(Expression::ZeroValue(ty), span)) + Ok(self.register_evaluated_expr(Expression::ZeroValue(ty), span)) + } + } + Expression::Splat { size, value } => { + if index >= size as usize { + Err(ConstantEvaluatorError::InvalidAccessBase) + } else { + Ok(value) } } Expression::Compose { ty, ref components } => { let _ = self.types[ty] .inner .components() - .ok_or(ConstantSolvingError::InvalidAccessBase)?; + .ok_or(ConstantEvaluatorError::InvalidAccessBase)?; components .get(index) .copied() - .ok_or(ConstantSolvingError::InvalidAccessIndex) + .ok_or(ConstantEvaluatorError::InvalidAccessIndex) } - _ => Err(ConstantSolvingError::InvalidAccessBase), + _ => Err(ConstantEvaluatorError::InvalidAccessBase), } } - fn constant_index(&self, expr: Handle) -> Result { - match self.const_expressions[expr] { + fn constant_index(&self, expr: Handle) -> Result { + match self.expressions[expr] { Expression::Literal(Literal::U32(index)) => Ok(index as usize), - _ => Err(ConstantSolvingError::InvalidAccessIndexTy), + _ => Err(ConstantEvaluatorError::InvalidAccessIndexTy), } } - /// Transforms a `Expression::ZeroValue` into either `Expression::Literal` or `Expression::Compose` - fn eval_zero_value( + /// Transforms `Expression::ZeroValue` and `Expression::Splat` into either `Expression::Literal` or `Expression::Compose` + fn eval_zero_value_and_splat( &mut self, expr: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - match self.const_expressions[expr] { + span: Span, + ) -> Result, ConstantEvaluatorError> { + match self.expressions[expr] { Expression::ZeroValue(ty) => self.eval_zero_value_impl(ty, span), + Expression::Splat { size, value } => self.splat(value, size, span), _ => Ok(expr), } } @@ -417,14 +605,15 @@ impl<'a> ConstantSolver<'a> { fn eval_zero_value_impl( &mut self, ty: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { + span: Span, + ) -> Result, ConstantEvaluatorError> { match self.types[ty].inner { TypeInner::Scalar { kind, width } => { let expr = Expression::Literal( - Literal::zero(kind, width).ok_or(ConstantSolvingError::TypeNotConstructible)?, + Literal::zero(kind, width) + .ok_or(ConstantEvaluatorError::TypeNotConstructible)?, ); - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } TypeInner::Vector { size, kind, width } => { let scalar_ty = self.types.insert( @@ -439,7 +628,7 @@ impl<'a> ConstantSolver<'a> { ty, components: vec![el; size as usize], }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } TypeInner::Matrix { columns, @@ -462,7 +651,7 @@ impl<'a> ConstantSolver<'a> { ty, components: vec![el; columns as usize], }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } TypeInner::Array { base, @@ -474,7 +663,7 @@ impl<'a> ConstantSolver<'a> { ty, components: vec![el; size.get() as usize], }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } TypeInner::Struct { ref members, .. } => { let types: Vec<_> = members.iter().map(|m| m.ty).collect(); @@ -483,9 +672,9 @@ impl<'a> ConstantSolver<'a> { components.push(self.eval_zero_value_impl(ty, span)?); } let expr = Expression::Compose { ty, components }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } - _ => Err(ConstantSolvingError::TypeNotConstructible), + _ => Err(ConstantEvaluatorError::TypeNotConstructible), } } @@ -494,11 +683,11 @@ impl<'a> ConstantSolver<'a> { expr: Handle, kind: ScalarKind, target_width: crate::Bytes, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let expr = self.eval_zero_value(expr, span)?; + span: Span, + ) -> Result, ConstantEvaluatorError> { + let expr = self.eval_zero_value_and_splat(expr, span)?; - let expr = match self.const_expressions[expr] { + let expr = match self.expressions[expr] { Expression::Literal(literal) => { let literal = match (kind, target_width) { (ScalarKind::Sint, 4) => Literal::I32(match literal { @@ -506,30 +695,30 @@ impl<'a> ConstantSolver<'a> { Literal::U32(v) => v as i32, Literal::F32(v) => v as i32, Literal::Bool(v) => v as i32, - Literal::F64(_) => return Err(ConstantSolvingError::InvalidCastArg), + Literal::F64(_) => return Err(ConstantEvaluatorError::InvalidCastArg), }), (ScalarKind::Uint, 4) => Literal::U32(match literal { Literal::I32(v) => v as u32, Literal::U32(v) => v, Literal::F32(v) => v as u32, Literal::Bool(v) => v as u32, - Literal::F64(_) => return Err(ConstantSolvingError::InvalidCastArg), + Literal::F64(_) => return Err(ConstantEvaluatorError::InvalidCastArg), }), (ScalarKind::Float, 4) => Literal::F32(match literal { Literal::I32(v) => v as f32, Literal::U32(v) => v as f32, Literal::F32(v) => v, Literal::Bool(v) => v as u32 as f32, - Literal::F64(_) => return Err(ConstantSolvingError::InvalidCastArg), + Literal::F64(_) => return Err(ConstantEvaluatorError::InvalidCastArg), }), (ScalarKind::Bool, crate::BOOL_WIDTH) => Literal::Bool(match literal { Literal::I32(v) => v != 0, Literal::U32(v) => v != 0, Literal::F32(v) => v != 0.0, Literal::Bool(v) => v, - Literal::F64(_) => return Err(ConstantSolvingError::InvalidCastArg), + Literal::F64(_) => return Err(ConstantEvaluatorError::InvalidCastArg), }), - _ => return Err(ConstantSolvingError::InvalidCastArg), + _ => return Err(ConstantEvaluatorError::InvalidCastArg), }; Expression::Literal(literal) } @@ -537,44 +726,61 @@ impl<'a> ConstantSolver<'a> { ty, components: ref src_components, } => { - match self.types[ty].inner { - TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), - _ => return Err(ConstantSolvingError::InvalidCastArg), - } + let ty_inner = match self.types[ty].inner { + TypeInner::Vector { size, .. } => TypeInner::Vector { + size, + kind, + width: target_width, + }, + TypeInner::Matrix { columns, rows, .. } => TypeInner::Matrix { + columns, + rows, + width: target_width, + }, + _ => return Err(ConstantEvaluatorError::InvalidCastArg), + }; let mut components = src_components.clone(); for component in &mut components { *component = self.cast(*component, kind, target_width, span)?; } + let ty = self.types.insert( + Type { + name: None, + inner: ty_inner, + }, + span, + ); + Expression::Compose { ty, components } } - _ => return Err(ConstantSolvingError::InvalidCastArg), + _ => return Err(ConstantEvaluatorError::InvalidCastArg), }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } fn unary_op( &mut self, op: UnaryOperator, expr: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let expr = self.eval_zero_value(expr, span)?; + span: Span, + ) -> Result, ConstantEvaluatorError> { + let expr = self.eval_zero_value_and_splat(expr, span)?; - let expr = match self.const_expressions[expr] { + let expr = match self.expressions[expr] { Expression::Literal(value) => Expression::Literal(match op { UnaryOperator::Negate => match value { Literal::I32(v) => Literal::I32(-v), Literal::F32(v) => Literal::F32(-v), - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }, UnaryOperator::Not => match value { Literal::I32(v) => Literal::I32(!v), Literal::U32(v) => Literal::U32(!v), Literal::Bool(v) => Literal::Bool(!v), - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }, }), Expression::Compose { @@ -583,7 +789,7 @@ impl<'a> ConstantSolver<'a> { } => { match self.types[ty].inner { TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), } let mut components = src_components.clone(); @@ -593,10 +799,10 @@ impl<'a> ConstantSolver<'a> { Expression::Compose { ty, components } } - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } fn binary_op( @@ -604,15 +810,12 @@ impl<'a> ConstantSolver<'a> { op: BinaryOperator, left: Handle, right: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let left = self.eval_zero_value(left, span)?; - let right = self.eval_zero_value(right, span)?; - - let expr = match ( - &self.const_expressions[left], - &self.const_expressions[right], - ) { + span: Span, + ) -> Result, ConstantEvaluatorError> { + let left = self.eval_zero_value_and_splat(left, span)?; + let right = self.eval_zero_value_and_splat(right, span)?; + + let expr = match (&self.expressions[left], &self.expressions[right]) { (&Expression::Literal(left_value), &Expression::Literal(right_value)) => { let literal = match op { BinaryOperator::Equal => Literal::Bool(left_value == right_value), @@ -632,12 +835,12 @@ impl<'a> ConstantSolver<'a> { BinaryOperator::And => a & b, BinaryOperator::ExclusiveOr => a ^ b, BinaryOperator::InclusiveOr => a | b, - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::I32(a), Literal::U32(b)) => Literal::I32(match op { BinaryOperator::ShiftLeft => a.wrapping_shl(b), BinaryOperator::ShiftRight => a.wrapping_shr(b), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::U32(a), Literal::U32(b)) => Literal::U32(match op { BinaryOperator::Add => a.wrapping_add(b), @@ -650,7 +853,7 @@ impl<'a> ConstantSolver<'a> { BinaryOperator::InclusiveOr => a | b, BinaryOperator::ShiftLeft => a.wrapping_shl(b), BinaryOperator::ShiftRight => a.wrapping_shr(b), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::F32(a), Literal::F32(b)) => Literal::F32(match op { BinaryOperator::Add => a + b, @@ -658,14 +861,14 @@ impl<'a> ConstantSolver<'a> { BinaryOperator::Multiply => a * b, BinaryOperator::Divide => a / b, BinaryOperator::Modulo => a - b * (a / b).floor(), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::Bool(a), Literal::Bool(b)) => Literal::Bool(match op { BinaryOperator::LogicalAnd => a && b, BinaryOperator::LogicalOr => a || b, - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }, }; Expression::Literal(literal) @@ -696,14 +899,43 @@ impl<'a> ConstantSolver<'a> { } Expression::Compose { ty, components } } - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }; - Ok(self.register_constant(expr, span)) + Ok(self.register_evaluated_expr(expr, span)) } - fn register_constant(&mut self, expr: Expression, span: crate::Span) -> Handle { - self.const_expressions.append(expr, span) + fn copy_from( + &mut self, + handle: Handle, + expressions: &Arena, + ) -> Result, ConstantEvaluatorError> { + let span = expressions.get_span(handle); + match expressions[handle] { + ref expr @ (Expression::Literal(_) + | Expression::Constant(_) + | Expression::ZeroValue(_)) => Ok(self.register_evaluated_expr(expr.clone(), span)), + Expression::Compose { ty, ref components } => { + let mut components = components.clone(); + for component in &mut components { + *component = self.copy_from(*component, expressions)?; + } + Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) + } + Expression::Splat { size, value } => { + let value = self.copy_from(value, expressions)?; + Ok(self.register_evaluated_expr(Expression::Splat { size, value }, span)) + } + _ => Err(ConstantEvaluatorError::SubexpressionsAreNotConstant), + } + } + + fn register_evaluated_expr(&mut self, expr: Expression, span: Span) -> Handle { + if let Some(ref mut append) = self.append { + append(self.expressions, expr, span) + } else { + self.expressions.append(expr, span) + } } } @@ -767,7 +999,7 @@ mod tests { UniqueArena, VectorSize, }; - use super::ConstantSolver; + use super::ConstantEvaluator; #[test] fn nan_handling() { @@ -785,7 +1017,6 @@ mod tests { #[test] fn unary_op() { let mut types = UniqueArena::new(); - let mut expressions = Arena::new(); let mut constants = Arena::new(); let mut const_expressions = Arena::new(); @@ -850,43 +1081,49 @@ mod tests { Default::default(), ); - let expr = expressions.append(Expression::Constant(h), Default::default()); - let expr1 = expressions.append(Expression::Constant(vec_h), Default::default()); + let expr = const_expressions.append(Expression::Constant(h), Default::default()); + let expr1 = const_expressions.append(Expression::Constant(vec_h), Default::default()); - let root1 = expressions.append( - Expression::Unary { - op: UnaryOperator::Negate, - expr, - }, - Default::default(), - ); + let expr2 = Expression::Unary { + op: UnaryOperator::Negate, + expr, + }; - let root2 = expressions.append( - Expression::Unary { - op: UnaryOperator::Not, - expr, - }, - Default::default(), - ); + let expr3 = Expression::Unary { + op: UnaryOperator::Not, + expr, + }; - let root3 = expressions.append( - Expression::Unary { - op: UnaryOperator::Not, - expr: expr1, - }, - Default::default(), - ); + let expr4 = Expression::Unary { + op: UnaryOperator::Not, + expr: expr1, + }; - let mut solver = ConstantSolver { + let mut solver = ConstantEvaluator { types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, + constants: &constants, + expressions: &mut const_expressions, + const_expressions: None, + append: None::< + Box< + dyn FnMut( + &mut Arena, + Expression, + crate::Span, + ) -> crate::Handle, + >, + >, }; - let res1 = solver.solve(root1).unwrap(); - let res2 = solver.solve(root2).unwrap(); - let res3 = solver.solve(root3).unwrap(); + let res1 = solver + .try_eval_and_append(&expr2, Default::default()) + .unwrap(); + let res2 = solver + .try_eval_and_append(&expr3, Default::default()) + .unwrap(); + let res3 = solver + .try_eval_and_append(&expr4, Default::default()) + .unwrap(); assert_eq!( const_expressions[res1], @@ -924,7 +1161,6 @@ mod tests { #[test] fn cast() { let mut types = UniqueArena::new(); - let mut expressions = Arena::new(); let mut constants = Arena::new(); let mut const_expressions = Arena::new(); @@ -950,25 +1186,33 @@ mod tests { Default::default(), ); - let expr = expressions.append(Expression::Constant(h), Default::default()); + let expr = const_expressions.append(Expression::Constant(h), Default::default()); - let root = expressions.append( - Expression::As { - expr, - kind: ScalarKind::Bool, - convert: Some(crate::BOOL_WIDTH), - }, - Default::default(), - ); + let root = Expression::As { + expr, + kind: ScalarKind::Bool, + convert: Some(crate::BOOL_WIDTH), + }; - let mut solver = ConstantSolver { + let mut solver = ConstantEvaluator { types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, + constants: &constants, + expressions: &mut const_expressions, + const_expressions: None, + append: None::< + Box< + dyn FnMut( + &mut Arena, + Expression, + crate::Span, + ) -> crate::Handle, + >, + >, }; - let res = solver.solve(root).unwrap(); + let res = solver + .try_eval_and_append(&root, Default::default()) + .unwrap(); assert_eq!( const_expressions[res], @@ -979,7 +1223,6 @@ mod tests { #[test] fn access() { let mut types = UniqueArena::new(); - let mut expressions = Arena::new(); let mut constants = Arena::new(); let mut const_expressions = Arena::new(); @@ -1076,28 +1319,38 @@ mod tests { Default::default(), ); - let base = expressions.append(Expression::Constant(h), Default::default()); - let root1 = expressions.append( - Expression::AccessIndex { base, index: 1 }, - Default::default(), - ); - let root2 = expressions.append( - Expression::AccessIndex { - base: root1, - index: 2, - }, - Default::default(), - ); + let base = const_expressions.append(Expression::Constant(h), Default::default()); - let mut solver = ConstantSolver { + let mut solver = ConstantEvaluator { types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, + constants: &constants, + expressions: &mut const_expressions, + const_expressions: None, + append: None::< + Box< + dyn FnMut( + &mut Arena, + Expression, + crate::Span, + ) -> crate::Handle, + >, + >, + }; + + let root1 = Expression::AccessIndex { base, index: 1 }; + + let res1 = solver + .try_eval_and_append(&root1, Default::default()) + .unwrap(); + + let root2 = Expression::AccessIndex { + base: res1, + index: 2, }; - let res1 = solver.solve(root1).unwrap(); - let res2 = solver.solve(root2).unwrap(); + let res2 = solver + .try_eval_and_append(&root2, Default::default()) + .unwrap(); match const_expressions[res1] { Expression::Compose { diff --git a/src/proc/mod.rs b/src/proc/mod.rs index 0d12126acb..c91e0cb3ee 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -2,12 +2,14 @@ [`Module`](super::Module) processing functionality. */ +mod constant_evaluator; pub mod index; mod layouter; mod namer; mod terminator; mod typifier; +pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorError}; pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; pub use namer::{EntryPointIndex, NameKey, Namer}; @@ -590,28 +592,39 @@ impl GlobalCtx<'_> { handle: crate::Handle, arena: &crate::Arena, ) -> Result { + match self.eval_expr_to_literal_from(handle, arena) { + Some(crate::Literal::U32(value)) => Ok(value), + Some(crate::Literal::I32(value)) => { + value.try_into().map_err(|_| U32EvalError::Negative) + } + _ => Err(U32EvalError::NonConst), + } + } + + pub(crate) fn eval_expr_to_literal( + &self, + handle: crate::Handle, + ) -> Option { + self.eval_expr_to_literal_from(handle, self.const_expressions) + } + + pub(crate) fn eval_expr_to_literal_from( + &self, + handle: crate::Handle, + arena: &crate::Arena, + ) -> Option { fn get( gctx: GlobalCtx, handle: crate::Handle, arena: &crate::Arena, - ) -> Result { + ) -> Option { match arena[handle] { - crate::Expression::Literal(crate::Literal::U32(value)) => Ok(value), - crate::Expression::Literal(crate::Literal::I32(value)) => { - value.try_into().map_err(|_| U32EvalError::Negative) - } - crate::Expression::ZeroValue(ty) - if matches!( - gctx.types[ty].inner, - crate::TypeInner::Scalar { - kind: crate::ScalarKind::Sint | crate::ScalarKind::Uint, - width: _ - } - ) => - { - Ok(0) - } - _ => Err(U32EvalError::NonConst), + crate::Expression::Literal(literal) => Some(literal), + crate::Expression::ZeroValue(ty) => match gctx.types[ty].inner { + crate::TypeInner::Scalar { kind, width } => crate::Literal::zero(kind, width), + _ => None, + }, + _ => None, } } match arena[handle] { diff --git a/src/valid/expression.rs b/src/valid/expression.rs index 0b61253682..af4b774f12 100644 --- a/src/valid/expression.rs +++ b/src/valid/expression.rs @@ -134,6 +134,8 @@ pub enum ConstExpressionError { NonConst, #[error(transparent)] Compose(#[from] super::ComposeError), + #[error("Splatting {0:?} can't be done")] + InvalidSplatType(Handle), #[error("Type resolution failed")] Type(#[from] ResolveError), #[error(transparent)] @@ -196,6 +198,10 @@ impl super::Validator { components.iter().map(|&handle| mod_info[handle].clone()), )?; } + E::Splat { value, .. } => match *mod_info[value].inner_with(gctx.types) { + crate::TypeInner::Scalar { .. } => {} + _ => return Err(super::ConstExpressionError::InvalidSplatType(value)), + }, _ => return Err(super::ConstExpressionError::NonConst), } diff --git a/tests/out/glsl/constructors.main.Compute.glsl b/tests/out/glsl/constructors.main.Compute.glsl index 112795eda1..8ef0a60ba7 100644 --- a/tests/out/glsl/constructors.main.Compute.glsl +++ b/tests/out/glsl/constructors.main.Compute.glsl @@ -32,11 +32,8 @@ void main() { mat2x2 cit1_ = mat2x2(vec2(0.0), vec2(0.0)); int cit2_[4] = int[4](0, 1, 2, 3); bool ic0_ = bool(false); - int ic1_ = int(0); - uint ic2_ = uint(0u); - float ic3_ = float(0.0); - uvec2 ic4_ = uvec2(uvec2(0u)); - mat2x3 ic5_ = mat2x3(mat2x3(0.0)); + uvec2 ic4_ = uvec2(0u, 0u); + mat2x3 ic5_ = mat2x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); uvec2 ic6_ = uvec2(0u); mat2x3 ic7_ = mat2x3(0.0); } diff --git a/tests/out/glsl/cubeArrayShadow.fragment.Fragment.glsl b/tests/out/glsl/cubeArrayShadow.fragment.Fragment.glsl index ac9bc6de4d..9339532831 100644 --- a/tests/out/glsl/cubeArrayShadow.fragment.Fragment.glsl +++ b/tests/out/glsl/cubeArrayShadow.fragment.Fragment.glsl @@ -9,8 +9,8 @@ uniform highp samplerCubeArrayShadow _group_0_binding_4_fs; layout(location = 0) out vec4 _fs2p_location0; void main() { - vec3 frag_ls = vec4(1.0, 1.0, 2.0, 1.0).xyz; - float a = texture(_group_0_binding_4_fs, vec4(frag_ls, int(1)), 1.0); + vec3 frag_ls = vec3(1.0, 1.0, 2.0); + float a = texture(_group_0_binding_4_fs, vec4(frag_ls, 1), 1.0); _fs2p_location0 = vec4(a, 1.0, 1.0, 1.0); return; } diff --git a/tests/out/glsl/image.texture_sample.Fragment.glsl b/tests/out/glsl/image.texture_sample.Fragment.glsl index 97be5a59d0..dc17cedc26 100644 --- a/tests/out/glsl/image.texture_sample.Fragment.glsl +++ b/tests/out/glsl/image.texture_sample.Fragment.glsl @@ -18,74 +18,74 @@ void main() { vec4 a = vec4(0.0); vec2 tc = vec2(0.5); vec3 tc3_ = vec3(0.5); - vec4 _e9 = texture(_group_0_binding_0_fs, vec2(tc.x, 0.0)); - vec4 _e10 = a; - a = (_e10 + _e9); - vec4 _e14 = texture(_group_0_binding_1_fs, vec2(tc)); - vec4 _e15 = a; - a = (_e15 + _e14); - vec4 _e19 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1)); - vec4 _e20 = a; - a = (_e20 + _e19); - vec4 _e24 = textureLod(_group_0_binding_1_fs, vec2(tc), 2.3); - vec4 _e25 = a; - a = (_e25 + _e24); - vec4 _e29 = textureLodOffset(_group_0_binding_1_fs, vec2(tc), 2.3, ivec2(3, 1)); - vec4 _e30 = a; - a = (_e30 + _e29); - vec4 _e35 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1), 2.0); - vec4 _e36 = a; - a = (_e36 + _e35); - vec4 _e41 = texture(_group_0_binding_4_fs, vec3(tc, 0u)); - vec4 _e42 = a; - a = (_e42 + _e41); - vec4 _e47 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1)); - vec4 _e48 = a; - a = (_e48 + _e47); - vec4 _e53 = textureLod(_group_0_binding_4_fs, vec3(tc, 0u), 2.3); - vec4 _e54 = a; - a = (_e54 + _e53); - vec4 _e59 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0u), 2.3, ivec2(3, 1)); - vec4 _e60 = a; - a = (_e60 + _e59); - vec4 _e66 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1), 2.0); - vec4 _e67 = a; - a = (_e67 + _e66); - vec4 _e72 = texture(_group_0_binding_4_fs, vec3(tc, 0)); - vec4 _e73 = a; - a = (_e73 + _e72); - vec4 _e78 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1)); - vec4 _e79 = a; - a = (_e79 + _e78); - vec4 _e84 = textureLod(_group_0_binding_4_fs, vec3(tc, 0), 2.3); - vec4 _e85 = a; - a = (_e85 + _e84); - vec4 _e90 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0), 2.3, ivec2(3, 1)); - vec4 _e91 = a; - a = (_e91 + _e90); - vec4 _e97 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1), 2.0); - vec4 _e98 = a; - a = (_e98 + _e97); - vec4 _e103 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u)); - vec4 _e104 = a; - a = (_e104 + _e103); - vec4 _e109 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.3); - vec4 _e110 = a; - a = (_e110 + _e109); - vec4 _e116 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.0); - vec4 _e117 = a; - a = (_e117 + _e116); - vec4 _e122 = texture(_group_0_binding_6_fs, vec4(tc3_, 0)); - vec4 _e123 = a; - a = (_e123 + _e122); - vec4 _e128 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0), 2.3); - vec4 _e129 = a; - a = (_e129 + _e128); - vec4 _e135 = texture(_group_0_binding_6_fs, vec4(tc3_, 0), 2.0); - vec4 _e136 = a; - a = (_e136 + _e135); - vec4 _e138 = a; - _fs2p_location0 = _e138; + vec4 _e8 = texture(_group_0_binding_0_fs, vec2(0.5, 0.0)); + vec4 _e9 = a; + a = (_e9 + _e8); + vec4 _e13 = texture(_group_0_binding_1_fs, vec2(tc)); + vec4 _e14 = a; + a = (_e14 + _e13); + vec4 _e18 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1)); + vec4 _e19 = a; + a = (_e19 + _e18); + vec4 _e23 = textureLod(_group_0_binding_1_fs, vec2(tc), 2.3); + vec4 _e24 = a; + a = (_e24 + _e23); + vec4 _e28 = textureLodOffset(_group_0_binding_1_fs, vec2(tc), 2.3, ivec2(3, 1)); + vec4 _e29 = a; + a = (_e29 + _e28); + vec4 _e34 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1), 2.0); + vec4 _e35 = a; + a = (_e35 + _e34); + vec4 _e40 = texture(_group_0_binding_4_fs, vec3(tc, 0u)); + vec4 _e41 = a; + a = (_e41 + _e40); + vec4 _e46 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1)); + vec4 _e47 = a; + a = (_e47 + _e46); + vec4 _e52 = textureLod(_group_0_binding_4_fs, vec3(tc, 0u), 2.3); + vec4 _e53 = a; + a = (_e53 + _e52); + vec4 _e58 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0u), 2.3, ivec2(3, 1)); + vec4 _e59 = a; + a = (_e59 + _e58); + vec4 _e65 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1), 2.0); + vec4 _e66 = a; + a = (_e66 + _e65); + vec4 _e71 = texture(_group_0_binding_4_fs, vec3(tc, 0)); + vec4 _e72 = a; + a = (_e72 + _e71); + vec4 _e77 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1)); + vec4 _e78 = a; + a = (_e78 + _e77); + vec4 _e83 = textureLod(_group_0_binding_4_fs, vec3(tc, 0), 2.3); + vec4 _e84 = a; + a = (_e84 + _e83); + vec4 _e89 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0), 2.3, ivec2(3, 1)); + vec4 _e90 = a; + a = (_e90 + _e89); + vec4 _e96 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1), 2.0); + vec4 _e97 = a; + a = (_e97 + _e96); + vec4 _e102 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u)); + vec4 _e103 = a; + a = (_e103 + _e102); + vec4 _e108 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.3); + vec4 _e109 = a; + a = (_e109 + _e108); + vec4 _e115 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.0); + vec4 _e116 = a; + a = (_e116 + _e115); + vec4 _e121 = texture(_group_0_binding_6_fs, vec4(tc3_, 0)); + vec4 _e122 = a; + a = (_e122 + _e121); + vec4 _e127 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0), 2.3); + vec4 _e128 = a; + a = (_e128 + _e127); + vec4 _e134 = texture(_group_0_binding_6_fs, vec4(tc3_, 0), 2.0); + vec4 _e135 = a; + a = (_e135 + _e134); + vec4 _e137 = a; + _fs2p_location0 = _e137; return; } diff --git a/tests/out/glsl/operators.main.Compute.glsl b/tests/out/glsl/operators.main.Compute.glsl index ba3734be18..1ed88c1023 100644 --- a/tests/out/glsl/operators.main.Compute.glsl +++ b/tests/out/glsl/operators.main.Compute.glsl @@ -17,9 +17,9 @@ vec4 builtins() { vec4 s3_ = mix(v_f32_one, v_f32_zero, bvec4(false, false, false, false)); vec4 m1_ = mix(v_f32_zero, v_f32_one, v_f32_half); vec4 m2_ = mix(v_f32_zero, v_f32_one, 0.1); - float b1_ = intBitsToFloat(v_i32_one.x); + float b1_ = intBitsToFloat(1); vec4 b2_ = intBitsToFloat(v_i32_one); - ivec4 v_i32_zero = ivec4(v_f32_zero); + ivec4 v_i32_zero = ivec4(0, 0, 0, 0); return (((((vec4((ivec4(s1_) + v_i32_zero)) + s2_) + m1_) + m2_) + vec4(b1_)) + b2_); } @@ -48,10 +48,7 @@ vec3 bool_cast(vec3 x) { } void logical() { - bool neg0_ = !(true); - bvec2 neg1_ = not(bvec2(true)); - bool or = (true || false); - bool and = (true && false); + bvec2 neg1_ = bvec2(false, false); bool bitwise_or0_ = (true || false); bvec3 bitwise_or1_ = bvec3(bvec3(true).x || bvec3(false).x, bvec3(true).y || bvec3(false).y, bvec3(true).z || bvec3(false).z); bool bitwise_and0_ = (true && false); @@ -59,140 +56,95 @@ void logical() { } void arithmetic() { - ivec2 neg1_1 = -(ivec2(1)); - vec2 neg2_ = -(vec2(1.0)); - int add0_ = (2 + 1); - uint add1_ = (2u + 1u); - float add2_ = (2.0 + 1.0); + ivec2 neg1_1 = ivec2(-1, -1); + vec2 neg2_ = vec2(-1.0, -1.0); ivec2 add3_ = (ivec2(2) + ivec2(1)); uvec3 add4_ = (uvec3(2u) + uvec3(1u)); vec4 add5_ = (vec4(2.0) + vec4(1.0)); - int sub0_ = (2 - 1); - uint sub1_ = (2u - 1u); - float sub2_ = (2.0 - 1.0); ivec2 sub3_ = (ivec2(2) - ivec2(1)); uvec3 sub4_ = (uvec3(2u) - uvec3(1u)); vec4 sub5_ = (vec4(2.0) - vec4(1.0)); - int mul0_ = (2 * 1); - uint mul1_ = (2u * 1u); - float mul2_ = (2.0 * 1.0); ivec2 mul3_ = (ivec2(2) * ivec2(1)); uvec3 mul4_ = (uvec3(2u) * uvec3(1u)); vec4 mul5_ = (vec4(2.0) * vec4(1.0)); - int div0_ = (2 / 1); - uint div1_ = (2u / 1u); - float div2_ = (2.0 / 1.0); ivec2 div3_ = (ivec2(2) / ivec2(1)); uvec3 div4_ = (uvec3(2u) / uvec3(1u)); vec4 div5_ = (vec4(2.0) / vec4(1.0)); - int rem0_ = (2 % 1); - uint rem1_ = (2u % 1u); - float rem2_ = (2.0 - 1.0 * trunc(2.0 / 1.0)); ivec2 rem3_ = (ivec2(2) % ivec2(1)); uvec3 rem4_ = (uvec3(2u) % uvec3(1u)); vec4 rem5_ = (vec4(2.0) - vec4(1.0) * trunc(vec4(2.0) / vec4(1.0))); { - ivec2 add0_1 = (ivec2(2) + ivec2(1)); - ivec2 add1_1 = (ivec2(2) + ivec2(1)); - uvec2 add2_1 = (uvec2(2u) + uvec2(1u)); + ivec2 add0_ = (ivec2(2) + ivec2(1)); + ivec2 add1_ = (ivec2(2) + ivec2(1)); + uvec2 add2_ = (uvec2(2u) + uvec2(1u)); uvec2 add3_1 = (uvec2(2u) + uvec2(1u)); vec2 add4_1 = (vec2(2.0) + vec2(1.0)); vec2 add5_1 = (vec2(2.0) + vec2(1.0)); - ivec2 sub0_1 = (ivec2(2) - ivec2(1)); - ivec2 sub1_1 = (ivec2(2) - ivec2(1)); - uvec2 sub2_1 = (uvec2(2u) - uvec2(1u)); + ivec2 sub0_ = (ivec2(2) - ivec2(1)); + ivec2 sub1_ = (ivec2(2) - ivec2(1)); + uvec2 sub2_ = (uvec2(2u) - uvec2(1u)); uvec2 sub3_1 = (uvec2(2u) - uvec2(1u)); vec2 sub4_1 = (vec2(2.0) - vec2(1.0)); vec2 sub5_1 = (vec2(2.0) - vec2(1.0)); - ivec2 mul0_1 = (ivec2(2) * 1); - ivec2 mul1_1 = (2 * ivec2(1)); - uvec2 mul2_1 = (uvec2(2u) * 1u); - uvec2 mul3_1 = (2u * uvec2(1u)); - vec2 mul4_1 = (vec2(2.0) * 1.0); - vec2 mul5_1 = (2.0 * vec2(1.0)); - ivec2 div0_1 = (ivec2(2) / ivec2(1)); - ivec2 div1_1 = (ivec2(2) / ivec2(1)); - uvec2 div2_1 = (uvec2(2u) / uvec2(1u)); + ivec2 mul0_ = ivec2(2, 2); + ivec2 mul1_ = ivec2(2, 2); + uvec2 mul2_ = uvec2(2u, 2u); + uvec2 mul3_1 = uvec2(2u, 2u); + vec2 mul4_1 = vec2(2.0, 2.0); + vec2 mul5_1 = vec2(2.0, 2.0); + ivec2 div0_ = (ivec2(2) / ivec2(1)); + ivec2 div1_ = (ivec2(2) / ivec2(1)); + uvec2 div2_ = (uvec2(2u) / uvec2(1u)); uvec2 div3_1 = (uvec2(2u) / uvec2(1u)); vec2 div4_1 = (vec2(2.0) / vec2(1.0)); vec2 div5_1 = (vec2(2.0) / vec2(1.0)); - ivec2 rem0_1 = (ivec2(2) % ivec2(1)); - ivec2 rem1_1 = (ivec2(2) % ivec2(1)); - uvec2 rem2_1 = (uvec2(2u) % uvec2(1u)); + ivec2 rem0_ = (ivec2(2) % ivec2(1)); + ivec2 rem1_ = (ivec2(2) % ivec2(1)); + uvec2 rem2_ = (uvec2(2u) % uvec2(1u)); uvec2 rem3_1 = (uvec2(2u) % uvec2(1u)); vec2 rem4_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0))); vec2 rem5_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0))); } mat3x3 add = (mat3x3(0.0) + mat3x3(0.0)); mat3x3 sub = (mat3x3(0.0) - mat3x3(0.0)); - mat3x3 mul_scalar0_ = (mat3x3(0.0) * 1.0); - mat3x3 mul_scalar1_ = (2.0 * mat3x3(0.0)); + mat3x3 mul_scalar0_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); + mat3x3 mul_scalar1_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); vec3 mul_vector0_ = (mat4x3(0.0) * vec4(1.0)); vec4 mul_vector1_ = (vec3(2.0) * mat4x3(0.0)); mat3x3 mul = (mat4x3(0.0) * mat3x4(0.0)); } void bit() { - int flip0_ = ~(1); - uint flip1_ = ~(1u); - ivec2 flip2_ = ~(ivec2(1)); - uvec3 flip3_ = ~(uvec3(1u)); - int or0_ = (2 | 1); - uint or1_ = (2u | 1u); + ivec2 flip2_ = ivec2(-2, -2); + uvec3 flip3_ = uvec3(4294967294u, 4294967294u, 4294967294u); ivec2 or2_ = (ivec2(2) | ivec2(1)); uvec3 or3_ = (uvec3(2u) | uvec3(1u)); - int and0_ = (2 & 1); - uint and1_ = (2u & 1u); ivec2 and2_ = (ivec2(2) & ivec2(1)); uvec3 and3_ = (uvec3(2u) & uvec3(1u)); - int xor0_ = (2 ^ 1); - uint xor1_ = (2u ^ 1u); ivec2 xor2_ = (ivec2(2) ^ ivec2(1)); uvec3 xor3_ = (uvec3(2u) ^ uvec3(1u)); - int shl0_ = (2 << 1u); - uint shl1_ = (2u << 1u); ivec2 shl2_ = (ivec2(2) << uvec2(1u)); uvec3 shl3_ = (uvec3(2u) << uvec3(1u)); - int shr0_ = (2 >> 1u); - uint shr1_ = (2u >> 1u); ivec2 shr2_ = (ivec2(2) >> uvec2(1u)); uvec3 shr3_ = (uvec3(2u) >> uvec3(1u)); } void comparison() { - bool eq0_ = (2 == 1); - bool eq1_ = (2u == 1u); - bool eq2_ = (2.0 == 1.0); bvec2 eq3_ = equal(ivec2(2), ivec2(1)); bvec3 eq4_ = equal(uvec3(2u), uvec3(1u)); bvec4 eq5_ = equal(vec4(2.0), vec4(1.0)); - bool neq0_ = (2 != 1); - bool neq1_ = (2u != 1u); - bool neq2_ = (2.0 != 1.0); bvec2 neq3_ = notEqual(ivec2(2), ivec2(1)); bvec3 neq4_ = notEqual(uvec3(2u), uvec3(1u)); bvec4 neq5_ = notEqual(vec4(2.0), vec4(1.0)); - bool lt0_ = (2 < 1); - bool lt1_ = (2u < 1u); - bool lt2_ = (2.0 < 1.0); bvec2 lt3_ = lessThan(ivec2(2), ivec2(1)); bvec3 lt4_ = lessThan(uvec3(2u), uvec3(1u)); bvec4 lt5_ = lessThan(vec4(2.0), vec4(1.0)); - bool lte0_ = (2 <= 1); - bool lte1_ = (2u <= 1u); - bool lte2_ = (2.0 <= 1.0); bvec2 lte3_ = lessThanEqual(ivec2(2), ivec2(1)); bvec3 lte4_ = lessThanEqual(uvec3(2u), uvec3(1u)); bvec4 lte5_ = lessThanEqual(vec4(2.0), vec4(1.0)); - bool gt0_ = (2 > 1); - bool gt1_ = (2u > 1u); - bool gt2_ = (2.0 > 1.0); bvec2 gt3_ = greaterThan(ivec2(2), ivec2(1)); bvec3 gt4_ = greaterThan(uvec3(2u), uvec3(1u)); bvec4 gt5_ = greaterThan(vec4(2.0), vec4(1.0)); - bool gte0_ = (2 >= 1); - bool gte1_ = (2u >= 1u); - bool gte2_ = (2.0 >= 1.0); bvec2 gte3_ = greaterThanEqual(ivec2(2), ivec2(1)); bvec3 gte4_ = greaterThanEqual(uvec3(2u), uvec3(1u)); bvec4 gte5_ = greaterThanEqual(vec4(2.0), vec4(1.0)); @@ -237,19 +189,13 @@ void assignment() { } void negation_avoids_prefix_decrement() { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + return; } void main() { vec4 _e0 = builtins(); vec4 _e1 = splat(); - vec3 _e4 = bool_cast(v_f32_one.xyz); + vec3 _e6 = bool_cast(vec3(1.0, 1.0, 1.0)); logical(); arithmetic(); bit(); diff --git a/tests/out/hlsl/constructors.hlsl b/tests/out/hlsl/constructors.hlsl index 3b9c06b0c1..52de162f44 100644 --- a/tests/out/hlsl/constructors.hlsl +++ b/tests/out/hlsl/constructors.hlsl @@ -50,11 +50,8 @@ void main() float2x2 cit1_ = float2x2((0.0).xx, (0.0).xx); int cit2_[4] = Constructarray4_int_(0, 1, 2, 3); bool ic0_ = bool((bool)0); - int ic1_ = int((int)0); - uint ic2_ = uint((uint)0); - float ic3_ = float((float)0); - uint2 ic4_ = uint2((uint2)0); - float2x3 ic5_ = float2x3((float2x3)0); + uint2 ic4_ = uint2(0u, 0u); + float2x3 ic5_ = float2x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)); uint2 ic6_ = asuint((uint2)0); float2x3 ic7_ = asfloat((float2x3)0); } diff --git a/tests/out/hlsl/image.hlsl b/tests/out/hlsl/image.hlsl index e284813a1b..05825e18cf 100644 --- a/tests/out/hlsl/image.hlsl +++ b/tests/out/hlsl/image.hlsl @@ -246,74 +246,74 @@ float4 texture_sample() : SV_Target0 float2 tc = (0.5).xx; float3 tc3_ = (0.5).xxx; - float4 _expr9 = image_1d.Sample(sampler_reg, tc.x); - float4 _expr10 = a; - a = (_expr10 + _expr9); - float4 _expr14 = image_2d.Sample(sampler_reg, tc); - float4 _expr15 = a; - a = (_expr15 + _expr14); - float4 _expr19 = image_2d.Sample(sampler_reg, tc, int2(3, 1)); - float4 _expr20 = a; - a = (_expr20 + _expr19); - float4 _expr24 = image_2d.SampleLevel(sampler_reg, tc, 2.3); - float4 _expr25 = a; - a = (_expr25 + _expr24); - float4 _expr29 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(3, 1)); - float4 _expr30 = a; - a = (_expr30 + _expr29); - float4 _expr35 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(3, 1)); - float4 _expr36 = a; - a = (_expr36 + _expr35); - float4 _expr41 = image_2d_array.Sample(sampler_reg, float3(tc, 0u)); - float4 _expr42 = a; - a = (_expr42 + _expr41); - float4 _expr47 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(3, 1)); - float4 _expr48 = a; - a = (_expr48 + _expr47); - float4 _expr53 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3); - float4 _expr54 = a; - a = (_expr54 + _expr53); - float4 _expr59 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(3, 1)); - float4 _expr60 = a; - a = (_expr60 + _expr59); - float4 _expr66 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(3, 1)); - float4 _expr67 = a; - a = (_expr67 + _expr66); - float4 _expr72 = image_2d_array.Sample(sampler_reg, float3(tc, 0)); - float4 _expr73 = a; - a = (_expr73 + _expr72); - float4 _expr78 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(3, 1)); - float4 _expr79 = a; - a = (_expr79 + _expr78); - float4 _expr84 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3); - float4 _expr85 = a; - a = (_expr85 + _expr84); - float4 _expr90 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(3, 1)); - float4 _expr91 = a; - a = (_expr91 + _expr90); - float4 _expr97 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(3, 1)); - float4 _expr98 = a; - a = (_expr98 + _expr97); - float4 _expr103 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u)); - float4 _expr104 = a; - a = (_expr104 + _expr103); - float4 _expr109 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3); - float4 _expr110 = a; - a = (_expr110 + _expr109); - float4 _expr116 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0); - float4 _expr117 = a; - a = (_expr117 + _expr116); - float4 _expr122 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0)); - float4 _expr123 = a; - a = (_expr123 + _expr122); - float4 _expr128 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3); - float4 _expr129 = a; - a = (_expr129 + _expr128); - float4 _expr135 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0); - float4 _expr136 = a; - a = (_expr136 + _expr135); - float4 _expr138 = a; - return _expr138; + float4 _expr8 = image_1d.Sample(sampler_reg, 0.5); + float4 _expr9 = a; + a = (_expr9 + _expr8); + float4 _expr13 = image_2d.Sample(sampler_reg, tc); + float4 _expr14 = a; + a = (_expr14 + _expr13); + float4 _expr18 = image_2d.Sample(sampler_reg, tc, int2(int2(3, 1))); + float4 _expr19 = a; + a = (_expr19 + _expr18); + float4 _expr23 = image_2d.SampleLevel(sampler_reg, tc, 2.3); + float4 _expr24 = a; + a = (_expr24 + _expr23); + float4 _expr28 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(3, 1))); + float4 _expr29 = a; + a = (_expr29 + _expr28); + float4 _expr34 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(3, 1))); + float4 _expr35 = a; + a = (_expr35 + _expr34); + float4 _expr40 = image_2d_array.Sample(sampler_reg, float3(tc, 0u)); + float4 _expr41 = a; + a = (_expr41 + _expr40); + float4 _expr46 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(int2(3, 1))); + float4 _expr47 = a; + a = (_expr47 + _expr46); + float4 _expr52 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3); + float4 _expr53 = a; + a = (_expr53 + _expr52); + float4 _expr58 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(int2(3, 1))); + float4 _expr59 = a; + a = (_expr59 + _expr58); + float4 _expr65 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(int2(3, 1))); + float4 _expr66 = a; + a = (_expr66 + _expr65); + float4 _expr71 = image_2d_array.Sample(sampler_reg, float3(tc, 0)); + float4 _expr72 = a; + a = (_expr72 + _expr71); + float4 _expr77 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(int2(3, 1))); + float4 _expr78 = a; + a = (_expr78 + _expr77); + float4 _expr83 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3); + float4 _expr84 = a; + a = (_expr84 + _expr83); + float4 _expr89 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(int2(3, 1))); + float4 _expr90 = a; + a = (_expr90 + _expr89); + float4 _expr96 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(int2(3, 1))); + float4 _expr97 = a; + a = (_expr97 + _expr96); + float4 _expr102 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u)); + float4 _expr103 = a; + a = (_expr103 + _expr102); + float4 _expr108 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3); + float4 _expr109 = a; + a = (_expr109 + _expr108); + float4 _expr115 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0); + float4 _expr116 = a; + a = (_expr116 + _expr115); + float4 _expr121 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0)); + float4 _expr122 = a; + a = (_expr122 + _expr121); + float4 _expr127 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3); + float4 _expr128 = a; + a = (_expr128 + _expr127); + float4 _expr134 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0); + float4 _expr135 = a; + a = (_expr135 + _expr134); + float4 _expr137 = a; + return _expr137; } float texture_sample_comparison() : SV_Target0 @@ -354,9 +354,9 @@ float4 gather() : SV_Target0 { float2 tc_2 = (0.5).xx; float4 s2d = image_2d.GatherGreen(sampler_reg, tc_2); - float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_2, int2(3, 1)); + float4 s2d_offset = image_2d.GatherAlpha(sampler_reg, tc_2, int2(int2(3, 1))); float4 s2d_depth = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5); - float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2(3, 1)); + float4 s2d_depth_offset = image_2d_depth.GatherCmp(sampler_cmp, tc_2, 0.5, int2(int2(3, 1))); uint4 u = image_2d_u32_.Gather(sampler_reg, tc_2); int4 i = image_2d_i32_.Gather(sampler_reg, tc_2); float4 f = (float4(u) + float4(i)); diff --git a/tests/out/hlsl/operators.hlsl b/tests/out/hlsl/operators.hlsl index 846f567f96..90c6723e2b 100644 --- a/tests/out/hlsl/operators.hlsl +++ b/tests/out/hlsl/operators.hlsl @@ -10,9 +10,9 @@ float4 builtins() float4 s3_ = (bool4(false, false, false, false) ? v_f32_zero : v_f32_one); float4 m1_ = lerp(v_f32_zero, v_f32_one, v_f32_half); float4 m2_ = lerp(v_f32_zero, v_f32_one, 0.1); - float b1_ = asfloat(v_i32_one.x); + float b1_ = asfloat(1); float4 b2_ = asfloat(v_i32_one); - int4 v_i32_zero = int4(v_f32_zero); + int4 v_i32_zero = int4(0, 0, 0, 0); return (((((float4(((s1_).xxxx + v_i32_zero)) + s2_) + m1_) + m2_) + (b1_).xxxx) + b2_); } @@ -46,10 +46,7 @@ float3 bool_cast(float3 x) void logical() { - bool neg0_ = !(true); - bool2 neg1_ = !((true).xx); - bool or_ = (true || false); - bool and_ = (true && false); + bool2 neg1_ = bool2(false, false); bool bitwise_or0_ = (true | false); bool3 bitwise_or1_ = ((true).xxx | (false).xxx); bool bitwise_and0_ = (true & false); @@ -58,74 +55,59 @@ void logical() void arithmetic() { - int2 neg1_1 = -((1).xx); - float2 neg2_ = -((1.0).xx); - int add0_ = (2 + 1); - uint add1_ = (2u + 1u); - float add2_ = (2.0 + 1.0); + int2 neg1_1 = int2(-1, -1); + float2 neg2_ = float2(-1.0, -1.0); int2 add3_ = ((2).xx + (1).xx); uint3 add4_ = ((2u).xxx + (1u).xxx); float4 add5_ = ((2.0).xxxx + (1.0).xxxx); - int sub0_ = (2 - 1); - uint sub1_ = (2u - 1u); - float sub2_ = (2.0 - 1.0); int2 sub3_ = ((2).xx - (1).xx); uint3 sub4_ = ((2u).xxx - (1u).xxx); float4 sub5_ = ((2.0).xxxx - (1.0).xxxx); - int mul0_ = (2 * 1); - uint mul1_ = (2u * 1u); - float mul2_ = (2.0 * 1.0); int2 mul3_ = ((2).xx * (1).xx); uint3 mul4_ = ((2u).xxx * (1u).xxx); float4 mul5_ = ((2.0).xxxx * (1.0).xxxx); - int div0_ = (2 / 1); - uint div1_ = (2u / 1u); - float div2_ = (2.0 / 1.0); int2 div3_ = ((2).xx / (1).xx); uint3 div4_ = ((2u).xxx / (1u).xxx); float4 div5_ = ((2.0).xxxx / (1.0).xxxx); - int rem0_ = (2 % 1); - uint rem1_ = (2u % 1u); - float rem2_ = fmod(2.0, 1.0); int2 rem3_ = ((2).xx % (1).xx); uint3 rem4_ = ((2u).xxx % (1u).xxx); float4 rem5_ = fmod((2.0).xxxx, (1.0).xxxx); { - int2 add0_1 = ((2).xx + (1).xx); - int2 add1_1 = ((2).xx + (1).xx); - uint2 add2_1 = ((2u).xx + (1u).xx); + int2 add0_ = ((2).xx + (1).xx); + int2 add1_ = ((2).xx + (1).xx); + uint2 add2_ = ((2u).xx + (1u).xx); uint2 add3_1 = ((2u).xx + (1u).xx); float2 add4_1 = ((2.0).xx + (1.0).xx); float2 add5_1 = ((2.0).xx + (1.0).xx); - int2 sub0_1 = ((2).xx - (1).xx); - int2 sub1_1 = ((2).xx - (1).xx); - uint2 sub2_1 = ((2u).xx - (1u).xx); + int2 sub0_ = ((2).xx - (1).xx); + int2 sub1_ = ((2).xx - (1).xx); + uint2 sub2_ = ((2u).xx - (1u).xx); uint2 sub3_1 = ((2u).xx - (1u).xx); float2 sub4_1 = ((2.0).xx - (1.0).xx); float2 sub5_1 = ((2.0).xx - (1.0).xx); - int2 mul0_1 = ((2).xx * 1); - int2 mul1_1 = (2 * (1).xx); - uint2 mul2_1 = ((2u).xx * 1u); - uint2 mul3_1 = (2u * (1u).xx); - float2 mul4_1 = ((2.0).xx * 1.0); - float2 mul5_1 = (2.0 * (1.0).xx); - int2 div0_1 = ((2).xx / (1).xx); - int2 div1_1 = ((2).xx / (1).xx); - uint2 div2_1 = ((2u).xx / (1u).xx); + int2 mul0_ = int2(2, 2); + int2 mul1_ = int2(2, 2); + uint2 mul2_ = uint2(2u, 2u); + uint2 mul3_1 = uint2(2u, 2u); + float2 mul4_1 = float2(2.0, 2.0); + float2 mul5_1 = float2(2.0, 2.0); + int2 div0_ = ((2).xx / (1).xx); + int2 div1_ = ((2).xx / (1).xx); + uint2 div2_ = ((2u).xx / (1u).xx); uint2 div3_1 = ((2u).xx / (1u).xx); float2 div4_1 = ((2.0).xx / (1.0).xx); float2 div5_1 = ((2.0).xx / (1.0).xx); - int2 rem0_1 = ((2).xx % (1).xx); - int2 rem1_1 = ((2).xx % (1).xx); - uint2 rem2_1 = ((2u).xx % (1u).xx); + int2 rem0_ = ((2).xx % (1).xx); + int2 rem1_ = ((2).xx % (1).xx); + uint2 rem2_ = ((2u).xx % (1u).xx); uint2 rem3_1 = ((2u).xx % (1u).xx); float2 rem4_1 = fmod((2.0).xx, (1.0).xx); float2 rem5_1 = fmod((2.0).xx, (1.0).xx); } float3x3 add = ((float3x3)0 + (float3x3)0); float3x3 sub = ((float3x3)0 - (float3x3)0); - float3x3 mul_scalar0_ = mul(1.0, (float3x3)0); - float3x3 mul_scalar1_ = mul((float3x3)0, 2.0); + float3x3 mul_scalar0_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)); + float3x3 mul_scalar1_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)); float3 mul_vector0_ = mul((1.0).xxxx, (float4x3)0); float4 mul_vector1_ = mul((float4x3)0, (2.0).xxx); float3x3 mul_ = mul((float3x4)0, (float4x3)0); @@ -133,67 +115,37 @@ void arithmetic() void bit() { - int flip0_ = ~(1); - uint flip1_ = ~(1u); - int2 flip2_ = ~((1).xx); - uint3 flip3_ = ~((1u).xxx); - int or0_ = (2 | 1); - uint or1_ = (2u | 1u); + int2 flip2_ = int2(-2, -2); + uint3 flip3_ = uint3(4294967294u, 4294967294u, 4294967294u); int2 or2_ = ((2).xx | (1).xx); uint3 or3_ = ((2u).xxx | (1u).xxx); - int and0_ = (2 & 1); - uint and1_ = (2u & 1u); int2 and2_ = ((2).xx & (1).xx); uint3 and3_ = ((2u).xxx & (1u).xxx); - int xor0_ = (2 ^ 1); - uint xor1_ = (2u ^ 1u); int2 xor2_ = ((2).xx ^ (1).xx); uint3 xor3_ = ((2u).xxx ^ (1u).xxx); - int shl0_ = (2 << 1u); - uint shl1_ = (2u << 1u); int2 shl2_ = ((2).xx << (1u).xx); uint3 shl3_ = ((2u).xxx << (1u).xxx); - int shr0_ = (2 >> 1u); - uint shr1_ = (2u >> 1u); int2 shr2_ = ((2).xx >> (1u).xx); uint3 shr3_ = ((2u).xxx >> (1u).xxx); } void comparison() { - bool eq0_ = (2 == 1); - bool eq1_ = (2u == 1u); - bool eq2_ = (2.0 == 1.0); bool2 eq3_ = ((2).xx == (1).xx); bool3 eq4_ = ((2u).xxx == (1u).xxx); bool4 eq5_ = ((2.0).xxxx == (1.0).xxxx); - bool neq0_ = (2 != 1); - bool neq1_ = (2u != 1u); - bool neq2_ = (2.0 != 1.0); bool2 neq3_ = ((2).xx != (1).xx); bool3 neq4_ = ((2u).xxx != (1u).xxx); bool4 neq5_ = ((2.0).xxxx != (1.0).xxxx); - bool lt0_ = (2 < 1); - bool lt1_ = (2u < 1u); - bool lt2_ = (2.0 < 1.0); bool2 lt3_ = ((2).xx < (1).xx); bool3 lt4_ = ((2u).xxx < (1u).xxx); bool4 lt5_ = ((2.0).xxxx < (1.0).xxxx); - bool lte0_ = (2 <= 1); - bool lte1_ = (2u <= 1u); - bool lte2_ = (2.0 <= 1.0); bool2 lte3_ = ((2).xx <= (1).xx); bool3 lte4_ = ((2u).xxx <= (1u).xxx); bool4 lte5_ = ((2.0).xxxx <= (1.0).xxxx); - bool gt0_ = (2 > 1); - bool gt1_ = (2u > 1u); - bool gt2_ = (2.0 > 1.0); bool2 gt3_ = ((2).xx > (1).xx); bool3 gt4_ = ((2u).xxx > (1u).xxx); bool4 gt5_ = ((2.0).xxxx > (1.0).xxxx); - bool gte0_ = (2 >= 1); - bool gte1_ = (2u >= 1u); - bool gte2_ = (2.0 >= 1.0); bool2 gte3_ = ((2).xx >= (1).xx); bool3 gte4_ = ((2u).xxx >= (1u).xxx); bool4 gte5_ = ((2.0).xxxx >= (1.0).xxxx); @@ -241,13 +193,7 @@ void assignment() void negation_avoids_prefix_decrement() { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + return; } [numthreads(1, 1, 1)] @@ -255,7 +201,7 @@ void main() { const float4 _e0 = builtins(); const float4 _e1 = splat(); - const float3 _e4 = bool_cast(v_f32_one.xyz); + const float3 _e6 = bool_cast(float3(1.0, 1.0, 1.0)); logical(); arithmetic(); bit(); diff --git a/tests/out/ir/access.ron b/tests/out/ir/access.ron index a200e75a91..e2a7aa9466 100644 --- a/tests/out/ir/access.ron +++ b/tests/out/ir/access.ron @@ -419,21 +419,32 @@ 6, ], ), + Literal(I32(8)), Literal(I32(2)), Literal(I32(10)), Literal(I32(2)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(1)), + Literal(I32(0)), Literal(I32(2)), Literal(I32(2)), + Literal(I32(0)), + Literal(I32(3)), + Literal(I32(2)), Literal(I32(2)), Literal(I32(10)), Literal(I32(5)), Literal(I32(5)), Literal(I32(10)), Literal(I32(5)), + Literal(I32(0)), Literal(I32(2)), Literal(I32(2)), Literal(I32(2)), Literal(I32(2)), + Literal(I32(1)), ], functions: [ ( diff --git a/tests/out/ir/collatz.ron b/tests/out/ir/collatz.ron index fb8ff825e1..615c638506 100644 --- a/tests/out/ir/collatz.ron +++ b/tests/out/ir/collatz.ron @@ -58,7 +58,11 @@ init: None, ), ], - const_expressions: [], + const_expressions: [ + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(1)), + ], functions: [ ( name: Some("collatz_iterations"), diff --git a/tests/out/msl/constructors.msl b/tests/out/msl/constructors.msl index b3d3b9dd43..100d6994e2 100644 --- a/tests/out/msl/constructors.msl +++ b/tests/out/msl/constructors.msl @@ -40,11 +40,8 @@ kernel void main_( metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0)); type_11 cit2_ = type_11 {0, 1, 2, 3}; bool ic0_ = static_cast(bool {}); - int ic1_ = static_cast(int {}); - uint ic2_ = static_cast(uint {}); - float ic3_ = static_cast(float {}); - metal::uint2 ic4_ = static_cast(metal::uint2 {}); - metal::float2x3 ic5_ = metal::float2x3(metal::float2x3 {}); + 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)); metal::uint2 ic6_ = as_type(metal::uint2 {}); metal::float2x3 ic7_ = metal::float2x3(metal::float2x3 {}); } diff --git a/tests/out/msl/image.msl b/tests/out/msl/image.msl index e390c2e0fc..1612314ec8 100644 --- a/tests/out/msl/image.msl +++ b/tests/out/msl/image.msl @@ -119,74 +119,74 @@ fragment texture_sampleOutput texture_sample( metal::float4 a = {}; metal::float2 tc = metal::float2(0.5); metal::float3 tc3_ = metal::float3(0.5); - metal::float4 _e9 = image_1d.sample(sampler_reg, tc.x); - metal::float4 _e10 = a; - a = _e10 + _e9; - metal::float4 _e14 = image_2d.sample(sampler_reg, tc); - metal::float4 _e15 = a; - a = _e15 + _e14; - metal::float4 _e19 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); - metal::float4 _e20 = a; - a = _e20 + _e19; - metal::float4 _e24 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); - metal::float4 _e25 = a; - a = _e25 + _e24; - metal::float4 _e29 = image_2d.sample(sampler_reg, tc, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e30 = a; - a = _e30 + _e29; - metal::float4 _e35 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e36 = a; - a = _e36 + _e35; - metal::float4 _e41 = image_2d_array.sample(sampler_reg, tc, 0u); - metal::float4 _e42 = a; - a = _e42 + _e41; - metal::float4 _e47 = image_2d_array.sample(sampler_reg, tc, 0u, metal::int2(3, 1)); - metal::float4 _e48 = a; - a = _e48 + _e47; - metal::float4 _e53 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); - metal::float4 _e54 = a; - a = _e54 + _e53; - metal::float4 _e59 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e60 = a; - a = _e60 + _e59; - metal::float4 _e66 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e67 = a; - a = _e67 + _e66; - metal::float4 _e72 = image_2d_array.sample(sampler_reg, tc, 0); - metal::float4 _e73 = a; - a = _e73 + _e72; - metal::float4 _e78 = image_2d_array.sample(sampler_reg, tc, 0, metal::int2(3, 1)); - metal::float4 _e79 = a; - a = _e79 + _e78; - metal::float4 _e84 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); - metal::float4 _e85 = a; - a = _e85 + _e84; - metal::float4 _e90 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e91 = a; - a = _e91 + _e90; - metal::float4 _e97 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e98 = a; - a = _e98 + _e97; - metal::float4 _e103 = image_cube_array.sample(sampler_reg, tc3_, 0u); - metal::float4 _e104 = a; - a = _e104 + _e103; - metal::float4 _e109 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::level(2.3)); - metal::float4 _e110 = a; - a = _e110 + _e109; - metal::float4 _e116 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::bias(2.0)); - metal::float4 _e117 = a; - a = _e117 + _e116; - metal::float4 _e122 = image_cube_array.sample(sampler_reg, tc3_, 0); - metal::float4 _e123 = a; - a = _e123 + _e122; - metal::float4 _e128 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::level(2.3)); - metal::float4 _e129 = a; - a = _e129 + _e128; - metal::float4 _e135 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::bias(2.0)); - metal::float4 _e136 = a; - a = _e136 + _e135; - metal::float4 _e138 = a; - return texture_sampleOutput { _e138 }; + metal::float4 _e8 = image_1d.sample(sampler_reg, 0.5); + metal::float4 _e9 = a; + a = _e9 + _e8; + metal::float4 _e13 = image_2d.sample(sampler_reg, tc); + metal::float4 _e14 = a; + a = _e14 + _e13; + metal::float4 _e18 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); + metal::float4 _e19 = a; + a = _e19 + _e18; + metal::float4 _e23 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); + metal::float4 _e24 = a; + a = _e24 + _e23; + metal::float4 _e28 = image_2d.sample(sampler_reg, tc, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e29 = a; + a = _e29 + _e28; + metal::float4 _e34 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e35 = a; + a = _e35 + _e34; + metal::float4 _e40 = image_2d_array.sample(sampler_reg, tc, 0u); + metal::float4 _e41 = a; + a = _e41 + _e40; + metal::float4 _e46 = image_2d_array.sample(sampler_reg, tc, 0u, metal::int2(3, 1)); + metal::float4 _e47 = a; + a = _e47 + _e46; + metal::float4 _e52 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); + metal::float4 _e53 = a; + a = _e53 + _e52; + metal::float4 _e58 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e59 = a; + a = _e59 + _e58; + metal::float4 _e65 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e66 = a; + a = _e66 + _e65; + metal::float4 _e71 = image_2d_array.sample(sampler_reg, tc, 0); + metal::float4 _e72 = a; + a = _e72 + _e71; + metal::float4 _e77 = image_2d_array.sample(sampler_reg, tc, 0, metal::int2(3, 1)); + metal::float4 _e78 = a; + a = _e78 + _e77; + metal::float4 _e83 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); + metal::float4 _e84 = a; + a = _e84 + _e83; + metal::float4 _e89 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e90 = a; + a = _e90 + _e89; + metal::float4 _e96 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e97 = a; + a = _e97 + _e96; + metal::float4 _e102 = image_cube_array.sample(sampler_reg, tc3_, 0u); + metal::float4 _e103 = a; + a = _e103 + _e102; + metal::float4 _e108 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::level(2.3)); + metal::float4 _e109 = a; + a = _e109 + _e108; + metal::float4 _e115 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::bias(2.0)); + metal::float4 _e116 = a; + a = _e116 + _e115; + metal::float4 _e121 = image_cube_array.sample(sampler_reg, tc3_, 0); + metal::float4 _e122 = a; + a = _e122 + _e121; + metal::float4 _e127 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::level(2.3)); + metal::float4 _e128 = a; + a = _e128 + _e127; + metal::float4 _e134 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::bias(2.0)); + metal::float4 _e135 = a; + a = _e135 + _e134; + metal::float4 _e137 = a; + return texture_sampleOutput { _e137 }; } diff --git a/tests/out/msl/operators.msl b/tests/out/msl/operators.msl index a80c71bef9..869f086736 100644 --- a/tests/out/msl/operators.msl +++ b/tests/out/msl/operators.msl @@ -16,9 +16,9 @@ metal::float4 builtins( metal::float4 s3_ = metal::select(v_f32_one, v_f32_zero, metal::bool4(false, false, false, false)); metal::float4 m1_ = metal::mix(v_f32_zero, v_f32_one, v_f32_half); metal::float4 m2_ = metal::mix(v_f32_zero, v_f32_one, 0.1); - float b1_ = as_type(v_i32_one.x); + float b1_ = as_type(1); metal::float4 b2_ = as_type(v_i32_one); - metal::int4 v_i32_zero = static_cast(v_f32_zero); + metal::int4 v_i32_zero = metal::int4(0, 0, 0, 0); return ((((static_cast(metal::int4(s1_) + v_i32_zero) + s2_) + m1_) + m2_) + metal::float4(b1_)) + b2_; } @@ -52,10 +52,7 @@ metal::float3 bool_cast( void logical( ) { - bool neg0_ = !(true); - metal::bool2 neg1_ = !(metal::bool2(true)); - bool or_ = true || false; - bool and_ = true && false; + metal::bool2 neg1_ = metal::bool2(false, false); bool bitwise_or0_ = true | false; metal::bool3 bitwise_or1_ = metal::bool3(true) | metal::bool3(false); bool bitwise_and0_ = true & false; @@ -64,74 +61,59 @@ void logical( void arithmetic( ) { - metal::int2 neg1_1 = -(metal::int2(1)); - metal::float2 neg2_ = -(metal::float2(1.0)); - int add0_ = 2 + 1; - uint add1_ = 2u + 1u; - float add2_ = 2.0 + 1.0; + metal::int2 neg1_1 = metal::int2(-1, -1); + metal::float2 neg2_ = metal::float2(-1.0, -1.0); metal::int2 add3_ = metal::int2(2) + metal::int2(1); metal::uint3 add4_ = metal::uint3(2u) + metal::uint3(1u); metal::float4 add5_ = metal::float4(2.0) + metal::float4(1.0); - int sub0_ = 2 - 1; - uint sub1_ = 2u - 1u; - float sub2_ = 2.0 - 1.0; metal::int2 sub3_ = metal::int2(2) - metal::int2(1); metal::uint3 sub4_ = metal::uint3(2u) - metal::uint3(1u); metal::float4 sub5_ = metal::float4(2.0) - metal::float4(1.0); - int mul0_ = 2 * 1; - uint mul1_ = 2u * 1u; - float mul2_ = 2.0 * 1.0; metal::int2 mul3_ = metal::int2(2) * metal::int2(1); metal::uint3 mul4_ = metal::uint3(2u) * metal::uint3(1u); metal::float4 mul5_ = metal::float4(2.0) * metal::float4(1.0); - int div0_ = 2 / 1; - uint div1_ = 2u / 1u; - float div2_ = 2.0 / 1.0; metal::int2 div3_ = metal::int2(2) / metal::int2(1); metal::uint3 div4_ = metal::uint3(2u) / metal::uint3(1u); metal::float4 div5_ = metal::float4(2.0) / metal::float4(1.0); - int rem0_ = 2 % 1; - uint rem1_ = 2u % 1u; - float rem2_ = metal::fmod(2.0, 1.0); metal::int2 rem3_ = metal::int2(2) % metal::int2(1); metal::uint3 rem4_ = metal::uint3(2u) % metal::uint3(1u); metal::float4 rem5_ = metal::fmod(metal::float4(2.0), metal::float4(1.0)); { - metal::int2 add0_1 = metal::int2(2) + metal::int2(1); - metal::int2 add1_1 = metal::int2(2) + metal::int2(1); - metal::uint2 add2_1 = metal::uint2(2u) + metal::uint2(1u); + metal::int2 add0_ = metal::int2(2) + metal::int2(1); + metal::int2 add1_ = metal::int2(2) + metal::int2(1); + metal::uint2 add2_ = metal::uint2(2u) + metal::uint2(1u); metal::uint2 add3_1 = metal::uint2(2u) + metal::uint2(1u); metal::float2 add4_1 = metal::float2(2.0) + metal::float2(1.0); metal::float2 add5_1 = metal::float2(2.0) + metal::float2(1.0); - metal::int2 sub0_1 = metal::int2(2) - metal::int2(1); - metal::int2 sub1_1 = metal::int2(2) - metal::int2(1); - metal::uint2 sub2_1 = metal::uint2(2u) - metal::uint2(1u); + metal::int2 sub0_ = metal::int2(2) - metal::int2(1); + metal::int2 sub1_ = metal::int2(2) - metal::int2(1); + metal::uint2 sub2_ = metal::uint2(2u) - metal::uint2(1u); metal::uint2 sub3_1 = metal::uint2(2u) - metal::uint2(1u); metal::float2 sub4_1 = metal::float2(2.0) - metal::float2(1.0); metal::float2 sub5_1 = metal::float2(2.0) - metal::float2(1.0); - metal::int2 mul0_1 = metal::int2(2) * 1; - metal::int2 mul1_1 = 2 * metal::int2(1); - metal::uint2 mul2_1 = metal::uint2(2u) * 1u; - metal::uint2 mul3_1 = 2u * metal::uint2(1u); - metal::float2 mul4_1 = metal::float2(2.0) * 1.0; - metal::float2 mul5_1 = 2.0 * metal::float2(1.0); - metal::int2 div0_1 = metal::int2(2) / metal::int2(1); - metal::int2 div1_1 = metal::int2(2) / metal::int2(1); - metal::uint2 div2_1 = metal::uint2(2u) / metal::uint2(1u); + metal::int2 mul0_ = metal::int2(2, 2); + metal::int2 mul1_ = metal::int2(2, 2); + metal::uint2 mul2_ = metal::uint2(2u, 2u); + metal::uint2 mul3_1 = metal::uint2(2u, 2u); + metal::float2 mul4_1 = metal::float2(2.0, 2.0); + metal::float2 mul5_1 = metal::float2(2.0, 2.0); + metal::int2 div0_ = metal::int2(2) / metal::int2(1); + metal::int2 div1_ = metal::int2(2) / metal::int2(1); + metal::uint2 div2_ = metal::uint2(2u) / metal::uint2(1u); metal::uint2 div3_1 = metal::uint2(2u) / metal::uint2(1u); metal::float2 div4_1 = metal::float2(2.0) / metal::float2(1.0); metal::float2 div5_1 = metal::float2(2.0) / metal::float2(1.0); - metal::int2 rem0_1 = metal::int2(2) % metal::int2(1); - metal::int2 rem1_1 = metal::int2(2) % metal::int2(1); - metal::uint2 rem2_1 = metal::uint2(2u) % metal::uint2(1u); + metal::int2 rem0_ = metal::int2(2) % metal::int2(1); + metal::int2 rem1_ = metal::int2(2) % metal::int2(1); + metal::uint2 rem2_ = metal::uint2(2u) % metal::uint2(1u); metal::uint2 rem3_1 = metal::uint2(2u) % metal::uint2(1u); metal::float2 rem4_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0)); metal::float2 rem5_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0)); } metal::float3x3 add = metal::float3x3 {} + metal::float3x3 {}; metal::float3x3 sub = metal::float3x3 {} - metal::float3x3 {}; - metal::float3x3 mul_scalar0_ = metal::float3x3 {} * 1.0; - metal::float3x3 mul_scalar1_ = 2.0 * metal::float3x3 {}; + metal::float3x3 mul_scalar0_ = metal::float3x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); + metal::float3x3 mul_scalar1_ = metal::float3x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); metal::float3 mul_vector0_ = metal::float4x3 {} * metal::float4(1.0); metal::float4 mul_vector1_ = metal::float3(2.0) * metal::float4x3 {}; metal::float3x3 mul = metal::float4x3 {} * metal::float3x4 {}; @@ -139,67 +121,37 @@ void arithmetic( void bit( ) { - int flip0_ = ~(1); - uint flip1_ = ~(1u); - metal::int2 flip2_ = ~(metal::int2(1)); - metal::uint3 flip3_ = ~(metal::uint3(1u)); - int or0_ = 2 | 1; - uint or1_ = 2u | 1u; + metal::int2 flip2_ = metal::int2(-2, -2); + metal::uint3 flip3_ = metal::uint3(4294967294u, 4294967294u, 4294967294u); metal::int2 or2_ = metal::int2(2) | metal::int2(1); metal::uint3 or3_ = metal::uint3(2u) | metal::uint3(1u); - int and0_ = 2 & 1; - uint and1_ = 2u & 1u; metal::int2 and2_ = metal::int2(2) & metal::int2(1); metal::uint3 and3_ = metal::uint3(2u) & metal::uint3(1u); - int xor0_ = 2 ^ 1; - uint xor1_ = 2u ^ 1u; metal::int2 xor2_ = metal::int2(2) ^ metal::int2(1); metal::uint3 xor3_ = metal::uint3(2u) ^ metal::uint3(1u); - int shl0_ = 2 << 1u; - uint shl1_ = 2u << 1u; metal::int2 shl2_ = metal::int2(2) << metal::uint2(1u); metal::uint3 shl3_ = metal::uint3(2u) << metal::uint3(1u); - int shr0_ = 2 >> 1u; - uint shr1_ = 2u >> 1u; metal::int2 shr2_ = metal::int2(2) >> metal::uint2(1u); metal::uint3 shr3_ = metal::uint3(2u) >> metal::uint3(1u); } void comparison( ) { - bool eq0_ = 2 == 1; - bool eq1_ = 2u == 1u; - bool eq2_ = 2.0 == 1.0; metal::bool2 eq3_ = metal::int2(2) == metal::int2(1); metal::bool3 eq4_ = metal::uint3(2u) == metal::uint3(1u); metal::bool4 eq5_ = metal::float4(2.0) == metal::float4(1.0); - bool neq0_ = 2 != 1; - bool neq1_ = 2u != 1u; - bool neq2_ = 2.0 != 1.0; metal::bool2 neq3_ = metal::int2(2) != metal::int2(1); metal::bool3 neq4_ = metal::uint3(2u) != metal::uint3(1u); metal::bool4 neq5_ = metal::float4(2.0) != metal::float4(1.0); - bool lt0_ = 2 < 1; - bool lt1_ = 2u < 1u; - bool lt2_ = 2.0 < 1.0; metal::bool2 lt3_ = metal::int2(2) < metal::int2(1); metal::bool3 lt4_ = metal::uint3(2u) < metal::uint3(1u); metal::bool4 lt5_ = metal::float4(2.0) < metal::float4(1.0); - bool lte0_ = 2 <= 1; - bool lte1_ = 2u <= 1u; - bool lte2_ = 2.0 <= 1.0; metal::bool2 lte3_ = metal::int2(2) <= metal::int2(1); metal::bool3 lte4_ = metal::uint3(2u) <= metal::uint3(1u); metal::bool4 lte5_ = metal::float4(2.0) <= metal::float4(1.0); - bool gt0_ = 2 > 1; - bool gt1_ = 2u > 1u; - bool gt2_ = 2.0 > 1.0; metal::bool2 gt3_ = metal::int2(2) > metal::int2(1); metal::bool3 gt4_ = metal::uint3(2u) > metal::uint3(1u); metal::bool4 gt5_ = metal::float4(2.0) > metal::float4(1.0); - bool gte0_ = 2 >= 1; - bool gte1_ = 2u >= 1u; - bool gte2_ = 2.0 >= 1.0; metal::bool2 gte3_ = metal::int2(2) >= metal::int2(1); metal::bool3 gte4_ = metal::uint3(2u) >= metal::uint3(1u); metal::bool4 gte5_ = metal::float4(2.0) >= metal::float4(1.0); @@ -246,20 +198,14 @@ void assignment( void negation_avoids_prefix_decrement( ) { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + return; } kernel void main_( ) { metal::float4 _e0 = builtins(); metal::float4 _e1 = splat(); - metal::float3 _e4 = bool_cast(v_f32_one.xyz); + metal::float3 _e6 = bool_cast(metal::float3(1.0, 1.0, 1.0)); logical(); arithmetic(); bit(); diff --git a/tests/out/spv/constructors.spvasm b/tests/out/spv/constructors.spvasm index ec54d6d1bb..4670ab39d3 100644 --- a/tests/out/spv/constructors.spvasm +++ b/tests/out/spv/constructors.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 74 +; Bound: 73 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -78,7 +78,10 @@ OpStore %43 %52 %63 = OpCompositeConstruct %9 %21 %21 %64 = OpCompositeConstruct %8 %62 %63 %65 = OpCompositeConstruct %17 %38 %39 %40 %41 -%71 = OpCopyObject %20 %49 -%73 = OpCopyObject %20 %49 +%67 = OpCompositeConstruct %14 %48 %48 +%68 = OpCompositeConstruct %7 %21 %21 %21 +%69 = OpCompositeConstruct %7 %21 %21 %21 +%70 = OpCompositeConstruct %20 %68 %69 +%72 = OpCopyObject %20 %49 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/debug-symbol-terrain.spvasm b/tests/out/spv/debug-symbol-terrain.spvasm index 8c27f3ab9e..044f1f169a 100644 --- a/tests/out/spv/debug-symbol-terrain.spvasm +++ b/tests/out/spv/debug-symbol-terrain.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 647 +; Bound: 641 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %348 "gen_terrain_compute" %345 -OpEntryPoint Vertex %418 "gen_terrain_vertex" %409 %412 %414 %416 -OpEntryPoint Fragment %470 "gen_terrain_fragment" %460 %462 %465 %468 %469 -OpEntryPoint Vertex %561 "vs_main" %552 %555 %557 %558 %560 -OpEntryPoint Fragment %587 "fs_main" %580 %582 %584 %586 -OpExecutionMode %348 LocalSize 64 1 1 -OpExecutionMode %470 OriginUpperLeft -OpExecutionMode %587 OriginUpperLeft +OpEntryPoint GLCompute %344 "gen_terrain_compute" %341 +OpEntryPoint Vertex %414 "gen_terrain_vertex" %405 %408 %410 %412 +OpEntryPoint Fragment %464 "gen_terrain_fragment" %454 %456 %459 %462 %463 +OpEntryPoint Vertex %555 "vs_main" %546 %549 %551 %552 %554 +OpEntryPoint Fragment %581 "fs_main" %574 %576 %578 %580 +OpExecutionMode %344 LocalSize 64 1 1 +OpExecutionMode %464 OriginUpperLeft +OpExecutionMode %581 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl // ============================ @@ -370,44 +370,44 @@ OpName %208 "a" OpName %209 "i" OpName %213 "p" OpName %214 "fbm" -OpName %258 "p" -OpName %259 "min_max_height" -OpName %260 "terrain_point" -OpName %271 "p" -OpName %272 "min_max_height" -OpName %273 "terrain_vertex" -OpName %303 "vert_index" -OpName %304 "chunk_size" -OpName %305 "chunk_corner" -OpName %306 "index_to_p" -OpName %322 "p" -OpName %323 "color23" -OpName %345 "gid" -OpName %348 "gen_terrain_compute" -OpName %409 "vindex" -OpName %412 "index" -OpName %414 "position" -OpName %416 "uv" -OpName %418 "gen_terrain_vertex" -OpName %456 "vert_component" -OpName %457 "index" -OpName %460 "index" -OpName %462 "position" -OpName %465 "uv" -OpName %468 "vert_component" -OpName %469 "index" -OpName %470 "gen_terrain_fragment" -OpName %552 "position" -OpName %555 "normal" -OpName %557 "clip_position" -OpName %558 "normal" -OpName %560 "world_pos" -OpName %561 "vs_main" -OpName %577 "color" -OpName %580 "clip_position" -OpName %582 "normal" -OpName %584 "world_pos" -OpName %587 "fs_main" +OpName %254 "p" +OpName %255 "min_max_height" +OpName %256 "terrain_point" +OpName %267 "p" +OpName %268 "min_max_height" +OpName %269 "terrain_vertex" +OpName %299 "vert_index" +OpName %300 "chunk_size" +OpName %301 "chunk_corner" +OpName %302 "index_to_p" +OpName %318 "p" +OpName %319 "color23" +OpName %341 "gid" +OpName %344 "gen_terrain_compute" +OpName %405 "vindex" +OpName %408 "index" +OpName %410 "position" +OpName %412 "uv" +OpName %414 "gen_terrain_vertex" +OpName %450 "vert_component" +OpName %451 "index" +OpName %454 "index" +OpName %456 "position" +OpName %459 "uv" +OpName %462 "vert_component" +OpName %463 "index" +OpName %464 "gen_terrain_fragment" +OpName %546 "position" +OpName %549 "normal" +OpName %551 "clip_position" +OpName %552 "normal" +OpName %554 "world_pos" +OpName %555 "vs_main" +OpName %571 "color" +OpName %574 "clip_position" +OpName %576 "normal" +OpName %578 "world_pos" +OpName %581 "fs_main" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -466,27 +466,27 @@ OpDecorate %49 DescriptorSet 2 OpDecorate %49 Binding 2 OpDecorate %50 DescriptorSet 2 OpDecorate %50 Binding 3 -OpDecorate %345 BuiltIn GlobalInvocationId -OpDecorate %409 BuiltIn VertexIndex -OpDecorate %412 Location 0 -OpDecorate %412 Flat -OpDecorate %414 BuiltIn Position -OpDecorate %416 Location 1 -OpDecorate %460 Location 0 -OpDecorate %460 Flat -OpDecorate %462 BuiltIn FragCoord -OpDecorate %465 Location 1 -OpDecorate %468 Location 0 -OpDecorate %469 Location 1 +OpDecorate %341 BuiltIn GlobalInvocationId +OpDecorate %405 BuiltIn VertexIndex +OpDecorate %408 Location 0 +OpDecorate %408 Flat +OpDecorate %410 BuiltIn Position +OpDecorate %412 Location 1 +OpDecorate %454 Location 0 +OpDecorate %454 Flat +OpDecorate %456 BuiltIn FragCoord +OpDecorate %459 Location 1 +OpDecorate %462 Location 0 +OpDecorate %463 Location 1 +OpDecorate %546 Location 0 +OpDecorate %549 Location 1 +OpDecorate %551 BuiltIn Position OpDecorate %552 Location 0 -OpDecorate %555 Location 1 -OpDecorate %557 BuiltIn Position -OpDecorate %558 Location 0 -OpDecorate %560 Location 1 -OpDecorate %580 BuiltIn FragCoord -OpDecorate %582 Location 0 -OpDecorate %584 Location 1 -OpDecorate %586 Location 0 +OpDecorate %554 Location 1 +OpDecorate %574 BuiltIn FragCoord +OpDecorate %576 Location 0 +OpDecorate %578 Location 1 +OpDecorate %580 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 3 @@ -568,69 +568,69 @@ OpDecorate %586 Location 0 %215 = OpConstant %8 5 %216 = OpConstant %5 0.01 %217 = OpConstant %5 100.0 -%261 = OpTypeFunction %4 %6 %6 -%274 = OpTypeFunction %14 %6 %6 -%275 = OpConstant %5 0.1 -%276 = OpConstant %5 -0.1 -%307 = OpTypeFunction %6 %8 %10 %11 -%324 = OpTypeFunction %4 %6 -%325 = OpConstant %5 23.0 -%326 = OpConstant %5 32.0 -%327 = OpConstant %5 -43.0 -%328 = OpConstant %5 3.0 -%346 = OpTypePointer Input %19 -%345 = OpVariable %346 Input -%349 = OpTypeFunction %2 -%350 = OpTypePointer Uniform %13 -%352 = OpConstant %8 6 -%353 = OpConstant %8 2 -%354 = OpConstant %8 3 -%355 = OpConstant %8 4 -%358 = OpTypePointer Uniform %10 -%361 = OpTypePointer Uniform %11 -%365 = OpTypePointer StorageBuffer %15 -%366 = OpTypePointer StorageBuffer %14 -%367 = OpTypePointer Uniform %6 -%374 = OpTypePointer Uniform %8 -%395 = OpTypePointer StorageBuffer %17 -%396 = OpTypePointer StorageBuffer %8 -%410 = OpTypePointer Input %8 -%409 = OpVariable %410 Input -%413 = OpTypePointer Output %8 +%257 = OpTypeFunction %4 %6 %6 +%270 = OpTypeFunction %14 %6 %6 +%271 = OpConstant %5 0.1 +%272 = OpConstant %5 -0.1 +%303 = OpTypeFunction %6 %8 %10 %11 +%320 = OpTypeFunction %4 %6 +%321 = OpConstant %5 23.0 +%322 = OpConstant %5 32.0 +%323 = OpConstant %5 -43.0 +%324 = OpConstant %5 3.0 +%342 = OpTypePointer Input %19 +%341 = OpVariable %342 Input +%345 = OpTypeFunction %2 +%346 = OpTypePointer Uniform %13 +%348 = OpConstant %8 6 +%349 = OpConstant %8 2 +%350 = OpConstant %8 3 +%351 = OpConstant %8 4 +%354 = OpTypePointer Uniform %10 +%357 = OpTypePointer Uniform %11 +%361 = OpTypePointer StorageBuffer %15 +%362 = OpTypePointer StorageBuffer %14 +%363 = OpTypePointer Uniform %6 +%370 = OpTypePointer Uniform %8 +%391 = OpTypePointer StorageBuffer %17 +%392 = OpTypePointer StorageBuffer %8 +%406 = OpTypePointer Input %8 +%405 = OpVariable %406 Input +%409 = OpTypePointer Output %8 +%408 = OpVariable %409 Output +%411 = OpTypePointer Output %7 +%410 = OpVariable %411 Output +%413 = OpTypePointer Output %6 %412 = OpVariable %413 Output -%415 = OpTypePointer Output %7 -%414 = OpVariable %415 Output -%417 = OpTypePointer Output %6 -%416 = OpVariable %417 Output -%419 = OpTypePointer Uniform %20 -%421 = OpConstant %5 -1.0 -%437 = OpTypePointer Uniform %8 -%460 = OpVariable %410 Input -%463 = OpTypePointer Input %7 -%462 = OpVariable %463 Input -%466 = OpTypePointer Input %6 -%465 = OpVariable %466 Input -%468 = OpVariable %413 Output -%469 = OpVariable %413 Output -%472 = OpConstant %5 6.0 -%553 = OpTypePointer Input %4 -%552 = OpVariable %553 Input -%555 = OpVariable %553 Input -%557 = OpVariable %415 Output -%559 = OpTypePointer Output %4 -%558 = OpVariable %559 Output -%560 = OpVariable %559 Output -%562 = OpTypePointer Uniform %24 -%565 = OpTypePointer Uniform %23 -%580 = OpVariable %463 Input -%582 = OpVariable %553 Input -%584 = OpVariable %553 Input -%586 = OpVariable %415 Output -%589 = OpTypePointer Uniform %25 -%591 = OpConstant %5 0.7 -%592 = OpConstant %5 0.2 -%611 = OpTypePointer Uniform %4 -%620 = OpTypePointer Uniform %7 +%415 = OpTypePointer Uniform %20 +%417 = OpConstant %5 -1.0 +%432 = OpTypePointer Uniform %8 +%454 = OpVariable %406 Input +%457 = OpTypePointer Input %7 +%456 = OpVariable %457 Input +%460 = OpTypePointer Input %6 +%459 = OpVariable %460 Input +%462 = OpVariable %409 Output +%463 = OpVariable %409 Output +%466 = OpConstant %5 6.0 +%547 = OpTypePointer Input %4 +%546 = OpVariable %547 Input +%549 = OpVariable %547 Input +%551 = OpVariable %411 Output +%553 = OpTypePointer Output %4 +%552 = OpVariable %553 Output +%554 = OpVariable %553 Output +%556 = OpTypePointer Uniform %24 +%559 = OpTypePointer Uniform %23 +%574 = OpVariable %457 Input +%576 = OpVariable %547 Input +%578 = OpVariable %547 Input +%580 = OpVariable %411 Output +%583 = OpTypePointer Uniform %25 +%585 = OpConstant %5 0.7 +%586 = OpConstant %5 0.2 +%605 = OpTypePointer Uniform %4 +%614 = OpTypePointer Uniform %7 %53 = OpFunction %4 None %54 %52 = OpFunctionParameter %4 %51 = OpLabel @@ -659,7 +659,7 @@ OpBranch %89 OpLine %3 13 13 %90 = OpCompositeConstruct %7 %79 %80 %81 %82 OpLine %3 14 24 -%91 = OpVectorShuffle %6 %90 %90 1 1 +%91 = OpCompositeConstruct %6 %80 %80 %92 = OpDot %5 %76 %91 %93 = OpCompositeConstruct %6 %92 %92 %94 = OpFAdd %6 %76 %93 @@ -670,7 +670,7 @@ OpLine %3 15 14 %96 = OpLoad %6 %65 %97 = OpFSub %6 %76 %96 %98 = OpLoad %6 %65 -%99 = OpVectorShuffle %6 %90 %90 0 0 +%99 = OpCompositeConstruct %6 %79 %79 %100 = OpDot %5 %98 %99 %101 = OpCompositeConstruct %6 %100 %100 %102 = OpFAdd %6 %97 %101 @@ -687,7 +687,7 @@ OpLine %3 17 5 OpStore %68 %109 OpLine %3 18 26 %112 = OpVectorShuffle %7 %102 %102 0 1 0 1 -%113 = OpVectorShuffle %7 %90 %90 0 0 2 2 +%113 = OpCompositeConstruct %7 %79 %79 %81 %81 %114 = OpFAdd %7 %112 %113 %115 = OpLoad %6 %68 OpLine %3 18 26 @@ -760,7 +760,7 @@ OpLine %3 23 9 OpLine %3 23 5 OpStore %72 %162 OpLine %3 24 13 -%163 = OpVectorShuffle %4 %90 %90 3 3 3 +%163 = OpCompositeConstruct %4 %82 %82 %82 %164 = OpFMul %4 %140 %163 %165 = OpExtInst %4 %1 Fract %164 %166 = OpVectorTimesScalar %4 %165 %85 @@ -839,626 +839,619 @@ OpLine %3 40 14 %222 = OpExtInst %5 %1 Sin %84 %223 = OpCompositeConstruct %6 %221 %222 OpLine %3 41 15 -%224 = OpCompositeExtract %5 %223 0 -%225 = OpCompositeExtract %5 %223 1 -%226 = OpCompositeExtract %5 %223 1 -%227 = OpFNegate %5 %226 -%228 = OpCompositeExtract %5 %223 0 -%229 = OpCompositeConstruct %6 %224 %225 -%230 = OpCompositeConstruct %6 %227 %228 -%231 = OpCompositeConstruct %9 %229 %230 +%224 = OpFNegate %5 %222 +%225 = OpCompositeConstruct %6 %221 %222 +%226 = OpCompositeConstruct %6 %224 %221 +%227 = OpCompositeConstruct %9 %225 %226 OpLine %3 43 10 OpStore %209 %131 -OpBranch %232 -%232 = OpLabel +OpBranch %228 +%228 = OpLabel OpLine %3 43 5 -OpLoopMerge %233 %235 None -OpBranch %234 -%234 = OpLabel +OpLoopMerge %229 %231 None +OpBranch %230 +%230 = OpLabel OpLine %3 43 22 -%236 = OpLoad %8 %209 -%237 = OpULessThan %107 %236 %215 +%232 = OpLoad %8 %209 +%233 = OpULessThan %107 %232 %215 OpLine %3 43 21 -OpSelectionMerge %238 None -OpBranchConditional %237 %238 %239 -%239 = OpLabel -OpBranch %233 -%238 = OpLabel -OpBranch %240 -%240 = OpLabel +OpSelectionMerge %234 None +OpBranchConditional %233 %234 %235 +%235 = OpLabel +OpBranch %229 +%234 = OpLabel +OpBranch %236 +%236 = OpLabel OpLine %3 1 1 -%242 = OpLoad %5 %205 -%243 = OpLoad %5 %208 -%244 = OpLoad %6 %204 +%238 = OpLoad %5 %205 +%239 = OpLoad %5 %208 +%240 = OpLoad %6 %204 OpLine %3 44 21 -%245 = OpFunctionCall %5 %77 %244 +%241 = OpFunctionCall %5 %77 %240 OpLine %3 44 13 -%246 = OpFMul %5 %243 %245 -%247 = OpFAdd %5 %242 %246 +%242 = OpFMul %5 %239 %241 +%243 = OpFAdd %5 %238 %242 OpLine %3 44 9 -OpStore %205 %247 +OpStore %205 %243 OpLine %3 45 13 -%248 = OpLoad %6 %204 -%249 = OpMatrixTimesVector %6 %231 %248 +%244 = OpLoad %6 %204 +%245 = OpMatrixTimesVector %6 %227 %244 OpLine %3 45 13 -%250 = OpVectorTimesScalar %6 %249 %85 -%251 = OpFAdd %6 %250 %220 +%246 = OpVectorTimesScalar %6 %245 %85 +%247 = OpFAdd %6 %246 %220 OpLine %3 45 9 -OpStore %204 %251 +OpStore %204 %247 OpLine %3 1 1 -%252 = OpLoad %5 %208 +%248 = OpLoad %5 %208 OpLine %3 46 13 -%253 = OpFMul %5 %252 %84 +%249 = OpFMul %5 %248 %84 OpLine %3 46 9 -OpStore %208 %253 -OpBranch %241 -%241 = OpLabel -OpBranch %235 -%235 = OpLabel +OpStore %208 %249 +OpBranch %237 +%237 = OpLabel +OpBranch %231 +%231 = OpLabel OpLine %3 1 1 -%254 = OpLoad %8 %209 +%250 = OpLoad %8 %209 OpLine %3 43 43 -%255 = OpIAdd %8 %254 %122 +%251 = OpIAdd %8 %250 %122 OpLine %3 43 39 -OpStore %209 %255 -OpBranch %232 -%233 = OpLabel +OpStore %209 %251 +OpBranch %228 +%229 = OpLabel OpLine %3 1 1 -%256 = OpLoad %5 %205 -OpReturnValue %256 +%252 = OpLoad %5 %205 +OpReturnValue %252 OpFunctionEnd -%260 = OpFunction %4 None %261 -%258 = OpFunctionParameter %6 -%259 = OpFunctionParameter %6 -%257 = OpLabel -OpBranch %262 -%262 = OpLabel +%256 = OpFunction %4 None %257 +%254 = OpFunctionParameter %6 +%255 = OpFunctionParameter %6 +%253 = OpLabel +OpBranch %258 +%258 = OpLabel OpLine %3 77 9 -%263 = OpCompositeExtract %5 %258 0 -%264 = OpCompositeExtract %5 %259 0 -%265 = OpCompositeExtract %5 %259 1 +%259 = OpCompositeExtract %5 %254 0 +%260 = OpCompositeExtract %5 %255 0 +%261 = OpCompositeExtract %5 %255 1 OpLine %3 78 49 -%266 = OpFunctionCall %5 %214 %258 +%262 = OpFunctionCall %5 %214 %254 OpLine %3 76 12 -%267 = OpExtInst %5 %1 FMix %264 %265 %266 -%268 = OpCompositeExtract %5 %258 1 -%269 = OpCompositeConstruct %4 %263 %267 %268 -OpReturnValue %269 +%263 = OpExtInst %5 %1 FMix %260 %261 %262 +%264 = OpCompositeExtract %5 %254 1 +%265 = OpCompositeConstruct %4 %259 %263 %264 +OpReturnValue %265 OpFunctionEnd -%273 = OpFunction %14 None %274 -%271 = OpFunctionParameter %6 -%272 = OpFunctionParameter %6 -%270 = OpLabel -OpBranch %277 -%277 = OpLabel +%269 = OpFunction %14 None %270 +%267 = OpFunctionParameter %6 +%268 = OpFunctionParameter %6 +%266 = OpLabel +OpBranch %273 +%273 = OpLabel OpLine %3 84 13 -%278 = OpFunctionCall %4 %260 %271 %272 +%274 = OpFunctionCall %4 %256 %267 %268 OpLine %3 86 29 -%279 = OpCompositeConstruct %6 %275 %83 -%280 = OpFAdd %6 %271 %279 +%275 = OpCompositeConstruct %6 %271 %83 +%276 = OpFAdd %6 %267 %275 OpLine %3 86 15 -%281 = OpFunctionCall %4 %260 %280 %272 +%277 = OpFunctionCall %4 %256 %276 %268 OpLine %3 86 15 -%282 = OpFSub %4 %281 %278 +%278 = OpFSub %4 %277 %274 OpLine %3 87 29 -%283 = OpCompositeConstruct %6 %83 %275 -%284 = OpFAdd %6 %271 %283 +%279 = OpCompositeConstruct %6 %83 %271 +%280 = OpFAdd %6 %267 %279 OpLine %3 87 15 -%285 = OpFunctionCall %4 %260 %284 %272 +%281 = OpFunctionCall %4 %256 %280 %268 OpLine %3 87 15 -%286 = OpFSub %4 %285 %278 +%282 = OpFSub %4 %281 %274 OpLine %3 88 29 -%287 = OpCompositeConstruct %6 %276 %83 -%288 = OpFAdd %6 %271 %287 +%283 = OpCompositeConstruct %6 %272 %83 +%284 = OpFAdd %6 %267 %283 OpLine %3 88 15 -%289 = OpFunctionCall %4 %260 %288 %272 +%285 = OpFunctionCall %4 %256 %284 %268 OpLine %3 88 15 -%290 = OpFSub %4 %289 %278 +%286 = OpFSub %4 %285 %274 OpLine %3 89 29 -%291 = OpCompositeConstruct %6 %83 %276 -%292 = OpFAdd %6 %271 %291 +%287 = OpCompositeConstruct %6 %83 %272 +%288 = OpFAdd %6 %267 %287 OpLine %3 89 15 -%293 = OpFunctionCall %4 %260 %292 %272 +%289 = OpFunctionCall %4 %256 %288 %268 OpLine %3 89 15 -%294 = OpFSub %4 %293 %278 +%290 = OpFSub %4 %289 %274 OpLine %3 91 14 -%295 = OpExtInst %4 %1 Cross %286 %282 -%296 = OpExtInst %4 %1 Normalize %295 +%291 = OpExtInst %4 %1 Cross %282 %278 +%292 = OpExtInst %4 %1 Normalize %291 OpLine %3 92 14 -%297 = OpExtInst %4 %1 Cross %294 %290 -%298 = OpExtInst %4 %1 Normalize %297 +%293 = OpExtInst %4 %1 Cross %290 %286 +%294 = OpExtInst %4 %1 Normalize %293 OpLine %3 94 14 -%299 = OpFAdd %4 %296 %298 +%295 = OpFAdd %4 %292 %294 OpLine %3 94 13 -%300 = OpVectorTimesScalar %4 %299 %84 +%296 = OpVectorTimesScalar %4 %295 %84 OpLine %3 96 12 -%301 = OpCompositeConstruct %14 %278 %300 -OpReturnValue %301 +%297 = OpCompositeConstruct %14 %274 %296 +OpReturnValue %297 OpFunctionEnd -%306 = OpFunction %6 None %307 -%303 = OpFunctionParameter %8 -%304 = OpFunctionParameter %10 -%305 = OpFunctionParameter %11 -%302 = OpLabel -OpBranch %308 -%308 = OpLabel +%302 = OpFunction %6 None %303 +%299 = OpFunctionParameter %8 +%300 = OpFunctionParameter %10 +%301 = OpFunctionParameter %11 +%298 = OpLabel +OpBranch %304 +%304 = OpLabel OpLine %3 101 9 -%309 = OpConvertUToF %5 %303 -%310 = OpCompositeExtract %8 %304 0 +%305 = OpConvertUToF %5 %299 +%306 = OpCompositeExtract %8 %300 0 OpLine %3 101 9 -%311 = OpIAdd %8 %310 %122 -%312 = OpConvertUToF %5 %311 -%313 = OpFRem %5 %309 %312 -%314 = OpCompositeExtract %8 %304 0 +%307 = OpIAdd %8 %306 %122 +%308 = OpConvertUToF %5 %307 +%309 = OpFRem %5 %305 %308 +%310 = OpCompositeExtract %8 %300 0 OpLine %3 100 12 -%315 = OpIAdd %8 %314 %122 -%316 = OpUDiv %8 %303 %315 -%317 = OpConvertUToF %5 %316 -%318 = OpCompositeConstruct %6 %313 %317 -%319 = OpConvertSToF %6 %305 -%320 = OpFAdd %6 %318 %319 -OpReturnValue %320 +%311 = OpIAdd %8 %310 %122 +%312 = OpUDiv %8 %299 %311 +%313 = OpConvertUToF %5 %312 +%314 = OpCompositeConstruct %6 %309 %313 +%315 = OpConvertSToF %6 %301 +%316 = OpFAdd %6 %314 %315 +OpReturnValue %316 OpFunctionEnd -%323 = OpFunction %4 None %324 -%322 = OpFunctionParameter %6 -%321 = OpLabel -OpBranch %329 -%329 = OpLabel +%319 = OpFunction %4 None %320 +%318 = OpFunctionParameter %6 +%317 = OpLabel +OpBranch %325 +%325 = OpLabel OpLine %3 270 9 -%330 = OpFunctionCall %5 %77 %322 +%326 = OpFunctionCall %5 %77 %318 OpLine %3 270 9 -%331 = OpFMul %5 %330 %84 +%327 = OpFMul %5 %326 %84 OpLine %3 270 9 -%332 = OpFAdd %5 %331 %84 +%328 = OpFAdd %5 %327 %84 OpLine %3 271 17 -%333 = OpCompositeConstruct %6 %325 %326 -%334 = OpFAdd %6 %322 %333 +%329 = OpCompositeConstruct %6 %321 %322 +%330 = OpFAdd %6 %318 %329 OpLine %3 271 9 -%335 = OpFunctionCall %5 %77 %334 +%331 = OpFunctionCall %5 %77 %330 OpLine %3 271 9 -%336 = OpFMul %5 %335 %84 +%332 = OpFMul %5 %331 %84 OpLine %3 271 9 -%337 = OpFAdd %5 %336 %84 +%333 = OpFAdd %5 %332 %84 OpLine %3 272 17 -%338 = OpCompositeConstruct %6 %327 %328 -%339 = OpFAdd %6 %322 %338 +%334 = OpCompositeConstruct %6 %323 %324 +%335 = OpFAdd %6 %318 %334 OpLine %3 272 9 -%340 = OpFunctionCall %5 %77 %339 +%336 = OpFunctionCall %5 %77 %335 OpLine %3 272 9 -%341 = OpFMul %5 %340 %84 +%337 = OpFMul %5 %336 %84 OpLine %3 269 12 -%342 = OpFAdd %5 %341 %84 -%343 = OpCompositeConstruct %4 %332 %337 %342 -OpReturnValue %343 +%338 = OpFAdd %5 %337 %84 +%339 = OpCompositeConstruct %4 %328 %333 %338 +OpReturnValue %339 OpFunctionEnd -%348 = OpFunction %2 None %349 -%344 = OpLabel -%347 = OpLoad %19 %345 -%351 = OpAccessChain %350 %29 %131 -OpBranch %356 -%356 = OpLabel +%344 = OpFunction %2 None %345 +%340 = OpLabel +%343 = OpLoad %19 %341 +%347 = OpAccessChain %346 %29 %131 +OpBranch %352 +%352 = OpLabel OpLine %3 111 22 -%357 = OpCompositeExtract %8 %347 0 +%353 = OpCompositeExtract %8 %343 0 OpLine %3 113 36 -%359 = OpAccessChain %358 %351 %131 -%360 = OpLoad %10 %359 +%355 = OpAccessChain %354 %347 %131 +%356 = OpLoad %10 %355 OpLine %3 113 59 -%362 = OpAccessChain %361 %351 %122 -%363 = OpLoad %11 %362 +%358 = OpAccessChain %357 %347 %122 +%359 = OpLoad %11 %358 OpLine %3 113 13 -%364 = OpFunctionCall %6 %306 %357 %360 %363 +%360 = OpFunctionCall %6 %302 %353 %356 %359 OpLine %3 115 5 OpLine %3 115 51 -%368 = OpAccessChain %367 %351 %353 -%369 = OpLoad %6 %368 +%364 = OpAccessChain %363 %347 %349 +%365 = OpLoad %6 %364 OpLine %3 115 33 -%370 = OpFunctionCall %14 %273 %364 %369 +%366 = OpFunctionCall %14 %269 %360 %365 OpLine %3 115 5 -%371 = OpAccessChain %366 %32 %131 %357 -OpStore %371 %370 +%367 = OpAccessChain %362 %32 %131 %353 +OpStore %367 %366 OpLine %3 118 23 -%372 = OpCompositeExtract %8 %347 0 +%368 = OpCompositeExtract %8 %343 0 OpLine %3 118 23 -%373 = OpIMul %8 %372 %352 +%369 = OpIMul %8 %368 %348 OpLine %3 120 25 -%375 = OpAccessChain %374 %351 %131 %131 -%376 = OpLoad %8 %375 +%371 = OpAccessChain %370 %347 %131 %131 +%372 = OpLoad %8 %371 OpLine %3 120 25 -%377 = OpAccessChain %374 %351 %131 %122 -%378 = OpLoad %8 %377 -%379 = OpIMul %8 %376 %378 +%373 = OpAccessChain %370 %347 %131 %122 +%374 = OpLoad %8 %373 +%375 = OpIMul %8 %372 %374 OpLine %3 120 9 -%380 = OpIMul %8 %379 %352 -%381 = OpUGreaterThanEqual %107 %373 %380 +%376 = OpIMul %8 %375 %348 +%377 = OpUGreaterThanEqual %107 %369 %376 OpLine %3 120 5 -OpSelectionMerge %382 None -OpBranchConditional %381 %383 %382 -%383 = OpLabel +OpSelectionMerge %378 None +OpBranchConditional %377 %379 %378 +%379 = OpLabel OpReturn -%382 = OpLabel +%378 = OpLabel OpLine %3 122 28 -%384 = OpCompositeExtract %8 %347 0 +%380 = OpCompositeExtract %8 %343 0 OpLine %3 122 15 -%385 = OpAccessChain %374 %351 %131 %131 -%386 = OpLoad %8 %385 -%387 = OpUDiv %8 %384 %386 -%388 = OpIAdd %8 %357 %387 +%381 = OpAccessChain %370 %347 %131 %131 +%382 = OpLoad %8 %381 +%383 = OpUDiv %8 %380 %382 +%384 = OpIAdd %8 %353 %383 OpLine %3 123 15 -%389 = OpIAdd %8 %388 %122 +%385 = OpIAdd %8 %384 %122 OpLine %3 124 15 -%390 = OpAccessChain %374 %351 %131 %131 -%391 = OpLoad %8 %390 -%392 = OpIAdd %8 %388 %391 +%386 = OpAccessChain %370 %347 %131 %131 +%387 = OpLoad %8 %386 +%388 = OpIAdd %8 %384 %387 OpLine %3 124 15 -%393 = OpIAdd %8 %392 %122 +%389 = OpIAdd %8 %388 %122 OpLine %3 125 15 -%394 = OpIAdd %8 %393 %122 +%390 = OpIAdd %8 %389 %122 OpLine %3 127 5 OpLine %3 127 5 -%397 = OpAccessChain %396 %34 %131 %373 -OpStore %397 %388 +%393 = OpAccessChain %392 %34 %131 %369 +OpStore %393 %384 OpLine %3 128 5 OpLine %3 128 5 -%398 = OpIAdd %8 %373 %122 +%394 = OpIAdd %8 %369 %122 OpLine %3 128 5 -%399 = OpAccessChain %396 %34 %131 %398 -OpStore %399 %393 +%395 = OpAccessChain %392 %34 %131 %394 +OpStore %395 %389 OpLine %3 129 5 OpLine %3 129 5 -%400 = OpIAdd %8 %373 %353 +%396 = OpIAdd %8 %369 %349 OpLine %3 129 5 -%401 = OpAccessChain %396 %34 %131 %400 -OpStore %401 %394 +%397 = OpAccessChain %392 %34 %131 %396 +OpStore %397 %390 OpLine %3 130 5 OpLine %3 130 5 -%402 = OpIAdd %8 %373 %354 +%398 = OpIAdd %8 %369 %350 OpLine %3 130 5 -%403 = OpAccessChain %396 %34 %131 %402 -OpStore %403 %388 +%399 = OpAccessChain %392 %34 %131 %398 +OpStore %399 %384 OpLine %3 131 5 OpLine %3 131 5 -%404 = OpIAdd %8 %373 %355 +%400 = OpIAdd %8 %369 %351 OpLine %3 131 5 -%405 = OpAccessChain %396 %34 %131 %404 -OpStore %405 %394 +%401 = OpAccessChain %392 %34 %131 %400 +OpStore %401 %390 OpLine %3 132 5 OpLine %3 132 5 -%406 = OpIAdd %8 %373 %215 +%402 = OpIAdd %8 %369 %215 OpLine %3 132 5 -%407 = OpAccessChain %396 %34 %131 %406 -OpStore %407 %389 +%403 = OpAccessChain %392 %34 %131 %402 +OpStore %403 %385 OpReturn OpFunctionEnd -%418 = OpFunction %2 None %349 -%408 = OpLabel -%411 = OpLoad %8 %409 -%420 = OpAccessChain %419 %36 %131 -OpBranch %422 -%422 = OpLabel +%414 = OpFunction %2 None %345 +%404 = OpLabel +%407 = OpLoad %8 %405 +%416 = OpAccessChain %415 %36 %131 +OpBranch %418 +%418 = OpLabel OpLine %3 161 19 -%423 = OpIAdd %8 %411 %353 +%419 = OpIAdd %8 %407 %349 OpLine %3 161 18 -%424 = OpUDiv %8 %423 %354 +%420 = OpUDiv %8 %419 %350 OpLine %3 161 13 -%425 = OpUMod %8 %424 %353 -%426 = OpConvertUToF %5 %425 +%421 = OpUMod %8 %420 %349 +%422 = OpConvertUToF %5 %421 OpLine %3 162 19 -%427 = OpIAdd %8 %411 %122 +%423 = OpIAdd %8 %407 %122 OpLine %3 162 18 -%428 = OpUDiv %8 %427 %354 +%424 = OpUDiv %8 %423 %350 OpLine %3 162 13 -%429 = OpUMod %8 %428 %353 -%430 = OpConvertUToF %5 %429 +%425 = OpUMod %8 %424 %349 +%426 = OpConvertUToF %5 %425 OpLine %3 163 14 -%431 = OpCompositeConstruct %6 %426 %430 +%427 = OpCompositeConstruct %6 %422 %426 OpLine %3 165 30 -%432 = OpVectorTimesScalar %6 %431 %85 -%433 = OpCompositeConstruct %6 %421 %421 -%434 = OpFAdd %6 %433 %432 +%428 = OpVectorTimesScalar %6 %427 %85 +%429 = OpCompositeConstruct %6 %417 %417 +%430 = OpFAdd %6 %429 %428 OpLine %3 165 20 -%435 = OpCompositeConstruct %7 %434 %83 %56 +%431 = OpCompositeConstruct %7 %430 %83 %56 OpLine %3 168 21 -%436 = OpCompositeExtract %5 %431 0 -OpLine %3 168 21 -%438 = OpAccessChain %437 %420 %354 -%439 = OpLoad %8 %438 -%440 = OpConvertUToF %5 %439 -%441 = OpFMul %5 %436 %440 -%442 = OpCompositeExtract %5 %431 1 +%433 = OpAccessChain %432 %416 %350 +%434 = OpLoad %8 %433 +%435 = OpConvertUToF %5 %434 +%436 = OpFMul %5 %422 %435 OpLine %3 168 17 -%443 = OpAccessChain %437 %420 %354 -%444 = OpLoad %8 %443 -%445 = OpConvertUToF %5 %444 -%446 = OpFMul %5 %442 %445 -%447 = OpFAdd %5 %441 %446 -%448 = OpConvertFToU %8 %447 +%437 = OpAccessChain %432 %416 %350 +%438 = OpLoad %8 %437 +%439 = OpConvertUToF %5 %438 +%440 = OpFMul %5 %426 %439 +%441 = OpFAdd %5 %436 %440 +%442 = OpConvertFToU %8 %441 OpLine %3 168 17 -%449 = OpAccessChain %437 %420 %355 -%450 = OpLoad %8 %449 -%451 = OpIAdd %8 %448 %450 +%443 = OpAccessChain %432 %416 %351 +%444 = OpLoad %8 %443 +%445 = OpIAdd %8 %442 %444 OpLine %3 170 12 -%452 = OpCompositeConstruct %21 %451 %435 %431 -%453 = OpCompositeExtract %8 %452 0 -OpStore %412 %453 -%454 = OpCompositeExtract %7 %452 1 -OpStore %414 %454 -%455 = OpCompositeExtract %6 %452 2 -OpStore %416 %455 +%446 = OpCompositeConstruct %21 %445 %431 %427 +%447 = OpCompositeExtract %8 %446 0 +OpStore %408 %447 +%448 = OpCompositeExtract %7 %446 1 +OpStore %410 %448 +%449 = OpCompositeExtract %6 %446 2 +OpStore %412 %449 OpReturn OpFunctionEnd -%470 = OpFunction %2 None %349 -%458 = OpLabel -%456 = OpVariable %206 Function %207 -%457 = OpVariable %210 Function %211 -%461 = OpLoad %8 %460 -%464 = OpLoad %7 %462 -%467 = OpLoad %6 %465 -%459 = OpCompositeConstruct %21 %461 %464 %467 -%471 = OpAccessChain %419 %36 %131 -OpBranch %473 -%473 = OpLabel +%464 = OpFunction %2 None %345 +%452 = OpLabel +%450 = OpVariable %206 Function %207 +%451 = OpVariable %210 Function %211 +%455 = OpLoad %8 %454 +%458 = OpLoad %7 %456 +%461 = OpLoad %6 %459 +%453 = OpCompositeConstruct %21 %455 %458 %461 +%465 = OpAccessChain %415 %36 %131 +OpBranch %467 +%467 = OpLabel OpLine %3 181 17 -%474 = OpCompositeExtract %6 %459 2 -%475 = OpCompositeExtract %5 %474 0 +%468 = OpCompositeExtract %6 %453 2 +%469 = OpCompositeExtract %5 %468 0 OpLine %3 181 17 -%476 = OpAccessChain %437 %471 %354 -%477 = OpLoad %8 %476 -%478 = OpConvertUToF %5 %477 -%479 = OpFMul %5 %475 %478 -%480 = OpCompositeExtract %6 %459 2 -%481 = OpCompositeExtract %5 %480 1 +%470 = OpAccessChain %432 %465 %350 +%471 = OpLoad %8 %470 +%472 = OpConvertUToF %5 %471 +%473 = OpFMul %5 %469 %472 +%474 = OpCompositeExtract %6 %453 2 +%475 = OpCompositeExtract %5 %474 1 OpLine %3 181 70 -%482 = OpAccessChain %437 %471 %354 -%483 = OpLoad %8 %482 +%476 = OpAccessChain %432 %465 %350 +%477 = OpLoad %8 %476 OpLine %3 181 13 -%484 = OpAccessChain %437 %471 %354 -%485 = OpLoad %8 %484 -%486 = OpIMul %8 %483 %485 -%487 = OpConvertUToF %5 %486 -%488 = OpFMul %5 %481 %487 -%489 = OpFAdd %5 %479 %488 -%490 = OpConvertFToU %8 %489 +%478 = OpAccessChain %432 %465 %350 +%479 = OpLoad %8 %478 +%480 = OpIMul %8 %477 %479 +%481 = OpConvertUToF %5 %480 +%482 = OpFMul %5 %475 %481 +%483 = OpFAdd %5 %473 %482 +%484 = OpConvertFToU %8 %483 OpLine %3 181 13 -%491 = OpAccessChain %437 %471 %355 -%492 = OpLoad %8 %491 -%493 = OpIAdd %8 %490 %492 +%485 = OpAccessChain %432 %465 %351 +%486 = OpLoad %8 %485 +%487 = OpIAdd %8 %484 %486 OpLine %3 182 32 -%494 = OpConvertUToF %5 %493 +%488 = OpConvertUToF %5 %487 OpLine %3 182 22 -%495 = OpFDiv %5 %494 %472 -%496 = OpExtInst %5 %1 Floor %495 -%497 = OpConvertFToU %8 %496 +%489 = OpFDiv %5 %488 %466 +%490 = OpExtInst %5 %1 Floor %489 +%491 = OpConvertFToU %8 %490 OpLine %3 183 22 -%498 = OpUMod %8 %493 %352 +%492 = OpUMod %8 %487 %348 OpLine %3 185 36 -%499 = OpAccessChain %358 %471 %131 -%500 = OpLoad %10 %499 +%493 = OpAccessChain %354 %465 %131 +%494 = OpLoad %10 %493 OpLine %3 185 57 -%501 = OpAccessChain %361 %471 %122 -%502 = OpLoad %11 %501 +%495 = OpAccessChain %357 %465 %122 +%496 = OpLoad %11 %495 OpLine %3 185 13 -%503 = OpFunctionCall %6 %306 %497 %500 %502 +%497 = OpFunctionCall %6 %302 %491 %494 %496 OpLine %3 186 31 -%504 = OpAccessChain %367 %471 %353 -%505 = OpLoad %6 %504 +%498 = OpAccessChain %363 %465 %349 +%499 = OpLoad %6 %498 OpLine %3 186 13 -%506 = OpFunctionCall %14 %273 %503 %505 +%500 = OpFunctionCall %14 %269 %497 %499 OpLine %3 188 5 -OpStore %456 %83 +OpStore %450 %83 OpLine %3 190 5 -OpSelectionMerge %507 None -OpSwitch %498 %514 0 %508 1 %509 2 %510 3 %511 4 %512 5 %513 -%508 = OpLabel +OpSelectionMerge %501 None +OpSwitch %492 %508 0 %502 1 %503 2 %504 3 %505 4 %506 5 %507 +%502 = OpLabel OpLine %3 191 37 -%515 = OpCompositeExtract %4 %506 0 -%516 = OpCompositeExtract %5 %515 0 +%509 = OpCompositeExtract %4 %500 0 +%510 = OpCompositeExtract %5 %509 0 OpLine %3 191 20 -OpStore %456 %516 -OpBranch %507 -%509 = OpLabel +OpStore %450 %510 +OpBranch %501 +%503 = OpLabel OpLine %3 192 37 -%517 = OpCompositeExtract %4 %506 0 -%518 = OpCompositeExtract %5 %517 1 +%511 = OpCompositeExtract %4 %500 0 +%512 = OpCompositeExtract %5 %511 1 OpLine %3 192 20 -OpStore %456 %518 -OpBranch %507 -%510 = OpLabel +OpStore %450 %512 +OpBranch %501 +%504 = OpLabel OpLine %3 193 37 -%519 = OpCompositeExtract %4 %506 0 -%520 = OpCompositeExtract %5 %519 2 +%513 = OpCompositeExtract %4 %500 0 +%514 = OpCompositeExtract %5 %513 2 OpLine %3 193 20 -OpStore %456 %520 -OpBranch %507 -%511 = OpLabel +OpStore %450 %514 +OpBranch %501 +%505 = OpLabel OpLine %3 194 37 -%521 = OpCompositeExtract %4 %506 1 -%522 = OpCompositeExtract %5 %521 0 +%515 = OpCompositeExtract %4 %500 1 +%516 = OpCompositeExtract %5 %515 0 OpLine %3 194 20 -OpStore %456 %522 -OpBranch %507 -%512 = OpLabel +OpStore %450 %516 +OpBranch %501 +%506 = OpLabel OpLine %3 195 37 -%523 = OpCompositeExtract %4 %506 1 -%524 = OpCompositeExtract %5 %523 1 +%517 = OpCompositeExtract %4 %500 1 +%518 = OpCompositeExtract %5 %517 1 OpLine %3 195 20 -OpStore %456 %524 -OpBranch %507 -%513 = OpLabel +OpStore %450 %518 +OpBranch %501 +%507 = OpLabel OpLine %3 196 37 -%525 = OpCompositeExtract %4 %506 1 -%526 = OpCompositeExtract %5 %525 2 +%519 = OpCompositeExtract %4 %500 1 +%520 = OpCompositeExtract %5 %519 2 OpLine %3 196 20 -OpStore %456 %526 -OpBranch %507 -%514 = OpLabel -OpBranch %507 -%507 = OpLabel +OpStore %450 %520 +OpBranch %501 +%508 = OpLabel +OpBranch %501 +%501 = OpLabel OpLine %3 200 15 -%527 = OpAccessChain %374 %471 %131 %131 -%528 = OpLoad %8 %527 -%529 = OpUDiv %8 %497 %528 -%530 = OpIAdd %8 %497 %529 +%521 = OpAccessChain %370 %465 %131 %131 +%522 = OpLoad %8 %521 +%523 = OpUDiv %8 %491 %522 +%524 = OpIAdd %8 %491 %523 OpLine %3 201 15 -%531 = OpIAdd %8 %530 %122 +%525 = OpIAdd %8 %524 %122 OpLine %3 202 15 -%532 = OpAccessChain %374 %471 %131 %131 -%533 = OpLoad %8 %532 -%534 = OpIAdd %8 %530 %533 +%526 = OpAccessChain %370 %465 %131 %131 +%527 = OpLoad %8 %526 +%528 = OpIAdd %8 %524 %527 OpLine %3 202 15 -%535 = OpIAdd %8 %534 %122 +%529 = OpIAdd %8 %528 %122 OpLine %3 203 15 -%536 = OpIAdd %8 %535 %122 +%530 = OpIAdd %8 %529 %122 OpLine %3 205 5 -OpStore %457 %131 +OpStore %451 %131 OpLine %3 206 5 -OpSelectionMerge %537 None -OpSwitch %498 %542 0 %538 3 %538 2 %539 4 %539 1 %540 5 %541 -%538 = OpLabel +OpSelectionMerge %531 None +OpSwitch %492 %536 0 %532 3 %532 2 %533 4 %533 1 %534 5 %535 +%532 = OpLabel OpLine %3 207 24 -OpStore %457 %530 -OpBranch %537 -%539 = OpLabel +OpStore %451 %524 +OpBranch %531 +%533 = OpLabel OpLine %3 208 24 -OpStore %457 %536 -OpBranch %537 -%540 = OpLabel +OpStore %451 %530 +OpBranch %531 +%534 = OpLabel OpLine %3 209 20 -OpStore %457 %535 -OpBranch %537 -%541 = OpLabel +OpStore %451 %529 +OpBranch %531 +%535 = OpLabel OpLine %3 210 20 -OpStore %457 %531 -OpBranch %537 -%542 = OpLabel -OpBranch %537 -%537 = OpLabel +OpStore %451 %525 +OpBranch %531 +%536 = OpLabel +OpBranch %531 +%531 = OpLabel OpLine %3 213 13 -%543 = OpCompositeExtract %8 %459 0 +%537 = OpCompositeExtract %8 %453 0 OpLine %3 213 5 -OpStore %457 %543 +OpStore %451 %537 OpLine %3 222 27 -%544 = OpLoad %5 %456 -%545 = OpBitcast %8 %544 +%538 = OpLoad %5 %450 +%539 = OpBitcast %8 %538 OpLine %3 223 12 -%546 = OpLoad %8 %457 -%547 = OpCompositeConstruct %22 %545 %546 -%548 = OpCompositeExtract %8 %547 0 -OpStore %468 %548 -%549 = OpCompositeExtract %8 %547 1 -OpStore %469 %549 +%540 = OpLoad %8 %451 +%541 = OpCompositeConstruct %22 %539 %540 +%542 = OpCompositeExtract %8 %541 0 +OpStore %462 %542 +%543 = OpCompositeExtract %8 %541 1 +OpStore %463 %543 OpReturn OpFunctionEnd -%561 = OpFunction %2 None %349 -%550 = OpLabel -%554 = OpLoad %4 %552 -%556 = OpLoad %4 %555 -%551 = OpCompositeConstruct %14 %554 %556 -%563 = OpAccessChain %562 %39 %131 -OpBranch %564 -%564 = OpLabel +%555 = OpFunction %2 None %345 +%544 = OpLabel +%548 = OpLoad %4 %546 +%550 = OpLoad %4 %549 +%545 = OpCompositeConstruct %14 %548 %550 +%557 = OpAccessChain %556 %39 %131 +OpBranch %558 +%558 = OpLabel OpLine %3 254 25 -%566 = OpAccessChain %565 %563 %122 -%567 = OpLoad %23 %566 -%568 = OpCompositeExtract %4 %551 0 +%560 = OpAccessChain %559 %557 %122 +%561 = OpLoad %23 %560 +%562 = OpCompositeExtract %4 %545 0 OpLine %3 254 25 -%569 = OpCompositeConstruct %7 %568 %56 -%570 = OpMatrixTimesVector %7 %567 %569 +%563 = OpCompositeConstruct %7 %562 %56 +%564 = OpMatrixTimesVector %7 %561 %563 OpLine %3 255 18 -%571 = OpCompositeExtract %4 %551 1 +%565 = OpCompositeExtract %4 %545 1 OpLine %3 256 12 -%572 = OpCompositeExtract %4 %551 0 -%573 = OpCompositeConstruct %26 %570 %571 %572 -%574 = OpCompositeExtract %7 %573 0 -OpStore %557 %574 -%575 = OpCompositeExtract %4 %573 1 -OpStore %558 %575 -%576 = OpCompositeExtract %4 %573 2 -OpStore %560 %576 +%566 = OpCompositeExtract %4 %545 0 +%567 = OpCompositeConstruct %26 %564 %565 %566 +%568 = OpCompositeExtract %7 %567 0 +OpStore %551 %568 +%569 = OpCompositeExtract %4 %567 1 +OpStore %552 %569 +%570 = OpCompositeExtract %4 %567 2 +OpStore %554 %570 OpReturn OpFunctionEnd -%587 = OpFunction %2 None %349 -%578 = OpLabel -%577 = OpVariable %73 Function %74 -%581 = OpLoad %7 %580 -%583 = OpLoad %4 %582 -%585 = OpLoad %4 %584 -%579 = OpCompositeConstruct %26 %581 %583 %585 -%588 = OpAccessChain %562 %39 %131 -%590 = OpAccessChain %589 %42 %131 -OpBranch %593 -%593 = OpLabel +%581 = OpFunction %2 None %345 +%572 = OpLabel +%571 = OpVariable %73 Function %74 +%575 = OpLoad %7 %574 +%577 = OpLoad %4 %576 +%579 = OpLoad %4 %578 +%573 = OpCompositeConstruct %26 %575 %577 %579 +%582 = OpAccessChain %556 %39 %131 +%584 = OpAccessChain %583 %42 %131 +OpBranch %587 +%587 = OpLabel OpLine %3 278 28 -%594 = OpCompositeConstruct %4 %83 %83 %83 +%588 = OpCompositeConstruct %4 %83 %83 %83 OpLine %3 278 17 -%595 = OpCompositeConstruct %4 %275 %275 %275 -%596 = OpCompositeExtract %4 %579 2 -%597 = OpExtInst %4 %1 Fract %596 -%598 = OpExtInst %4 %1 SmoothStep %594 %595 %597 +%589 = OpCompositeConstruct %4 %271 %271 %271 +%590 = OpCompositeExtract %4 %573 2 +%591 = OpExtInst %4 %1 Fract %590 +%592 = OpExtInst %4 %1 SmoothStep %588 %589 %591 OpLine %3 278 5 -OpStore %577 %598 +OpStore %571 %592 OpLine %3 279 17 -%599 = OpCompositeConstruct %4 %84 %275 %591 +%593 = OpCompositeConstruct %4 %84 %271 %585 OpLine %3 279 13 -%600 = OpCompositeConstruct %4 %592 %592 %592 -%601 = OpAccessChain %121 %577 %131 -%602 = OpLoad %5 %601 -%603 = OpAccessChain %121 %577 %122 -%604 = OpLoad %5 %603 -%605 = OpFMul %5 %602 %604 -%606 = OpAccessChain %121 %577 %353 -%607 = OpLoad %5 %606 -%608 = OpFMul %5 %605 %607 -%609 = OpCompositeConstruct %4 %608 %608 %608 -%610 = OpExtInst %4 %1 FMix %599 %600 %609 +%594 = OpCompositeConstruct %4 %586 %586 %586 +%595 = OpAccessChain %121 %571 %131 +%596 = OpLoad %5 %595 +%597 = OpAccessChain %121 %571 %122 +%598 = OpLoad %5 %597 +%599 = OpFMul %5 %596 %598 +%600 = OpAccessChain %121 %571 %349 +%601 = OpLoad %5 %600 +%602 = OpFMul %5 %599 %601 +%603 = OpCompositeConstruct %4 %602 %602 %602 +%604 = OpExtInst %4 %1 FMix %593 %594 %603 OpLine %3 279 5 -OpStore %577 %610 +OpStore %571 %604 OpLine %3 282 25 -%612 = OpAccessChain %611 %590 %122 -%613 = OpLoad %4 %612 -%614 = OpVectorTimesScalar %4 %613 %275 +%606 = OpAccessChain %605 %584 %122 +%607 = OpLoad %4 %606 +%608 = OpVectorTimesScalar %4 %607 %271 OpLine %3 284 21 -%615 = OpAccessChain %611 %590 %131 -%616 = OpLoad %4 %615 -%617 = OpCompositeExtract %4 %579 2 -%618 = OpFSub %4 %616 %617 -%619 = OpExtInst %4 %1 Normalize %618 +%609 = OpAccessChain %605 %584 %131 +%610 = OpLoad %4 %609 +%611 = OpCompositeExtract %4 %573 2 +%612 = OpFSub %4 %610 %611 +%613 = OpExtInst %4 %1 Normalize %612 OpLine %3 285 20 -%621 = OpAccessChain %620 %588 %131 -%622 = OpLoad %7 %621 -%623 = OpVectorShuffle %4 %622 %622 0 1 2 -%624 = OpCompositeExtract %4 %579 2 -%625 = OpFSub %4 %623 %624 -%626 = OpExtInst %4 %1 Normalize %625 +%615 = OpAccessChain %614 %582 %131 +%616 = OpLoad %7 %615 +%617 = OpVectorShuffle %4 %616 %616 0 1 2 +%618 = OpCompositeExtract %4 %573 2 +%619 = OpFSub %4 %617 %618 +%620 = OpExtInst %4 %1 Normalize %619 OpLine %3 286 20 -%627 = OpFAdd %4 %626 %619 -%628 = OpExtInst %4 %1 Normalize %627 +%621 = OpFAdd %4 %620 %613 +%622 = OpExtInst %4 %1 Normalize %621 OpLine %3 288 32 -%629 = OpCompositeExtract %4 %579 1 -%630 = OpDot %5 %629 %619 +%623 = OpCompositeExtract %4 %573 1 +%624 = OpDot %5 %623 %613 OpLine %3 288 28 -%631 = OpExtInst %5 %1 FMax %630 %83 +%625 = OpExtInst %5 %1 FMax %624 %83 OpLine %3 289 25 -%632 = OpAccessChain %611 %590 %122 -%633 = OpLoad %4 %632 -%634 = OpVectorTimesScalar %4 %633 %631 +%626 = OpAccessChain %605 %584 %122 +%627 = OpLoad %4 %626 +%628 = OpVectorTimesScalar %4 %627 %625 OpLine %3 291 37 -%635 = OpCompositeExtract %4 %579 1 -%636 = OpDot %5 %635 %628 +%629 = OpCompositeExtract %4 %573 1 +%630 = OpDot %5 %629 %622 OpLine %3 291 33 -%637 = OpExtInst %5 %1 FMax %636 %83 +%631 = OpExtInst %5 %1 FMax %630 %83 OpLine %3 291 29 -%638 = OpExtInst %5 %1 Pow %637 %326 +%632 = OpExtInst %5 %1 Pow %631 %322 OpLine %3 292 26 -%639 = OpAccessChain %611 %590 %122 -%640 = OpLoad %4 %639 -%641 = OpVectorTimesScalar %4 %640 %638 +%633 = OpAccessChain %605 %584 %122 +%634 = OpLoad %4 %633 +%635 = OpVectorTimesScalar %4 %634 %632 OpLine %3 294 18 -%642 = OpFAdd %4 %614 %634 -%643 = OpFAdd %4 %642 %641 -%644 = OpLoad %4 %577 -%645 = OpFMul %4 %643 %644 +%636 = OpFAdd %4 %608 %628 +%637 = OpFAdd %4 %636 %635 +%638 = OpLoad %4 %571 +%639 = OpFMul %4 %637 %638 OpLine %3 296 12 -%646 = OpCompositeConstruct %7 %645 %56 -OpStore %586 %646 +%640 = OpCompositeConstruct %7 %639 %56 +OpStore %580 %640 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/image.spvasm b/tests/out/spv/image.spvasm index 1b6ef28879..06aa36bcb2 100644 --- a/tests/out/spv/image.spvasm +++ b/tests/out/spv/image.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 523 +; Bound: 522 OpCapability Shader OpCapability Image1D OpCapability Sampled1D @@ -14,15 +14,15 @@ OpEntryPoint GLCompute %169 "depth_load" %167 OpEntryPoint Vertex %190 "queries" %188 OpEntryPoint Vertex %242 "levels_queries" %241 OpEntryPoint Fragment %274 "texture_sample" %273 -OpEntryPoint Fragment %421 "texture_sample_comparison" %419 -OpEntryPoint Fragment %476 "gather" %475 -OpEntryPoint Fragment %511 "depth_no_comparison" %510 +OpEntryPoint Fragment %420 "texture_sample_comparison" %418 +OpEntryPoint Fragment %475 "gather" %474 +OpEntryPoint Fragment %510 "depth_no_comparison" %509 OpExecutionMode %78 LocalSize 16 1 1 OpExecutionMode %169 LocalSize 16 1 1 OpExecutionMode %274 OriginUpperLeft -OpExecutionMode %421 OriginUpperLeft -OpExecutionMode %476 OriginUpperLeft -OpExecutionMode %511 OriginUpperLeft +OpExecutionMode %420 OriginUpperLeft +OpExecutionMode %475 OriginUpperLeft +OpExecutionMode %510 OriginUpperLeft OpName %31 "image_mipmapped_src" OpName %33 "image_multisampled_src" OpName %35 "image_depth_multisampled_src" @@ -53,10 +53,10 @@ OpName %190 "queries" OpName %242 "levels_queries" OpName %269 "a" OpName %274 "texture_sample" -OpName %415 "a" -OpName %421 "texture_sample_comparison" -OpName %476 "gather" -OpName %511 "depth_no_comparison" +OpName %414 "a" +OpName %420 "texture_sample_comparison" +OpName %475 "gather" +OpName %510 "depth_no_comparison" OpDecorate %31 DescriptorSet 0 OpDecorate %31 Binding 0 OpDecorate %33 DescriptorSet 0 @@ -109,9 +109,9 @@ OpDecorate %167 BuiltIn LocalInvocationId OpDecorate %188 BuiltIn Position OpDecorate %241 BuiltIn Position OpDecorate %273 Location 0 -OpDecorate %419 Location 0 -OpDecorate %475 Location 0 -OpDecorate %510 Location 0 +OpDecorate %418 Location 0 +OpDecorate %474 Location 0 +OpDecorate %509 Location 0 %2 = OpTypeVoid %4 = OpTypeInt 32 0 %3 = OpTypeImage %4 2D 0 0 0 1 Unknown @@ -206,25 +206,25 @@ OpDecorate %510 Location 0 %283 = OpConstant %14 0 %285 = OpTypeVector %7 2 %287 = OpTypeVector %7 3 -%290 = OpTypeSampledImage %15 -%295 = OpTypeSampledImage %16 -%316 = OpTypeSampledImage %18 -%377 = OpTypeSampledImage %20 -%416 = OpTypePointer Function %7 -%417 = OpConstantNull %7 -%420 = OpTypePointer Output %7 -%419 = OpVariable %420 Output -%429 = OpTypeSampledImage %25 -%434 = OpTypeSampledImage %26 -%447 = OpTypeSampledImage %27 -%454 = OpConstant %7 0.0 -%475 = OpVariable %189 Output -%487 = OpConstant %4 1 -%490 = OpConstant %4 3 -%495 = OpTypeSampledImage %3 -%498 = OpTypeVector %14 4 -%499 = OpTypeSampledImage %17 -%510 = OpVariable %189 Output +%289 = OpTypeSampledImage %15 +%294 = OpTypeSampledImage %16 +%315 = OpTypeSampledImage %18 +%376 = OpTypeSampledImage %20 +%415 = OpTypePointer Function %7 +%416 = OpConstantNull %7 +%419 = OpTypePointer Output %7 +%418 = OpVariable %419 Output +%428 = OpTypeSampledImage %25 +%433 = OpTypeSampledImage %26 +%446 = OpTypeSampledImage %27 +%453 = OpConstant %7 0.0 +%474 = OpVariable %189 Output +%486 = OpConstant %4 1 +%489 = OpConstant %4 3 +%494 = OpTypeSampledImage %3 +%497 = OpTypeVector %14 4 +%498 = OpTypeSampledImage %17 +%509 = OpVariable %189 Output %78 = OpFunction %2 None %79 %74 = OpLabel %77 = OpLoad %12 %75 @@ -435,263 +435,262 @@ OpBranch %284 %284 = OpLabel %286 = OpCompositeConstruct %285 %280 %280 %288 = OpCompositeConstruct %287 %280 %280 %280 -%289 = OpCompositeExtract %7 %286 0 -%291 = OpSampledImage %290 %275 %279 -%292 = OpImageSampleImplicitLod %23 %291 %289 -%293 = OpLoad %23 %269 -%294 = OpFAdd %23 %293 %292 -OpStore %269 %294 -%296 = OpSampledImage %295 %276 %279 -%297 = OpImageSampleImplicitLod %23 %296 %286 -%298 = OpLoad %23 %269 -%299 = OpFAdd %23 %298 %297 -OpStore %269 %299 -%300 = OpSampledImage %295 %276 %279 -%301 = OpImageSampleImplicitLod %23 %300 %286 ConstOffset %30 -%302 = OpLoad %23 %269 -%303 = OpFAdd %23 %302 %301 -OpStore %269 %303 -%304 = OpSampledImage %295 %276 %279 -%305 = OpImageSampleExplicitLod %23 %304 %286 Lod %281 -%306 = OpLoad %23 %269 -%307 = OpFAdd %23 %306 %305 -OpStore %269 %307 -%308 = OpSampledImage %295 %276 %279 -%309 = OpImageSampleExplicitLod %23 %308 %286 Lod|ConstOffset %281 %30 -%310 = OpLoad %23 %269 -%311 = OpFAdd %23 %310 %309 -OpStore %269 %311 -%312 = OpSampledImage %295 %276 %279 -%313 = OpImageSampleImplicitLod %23 %312 %286 Bias|ConstOffset %282 %30 -%314 = OpLoad %23 %269 -%315 = OpFAdd %23 %314 %313 -OpStore %269 %315 -%317 = OpConvertUToF %7 %199 -%318 = OpCompositeConstruct %287 %286 %317 -%319 = OpSampledImage %316 %277 %279 -%320 = OpImageSampleImplicitLod %23 %319 %318 -%321 = OpLoad %23 %269 -%322 = OpFAdd %23 %321 %320 -OpStore %269 %322 -%323 = OpConvertUToF %7 %199 -%324 = OpCompositeConstruct %287 %286 %323 -%325 = OpSampledImage %316 %277 %279 -%326 = OpImageSampleImplicitLod %23 %325 %324 ConstOffset %30 -%327 = OpLoad %23 %269 -%328 = OpFAdd %23 %327 %326 -OpStore %269 %328 -%329 = OpConvertUToF %7 %199 -%330 = OpCompositeConstruct %287 %286 %329 -%331 = OpSampledImage %316 %277 %279 -%332 = OpImageSampleExplicitLod %23 %331 %330 Lod %281 -%333 = OpLoad %23 %269 -%334 = OpFAdd %23 %333 %332 -OpStore %269 %334 -%335 = OpConvertUToF %7 %199 -%336 = OpCompositeConstruct %287 %286 %335 -%337 = OpSampledImage %316 %277 %279 -%338 = OpImageSampleExplicitLod %23 %337 %336 Lod|ConstOffset %281 %30 -%339 = OpLoad %23 %269 -%340 = OpFAdd %23 %339 %338 -OpStore %269 %340 -%341 = OpConvertUToF %7 %199 -%342 = OpCompositeConstruct %287 %286 %341 -%343 = OpSampledImage %316 %277 %279 -%344 = OpImageSampleImplicitLod %23 %343 %342 Bias|ConstOffset %282 %30 -%345 = OpLoad %23 %269 -%346 = OpFAdd %23 %345 %344 -OpStore %269 %346 -%347 = OpConvertSToF %7 %283 -%348 = OpCompositeConstruct %287 %286 %347 -%349 = OpSampledImage %316 %277 %279 -%350 = OpImageSampleImplicitLod %23 %349 %348 -%351 = OpLoad %23 %269 -%352 = OpFAdd %23 %351 %350 -OpStore %269 %352 -%353 = OpConvertSToF %7 %283 -%354 = OpCompositeConstruct %287 %286 %353 -%355 = OpSampledImage %316 %277 %279 -%356 = OpImageSampleImplicitLod %23 %355 %354 ConstOffset %30 -%357 = OpLoad %23 %269 -%358 = OpFAdd %23 %357 %356 -OpStore %269 %358 -%359 = OpConvertSToF %7 %283 -%360 = OpCompositeConstruct %287 %286 %359 -%361 = OpSampledImage %316 %277 %279 -%362 = OpImageSampleExplicitLod %23 %361 %360 Lod %281 -%363 = OpLoad %23 %269 -%364 = OpFAdd %23 %363 %362 -OpStore %269 %364 -%365 = OpConvertSToF %7 %283 -%366 = OpCompositeConstruct %287 %286 %365 -%367 = OpSampledImage %316 %277 %279 -%368 = OpImageSampleExplicitLod %23 %367 %366 Lod|ConstOffset %281 %30 -%369 = OpLoad %23 %269 -%370 = OpFAdd %23 %369 %368 -OpStore %269 %370 -%371 = OpConvertSToF %7 %283 -%372 = OpCompositeConstruct %287 %286 %371 -%373 = OpSampledImage %316 %277 %279 -%374 = OpImageSampleImplicitLod %23 %373 %372 Bias|ConstOffset %282 %30 -%375 = OpLoad %23 %269 -%376 = OpFAdd %23 %375 %374 -OpStore %269 %376 -%378 = OpConvertUToF %7 %199 -%379 = OpCompositeConstruct %23 %288 %378 -%380 = OpSampledImage %377 %278 %279 -%381 = OpImageSampleImplicitLod %23 %380 %379 -%382 = OpLoad %23 %269 -%383 = OpFAdd %23 %382 %381 -OpStore %269 %383 -%384 = OpConvertUToF %7 %199 -%385 = OpCompositeConstruct %23 %288 %384 -%386 = OpSampledImage %377 %278 %279 -%387 = OpImageSampleExplicitLod %23 %386 %385 Lod %281 -%388 = OpLoad %23 %269 -%389 = OpFAdd %23 %388 %387 -OpStore %269 %389 -%390 = OpConvertUToF %7 %199 -%391 = OpCompositeConstruct %23 %288 %390 -%392 = OpSampledImage %377 %278 %279 -%393 = OpImageSampleImplicitLod %23 %392 %391 Bias %282 -%394 = OpLoad %23 %269 -%395 = OpFAdd %23 %394 %393 -OpStore %269 %395 -%396 = OpConvertSToF %7 %283 -%397 = OpCompositeConstruct %23 %288 %396 -%398 = OpSampledImage %377 %278 %279 -%399 = OpImageSampleImplicitLod %23 %398 %397 -%400 = OpLoad %23 %269 -%401 = OpFAdd %23 %400 %399 -OpStore %269 %401 -%402 = OpConvertSToF %7 %283 -%403 = OpCompositeConstruct %23 %288 %402 -%404 = OpSampledImage %377 %278 %279 -%405 = OpImageSampleExplicitLod %23 %404 %403 Lod %281 -%406 = OpLoad %23 %269 -%407 = OpFAdd %23 %406 %405 -OpStore %269 %407 -%408 = OpConvertSToF %7 %283 -%409 = OpCompositeConstruct %23 %288 %408 -%410 = OpSampledImage %377 %278 %279 -%411 = OpImageSampleImplicitLod %23 %410 %409 Bias %282 -%412 = OpLoad %23 %269 -%413 = OpFAdd %23 %412 %411 -OpStore %269 %413 -%414 = OpLoad %23 %269 -OpStore %273 %414 +%290 = OpSampledImage %289 %275 %279 +%291 = OpImageSampleImplicitLod %23 %290 %280 +%292 = OpLoad %23 %269 +%293 = OpFAdd %23 %292 %291 +OpStore %269 %293 +%295 = OpSampledImage %294 %276 %279 +%296 = OpImageSampleImplicitLod %23 %295 %286 +%297 = OpLoad %23 %269 +%298 = OpFAdd %23 %297 %296 +OpStore %269 %298 +%299 = OpSampledImage %294 %276 %279 +%300 = OpImageSampleImplicitLod %23 %299 %286 ConstOffset %30 +%301 = OpLoad %23 %269 +%302 = OpFAdd %23 %301 %300 +OpStore %269 %302 +%303 = OpSampledImage %294 %276 %279 +%304 = OpImageSampleExplicitLod %23 %303 %286 Lod %281 +%305 = OpLoad %23 %269 +%306 = OpFAdd %23 %305 %304 +OpStore %269 %306 +%307 = OpSampledImage %294 %276 %279 +%308 = OpImageSampleExplicitLod %23 %307 %286 Lod|ConstOffset %281 %30 +%309 = OpLoad %23 %269 +%310 = OpFAdd %23 %309 %308 +OpStore %269 %310 +%311 = OpSampledImage %294 %276 %279 +%312 = OpImageSampleImplicitLod %23 %311 %286 Bias|ConstOffset %282 %30 +%313 = OpLoad %23 %269 +%314 = OpFAdd %23 %313 %312 +OpStore %269 %314 +%316 = OpConvertUToF %7 %199 +%317 = OpCompositeConstruct %287 %286 %316 +%318 = OpSampledImage %315 %277 %279 +%319 = OpImageSampleImplicitLod %23 %318 %317 +%320 = OpLoad %23 %269 +%321 = OpFAdd %23 %320 %319 +OpStore %269 %321 +%322 = OpConvertUToF %7 %199 +%323 = OpCompositeConstruct %287 %286 %322 +%324 = OpSampledImage %315 %277 %279 +%325 = OpImageSampleImplicitLod %23 %324 %323 ConstOffset %30 +%326 = OpLoad %23 %269 +%327 = OpFAdd %23 %326 %325 +OpStore %269 %327 +%328 = OpConvertUToF %7 %199 +%329 = OpCompositeConstruct %287 %286 %328 +%330 = OpSampledImage %315 %277 %279 +%331 = OpImageSampleExplicitLod %23 %330 %329 Lod %281 +%332 = OpLoad %23 %269 +%333 = OpFAdd %23 %332 %331 +OpStore %269 %333 +%334 = OpConvertUToF %7 %199 +%335 = OpCompositeConstruct %287 %286 %334 +%336 = OpSampledImage %315 %277 %279 +%337 = OpImageSampleExplicitLod %23 %336 %335 Lod|ConstOffset %281 %30 +%338 = OpLoad %23 %269 +%339 = OpFAdd %23 %338 %337 +OpStore %269 %339 +%340 = OpConvertUToF %7 %199 +%341 = OpCompositeConstruct %287 %286 %340 +%342 = OpSampledImage %315 %277 %279 +%343 = OpImageSampleImplicitLod %23 %342 %341 Bias|ConstOffset %282 %30 +%344 = OpLoad %23 %269 +%345 = OpFAdd %23 %344 %343 +OpStore %269 %345 +%346 = OpConvertSToF %7 %283 +%347 = OpCompositeConstruct %287 %286 %346 +%348 = OpSampledImage %315 %277 %279 +%349 = OpImageSampleImplicitLod %23 %348 %347 +%350 = OpLoad %23 %269 +%351 = OpFAdd %23 %350 %349 +OpStore %269 %351 +%352 = OpConvertSToF %7 %283 +%353 = OpCompositeConstruct %287 %286 %352 +%354 = OpSampledImage %315 %277 %279 +%355 = OpImageSampleImplicitLod %23 %354 %353 ConstOffset %30 +%356 = OpLoad %23 %269 +%357 = OpFAdd %23 %356 %355 +OpStore %269 %357 +%358 = OpConvertSToF %7 %283 +%359 = OpCompositeConstruct %287 %286 %358 +%360 = OpSampledImage %315 %277 %279 +%361 = OpImageSampleExplicitLod %23 %360 %359 Lod %281 +%362 = OpLoad %23 %269 +%363 = OpFAdd %23 %362 %361 +OpStore %269 %363 +%364 = OpConvertSToF %7 %283 +%365 = OpCompositeConstruct %287 %286 %364 +%366 = OpSampledImage %315 %277 %279 +%367 = OpImageSampleExplicitLod %23 %366 %365 Lod|ConstOffset %281 %30 +%368 = OpLoad %23 %269 +%369 = OpFAdd %23 %368 %367 +OpStore %269 %369 +%370 = OpConvertSToF %7 %283 +%371 = OpCompositeConstruct %287 %286 %370 +%372 = OpSampledImage %315 %277 %279 +%373 = OpImageSampleImplicitLod %23 %372 %371 Bias|ConstOffset %282 %30 +%374 = OpLoad %23 %269 +%375 = OpFAdd %23 %374 %373 +OpStore %269 %375 +%377 = OpConvertUToF %7 %199 +%378 = OpCompositeConstruct %23 %288 %377 +%379 = OpSampledImage %376 %278 %279 +%380 = OpImageSampleImplicitLod %23 %379 %378 +%381 = OpLoad %23 %269 +%382 = OpFAdd %23 %381 %380 +OpStore %269 %382 +%383 = OpConvertUToF %7 %199 +%384 = OpCompositeConstruct %23 %288 %383 +%385 = OpSampledImage %376 %278 %279 +%386 = OpImageSampleExplicitLod %23 %385 %384 Lod %281 +%387 = OpLoad %23 %269 +%388 = OpFAdd %23 %387 %386 +OpStore %269 %388 +%389 = OpConvertUToF %7 %199 +%390 = OpCompositeConstruct %23 %288 %389 +%391 = OpSampledImage %376 %278 %279 +%392 = OpImageSampleImplicitLod %23 %391 %390 Bias %282 +%393 = OpLoad %23 %269 +%394 = OpFAdd %23 %393 %392 +OpStore %269 %394 +%395 = OpConvertSToF %7 %283 +%396 = OpCompositeConstruct %23 %288 %395 +%397 = OpSampledImage %376 %278 %279 +%398 = OpImageSampleImplicitLod %23 %397 %396 +%399 = OpLoad %23 %269 +%400 = OpFAdd %23 %399 %398 +OpStore %269 %400 +%401 = OpConvertSToF %7 %283 +%402 = OpCompositeConstruct %23 %288 %401 +%403 = OpSampledImage %376 %278 %279 +%404 = OpImageSampleExplicitLod %23 %403 %402 Lod %281 +%405 = OpLoad %23 %269 +%406 = OpFAdd %23 %405 %404 +OpStore %269 %406 +%407 = OpConvertSToF %7 %283 +%408 = OpCompositeConstruct %23 %288 %407 +%409 = OpSampledImage %376 %278 %279 +%410 = OpImageSampleImplicitLod %23 %409 %408 Bias %282 +%411 = OpLoad %23 %269 +%412 = OpFAdd %23 %411 %410 +OpStore %269 %412 +%413 = OpLoad %23 %269 +OpStore %273 %413 OpReturn OpFunctionEnd -%421 = OpFunction %2 None %79 -%418 = OpLabel -%415 = OpVariable %416 Function %417 -%422 = OpLoad %24 %66 -%423 = OpLoad %25 %68 -%424 = OpLoad %26 %70 -%425 = OpLoad %27 %72 -OpBranch %426 -%426 = OpLabel -%427 = OpCompositeConstruct %285 %280 %280 -%428 = OpCompositeConstruct %287 %280 %280 %280 -%430 = OpSampledImage %429 %423 %422 -%431 = OpImageSampleDrefImplicitLod %7 %430 %427 %280 -%432 = OpLoad %7 %415 -%433 = OpFAdd %7 %432 %431 -OpStore %415 %433 -%435 = OpConvertUToF %7 %199 -%436 = OpCompositeConstruct %287 %427 %435 -%437 = OpSampledImage %434 %424 %422 -%438 = OpImageSampleDrefImplicitLod %7 %437 %436 %280 -%439 = OpLoad %7 %415 -%440 = OpFAdd %7 %439 %438 -OpStore %415 %440 -%441 = OpConvertSToF %7 %283 -%442 = OpCompositeConstruct %287 %427 %441 -%443 = OpSampledImage %434 %424 %422 -%444 = OpImageSampleDrefImplicitLod %7 %443 %442 %280 -%445 = OpLoad %7 %415 -%446 = OpFAdd %7 %445 %444 -OpStore %415 %446 -%448 = OpSampledImage %447 %425 %422 -%449 = OpImageSampleDrefImplicitLod %7 %448 %428 %280 -%450 = OpLoad %7 %415 -%451 = OpFAdd %7 %450 %449 -OpStore %415 %451 -%452 = OpSampledImage %429 %423 %422 -%453 = OpImageSampleDrefExplicitLod %7 %452 %427 %280 Lod %454 -%455 = OpLoad %7 %415 -%456 = OpFAdd %7 %455 %453 -OpStore %415 %456 -%457 = OpConvertUToF %7 %199 -%458 = OpCompositeConstruct %287 %427 %457 -%459 = OpSampledImage %434 %424 %422 -%460 = OpImageSampleDrefExplicitLod %7 %459 %458 %280 Lod %454 -%461 = OpLoad %7 %415 -%462 = OpFAdd %7 %461 %460 -OpStore %415 %462 -%463 = OpConvertSToF %7 %283 -%464 = OpCompositeConstruct %287 %427 %463 -%465 = OpSampledImage %434 %424 %422 -%466 = OpImageSampleDrefExplicitLod %7 %465 %464 %280 Lod %454 -%467 = OpLoad %7 %415 -%468 = OpFAdd %7 %467 %466 -OpStore %415 %468 -%469 = OpSampledImage %447 %425 %422 -%470 = OpImageSampleDrefExplicitLod %7 %469 %428 %280 Lod %454 -%471 = OpLoad %7 %415 -%472 = OpFAdd %7 %471 %470 -OpStore %415 %472 -%473 = OpLoad %7 %415 -OpStore %419 %473 +%420 = OpFunction %2 None %79 +%417 = OpLabel +%414 = OpVariable %415 Function %416 +%421 = OpLoad %24 %66 +%422 = OpLoad %25 %68 +%423 = OpLoad %26 %70 +%424 = OpLoad %27 %72 +OpBranch %425 +%425 = OpLabel +%426 = OpCompositeConstruct %285 %280 %280 +%427 = OpCompositeConstruct %287 %280 %280 %280 +%429 = OpSampledImage %428 %422 %421 +%430 = OpImageSampleDrefImplicitLod %7 %429 %426 %280 +%431 = OpLoad %7 %414 +%432 = OpFAdd %7 %431 %430 +OpStore %414 %432 +%434 = OpConvertUToF %7 %199 +%435 = OpCompositeConstruct %287 %426 %434 +%436 = OpSampledImage %433 %423 %421 +%437 = OpImageSampleDrefImplicitLod %7 %436 %435 %280 +%438 = OpLoad %7 %414 +%439 = OpFAdd %7 %438 %437 +OpStore %414 %439 +%440 = OpConvertSToF %7 %283 +%441 = OpCompositeConstruct %287 %426 %440 +%442 = OpSampledImage %433 %423 %421 +%443 = OpImageSampleDrefImplicitLod %7 %442 %441 %280 +%444 = OpLoad %7 %414 +%445 = OpFAdd %7 %444 %443 +OpStore %414 %445 +%447 = OpSampledImage %446 %424 %421 +%448 = OpImageSampleDrefImplicitLod %7 %447 %427 %280 +%449 = OpLoad %7 %414 +%450 = OpFAdd %7 %449 %448 +OpStore %414 %450 +%451 = OpSampledImage %428 %422 %421 +%452 = OpImageSampleDrefExplicitLod %7 %451 %426 %280 Lod %453 +%454 = OpLoad %7 %414 +%455 = OpFAdd %7 %454 %452 +OpStore %414 %455 +%456 = OpConvertUToF %7 %199 +%457 = OpCompositeConstruct %287 %426 %456 +%458 = OpSampledImage %433 %423 %421 +%459 = OpImageSampleDrefExplicitLod %7 %458 %457 %280 Lod %453 +%460 = OpLoad %7 %414 +%461 = OpFAdd %7 %460 %459 +OpStore %414 %461 +%462 = OpConvertSToF %7 %283 +%463 = OpCompositeConstruct %287 %426 %462 +%464 = OpSampledImage %433 %423 %421 +%465 = OpImageSampleDrefExplicitLod %7 %464 %463 %280 Lod %453 +%466 = OpLoad %7 %414 +%467 = OpFAdd %7 %466 %465 +OpStore %414 %467 +%468 = OpSampledImage %446 %424 %421 +%469 = OpImageSampleDrefExplicitLod %7 %468 %427 %280 Lod %453 +%470 = OpLoad %7 %414 +%471 = OpFAdd %7 %470 %469 +OpStore %414 %471 +%472 = OpLoad %7 %414 +OpStore %418 %472 OpReturn OpFunctionEnd -%476 = OpFunction %2 None %79 -%474 = OpLabel -%477 = OpLoad %16 %49 -%478 = OpLoad %3 %51 -%479 = OpLoad %17 %52 -%480 = OpLoad %24 %64 -%481 = OpLoad %24 %66 -%482 = OpLoad %25 %68 -OpBranch %483 -%483 = OpLabel -%484 = OpCompositeConstruct %285 %280 %280 -%485 = OpSampledImage %295 %477 %480 -%486 = OpImageGather %23 %485 %484 %487 -%488 = OpSampledImage %295 %477 %480 -%489 = OpImageGather %23 %488 %484 %490 ConstOffset %30 -%491 = OpSampledImage %429 %482 %481 -%492 = OpImageDrefGather %23 %491 %484 %280 -%493 = OpSampledImage %429 %482 %481 -%494 = OpImageDrefGather %23 %493 %484 %280 ConstOffset %30 -%496 = OpSampledImage %495 %478 %480 -%497 = OpImageGather %98 %496 %484 %199 -%500 = OpSampledImage %499 %479 %480 -%501 = OpImageGather %498 %500 %484 %199 -%502 = OpConvertUToF %23 %497 -%503 = OpConvertSToF %23 %501 -%504 = OpFAdd %23 %502 %503 -%505 = OpFAdd %23 %486 %489 -%506 = OpFAdd %23 %505 %492 -%507 = OpFAdd %23 %506 %494 -%508 = OpFAdd %23 %507 %504 -OpStore %475 %508 +%475 = OpFunction %2 None %79 +%473 = OpLabel +%476 = OpLoad %16 %49 +%477 = OpLoad %3 %51 +%478 = OpLoad %17 %52 +%479 = OpLoad %24 %64 +%480 = OpLoad %24 %66 +%481 = OpLoad %25 %68 +OpBranch %482 +%482 = OpLabel +%483 = OpCompositeConstruct %285 %280 %280 +%484 = OpSampledImage %294 %476 %479 +%485 = OpImageGather %23 %484 %483 %486 +%487 = OpSampledImage %294 %476 %479 +%488 = OpImageGather %23 %487 %483 %489 ConstOffset %30 +%490 = OpSampledImage %428 %481 %480 +%491 = OpImageDrefGather %23 %490 %483 %280 +%492 = OpSampledImage %428 %481 %480 +%493 = OpImageDrefGather %23 %492 %483 %280 ConstOffset %30 +%495 = OpSampledImage %494 %477 %479 +%496 = OpImageGather %98 %495 %483 %199 +%499 = OpSampledImage %498 %478 %479 +%500 = OpImageGather %497 %499 %483 %199 +%501 = OpConvertUToF %23 %496 +%502 = OpConvertSToF %23 %500 +%503 = OpFAdd %23 %501 %502 +%504 = OpFAdd %23 %485 %488 +%505 = OpFAdd %23 %504 %491 +%506 = OpFAdd %23 %505 %493 +%507 = OpFAdd %23 %506 %503 +OpStore %474 %507 OpReturn OpFunctionEnd -%511 = OpFunction %2 None %79 -%509 = OpLabel -%512 = OpLoad %24 %64 -%513 = OpLoad %25 %68 -OpBranch %514 -%514 = OpLabel -%515 = OpCompositeConstruct %285 %280 %280 -%516 = OpSampledImage %429 %513 %512 -%517 = OpImageSampleImplicitLod %23 %516 %515 -%518 = OpCompositeExtract %7 %517 0 -%519 = OpSampledImage %429 %513 %512 -%520 = OpImageGather %23 %519 %515 %199 -%521 = OpCompositeConstruct %23 %518 %518 %518 %518 -%522 = OpFAdd %23 %521 %520 -OpStore %510 %522 +%510 = OpFunction %2 None %79 +%508 = OpLabel +%511 = OpLoad %24 %64 +%512 = OpLoad %25 %68 +OpBranch %513 +%513 = OpLabel +%514 = OpCompositeConstruct %285 %280 %280 +%515 = OpSampledImage %428 %512 %511 +%516 = OpImageSampleImplicitLod %23 %515 %514 +%517 = OpCompositeExtract %7 %516 0 +%518 = OpSampledImage %428 %512 %511 +%519 = OpImageGather %23 %518 %514 %199 +%520 = OpCompositeConstruct %23 %517 %517 %517 %517 +%521 = OpFAdd %23 %520 %519 +OpStore %509 %521 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/operators.spvasm b/tests/out/spv/operators.spvasm index 71bd913f7a..5e2125b723 100644 --- a/tests/out/spv/operators.spvasm +++ b/tests/out/spv/operators.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 522 +; Bound: 450 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %511 "main" -OpExecutionMode %511 LocalSize 1 1 1 +OpEntryPoint GLCompute %439 "main" +OpExecutionMode %439 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -16,569 +16,497 @@ OpExecutionMode %511 LocalSize 1 1 1 %7 = OpTypeVector %8 4 %9 = OpTypeVector %4 2 %10 = OpTypeVector %4 3 -%11 = OpTypeMatrix %10 3 -%12 = OpTypeMatrix %10 4 -%13 = OpTypeMatrix %3 3 -%14 = OpTypeVector %6 3 -%15 = OpConstant %4 1.0 -%16 = OpConstantComposite %3 %15 %15 %15 %15 -%17 = OpConstant %4 0.0 -%18 = OpConstantComposite %3 %17 %17 %17 %17 -%19 = OpConstant %4 0.5 -%20 = OpConstantComposite %3 %19 %19 %19 %19 -%21 = OpConstant %6 1 -%22 = OpConstantComposite %5 %21 %21 %21 %21 -%25 = OpTypeFunction %3 -%26 = OpConstantTrue %8 -%27 = OpConstant %6 0 -%28 = OpConstantFalse %8 -%29 = OpConstant %4 0.1 -%54 = OpConstant %4 2.0 -%55 = OpConstant %4 3.0 -%56 = OpConstant %4 4.0 -%57 = OpConstant %6 5 -%58 = OpConstant %6 2 -%74 = OpTypePointer Function %9 -%75 = OpConstantNull %9 -%78 = OpTypeFunction %9 -%94 = OpTypeFunction %10 %10 -%96 = OpTypeVector %8 3 -%97 = OpConstantComposite %10 %17 %17 %17 -%99 = OpConstantComposite %10 %15 %15 %15 -%103 = OpTypeFunction %2 -%106 = OpTypeVector %8 2 -%121 = OpConstant %4 -1.0 -%122 = OpTypeInt 32 0 -%123 = OpConstant %122 2 -%124 = OpConstant %122 1 -%125 = OpConstantNull %11 -%126 = OpConstantNull %12 -%127 = OpConstantNull %13 -%129 = OpTypeVector %6 2 -%140 = OpTypeVector %122 3 -%203 = OpTypeVector %122 2 -%438 = OpTypePointer Function %6 -%439 = OpConstantNull %6 -%441 = OpTypePointer Function %14 -%442 = OpConstantNull %14 -%472 = OpTypePointer Function %6 -%483 = OpConstant %6 -1 -%484 = OpConstant %6 -2 -%485 = OpConstant %6 -3 -%486 = OpConstant %6 4 -%487 = OpConstant %6 -5 -%488 = OpConstant %6 6 -%489 = OpConstant %6 -7 -%490 = OpConstant %6 -8 -%24 = OpFunction %3 None %25 -%23 = OpLabel -OpBranch %30 -%30 = OpLabel -%31 = OpSelect %6 %26 %21 %27 -%33 = OpCompositeConstruct %7 %26 %26 %26 %26 -%32 = OpSelect %3 %33 %16 %18 -%34 = OpCompositeConstruct %7 %28 %28 %28 %28 -%35 = OpSelect %3 %34 %18 %16 -%36 = OpExtInst %3 %1 FMix %18 %16 %20 -%38 = OpCompositeConstruct %3 %29 %29 %29 %29 -%37 = OpExtInst %3 %1 FMix %18 %16 %38 -%39 = OpCompositeExtract %6 %22 0 -%40 = OpBitcast %4 %39 -%41 = OpBitcast %3 %22 -%42 = OpConvertFToS %5 %18 -%43 = OpCompositeConstruct %5 %31 %31 %31 %31 -%44 = OpIAdd %5 %43 %42 -%45 = OpConvertSToF %3 %44 -%46 = OpFAdd %3 %45 %32 -%47 = OpFAdd %3 %46 %36 -%48 = OpFAdd %3 %47 %37 -%49 = OpCompositeConstruct %3 %40 %40 %40 %40 -%50 = OpFAdd %3 %48 %49 +%11 = OpTypeVector %8 2 +%12 = OpTypeVector %6 2 +%14 = OpTypeInt 32 0 +%13 = OpTypeVector %14 3 +%15 = OpTypeVector %14 2 +%16 = OpTypeMatrix %10 3 +%17 = OpTypeMatrix %10 4 +%18 = OpTypeMatrix %3 3 +%19 = OpTypeVector %6 3 +%20 = OpConstant %4 1.0 +%21 = OpConstantComposite %3 %20 %20 %20 %20 +%22 = OpConstant %4 0.0 +%23 = OpConstantComposite %3 %22 %22 %22 %22 +%24 = OpConstant %4 0.5 +%25 = OpConstantComposite %3 %24 %24 %24 %24 +%26 = OpConstant %6 1 +%27 = OpConstantComposite %5 %26 %26 %26 %26 +%30 = OpTypeFunction %3 +%31 = OpConstantTrue %8 +%32 = OpConstant %6 0 +%33 = OpConstantFalse %8 +%34 = OpConstant %4 0.1 +%58 = OpConstant %4 2.0 +%59 = OpConstant %4 3.0 +%60 = OpConstant %4 4.0 +%61 = OpConstant %6 5 +%62 = OpConstant %6 2 +%78 = OpTypePointer Function %9 +%79 = OpConstantNull %9 +%82 = OpTypeFunction %9 +%98 = OpTypeFunction %10 %10 +%100 = OpTypeVector %8 3 +%101 = OpConstantComposite %10 %22 %22 %22 +%103 = OpConstantComposite %10 %20 %20 %20 +%107 = OpTypeFunction %2 +%120 = OpConstant %4 -1.0 +%121 = OpConstant %6 -1 +%122 = OpConstant %6 3 +%123 = OpConstant %14 3 +%124 = OpConstant %14 2 +%125 = OpConstant %14 1 +%126 = OpConstant %14 0 +%127 = OpConstantNull %16 +%128 = OpConstantNull %17 +%129 = OpConstantNull %18 +%293 = OpConstant %6 -2 +%294 = OpConstant %14 4294967294 +%295 = OpConstant %6 4 +%296 = OpConstant %14 4 +%388 = OpTypePointer Function %6 +%389 = OpConstantNull %6 +%391 = OpTypePointer Function %19 +%392 = OpConstantNull %19 +%422 = OpTypePointer Function %6 +%433 = OpConstant %6 -5 +%434 = OpConstant %6 6 +%435 = OpConstant %6 -7 +%436 = OpConstant %6 -8 +%29 = OpFunction %3 None %30 +%28 = OpLabel +OpBranch %35 +%35 = OpLabel +%36 = OpSelect %6 %31 %26 %32 +%38 = OpCompositeConstruct %7 %31 %31 %31 %31 +%37 = OpSelect %3 %38 %21 %23 +%39 = OpCompositeConstruct %7 %33 %33 %33 %33 +%40 = OpSelect %3 %39 %23 %21 +%41 = OpExtInst %3 %1 FMix %23 %21 %25 +%43 = OpCompositeConstruct %3 %34 %34 %34 %34 +%42 = OpExtInst %3 %1 FMix %23 %21 %43 +%44 = OpBitcast %4 %26 +%45 = OpBitcast %3 %27 +%46 = OpCompositeConstruct %5 %32 %32 %32 %32 +%47 = OpCompositeConstruct %5 %36 %36 %36 %36 +%48 = OpIAdd %5 %47 %46 +%49 = OpConvertSToF %3 %48 +%50 = OpFAdd %3 %49 %37 %51 = OpFAdd %3 %50 %41 -OpReturnValue %51 +%52 = OpFAdd %3 %51 %42 +%53 = OpCompositeConstruct %3 %44 %44 %44 %44 +%54 = OpFAdd %3 %52 %53 +%55 = OpFAdd %3 %54 %45 +OpReturnValue %55 OpFunctionEnd -%53 = OpFunction %3 None %25 -%52 = OpLabel -OpBranch %59 -%59 = OpLabel -%60 = OpCompositeConstruct %9 %54 %54 -%61 = OpCompositeConstruct %9 %15 %15 -%62 = OpFAdd %9 %61 %60 -%63 = OpCompositeConstruct %9 %55 %55 -%64 = OpFSub %9 %62 %63 -%65 = OpCompositeConstruct %9 %56 %56 -%66 = OpFDiv %9 %64 %65 -%67 = OpCompositeConstruct %5 %57 %57 %57 %57 -%68 = OpCompositeConstruct %5 %58 %58 %58 %58 -%69 = OpSRem %5 %67 %68 -%70 = OpVectorShuffle %3 %66 %66 0 1 0 1 -%71 = OpConvertSToF %3 %69 -%72 = OpFAdd %3 %70 %71 -OpReturnValue %72 +%57 = OpFunction %3 None %30 +%56 = OpLabel +OpBranch %63 +%63 = OpLabel +%64 = OpCompositeConstruct %9 %58 %58 +%65 = OpCompositeConstruct %9 %20 %20 +%66 = OpFAdd %9 %65 %64 +%67 = OpCompositeConstruct %9 %59 %59 +%68 = OpFSub %9 %66 %67 +%69 = OpCompositeConstruct %9 %60 %60 +%70 = OpFDiv %9 %68 %69 +%71 = OpCompositeConstruct %5 %61 %61 %61 %61 +%72 = OpCompositeConstruct %5 %62 %62 %62 %62 +%73 = OpSRem %5 %71 %72 +%74 = OpVectorShuffle %3 %70 %70 0 1 0 1 +%75 = OpConvertSToF %3 %73 +%76 = OpFAdd %3 %74 %75 +OpReturnValue %76 OpFunctionEnd -%77 = OpFunction %9 None %78 -%76 = OpLabel -%73 = OpVariable %74 Function %75 -OpBranch %79 -%79 = OpLabel -%80 = OpCompositeConstruct %9 %54 %54 -OpStore %73 %80 -%81 = OpLoad %9 %73 -%82 = OpCompositeConstruct %9 %15 %15 -%83 = OpFAdd %9 %81 %82 -OpStore %73 %83 -%84 = OpLoad %9 %73 -%85 = OpCompositeConstruct %9 %55 %55 -%86 = OpFSub %9 %84 %85 -OpStore %73 %86 -%87 = OpLoad %9 %73 -%88 = OpCompositeConstruct %9 %56 %56 -%89 = OpFDiv %9 %87 %88 -OpStore %73 %89 -%90 = OpLoad %9 %73 -OpReturnValue %90 +%81 = OpFunction %9 None %82 +%80 = OpLabel +%77 = OpVariable %78 Function %79 +OpBranch %83 +%83 = OpLabel +%84 = OpCompositeConstruct %9 %58 %58 +OpStore %77 %84 +%85 = OpLoad %9 %77 +%86 = OpCompositeConstruct %9 %20 %20 +%87 = OpFAdd %9 %85 %86 +OpStore %77 %87 +%88 = OpLoad %9 %77 +%89 = OpCompositeConstruct %9 %59 %59 +%90 = OpFSub %9 %88 %89 +OpStore %77 %90 +%91 = OpLoad %9 %77 +%92 = OpCompositeConstruct %9 %60 %60 +%93 = OpFDiv %9 %91 %92 +OpStore %77 %93 +%94 = OpLoad %9 %77 +OpReturnValue %94 OpFunctionEnd -%93 = OpFunction %10 None %94 -%92 = OpFunctionParameter %10 -%91 = OpLabel -OpBranch %95 +%97 = OpFunction %10 None %98 +%96 = OpFunctionParameter %10 %95 = OpLabel -%98 = OpFUnordNotEqual %96 %92 %97 -%100 = OpSelect %10 %98 %99 %97 -OpReturnValue %100 +OpBranch %99 +%99 = OpLabel +%102 = OpFUnordNotEqual %100 %96 %101 +%104 = OpSelect %10 %102 %103 %101 +OpReturnValue %104 OpFunctionEnd -%102 = OpFunction %2 None %103 -%101 = OpLabel -OpBranch %104 -%104 = OpLabel -%105 = OpLogicalNot %8 %26 -%107 = OpCompositeConstruct %106 %26 %26 -%108 = OpLogicalNot %106 %107 -%109 = OpLogicalOr %8 %26 %28 -%110 = OpLogicalAnd %8 %26 %28 -%111 = OpLogicalOr %8 %26 %28 -%112 = OpCompositeConstruct %96 %26 %26 %26 -%113 = OpCompositeConstruct %96 %28 %28 %28 -%114 = OpLogicalOr %96 %112 %113 -%115 = OpLogicalAnd %8 %26 %28 -%116 = OpCompositeConstruct %7 %26 %26 %26 %26 -%117 = OpCompositeConstruct %7 %28 %28 %28 %28 -%118 = OpLogicalAnd %7 %116 %117 +%106 = OpFunction %2 None %107 +%105 = OpLabel +OpBranch %108 +%108 = OpLabel +%109 = OpCompositeConstruct %11 %33 %33 +%110 = OpLogicalOr %8 %31 %33 +%111 = OpCompositeConstruct %100 %31 %31 %31 +%112 = OpCompositeConstruct %100 %33 %33 %33 +%113 = OpLogicalOr %100 %111 %112 +%114 = OpLogicalAnd %8 %31 %33 +%115 = OpCompositeConstruct %7 %31 %31 %31 %31 +%116 = OpCompositeConstruct %7 %33 %33 %33 %33 +%117 = OpLogicalAnd %7 %115 %116 OpReturn OpFunctionEnd -%120 = OpFunction %2 None %103 -%119 = OpLabel -OpBranch %128 -%128 = OpLabel -%130 = OpCompositeConstruct %129 %21 %21 -%131 = OpSNegate %129 %130 -%132 = OpCompositeConstruct %9 %15 %15 -%133 = OpFNegate %9 %132 -%134 = OpIAdd %6 %58 %21 -%135 = OpIAdd %122 %123 %124 -%136 = OpFAdd %4 %54 %15 -%137 = OpCompositeConstruct %129 %58 %58 -%138 = OpCompositeConstruct %129 %21 %21 -%139 = OpIAdd %129 %137 %138 -%141 = OpCompositeConstruct %140 %123 %123 %123 -%142 = OpCompositeConstruct %140 %124 %124 %124 -%143 = OpIAdd %140 %141 %142 -%144 = OpCompositeConstruct %3 %54 %54 %54 %54 -%145 = OpCompositeConstruct %3 %15 %15 %15 %15 -%146 = OpFAdd %3 %144 %145 -%147 = OpISub %6 %58 %21 -%148 = OpISub %122 %123 %124 -%149 = OpFSub %4 %54 %15 -%150 = OpCompositeConstruct %129 %58 %58 -%151 = OpCompositeConstruct %129 %21 %21 -%152 = OpISub %129 %150 %151 -%153 = OpCompositeConstruct %140 %123 %123 %123 -%154 = OpCompositeConstruct %140 %124 %124 %124 -%155 = OpISub %140 %153 %154 -%156 = OpCompositeConstruct %3 %54 %54 %54 %54 -%157 = OpCompositeConstruct %3 %15 %15 %15 %15 -%158 = OpFSub %3 %156 %157 -%159 = OpIMul %6 %58 %21 -%160 = OpIMul %122 %123 %124 -%161 = OpFMul %4 %54 %15 -%162 = OpCompositeConstruct %129 %58 %58 -%163 = OpCompositeConstruct %129 %21 %21 -%164 = OpIMul %129 %162 %163 -%165 = OpCompositeConstruct %140 %123 %123 %123 -%166 = OpCompositeConstruct %140 %124 %124 %124 -%167 = OpIMul %140 %165 %166 -%168 = OpCompositeConstruct %3 %54 %54 %54 %54 -%169 = OpCompositeConstruct %3 %15 %15 %15 %15 -%170 = OpFMul %3 %168 %169 -%171 = OpSDiv %6 %58 %21 -%172 = OpUDiv %122 %123 %124 -%173 = OpFDiv %4 %54 %15 -%174 = OpCompositeConstruct %129 %58 %58 -%175 = OpCompositeConstruct %129 %21 %21 -%176 = OpSDiv %129 %174 %175 -%177 = OpCompositeConstruct %140 %123 %123 %123 -%178 = OpCompositeConstruct %140 %124 %124 %124 -%179 = OpUDiv %140 %177 %178 -%180 = OpCompositeConstruct %3 %54 %54 %54 %54 -%181 = OpCompositeConstruct %3 %15 %15 %15 %15 -%182 = OpFDiv %3 %180 %181 -%183 = OpSRem %6 %58 %21 -%184 = OpUMod %122 %123 %124 -%185 = OpFRem %4 %54 %15 -%186 = OpCompositeConstruct %129 %58 %58 -%187 = OpCompositeConstruct %129 %21 %21 -%188 = OpSRem %129 %186 %187 -%189 = OpCompositeConstruct %140 %123 %123 %123 -%190 = OpCompositeConstruct %140 %124 %124 %124 -%191 = OpUMod %140 %189 %190 -%192 = OpCompositeConstruct %3 %54 %54 %54 %54 -%193 = OpCompositeConstruct %3 %15 %15 %15 %15 -%194 = OpFRem %3 %192 %193 -OpBranch %195 -%195 = OpLabel -%197 = OpCompositeConstruct %129 %58 %58 -%198 = OpCompositeConstruct %129 %21 %21 -%199 = OpIAdd %129 %197 %198 -%200 = OpCompositeConstruct %129 %21 %21 -%201 = OpCompositeConstruct %129 %58 %58 -%202 = OpIAdd %129 %201 %200 -%204 = OpCompositeConstruct %203 %123 %123 -%205 = OpCompositeConstruct %203 %124 %124 -%206 = OpIAdd %203 %204 %205 -%207 = OpCompositeConstruct %203 %124 %124 -%208 = OpCompositeConstruct %203 %123 %123 -%209 = OpIAdd %203 %208 %207 -%210 = OpCompositeConstruct %9 %54 %54 -%211 = OpCompositeConstruct %9 %15 %15 -%212 = OpFAdd %9 %210 %211 -%213 = OpCompositeConstruct %9 %15 %15 -%214 = OpCompositeConstruct %9 %54 %54 -%215 = OpFAdd %9 %214 %213 -%216 = OpCompositeConstruct %129 %58 %58 -%217 = OpCompositeConstruct %129 %21 %21 -%218 = OpISub %129 %216 %217 -%219 = OpCompositeConstruct %129 %21 %21 -%220 = OpCompositeConstruct %129 %58 %58 -%221 = OpISub %129 %220 %219 -%222 = OpCompositeConstruct %203 %123 %123 -%223 = OpCompositeConstruct %203 %124 %124 -%224 = OpISub %203 %222 %223 -%225 = OpCompositeConstruct %203 %124 %124 -%226 = OpCompositeConstruct %203 %123 %123 -%227 = OpISub %203 %226 %225 -%228 = OpCompositeConstruct %9 %54 %54 -%229 = OpCompositeConstruct %9 %15 %15 -%230 = OpFSub %9 %228 %229 -%231 = OpCompositeConstruct %9 %15 %15 -%232 = OpCompositeConstruct %9 %54 %54 -%233 = OpFSub %9 %232 %231 -%234 = OpCompositeConstruct %129 %58 %58 -%236 = OpCompositeConstruct %129 %21 %21 -%235 = OpIMul %129 %234 %236 -%237 = OpCompositeConstruct %129 %21 %21 -%239 = OpCompositeConstruct %129 %58 %58 -%238 = OpIMul %129 %237 %239 -%240 = OpCompositeConstruct %203 %123 %123 -%242 = OpCompositeConstruct %203 %124 %124 -%241 = OpIMul %203 %240 %242 -%243 = OpCompositeConstruct %203 %124 %124 -%245 = OpCompositeConstruct %203 %123 %123 -%244 = OpIMul %203 %243 %245 -%246 = OpCompositeConstruct %9 %54 %54 -%247 = OpVectorTimesScalar %9 %246 %15 -%248 = OpCompositeConstruct %9 %15 %15 -%249 = OpVectorTimesScalar %9 %248 %54 -%250 = OpCompositeConstruct %129 %58 %58 -%251 = OpCompositeConstruct %129 %21 %21 -%252 = OpSDiv %129 %250 %251 -%253 = OpCompositeConstruct %129 %21 %21 -%254 = OpCompositeConstruct %129 %58 %58 -%255 = OpSDiv %129 %254 %253 -%256 = OpCompositeConstruct %203 %123 %123 -%257 = OpCompositeConstruct %203 %124 %124 -%258 = OpUDiv %203 %256 %257 -%259 = OpCompositeConstruct %203 %124 %124 -%260 = OpCompositeConstruct %203 %123 %123 -%261 = OpUDiv %203 %260 %259 -%262 = OpCompositeConstruct %9 %54 %54 -%263 = OpCompositeConstruct %9 %15 %15 -%264 = OpFDiv %9 %262 %263 -%265 = OpCompositeConstruct %9 %15 %15 -%266 = OpCompositeConstruct %9 %54 %54 -%267 = OpFDiv %9 %266 %265 -%268 = OpCompositeConstruct %129 %58 %58 -%269 = OpCompositeConstruct %129 %21 %21 -%270 = OpSRem %129 %268 %269 -%271 = OpCompositeConstruct %129 %21 %21 -%272 = OpCompositeConstruct %129 %58 %58 -%273 = OpSRem %129 %272 %271 -%274 = OpCompositeConstruct %203 %123 %123 -%275 = OpCompositeConstruct %203 %124 %124 -%276 = OpUMod %203 %274 %275 -%277 = OpCompositeConstruct %203 %124 %124 -%278 = OpCompositeConstruct %203 %123 %123 -%279 = OpUMod %203 %278 %277 -%280 = OpCompositeConstruct %9 %54 %54 -%281 = OpCompositeConstruct %9 %15 %15 -%282 = OpFRem %9 %280 %281 -%283 = OpCompositeConstruct %9 %15 %15 -%284 = OpCompositeConstruct %9 %54 %54 -%285 = OpFRem %9 %284 %283 -OpBranch %196 -%196 = OpLabel -%287 = OpCompositeExtract %10 %125 0 -%288 = OpCompositeExtract %10 %125 0 -%289 = OpFAdd %10 %287 %288 -%290 = OpCompositeExtract %10 %125 1 -%291 = OpCompositeExtract %10 %125 1 -%292 = OpFAdd %10 %290 %291 -%293 = OpCompositeExtract %10 %125 2 -%294 = OpCompositeExtract %10 %125 2 -%295 = OpFAdd %10 %293 %294 -%286 = OpCompositeConstruct %11 %289 %292 %295 -%297 = OpCompositeExtract %10 %125 0 -%298 = OpCompositeExtract %10 %125 0 -%299 = OpFSub %10 %297 %298 -%300 = OpCompositeExtract %10 %125 1 -%301 = OpCompositeExtract %10 %125 1 -%302 = OpFSub %10 %300 %301 -%303 = OpCompositeExtract %10 %125 2 -%304 = OpCompositeExtract %10 %125 2 -%305 = OpFSub %10 %303 %304 -%296 = OpCompositeConstruct %11 %299 %302 %305 -%306 = OpMatrixTimesScalar %11 %125 %15 -%307 = OpMatrixTimesScalar %11 %125 %54 -%308 = OpCompositeConstruct %3 %15 %15 %15 %15 -%309 = OpMatrixTimesVector %10 %126 %308 -%310 = OpCompositeConstruct %10 %54 %54 %54 -%311 = OpVectorTimesMatrix %3 %310 %126 -%312 = OpMatrixTimesMatrix %11 %126 %127 +%119 = OpFunction %2 None %107 +%118 = OpLabel +OpBranch %130 +%130 = OpLabel +%131 = OpCompositeConstruct %12 %121 %121 +%132 = OpCompositeConstruct %9 %120 %120 +%133 = OpCompositeConstruct %12 %62 %62 +%134 = OpCompositeConstruct %12 %26 %26 +%135 = OpIAdd %12 %133 %134 +%136 = OpCompositeConstruct %13 %124 %124 %124 +%137 = OpCompositeConstruct %13 %125 %125 %125 +%138 = OpIAdd %13 %136 %137 +%139 = OpCompositeConstruct %3 %58 %58 %58 %58 +%140 = OpCompositeConstruct %3 %20 %20 %20 %20 +%141 = OpFAdd %3 %139 %140 +%142 = OpCompositeConstruct %12 %62 %62 +%143 = OpCompositeConstruct %12 %26 %26 +%144 = OpISub %12 %142 %143 +%145 = OpCompositeConstruct %13 %124 %124 %124 +%146 = OpCompositeConstruct %13 %125 %125 %125 +%147 = OpISub %13 %145 %146 +%148 = OpCompositeConstruct %3 %58 %58 %58 %58 +%149 = OpCompositeConstruct %3 %20 %20 %20 %20 +%150 = OpFSub %3 %148 %149 +%151 = OpCompositeConstruct %12 %62 %62 +%152 = OpCompositeConstruct %12 %26 %26 +%153 = OpIMul %12 %151 %152 +%154 = OpCompositeConstruct %13 %124 %124 %124 +%155 = OpCompositeConstruct %13 %125 %125 %125 +%156 = OpIMul %13 %154 %155 +%157 = OpCompositeConstruct %3 %58 %58 %58 %58 +%158 = OpCompositeConstruct %3 %20 %20 %20 %20 +%159 = OpFMul %3 %157 %158 +%160 = OpCompositeConstruct %12 %62 %62 +%161 = OpCompositeConstruct %12 %26 %26 +%162 = OpSDiv %12 %160 %161 +%163 = OpCompositeConstruct %13 %124 %124 %124 +%164 = OpCompositeConstruct %13 %125 %125 %125 +%165 = OpUDiv %13 %163 %164 +%166 = OpCompositeConstruct %3 %58 %58 %58 %58 +%167 = OpCompositeConstruct %3 %20 %20 %20 %20 +%168 = OpFDiv %3 %166 %167 +%169 = OpCompositeConstruct %12 %62 %62 +%170 = OpCompositeConstruct %12 %26 %26 +%171 = OpSRem %12 %169 %170 +%172 = OpCompositeConstruct %13 %124 %124 %124 +%173 = OpCompositeConstruct %13 %125 %125 %125 +%174 = OpUMod %13 %172 %173 +%175 = OpCompositeConstruct %3 %58 %58 %58 %58 +%176 = OpCompositeConstruct %3 %20 %20 %20 %20 +%177 = OpFRem %3 %175 %176 +OpBranch %178 +%178 = OpLabel +%180 = OpCompositeConstruct %12 %62 %62 +%181 = OpCompositeConstruct %12 %26 %26 +%182 = OpIAdd %12 %180 %181 +%183 = OpCompositeConstruct %12 %26 %26 +%184 = OpCompositeConstruct %12 %62 %62 +%185 = OpIAdd %12 %184 %183 +%186 = OpCompositeConstruct %15 %124 %124 +%187 = OpCompositeConstruct %15 %125 %125 +%188 = OpIAdd %15 %186 %187 +%189 = OpCompositeConstruct %15 %125 %125 +%190 = OpCompositeConstruct %15 %124 %124 +%191 = OpIAdd %15 %190 %189 +%192 = OpCompositeConstruct %9 %58 %58 +%193 = OpCompositeConstruct %9 %20 %20 +%194 = OpFAdd %9 %192 %193 +%195 = OpCompositeConstruct %9 %20 %20 +%196 = OpCompositeConstruct %9 %58 %58 +%197 = OpFAdd %9 %196 %195 +%198 = OpCompositeConstruct %12 %62 %62 +%199 = OpCompositeConstruct %12 %26 %26 +%200 = OpISub %12 %198 %199 +%201 = OpCompositeConstruct %12 %26 %26 +%202 = OpCompositeConstruct %12 %62 %62 +%203 = OpISub %12 %202 %201 +%204 = OpCompositeConstruct %15 %124 %124 +%205 = OpCompositeConstruct %15 %125 %125 +%206 = OpISub %15 %204 %205 +%207 = OpCompositeConstruct %15 %125 %125 +%208 = OpCompositeConstruct %15 %124 %124 +%209 = OpISub %15 %208 %207 +%210 = OpCompositeConstruct %9 %58 %58 +%211 = OpCompositeConstruct %9 %20 %20 +%212 = OpFSub %9 %210 %211 +%213 = OpCompositeConstruct %9 %20 %20 +%214 = OpCompositeConstruct %9 %58 %58 +%215 = OpFSub %9 %214 %213 +%216 = OpCompositeConstruct %12 %62 %62 +%217 = OpCompositeConstruct %12 %62 %62 +%218 = OpCompositeConstruct %15 %124 %124 +%219 = OpCompositeConstruct %15 %124 %124 +%220 = OpCompositeConstruct %9 %58 %58 +%221 = OpCompositeConstruct %9 %58 %58 +%222 = OpCompositeConstruct %12 %62 %62 +%223 = OpCompositeConstruct %12 %26 %26 +%224 = OpSDiv %12 %222 %223 +%225 = OpCompositeConstruct %12 %26 %26 +%226 = OpCompositeConstruct %12 %62 %62 +%227 = OpSDiv %12 %226 %225 +%228 = OpCompositeConstruct %15 %124 %124 +%229 = OpCompositeConstruct %15 %125 %125 +%230 = OpUDiv %15 %228 %229 +%231 = OpCompositeConstruct %15 %125 %125 +%232 = OpCompositeConstruct %15 %124 %124 +%233 = OpUDiv %15 %232 %231 +%234 = OpCompositeConstruct %9 %58 %58 +%235 = OpCompositeConstruct %9 %20 %20 +%236 = OpFDiv %9 %234 %235 +%237 = OpCompositeConstruct %9 %20 %20 +%238 = OpCompositeConstruct %9 %58 %58 +%239 = OpFDiv %9 %238 %237 +%240 = OpCompositeConstruct %12 %62 %62 +%241 = OpCompositeConstruct %12 %26 %26 +%242 = OpSRem %12 %240 %241 +%243 = OpCompositeConstruct %12 %26 %26 +%244 = OpCompositeConstruct %12 %62 %62 +%245 = OpSRem %12 %244 %243 +%246 = OpCompositeConstruct %15 %124 %124 +%247 = OpCompositeConstruct %15 %125 %125 +%248 = OpUMod %15 %246 %247 +%249 = OpCompositeConstruct %15 %125 %125 +%250 = OpCompositeConstruct %15 %124 %124 +%251 = OpUMod %15 %250 %249 +%252 = OpCompositeConstruct %9 %58 %58 +%253 = OpCompositeConstruct %9 %20 %20 +%254 = OpFRem %9 %252 %253 +%255 = OpCompositeConstruct %9 %20 %20 +%256 = OpCompositeConstruct %9 %58 %58 +%257 = OpFRem %9 %256 %255 +OpBranch %179 +%179 = OpLabel +%259 = OpCompositeExtract %10 %127 0 +%260 = OpCompositeExtract %10 %127 0 +%261 = OpFAdd %10 %259 %260 +%262 = OpCompositeExtract %10 %127 1 +%263 = OpCompositeExtract %10 %127 1 +%264 = OpFAdd %10 %262 %263 +%265 = OpCompositeExtract %10 %127 2 +%266 = OpCompositeExtract %10 %127 2 +%267 = OpFAdd %10 %265 %266 +%258 = OpCompositeConstruct %16 %261 %264 %267 +%269 = OpCompositeExtract %10 %127 0 +%270 = OpCompositeExtract %10 %127 0 +%271 = OpFSub %10 %269 %270 +%272 = OpCompositeExtract %10 %127 1 +%273 = OpCompositeExtract %10 %127 1 +%274 = OpFSub %10 %272 %273 +%275 = OpCompositeExtract %10 %127 2 +%276 = OpCompositeExtract %10 %127 2 +%277 = OpFSub %10 %275 %276 +%268 = OpCompositeConstruct %16 %271 %274 %277 +%278 = OpCompositeConstruct %10 %22 %22 %22 +%279 = OpCompositeConstruct %10 %22 %22 %22 +%280 = OpCompositeConstruct %10 %22 %22 %22 +%281 = OpCompositeConstruct %16 %278 %279 %280 +%282 = OpCompositeConstruct %10 %22 %22 %22 +%283 = OpCompositeConstruct %10 %22 %22 %22 +%284 = OpCompositeConstruct %10 %22 %22 %22 +%285 = OpCompositeConstruct %16 %282 %283 %284 +%286 = OpCompositeConstruct %3 %20 %20 %20 %20 +%287 = OpMatrixTimesVector %10 %128 %286 +%288 = OpCompositeConstruct %10 %58 %58 %58 +%289 = OpVectorTimesMatrix %3 %288 %128 +%290 = OpMatrixTimesMatrix %16 %128 %129 OpReturn OpFunctionEnd -%314 = OpFunction %2 None %103 -%313 = OpLabel -OpBranch %315 -%315 = OpLabel -%316 = OpNot %6 %21 -%317 = OpNot %122 %124 -%318 = OpCompositeConstruct %129 %21 %21 -%319 = OpNot %129 %318 -%320 = OpCompositeConstruct %140 %124 %124 %124 -%321 = OpNot %140 %320 -%322 = OpBitwiseOr %6 %58 %21 -%323 = OpBitwiseOr %122 %123 %124 -%324 = OpCompositeConstruct %129 %58 %58 -%325 = OpCompositeConstruct %129 %21 %21 -%326 = OpBitwiseOr %129 %324 %325 -%327 = OpCompositeConstruct %140 %123 %123 %123 -%328 = OpCompositeConstruct %140 %124 %124 %124 -%329 = OpBitwiseOr %140 %327 %328 -%330 = OpBitwiseAnd %6 %58 %21 -%331 = OpBitwiseAnd %122 %123 %124 -%332 = OpCompositeConstruct %129 %58 %58 -%333 = OpCompositeConstruct %129 %21 %21 -%334 = OpBitwiseAnd %129 %332 %333 -%335 = OpCompositeConstruct %140 %123 %123 %123 -%336 = OpCompositeConstruct %140 %124 %124 %124 -%337 = OpBitwiseAnd %140 %335 %336 -%338 = OpBitwiseXor %6 %58 %21 -%339 = OpBitwiseXor %122 %123 %124 -%340 = OpCompositeConstruct %129 %58 %58 -%341 = OpCompositeConstruct %129 %21 %21 -%342 = OpBitwiseXor %129 %340 %341 -%343 = OpCompositeConstruct %140 %123 %123 %123 -%344 = OpCompositeConstruct %140 %124 %124 %124 -%345 = OpBitwiseXor %140 %343 %344 -%346 = OpShiftLeftLogical %6 %58 %124 -%347 = OpShiftLeftLogical %122 %123 %124 -%348 = OpCompositeConstruct %129 %58 %58 -%349 = OpCompositeConstruct %203 %124 %124 -%350 = OpShiftLeftLogical %129 %348 %349 -%351 = OpCompositeConstruct %140 %123 %123 %123 -%352 = OpCompositeConstruct %140 %124 %124 %124 -%353 = OpShiftLeftLogical %140 %351 %352 -%354 = OpShiftRightArithmetic %6 %58 %124 -%355 = OpShiftRightLogical %122 %123 %124 -%356 = OpCompositeConstruct %129 %58 %58 -%357 = OpCompositeConstruct %203 %124 %124 -%358 = OpShiftRightArithmetic %129 %356 %357 -%359 = OpCompositeConstruct %140 %123 %123 %123 -%360 = OpCompositeConstruct %140 %124 %124 %124 -%361 = OpShiftRightLogical %140 %359 %360 +%292 = OpFunction %2 None %107 +%291 = OpLabel +OpBranch %297 +%297 = OpLabel +%298 = OpCompositeConstruct %12 %293 %293 +%299 = OpCompositeConstruct %13 %294 %294 %294 +%300 = OpCompositeConstruct %12 %62 %62 +%301 = OpCompositeConstruct %12 %26 %26 +%302 = OpBitwiseOr %12 %300 %301 +%303 = OpCompositeConstruct %13 %124 %124 %124 +%304 = OpCompositeConstruct %13 %125 %125 %125 +%305 = OpBitwiseOr %13 %303 %304 +%306 = OpCompositeConstruct %12 %62 %62 +%307 = OpCompositeConstruct %12 %26 %26 +%308 = OpBitwiseAnd %12 %306 %307 +%309 = OpCompositeConstruct %13 %124 %124 %124 +%310 = OpCompositeConstruct %13 %125 %125 %125 +%311 = OpBitwiseAnd %13 %309 %310 +%312 = OpCompositeConstruct %12 %62 %62 +%313 = OpCompositeConstruct %12 %26 %26 +%314 = OpBitwiseXor %12 %312 %313 +%315 = OpCompositeConstruct %13 %124 %124 %124 +%316 = OpCompositeConstruct %13 %125 %125 %125 +%317 = OpBitwiseXor %13 %315 %316 +%318 = OpCompositeConstruct %12 %62 %62 +%319 = OpCompositeConstruct %15 %125 %125 +%320 = OpShiftLeftLogical %12 %318 %319 +%321 = OpCompositeConstruct %13 %124 %124 %124 +%322 = OpCompositeConstruct %13 %125 %125 %125 +%323 = OpShiftLeftLogical %13 %321 %322 +%324 = OpCompositeConstruct %12 %62 %62 +%325 = OpCompositeConstruct %15 %125 %125 +%326 = OpShiftRightArithmetic %12 %324 %325 +%327 = OpCompositeConstruct %13 %124 %124 %124 +%328 = OpCompositeConstruct %13 %125 %125 %125 +%329 = OpShiftRightLogical %13 %327 %328 OpReturn OpFunctionEnd -%363 = OpFunction %2 None %103 -%362 = OpLabel -OpBranch %364 -%364 = OpLabel -%365 = OpIEqual %8 %58 %21 -%366 = OpIEqual %8 %123 %124 -%367 = OpFOrdEqual %8 %54 %15 -%368 = OpCompositeConstruct %129 %58 %58 -%369 = OpCompositeConstruct %129 %21 %21 -%370 = OpIEqual %106 %368 %369 -%371 = OpCompositeConstruct %140 %123 %123 %123 -%372 = OpCompositeConstruct %140 %124 %124 %124 -%373 = OpIEqual %96 %371 %372 -%374 = OpCompositeConstruct %3 %54 %54 %54 %54 -%375 = OpCompositeConstruct %3 %15 %15 %15 %15 -%376 = OpFOrdEqual %7 %374 %375 -%377 = OpINotEqual %8 %58 %21 -%378 = OpINotEqual %8 %123 %124 -%379 = OpFOrdNotEqual %8 %54 %15 -%380 = OpCompositeConstruct %129 %58 %58 -%381 = OpCompositeConstruct %129 %21 %21 -%382 = OpINotEqual %106 %380 %381 -%383 = OpCompositeConstruct %140 %123 %123 %123 -%384 = OpCompositeConstruct %140 %124 %124 %124 -%385 = OpINotEqual %96 %383 %384 -%386 = OpCompositeConstruct %3 %54 %54 %54 %54 -%387 = OpCompositeConstruct %3 %15 %15 %15 %15 -%388 = OpFOrdNotEqual %7 %386 %387 -%389 = OpSLessThan %8 %58 %21 -%390 = OpULessThan %8 %123 %124 -%391 = OpFOrdLessThan %8 %54 %15 -%392 = OpCompositeConstruct %129 %58 %58 -%393 = OpCompositeConstruct %129 %21 %21 -%394 = OpSLessThan %106 %392 %393 -%395 = OpCompositeConstruct %140 %123 %123 %123 -%396 = OpCompositeConstruct %140 %124 %124 %124 -%397 = OpULessThan %96 %395 %396 -%398 = OpCompositeConstruct %3 %54 %54 %54 %54 -%399 = OpCompositeConstruct %3 %15 %15 %15 %15 -%400 = OpFOrdLessThan %7 %398 %399 -%401 = OpSLessThanEqual %8 %58 %21 -%402 = OpULessThanEqual %8 %123 %124 -%403 = OpFOrdLessThanEqual %8 %54 %15 -%404 = OpCompositeConstruct %129 %58 %58 -%405 = OpCompositeConstruct %129 %21 %21 -%406 = OpSLessThanEqual %106 %404 %405 -%407 = OpCompositeConstruct %140 %123 %123 %123 -%408 = OpCompositeConstruct %140 %124 %124 %124 -%409 = OpULessThanEqual %96 %407 %408 -%410 = OpCompositeConstruct %3 %54 %54 %54 %54 -%411 = OpCompositeConstruct %3 %15 %15 %15 %15 -%412 = OpFOrdLessThanEqual %7 %410 %411 -%413 = OpSGreaterThan %8 %58 %21 -%414 = OpUGreaterThan %8 %123 %124 -%415 = OpFOrdGreaterThan %8 %54 %15 -%416 = OpCompositeConstruct %129 %58 %58 -%417 = OpCompositeConstruct %129 %21 %21 -%418 = OpSGreaterThan %106 %416 %417 -%419 = OpCompositeConstruct %140 %123 %123 %123 -%420 = OpCompositeConstruct %140 %124 %124 %124 -%421 = OpUGreaterThan %96 %419 %420 -%422 = OpCompositeConstruct %3 %54 %54 %54 %54 -%423 = OpCompositeConstruct %3 %15 %15 %15 %15 -%424 = OpFOrdGreaterThan %7 %422 %423 -%425 = OpSGreaterThanEqual %8 %58 %21 -%426 = OpUGreaterThanEqual %8 %123 %124 -%427 = OpFOrdGreaterThanEqual %8 %54 %15 -%428 = OpCompositeConstruct %129 %58 %58 -%429 = OpCompositeConstruct %129 %21 %21 -%430 = OpSGreaterThanEqual %106 %428 %429 -%431 = OpCompositeConstruct %140 %123 %123 %123 -%432 = OpCompositeConstruct %140 %124 %124 %124 -%433 = OpUGreaterThanEqual %96 %431 %432 -%434 = OpCompositeConstruct %3 %54 %54 %54 %54 -%435 = OpCompositeConstruct %3 %15 %15 %15 %15 -%436 = OpFOrdGreaterThanEqual %7 %434 %435 +%331 = OpFunction %2 None %107 +%330 = OpLabel +OpBranch %332 +%332 = OpLabel +%333 = OpCompositeConstruct %12 %62 %62 +%334 = OpCompositeConstruct %12 %26 %26 +%335 = OpIEqual %11 %333 %334 +%336 = OpCompositeConstruct %13 %124 %124 %124 +%337 = OpCompositeConstruct %13 %125 %125 %125 +%338 = OpIEqual %100 %336 %337 +%339 = OpCompositeConstruct %3 %58 %58 %58 %58 +%340 = OpCompositeConstruct %3 %20 %20 %20 %20 +%341 = OpFOrdEqual %7 %339 %340 +%342 = OpCompositeConstruct %12 %62 %62 +%343 = OpCompositeConstruct %12 %26 %26 +%344 = OpINotEqual %11 %342 %343 +%345 = OpCompositeConstruct %13 %124 %124 %124 +%346 = OpCompositeConstruct %13 %125 %125 %125 +%347 = OpINotEqual %100 %345 %346 +%348 = OpCompositeConstruct %3 %58 %58 %58 %58 +%349 = OpCompositeConstruct %3 %20 %20 %20 %20 +%350 = OpFOrdNotEqual %7 %348 %349 +%351 = OpCompositeConstruct %12 %62 %62 +%352 = OpCompositeConstruct %12 %26 %26 +%353 = OpSLessThan %11 %351 %352 +%354 = OpCompositeConstruct %13 %124 %124 %124 +%355 = OpCompositeConstruct %13 %125 %125 %125 +%356 = OpULessThan %100 %354 %355 +%357 = OpCompositeConstruct %3 %58 %58 %58 %58 +%358 = OpCompositeConstruct %3 %20 %20 %20 %20 +%359 = OpFOrdLessThan %7 %357 %358 +%360 = OpCompositeConstruct %12 %62 %62 +%361 = OpCompositeConstruct %12 %26 %26 +%362 = OpSLessThanEqual %11 %360 %361 +%363 = OpCompositeConstruct %13 %124 %124 %124 +%364 = OpCompositeConstruct %13 %125 %125 %125 +%365 = OpULessThanEqual %100 %363 %364 +%366 = OpCompositeConstruct %3 %58 %58 %58 %58 +%367 = OpCompositeConstruct %3 %20 %20 %20 %20 +%368 = OpFOrdLessThanEqual %7 %366 %367 +%369 = OpCompositeConstruct %12 %62 %62 +%370 = OpCompositeConstruct %12 %26 %26 +%371 = OpSGreaterThan %11 %369 %370 +%372 = OpCompositeConstruct %13 %124 %124 %124 +%373 = OpCompositeConstruct %13 %125 %125 %125 +%374 = OpUGreaterThan %100 %372 %373 +%375 = OpCompositeConstruct %3 %58 %58 %58 %58 +%376 = OpCompositeConstruct %3 %20 %20 %20 %20 +%377 = OpFOrdGreaterThan %7 %375 %376 +%378 = OpCompositeConstruct %12 %62 %62 +%379 = OpCompositeConstruct %12 %26 %26 +%380 = OpSGreaterThanEqual %11 %378 %379 +%381 = OpCompositeConstruct %13 %124 %124 %124 +%382 = OpCompositeConstruct %13 %125 %125 %125 +%383 = OpUGreaterThanEqual %100 %381 %382 +%384 = OpCompositeConstruct %3 %58 %58 %58 %58 +%385 = OpCompositeConstruct %3 %20 %20 %20 %20 +%386 = OpFOrdGreaterThanEqual %7 %384 %385 OpReturn OpFunctionEnd -%444 = OpFunction %2 None %103 -%443 = OpLabel -%437 = OpVariable %438 Function %439 -%440 = OpVariable %441 Function %442 -OpBranch %445 -%445 = OpLabel -OpStore %437 %21 -%446 = OpLoad %6 %437 -%447 = OpIAdd %6 %446 %21 -OpStore %437 %447 -%448 = OpLoad %6 %437 -%449 = OpISub %6 %448 %21 -OpStore %437 %449 -%450 = OpLoad %6 %437 -%451 = OpLoad %6 %437 -%452 = OpIMul %6 %451 %450 -OpStore %437 %452 -%453 = OpLoad %6 %437 -%454 = OpLoad %6 %437 -%455 = OpSDiv %6 %454 %453 -OpStore %437 %455 -%456 = OpLoad %6 %437 -%457 = OpSRem %6 %456 %21 -OpStore %437 %457 -%458 = OpLoad %6 %437 -%459 = OpBitwiseAnd %6 %458 %27 -OpStore %437 %459 -%460 = OpLoad %6 %437 -%461 = OpBitwiseOr %6 %460 %27 -OpStore %437 %461 -%462 = OpLoad %6 %437 -%463 = OpBitwiseXor %6 %462 %27 -OpStore %437 %463 -%464 = OpLoad %6 %437 -%465 = OpShiftLeftLogical %6 %464 %123 -OpStore %437 %465 -%466 = OpLoad %6 %437 -%467 = OpShiftRightArithmetic %6 %466 %124 -OpStore %437 %467 -%468 = OpLoad %6 %437 -%469 = OpIAdd %6 %468 %21 -OpStore %437 %469 -%470 = OpLoad %6 %437 -%471 = OpISub %6 %470 %21 -OpStore %437 %471 -OpStore %440 %442 -%473 = OpAccessChain %472 %440 %124 -%474 = OpLoad %6 %473 -%475 = OpIAdd %6 %474 %21 -%476 = OpAccessChain %472 %440 %124 -OpStore %476 %475 -%477 = OpAccessChain %472 %440 %124 -%478 = OpLoad %6 %477 -%479 = OpISub %6 %478 %21 -%480 = OpAccessChain %472 %440 %124 -OpStore %480 %479 +%394 = OpFunction %2 None %107 +%393 = OpLabel +%387 = OpVariable %388 Function %389 +%390 = OpVariable %391 Function %392 +OpBranch %395 +%395 = OpLabel +OpStore %387 %26 +%396 = OpLoad %6 %387 +%397 = OpIAdd %6 %396 %26 +OpStore %387 %397 +%398 = OpLoad %6 %387 +%399 = OpISub %6 %398 %26 +OpStore %387 %399 +%400 = OpLoad %6 %387 +%401 = OpLoad %6 %387 +%402 = OpIMul %6 %401 %400 +OpStore %387 %402 +%403 = OpLoad %6 %387 +%404 = OpLoad %6 %387 +%405 = OpSDiv %6 %404 %403 +OpStore %387 %405 +%406 = OpLoad %6 %387 +%407 = OpSRem %6 %406 %26 +OpStore %387 %407 +%408 = OpLoad %6 %387 +%409 = OpBitwiseAnd %6 %408 %32 +OpStore %387 %409 +%410 = OpLoad %6 %387 +%411 = OpBitwiseOr %6 %410 %32 +OpStore %387 %411 +%412 = OpLoad %6 %387 +%413 = OpBitwiseXor %6 %412 %32 +OpStore %387 %413 +%414 = OpLoad %6 %387 +%415 = OpShiftLeftLogical %6 %414 %124 +OpStore %387 %415 +%416 = OpLoad %6 %387 +%417 = OpShiftRightArithmetic %6 %416 %125 +OpStore %387 %417 +%418 = OpLoad %6 %387 +%419 = OpIAdd %6 %418 %26 +OpStore %387 %419 +%420 = OpLoad %6 %387 +%421 = OpISub %6 %420 %26 +OpStore %387 %421 +OpStore %390 %392 +%423 = OpAccessChain %422 %390 %125 +%424 = OpLoad %6 %423 +%425 = OpIAdd %6 %424 %26 +%426 = OpAccessChain %422 %390 %125 +OpStore %426 %425 +%427 = OpAccessChain %422 %390 %125 +%428 = OpLoad %6 %427 +%429 = OpISub %6 %428 %26 +%430 = OpAccessChain %422 %390 %125 +OpStore %430 %429 OpReturn OpFunctionEnd -%482 = OpFunction %2 None %103 -%481 = OpLabel -OpBranch %491 -%491 = OpLabel -%492 = OpSNegate %6 %484 -%493 = OpSNegate %6 %485 -%494 = OpSNegate %6 %486 -%495 = OpSNegate %6 %494 -%496 = OpSNegate %6 %487 -%497 = OpSNegate %6 %496 -%498 = OpSNegate %6 %488 -%499 = OpSNegate %6 %498 -%500 = OpSNegate %6 %499 -%501 = OpSNegate %6 %500 -%502 = OpSNegate %6 %489 -%503 = OpSNegate %6 %502 -%504 = OpSNegate %6 %503 -%505 = OpSNegate %6 %504 -%506 = OpSNegate %6 %490 -%507 = OpSNegate %6 %506 -%508 = OpSNegate %6 %507 -%509 = OpSNegate %6 %508 +%432 = OpFunction %2 None %107 +%431 = OpLabel +OpBranch %437 +%437 = OpLabel OpReturn OpFunctionEnd -%511 = OpFunction %2 None %103 -%510 = OpLabel -OpBranch %512 -%512 = OpLabel -%513 = OpFunctionCall %3 %24 -%514 = OpFunctionCall %3 %53 -%515 = OpVectorShuffle %10 %16 %16 0 1 2 -%516 = OpFunctionCall %10 %93 %515 -%517 = OpFunctionCall %2 %102 -%518 = OpFunctionCall %2 %120 -%519 = OpFunctionCall %2 %314 -%520 = OpFunctionCall %2 %363 -%521 = OpFunctionCall %2 %444 +%439 = OpFunction %2 None %107 +%438 = OpLabel +OpBranch %440 +%440 = OpLabel +%441 = OpFunctionCall %3 %29 +%442 = OpFunctionCall %3 %57 +%443 = OpCompositeConstruct %10 %20 %20 %20 +%444 = OpFunctionCall %10 %97 %443 +%445 = OpFunctionCall %2 %106 +%446 = OpFunctionCall %2 %119 +%447 = OpFunctionCall %2 %292 +%448 = OpFunctionCall %2 %331 +%449 = OpFunctionCall %2 %394 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/constructors.wgsl b/tests/out/wgsl/constructors.wgsl index 6ed0e50907..f15bcb6c8d 100644 --- a/tests/out/wgsl/constructors.wgsl +++ b/tests/out/wgsl/constructors.wgsl @@ -27,11 +27,8 @@ fn main() { let cit1_ = mat2x2(vec2(0.0), vec2(0.0)); let cit2_ = array(0, 1, 2, 3); let ic0_ = bool(bool()); - let ic1_ = i32(i32()); - let ic2_ = u32(u32()); - let ic3_ = f32(f32()); - let ic4_ = vec2(vec2()); - let ic5_ = mat2x3(mat2x3()); + let ic4_ = vec2(0u, 0u); + let ic5_ = mat2x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); let ic6_ = bitcast>(vec2()); let ic7_ = mat2x3(mat2x3()); } diff --git a/tests/out/wgsl/image.wgsl b/tests/out/wgsl/image.wgsl index 062d377139..6dfa0dbac7 100644 --- a/tests/out/wgsl/image.wgsl +++ b/tests/out/wgsl/image.wgsl @@ -112,74 +112,74 @@ fn texture_sample() -> @location(0) vec4 { let tc = vec2(0.5); let tc3_ = vec3(0.5); - let _e9 = textureSample(image_1d, sampler_reg, tc.x); - let _e10 = a; - a = (_e10 + _e9); - let _e14 = textureSample(image_2d, sampler_reg, tc); - let _e15 = a; - a = (_e15 + _e14); - let _e19 = textureSample(image_2d, sampler_reg, tc, vec2(3, 1)); - let _e20 = a; - a = (_e20 + _e19); - let _e24 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3); - let _e25 = a; - a = (_e25 + _e24); - let _e29 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3, vec2(3, 1)); - let _e30 = a; - a = (_e30 + _e29); - let _e35 = textureSampleBias(image_2d, sampler_reg, tc, 2.0, vec2(3, 1)); - let _e36 = a; - a = (_e36 + _e35); - let _e41 = textureSample(image_2d_array, sampler_reg, tc, 0u); - let _e42 = a; - a = (_e42 + _e41); - let _e47 = textureSample(image_2d_array, sampler_reg, tc, 0u, vec2(3, 1)); - let _e48 = a; - a = (_e48 + _e47); - let _e53 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3); - let _e54 = a; - a = (_e54 + _e53); - let _e59 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3, vec2(3, 1)); - let _e60 = a; - a = (_e60 + _e59); - let _e66 = textureSampleBias(image_2d_array, sampler_reg, tc, 0u, 2.0, vec2(3, 1)); - let _e67 = a; - a = (_e67 + _e66); - let _e72 = textureSample(image_2d_array, sampler_reg, tc, 0); - let _e73 = a; - a = (_e73 + _e72); - let _e78 = textureSample(image_2d_array, sampler_reg, tc, 0, vec2(3, 1)); - let _e79 = a; - a = (_e79 + _e78); - let _e84 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3); - let _e85 = a; - a = (_e85 + _e84); - let _e90 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3, vec2(3, 1)); - let _e91 = a; - a = (_e91 + _e90); - let _e97 = textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, vec2(3, 1)); - let _e98 = a; - a = (_e98 + _e97); - let _e103 = textureSample(image_cube_array, sampler_reg, tc3_, 0u); - let _e104 = a; - a = (_e104 + _e103); - let _e109 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0u, 2.3); - let _e110 = a; - a = (_e110 + _e109); - let _e116 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0u, 2.0); - let _e117 = a; - a = (_e117 + _e116); - let _e122 = textureSample(image_cube_array, sampler_reg, tc3_, 0); - let _e123 = a; - a = (_e123 + _e122); - let _e128 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0, 2.3); - let _e129 = a; - a = (_e129 + _e128); - let _e135 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0, 2.0); - let _e136 = a; - a = (_e136 + _e135); - let _e138 = a; - return _e138; + let _e8 = textureSample(image_1d, sampler_reg, 0.5); + let _e9 = a; + a = (_e9 + _e8); + let _e13 = textureSample(image_2d, sampler_reg, tc); + let _e14 = a; + a = (_e14 + _e13); + let _e18 = textureSample(image_2d, sampler_reg, tc, vec2(3, 1)); + let _e19 = a; + a = (_e19 + _e18); + let _e23 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3); + let _e24 = a; + a = (_e24 + _e23); + let _e28 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3, vec2(3, 1)); + let _e29 = a; + a = (_e29 + _e28); + let _e34 = textureSampleBias(image_2d, sampler_reg, tc, 2.0, vec2(3, 1)); + let _e35 = a; + a = (_e35 + _e34); + let _e40 = textureSample(image_2d_array, sampler_reg, tc, 0u); + let _e41 = a; + a = (_e41 + _e40); + let _e46 = textureSample(image_2d_array, sampler_reg, tc, 0u, vec2(3, 1)); + let _e47 = a; + a = (_e47 + _e46); + let _e52 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3); + let _e53 = a; + a = (_e53 + _e52); + let _e58 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3, vec2(3, 1)); + let _e59 = a; + a = (_e59 + _e58); + let _e65 = textureSampleBias(image_2d_array, sampler_reg, tc, 0u, 2.0, vec2(3, 1)); + let _e66 = a; + a = (_e66 + _e65); + let _e71 = textureSample(image_2d_array, sampler_reg, tc, 0); + let _e72 = a; + a = (_e72 + _e71); + let _e77 = textureSample(image_2d_array, sampler_reg, tc, 0, vec2(3, 1)); + let _e78 = a; + a = (_e78 + _e77); + let _e83 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3); + let _e84 = a; + a = (_e84 + _e83); + let _e89 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3, vec2(3, 1)); + let _e90 = a; + a = (_e90 + _e89); + let _e96 = textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, vec2(3, 1)); + let _e97 = a; + a = (_e97 + _e96); + let _e102 = textureSample(image_cube_array, sampler_reg, tc3_, 0u); + let _e103 = a; + a = (_e103 + _e102); + let _e108 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0u, 2.3); + let _e109 = a; + a = (_e109 + _e108); + let _e115 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0u, 2.0); + let _e116 = a; + a = (_e116 + _e115); + let _e121 = textureSample(image_cube_array, sampler_reg, tc3_, 0); + let _e122 = a; + a = (_e122 + _e121); + let _e127 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0, 2.3); + let _e128 = a; + a = (_e128 + _e127); + let _e134 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0, 2.0); + let _e135 = a; + a = (_e135 + _e134); + let _e137 = a; + return _e137; } @fragment diff --git a/tests/out/wgsl/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index 3276a0a10a..c30052dd1d 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -20,7 +20,6 @@ fn returns() -> S { fn call() { statement(); let _e0 = returns(); - let vf = f32(Value); - let s = textureSample(Texture, Sampler, vec2(vf)); + let s = textureSample(Texture, Sampler, vec2(1.0)); } diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index f444c6db0b..caedce204b 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -9,9 +9,9 @@ fn builtins() -> vec4 { let s3_ = select(v_f32_one, v_f32_zero, vec4(false, false, false, false)); let m1_ = mix(v_f32_zero, v_f32_one, v_f32_half); let m2_ = mix(v_f32_zero, v_f32_one, 0.1); - let b1_ = bitcast(v_i32_one.x); + let b1_ = bitcast(1); let b2_ = bitcast>(v_i32_one); - let v_i32_zero = vec4(v_f32_zero); + let v_i32_zero = vec4(0, 0, 0, 0); return (((((vec4((vec4(s1_) + v_i32_zero)) + s2_) + m1_) + m2_) + vec4(b1_)) + b2_); } @@ -41,10 +41,7 @@ fn bool_cast(x: vec3) -> vec3 { } fn logical() { - let neg0_ = !(true); - let neg1_ = !(vec2(true)); - let or = (true || false); - let and = (true && false); + let neg1_ = vec2(false, false); let bitwise_or0_ = (true | false); let bitwise_or1_ = (vec3(true) | vec3(false)); let bitwise_and0_ = (true & false); @@ -52,140 +49,95 @@ fn logical() { } fn arithmetic() { - let neg1_1 = -(vec2(1)); - let neg2_ = -(vec2(1.0)); - let add0_ = (2 + 1); - let add1_ = (2u + 1u); - let add2_ = (2.0 + 1.0); + let neg1_1 = vec2(-1, -1); + let neg2_ = vec2(-1.0, -1.0); let add3_ = (vec2(2) + vec2(1)); let add4_ = (vec3(2u) + vec3(1u)); let add5_ = (vec4(2.0) + vec4(1.0)); - let sub0_ = (2 - 1); - let sub1_ = (2u - 1u); - let sub2_ = (2.0 - 1.0); let sub3_ = (vec2(2) - vec2(1)); let sub4_ = (vec3(2u) - vec3(1u)); let sub5_ = (vec4(2.0) - vec4(1.0)); - let mul0_ = (2 * 1); - let mul1_ = (2u * 1u); - let mul2_ = (2.0 * 1.0); let mul3_ = (vec2(2) * vec2(1)); let mul4_ = (vec3(2u) * vec3(1u)); let mul5_ = (vec4(2.0) * vec4(1.0)); - let div0_ = (2 / 1); - let div1_ = (2u / 1u); - let div2_ = (2.0 / 1.0); let div3_ = (vec2(2) / vec2(1)); let div4_ = (vec3(2u) / vec3(1u)); let div5_ = (vec4(2.0) / vec4(1.0)); - let rem0_ = (2 % 1); - let rem1_ = (2u % 1u); - let rem2_ = (2.0 % 1.0); let rem3_ = (vec2(2) % vec2(1)); let rem4_ = (vec3(2u) % vec3(1u)); let rem5_ = (vec4(2.0) % vec4(1.0)); { - let add0_1 = (vec2(2) + vec2(1)); - let add1_1 = (vec2(2) + vec2(1)); - let add2_1 = (vec2(2u) + vec2(1u)); + let add0_ = (vec2(2) + vec2(1)); + let add1_ = (vec2(2) + vec2(1)); + let add2_ = (vec2(2u) + vec2(1u)); let add3_1 = (vec2(2u) + vec2(1u)); let add4_1 = (vec2(2.0) + vec2(1.0)); let add5_1 = (vec2(2.0) + vec2(1.0)); - let sub0_1 = (vec2(2) - vec2(1)); - let sub1_1 = (vec2(2) - vec2(1)); - let sub2_1 = (vec2(2u) - vec2(1u)); + let sub0_ = (vec2(2) - vec2(1)); + let sub1_ = (vec2(2) - vec2(1)); + let sub2_ = (vec2(2u) - vec2(1u)); let sub3_1 = (vec2(2u) - vec2(1u)); let sub4_1 = (vec2(2.0) - vec2(1.0)); let sub5_1 = (vec2(2.0) - vec2(1.0)); - let mul0_1 = (vec2(2) * 1); - let mul1_1 = (2 * vec2(1)); - let mul2_1 = (vec2(2u) * 1u); - let mul3_1 = (2u * vec2(1u)); - let mul4_1 = (vec2(2.0) * 1.0); - let mul5_1 = (2.0 * vec2(1.0)); - let div0_1 = (vec2(2) / vec2(1)); - let div1_1 = (vec2(2) / vec2(1)); - let div2_1 = (vec2(2u) / vec2(1u)); + let mul0_ = vec2(2, 2); + let mul1_ = vec2(2, 2); + let mul2_ = vec2(2u, 2u); + let mul3_1 = vec2(2u, 2u); + let mul4_1 = vec2(2.0, 2.0); + let mul5_1 = vec2(2.0, 2.0); + let div0_ = (vec2(2) / vec2(1)); + let div1_ = (vec2(2) / vec2(1)); + let div2_ = (vec2(2u) / vec2(1u)); let div3_1 = (vec2(2u) / vec2(1u)); let div4_1 = (vec2(2.0) / vec2(1.0)); let div5_1 = (vec2(2.0) / vec2(1.0)); - let rem0_1 = (vec2(2) % vec2(1)); - let rem1_1 = (vec2(2) % vec2(1)); - let rem2_1 = (vec2(2u) % vec2(1u)); + let rem0_ = (vec2(2) % vec2(1)); + let rem1_ = (vec2(2) % vec2(1)); + let rem2_ = (vec2(2u) % vec2(1u)); let rem3_1 = (vec2(2u) % vec2(1u)); let rem4_1 = (vec2(2.0) % vec2(1.0)); let rem5_1 = (vec2(2.0) % vec2(1.0)); } let add = (mat3x3() + mat3x3()); let sub = (mat3x3() - mat3x3()); - let mul_scalar0_ = (mat3x3() * 1.0); - let mul_scalar1_ = (2.0 * mat3x3()); + let mul_scalar0_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); + let mul_scalar1_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); let mul_vector0_ = (mat4x3() * vec4(1.0)); let mul_vector1_ = (vec3(2.0) * mat4x3()); let mul = (mat4x3() * mat3x4()); } fn bit() { - let flip0_ = ~(1); - let flip1_ = ~(1u); - let flip2_ = !(vec2(1)); - let flip3_ = !(vec3(1u)); - let or0_ = (2 | 1); - let or1_ = (2u | 1u); + let flip2_ = vec2(-2, -2); + let flip3_ = vec3(4294967294u, 4294967294u, 4294967294u); let or2_ = (vec2(2) | vec2(1)); let or3_ = (vec3(2u) | vec3(1u)); - let and0_ = (2 & 1); - let and1_ = (2u & 1u); let and2_ = (vec2(2) & vec2(1)); let and3_ = (vec3(2u) & vec3(1u)); - let xor0_ = (2 ^ 1); - let xor1_ = (2u ^ 1u); let xor2_ = (vec2(2) ^ vec2(1)); let xor3_ = (vec3(2u) ^ vec3(1u)); - let shl0_ = (2 << 1u); - let shl1_ = (2u << 1u); let shl2_ = (vec2(2) << vec2(1u)); let shl3_ = (vec3(2u) << vec3(1u)); - let shr0_ = (2 >> 1u); - let shr1_ = (2u >> 1u); let shr2_ = (vec2(2) >> vec2(1u)); let shr3_ = (vec3(2u) >> vec3(1u)); } fn comparison() { - let eq0_ = (2 == 1); - let eq1_ = (2u == 1u); - let eq2_ = (2.0 == 1.0); let eq3_ = (vec2(2) == vec2(1)); let eq4_ = (vec3(2u) == vec3(1u)); let eq5_ = (vec4(2.0) == vec4(1.0)); - let neq0_ = (2 != 1); - let neq1_ = (2u != 1u); - let neq2_ = (2.0 != 1.0); let neq3_ = (vec2(2) != vec2(1)); let neq4_ = (vec3(2u) != vec3(1u)); let neq5_ = (vec4(2.0) != vec4(1.0)); - let lt0_ = (2 < 1); - let lt1_ = (2u < 1u); - let lt2_ = (2.0 < 1.0); let lt3_ = (vec2(2) < vec2(1)); let lt4_ = (vec3(2u) < vec3(1u)); let lt5_ = (vec4(2.0) < vec4(1.0)); - let lte0_ = (2 <= 1); - let lte1_ = (2u <= 1u); - let lte2_ = (2.0 <= 1.0); let lte3_ = (vec2(2) <= vec2(1)); let lte4_ = (vec3(2u) <= vec3(1u)); let lte5_ = (vec4(2.0) <= vec4(1.0)); - let gt0_ = (2 > 1); - let gt1_ = (2u > 1u); - let gt2_ = (2.0 > 1.0); let gt3_ = (vec2(2) > vec2(1)); let gt4_ = (vec3(2u) > vec3(1u)); let gt5_ = (vec4(2.0) > vec4(1.0)); - let gte0_ = (2 >= 1); - let gte1_ = (2u >= 1u); - let gte2_ = (2.0 >= 1.0); let gte3_ = (vec2(2) >= vec2(1)); let gte4_ = (vec3(2u) >= vec3(1u)); let gte5_ = (vec4(2.0) >= vec4(1.0)); @@ -231,20 +183,14 @@ fn assignment() { } fn negation_avoids_prefix_decrement() { - let p1_ = -(-2); - let p2_ = -(-3); - let p3_ = -(-(4)); - let p4_ = -(-(-5)); - let p5_ = -(-(-(-(6)))); - let p6_ = -(-(-(-(-7)))); - let p7_ = -(-(-(-(-8)))); + return; } @compute @workgroup_size(1, 1, 1) fn main() { let _e0 = builtins(); let _e1 = splat(); - let _e4 = bool_cast(v_f32_one.xyz); + let _e6 = bool_cast(vec3(1.0, 1.0, 1.0)); logical(); arithmetic(); bit(); diff --git a/tests/out/wgsl/type-alias.wgsl b/tests/out/wgsl/type-alias.wgsl index fea2dec108..a4a9438eb0 100644 --- a/tests/out/wgsl/type-alias.wgsl +++ b/tests/out/wgsl/type-alias.wgsl @@ -3,7 +3,7 @@ fn main() { let c = vec3(0.0); let b = vec3(vec2(0.0), 0.0); let d = vec3(vec2(0.0), 0.0); - let e = vec3(d); + let e = vec3(vec2(0, 0), 0); let f = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); let g = mat3x3(a, a, a); } diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index cbab660269..637b5372f9 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -107,24 +107,24 @@ fn unknown_identifier() { ); } -#[test] -fn negative_index() { - check( - r#" - fn main() -> f32 { - let a = array(0., 1., 2.); - return a[-1]; - } - "#, - r#"error: expected unsigned integer constant expression, found `-1` - ┌─ wgsl:4:26 - │ -4 │ return a[-1]; - │ ^^ expected unsigned integer - -"#, - ); -} +// #[test] +// fn negative_index() { +// check( +// r#" +// fn main() -> f32 { +// let a = array(0., 1., 2.); +// return a[-1]; +// } +// "#, +// r#"error: expected unsigned integer constant expression, found `-1` +// ┌─ wgsl:4:26 +// │ +// 4 │ return a[-1]; +// │ ^^ expected unsigned integer + +// "#, +// ); +// } #[test] fn bad_texture() { @@ -923,11 +923,11 @@ fn invalid_arrays() { check( "alias Bad = array;", - r###"error: array element count must resolve to an integer scalar (u32 or i32) + r###"error: must be a const-expression that resolves to a concrete integer scalar (u32 or i32) ┌─ wgsl:1:24 │ 1 │ alias Bad = array; - │ ^^^^ must resolve to u32/i32 + │ ^^^^ must resolve to u32 or i32 "###, ); @@ -937,33 +937,33 @@ fn invalid_arrays() { const length: f32 = 2.718; alias Bad = array; "#, - r###"error: array element count must resolve to an integer scalar (u32 or i32) + r###"error: must be a const-expression that resolves to a concrete integer scalar (u32 or i32) ┌─ wgsl:3:36 │ 3 │ alias Bad = array; - │ ^^^^^^ must resolve to u32/i32 + │ ^^^^^^ must resolve to u32 or i32 "###, ); check( "alias Bad = array;", - r###"error: array element count must be greater than zero + r###"error: array element count must be positive (> 0) ┌─ wgsl:1:24 │ 1 │ alias Bad = array; - │ ^ must be greater than zero + │ ^ must be positive "###, ); check( "alias Bad = array;", - r###"error: array element count must be greater than zero + r###"error: array element count must be positive (> 0) ┌─ wgsl:1:24 │ 1 │ alias Bad = array; - │ ^^ must be greater than zero + │ ^^ must be positive "###, ); @@ -1759,47 +1759,47 @@ fn assign_to_let() { "###, ); - check( - " - fn f() { - let a = array(1, 2); - a[0] = 1; - } - ", - r###"error: invalid left-hand side of assignment - ┌─ wgsl:3:17 - │ -3 │ let a = array(1, 2); - │ ^ this is an immutable binding -4 │ a[0] = 1; - │ ^^^^ cannot assign to this expression - │ - = note: consider declaring 'a' with `var` instead of `let` - -"###, - ); - - check( - " - struct S { a: i32 } - - fn f() { - let a = S(10); - a.a = 20; - } - ", - r###"error: invalid left-hand side of assignment - ┌─ wgsl:5:17 - │ -5 │ let a = S(10); - │ ^ this is an immutable binding -6 │ a.a = 20; - │ ^^^ cannot assign to this expression - │ - = note: consider declaring 'a' with `var` instead of `let` - -"###, - ); + // check( + // " + // fn f() { + // let a = array(1, 2); + // a[0] = 1; + // } + // ", + // r###"error: invalid left-hand side of assignment + // ┌─ wgsl:3:17 + // │ + // 3 │ let a = array(1, 2); + // │ ^ this is an immutable binding + // 4 │ a[0] = 1; + // │ ^^^^ cannot assign to this expression + // │ + // = note: consider declaring 'a' with `var` instead of `let` + + // "###, + // ); + + // check( + // " + // struct S { a: i32 } + + // fn f() { + // let a = S(10); + // a.a = 20; + // } + // ", + // r###"error: invalid left-hand side of assignment + // ┌─ wgsl:5:17 + // │ + // 5 │ let a = S(10); + // │ ^ this is an immutable binding + // 6 │ a.a = 20; + // │ ^^^ cannot assign to this expression + // │ + // = note: consider declaring 'a' with `var` instead of `let` + + // "###, + // ); } #[test] From 345360ed08b5f0061628fb8e86fc48be246be7f1 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 19 Apr 2023 15:16:46 +0200 Subject: [PATCH 02/37] use LocalVariable init --- src/back/glsl/mod.rs | 2 +- src/back/hlsl/writer.rs | 2 +- src/back/msl/writer.rs | 70 +- src/back/spv/block.rs | 55 +- src/back/spv/writer.rs | 74 +- src/back/wgsl/writer.rs | 2 +- src/compact/functions.rs | 10 +- src/front/glsl/context.rs | 22 +- src/front/spv/mod.rs | 2 +- src/front/wgsl/lower/mod.rs | 29 +- src/lib.rs | 4 +- src/proc/constant_evaluator.rs | 14 + src/valid/analyzer.rs | 6 + src/valid/function.rs | 6 +- src/valid/handles.rs | 4 +- tests/out/analysis/access.info.ron | 12 +- tests/out/analysis/collatz.info.ron | 2 +- tests/out/analysis/shadow.info.ron | 122 +- .../access.assign_through_ptr.Compute.glsl | 3 +- tests/out/glsl/access.foo_vert.Vertex.glsl | 11 +- tests/out/glsl/bitcast.main.Compute.glsl | 9 - tests/out/glsl/bits.main.Compute.glsl | 10 - tests/out/glsl/boids.main.Compute.glsl | 12 +- tests/out/glsl/dualsource.main.Fragment.glsl | 6 +- tests/out/glsl/globals.main.Compute.glsl | 9 +- tests/out/glsl/operators.main.Compute.glsl | 7 +- tests/out/glsl/shadow.fs_main.Fragment.glsl | 4 +- ...adow.fs_main_without_storage.Fragment.glsl | 4 +- tests/out/hlsl/access.hlsl | 18 +- tests/out/hlsl/binding-arrays.hlsl | 12 +- tests/out/hlsl/bitcast.hlsl | 27 +- tests/out/hlsl/bits.hlsl | 30 +- tests/out/hlsl/boids.hlsl | 18 +- tests/out/hlsl/collatz.hlsl | 3 +- tests/out/hlsl/dualsource.hlsl | 6 +- tests/out/hlsl/globals.hlsl | 9 +- tests/out/hlsl/hlsl-keyword.hlsl | 3 +- tests/out/hlsl/interface.hlsl | 3 +- tests/out/hlsl/operators.hlsl | 7 +- tests/out/hlsl/shadow.hlsl | 12 +- tests/out/ir/access.compact.ron | 36 +- tests/out/ir/access.ron | 36 +- tests/out/ir/collatz.compact.ron | 6 +- tests/out/ir/collatz.ron | 6 +- tests/out/ir/shadow.compact.ron | 202 +-- tests/out/ir/shadow.ron | 202 +-- tests/out/msl/access.msl | 18 +- tests/out/msl/binding-arrays.msl | 12 +- tests/out/msl/bitcast.msl | 27 +- tests/out/msl/bits.msl | 30 +- tests/out/msl/boids.msl | 18 +- tests/out/msl/collatz.msl | 3 +- tests/out/msl/dualsource.msl | 6 +- tests/out/msl/globals.msl | 9 +- tests/out/msl/interface.msl | 3 +- tests/out/msl/operators.msl | 9 +- tests/out/msl/policy-mix.msl | 3 +- tests/out/msl/shadow.msl | 12 +- tests/out/spv/access.spvasm | 675 ++++---- .../spv/array-in-function-return-type.spvasm | 8 +- tests/out/spv/atomicCompareExchange.spvasm | 293 ++-- tests/out/spv/binding-arrays.spvasm | 959 ++++++----- tests/out/spv/binding-buffer-arrays.spvasm | 97 +- tests/out/spv/bitcast.spvasm | 144 +- tests/out/spv/bits.spvasm | 406 +++-- tests/out/spv/boids.spvasm | 515 +++--- .../spv/bounds-check-image-restrict.spvasm | 30 +- tests/out/spv/bounds-check-image-rzsw.spvasm | 30 +- tests/out/spv/break-if.spvasm | 95 +- tests/out/spv/collatz.spvasm | 73 +- tests/out/spv/constructors.spvasm | 63 +- tests/out/spv/control-flow.spvasm | 60 +- tests/out/spv/debug-symbol-simple.spvasm | 237 ++- tests/out/spv/debug-symbol-terrain.spvasm | 1493 ++++++++--------- tests/out/spv/dualsource.spvasm | 79 +- tests/out/spv/extra.spvasm | 38 +- tests/out/spv/fragment-output.spvasm | 236 +-- tests/out/spv/functions.spvasm | 147 +- tests/out/spv/globals.spvasm | 278 ++- tests/out/spv/image.spvasm | 837 +++++---- tests/out/spv/interface.vertex.spvasm | 14 +- .../spv/interface.vertex_two_structs.spvasm | 76 +- tests/out/spv/interpolate.spvasm | 214 +-- tests/out/spv/math-functions.spvasm | 220 ++- tests/out/spv/operators.spvasm | 743 ++++---- tests/out/spv/padding.spvasm | 8 +- tests/out/spv/pointers.spvasm | 22 +- tests/out/spv/policy-mix.spvasm | 156 +- tests/out/spv/quad.spvasm | 8 +- tests/out/spv/ray-query.spvasm | 88 +- tests/out/spv/shadow.spvasm | 484 +++--- tests/out/spv/skybox.spvasm | 187 ++- tests/out/spv/standard.spvasm | 92 +- tests/out/spv/texture-arg.spvasm | 8 +- tests/out/wgsl/access.wgsl | 18 +- tests/out/wgsl/atomicCompareExchange.wgsl | 10 +- tests/out/wgsl/binding-arrays.wgsl | 12 +- tests/out/wgsl/binding-buffer-arrays.wgsl | 3 +- tests/out/wgsl/bitcast.wgsl | 27 +- tests/out/wgsl/bits.wgsl | 30 +- tests/out/wgsl/boids.wgsl | 18 +- tests/out/wgsl/collatz.wgsl | 3 +- tests/out/wgsl/dualsource.wgsl | 6 +- tests/out/wgsl/expressions.frag.wgsl | 4 +- tests/out/wgsl/globals.wgsl | 9 +- tests/out/wgsl/interface.wgsl | 3 +- tests/out/wgsl/lexical-scopes.wgsl | 3 +- tests/out/wgsl/operators.wgsl | 9 +- tests/out/wgsl/shadow.wgsl | 12 +- 109 files changed, 5065 insertions(+), 5514 deletions(-) diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index 12d358bb80..77e206d3c6 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -1605,7 +1605,7 @@ impl<'a, W: Write> Writer<'a, W> { // Write the constant // `write_constant` adds no trailing or leading space/newline - self.write_const_expr(init)?; + self.write_expr(init, &ctx)?; } else if is_value_init_supported(self.module, local.ty) { write!(self.out, " = ")?; self.write_zero_init_value(local.ty)?; diff --git a/src/back/hlsl/writer.rs b/src/back/hlsl/writer.rs index a2e0d2fefa..590850fc4d 100644 --- a/src/back/hlsl/writer.rs +++ b/src/back/hlsl/writer.rs @@ -1238,7 +1238,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { write!(self.out, " = ")?; // Write the local initializer if needed if let Some(init) = local.init { - self.write_const_expression(module, init)?; + self.write_expr(module, init, func_ctx)?; } else { // Zero initialize local variables self.write_default_init(module, local.ty)?; diff --git a/src/back/msl/writer.rs b/src/back/msl/writer.rs index fee917b035..d0f5413136 100644 --- a/src/back/msl/writer.rs +++ b/src/back/msl/writer.rs @@ -3557,6 +3557,23 @@ impl Writer { writeln!(self.out, ") {{")?; + let guarded_indices = + index::find_checked_indexes(module, fun, fun_info, options.bounds_check_policies); + + let context = StatementContext { + expression: ExpressionContext { + function: fun, + origin: FunctionOrigin::Handle(fun_handle), + info: fun_info, + policies: options.bounds_check_policies, + guarded_indices, + module, + mod_info, + pipeline_options, + }, + result_struct: None, + }; + for (local_handle, local) in fun.local_variables.iter() { let ty_name = TypeContext { handle: local.ty, @@ -3571,7 +3588,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module, mod_info)?; + self.put_expression(value, &context.expression, true)?; } None => { write!(self.out, " = {{}}")?; @@ -3580,22 +3597,6 @@ impl Writer { writeln!(self.out, ";")?; } - let guarded_indices = - index::find_checked_indexes(module, fun, fun_info, options.bounds_check_policies); - - let context = StatementContext { - expression: ExpressionContext { - function: fun, - origin: FunctionOrigin::Handle(fun_handle), - info: fun_info, - policies: options.bounds_check_policies, - guarded_indices, - module, - mod_info, - pipeline_options, - }, - result_struct: None, - }; self.named_expressions.clear(); self.update_expressions_to_bake(fun, fun_info, &context.expression); self.put_block(back::Level(1), &fun.body, &context)?; @@ -4112,6 +4113,23 @@ impl Writer { } } + let guarded_indices = + index::find_checked_indexes(module, fun, fun_info, options.bounds_check_policies); + + let context = StatementContext { + expression: ExpressionContext { + function: fun, + origin: FunctionOrigin::EntryPoint(ep_index as _), + info: fun_info, + policies: options.bounds_check_policies, + guarded_indices, + module, + mod_info, + pipeline_options, + }, + result_struct: Some(&stage_out_name), + }; + // Finally, declare all the local variables that we need //TODO: we can postpone this till the relevant expressions are emitted for (local_handle, local) in fun.local_variables.iter() { @@ -4128,7 +4146,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module, mod_info)?; + self.put_expression(value, &context.expression, true)?; } None => { write!(self.out, " = {{}}")?; @@ -4137,22 +4155,6 @@ impl Writer { writeln!(self.out, ";")?; } - let guarded_indices = - index::find_checked_indexes(module, fun, fun_info, options.bounds_check_policies); - - let context = StatementContext { - expression: ExpressionContext { - function: fun, - origin: FunctionOrigin::EntryPoint(ep_index as _), - info: fun_info, - policies: options.bounds_check_policies, - guarded_indices, - module, - mod_info, - pipeline_options, - }, - result_struct: Some(&stage_out_name), - }; self.named_expressions.clear(); self.update_expressions_to_bake(fun, fun_info, &context.expression); self.put_block(back::Level(1), &fun.body, &context)?; diff --git a/src/back/spv/block.rs b/src/back/spv/block.rs index c5246ad190..d698931f6d 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -252,13 +252,39 @@ impl<'w> BlockContext<'w> { self.temp_list.push(self.cached[component]); } - let id = self.gen_id(); - block.body.push(Instruction::composite_construct( - result_type_id, - id, - &self.temp_list, - )); - id + if self.ir_function.expressions.is_const(expr_handle) { + let ty = self + .writer + .get_expression_lookup_type(&self.fun_info[expr_handle].ty); + self.writer.get_constant_composite(ty, &self.temp_list) + } else { + let id = self.gen_id(); + block.body.push(Instruction::composite_construct( + result_type_id, + id, + &self.temp_list, + )); + id + } + } + crate::Expression::Splat { size, value } => { + let value_id = self.cached[value]; + let components = &[value_id; 4][..size as usize]; + + if self.ir_function.expressions.is_const(expr_handle) { + let ty = self + .writer + .get_expression_lookup_type(&self.fun_info[expr_handle].ty); + self.writer.get_constant_composite(ty, components) + } else { + let id = self.gen_id(); + block.body.push(Instruction::composite_construct( + result_type_id, + id, + components, + )); + id + } } crate::Expression::Access { base, index: _ } if self.is_intermediate(base) => { // See `is_intermediate`; we'll handle this later in @@ -405,17 +431,6 @@ impl<'w> BlockContext<'w> { crate::Expression::GlobalVariable(handle) => { self.writer.global_variables[handle.index()].access_id } - crate::Expression::Splat { size, value } => { - let value_id = self.cached[value]; - let components = [value_id; 4]; - let id = self.gen_id(); - block.body.push(Instruction::composite_construct( - result_type_id, - id, - &components[..size as usize], - )); - id - } crate::Expression::Swizzle { size, vector, @@ -1758,7 +1773,9 @@ impl<'w> BlockContext<'w> { match *statement { crate::Statement::Emit(ref range) => { for handle in range.clone() { - self.cache_expression_value(handle, &mut block)?; + if !self.ir_function.expressions.is_const(handle) { + self.cache_expression_value(handle, &mut block)?; + } } } crate::Statement::Block(ref block_statements) => { diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 4be19cce66..7d79377786 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -338,37 +338,6 @@ impl Writer { ) -> Result { let mut function = Function::default(); - for (handle, variable) in ir_function.local_variables.iter() { - let id = self.id_gen.next(); - - if self.flags.contains(WriterFlags::DEBUG) { - if let Some(ref name) = variable.name { - self.debugs.push(Instruction::name(id, name)); - } - } - - let init_word = variable - .init - .map(|constant| self.constant_ids[constant.index()]); - let pointer_type_id = - self.get_pointer_id(&ir_module.types, variable.ty, spirv::StorageClass::Function)?; - let instruction = Instruction::variable( - pointer_type_id, - id, - spirv::StorageClass::Function, - init_word.or_else(|| match ir_module.types[variable.ty].inner { - crate::TypeInner::RayQuery => None, - _ => { - let type_id = self.get_type_id(LookupType::Handle(variable.ty)); - Some(self.get_constant_null(type_id)) - } - }), - ); - function - .variables - .insert(handle, LocalVariable { id, instruction }); - } - let prelude_id = self.id_gen.next(); let mut prelude = Block::new(prelude_id); let mut ep_context = EntryPointContext { @@ -656,7 +625,48 @@ impl Writer { // fill up the pre-emitted expressions context.cached.reset(ir_function.expressions.len()); for (handle, expr) in ir_function.expressions.iter() { - if expr.needs_pre_emit() { + if (expr.needs_pre_emit() && !matches!(*expr, crate::Expression::LocalVariable(_))) + || ir_function.expressions.is_const(handle) + { + context.cache_expression_value(handle, &mut prelude)?; + } + } + + for (handle, variable) in ir_function.local_variables.iter() { + let id = context.gen_id(); + + if context.writer.flags.contains(WriterFlags::DEBUG) { + if let Some(ref name) = variable.name { + context.writer.debugs.push(Instruction::name(id, name)); + } + } + + let init_word = variable.init.map(|constant| context.cached[constant]); + let pointer_type_id = context.writer.get_pointer_id( + &ir_module.types, + variable.ty, + spirv::StorageClass::Function, + )?; + let instruction = Instruction::variable( + pointer_type_id, + id, + spirv::StorageClass::Function, + init_word.or_else(|| match ir_module.types[variable.ty].inner { + crate::TypeInner::RayQuery => None, + _ => { + let type_id = context.get_type_id(LookupType::Handle(variable.ty)); + Some(context.writer.write_constant_null(type_id)) + } + }), + ); + context + .function + .variables + .insert(handle, LocalVariable { id, instruction }); + } + + for (handle, expr) in ir_function.expressions.iter() { + if expr.needs_pre_emit() && matches!(*expr, crate::Expression::LocalVariable(_)) { context.cache_expression_value(handle, &mut prelude)?; } } diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index e41460061d..0655fcde80 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -292,7 +292,7 @@ impl Writer { // Write the constant // `write_constant` adds no trailing or leading space/newline - self.write_const_expression(module, init)?; + self.write_expr(module, init, func_ctx)?; } // Finish the local with `;` and add a newline (only for readability) diff --git a/src/compact/functions.rs b/src/compact/functions.rs index 176221f98e..752c3eb7f1 100644 --- a/src/compact/functions.rs +++ b/src/compact/functions.rs @@ -27,7 +27,7 @@ impl<'a> FunctionTracer<'a> { for (_, local) in self.function.local_variables.iter() { self.trace_type(local.ty); if let Some(init) = local.init { - self.trace_const_expression(init); + self.trace_expression(init); } } @@ -48,12 +48,6 @@ impl<'a> FunctionTracer<'a> { self.as_expression().trace_expression(expr); } - pub fn trace_const_expression(&mut self, expr: Handle) { - self.as_expression() - .as_const_expression() - .trace_expression(expr); - } - fn as_type(&mut self) -> super::types::TypeTracer { super::types::TypeTracer { types: &self.module.types, @@ -99,7 +93,7 @@ impl FunctionMap { log::trace!("adjusting local variable {:?}", local.name); module_map.types.adjust(&mut local.ty); if let Some(ref mut init) = local.init { - module_map.const_expressions.adjust(init); + self.expressions.adjust(init); } } diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index ffdc2bd978..a13e6ac5ba 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -988,18 +988,16 @@ impl<'a> Context<'a> { // pointer type which is required for dynamic indexing if !constant_index { if let Some((constant, ty)) = var.constant { - let local = - self.locals.append( - LocalVariable { - name: None, - ty, - init: Some(self.module.const_expressions.append( - Expression::Constant(constant), - Span::default(), - )), - }, - Span::default(), - ); + let init = self + .add_expression(Expression::Constant(constant), Span::default())?; + let local = self.locals.append( + LocalVariable { + name: None, + ty, + init: Some(init), + }, + Span::default(), + ); self.add_expression(Expression::LocalVariable(local), Span::default())? } else { diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 5fd54b023f..1609868efa 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -1395,7 +1395,7 @@ impl> Frontend { let init_id = self.next()?; let lconst = self.lookup_constant.lookup(init_id)?; Some( - ctx.const_expressions + ctx.expressions .append(crate::Expression::Constant(lconst.handle), span), ) } else { diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 3a78f0f2bd..edb4f6d490 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -1031,6 +1031,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let mut typifier = Typifier::default(); let mut body = self.block( &f.body, + false, StatementContext { local_table: &mut local_table, globals: ctx.globals, @@ -1091,12 +1092,13 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { fn block( &mut self, b: &ast::Block<'source>, + is_inside_loop: bool, mut ctx: StatementContext<'source, '_, '_>, ) -> Result> { let mut block = crate::Block::default(); for stmt in b.stmts.iter() { - self.statement(stmt, &mut block, ctx.reborrow())?; + self.statement(stmt, &mut block, is_inside_loop, ctx.reborrow())?; } Ok(block) @@ -1106,11 +1108,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { &mut self, stmt: &ast::Statement<'source>, block: &mut crate::Block, + is_inside_loop: bool, mut ctx: StatementContext<'source, '_, '_>, ) -> Result<(), Error<'source>> { let out = match stmt.kind { ast::StatementKind::Block(ref block) => { - let block = self.block(block, ctx.reborrow())?; + let block = self.block(block, is_inside_loop, ctx.reborrow())?; crate::Statement::Block(block) } ast::StatementKind::LocalDecl(ref decl) => match *decl { @@ -1191,11 +1194,21 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; + let (const_initializer, initializer) = { + match initializer { + Some(init) if ctx.naga_expressions.is_const(init) => { + (Some(init), is_inside_loop.then_some(init)) + } + Some(init) => (None, Some(init)), + None => (None, None), + } + }; + let var = ctx.variables.append( crate::LocalVariable { name: Some(v.name.name.to_string()), ty, - init: None, + init: const_initializer, }, stmt.span, ); @@ -1234,8 +1247,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { self.expression(condition, ctx.as_expression(block, &mut emitter))?; block.extend(emitter.finish(ctx.naga_expressions)); - let accept = self.block(accept, ctx.reborrow())?; - let reject = self.block(reject, ctx.reborrow())?; + let accept = self.block(accept, is_inside_loop, ctx.reborrow())?; + let reject = self.block(reject, is_inside_loop, ctx.reborrow())?; crate::Statement::If { condition, @@ -1282,7 +1295,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } ast::SwitchValue::Default => crate::SwitchValue::Default, }, - body: self.block(&case.body, ctx.reborrow())?, + body: self.block(&case.body, is_inside_loop, ctx.reborrow())?, fall_through: case.fall_through, }) }) @@ -1295,8 +1308,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ref continuing, break_if, } => { - let body = self.block(body, ctx.reborrow())?; - let mut continuing = self.block(continuing, ctx.reborrow())?; + let body = self.block(body, true, ctx.reborrow())?; + let mut continuing = self.block(continuing, true, ctx.reborrow())?; let mut emitter = Emitter::default(); emitter.start(ctx.naga_expressions); diff --git a/src/lib.rs b/src/lib.rs index 93ecaa1ab3..80461e16ff 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -978,9 +978,7 @@ pub struct LocalVariable { pub name: Option, /// The type of this variable. pub ty: Handle, - /// Initial value for this variable. - /// - /// Expression handle lives in const_expressions + /// Initial value for this variable. Must be a const-expression. pub init: Option>, } diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index cf00b13de5..6778a0bf93 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -91,6 +91,20 @@ pub enum ExprType { // Math // As +// TODO(teoxoy): consider accumulating this metadata instead of recursing through subexpressions +impl Arena { + pub fn is_const(&self, handle: Handle) -> bool { + match self[handle] { + Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => true, + Expression::Compose { ref components, .. } => { + components.iter().all(|h| self.is_const(*h)) + } + Expression::Splat { ref value, .. } => self.is_const(*value), + _ => false, + } + } +} + impl<'a, F: FnMut(&mut Arena, Expression, Span) -> Handle> ConstantEvaluator<'a, F> { diff --git a/src/valid/analyzer.rs b/src/valid/analyzer.rs index 0ed707c1e3..ff1db071c8 100644 --- a/src/valid/analyzer.rs +++ b/src/valid/analyzer.rs @@ -1041,6 +1041,12 @@ impl ModuleInfo { } } + for (_, expr) in fun.local_variables.iter() { + if let Some(init) = expr.init { + let _ = info.add_ref(init); + } + } + let uniformity = info.process_block(&fun.body, &self.functions, None, &fun.expressions)?; info.uniformity = uniformity.result; info.may_kill = uniformity.exit.contains(ExitFlags::MAY_KILL); diff --git a/src/valid/function.rs b/src/valid/function.rs index 998f873c08..a056a1d1f6 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -941,7 +941,7 @@ impl super::Validator { &self, var: &crate::LocalVariable, gctx: crate::proc::GlobalCtx, - mod_info: &ModuleInfo, + fun_info: &FunctionInfo, ) -> Result<(), LocalVariableError> { log::debug!("var {:?}", var); let type_info = self @@ -954,7 +954,7 @@ impl super::Validator { if let Some(init) = var.init { let decl_ty = &gctx.types[var.ty].inner; - let init_ty = mod_info[init].inner_with(gctx.types); + let init_ty = fun_info[init].ty.inner_with(gctx.types); if !decl_ty.equivalent(init_ty, gctx.types) { return Err(LocalVariableError::InitializerType); } @@ -975,7 +975,7 @@ impl super::Validator { #[cfg(feature = "validate")] for (var_handle, var) in fun.local_variables.iter() { - self.validate_local_var(var, module.to_ctx(), mod_info) + self.validate_local_var(var, module.to_ctx(), &info) .map_err(|source| { FunctionError::LocalVariable { handle: var_handle, diff --git a/src/valid/handles.rs b/src/valid/handles.rs index da95f60842..c68ded074b 100644 --- a/src/valid/handles.rs +++ b/src/valid/handles.rs @@ -131,8 +131,8 @@ impl super::Validator { for (_handle, local_variable) in local_variables.iter() { let &crate::LocalVariable { name: _, ty, init } = local_variable; validate_type(ty)?; - if let Some(init_constant) = init { - validate_const_expr(init_constant)?; + if let Some(init) = init { + Self::validate_expression_handle(init, expressions)?; } } diff --git a/tests/out/analysis/access.info.ron b/tests/out/analysis/access.info.ron index 4a020e48c4..f66a792858 100644 --- a/tests/out/analysis/access.info.ron +++ b/tests/out/analysis/access.info.ron @@ -66,7 +66,7 @@ non_uniform_result: Some(2), requirements: (""), ), - ref_count: 15, + ref_count: 14, assignable_global: None, ty: Value(Pointer( base: 3, @@ -637,7 +637,7 @@ non_uniform_result: Some(50), requirements: (""), ), - ref_count: 8, + ref_count: 7, assignable_global: None, ty: Value(Pointer( base: 16, @@ -1164,7 +1164,7 @@ non_uniform_result: Some(2), requirements: (""), ), - ref_count: 15, + ref_count: 14, assignable_global: None, ty: Value(Pointer( base: 3, @@ -1777,7 +1777,7 @@ non_uniform_result: Some(54), requirements: (""), ), - ref_count: 9, + ref_count: 8, assignable_global: None, ty: Value(Pointer( base: 20, @@ -2667,7 +2667,7 @@ non_uniform_result: Some(3), requirements: (""), ), - ref_count: 4, + ref_count: 3, assignable_global: None, ty: Value(Pointer( base: 21, @@ -3803,7 +3803,7 @@ non_uniform_result: Some(6), requirements: (""), ), - ref_count: 2, + ref_count: 1, assignable_global: None, ty: Value(Pointer( base: 28, diff --git a/tests/out/analysis/collatz.info.ron b/tests/out/analysis/collatz.info.ron index 8241bf9a15..5b32bf44ad 100644 --- a/tests/out/analysis/collatz.info.ron +++ b/tests/out/analysis/collatz.info.ron @@ -57,7 +57,7 @@ non_uniform_result: Some(4), requirements: (""), ), - ref_count: 4, + ref_count: 3, assignable_global: None, ty: Value(Pointer( base: 1, diff --git a/tests/out/analysis/shadow.info.ron b/tests/out/analysis/shadow.info.ron index 15ec6e2b3a..3553f9030b 100644 --- a/tests/out/analysis/shadow.info.ron +++ b/tests/out/analysis/shadow.info.ron @@ -625,7 +625,16 @@ ), ( uniformity: ( - non_uniform_result: Some(20), + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(2), + ), + ( + uniformity: ( + non_uniform_result: Some(21), requirements: (""), ), ref_count: 3, @@ -637,7 +646,16 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: None, + requirements: (""), + ), + ref_count: 1, + assignable_global: None, + ty: Handle(3), + ), + ( + uniformity: ( + non_uniform_result: Some(23), requirements: (""), ), ref_count: 11, @@ -649,7 +667,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -708,7 +726,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -720,7 +738,7 @@ ), ( uniformity: ( - non_uniform_result: Some(20), + non_uniform_result: Some(21), requirements: (""), ), ref_count: 1, @@ -729,7 +747,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -752,7 +770,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -761,7 +779,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -775,7 +793,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -789,7 +807,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -807,7 +825,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -861,7 +879,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -870,7 +888,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -884,7 +902,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -898,7 +916,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -914,7 +932,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -940,7 +958,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -949,7 +967,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -963,7 +981,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -977,7 +995,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -993,7 +1011,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1019,7 +1037,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1028,7 +1046,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1042,7 +1060,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1056,7 +1074,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1072,7 +1090,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1084,7 +1102,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1180,7 +1198,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1189,7 +1207,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1242,7 +1260,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1251,7 +1269,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1265,7 +1283,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1279,7 +1297,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1295,7 +1313,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1321,7 +1339,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1330,7 +1348,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1344,7 +1362,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1358,7 +1376,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1374,7 +1392,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1400,7 +1418,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1409,7 +1427,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1423,7 +1441,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1437,7 +1455,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1453,7 +1471,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1465,7 +1483,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1474,7 +1492,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1483,7 +1501,7 @@ ), ( uniformity: ( - non_uniform_result: Some(20), + non_uniform_result: Some(21), requirements: (""), ), ref_count: 1, @@ -1492,7 +1510,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1501,7 +1519,7 @@ ), ( uniformity: ( - non_uniform_result: Some(21), + non_uniform_result: Some(23), requirements: (""), ), ref_count: 1, @@ -1510,7 +1528,7 @@ ), ( uniformity: ( - non_uniform_result: Some(20), + non_uniform_result: Some(21), requirements: (""), ), ref_count: 1, @@ -1519,7 +1537,7 @@ ), ( uniformity: ( - non_uniform_result: Some(20), + non_uniform_result: Some(21), requirements: (""), ), ref_count: 1, @@ -1701,7 +1719,5 @@ kind: Sint, width: 4, )), - Handle(2), - Handle(3), ], ) \ No newline at end of file diff --git a/tests/out/glsl/access.assign_through_ptr.Compute.glsl b/tests/out/glsl/access.assign_through_ptr.Compute.glsl index ab5bd9a3fb..a75b0f4d97 100644 --- a/tests/out/glsl/access.assign_through_ptr.Compute.glsl +++ b/tests/out/glsl/access.assign_through_ptr.Compute.glsl @@ -47,8 +47,7 @@ void main() { } memoryBarrierShared(); barrier(); - vec4 arr[2] = vec4[2](vec4(0.0), vec4(0.0)); - arr = vec4[2](vec4(6.0), vec4(7.0)); + vec4 arr[2] = vec4[2](vec4(6.0), vec4(7.0)); assign_through_ptr_fn(val); assign_array_through_ptr_fn(arr); return; diff --git a/tests/out/glsl/access.foo_vert.Vertex.glsl b/tests/out/glsl/access.foo_vert.Vertex.glsl index a505ee19eb..a79ff3039d 100644 --- a/tests/out/glsl/access.foo_vert.Vertex.glsl +++ b/tests/out/glsl/access.foo_vert.Vertex.glsl @@ -34,9 +34,8 @@ uniform MatCx2InArray_block_3Vertex { MatCx2InArray _group_0_binding_3_vs; }; void test_matrix_within_struct_accesses() { - int idx = 0; - Baz t = Baz(mat3x2(0.0)); - idx = 1; + int idx = 1; + Baz t = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); int _e3 = idx; idx = (_e3 - 1); mat3x2 l0_ = _group_0_binding_1_vs.m; @@ -51,7 +50,6 @@ void test_matrix_within_struct_accesses() { int _e36 = idx; int _e38 = idx; float l6_ = _group_0_binding_1_vs.m[_e36][_e38]; - t = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); int _e51 = idx; idx = (_e51 + 1); t.m = mat3x2(vec2(6.0), vec2(5.0), vec2(4.0)); @@ -70,9 +68,8 @@ void test_matrix_within_struct_accesses() { } void test_matrix_within_array_within_struct_accesses() { - int idx_1 = 0; + int idx_1 = 1; MatCx2InArray t_1 = MatCx2InArray(mat4x2[2](mat4x2(0.0), mat4x2(0.0))); - idx_1 = 1; int _e3 = idx_1; idx_1 = (_e3 - 1); mat4x2 l0_1[2] = _group_0_binding_3_vs.am; @@ -88,7 +85,6 @@ void test_matrix_within_array_within_struct_accesses() { int _e46 = idx_1; int _e48 = idx_1; float l7_ = _group_0_binding_3_vs.am[0][_e46][_e48]; - t_1 = MatCx2InArray(mat4x2[2](mat4x2(0.0), mat4x2(0.0))); int _e55 = idx_1; idx_1 = (_e55 + 1); t_1.am = mat4x2[2](mat4x2(0.0), mat4x2(0.0)); @@ -130,7 +126,6 @@ void main() { uint vi = uint(gl_VertexID); float foo = 0.0; int c2_[5] = int[5](0, 0, 0, 0, 0); - foo = 0.0; float baz_1 = foo; foo = 1.0; test_matrix_within_struct_accesses(); diff --git a/tests/out/glsl/bitcast.main.Compute.glsl b/tests/out/glsl/bitcast.main.Compute.glsl index 215aef8a58..57e7e221b7 100644 --- a/tests/out/glsl/bitcast.main.Compute.glsl +++ b/tests/out/glsl/bitcast.main.Compute.glsl @@ -16,15 +16,6 @@ void main() { vec2 f2_ = vec2(0.0); vec3 f3_ = vec3(0.0); vec4 f4_ = vec4(0.0); - i2_ = ivec2(0); - i3_ = ivec3(0); - i4_ = ivec4(0); - u2_ = uvec2(0u); - u3_ = uvec3(0u); - u4_ = uvec4(0u); - f2_ = vec2(0.0); - f3_ = vec3(0.0); - f4_ = vec4(0.0); ivec2 _e27 = i2_; u2_ = uvec2(_e27); ivec3 _e29 = i3_; diff --git a/tests/out/glsl/bits.main.Compute.glsl b/tests/out/glsl/bits.main.Compute.glsl index 1c17638faf..f991f532ac 100644 --- a/tests/out/glsl/bits.main.Compute.glsl +++ b/tests/out/glsl/bits.main.Compute.glsl @@ -17,16 +17,6 @@ void main() { uvec4 u4_ = uvec4(0u); vec2 f2_ = vec2(0.0); vec4 f4_ = vec4(0.0); - i = 0; - i2_ = ivec2(0); - i3_ = ivec3(0); - i4_ = ivec4(0); - u = 0u; - u2_ = uvec2(0u); - u3_ = uvec3(0u); - u4_ = uvec4(0u); - f2_ = vec2(0.0); - f4_ = vec4(0.0); vec4 _e28 = f4_; u = packSnorm4x8(_e28); vec4 _e30 = f4_; diff --git a/tests/out/glsl/boids.main.Compute.glsl b/tests/out/glsl/boids.main.Compute.glsl index 8d6067aeed..c42358bfef 100644 --- a/tests/out/glsl/boids.main.Compute.glsl +++ b/tests/out/glsl/boids.main.Compute.glsl @@ -35,9 +35,9 @@ void main() { uvec3 global_invocation_id = gl_GlobalInvocationID; vec2 vPos = vec2(0.0); vec2 vVel = vec2(0.0); - vec2 cMass = vec2(0.0); - vec2 cVel = vec2(0.0); - vec2 colVel = vec2(0.0); + vec2 cMass = vec2(0.0, 0.0); + vec2 cVel = vec2(0.0, 0.0); + vec2 colVel = vec2(0.0, 0.0); int cMassCount = 0; int cVelCount = 0; vec2 pos = vec2(0.0); @@ -51,12 +51,6 @@ void main() { vPos = _e8; vec2 _e14 = _group_0_binding_1_cs.particles[index].vel; vVel = _e14; - cMass = vec2(0.0, 0.0); - cVel = vec2(0.0, 0.0); - colVel = vec2(0.0, 0.0); - cMassCount = 0; - cVelCount = 0; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { diff --git a/tests/out/glsl/dualsource.main.Fragment.glsl b/tests/out/glsl/dualsource.main.Fragment.glsl index 9ac463c2b3..ef57922798 100644 --- a/tests/out/glsl/dualsource.main.Fragment.glsl +++ b/tests/out/glsl/dualsource.main.Fragment.glsl @@ -13,10 +13,8 @@ layout(location = 0, index = 1) out vec4 _fs2p_location1; void main() { vec4 position = gl_FragCoord; - vec4 color = vec4(0.0); - vec4 mask = vec4(0.0); - color = vec4(0.4, 0.3, 0.2, 0.1); - mask = vec4(0.9, 0.8, 0.7, 0.6); + vec4 color = vec4(0.4, 0.3, 0.2, 0.1); + vec4 mask = vec4(0.9, 0.8, 0.7, 0.6); vec4 _e13 = color; vec4 _e14 = mask; FragmentOutput _tmp_return = FragmentOutput(_e13, _e14); diff --git a/tests/out/glsl/globals.main.Compute.glsl b/tests/out/glsl/globals.main.Compute.glsl index b5e36f5414..b7ef8bd295 100644 --- a/tests/out/glsl/globals.main.Compute.glsl +++ b/tests/out/glsl/globals.main.Compute.glsl @@ -35,9 +35,8 @@ void test_msl_packed_vec3_as_arg(vec3 arg) { } void test_msl_packed_vec3_() { - int idx = 0; + int idx = 1; _group_0_binding_1_cs.v3_ = vec3(1.0); - idx = 1; _group_0_binding_1_cs.v3_.x = 1.0; _group_0_binding_1_cs.v3_.x = 2.0; int _e16 = idx; @@ -59,8 +58,8 @@ void main() { } memoryBarrierShared(); barrier(); - float Foo = 0.0; - bool at = false; + float Foo = 1.0; + bool at = true; test_msl_packed_vec3_(); mat4x2 _e5 = _group_0_binding_7_cs[0][0]; vec4 _e10 = _group_0_binding_6_cs[0][0][0]; @@ -79,8 +78,6 @@ void main() { _group_0_binding_1_cs.v1_ = 4.0; wg[1] = float(uint(_group_0_binding_2_cs.length())); at_1 = 2u; - Foo = 1.0; - at = true; return; } diff --git a/tests/out/glsl/operators.main.Compute.glsl b/tests/out/glsl/operators.main.Compute.glsl index 1ed88c1023..a1a7131e99 100644 --- a/tests/out/glsl/operators.main.Compute.glsl +++ b/tests/out/glsl/operators.main.Compute.glsl @@ -30,8 +30,7 @@ vec4 splat() { } vec2 splat_assignment() { - vec2 a = vec2(0.0); - a = vec2(2.0); + vec2 a = vec2(2.0); vec2 _e4 = a; a = (_e4 + vec2(1.0)); vec2 _e8 = a; @@ -151,9 +150,8 @@ void comparison() { } void assignment() { - int a_1 = 0; + int a_1 = 1; ivec3 vec0_ = ivec3(0); - a_1 = 1; int _e3 = a_1; a_1 = (_e3 + 1); int _e6 = a_1; @@ -180,7 +178,6 @@ void assignment() { a_1 = (_e33 + 1); int _e36 = a_1; a_1 = (_e36 - 1); - vec0_ = ivec3(0); int _e42 = vec0_.y; vec0_.y = (_e42 + 1); int _e46 = vec0_.y; diff --git a/tests/out/glsl/shadow.fs_main.Fragment.glsl b/tests/out/glsl/shadow.fs_main.Fragment.glsl index 0910850814..61c14561d5 100644 --- a/tests/out/glsl/shadow.fs_main.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main.Fragment.glsl @@ -49,11 +49,9 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) { void main() { VertexOutput in_ = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); - vec3 color = vec3(0.0); + vec3 color = c_ambient; uint i = 0u; vec3 normal_1 = normalize(in_.world_normal); - color = c_ambient; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { diff --git a/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl b/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl index c85a89eb96..57677c91a6 100644 --- a/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl @@ -49,11 +49,9 @@ float fetch_shadow(uint light_id, vec4 homogeneous_coords) { void main() { VertexOutput in_1 = VertexOutput(gl_FragCoord, _vs2fs_location0, _vs2fs_location1); - vec3 color_1 = vec3(0.0); + vec3 color_1 = c_ambient; uint i_1 = 0u; vec3 normal_1 = normalize(in_1.world_normal); - color_1 = c_ambient; - i_1 = 0u; bool loop_init = true; while(true) { if (!loop_init) { diff --git a/tests/out/hlsl/access.hlsl b/tests/out/hlsl/access.hlsl index 465643bb44..6f44bdb07f 100644 --- a/tests/out/hlsl/access.hlsl +++ b/tests/out/hlsl/access.hlsl @@ -119,10 +119,9 @@ void SetMatScalarmOnBaz(Baz obj, float scalar, uint mat_idx, uint vec_idx) { void test_matrix_within_struct_accesses() { - int idx = (int)0; - Baz t = (Baz)0; + int idx = 1; + Baz t = ConstructBaz(float3x2((1.0).xx, (2.0).xx, (3.0).xx)); - idx = 1; int _expr3 = idx; idx = (_expr3 - 1); float3x2 l0_ = GetMatmOnBaz(baz); @@ -137,7 +136,6 @@ void test_matrix_within_struct_accesses() int _expr36 = idx; int _expr38 = idx; float l6_ = GetMatmOnBaz(baz)[_expr36][_expr38]; - t = ConstructBaz(float3x2((1.0).xx, (2.0).xx, (3.0).xx)); int _expr51 = idx; idx = (_expr51 + 1); SetMatmOnBaz(t, float3x2((6.0).xx, (5.0).xx, (4.0).xx)); @@ -163,10 +161,9 @@ MatCx2InArray ConstructMatCx2InArray(float4x2 arg0[2]) { void test_matrix_within_array_within_struct_accesses() { - int idx_1 = (int)0; - MatCx2InArray t_1 = (MatCx2InArray)0; + int idx_1 = 1; + MatCx2InArray t_1 = ConstructMatCx2InArray((float4x2[2])0); - idx_1 = 1; int _expr3 = idx_1; idx_1 = (_expr3 - 1); float4x2 l0_1[2] = ((float4x2[2])nested_mat_cx2_.am); @@ -182,7 +179,6 @@ void test_matrix_within_array_within_struct_accesses() int _expr46 = idx_1; int _expr48 = idx_1; float l7_ = __get_col_of_mat4x2(nested_mat_cx2_.am[0], _expr46)[_expr48]; - t_1 = ConstructMatCx2InArray((float4x2[2])0); int _expr55 = idx_1; idx_1 = (_expr55 + 1); t_1.am = (__mat4x2[2])(float4x2[2])0; @@ -251,10 +247,9 @@ uint NagaBufferLengthRW(RWByteAddressBuffer buffer) float4 foo_vert(uint vi : SV_VertexID) : SV_Position { - float foo = (float)0; + float foo = 0.0; int c2_[5] = (int[5])0; - foo = 0.0; float baz_1 = foo; foo = 1.0; test_matrix_within_struct_accesses(); @@ -299,9 +294,8 @@ void assign_through_ptr(uint3 __local_invocation_id : SV_GroupThreadID) val = (uint)0; } GroupMemoryBarrierWithGroupSync(); - float4 arr[2] = (float4[2])0; + float4 arr[2] = Constructarray2_float4_((6.0).xxxx, (7.0).xxxx); - arr = Constructarray2_float4_((6.0).xxxx, (7.0).xxxx); assign_through_ptr_fn(val); assign_array_through_ptr_fn(arr); return; diff --git a/tests/out/hlsl/binding-arrays.hlsl b/tests/out/hlsl/binding-arrays.hlsl index 4a22c2746c..aa631b3225 100644 --- a/tests/out/hlsl/binding-arrays.hlsl +++ b/tests/out/hlsl/binding-arrays.hlsl @@ -51,17 +51,13 @@ uint NagaMSNumSamples2D(Texture2DMS tex) float4 main(FragmentInput_main fragmentinput_main) : SV_Target0 { FragmentIn fragment_in = { fragmentinput_main.index }; - uint u1_ = (uint)0; - uint2 u2_ = (uint2)0; - float v1_ = (float)0; - float4 v4_ = (float4)0; + uint u1_ = 0u; + uint2 u2_ = (0u).xx; + float v1_ = 0.0; + float4 v4_ = (0.0).xxxx; uint uniform_index = uni.index; uint non_uniform_index = fragment_in.index; - u1_ = 0u; - u2_ = (0u).xx; - v1_ = 0.0; - v4_ = (0.0).xxxx; float2 uv = (0.0).xx; int2 pix = (0).xx; uint2 _expr22 = u2_; diff --git a/tests/out/hlsl/bitcast.hlsl b/tests/out/hlsl/bitcast.hlsl index 00f4206a10..5208074002 100644 --- a/tests/out/hlsl/bitcast.hlsl +++ b/tests/out/hlsl/bitcast.hlsl @@ -1,25 +1,16 @@ [numthreads(1, 1, 1)] void main() { - int2 i2_ = (int2)0; - int3 i3_ = (int3)0; - int4 i4_ = (int4)0; - uint2 u2_ = (uint2)0; - uint3 u3_ = (uint3)0; - uint4 u4_ = (uint4)0; - float2 f2_ = (float2)0; - float3 f3_ = (float3)0; - float4 f4_ = (float4)0; + int2 i2_ = (0).xx; + int3 i3_ = (0).xxx; + int4 i4_ = (0).xxxx; + uint2 u2_ = (0u).xx; + uint3 u3_ = (0u).xxx; + uint4 u4_ = (0u).xxxx; + float2 f2_ = (0.0).xx; + float3 f3_ = (0.0).xxx; + float4 f4_ = (0.0).xxxx; - i2_ = (0).xx; - i3_ = (0).xxx; - i4_ = (0).xxxx; - u2_ = (0u).xx; - u3_ = (0u).xxx; - u4_ = (0u).xxxx; - f2_ = (0.0).xx; - f3_ = (0.0).xxx; - f4_ = (0.0).xxxx; int2 _expr27 = i2_; u2_ = asuint(_expr27); int3 _expr29 = i3_; diff --git a/tests/out/hlsl/bits.hlsl b/tests/out/hlsl/bits.hlsl index 55e1afbd80..8ae2f7e1fc 100644 --- a/tests/out/hlsl/bits.hlsl +++ b/tests/out/hlsl/bits.hlsl @@ -1,27 +1,17 @@ [numthreads(1, 1, 1)] void main() { - int i = (int)0; - int2 i2_ = (int2)0; - int3 i3_ = (int3)0; - int4 i4_ = (int4)0; - uint u = (uint)0; - uint2 u2_ = (uint2)0; - uint3 u3_ = (uint3)0; - uint4 u4_ = (uint4)0; - float2 f2_ = (float2)0; - float4 f4_ = (float4)0; + int i = 0; + int2 i2_ = (0).xx; + int3 i3_ = (0).xxx; + int4 i4_ = (0).xxxx; + uint u = 0u; + uint2 u2_ = (0u).xx; + uint3 u3_ = (0u).xxx; + uint4 u4_ = (0u).xxxx; + float2 f2_ = (0.0).xx; + float4 f4_ = (0.0).xxxx; - i = 0; - i2_ = (0).xx; - i3_ = (0).xxx; - i4_ = (0).xxxx; - u = 0u; - u2_ = (0u).xx; - u3_ = (0u).xxx; - u4_ = (0u).xxxx; - f2_ = (0.0).xx; - f4_ = (0.0).xxxx; float4 _expr28 = f4_; u = uint((int(round(clamp(_expr28[0], -1.0, 1.0) * 127.0)) & 0xFF) | ((int(round(clamp(_expr28[1], -1.0, 1.0) * 127.0)) & 0xFF) << 8) | ((int(round(clamp(_expr28[2], -1.0, 1.0) * 127.0)) & 0xFF) << 16) | ((int(round(clamp(_expr28[3], -1.0, 1.0) * 127.0)) & 0xFF) << 24)); float4 _expr30 = f4_; diff --git a/tests/out/hlsl/boids.hlsl b/tests/out/hlsl/boids.hlsl index 5400a5e3a8..bb6f6f9d1b 100644 --- a/tests/out/hlsl/boids.hlsl +++ b/tests/out/hlsl/boids.hlsl @@ -24,14 +24,14 @@ void main(uint3 global_invocation_id : SV_DispatchThreadID) { float2 vPos = (float2)0; float2 vVel = (float2)0; - float2 cMass = (float2)0; - float2 cVel = (float2)0; - float2 colVel = (float2)0; - int cMassCount = (int)0; - int cVelCount = (int)0; + float2 cMass = float2(0.0, 0.0); + float2 cVel = float2(0.0, 0.0); + float2 colVel = float2(0.0, 0.0); + int cMassCount = 0; + int cVelCount = 0; float2 pos = (float2)0; float2 vel = (float2)0; - uint i = (uint)0; + uint i = 0u; uint index = global_invocation_id.x; if ((index >= NUM_PARTICLES)) { @@ -41,12 +41,6 @@ void main(uint3 global_invocation_id : SV_DispatchThreadID) vPos = _expr8; float2 _expr14 = asfloat(particlesSrc.Load2(8+index*16+0)); vVel = _expr14; - cMass = float2(0.0, 0.0); - cVel = float2(0.0, 0.0); - colVel = float2(0.0, 0.0); - cMassCount = 0; - cVelCount = 0; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { diff --git a/tests/out/hlsl/collatz.hlsl b/tests/out/hlsl/collatz.hlsl index 92539ee2f4..a8a5a776e3 100644 --- a/tests/out/hlsl/collatz.hlsl +++ b/tests/out/hlsl/collatz.hlsl @@ -3,10 +3,9 @@ RWByteAddressBuffer v_indices : register(u0); uint collatz_iterations(uint n_base) { uint n = (uint)0; - uint i = (uint)0; + uint i = 0u; n = n_base; - i = 0u; while(true) { uint _expr4 = n; if ((_expr4 > 1u)) { diff --git a/tests/out/hlsl/dualsource.hlsl b/tests/out/hlsl/dualsource.hlsl index 1d5b53d6f8..36784b13d2 100644 --- a/tests/out/hlsl/dualsource.hlsl +++ b/tests/out/hlsl/dualsource.hlsl @@ -17,11 +17,9 @@ FragmentOutput ConstructFragmentOutput(float4 arg0, float4 arg1) { FragmentOutput main(FragmentInput_main fragmentinput_main) { float4 position = fragmentinput_main.position_1; - float4 color = (float4)0; - float4 mask = (float4)0; + float4 color = float4(0.4, 0.3, 0.2, 0.1); + float4 mask = float4(0.9, 0.8, 0.7, 0.6); - color = float4(0.4, 0.3, 0.2, 0.1); - mask = float4(0.9, 0.8, 0.7, 0.6); float4 _expr13 = color; float4 _expr14 = mask; const FragmentOutput fragmentoutput = ConstructFragmentOutput(_expr13, _expr14); diff --git a/tests/out/hlsl/globals.hlsl b/tests/out/hlsl/globals.hlsl index b4994837cd..55faf060d0 100644 --- a/tests/out/hlsl/globals.hlsl +++ b/tests/out/hlsl/globals.hlsl @@ -80,10 +80,9 @@ FooStruct ConstructFooStruct(float3 arg0, float arg1) { void test_msl_packed_vec3_() { - int idx = (int)0; + int idx = 1; alignment.Store3(0, asuint((1.0).xxx)); - idx = 1; alignment.Store(0+0, asuint(1.0)); alignment.Store(0+0, asuint(2.0)); int _expr16 = idx; @@ -113,8 +112,8 @@ void main(uint3 __local_invocation_id : SV_GroupThreadID) at_1 = (uint)0; } GroupMemoryBarrierWithGroupSync(); - float Foo = (float)0; - bool at = (bool)0; + float Foo = 1.0; + bool at = true; test_msl_packed_vec3_(); float4x2 _expr5 = ((float4x2)global_nested_arrays_of_matrices_4x2_[0][0]); @@ -134,7 +133,5 @@ void main(uint3 __local_invocation_id : SV_GroupThreadID) alignment.Store(12, asuint(4.0)); wg[1] = float(((NagaBufferLength(dummy) - 0) / 8)); at_1 = 2u; - Foo = 1.0; - at = true; return; } diff --git a/tests/out/hlsl/hlsl-keyword.hlsl b/tests/out/hlsl/hlsl-keyword.hlsl index 8602525e29..9259549ab2 100644 --- a/tests/out/hlsl/hlsl-keyword.hlsl +++ b/tests/out/hlsl/hlsl-keyword.hlsl @@ -1,8 +1,7 @@ float4 fs_main() : SV_Target0 { - float4 Pass_ = (float4)0; + float4 Pass_ = float4(1.0, 1.0, 1.0, 1.0); - Pass_ = float4(1.0, 1.0, 1.0, 1.0); float4 _expr6 = Pass_; return _expr6; } diff --git a/tests/out/hlsl/interface.hlsl b/tests/out/hlsl/interface.hlsl index 9251396c7a..3784864edf 100644 --- a/tests/out/hlsl/interface.hlsl +++ b/tests/out/hlsl/interface.hlsl @@ -87,9 +87,8 @@ void compute(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThr precise float4 vertex_two_structs(Input1_ in1_, Input2_ in2_) : SV_Position { - uint index = (uint)0; + uint index = 2u; - index = 2u; uint _expr8 = index; return float4(float((_NagaConstants.base_vertex + in1_.index)), float((_NagaConstants.base_instance + in2_.index)), float(_expr8), 0.0); } diff --git a/tests/out/hlsl/operators.hlsl b/tests/out/hlsl/operators.hlsl index 90c6723e2b..7074d1d562 100644 --- a/tests/out/hlsl/operators.hlsl +++ b/tests/out/hlsl/operators.hlsl @@ -25,9 +25,8 @@ float4 splat() float2 splat_assignment() { - float2 a = (float2)0; + float2 a = (2.0).xx; - a = (2.0).xx; float2 _expr4 = a; a = (_expr4 + (1.0).xx); float2 _expr8 = a; @@ -153,10 +152,9 @@ void comparison() void assignment() { - int a_1 = (int)0; + int a_1 = 1; int3 vec0_ = (int3)0; - a_1 = 1; int _expr3 = a_1; a_1 = (_expr3 + 1); int _expr6 = a_1; @@ -183,7 +181,6 @@ void assignment() a_1 = (_expr33 + 1); int _expr36 = a_1; a_1 = (_expr36 - 1); - vec0_ = (int3)0; int _expr42 = vec0_.y; vec0_.y = (_expr42 + 1); int _expr46 = vec0_.y; diff --git a/tests/out/hlsl/shadow.hlsl b/tests/out/hlsl/shadow.hlsl index 7116e803eb..91a918283b 100644 --- a/tests/out/hlsl/shadow.hlsl +++ b/tests/out/hlsl/shadow.hlsl @@ -88,12 +88,10 @@ Light ConstructLight(float4x4 arg0, float4 arg1, float4 arg2) { float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 { VertexOutput in_ = { fragmentinput_fs_main.proj_position_1, fragmentinput_fs_main.world_normal_1, fragmentinput_fs_main.world_position_1 }; - float3 color = (float3)0; - uint i = (uint)0; + float3 color = c_ambient; + uint i = 0u; float3 normal_1 = normalize(in_.world_normal); - color = c_ambient; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { @@ -126,12 +124,10 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinput_fs_main_without_storage) : SV_Target0 { VertexOutput in_1 = { fragmentinput_fs_main_without_storage.proj_position_2, fragmentinput_fs_main_without_storage.world_normal_2, fragmentinput_fs_main_without_storage.world_position_2 }; - float3 color_1 = (float3)0; - uint i_1 = (uint)0; + float3 color_1 = c_ambient; + uint i_1 = 0u; float3 normal_2 = normalize(in_1.world_normal); - color_1 = c_ambient; - i_1 = 0u; bool loop_init_1 = true; while(true) { if (!loop_init_1) { diff --git a/tests/out/ir/access.compact.ron b/tests/out/ir/access.compact.ron index b725765d46..1c0220141d 100644 --- a/tests/out/ir/access.compact.ron +++ b/tests/out/ir/access.compact.ron @@ -396,12 +396,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 16, - init: None, + init: Some(49), ), ], expressions: [ @@ -697,10 +697,6 @@ 41: "l6", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -769,10 +765,6 @@ start: 46, end: 49, )), - Store( - pointer: 50, - value: 49, - ), Emit(( start: 51, end: 53, @@ -890,12 +882,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 20, - init: None, + init: Some(53), ), ], expressions: [ @@ -1245,10 +1237,6 @@ 51: "l7", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -1341,10 +1329,6 @@ start: 52, end: 53, )), - Store( - pointer: 54, - value: 53, - ), Emit(( start: 55, end: 57, @@ -1675,7 +1659,7 @@ ( name: Some("foo"), ty: 21, - init: None, + init: Some(2), ), ( name: Some("c2"), @@ -1846,10 +1830,6 @@ 46: "value", }, body: [ - Store( - pointer: 3, - value: 2, - ), Emit(( start: 3, end: 4, @@ -2160,7 +2140,7 @@ ( name: Some("arr"), ty: 28, - init: None, + init: Some(5), ), ], expressions: [ @@ -2194,10 +2174,6 @@ start: 3, end: 5, )), - Store( - pointer: 6, - value: 5, - ), Call( function: 5, arguments: [ diff --git a/tests/out/ir/access.ron b/tests/out/ir/access.ron index e2a7aa9466..fcdd3b8b7c 100644 --- a/tests/out/ir/access.ron +++ b/tests/out/ir/access.ron @@ -455,12 +455,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 16, - init: None, + init: Some(54), ), ], expressions: [ @@ -766,10 +766,6 @@ 46: "l6", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -838,10 +834,6 @@ start: 51, end: 54, )), - Store( - pointer: 55, - value: 54, - ), Emit(( start: 56, end: 58, @@ -959,12 +951,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 21, - init: None, + init: Some(65), ), ], expressions: [ @@ -1338,10 +1330,6 @@ 63: "l7", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -1434,10 +1422,6 @@ start: 64, end: 65, )), - Store( - pointer: 66, - value: 65, - ), Emit(( start: 67, end: 69, @@ -1770,7 +1754,7 @@ ( name: Some("foo"), ty: 22, - init: None, + init: Some(2), ), ( name: Some("c2"), @@ -1942,10 +1926,6 @@ 47: "value", }, body: [ - Store( - pointer: 3, - value: 2, - ), Emit(( start: 3, end: 4, @@ -2258,7 +2238,7 @@ ( name: Some("arr"), ty: 32, - init: None, + init: Some(5), ), ], expressions: [ @@ -2292,10 +2272,6 @@ start: 3, end: 5, )), - Store( - pointer: 6, - value: 5, - ), Call( function: 5, arguments: [ diff --git a/tests/out/ir/collatz.compact.ron b/tests/out/ir/collatz.compact.ron index fb8ff825e1..7cad54b713 100644 --- a/tests/out/ir/collatz.compact.ron +++ b/tests/out/ir/collatz.compact.ron @@ -82,7 +82,7 @@ ( name: Some("i"), ty: 1, - init: None, + init: Some(3), ), ], expressions: [ @@ -159,10 +159,6 @@ pointer: 2, value: 1, ), - Store( - pointer: 4, - value: 3, - ), Loop( body: [ Emit(( diff --git a/tests/out/ir/collatz.ron b/tests/out/ir/collatz.ron index 615c638506..8146909c1e 100644 --- a/tests/out/ir/collatz.ron +++ b/tests/out/ir/collatz.ron @@ -86,7 +86,7 @@ ( name: Some("i"), ty: 1, - init: None, + init: Some(3), ), ], expressions: [ @@ -163,10 +163,6 @@ pointer: 2, value: 1, ), - Store( - pointer: 4, - value: 3, - ), Loop( body: [ Emit(( diff --git a/tests/out/ir/shadow.compact.ron b/tests/out/ir/shadow.compact.ron index 313938997f..9ca6799c21 100644 --- a/tests/out/ir/shadow.compact.ron +++ b/tests/out/ir/shadow.compact.ron @@ -356,8 +356,6 @@ Literal(I32(0)), Literal(I32(1)), Literal(I32(2)), - Constant(6), - Constant(8), ], functions: [ ( @@ -558,12 +556,12 @@ ( name: Some("color"), ty: 2, - init: Some(23), + init: Some(20), ), ( name: Some("i"), ty: 3, - init: Some(24), + init: Some(22), ), ], expressions: [ @@ -586,65 +584,67 @@ Constant(10), Constant(12), Constant(1), + Constant(6), LocalVariable(1), + Constant(8), LocalVariable(2), Load( - pointer: 21, + pointer: 23, ), AccessIndex( base: 1, index: 0, ), Access( - base: 23, + base: 25, index: 17, ), Load( - pointer: 24, + pointer: 26, ), Math( fun: Min, - arg: 25, + arg: 27, arg1: Some(13), arg2: None, arg3: None, ), Binary( op: GreaterEqual, - left: 22, - right: 26, + left: 24, + right: 28, ), Load( - pointer: 20, + pointer: 21, ), Load( - pointer: 21, + pointer: 23, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 30, - index: 31, + base: 32, + index: 33, ), AccessIndex( - base: 32, + base: 34, index: 0, ), Load( - pointer: 33, + pointer: 35, ), Load( pointer: 3, ), Binary( op: Multiply, - left: 34, - right: 35, + left: 36, + right: 37, ), CallResult(1), Load( @@ -652,7 +652,7 @@ ), Math( fun: Normalize, - arg: 38, + arg: 40, arg1: None, arg2: None, arg3: None, @@ -662,73 +662,73 @@ index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 40, - index: 41, + base: 42, + index: 43, ), AccessIndex( - base: 42, + base: 44, index: 1, ), Access( - base: 43, + base: 45, index: 15, ), Load( - pointer: 44, + pointer: 46, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 46, - index: 47, + base: 48, + index: 49, ), AccessIndex( - base: 48, + base: 50, index: 1, ), Access( - base: 49, + base: 51, index: 18, ), Load( - pointer: 50, + pointer: 52, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 52, - index: 53, + base: 54, + index: 55, ), AccessIndex( - base: 54, + base: 56, index: 1, ), Access( - base: 55, + base: 57, index: 8, ), Load( - pointer: 56, + pointer: 58, ), Compose( ty: 2, components: [ - 45, - 51, - 57, + 47, + 53, + 59, ], ), Access( @@ -736,160 +736,160 @@ index: 16, ), Load( - pointer: 59, + pointer: 61, ), Access( base: 3, index: 7, ), Load( - pointer: 61, + pointer: 63, ), Access( base: 3, index: 10, ), Load( - pointer: 63, + pointer: 65, ), Compose( ty: 2, components: [ - 60, 62, 64, + 66, ], ), Binary( op: Subtract, - left: 58, - right: 65, + left: 60, + right: 67, ), Math( fun: Normalize, - arg: 66, + arg: 68, arg1: None, arg2: None, arg3: None, ), Math( fun: Dot, - arg: 39, - arg1: Some(67), + arg: 41, + arg1: Some(69), arg2: None, arg3: None, ), Math( fun: Max, arg: 19, - arg1: Some(68), + arg1: Some(70), arg2: None, arg3: None, ), Binary( op: Multiply, - left: 37, - right: 69, + left: 39, + right: 71, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 71, - index: 72, + base: 73, + index: 74, ), AccessIndex( - base: 73, + base: 75, index: 2, ), Access( - base: 74, + base: 76, index: 6, ), Load( - pointer: 75, + pointer: 77, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 77, - index: 78, + base: 79, + index: 80, ), AccessIndex( - base: 79, + base: 81, index: 2, ), Access( - base: 80, + base: 82, index: 9, ), Load( - pointer: 81, + pointer: 83, ), AccessIndex( base: 4, index: 0, ), Load( - pointer: 21, + pointer: 23, ), Access( - base: 83, - index: 84, + base: 85, + index: 86, ), AccessIndex( - base: 85, + base: 87, index: 2, ), Access( - base: 86, + base: 88, index: 11, ), Load( - pointer: 87, + pointer: 89, ), Compose( ty: 2, components: [ - 76, - 82, - 88, + 78, + 84, + 90, ], ), Binary( op: Multiply, - left: 89, - right: 70, + left: 91, + right: 72, ), Binary( op: Add, - left: 28, - right: 90, + left: 30, + right: 92, ), Load( - pointer: 21, + pointer: 23, ), Binary( op: Add, - left: 92, + left: 94, right: 12, ), Load( - pointer: 20, + pointer: 21, ), Compose( ty: 4, components: [ - 94, + 96, 14, ], ), @@ -899,57 +899,57 @@ Loop( body: [ Emit(( - start: 21, - end: 27, + start: 23, + end: 29, )), If( - condition: 27, + condition: 29, accept: [ Break, ], reject: [], ), Emit(( - start: 27, - end: 36, + start: 29, + end: 38, )), Call( function: 1, arguments: [ - 29, - 36, + 31, + 38, ], - result: Some(37), + result: Some(39), ), Emit(( - start: 37, - end: 91, + start: 39, + end: 93, )), Store( - pointer: 20, - value: 91, + pointer: 21, + value: 93, ), Continue, ], continuing: [ Emit(( - start: 91, - end: 93, + start: 93, + end: 95, )), Store( - pointer: 21, - value: 93, + pointer: 23, + value: 95, ), ], break_if: None, ), Emit(( - start: 93, - end: 95, + start: 95, + end: 97, )), Store( pointer: 5, - value: 95, + value: 97, ), Return( value: None, diff --git a/tests/out/ir/shadow.ron b/tests/out/ir/shadow.ron index bfde76d6ae..07bf66fcc8 100644 --- a/tests/out/ir/shadow.ron +++ b/tests/out/ir/shadow.ron @@ -591,8 +591,6 @@ Literal(I32(0)), Literal(I32(2)), Literal(I32(2)), - Constant(6), - Constant(8), ], functions: [ ( @@ -829,12 +827,12 @@ ( name: Some("color"), ty: 2, - init: Some(39), + init: Some(43), ), ( name: Some("i"), ty: 3, - init: Some(40), + init: Some(45), ), ], expressions: [ @@ -880,65 +878,67 @@ Constant(18), Constant(6), Constant(1), + Constant(6), LocalVariable(1), + Constant(8), LocalVariable(2), Load( - pointer: 44, + pointer: 46, ), AccessIndex( base: 1, index: 0, ), Access( - base: 46, + base: 48, index: 37, ), Load( - pointer: 47, + pointer: 49, ), Math( fun: Min, - arg: 48, + arg: 50, arg1: Some(28), arg2: None, arg3: None, ), Binary( op: GreaterEqual, - left: 45, - right: 49, + left: 47, + right: 51, ), Load( - pointer: 43, + pointer: 44, ), Load( - pointer: 44, + pointer: 46, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 53, - index: 54, + base: 55, + index: 56, ), AccessIndex( - base: 55, + base: 57, index: 0, ), Load( - pointer: 56, + pointer: 58, ), Load( pointer: 3, ), Binary( op: Multiply, - left: 57, - right: 58, + left: 59, + right: 60, ), CallResult(1), Load( @@ -946,7 +946,7 @@ ), Math( fun: Normalize, - arg: 61, + arg: 63, arg1: None, arg2: None, arg3: None, @@ -956,73 +956,73 @@ index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 63, - index: 64, + base: 65, + index: 66, ), AccessIndex( - base: 65, + base: 67, index: 1, ), Access( - base: 66, + base: 68, index: 31, ), Load( - pointer: 67, + pointer: 69, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 69, - index: 70, + base: 71, + index: 72, ), AccessIndex( - base: 71, + base: 73, index: 1, ), Access( - base: 72, + base: 74, index: 38, ), Load( - pointer: 73, + pointer: 75, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 75, - index: 76, + base: 77, + index: 78, ), AccessIndex( - base: 77, + base: 79, index: 1, ), Access( - base: 78, + base: 80, index: 13, ), Load( - pointer: 79, + pointer: 81, ), Compose( ty: 2, components: [ - 68, - 74, - 80, + 70, + 76, + 82, ], ), Access( @@ -1030,160 +1030,160 @@ index: 36, ), Load( - pointer: 82, + pointer: 84, ), Access( base: 3, index: 12, ), Load( - pointer: 84, + pointer: 86, ), Access( base: 3, index: 23, ), Load( - pointer: 86, + pointer: 88, ), Compose( ty: 2, components: [ - 83, 85, 87, + 89, ], ), Binary( op: Subtract, - left: 81, - right: 88, + left: 83, + right: 90, ), Math( fun: Normalize, - arg: 89, + arg: 91, arg1: None, arg2: None, arg3: None, ), Math( fun: Dot, - arg: 62, - arg1: Some(90), + arg: 64, + arg1: Some(92), arg2: None, arg3: None, ), Math( fun: Max, arg: 42, - arg1: Some(91), + arg1: Some(93), arg2: None, arg3: None, ), Binary( op: Multiply, - left: 60, - right: 92, + left: 62, + right: 94, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 94, - index: 95, + base: 96, + index: 97, ), AccessIndex( - base: 96, + base: 98, index: 2, ), Access( - base: 97, + base: 99, index: 10, ), Load( - pointer: 98, + pointer: 100, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 100, - index: 101, + base: 102, + index: 103, ), AccessIndex( - base: 102, + base: 104, index: 2, ), Access( - base: 103, + base: 105, index: 19, ), Load( - pointer: 104, + pointer: 106, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 44, + pointer: 46, ), Access( - base: 106, - index: 107, + base: 108, + index: 109, ), AccessIndex( - base: 108, + base: 110, index: 2, ), Access( - base: 109, + base: 111, index: 26, ), Load( - pointer: 110, + pointer: 112, ), Compose( ty: 2, components: [ - 99, - 105, - 111, + 101, + 107, + 113, ], ), Binary( op: Multiply, - left: 112, - right: 93, + left: 114, + right: 95, ), Binary( op: Add, - left: 51, - right: 113, + left: 53, + right: 115, ), Load( - pointer: 44, + pointer: 46, ), Binary( op: Add, - left: 115, + left: 117, right: 27, ), Load( - pointer: 43, + pointer: 44, ), Compose( ty: 4, components: [ - 117, + 119, 30, ], ), @@ -1193,57 +1193,57 @@ Loop( body: [ Emit(( - start: 44, - end: 50, + start: 46, + end: 52, )), If( - condition: 50, + condition: 52, accept: [ Break, ], reject: [], ), Emit(( - start: 50, - end: 59, + start: 52, + end: 61, )), Call( function: 1, arguments: [ - 52, - 59, + 54, + 61, ], - result: Some(60), + result: Some(62), ), Emit(( - start: 60, - end: 114, + start: 62, + end: 116, )), Store( - pointer: 43, - value: 114, + pointer: 44, + value: 116, ), Continue, ], continuing: [ Emit(( - start: 114, - end: 116, + start: 116, + end: 118, )), Store( - pointer: 44, - value: 116, + pointer: 46, + value: 118, ), ], break_if: None, ), Emit(( - start: 116, - end: 118, + start: 118, + end: 120, )), Store( pointer: 7, - value: 118, + value: 120, ), Return( value: None, diff --git a/tests/out/msl/access.msl b/tests/out/msl/access.msl index c35139a8cf..3d57ebd7c8 100644 --- a/tests/out/msl/access.msl +++ b/tests/out/msl/access.msl @@ -61,9 +61,8 @@ struct type_22 { void test_matrix_within_struct_accesses( constant Baz& baz ) { - int idx = {}; - Baz t = {}; - idx = 1; + int idx = 1; + Baz t = Baz {metal::float3x2(metal::float2(1.0), metal::float2(2.0), metal::float2(3.0))}; int _e3 = idx; idx = _e3 - 1; metal::float3x2 l0_ = baz.m; @@ -78,7 +77,6 @@ void test_matrix_within_struct_accesses( int _e36 = idx; int _e38 = idx; float l6_ = baz.m[_e36][_e38]; - t = Baz {metal::float3x2(metal::float2(1.0), metal::float2(2.0), metal::float2(3.0))}; int _e51 = idx; idx = _e51 + 1; t.m = metal::float3x2(metal::float2(6.0), metal::float2(5.0), metal::float2(4.0)); @@ -99,9 +97,8 @@ void test_matrix_within_struct_accesses( void test_matrix_within_array_within_struct_accesses( constant MatCx2InArray& nested_mat_cx2_ ) { - int idx_1 = {}; - MatCx2InArray t_1 = {}; - idx_1 = 1; + int idx_1 = 1; + MatCx2InArray t_1 = MatCx2InArray {type_14 {}}; int _e3 = idx_1; idx_1 = _e3 - 1; type_14 l0_1 = nested_mat_cx2_.am; @@ -117,7 +114,6 @@ void test_matrix_within_array_within_struct_accesses( int _e46 = idx_1; int _e48 = idx_1; float l7_ = nested_mat_cx2_.am.inner[0][_e46][_e48]; - t_1 = MatCx2InArray {type_14 {}}; int _e55 = idx_1; idx_1 = _e55 + 1; t_1.am = type_14 {}; @@ -176,9 +172,8 @@ vertex foo_vertOutput foo_vert( , constant MatCx2InArray& nested_mat_cx2_ [[buffer(3)]] , constant _mslBufferSizes& _buffer_sizes [[buffer(24)]] ) { - float foo = {}; + float foo = 0.0; type_20 c2_ = {}; - foo = 0.0; float baz_1 = foo; foo = 1.0; test_matrix_within_struct_accesses(baz); @@ -222,8 +217,7 @@ kernel void assign_through_ptr( val = {}; } metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); - type_22 arr = {}; - arr = type_22 {metal::float4(6.0), metal::float4(7.0)}; + type_22 arr = type_22 {metal::float4(6.0), metal::float4(7.0)}; assign_through_ptr_fn(val); assign_array_through_ptr_fn(arr); return; diff --git a/tests/out/msl/binding-arrays.msl b/tests/out/msl/binding-arrays.msl index f7597b5c76..f3548c9e79 100644 --- a/tests/out/msl/binding-arrays.msl +++ b/tests/out/msl/binding-arrays.msl @@ -36,16 +36,12 @@ fragment main_Output main_( , constant UniformIndex& uni [[user(fake0)]] ) { const FragmentIn fragment_in = { varyings.index }; - uint u1_ = {}; - metal::uint2 u2_ = {}; - float v1_ = {}; - metal::float4 v4_ = {}; + uint u1_ = 0u; + metal::uint2 u2_ = metal::uint2(0u); + float v1_ = 0.0; + metal::float4 v4_ = metal::float4(0.0); uint uniform_index = uni.index; uint non_uniform_index = fragment_in.index; - u1_ = 0u; - u2_ = metal::uint2(0u); - v1_ = 0.0; - v4_ = metal::float4(0.0); metal::float2 uv = metal::float2(0.0); metal::int2 pix = metal::int2(0); metal::uint2 _e22 = u2_; diff --git a/tests/out/msl/bitcast.msl b/tests/out/msl/bitcast.msl index a0cf093b7f..ca8bc329bb 100644 --- a/tests/out/msl/bitcast.msl +++ b/tests/out/msl/bitcast.msl @@ -7,24 +7,15 @@ using metal::uint; kernel void main_( ) { - metal::int2 i2_ = {}; - metal::int3 i3_ = {}; - metal::int4 i4_ = {}; - metal::uint2 u2_ = {}; - metal::uint3 u3_ = {}; - metal::uint4 u4_ = {}; - metal::float2 f2_ = {}; - metal::float3 f3_ = {}; - metal::float4 f4_ = {}; - i2_ = metal::int2(0); - i3_ = metal::int3(0); - i4_ = metal::int4(0); - u2_ = metal::uint2(0u); - u3_ = metal::uint3(0u); - u4_ = metal::uint4(0u); - f2_ = metal::float2(0.0); - f3_ = metal::float3(0.0); - f4_ = metal::float4(0.0); + metal::int2 i2_ = metal::int2(0); + metal::int3 i3_ = metal::int3(0); + metal::int4 i4_ = metal::int4(0); + metal::uint2 u2_ = metal::uint2(0u); + metal::uint3 u3_ = metal::uint3(0u); + metal::uint4 u4_ = metal::uint4(0u); + metal::float2 f2_ = metal::float2(0.0); + metal::float3 f3_ = metal::float3(0.0); + metal::float4 f4_ = metal::float4(0.0); metal::int2 _e27 = i2_; u2_ = as_type(_e27); metal::int3 _e29 = i3_; diff --git a/tests/out/msl/bits.msl b/tests/out/msl/bits.msl index 2a00b6b843..7d73568b7f 100644 --- a/tests/out/msl/bits.msl +++ b/tests/out/msl/bits.msl @@ -7,26 +7,16 @@ using metal::uint; kernel void main_( ) { - int i = {}; - metal::int2 i2_ = {}; - metal::int3 i3_ = {}; - metal::int4 i4_ = {}; - uint u = {}; - metal::uint2 u2_ = {}; - metal::uint3 u3_ = {}; - metal::uint4 u4_ = {}; - metal::float2 f2_ = {}; - metal::float4 f4_ = {}; - i = 0; - i2_ = metal::int2(0); - i3_ = metal::int3(0); - i4_ = metal::int4(0); - u = 0u; - u2_ = metal::uint2(0u); - u3_ = metal::uint3(0u); - u4_ = metal::uint4(0u); - f2_ = metal::float2(0.0); - f4_ = metal::float4(0.0); + int i = 0; + metal::int2 i2_ = metal::int2(0); + metal::int3 i3_ = metal::int3(0); + metal::int4 i4_ = metal::int4(0); + uint u = 0u; + metal::uint2 u2_ = metal::uint2(0u); + metal::uint3 u3_ = metal::uint3(0u); + metal::uint4 u4_ = metal::uint4(0u); + metal::float2 f2_ = metal::float2(0.0); + metal::float4 f4_ = metal::float4(0.0); metal::float4 _e28 = f4_; u = metal::pack_float_to_snorm4x8(_e28); metal::float4 _e30 = f4_; diff --git a/tests/out/msl/boids.msl b/tests/out/msl/boids.msl index 1a81aaf684..de9d7186a8 100644 --- a/tests/out/msl/boids.msl +++ b/tests/out/msl/boids.msl @@ -39,14 +39,14 @@ kernel void main_( ) { metal::float2 vPos = {}; metal::float2 vVel = {}; - metal::float2 cMass = {}; - metal::float2 cVel = {}; - metal::float2 colVel = {}; - int cMassCount = {}; - int cVelCount = {}; + metal::float2 cMass = metal::float2(0.0, 0.0); + metal::float2 cVel = metal::float2(0.0, 0.0); + metal::float2 colVel = metal::float2(0.0, 0.0); + int cMassCount = 0; + int cVelCount = 0; metal::float2 pos = {}; metal::float2 vel = {}; - uint i = {}; + uint i = 0u; uint index = global_invocation_id.x; if (index >= NUM_PARTICLES) { return; @@ -55,12 +55,6 @@ kernel void main_( vPos = _e8; metal::float2 _e14 = particlesSrc.particles[index].vel; vVel = _e14; - cMass = metal::float2(0.0, 0.0); - cVel = metal::float2(0.0, 0.0); - colVel = metal::float2(0.0, 0.0); - cMassCount = 0; - cVelCount = 0; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { diff --git a/tests/out/msl/collatz.msl b/tests/out/msl/collatz.msl index 88f9521a27..3c8bcf1722 100644 --- a/tests/out/msl/collatz.msl +++ b/tests/out/msl/collatz.msl @@ -17,9 +17,8 @@ uint collatz_iterations( uint n_base ) { uint n = {}; - uint i = {}; + uint i = 0u; n = n_base; - i = 0u; while(true) { uint _e4 = n; if (_e4 > 1u) { diff --git a/tests/out/msl/dualsource.msl b/tests/out/msl/dualsource.msl index 92b1909f8b..871957c81f 100644 --- a/tests/out/msl/dualsource.msl +++ b/tests/out/msl/dualsource.msl @@ -18,10 +18,8 @@ struct main_Output { fragment main_Output main_( metal::float4 position [[position]] ) { - metal::float4 color = {}; - metal::float4 mask = {}; - color = metal::float4(0.4, 0.3, 0.2, 0.1); - mask = metal::float4(0.9, 0.8, 0.7, 0.6); + metal::float4 color = metal::float4(0.4, 0.3, 0.2, 0.1); + metal::float4 mask = metal::float4(0.9, 0.8, 0.7, 0.6); metal::float4 _e13 = color; metal::float4 _e14 = mask; const auto _tmp = FragmentOutput {_e13, _e14}; diff --git a/tests/out/msl/globals.msl b/tests/out/msl/globals.msl index 9e964d6c1e..9d09db8055 100644 --- a/tests/out/msl/globals.msl +++ b/tests/out/msl/globals.msl @@ -42,9 +42,8 @@ void test_msl_packed_vec3_as_arg( void test_msl_packed_vec3_( device FooStruct& alignment ) { - int idx = {}; + int idx = 1; alignment.v3_ = metal::float3(1.0); - idx = 1; alignment.v3_[0] = 1.0; alignment.v3_[0] = 2.0; int _e16 = idx; @@ -77,8 +76,8 @@ kernel void main_( metal::atomic_store_explicit(&at_1, 0, metal::memory_order_relaxed); } metal::threadgroup_barrier(metal::mem_flags::mem_threadgroup); - float Foo = {}; - bool at = {}; + float Foo = 1.0; + bool at = true; test_msl_packed_vec3_(alignment); metal::float4x2 _e5 = global_nested_arrays_of_matrices_4x2_.inner[0].inner[0]; metal::float4 _e10 = global_nested_arrays_of_matrices_2x4_.inner[0].inner[0][0]; @@ -97,7 +96,5 @@ kernel void main_( alignment.v1_ = 4.0; wg.inner[1] = static_cast(1 + (_buffer_sizes.size3 - 0 - 8) / 8); metal::atomic_store_explicit(&at_1, 2u, metal::memory_order_relaxed); - Foo = 1.0; - at = true; return; } diff --git a/tests/out/msl/interface.msl b/tests/out/msl/interface.msl index c9b93d86a6..d03912fabd 100644 --- a/tests/out/msl/interface.msl +++ b/tests/out/msl/interface.msl @@ -97,8 +97,7 @@ vertex vertex_two_structsOutput vertex_two_structs( ) { const Input1_ in1_ = { index_1 }; const Input2_ in2_ = { index_2 }; - uint index = {}; - index = 2u; + uint index = 2u; uint _e8 = index; return vertex_two_structsOutput { metal::float4(static_cast(in1_.index), static_cast(in2_.index), static_cast(_e8), 0.0), 1.0 }; } diff --git a/tests/out/msl/operators.msl b/tests/out/msl/operators.msl index 869f086736..2a7463646f 100644 --- a/tests/out/msl/operators.msl +++ b/tests/out/msl/operators.msl @@ -31,8 +31,7 @@ metal::float4 splat( metal::float2 splat_assignment( ) { - metal::float2 a = {}; - a = metal::float2(2.0); + metal::float2 a = metal::float2(2.0); metal::float2 _e4 = a; a = _e4 + metal::float2(1.0); metal::float2 _e8 = a; @@ -159,9 +158,8 @@ void comparison( void assignment( ) { - int a_1 = {}; - metal::int3 vec0_ = {}; - a_1 = 1; + int a_1 = 1; + metal::int3 vec0_ = metal::int3 {}; int _e3 = a_1; a_1 = _e3 + 1; int _e6 = a_1; @@ -188,7 +186,6 @@ void assignment( a_1 = _e33 + 1; int _e36 = a_1; a_1 = _e36 - 1; - vec0_ = metal::int3 {}; int _e42 = vec0_.y; vec0_.y = _e42 + 1; int _e46 = vec0_.y; diff --git a/tests/out/msl/policy-mix.msl b/tests/out/msl/policy-mix.msl index f6a4fe5d6d..bb7c12671a 100644 --- a/tests/out/msl/policy-mix.msl +++ b/tests/out/msl/policy-mix.msl @@ -42,8 +42,7 @@ metal::float4 mock_function( threadgroup type_5& in_workgroup, thread type_6& in_private ) { - type_9 in_function = {}; - in_function = type_9 {metal::float4(0.707, 0.0, 0.0, 1.0), metal::float4(0.0, 0.707, 0.0, 1.0)}; + type_9 in_function = type_9 {metal::float4(0.707, 0.0, 0.0, 1.0), metal::float4(0.0, 0.707, 0.0, 1.0)}; metal::float4 _e18 = in_storage.a.inner[i]; metal::float4 _e22 = in_uniform.a.inner[i]; metal::float4 _e25 = (uint(l) < image_2d_array.get_num_mip_levels() && uint(i) < image_2d_array.get_array_size() && metal::all(metal::uint2(c) < metal::uint2(image_2d_array.get_width(l), image_2d_array.get_height(l))) ? image_2d_array.read(metal::uint2(c), i, l): DefaultConstructible()); diff --git a/tests/out/msl/shadow.msl b/tests/out/msl/shadow.msl index 53f320344a..15dd042b8d 100644 --- a/tests/out/msl/shadow.msl +++ b/tests/out/msl/shadow.msl @@ -97,11 +97,9 @@ fragment fs_mainOutput fs_main( , constant _mslBufferSizes& _buffer_sizes [[user(fake0)]] ) { const VertexOutput in = { proj_position, varyings_1.world_normal, varyings_1.world_position }; - metal::float3 color = {}; - uint i = {}; + metal::float3 color = c_ambient; + uint i = 0u; metal::float3 normal_1 = metal::normalize(in.world_normal); - color = c_ambient; - i = 0u; bool loop_init = true; while(true) { if (!loop_init) { @@ -149,11 +147,9 @@ fragment fs_main_without_storageOutput fs_main_without_storage( , metal::sampler sampler_shadow [[user(fake0)]] ) { const VertexOutput in_1 = { proj_position_1, varyings_2.world_normal, varyings_2.world_position }; - metal::float3 color_1 = {}; - uint i_1 = {}; + metal::float3 color_1 = c_ambient; + uint i_1 = 0u; metal::float3 normal_2 = metal::normalize(in_1.world_normal); - color_1 = c_ambient; - i_1 = 0u; bool loop_init_1 = true; while(true) { if (!loop_init_1) { diff --git a/tests/out/spv/access.spvasm b/tests/out/spv/access.spvasm index d5b6524ee7..40476395c4 100644 --- a/tests/out/spv/access.spvasm +++ b/tests/out/spv/access.spvasm @@ -1,16 +1,16 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 322 +; Bound: 313 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %232 "foo_vert" %227 %230 -OpEntryPoint Fragment %282 "foo_frag" %281 -OpEntryPoint GLCompute %302 "assign_through_ptr" %305 -OpExecutionMode %282 OriginUpperLeft -OpExecutionMode %302 LocalSize 1 1 1 +OpEntryPoint Vertex %220 "foo_vert" %215 %218 +OpEntryPoint Fragment %274 "foo_frag" %273 +OpEntryPoint GLCompute %292 "assign_through_ptr" %299 +OpExecutionMode %274 OriginUpperLeft +OpExecutionMode %292 LocalSize 1 1 1 OpMemberName %6 0 "a" OpMemberName %6 1 "b" OpMemberName %6 2 "c" @@ -34,27 +34,27 @@ OpName %44 "baz" OpName %47 "qux" OpName %50 "nested_mat_cx2" OpName %53 "val" -OpName %54 "idx" -OpName %57 "t" -OpName %61 "test_matrix_within_struct_accesses" -OpName %132 "idx" -OpName %133 "t" -OpName %137 "test_matrix_within_array_within_struct_accesses" -OpName %195 "foo" -OpName %196 "read_from_private" -OpName %201 "a" -OpName %202 "test_arr_as_arg" -OpName %208 "p" -OpName %209 "assign_through_ptr_fn" -OpName %214 "foo" -OpName %215 "assign_array_through_ptr_fn" -OpName %221 "foo" -OpName %223 "c2" -OpName %227 "vi" -OpName %232 "foo_vert" -OpName %282 "foo_frag" -OpName %299 "arr" -OpName %302 "assign_through_ptr" +OpName %55 "test_matrix_within_struct_accesses" +OpName %83 "idx" +OpName %85 "t" +OpName %131 "test_matrix_within_array_within_struct_accesses" +OpName %141 "idx" +OpName %142 "t" +OpName %188 "foo" +OpName %189 "read_from_private" +OpName %194 "a" +OpName %195 "test_arr_as_arg" +OpName %201 "p" +OpName %202 "assign_through_ptr_fn" +OpName %207 "foo" +OpName %208 "assign_array_through_ptr_fn" +OpName %215 "vi" +OpName %220 "foo_vert" +OpName %232 "foo" +OpName %233 "c2" +OpName %274 "foo_frag" +OpName %292 "assign_through_ptr" +OpName %296 "arr" OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %6 2 Offset 28 @@ -99,10 +99,10 @@ OpDecorate %50 DescriptorSet 0 OpDecorate %50 Binding 3 OpDecorate %51 Block OpMemberDecorate %51 0 Offset 0 -OpDecorate %227 BuiltIn VertexIndex -OpDecorate %230 BuiltIn Position -OpDecorate %281 Location 0 -OpDecorate %305 BuiltIn LocalInvocationId +OpDecorate %215 BuiltIn VertexIndex +OpDecorate %218 BuiltIn Position +OpDecorate %273 Location 0 +OpDecorate %299 BuiltIn LocalInvocationId %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeVector %3 3 @@ -155,341 +155,326 @@ OpDecorate %305 BuiltIn LocalInvocationId %52 = OpTypePointer Uniform %51 %50 = OpVariable %52 Uniform %53 = OpVariable %33 Workgroup -%55 = OpTypePointer Function %5 -%56 = OpConstantNull %5 -%58 = OpTypePointer Function %22 -%59 = OpConstantNull %22 -%62 = OpTypeFunction %2 -%63 = OpTypePointer Uniform %22 -%65 = OpConstant %5 1 -%66 = OpConstant %10 1.0 -%67 = OpConstant %10 2.0 -%68 = OpConstant %10 3.0 -%69 = OpConstant %10 6.0 +%56 = OpTypeFunction %2 +%57 = OpTypePointer Uniform %22 +%59 = OpConstant %5 1 +%60 = OpConstant %10 1.0 +%61 = OpConstantComposite %12 %60 %60 +%62 = OpConstant %10 2.0 +%63 = OpConstantComposite %12 %62 %62 +%64 = OpConstant %10 3.0 +%65 = OpConstantComposite %12 %64 %64 +%66 = OpConstantComposite %21 %61 %63 %65 +%67 = OpConstantComposite %22 %66 +%68 = OpConstant %10 6.0 +%69 = OpConstantComposite %12 %68 %68 %70 = OpConstant %10 5.0 -%71 = OpConstant %10 4.0 -%72 = OpConstant %10 9.0 -%73 = OpConstant %10 90.0 -%74 = OpConstant %10 10.0 -%75 = OpConstant %10 20.0 -%76 = OpConstant %10 30.0 -%77 = OpConstant %10 40.0 -%81 = OpTypePointer Uniform %21 -%84 = OpTypePointer Uniform %12 -%90 = OpTypePointer Uniform %10 -%91 = OpConstant %3 1 -%111 = OpTypePointer Function %21 +%71 = OpConstantComposite %12 %70 %70 +%72 = OpConstant %10 4.0 +%73 = OpConstantComposite %12 %72 %72 +%74 = OpConstantComposite %21 %69 %71 %73 +%75 = OpConstant %10 9.0 +%76 = OpConstantComposite %12 %75 %75 +%77 = OpConstant %10 90.0 +%78 = OpConstantComposite %12 %77 %77 +%79 = OpConstant %10 10.0 +%80 = OpConstant %10 20.0 +%81 = OpConstant %10 30.0 +%82 = OpConstant %10 40.0 +%84 = OpTypePointer Function %5 +%86 = OpTypePointer Function %22 +%90 = OpTypePointer Uniform %21 +%93 = OpTypePointer Uniform %12 +%99 = OpTypePointer Uniform %10 +%100 = OpConstant %3 1 +%115 = OpTypePointer Function %21 %117 = OpTypePointer Function %12 -%123 = OpTypePointer Function %10 -%134 = OpTypePointer Function %26 -%135 = OpConstantNull %26 -%138 = OpTypePointer Uniform %26 -%140 = OpConstantNull %25 -%141 = OpConstant %10 8.0 -%142 = OpConstant %10 7.0 -%146 = OpTypePointer Uniform %25 -%149 = OpTypePointer Uniform %24 +%121 = OpTypePointer Function %10 +%132 = OpTypePointer Uniform %26 +%134 = OpConstantNull %25 +%135 = OpConstantComposite %26 %134 +%136 = OpConstant %10 8.0 +%137 = OpConstantComposite %12 %136 %136 +%138 = OpConstant %10 7.0 +%139 = OpConstantComposite %12 %138 %138 +%140 = OpConstantComposite %24 %137 %139 %69 %71 +%143 = OpTypePointer Function %26 +%147 = OpTypePointer Uniform %25 +%150 = OpTypePointer Uniform %24 %172 = OpTypePointer Function %25 %174 = OpTypePointer Function %24 -%197 = OpTypeFunction %10 %27 -%203 = OpTypeFunction %10 %29 -%210 = OpTypeFunction %2 %33 -%211 = OpConstant %3 42 -%216 = OpTypeFunction %2 %35 -%222 = OpConstantNull %10 -%224 = OpTypePointer Function %32 -%225 = OpConstantNull %32 -%228 = OpTypePointer Input %3 -%227 = OpVariable %228 Input -%231 = OpTypePointer Output %31 -%230 = OpVariable %231 Output -%234 = OpTypePointer StorageBuffer %23 -%237 = OpConstant %10 0.0 -%238 = OpConstant %3 3 -%239 = OpConstant %5 3 -%240 = OpConstant %5 4 -%241 = OpConstant %5 5 -%242 = OpConstant %5 42 -%243 = OpConstantNull %29 -%248 = OpTypePointer StorageBuffer %8 -%251 = OpTypePointer StorageBuffer %18 -%252 = OpConstant %3 4 -%255 = OpTypePointer StorageBuffer %9 -%256 = OpTypePointer StorageBuffer %10 -%259 = OpTypePointer StorageBuffer %19 -%262 = OpTypePointer StorageBuffer %7 -%263 = OpTypePointer StorageBuffer %5 -%275 = OpTypeVector %5 4 -%281 = OpVariable %231 Output +%190 = OpTypeFunction %10 %27 +%196 = OpTypeFunction %10 %29 +%203 = OpTypeFunction %2 %33 +%204 = OpConstant %3 42 +%209 = OpTypeFunction %2 %35 +%210 = OpConstantComposite %31 %60 %60 %60 %60 +%211 = OpConstantComposite %31 %62 %62 %62 %62 +%212 = OpConstantComposite %34 %210 %211 +%216 = OpTypePointer Input %3 +%215 = OpVariable %216 Input +%219 = OpTypePointer Output %31 +%218 = OpVariable %219 Output +%222 = OpTypePointer StorageBuffer %23 +%225 = OpConstant %10 0.0 +%226 = OpConstant %3 3 +%227 = OpConstant %5 3 +%228 = OpConstant %5 4 +%229 = OpConstant %5 5 +%230 = OpConstant %5 42 +%231 = OpConstantNull %29 +%234 = OpTypePointer Function %32 +%235 = OpConstantNull %32 +%240 = OpTypePointer StorageBuffer %8 +%243 = OpTypePointer StorageBuffer %18 +%244 = OpConstant %3 4 +%247 = OpTypePointer StorageBuffer %9 +%248 = OpTypePointer StorageBuffer %10 +%251 = OpTypePointer StorageBuffer %19 +%254 = OpTypePointer StorageBuffer %7 +%255 = OpTypePointer StorageBuffer %5 +%267 = OpTypeVector %5 4 +%273 = OpVariable %219 Output +%276 = OpConstantComposite %9 %225 %225 %225 +%277 = OpConstantComposite %9 %60 %60 %60 +%278 = OpConstantComposite %9 %62 %62 %62 +%279 = OpConstantComposite %9 %64 %64 %64 +%280 = OpConstantComposite %8 %276 %277 %278 %279 +%281 = OpConstantComposite %17 %36 %36 +%282 = OpConstantComposite %17 %100 %100 +%283 = OpConstantComposite %18 %281 %282 %284 = OpConstantNull %23 -%300 = OpConstantNull %34 -%304 = OpConstantNull %3 -%306 = OpTypePointer Input %4 -%305 = OpVariable %306 Input -%308 = OpConstantNull %4 -%310 = OpTypeBool -%309 = OpTypeVector %310 3 -%315 = OpConstant %3 264 -%61 = OpFunction %2 None %62 -%60 = OpLabel -%54 = OpVariable %55 Function %56 -%57 = OpVariable %58 Function %59 -%64 = OpAccessChain %63 %44 %36 -OpBranch %78 -%78 = OpLabel -OpStore %54 %65 -%79 = OpLoad %5 %54 -%80 = OpISub %5 %79 %65 -OpStore %54 %80 -%82 = OpAccessChain %81 %64 %36 -%83 = OpLoad %21 %82 -%85 = OpAccessChain %84 %64 %36 %36 -%86 = OpLoad %12 %85 -%87 = OpLoad %5 %54 -%88 = OpAccessChain %84 %64 %36 %87 -%89 = OpLoad %12 %88 -%92 = OpAccessChain %90 %64 %36 %36 %91 -%93 = OpLoad %10 %92 -%94 = OpLoad %5 %54 -%95 = OpAccessChain %90 %64 %36 %36 %94 -%96 = OpLoad %10 %95 -%97 = OpLoad %5 %54 -%98 = OpAccessChain %90 %64 %36 %97 %91 -%99 = OpLoad %10 %98 -%100 = OpLoad %5 %54 -%101 = OpLoad %5 %54 -%102 = OpAccessChain %90 %64 %36 %100 %101 -%103 = OpLoad %10 %102 -%104 = OpCompositeConstruct %12 %66 %66 -%105 = OpCompositeConstruct %12 %67 %67 -%106 = OpCompositeConstruct %12 %68 %68 -%107 = OpCompositeConstruct %21 %104 %105 %106 -%108 = OpCompositeConstruct %22 %107 -OpStore %57 %108 -%109 = OpLoad %5 %54 -%110 = OpIAdd %5 %109 %65 -OpStore %54 %110 -%112 = OpCompositeConstruct %12 %69 %69 -%113 = OpCompositeConstruct %12 %70 %70 -%114 = OpCompositeConstruct %12 %71 %71 -%115 = OpCompositeConstruct %21 %112 %113 %114 -%116 = OpAccessChain %111 %57 %36 -OpStore %116 %115 -%118 = OpCompositeConstruct %12 %72 %72 -%119 = OpAccessChain %117 %57 %36 %36 -OpStore %119 %118 -%120 = OpLoad %5 %54 -%121 = OpCompositeConstruct %12 %73 %73 -%122 = OpAccessChain %117 %57 %36 %120 -OpStore %122 %121 -%124 = OpAccessChain %123 %57 %36 %36 %91 -OpStore %124 %74 -%125 = OpLoad %5 %54 -%126 = OpAccessChain %123 %57 %36 %36 %125 -OpStore %126 %75 -%127 = OpLoad %5 %54 -%128 = OpAccessChain %123 %57 %36 %127 %91 -OpStore %128 %76 -%129 = OpLoad %5 %54 -%130 = OpLoad %5 %54 -%131 = OpAccessChain %123 %57 %36 %129 %130 -OpStore %131 %77 +%285 = OpConstantComposite %31 %225 %225 %225 %225 +%293 = OpConstantComposite %31 %68 %68 %68 %68 +%294 = OpConstantComposite %31 %138 %138 %138 %138 +%295 = OpConstantComposite %34 %293 %294 +%298 = OpConstantNull %3 +%300 = OpTypePointer Input %4 +%299 = OpVariable %300 Input +%302 = OpConstantNull %4 +%304 = OpTypeBool +%303 = OpTypeVector %304 3 +%309 = OpConstant %3 264 +%55 = OpFunction %2 None %56 +%54 = OpLabel +%83 = OpVariable %84 Function %59 +%85 = OpVariable %86 Function %67 +%58 = OpAccessChain %57 %44 %36 +OpBranch %87 +%87 = OpLabel +%88 = OpLoad %5 %83 +%89 = OpISub %5 %88 %59 +OpStore %83 %89 +%91 = OpAccessChain %90 %58 %36 +%92 = OpLoad %21 %91 +%94 = OpAccessChain %93 %58 %36 %36 +%95 = OpLoad %12 %94 +%96 = OpLoad %5 %83 +%97 = OpAccessChain %93 %58 %36 %96 +%98 = OpLoad %12 %97 +%101 = OpAccessChain %99 %58 %36 %36 %100 +%102 = OpLoad %10 %101 +%103 = OpLoad %5 %83 +%104 = OpAccessChain %99 %58 %36 %36 %103 +%105 = OpLoad %10 %104 +%106 = OpLoad %5 %83 +%107 = OpAccessChain %99 %58 %36 %106 %100 +%108 = OpLoad %10 %107 +%109 = OpLoad %5 %83 +%110 = OpLoad %5 %83 +%111 = OpAccessChain %99 %58 %36 %109 %110 +%112 = OpLoad %10 %111 +%113 = OpLoad %5 %83 +%114 = OpIAdd %5 %113 %59 +OpStore %83 %114 +%116 = OpAccessChain %115 %85 %36 +OpStore %116 %74 +%118 = OpAccessChain %117 %85 %36 %36 +OpStore %118 %76 +%119 = OpLoad %5 %83 +%120 = OpAccessChain %117 %85 %36 %119 +OpStore %120 %78 +%122 = OpAccessChain %121 %85 %36 %36 %100 +OpStore %122 %79 +%123 = OpLoad %5 %83 +%124 = OpAccessChain %121 %85 %36 %36 %123 +OpStore %124 %80 +%125 = OpLoad %5 %83 +%126 = OpAccessChain %121 %85 %36 %125 %100 +OpStore %126 %81 +%127 = OpLoad %5 %83 +%128 = OpLoad %5 %83 +%129 = OpAccessChain %121 %85 %36 %127 %128 +OpStore %129 %82 OpReturn OpFunctionEnd -%137 = OpFunction %2 None %62 -%136 = OpLabel -%132 = OpVariable %55 Function %56 -%133 = OpVariable %134 Function %135 -%139 = OpAccessChain %138 %50 %36 -OpBranch %143 -%143 = OpLabel -OpStore %132 %65 -%144 = OpLoad %5 %132 -%145 = OpISub %5 %144 %65 -OpStore %132 %145 -%147 = OpAccessChain %146 %139 %36 -%148 = OpLoad %25 %147 -%150 = OpAccessChain %149 %139 %36 %36 -%151 = OpLoad %24 %150 -%152 = OpAccessChain %84 %139 %36 %36 %36 -%153 = OpLoad %12 %152 -%154 = OpLoad %5 %132 -%155 = OpAccessChain %84 %139 %36 %36 %154 -%156 = OpLoad %12 %155 -%157 = OpAccessChain %90 %139 %36 %36 %36 %91 -%158 = OpLoad %10 %157 -%159 = OpLoad %5 %132 -%160 = OpAccessChain %90 %139 %36 %36 %36 %159 -%161 = OpLoad %10 %160 -%162 = OpLoad %5 %132 -%163 = OpAccessChain %90 %139 %36 %36 %162 %91 -%164 = OpLoad %10 %163 -%165 = OpLoad %5 %132 -%166 = OpLoad %5 %132 -%167 = OpAccessChain %90 %139 %36 %36 %165 %166 -%168 = OpLoad %10 %167 -%169 = OpCompositeConstruct %26 %140 -OpStore %133 %169 -%170 = OpLoad %5 %132 -%171 = OpIAdd %5 %170 %65 -OpStore %132 %171 -%173 = OpAccessChain %172 %133 %36 -OpStore %173 %140 -%175 = OpCompositeConstruct %12 %141 %141 -%176 = OpCompositeConstruct %12 %142 %142 -%177 = OpCompositeConstruct %12 %69 %69 -%178 = OpCompositeConstruct %12 %70 %70 -%179 = OpCompositeConstruct %24 %175 %176 %177 %178 -%180 = OpAccessChain %174 %133 %36 %36 -OpStore %180 %179 -%181 = OpCompositeConstruct %12 %72 %72 -%182 = OpAccessChain %117 %133 %36 %36 %36 -OpStore %182 %181 -%183 = OpLoad %5 %132 -%184 = OpCompositeConstruct %12 %73 %73 -%185 = OpAccessChain %117 %133 %36 %36 %183 -OpStore %185 %184 -%186 = OpAccessChain %123 %133 %36 %36 %36 %91 -OpStore %186 %74 -%187 = OpLoad %5 %132 -%188 = OpAccessChain %123 %133 %36 %36 %36 %187 -OpStore %188 %75 -%189 = OpLoad %5 %132 -%190 = OpAccessChain %123 %133 %36 %36 %189 %91 -OpStore %190 %76 -%191 = OpLoad %5 %132 -%192 = OpLoad %5 %132 -%193 = OpAccessChain %123 %133 %36 %36 %191 %192 -OpStore %193 %77 +%131 = OpFunction %2 None %56 +%130 = OpLabel +%141 = OpVariable %84 Function %59 +%142 = OpVariable %143 Function %135 +%133 = OpAccessChain %132 %50 %36 +OpBranch %144 +%144 = OpLabel +%145 = OpLoad %5 %141 +%146 = OpISub %5 %145 %59 +OpStore %141 %146 +%148 = OpAccessChain %147 %133 %36 +%149 = OpLoad %25 %148 +%151 = OpAccessChain %150 %133 %36 %36 +%152 = OpLoad %24 %151 +%153 = OpAccessChain %93 %133 %36 %36 %36 +%154 = OpLoad %12 %153 +%155 = OpLoad %5 %141 +%156 = OpAccessChain %93 %133 %36 %36 %155 +%157 = OpLoad %12 %156 +%158 = OpAccessChain %99 %133 %36 %36 %36 %100 +%159 = OpLoad %10 %158 +%160 = OpLoad %5 %141 +%161 = OpAccessChain %99 %133 %36 %36 %36 %160 +%162 = OpLoad %10 %161 +%163 = OpLoad %5 %141 +%164 = OpAccessChain %99 %133 %36 %36 %163 %100 +%165 = OpLoad %10 %164 +%166 = OpLoad %5 %141 +%167 = OpLoad %5 %141 +%168 = OpAccessChain %99 %133 %36 %36 %166 %167 +%169 = OpLoad %10 %168 +%170 = OpLoad %5 %141 +%171 = OpIAdd %5 %170 %59 +OpStore %141 %171 +%173 = OpAccessChain %172 %142 %36 +OpStore %173 %134 +%175 = OpAccessChain %174 %142 %36 %36 +OpStore %175 %140 +%176 = OpAccessChain %117 %142 %36 %36 %36 +OpStore %176 %76 +%177 = OpLoad %5 %141 +%178 = OpAccessChain %117 %142 %36 %36 %177 +OpStore %178 %78 +%179 = OpAccessChain %121 %142 %36 %36 %36 %100 +OpStore %179 %79 +%180 = OpLoad %5 %141 +%181 = OpAccessChain %121 %142 %36 %36 %36 %180 +OpStore %181 %80 +%182 = OpLoad %5 %141 +%183 = OpAccessChain %121 %142 %36 %36 %182 %100 +OpStore %183 %81 +%184 = OpLoad %5 %141 +%185 = OpLoad %5 %141 +%186 = OpAccessChain %121 %142 %36 %36 %184 %185 +OpStore %186 %82 OpReturn OpFunctionEnd -%196 = OpFunction %10 None %197 -%195 = OpFunctionParameter %27 -%194 = OpLabel -OpBranch %198 -%198 = OpLabel -%199 = OpLoad %10 %195 +%189 = OpFunction %10 None %190 +%188 = OpFunctionParameter %27 +%187 = OpLabel +OpBranch %191 +%191 = OpLabel +%192 = OpLoad %10 %188 +OpReturnValue %192 +OpFunctionEnd +%195 = OpFunction %10 None %196 +%194 = OpFunctionParameter %29 +%193 = OpLabel +OpBranch %197 +%197 = OpLabel +%198 = OpCompositeExtract %28 %194 4 +%199 = OpCompositeExtract %10 %198 9 OpReturnValue %199 OpFunctionEnd -%202 = OpFunction %10 None %203 -%201 = OpFunctionParameter %29 +%202 = OpFunction %2 None %203 +%201 = OpFunctionParameter %33 %200 = OpLabel -OpBranch %204 -%204 = OpLabel -%205 = OpCompositeExtract %28 %201 4 -%206 = OpCompositeExtract %10 %205 9 -OpReturnValue %206 -OpFunctionEnd -%209 = OpFunction %2 None %210 -%208 = OpFunctionParameter %33 -%207 = OpLabel -OpBranch %212 -%212 = OpLabel -OpStore %208 %211 +OpBranch %205 +%205 = OpLabel +OpStore %201 %204 OpReturn OpFunctionEnd -%215 = OpFunction %2 None %216 -%214 = OpFunctionParameter %35 +%208 = OpFunction %2 None %209 +%207 = OpFunctionParameter %35 +%206 = OpLabel +OpBranch %213 %213 = OpLabel -OpBranch %217 -%217 = OpLabel -%218 = OpCompositeConstruct %31 %66 %66 %66 %66 -%219 = OpCompositeConstruct %31 %67 %67 %67 %67 -%220 = OpCompositeConstruct %34 %218 %219 -OpStore %214 %220 +OpStore %207 %212 OpReturn OpFunctionEnd -%232 = OpFunction %2 None %62 -%226 = OpLabel -%221 = OpVariable %27 Function %222 -%223 = OpVariable %224 Function %225 -%229 = OpLoad %3 %227 -%233 = OpAccessChain %63 %44 %36 -%235 = OpAccessChain %234 %47 %36 -%236 = OpAccessChain %138 %50 %36 -OpBranch %244 -%244 = OpLabel -OpStore %221 %237 -%245 = OpLoad %10 %221 -OpStore %221 %66 -%246 = OpFunctionCall %2 %61 -%247 = OpFunctionCall %2 %137 -%249 = OpAccessChain %248 %42 %36 -%250 = OpLoad %8 %249 -%253 = OpAccessChain %251 %42 %252 -%254 = OpLoad %18 %253 -%257 = OpAccessChain %256 %42 %36 %238 %36 -%258 = OpLoad %10 %257 -%260 = OpArrayLength %3 %42 5 -%261 = OpISub %3 %260 %14 -%264 = OpAccessChain %263 %42 %30 %261 %36 +%220 = OpFunction %2 None %56 +%214 = OpLabel +%232 = OpVariable %27 Function %225 +%233 = OpVariable %234 Function %235 +%217 = OpLoad %3 %215 +%221 = OpAccessChain %57 %44 %36 +%223 = OpAccessChain %222 %47 %36 +%224 = OpAccessChain %132 %50 %36 +OpBranch %236 +%236 = OpLabel +%237 = OpLoad %10 %232 +OpStore %232 %60 +%238 = OpFunctionCall %2 %55 +%239 = OpFunctionCall %2 %131 +%241 = OpAccessChain %240 %42 %36 +%242 = OpLoad %8 %241 +%245 = OpAccessChain %243 %42 %244 +%246 = OpLoad %18 %245 +%249 = OpAccessChain %248 %42 %36 %226 %36 +%250 = OpLoad %10 %249 +%252 = OpArrayLength %3 %42 5 +%253 = OpISub %3 %252 %14 +%256 = OpAccessChain %255 %42 %30 %253 %36 +%257 = OpLoad %5 %256 +%258 = OpLoad %23 %223 +%259 = OpFunctionCall %10 %189 %232 +%260 = OpConvertFToS %5 %250 +%261 = OpCompositeConstruct %32 %257 %260 %227 %228 %229 +OpStore %233 %261 +%262 = OpIAdd %3 %217 %100 +%263 = OpAccessChain %84 %233 %262 +OpStore %263 %230 +%264 = OpAccessChain %84 %233 %217 %265 = OpLoad %5 %264 -%266 = OpLoad %23 %235 -%267 = OpFunctionCall %10 %196 %221 -%268 = OpConvertFToS %5 %258 -%269 = OpCompositeConstruct %32 %265 %268 %239 %240 %241 -OpStore %223 %269 -%270 = OpIAdd %3 %229 %91 -%271 = OpAccessChain %55 %223 %270 -OpStore %271 %242 -%272 = OpAccessChain %55 %223 %229 -%273 = OpLoad %5 %272 -%274 = OpFunctionCall %10 %202 %243 -%276 = OpCompositeConstruct %275 %273 %273 %273 %273 -%277 = OpConvertSToF %31 %276 -%278 = OpMatrixTimesVector %9 %250 %277 -%279 = OpCompositeConstruct %31 %278 %67 -OpStore %230 %279 +%266 = OpFunctionCall %10 %195 %231 +%268 = OpCompositeConstruct %267 %265 %265 %265 %265 +%269 = OpConvertSToF %31 %268 +%270 = OpMatrixTimesVector %9 %242 %269 +%271 = OpCompositeConstruct %31 %270 %62 +OpStore %218 %271 OpReturn OpFunctionEnd -%282 = OpFunction %2 None %62 -%280 = OpLabel -%283 = OpAccessChain %234 %47 %36 -OpBranch %285 -%285 = OpLabel -%286 = OpAccessChain %256 %42 %36 %91 %14 -OpStore %286 %66 -%287 = OpCompositeConstruct %9 %237 %237 %237 -%288 = OpCompositeConstruct %9 %66 %66 %66 -%289 = OpCompositeConstruct %9 %67 %67 %67 -%290 = OpCompositeConstruct %9 %68 %68 %68 -%291 = OpCompositeConstruct %8 %287 %288 %289 %290 -%292 = OpAccessChain %248 %42 %36 -OpStore %292 %291 -%293 = OpCompositeConstruct %17 %36 %36 -%294 = OpCompositeConstruct %17 %91 %91 -%295 = OpCompositeConstruct %18 %293 %294 -%296 = OpAccessChain %251 %42 %252 -OpStore %296 %295 -%297 = OpAccessChain %263 %42 %30 %91 %36 -OpStore %297 %65 -OpStore %283 %284 -%298 = OpCompositeConstruct %31 %237 %237 %237 %237 -OpStore %281 %298 +%274 = OpFunction %2 None %56 +%272 = OpLabel +%275 = OpAccessChain %222 %47 %36 +OpBranch %286 +%286 = OpLabel +%287 = OpAccessChain %248 %42 %36 %100 %14 +OpStore %287 %60 +%288 = OpAccessChain %240 %42 %36 +OpStore %288 %280 +%289 = OpAccessChain %243 %42 %244 +OpStore %289 %283 +%290 = OpAccessChain %255 %42 %30 %100 %36 +OpStore %290 %59 +OpStore %275 %284 +OpStore %273 %285 OpReturn OpFunctionEnd -%302 = OpFunction %2 None %62 -%301 = OpLabel -%299 = OpVariable %35 Function %300 -OpBranch %303 -%303 = OpLabel -%307 = OpLoad %4 %305 -%311 = OpIEqual %309 %307 %308 -%312 = OpAll %310 %311 -OpSelectionMerge %313 None -OpBranchConditional %312 %314 %313 -%314 = OpLabel -OpStore %53 %304 -OpBranch %313 -%313 = OpLabel -OpControlBarrier %14 %14 %315 -OpBranch %316 -%316 = OpLabel -%317 = OpCompositeConstruct %31 %69 %69 %69 %69 -%318 = OpCompositeConstruct %31 %142 %142 %142 %142 -%319 = OpCompositeConstruct %34 %317 %318 -OpStore %299 %319 -%320 = OpFunctionCall %2 %209 %53 -%321 = OpFunctionCall %2 %215 %299 +%292 = OpFunction %2 None %56 +%291 = OpLabel +%296 = OpVariable %35 Function %295 +OpBranch %297 +%297 = OpLabel +%301 = OpLoad %4 %299 +%305 = OpIEqual %303 %301 %302 +%306 = OpAll %304 %305 +OpSelectionMerge %307 None +OpBranchConditional %306 %308 %307 +%308 = OpLabel +OpStore %53 %298 +OpBranch %307 +%307 = OpLabel +OpControlBarrier %14 %14 %309 +OpBranch %310 +%310 = OpLabel +%311 = OpFunctionCall %2 %202 %53 +%312 = OpFunctionCall %2 %208 %296 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/array-in-function-return-type.spvasm b/tests/out/spv/array-in-function-return-type.spvasm index e68f6ad835..79e94fba8a 100644 --- a/tests/out/spv/array-in-function-return-type.spvasm +++ b/tests/out/spv/array-in-function-return-type.spvasm @@ -18,16 +18,16 @@ OpDecorate %16 Location 0 %10 = OpTypeFunction %4 %11 = OpConstant %3 1.0 %12 = OpConstant %3 2.0 +%13 = OpConstantComposite %4 %11 %12 %17 = OpTypePointer Output %7 %16 = OpVariable %17 Output %19 = OpTypeFunction %2 %20 = OpConstant %3 0.0 %9 = OpFunction %4 None %10 %8 = OpLabel -OpBranch %13 -%13 = OpLabel -%14 = OpCompositeConstruct %4 %11 %12 -OpReturnValue %14 +OpBranch %14 +%14 = OpLabel +OpReturnValue %13 OpFunctionEnd %18 = OpFunction %2 None %19 %15 = OpLabel diff --git a/tests/out/spv/atomicCompareExchange.spvasm b/tests/out/spv/atomicCompareExchange.spvasm index c73c159ea2..d08e3656fd 100644 --- a/tests/out/spv/atomicCompareExchange.spvasm +++ b/tests/out/spv/atomicCompareExchange.spvasm @@ -1,15 +1,15 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 123 +; Bound: 122 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %27 "test_atomic_compare_exchange_i32" -OpEntryPoint GLCompute %81 "test_atomic_compare_exchange_u32" -OpExecutionMode %27 LocalSize 1 1 1 -OpExecutionMode %81 LocalSize 1 1 1 +OpEntryPoint GLCompute %18 "test_atomic_compare_exchange_i32" +OpEntryPoint GLCompute %76 "test_atomic_compare_exchange_u32" +OpExecutionMode %18 LocalSize 1 1 1 +OpExecutionMode %76 LocalSize 1 1 1 OpDecorate %5 ArrayStride 4 OpDecorate %7 ArrayStride 4 OpMemberDecorate %9 0 Offset 0 @@ -39,167 +39,164 @@ OpMemberDecorate %15 0 Offset 0 %15 = OpTypeStruct %7 %16 = OpTypePointer StorageBuffer %15 %14 = OpVariable %16 StorageBuffer -%18 = OpTypePointer Function %3 -%19 = OpConstantNull %3 -%21 = OpTypePointer Function %4 -%22 = OpConstantNull %4 -%24 = OpTypePointer Function %8 -%25 = OpConstantNull %8 -%28 = OpTypeFunction %2 -%29 = OpTypePointer StorageBuffer %5 -%30 = OpConstant %3 0 -%32 = OpConstantFalse %8 -%33 = OpTypeFloat 32 -%34 = OpConstant %33 1.0 -%35 = OpConstant %3 1 -%48 = OpTypePointer StorageBuffer %4 -%51 = OpConstant %4 1 -%52 = OpConstant %3 64 -%82 = OpTypePointer StorageBuffer %7 -%96 = OpTypePointer StorageBuffer %3 -%27 = OpFunction %2 None %28 -%26 = OpLabel -%17 = OpVariable %18 Function %19 -%20 = OpVariable %21 Function %22 -%23 = OpVariable %24 Function %25 -%31 = OpAccessChain %29 %11 %30 -OpBranch %36 -%36 = OpLabel -OpStore %17 %30 +%19 = OpTypeFunction %2 +%20 = OpTypePointer StorageBuffer %5 +%21 = OpConstant %3 0 +%23 = OpConstantFalse %8 +%24 = OpTypeFloat 32 +%25 = OpConstant %24 1.0 +%26 = OpConstant %3 1 +%28 = OpTypePointer Function %3 +%30 = OpTypePointer Function %4 +%31 = OpConstantNull %4 +%33 = OpTypePointer Function %8 +%46 = OpTypePointer StorageBuffer %4 +%49 = OpConstant %4 1 +%50 = OpConstant %3 64 +%77 = OpTypePointer StorageBuffer %7 +%81 = OpConstantNull %3 +%95 = OpTypePointer StorageBuffer %3 +%18 = OpFunction %2 None %19 +%17 = OpLabel +%27 = OpVariable %28 Function %21 +%29 = OpVariable %30 Function %31 +%32 = OpVariable %33 Function %23 +%22 = OpAccessChain %20 %11 %21 +OpBranch %34 +%34 = OpLabel +OpBranch %35 +%35 = OpLabel +OpLoopMerge %36 %38 None OpBranch %37 %37 = OpLabel -OpLoopMerge %38 %40 None -OpBranch %39 -%39 = OpLabel -%41 = OpLoad %3 %17 -%42 = OpULessThan %8 %41 %6 -OpSelectionMerge %43 None -OpBranchConditional %42 %43 %44 -%44 = OpLabel -OpBranch %38 +%39 = OpLoad %3 %27 +%40 = OpULessThan %8 %39 %6 +OpSelectionMerge %41 None +OpBranchConditional %40 %41 %42 +%42 = OpLabel +OpBranch %36 +%41 = OpLabel +OpBranch %43 %43 = OpLabel -OpBranch %45 -%45 = OpLabel -%47 = OpLoad %3 %17 -%49 = OpAccessChain %48 %31 %47 -%50 = OpAtomicLoad %4 %49 %51 %52 -OpStore %20 %50 -OpStore %23 %32 +%45 = OpLoad %3 %27 +%47 = OpAccessChain %46 %22 %45 +%48 = OpAtomicLoad %4 %47 %49 %50 +OpStore %29 %48 +OpStore %32 %23 +OpBranch %51 +%51 = OpLabel +OpLoopMerge %52 %54 None OpBranch %53 %53 = OpLabel -OpLoopMerge %54 %56 None -OpBranch %55 -%55 = OpLabel -%57 = OpLoad %8 %23 -%58 = OpLogicalNot %8 %57 -OpSelectionMerge %59 None -OpBranchConditional %58 %59 %60 +%55 = OpLoad %8 %32 +%56 = OpLogicalNot %8 %55 +OpSelectionMerge %57 None +OpBranchConditional %56 %57 %58 +%58 = OpLabel +OpBranch %52 +%57 = OpLabel +OpBranch %59 +%59 = OpLabel +%61 = OpLoad %4 %29 +%62 = OpBitcast %24 %61 +%63 = OpFAdd %24 %62 %25 +%64 = OpBitcast %4 %63 +%65 = OpLoad %3 %27 +%66 = OpLoad %4 %29 +%68 = OpAccessChain %46 %22 %65 +%69 = OpAtomicCompareExchange %4 %68 %49 %50 %50 %64 %66 +%70 = OpIEqual %8 %69 %66 +%67 = OpCompositeConstruct %9 %69 %70 +%71 = OpCompositeExtract %4 %67 0 +OpStore %29 %71 +%72 = OpCompositeExtract %8 %67 1 +OpStore %32 %72 +OpBranch %60 %60 = OpLabel OpBranch %54 -%59 = OpLabel -OpBranch %61 -%61 = OpLabel -%63 = OpLoad %4 %20 -%64 = OpBitcast %33 %63 -%65 = OpFAdd %33 %64 %34 -%66 = OpBitcast %4 %65 -%67 = OpLoad %3 %17 -%68 = OpLoad %4 %20 -%70 = OpAccessChain %48 %31 %67 -%71 = OpAtomicCompareExchange %4 %70 %51 %52 %52 %66 %68 -%72 = OpIEqual %8 %71 %68 -%69 = OpCompositeConstruct %9 %71 %72 -%73 = OpCompositeExtract %4 %69 0 -OpStore %20 %73 -%74 = OpCompositeExtract %8 %69 1 -OpStore %23 %74 -OpBranch %62 -%62 = OpLabel -OpBranch %56 -%56 = OpLabel -OpBranch %53 %54 = OpLabel -OpBranch %46 -%46 = OpLabel -OpBranch %40 -%40 = OpLabel -%75 = OpLoad %3 %17 -%76 = OpIAdd %3 %75 %35 -OpStore %17 %76 -OpBranch %37 +OpBranch %51 +%52 = OpLabel +OpBranch %44 +%44 = OpLabel +OpBranch %38 %38 = OpLabel +%73 = OpLoad %3 %27 +%74 = OpIAdd %3 %73 %26 +OpStore %27 %74 +OpBranch %35 +%36 = OpLabel OpReturn OpFunctionEnd -%81 = OpFunction %2 None %28 -%80 = OpLabel -%77 = OpVariable %18 Function %19 -%78 = OpVariable %18 Function %19 -%79 = OpVariable %24 Function %25 -%83 = OpAccessChain %82 %14 %30 +%76 = OpFunction %2 None %19 +%75 = OpLabel +%79 = OpVariable %28 Function %21 +%80 = OpVariable %28 Function %81 +%82 = OpVariable %33 Function %23 +%78 = OpAccessChain %77 %14 %21 +OpBranch %83 +%83 = OpLabel OpBranch %84 %84 = OpLabel -OpStore %77 %30 -OpBranch %85 -%85 = OpLabel -OpLoopMerge %86 %88 None -OpBranch %87 -%87 = OpLabel -%89 = OpLoad %3 %77 -%90 = OpULessThan %8 %89 %6 -OpSelectionMerge %91 None -OpBranchConditional %90 %91 %92 -%92 = OpLabel +OpLoopMerge %85 %87 None OpBranch %86 +%86 = OpLabel +%88 = OpLoad %3 %79 +%89 = OpULessThan %8 %88 %6 +OpSelectionMerge %90 None +OpBranchConditional %89 %90 %91 %91 = OpLabel -OpBranch %93 -%93 = OpLabel -%95 = OpLoad %3 %77 -%97 = OpAccessChain %96 %83 %95 -%98 = OpAtomicLoad %3 %97 %51 %52 -OpStore %78 %98 -OpStore %79 %32 -OpBranch %99 -%99 = OpLabel -OpLoopMerge %100 %102 None -OpBranch %101 -%101 = OpLabel -%103 = OpLoad %8 %79 -%104 = OpLogicalNot %8 %103 -OpSelectionMerge %105 None -OpBranchConditional %104 %105 %106 -%106 = OpLabel +OpBranch %85 +%90 = OpLabel +OpBranch %92 +%92 = OpLabel +%94 = OpLoad %3 %79 +%96 = OpAccessChain %95 %78 %94 +%97 = OpAtomicLoad %3 %96 %49 %50 +OpStore %80 %97 +OpStore %82 %23 +OpBranch %98 +%98 = OpLabel +OpLoopMerge %99 %101 None OpBranch %100 +%100 = OpLabel +%102 = OpLoad %8 %82 +%103 = OpLogicalNot %8 %102 +OpSelectionMerge %104 None +OpBranchConditional %103 %104 %105 %105 = OpLabel +OpBranch %99 +%104 = OpLabel +OpBranch %106 +%106 = OpLabel +%108 = OpLoad %3 %80 +%109 = OpBitcast %24 %108 +%110 = OpFAdd %24 %109 %25 +%111 = OpBitcast %3 %110 +%112 = OpLoad %3 %79 +%113 = OpLoad %3 %80 +%115 = OpAccessChain %95 %78 %112 +%116 = OpAtomicCompareExchange %3 %115 %49 %50 %50 %111 %113 +%117 = OpIEqual %8 %116 %113 +%114 = OpCompositeConstruct %10 %116 %117 +%118 = OpCompositeExtract %3 %114 0 +OpStore %80 %118 +%119 = OpCompositeExtract %8 %114 1 +OpStore %82 %119 OpBranch %107 %107 = OpLabel -%109 = OpLoad %3 %78 -%110 = OpBitcast %33 %109 -%111 = OpFAdd %33 %110 %34 -%112 = OpBitcast %3 %111 -%113 = OpLoad %3 %77 -%114 = OpLoad %3 %78 -%116 = OpAccessChain %96 %83 %113 -%117 = OpAtomicCompareExchange %3 %116 %51 %52 %52 %112 %114 -%118 = OpIEqual %8 %117 %114 -%115 = OpCompositeConstruct %10 %117 %118 -%119 = OpCompositeExtract %3 %115 0 -OpStore %78 %119 -%120 = OpCompositeExtract %8 %115 1 -OpStore %79 %120 -OpBranch %108 -%108 = OpLabel -OpBranch %102 -%102 = OpLabel -OpBranch %99 -%100 = OpLabel -OpBranch %94 -%94 = OpLabel -OpBranch %88 -%88 = OpLabel -%121 = OpLoad %3 %77 -%122 = OpIAdd %3 %121 %35 -OpStore %77 %122 -OpBranch %85 -%86 = OpLabel +OpBranch %101 +%101 = OpLabel +OpBranch %98 +%99 = OpLabel +OpBranch %93 +%93 = OpLabel +OpBranch %87 +%87 = OpLabel +%120 = OpLoad %3 %79 +%121 = OpIAdd %3 %120 %26 +OpStore %79 %121 +OpBranch %84 +%85 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/binding-arrays.spvasm b/tests/out/spv/binding-arrays.spvasm index 57636775f0..3d3b9f8e57 100644 --- a/tests/out/spv/binding-arrays.spvasm +++ b/tests/out/spv/binding-arrays.spvasm @@ -1,15 +1,15 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 431 +; Bound: 428 OpCapability Shader OpCapability ImageQuery OpCapability ShaderNonUniform OpExtension "SPV_EXT_descriptor_indexing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %64 "main" %59 %62 -OpExecutionMode %64 OriginUpperLeft +OpEntryPoint Fragment %52 "main" %47 %50 +OpExecutionMode %52 OriginUpperLeft OpMemberDecorate %4 0 Offset 0 OpMemberDecorate %21 0 Offset 0 OpDecorate %24 DescriptorSet 0 @@ -32,31 +32,31 @@ OpDecorate %42 DescriptorSet 0 OpDecorate %42 Binding 8 OpDecorate %43 Block OpMemberDecorate %43 0 Offset 0 -OpDecorate %59 Location 0 -OpDecorate %59 Flat -OpDecorate %62 Location 0 -OpDecorate %95 NonUniform -OpDecorate %118 NonUniform -OpDecorate %120 NonUniform -OpDecorate %145 NonUniform -OpDecorate %147 NonUniform -OpDecorate %183 NonUniform -OpDecorate %211 NonUniform -OpDecorate %227 NonUniform -OpDecorate %243 NonUniform -OpDecorate %264 NonUniform -OpDecorate %266 NonUniform -OpDecorate %288 NonUniform -OpDecorate %290 NonUniform -OpDecorate %312 NonUniform -OpDecorate %314 NonUniform -OpDecorate %336 NonUniform -OpDecorate %338 NonUniform -OpDecorate %360 NonUniform -OpDecorate %362 NonUniform -OpDecorate %384 NonUniform -OpDecorate %386 NonUniform -OpDecorate %409 NonUniform +OpDecorate %47 Location 0 +OpDecorate %47 Flat +OpDecorate %50 Location 0 +OpDecorate %91 NonUniform +OpDecorate %114 NonUniform +OpDecorate %116 NonUniform +OpDecorate %141 NonUniform +OpDecorate %143 NonUniform +OpDecorate %180 NonUniform +OpDecorate %208 NonUniform +OpDecorate %224 NonUniform +OpDecorate %240 NonUniform +OpDecorate %261 NonUniform +OpDecorate %263 NonUniform +OpDecorate %285 NonUniform +OpDecorate %287 NonUniform +OpDecorate %309 NonUniform +OpDecorate %311 NonUniform +OpDecorate %333 NonUniform +OpDecorate %335 NonUniform +OpDecorate %357 NonUniform +OpDecorate %359 NonUniform +OpDecorate %381 NonUniform +OpDecorate %383 NonUniform +OpDecorate %406 NonUniform %2 = OpTypeVoid %3 = OpTypeInt 32 0 %4 = OpTypeStruct %3 @@ -100,460 +100,453 @@ OpDecorate %409 NonUniform %43 = OpTypeStruct %4 %44 = OpTypePointer Uniform %43 %42 = OpVariable %44 Uniform -%46 = OpTypePointer Function %3 -%47 = OpConstantNull %3 -%49 = OpTypePointer Function %23 -%50 = OpConstantNull %23 -%52 = OpTypePointer Function %6 -%53 = OpConstantNull %6 -%55 = OpTypePointer Function %22 -%56 = OpConstantNull %22 -%60 = OpTypePointer Input %3 -%59 = OpVariable %60 Input -%63 = OpTypePointer Output %22 -%62 = OpVariable %63 Output -%65 = OpTypeFunction %2 -%66 = OpTypePointer Uniform %4 -%67 = OpConstant %3 0 -%69 = OpConstant %6 0.0 -%70 = OpTypeInt 32 1 -%71 = OpConstant %70 0 -%73 = OpTypePointer Uniform %3 -%79 = OpTypeVector %6 2 -%81 = OpTypeVector %70 2 -%83 = OpTypePointer UniformConstant %5 -%101 = OpTypePointer UniformConstant %18 -%104 = OpTypeSampledImage %5 -%125 = OpTypePointer UniformConstant %14 -%128 = OpTypePointer UniformConstant %18 -%131 = OpTypeSampledImage %14 -%154 = OpTypeBool -%160 = OpTypeVector %154 2 -%196 = OpTypePointer UniformConstant %10 -%199 = OpTypeVector %3 3 -%231 = OpTypePointer UniformConstant %12 -%391 = OpTypePointer UniformConstant %16 -%64 = OpFunction %2 None %65 -%57 = OpLabel -%48 = OpVariable %49 Function %50 -%54 = OpVariable %55 Function %56 -%45 = OpVariable %46 Function %47 -%51 = OpVariable %52 Function %53 -%61 = OpLoad %3 %59 -%58 = OpCompositeConstruct %21 %61 -%68 = OpAccessChain %66 %42 %67 -OpBranch %72 -%72 = OpLabel -%74 = OpAccessChain %73 %68 %67 -%75 = OpLoad %3 %74 -%76 = OpCompositeExtract %3 %58 0 -OpStore %45 %67 -%77 = OpCompositeConstruct %23 %67 %67 -OpStore %48 %77 -OpStore %51 %69 -%78 = OpCompositeConstruct %22 %69 %69 %69 %69 -OpStore %54 %78 -%80 = OpCompositeConstruct %79 %69 %69 -%82 = OpCompositeConstruct %81 %71 %71 -%84 = OpAccessChain %83 %24 %67 -%85 = OpLoad %5 %84 -%86 = OpImageQuerySizeLod %23 %85 %67 -%87 = OpLoad %23 %48 -%88 = OpIAdd %23 %87 %86 -OpStore %48 %88 -%89 = OpAccessChain %83 %24 %75 -%90 = OpLoad %5 %89 -%91 = OpImageQuerySizeLod %23 %90 %67 -%92 = OpLoad %23 %48 -%93 = OpIAdd %23 %92 %91 -OpStore %48 %93 -%94 = OpAccessChain %83 %24 %76 -%95 = OpLoad %5 %94 -%96 = OpImageQuerySizeLod %23 %95 %67 -%97 = OpLoad %23 %48 -%98 = OpIAdd %23 %97 %96 -OpStore %48 %98 -%99 = OpAccessChain %83 %28 %67 -%100 = OpLoad %5 %99 -%102 = OpAccessChain %101 %38 %67 -%103 = OpLoad %18 %102 -%105 = OpSampledImage %104 %100 %103 -%106 = OpImageGather %22 %105 %80 %67 -%107 = OpLoad %22 %54 -%108 = OpFAdd %22 %107 %106 -OpStore %54 %108 -%109 = OpAccessChain %83 %28 %75 -%110 = OpLoad %5 %109 -%111 = OpAccessChain %101 %38 %75 -%112 = OpLoad %18 %111 -%113 = OpSampledImage %104 %110 %112 -%114 = OpImageGather %22 %113 %80 %67 -%115 = OpLoad %22 %54 -%116 = OpFAdd %22 %115 %114 -OpStore %54 %116 -%117 = OpAccessChain %83 %28 %76 -%118 = OpLoad %5 %117 -%119 = OpAccessChain %101 %38 %76 -%120 = OpLoad %18 %119 -%121 = OpSampledImage %104 %118 %120 -%122 = OpImageGather %22 %121 %80 %67 -%123 = OpLoad %22 %54 -%124 = OpFAdd %22 %123 %122 -OpStore %54 %124 -%126 = OpAccessChain %125 %34 %67 -%127 = OpLoad %14 %126 -%129 = OpAccessChain %128 %40 %67 -%130 = OpLoad %18 %129 -%132 = OpSampledImage %131 %127 %130 -%133 = OpImageDrefGather %22 %132 %80 %69 -%134 = OpLoad %22 %54 -%135 = OpFAdd %22 %134 %133 -OpStore %54 %135 -%136 = OpAccessChain %125 %34 %75 -%137 = OpLoad %14 %136 -%138 = OpAccessChain %128 %40 %75 -%139 = OpLoad %18 %138 -%140 = OpSampledImage %131 %137 %139 -%141 = OpImageDrefGather %22 %140 %80 %69 -%142 = OpLoad %22 %54 -%143 = OpFAdd %22 %142 %141 -OpStore %54 %143 -%144 = OpAccessChain %125 %34 %76 -%145 = OpLoad %14 %144 -%146 = OpAccessChain %128 %40 %76 -%147 = OpLoad %18 %146 -%148 = OpSampledImage %131 %145 %147 -%149 = OpImageDrefGather %22 %148 %80 %69 -%150 = OpLoad %22 %54 -%151 = OpFAdd %22 %150 %149 -OpStore %54 %151 -%152 = OpAccessChain %83 %24 %67 -%153 = OpLoad %5 %152 -%155 = OpImageQueryLevels %70 %153 -%156 = OpULessThan %154 %71 %155 -OpSelectionMerge %157 None -OpBranchConditional %156 %158 %157 -%158 = OpLabel -%159 = OpImageQuerySizeLod %81 %153 %71 -%161 = OpULessThan %160 %82 %159 -%162 = OpAll %154 %161 -OpBranchConditional %162 %163 %157 -%163 = OpLabel -%164 = OpImageFetch %22 %153 %82 Lod %71 -OpBranch %157 -%157 = OpLabel -%165 = OpPhi %22 %56 %72 %56 %158 %164 %163 -%166 = OpLoad %22 %54 -%167 = OpFAdd %22 %166 %165 -OpStore %54 %167 -%168 = OpAccessChain %83 %24 %75 -%169 = OpLoad %5 %168 -%170 = OpImageQueryLevels %70 %169 -%171 = OpULessThan %154 %71 %170 -OpSelectionMerge %172 None -OpBranchConditional %171 %173 %172 -%173 = OpLabel -%174 = OpImageQuerySizeLod %81 %169 %71 -%175 = OpULessThan %160 %82 %174 -%176 = OpAll %154 %175 -OpBranchConditional %176 %177 %172 -%177 = OpLabel -%178 = OpImageFetch %22 %169 %82 Lod %71 -OpBranch %172 -%172 = OpLabel -%179 = OpPhi %22 %56 %157 %56 %173 %178 %177 -%180 = OpLoad %22 %54 -%181 = OpFAdd %22 %180 %179 -OpStore %54 %181 -%182 = OpAccessChain %83 %24 %76 -%183 = OpLoad %5 %182 -%184 = OpImageQueryLevels %70 %183 -%185 = OpULessThan %154 %71 %184 -OpSelectionMerge %186 None -OpBranchConditional %185 %187 %186 -%187 = OpLabel -%188 = OpImageQuerySizeLod %81 %183 %71 -%189 = OpULessThan %160 %82 %188 -%190 = OpAll %154 %189 -OpBranchConditional %190 %191 %186 -%191 = OpLabel -%192 = OpImageFetch %22 %183 %82 Lod %71 -OpBranch %186 -%186 = OpLabel -%193 = OpPhi %22 %56 %172 %56 %187 %192 %191 -%194 = OpLoad %22 %54 -%195 = OpFAdd %22 %194 %193 -OpStore %54 %195 -%197 = OpAccessChain %196 %30 %67 -%198 = OpLoad %10 %197 -%200 = OpImageQuerySizeLod %199 %198 %67 -%201 = OpCompositeExtract %3 %200 2 -%202 = OpLoad %3 %45 -%203 = OpIAdd %3 %202 %201 -OpStore %45 %203 -%204 = OpAccessChain %196 %30 %75 -%205 = OpLoad %10 %204 -%206 = OpImageQuerySizeLod %199 %205 %67 -%207 = OpCompositeExtract %3 %206 2 -%208 = OpLoad %3 %45 -%209 = OpIAdd %3 %208 %207 -OpStore %45 %209 -%210 = OpAccessChain %196 %30 %76 -%211 = OpLoad %10 %210 -%212 = OpImageQuerySizeLod %199 %211 %67 -%213 = OpCompositeExtract %3 %212 2 -%214 = OpLoad %3 %45 -%215 = OpIAdd %3 %214 %213 -OpStore %45 %215 -%216 = OpAccessChain %83 %28 %67 -%217 = OpLoad %5 %216 -%218 = OpImageQueryLevels %3 %217 -%219 = OpLoad %3 %45 -%220 = OpIAdd %3 %219 %218 -OpStore %45 %220 -%221 = OpAccessChain %83 %28 %75 -%222 = OpLoad %5 %221 -%223 = OpImageQueryLevels %3 %222 -%224 = OpLoad %3 %45 -%225 = OpIAdd %3 %224 %223 -OpStore %45 %225 -%226 = OpAccessChain %83 %28 %76 -%227 = OpLoad %5 %226 -%228 = OpImageQueryLevels %3 %227 -%229 = OpLoad %3 %45 -%230 = OpIAdd %3 %229 %228 -OpStore %45 %230 -%232 = OpAccessChain %231 %32 %67 -%233 = OpLoad %12 %232 -%234 = OpImageQuerySamples %3 %233 -%235 = OpLoad %3 %45 -%236 = OpIAdd %3 %235 %234 -OpStore %45 %236 -%237 = OpAccessChain %231 %32 %75 -%238 = OpLoad %12 %237 -%239 = OpImageQuerySamples %3 %238 -%240 = OpLoad %3 %45 -%241 = OpIAdd %3 %240 %239 -OpStore %45 %241 -%242 = OpAccessChain %231 %32 %76 -%243 = OpLoad %12 %242 -%244 = OpImageQuerySamples %3 %243 -%245 = OpLoad %3 %45 -%246 = OpIAdd %3 %245 %244 -OpStore %45 %246 -%247 = OpAccessChain %83 %28 %67 -%248 = OpLoad %5 %247 -%249 = OpAccessChain %101 %38 %67 -%250 = OpLoad %18 %249 -%251 = OpSampledImage %104 %248 %250 -%252 = OpImageSampleImplicitLod %22 %251 %80 -%253 = OpLoad %22 %54 -%254 = OpFAdd %22 %253 %252 -OpStore %54 %254 -%255 = OpAccessChain %83 %28 %75 -%256 = OpLoad %5 %255 -%257 = OpAccessChain %101 %38 %75 -%258 = OpLoad %18 %257 -%259 = OpSampledImage %104 %256 %258 -%260 = OpImageSampleImplicitLod %22 %259 %80 -%261 = OpLoad %22 %54 -%262 = OpFAdd %22 %261 %260 -OpStore %54 %262 -%263 = OpAccessChain %83 %28 %76 -%264 = OpLoad %5 %263 -%265 = OpAccessChain %101 %38 %76 -%266 = OpLoad %18 %265 -%267 = OpSampledImage %104 %264 %266 -%268 = OpImageSampleImplicitLod %22 %267 %80 -%269 = OpLoad %22 %54 -%270 = OpFAdd %22 %269 %268 -OpStore %54 %270 -%271 = OpAccessChain %83 %28 %67 -%272 = OpLoad %5 %271 -%273 = OpAccessChain %101 %38 %67 -%274 = OpLoad %18 %273 -%275 = OpSampledImage %104 %272 %274 -%276 = OpImageSampleImplicitLod %22 %275 %80 Bias %69 -%277 = OpLoad %22 %54 -%278 = OpFAdd %22 %277 %276 -OpStore %54 %278 -%279 = OpAccessChain %83 %28 %75 -%280 = OpLoad %5 %279 -%281 = OpAccessChain %101 %38 %75 -%282 = OpLoad %18 %281 -%283 = OpSampledImage %104 %280 %282 -%284 = OpImageSampleImplicitLod %22 %283 %80 Bias %69 -%285 = OpLoad %22 %54 -%286 = OpFAdd %22 %285 %284 -OpStore %54 %286 -%287 = OpAccessChain %83 %28 %76 -%288 = OpLoad %5 %287 -%289 = OpAccessChain %101 %38 %76 -%290 = OpLoad %18 %289 -%291 = OpSampledImage %104 %288 %290 -%292 = OpImageSampleImplicitLod %22 %291 %80 Bias %69 -%293 = OpLoad %22 %54 -%294 = OpFAdd %22 %293 %292 -OpStore %54 %294 -%295 = OpAccessChain %125 %34 %67 -%296 = OpLoad %14 %295 -%297 = OpAccessChain %128 %40 %67 -%298 = OpLoad %18 %297 -%299 = OpSampledImage %131 %296 %298 -%300 = OpImageSampleDrefImplicitLod %6 %299 %80 %69 -%301 = OpLoad %6 %51 -%302 = OpFAdd %6 %301 %300 -OpStore %51 %302 -%303 = OpAccessChain %125 %34 %75 -%304 = OpLoad %14 %303 -%305 = OpAccessChain %128 %40 %75 -%306 = OpLoad %18 %305 -%307 = OpSampledImage %131 %304 %306 -%308 = OpImageSampleDrefImplicitLod %6 %307 %80 %69 -%309 = OpLoad %6 %51 -%310 = OpFAdd %6 %309 %308 -OpStore %51 %310 -%311 = OpAccessChain %125 %34 %76 -%312 = OpLoad %14 %311 -%313 = OpAccessChain %128 %40 %76 -%314 = OpLoad %18 %313 -%315 = OpSampledImage %131 %312 %314 -%316 = OpImageSampleDrefImplicitLod %6 %315 %80 %69 -%317 = OpLoad %6 %51 -%318 = OpFAdd %6 %317 %316 -OpStore %51 %318 -%319 = OpAccessChain %125 %34 %67 -%320 = OpLoad %14 %319 -%321 = OpAccessChain %128 %40 %67 -%322 = OpLoad %18 %321 -%323 = OpSampledImage %131 %320 %322 -%324 = OpImageSampleDrefExplicitLod %6 %323 %80 %69 Lod %69 -%325 = OpLoad %6 %51 -%326 = OpFAdd %6 %325 %324 -OpStore %51 %326 -%327 = OpAccessChain %125 %34 %75 -%328 = OpLoad %14 %327 -%329 = OpAccessChain %128 %40 %75 -%330 = OpLoad %18 %329 -%331 = OpSampledImage %131 %328 %330 -%332 = OpImageSampleDrefExplicitLod %6 %331 %80 %69 Lod %69 -%333 = OpLoad %6 %51 -%334 = OpFAdd %6 %333 %332 -OpStore %51 %334 -%335 = OpAccessChain %125 %34 %76 -%336 = OpLoad %14 %335 -%337 = OpAccessChain %128 %40 %76 -%338 = OpLoad %18 %337 -%339 = OpSampledImage %131 %336 %338 -%340 = OpImageSampleDrefExplicitLod %6 %339 %80 %69 Lod %69 -%341 = OpLoad %6 %51 -%342 = OpFAdd %6 %341 %340 -OpStore %51 %342 -%343 = OpAccessChain %83 %28 %67 -%344 = OpLoad %5 %343 -%345 = OpAccessChain %101 %38 %67 -%346 = OpLoad %18 %345 -%347 = OpSampledImage %104 %344 %346 -%348 = OpImageSampleExplicitLod %22 %347 %80 Grad %80 %80 -%349 = OpLoad %22 %54 -%350 = OpFAdd %22 %349 %348 -OpStore %54 %350 -%351 = OpAccessChain %83 %28 %75 -%352 = OpLoad %5 %351 -%353 = OpAccessChain %101 %38 %75 -%354 = OpLoad %18 %353 -%355 = OpSampledImage %104 %352 %354 -%356 = OpImageSampleExplicitLod %22 %355 %80 Grad %80 %80 -%357 = OpLoad %22 %54 -%358 = OpFAdd %22 %357 %356 -OpStore %54 %358 -%359 = OpAccessChain %83 %28 %76 -%360 = OpLoad %5 %359 -%361 = OpAccessChain %101 %38 %76 -%362 = OpLoad %18 %361 -%363 = OpSampledImage %104 %360 %362 -%364 = OpImageSampleExplicitLod %22 %363 %80 Grad %80 %80 -%365 = OpLoad %22 %54 -%366 = OpFAdd %22 %365 %364 -OpStore %54 %366 -%367 = OpAccessChain %83 %28 %67 -%368 = OpLoad %5 %367 -%369 = OpAccessChain %101 %38 %67 -%370 = OpLoad %18 %369 -%371 = OpSampledImage %104 %368 %370 -%372 = OpImageSampleExplicitLod %22 %371 %80 Lod %69 -%373 = OpLoad %22 %54 -%374 = OpFAdd %22 %373 %372 -OpStore %54 %374 -%375 = OpAccessChain %83 %28 %75 -%376 = OpLoad %5 %375 -%377 = OpAccessChain %101 %38 %75 -%378 = OpLoad %18 %377 -%379 = OpSampledImage %104 %376 %378 -%380 = OpImageSampleExplicitLod %22 %379 %80 Lod %69 -%381 = OpLoad %22 %54 -%382 = OpFAdd %22 %381 %380 -OpStore %54 %382 -%383 = OpAccessChain %83 %28 %76 -%384 = OpLoad %5 %383 -%385 = OpAccessChain %101 %38 %76 -%386 = OpLoad %18 %385 -%387 = OpSampledImage %104 %384 %386 -%388 = OpImageSampleExplicitLod %22 %387 %80 Lod %69 -%389 = OpLoad %22 %54 -%390 = OpFAdd %22 %389 %388 -OpStore %54 %390 -%392 = OpAccessChain %391 %36 %67 -%393 = OpLoad %16 %392 -%394 = OpLoad %22 %54 -%395 = OpImageQuerySize %81 %393 -%396 = OpULessThan %160 %82 %395 -%397 = OpAll %154 %396 -OpSelectionMerge %398 None -OpBranchConditional %397 %399 %398 -%399 = OpLabel -OpImageWrite %393 %82 %394 -OpBranch %398 -%398 = OpLabel -%400 = OpAccessChain %391 %36 %75 -%401 = OpLoad %16 %400 -%402 = OpLoad %22 %54 -%403 = OpImageQuerySize %81 %401 -%404 = OpULessThan %160 %82 %403 -%405 = OpAll %154 %404 -OpSelectionMerge %406 None -OpBranchConditional %405 %407 %406 -%407 = OpLabel -OpImageWrite %401 %82 %402 -OpBranch %406 -%406 = OpLabel -%408 = OpAccessChain %391 %36 %76 -%409 = OpLoad %16 %408 -%410 = OpLoad %22 %54 -%411 = OpImageQuerySize %81 %409 -%412 = OpULessThan %160 %82 %411 -%413 = OpAll %154 %412 -OpSelectionMerge %414 None -OpBranchConditional %413 %415 %414 -%415 = OpLabel -OpImageWrite %409 %82 %410 -OpBranch %414 -%414 = OpLabel -%416 = OpLoad %23 %48 -%417 = OpLoad %3 %45 -%418 = OpCompositeConstruct %23 %417 %417 -%419 = OpIAdd %23 %416 %418 -%420 = OpConvertUToF %79 %419 -%421 = OpLoad %22 %54 -%422 = OpCompositeExtract %6 %420 0 -%423 = OpCompositeExtract %6 %420 1 -%424 = OpCompositeExtract %6 %420 0 -%425 = OpCompositeExtract %6 %420 1 -%426 = OpCompositeConstruct %22 %422 %423 %424 %425 -%427 = OpFAdd %22 %421 %426 -%428 = OpLoad %6 %51 -%429 = OpCompositeConstruct %22 %428 %428 %428 %428 -%430 = OpFAdd %22 %427 %429 -OpStore %62 %430 +%48 = OpTypePointer Input %3 +%47 = OpVariable %48 Input +%51 = OpTypePointer Output %22 +%50 = OpVariable %51 Output +%53 = OpTypeFunction %2 +%54 = OpTypePointer Uniform %4 +%55 = OpConstant %3 0 +%57 = OpConstantComposite %23 %55 %55 +%58 = OpConstant %6 0.0 +%59 = OpConstantComposite %22 %58 %58 %58 %58 +%60 = OpTypeVector %6 2 +%61 = OpConstantComposite %60 %58 %58 +%62 = OpTypeInt 32 1 +%63 = OpConstant %62 0 +%64 = OpTypeVector %62 2 +%65 = OpConstantComposite %64 %63 %63 +%67 = OpTypePointer Function %3 +%69 = OpTypePointer Function %23 +%71 = OpTypePointer Function %6 +%73 = OpTypePointer Function %22 +%75 = OpTypePointer Uniform %3 +%79 = OpTypePointer UniformConstant %5 +%97 = OpTypePointer UniformConstant %18 +%100 = OpTypeSampledImage %5 +%121 = OpTypePointer UniformConstant %14 +%124 = OpTypePointer UniformConstant %18 +%127 = OpTypeSampledImage %14 +%150 = OpTypeBool +%151 = OpConstantNull %22 +%157 = OpTypeVector %150 2 +%193 = OpTypePointer UniformConstant %10 +%196 = OpTypeVector %3 3 +%228 = OpTypePointer UniformConstant %12 +%388 = OpTypePointer UniformConstant %16 +%52 = OpFunction %2 None %53 +%45 = OpLabel +%68 = OpVariable %69 Function %57 +%72 = OpVariable %73 Function %59 +%66 = OpVariable %67 Function %55 +%70 = OpVariable %71 Function %58 +%49 = OpLoad %3 %47 +%46 = OpCompositeConstruct %21 %49 +%56 = OpAccessChain %54 %42 %55 +OpBranch %74 +%74 = OpLabel +%76 = OpAccessChain %75 %56 %55 +%77 = OpLoad %3 %76 +%78 = OpCompositeExtract %3 %46 0 +%80 = OpAccessChain %79 %24 %55 +%81 = OpLoad %5 %80 +%82 = OpImageQuerySizeLod %23 %81 %55 +%83 = OpLoad %23 %68 +%84 = OpIAdd %23 %83 %82 +OpStore %68 %84 +%85 = OpAccessChain %79 %24 %77 +%86 = OpLoad %5 %85 +%87 = OpImageQuerySizeLod %23 %86 %55 +%88 = OpLoad %23 %68 +%89 = OpIAdd %23 %88 %87 +OpStore %68 %89 +%90 = OpAccessChain %79 %24 %78 +%91 = OpLoad %5 %90 +%92 = OpImageQuerySizeLod %23 %91 %55 +%93 = OpLoad %23 %68 +%94 = OpIAdd %23 %93 %92 +OpStore %68 %94 +%95 = OpAccessChain %79 %28 %55 +%96 = OpLoad %5 %95 +%98 = OpAccessChain %97 %38 %55 +%99 = OpLoad %18 %98 +%101 = OpSampledImage %100 %96 %99 +%102 = OpImageGather %22 %101 %61 %55 +%103 = OpLoad %22 %72 +%104 = OpFAdd %22 %103 %102 +OpStore %72 %104 +%105 = OpAccessChain %79 %28 %77 +%106 = OpLoad %5 %105 +%107 = OpAccessChain %97 %38 %77 +%108 = OpLoad %18 %107 +%109 = OpSampledImage %100 %106 %108 +%110 = OpImageGather %22 %109 %61 %55 +%111 = OpLoad %22 %72 +%112 = OpFAdd %22 %111 %110 +OpStore %72 %112 +%113 = OpAccessChain %79 %28 %78 +%114 = OpLoad %5 %113 +%115 = OpAccessChain %97 %38 %78 +%116 = OpLoad %18 %115 +%117 = OpSampledImage %100 %114 %116 +%118 = OpImageGather %22 %117 %61 %55 +%119 = OpLoad %22 %72 +%120 = OpFAdd %22 %119 %118 +OpStore %72 %120 +%122 = OpAccessChain %121 %34 %55 +%123 = OpLoad %14 %122 +%125 = OpAccessChain %124 %40 %55 +%126 = OpLoad %18 %125 +%128 = OpSampledImage %127 %123 %126 +%129 = OpImageDrefGather %22 %128 %61 %58 +%130 = OpLoad %22 %72 +%131 = OpFAdd %22 %130 %129 +OpStore %72 %131 +%132 = OpAccessChain %121 %34 %77 +%133 = OpLoad %14 %132 +%134 = OpAccessChain %124 %40 %77 +%135 = OpLoad %18 %134 +%136 = OpSampledImage %127 %133 %135 +%137 = OpImageDrefGather %22 %136 %61 %58 +%138 = OpLoad %22 %72 +%139 = OpFAdd %22 %138 %137 +OpStore %72 %139 +%140 = OpAccessChain %121 %34 %78 +%141 = OpLoad %14 %140 +%142 = OpAccessChain %124 %40 %78 +%143 = OpLoad %18 %142 +%144 = OpSampledImage %127 %141 %143 +%145 = OpImageDrefGather %22 %144 %61 %58 +%146 = OpLoad %22 %72 +%147 = OpFAdd %22 %146 %145 +OpStore %72 %147 +%148 = OpAccessChain %79 %24 %55 +%149 = OpLoad %5 %148 +%152 = OpImageQueryLevels %62 %149 +%153 = OpULessThan %150 %63 %152 +OpSelectionMerge %154 None +OpBranchConditional %153 %155 %154 +%155 = OpLabel +%156 = OpImageQuerySizeLod %64 %149 %63 +%158 = OpULessThan %157 %65 %156 +%159 = OpAll %150 %158 +OpBranchConditional %159 %160 %154 +%160 = OpLabel +%161 = OpImageFetch %22 %149 %65 Lod %63 +OpBranch %154 +%154 = OpLabel +%162 = OpPhi %22 %151 %74 %151 %155 %161 %160 +%163 = OpLoad %22 %72 +%164 = OpFAdd %22 %163 %162 +OpStore %72 %164 +%165 = OpAccessChain %79 %24 %77 +%166 = OpLoad %5 %165 +%167 = OpImageQueryLevels %62 %166 +%168 = OpULessThan %150 %63 %167 +OpSelectionMerge %169 None +OpBranchConditional %168 %170 %169 +%170 = OpLabel +%171 = OpImageQuerySizeLod %64 %166 %63 +%172 = OpULessThan %157 %65 %171 +%173 = OpAll %150 %172 +OpBranchConditional %173 %174 %169 +%174 = OpLabel +%175 = OpImageFetch %22 %166 %65 Lod %63 +OpBranch %169 +%169 = OpLabel +%176 = OpPhi %22 %151 %154 %151 %170 %175 %174 +%177 = OpLoad %22 %72 +%178 = OpFAdd %22 %177 %176 +OpStore %72 %178 +%179 = OpAccessChain %79 %24 %78 +%180 = OpLoad %5 %179 +%181 = OpImageQueryLevels %62 %180 +%182 = OpULessThan %150 %63 %181 +OpSelectionMerge %183 None +OpBranchConditional %182 %184 %183 +%184 = OpLabel +%185 = OpImageQuerySizeLod %64 %180 %63 +%186 = OpULessThan %157 %65 %185 +%187 = OpAll %150 %186 +OpBranchConditional %187 %188 %183 +%188 = OpLabel +%189 = OpImageFetch %22 %180 %65 Lod %63 +OpBranch %183 +%183 = OpLabel +%190 = OpPhi %22 %151 %169 %151 %184 %189 %188 +%191 = OpLoad %22 %72 +%192 = OpFAdd %22 %191 %190 +OpStore %72 %192 +%194 = OpAccessChain %193 %30 %55 +%195 = OpLoad %10 %194 +%197 = OpImageQuerySizeLod %196 %195 %55 +%198 = OpCompositeExtract %3 %197 2 +%199 = OpLoad %3 %66 +%200 = OpIAdd %3 %199 %198 +OpStore %66 %200 +%201 = OpAccessChain %193 %30 %77 +%202 = OpLoad %10 %201 +%203 = OpImageQuerySizeLod %196 %202 %55 +%204 = OpCompositeExtract %3 %203 2 +%205 = OpLoad %3 %66 +%206 = OpIAdd %3 %205 %204 +OpStore %66 %206 +%207 = OpAccessChain %193 %30 %78 +%208 = OpLoad %10 %207 +%209 = OpImageQuerySizeLod %196 %208 %55 +%210 = OpCompositeExtract %3 %209 2 +%211 = OpLoad %3 %66 +%212 = OpIAdd %3 %211 %210 +OpStore %66 %212 +%213 = OpAccessChain %79 %28 %55 +%214 = OpLoad %5 %213 +%215 = OpImageQueryLevels %3 %214 +%216 = OpLoad %3 %66 +%217 = OpIAdd %3 %216 %215 +OpStore %66 %217 +%218 = OpAccessChain %79 %28 %77 +%219 = OpLoad %5 %218 +%220 = OpImageQueryLevels %3 %219 +%221 = OpLoad %3 %66 +%222 = OpIAdd %3 %221 %220 +OpStore %66 %222 +%223 = OpAccessChain %79 %28 %78 +%224 = OpLoad %5 %223 +%225 = OpImageQueryLevels %3 %224 +%226 = OpLoad %3 %66 +%227 = OpIAdd %3 %226 %225 +OpStore %66 %227 +%229 = OpAccessChain %228 %32 %55 +%230 = OpLoad %12 %229 +%231 = OpImageQuerySamples %3 %230 +%232 = OpLoad %3 %66 +%233 = OpIAdd %3 %232 %231 +OpStore %66 %233 +%234 = OpAccessChain %228 %32 %77 +%235 = OpLoad %12 %234 +%236 = OpImageQuerySamples %3 %235 +%237 = OpLoad %3 %66 +%238 = OpIAdd %3 %237 %236 +OpStore %66 %238 +%239 = OpAccessChain %228 %32 %78 +%240 = OpLoad %12 %239 +%241 = OpImageQuerySamples %3 %240 +%242 = OpLoad %3 %66 +%243 = OpIAdd %3 %242 %241 +OpStore %66 %243 +%244 = OpAccessChain %79 %28 %55 +%245 = OpLoad %5 %244 +%246 = OpAccessChain %97 %38 %55 +%247 = OpLoad %18 %246 +%248 = OpSampledImage %100 %245 %247 +%249 = OpImageSampleImplicitLod %22 %248 %61 +%250 = OpLoad %22 %72 +%251 = OpFAdd %22 %250 %249 +OpStore %72 %251 +%252 = OpAccessChain %79 %28 %77 +%253 = OpLoad %5 %252 +%254 = OpAccessChain %97 %38 %77 +%255 = OpLoad %18 %254 +%256 = OpSampledImage %100 %253 %255 +%257 = OpImageSampleImplicitLod %22 %256 %61 +%258 = OpLoad %22 %72 +%259 = OpFAdd %22 %258 %257 +OpStore %72 %259 +%260 = OpAccessChain %79 %28 %78 +%261 = OpLoad %5 %260 +%262 = OpAccessChain %97 %38 %78 +%263 = OpLoad %18 %262 +%264 = OpSampledImage %100 %261 %263 +%265 = OpImageSampleImplicitLod %22 %264 %61 +%266 = OpLoad %22 %72 +%267 = OpFAdd %22 %266 %265 +OpStore %72 %267 +%268 = OpAccessChain %79 %28 %55 +%269 = OpLoad %5 %268 +%270 = OpAccessChain %97 %38 %55 +%271 = OpLoad %18 %270 +%272 = OpSampledImage %100 %269 %271 +%273 = OpImageSampleImplicitLod %22 %272 %61 Bias %58 +%274 = OpLoad %22 %72 +%275 = OpFAdd %22 %274 %273 +OpStore %72 %275 +%276 = OpAccessChain %79 %28 %77 +%277 = OpLoad %5 %276 +%278 = OpAccessChain %97 %38 %77 +%279 = OpLoad %18 %278 +%280 = OpSampledImage %100 %277 %279 +%281 = OpImageSampleImplicitLod %22 %280 %61 Bias %58 +%282 = OpLoad %22 %72 +%283 = OpFAdd %22 %282 %281 +OpStore %72 %283 +%284 = OpAccessChain %79 %28 %78 +%285 = OpLoad %5 %284 +%286 = OpAccessChain %97 %38 %78 +%287 = OpLoad %18 %286 +%288 = OpSampledImage %100 %285 %287 +%289 = OpImageSampleImplicitLod %22 %288 %61 Bias %58 +%290 = OpLoad %22 %72 +%291 = OpFAdd %22 %290 %289 +OpStore %72 %291 +%292 = OpAccessChain %121 %34 %55 +%293 = OpLoad %14 %292 +%294 = OpAccessChain %124 %40 %55 +%295 = OpLoad %18 %294 +%296 = OpSampledImage %127 %293 %295 +%297 = OpImageSampleDrefImplicitLod %6 %296 %61 %58 +%298 = OpLoad %6 %70 +%299 = OpFAdd %6 %298 %297 +OpStore %70 %299 +%300 = OpAccessChain %121 %34 %77 +%301 = OpLoad %14 %300 +%302 = OpAccessChain %124 %40 %77 +%303 = OpLoad %18 %302 +%304 = OpSampledImage %127 %301 %303 +%305 = OpImageSampleDrefImplicitLod %6 %304 %61 %58 +%306 = OpLoad %6 %70 +%307 = OpFAdd %6 %306 %305 +OpStore %70 %307 +%308 = OpAccessChain %121 %34 %78 +%309 = OpLoad %14 %308 +%310 = OpAccessChain %124 %40 %78 +%311 = OpLoad %18 %310 +%312 = OpSampledImage %127 %309 %311 +%313 = OpImageSampleDrefImplicitLod %6 %312 %61 %58 +%314 = OpLoad %6 %70 +%315 = OpFAdd %6 %314 %313 +OpStore %70 %315 +%316 = OpAccessChain %121 %34 %55 +%317 = OpLoad %14 %316 +%318 = OpAccessChain %124 %40 %55 +%319 = OpLoad %18 %318 +%320 = OpSampledImage %127 %317 %319 +%321 = OpImageSampleDrefExplicitLod %6 %320 %61 %58 Lod %58 +%322 = OpLoad %6 %70 +%323 = OpFAdd %6 %322 %321 +OpStore %70 %323 +%324 = OpAccessChain %121 %34 %77 +%325 = OpLoad %14 %324 +%326 = OpAccessChain %124 %40 %77 +%327 = OpLoad %18 %326 +%328 = OpSampledImage %127 %325 %327 +%329 = OpImageSampleDrefExplicitLod %6 %328 %61 %58 Lod %58 +%330 = OpLoad %6 %70 +%331 = OpFAdd %6 %330 %329 +OpStore %70 %331 +%332 = OpAccessChain %121 %34 %78 +%333 = OpLoad %14 %332 +%334 = OpAccessChain %124 %40 %78 +%335 = OpLoad %18 %334 +%336 = OpSampledImage %127 %333 %335 +%337 = OpImageSampleDrefExplicitLod %6 %336 %61 %58 Lod %58 +%338 = OpLoad %6 %70 +%339 = OpFAdd %6 %338 %337 +OpStore %70 %339 +%340 = OpAccessChain %79 %28 %55 +%341 = OpLoad %5 %340 +%342 = OpAccessChain %97 %38 %55 +%343 = OpLoad %18 %342 +%344 = OpSampledImage %100 %341 %343 +%345 = OpImageSampleExplicitLod %22 %344 %61 Grad %61 %61 +%346 = OpLoad %22 %72 +%347 = OpFAdd %22 %346 %345 +OpStore %72 %347 +%348 = OpAccessChain %79 %28 %77 +%349 = OpLoad %5 %348 +%350 = OpAccessChain %97 %38 %77 +%351 = OpLoad %18 %350 +%352 = OpSampledImage %100 %349 %351 +%353 = OpImageSampleExplicitLod %22 %352 %61 Grad %61 %61 +%354 = OpLoad %22 %72 +%355 = OpFAdd %22 %354 %353 +OpStore %72 %355 +%356 = OpAccessChain %79 %28 %78 +%357 = OpLoad %5 %356 +%358 = OpAccessChain %97 %38 %78 +%359 = OpLoad %18 %358 +%360 = OpSampledImage %100 %357 %359 +%361 = OpImageSampleExplicitLod %22 %360 %61 Grad %61 %61 +%362 = OpLoad %22 %72 +%363 = OpFAdd %22 %362 %361 +OpStore %72 %363 +%364 = OpAccessChain %79 %28 %55 +%365 = OpLoad %5 %364 +%366 = OpAccessChain %97 %38 %55 +%367 = OpLoad %18 %366 +%368 = OpSampledImage %100 %365 %367 +%369 = OpImageSampleExplicitLod %22 %368 %61 Lod %58 +%370 = OpLoad %22 %72 +%371 = OpFAdd %22 %370 %369 +OpStore %72 %371 +%372 = OpAccessChain %79 %28 %77 +%373 = OpLoad %5 %372 +%374 = OpAccessChain %97 %38 %77 +%375 = OpLoad %18 %374 +%376 = OpSampledImage %100 %373 %375 +%377 = OpImageSampleExplicitLod %22 %376 %61 Lod %58 +%378 = OpLoad %22 %72 +%379 = OpFAdd %22 %378 %377 +OpStore %72 %379 +%380 = OpAccessChain %79 %28 %78 +%381 = OpLoad %5 %380 +%382 = OpAccessChain %97 %38 %78 +%383 = OpLoad %18 %382 +%384 = OpSampledImage %100 %381 %383 +%385 = OpImageSampleExplicitLod %22 %384 %61 Lod %58 +%386 = OpLoad %22 %72 +%387 = OpFAdd %22 %386 %385 +OpStore %72 %387 +%389 = OpAccessChain %388 %36 %55 +%390 = OpLoad %16 %389 +%391 = OpLoad %22 %72 +%392 = OpImageQuerySize %64 %390 +%393 = OpULessThan %157 %65 %392 +%394 = OpAll %150 %393 +OpSelectionMerge %395 None +OpBranchConditional %394 %396 %395 +%396 = OpLabel +OpImageWrite %390 %65 %391 +OpBranch %395 +%395 = OpLabel +%397 = OpAccessChain %388 %36 %77 +%398 = OpLoad %16 %397 +%399 = OpLoad %22 %72 +%400 = OpImageQuerySize %64 %398 +%401 = OpULessThan %157 %65 %400 +%402 = OpAll %150 %401 +OpSelectionMerge %403 None +OpBranchConditional %402 %404 %403 +%404 = OpLabel +OpImageWrite %398 %65 %399 +OpBranch %403 +%403 = OpLabel +%405 = OpAccessChain %388 %36 %78 +%406 = OpLoad %16 %405 +%407 = OpLoad %22 %72 +%408 = OpImageQuerySize %64 %406 +%409 = OpULessThan %157 %65 %408 +%410 = OpAll %150 %409 +OpSelectionMerge %411 None +OpBranchConditional %410 %412 %411 +%412 = OpLabel +OpImageWrite %406 %65 %407 +OpBranch %411 +%411 = OpLabel +%413 = OpLoad %23 %68 +%414 = OpLoad %3 %66 +%415 = OpCompositeConstruct %23 %414 %414 +%416 = OpIAdd %23 %413 %415 +%417 = OpConvertUToF %60 %416 +%418 = OpLoad %22 %72 +%419 = OpCompositeExtract %6 %417 0 +%420 = OpCompositeExtract %6 %417 1 +%421 = OpCompositeExtract %6 %417 0 +%422 = OpCompositeExtract %6 %417 1 +%423 = OpCompositeConstruct %22 %419 %420 %421 %422 +%424 = OpFAdd %22 %418 %423 +%425 = OpLoad %6 %70 +%426 = OpCompositeConstruct %22 %425 %425 %425 %425 +%427 = OpFAdd %22 %424 %426 +OpStore %50 %427 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/binding-buffer-arrays.spvasm b/tests/out/spv/binding-buffer-arrays.spvasm index bc89271fd3..050372036d 100644 --- a/tests/out/spv/binding-buffer-arrays.spvasm +++ b/tests/out/spv/binding-buffer-arrays.spvasm @@ -8,8 +8,8 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" OpExtension "SPV_EXT_descriptor_indexing" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %26 "main" %21 %24 -OpExecutionMode %26 OriginUpperLeft +OpEntryPoint Fragment %23 "main" %18 %21 +OpExecutionMode %23 OriginUpperLeft OpMemberDecorate %4 0 Offset 0 OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %8 0 Offset 0 @@ -21,9 +21,9 @@ OpDecorate %13 DescriptorSet 0 OpDecorate %13 Binding 10 OpDecorate %14 Block OpMemberDecorate %14 0 Offset 0 +OpDecorate %18 Location 0 +OpDecorate %18 Flat OpDecorate %21 Location 0 -OpDecorate %21 Flat -OpDecorate %24 Location 0 OpDecorate %53 NonUniform %2 = OpTypeVoid %3 = OpTypeInt 32 0 @@ -39,62 +39,61 @@ OpDecorate %53 NonUniform %14 = OpTypeStruct %4 %15 = OpTypePointer Uniform %14 %13 = OpVariable %15 Uniform -%17 = OpTypePointer Function %3 -%18 = OpConstantNull %3 -%22 = OpTypePointer Input %3 -%21 = OpVariable %22 Input -%25 = OpTypePointer Output %3 -%24 = OpVariable %25 Output -%27 = OpTypeFunction %2 -%28 = OpTypePointer Uniform %4 -%29 = OpConstant %3 0 -%31 = OpTypePointer StorageBuffer %6 -%33 = OpTypePointer Uniform %3 -%37 = OpTypePointer StorageBuffer %5 -%38 = OpTypePointer StorageBuffer %3 -%44 = OpTypeBool -%26 = OpFunction %2 None %27 -%19 = OpLabel -%16 = OpVariable %17 Function %18 -%23 = OpLoad %3 %21 -%20 = OpCompositeConstruct %8 %23 -%30 = OpAccessChain %28 %13 %29 -OpBranch %32 -%32 = OpLabel -%34 = OpAccessChain %33 %30 %29 -%35 = OpLoad %3 %34 -%36 = OpCompositeExtract %3 %20 0 -OpStore %16 %29 -%39 = OpAccessChain %38 %9 %29 %29 -%40 = OpLoad %3 %39 -%41 = OpLoad %3 %16 -%42 = OpIAdd %3 %41 %40 -OpStore %16 %42 -%43 = OpULessThan %44 %35 %7 +%19 = OpTypePointer Input %3 +%18 = OpVariable %19 Input +%22 = OpTypePointer Output %3 +%21 = OpVariable %22 Output +%24 = OpTypeFunction %2 +%25 = OpTypePointer Uniform %4 +%26 = OpConstant %3 0 +%28 = OpTypePointer StorageBuffer %6 +%30 = OpTypePointer Function %3 +%32 = OpTypePointer Uniform %3 +%36 = OpTypePointer StorageBuffer %5 +%37 = OpTypePointer StorageBuffer %3 +%43 = OpTypeBool +%45 = OpConstantNull %3 +%23 = OpFunction %2 None %24 +%16 = OpLabel +%29 = OpVariable %30 Function %26 +%20 = OpLoad %3 %18 +%17 = OpCompositeConstruct %8 %20 +%27 = OpAccessChain %25 %13 %26 +OpBranch %31 +%31 = OpLabel +%33 = OpAccessChain %32 %27 %26 +%34 = OpLoad %3 %33 +%35 = OpCompositeExtract %3 %17 0 +%38 = OpAccessChain %37 %9 %26 %26 +%39 = OpLoad %3 %38 +%40 = OpLoad %3 %29 +%41 = OpIAdd %3 %40 %39 +OpStore %29 %41 +%42 = OpULessThan %43 %34 %7 OpSelectionMerge %46 None -OpBranchConditional %43 %47 %46 +OpBranchConditional %42 %47 %46 %47 = OpLabel -%45 = OpAccessChain %38 %9 %35 %29 -%48 = OpLoad %3 %45 +%44 = OpAccessChain %37 %9 %34 %26 +%48 = OpLoad %3 %44 OpBranch %46 %46 = OpLabel -%49 = OpPhi %3 %18 %32 %48 %47 -%50 = OpLoad %3 %16 +%49 = OpPhi %3 %45 %31 %48 %47 +%50 = OpLoad %3 %29 %51 = OpIAdd %3 %50 %49 -OpStore %16 %51 -%52 = OpULessThan %44 %36 %7 +OpStore %29 %51 +%52 = OpULessThan %43 %35 %7 OpSelectionMerge %54 None OpBranchConditional %52 %55 %54 %55 = OpLabel -%53 = OpAccessChain %38 %9 %36 %29 +%53 = OpAccessChain %37 %9 %35 %26 %56 = OpLoad %3 %53 OpBranch %54 %54 = OpLabel -%57 = OpPhi %3 %18 %46 %56 %55 -%58 = OpLoad %3 %16 +%57 = OpPhi %3 %45 %46 %56 %55 +%58 = OpLoad %3 %29 %59 = OpIAdd %3 %58 %57 -OpStore %16 %59 -%60 = OpLoad %3 %16 -OpStore %24 %60 +OpStore %29 %59 +%60 = OpLoad %3 %29 +OpStore %21 %60 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/bitcast.spvasm b/tests/out/spv/bitcast.spvasm index f8b0c93279..43dfa8df33 100644 --- a/tests/out/spv/bitcast.spvasm +++ b/tests/out/spv/bitcast.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 76 +; Bound: 67 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %43 "main" -OpExecutionMode %43 LocalSize 1 1 1 +OpEntryPoint GLCompute %16 "main" +OpExecutionMode %16 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 2 @@ -20,85 +20,67 @@ OpExecutionMode %43 LocalSize 1 1 1 %11 = OpTypeVector %12 2 %13 = OpTypeVector %12 3 %14 = OpTypeVector %12 4 -%16 = OpTypePointer Function %3 -%17 = OpConstantNull %3 -%19 = OpTypePointer Function %5 -%20 = OpConstantNull %5 -%22 = OpTypePointer Function %6 -%23 = OpConstantNull %6 -%25 = OpTypePointer Function %7 -%26 = OpConstantNull %7 -%28 = OpTypePointer Function %9 -%29 = OpConstantNull %9 -%31 = OpTypePointer Function %10 -%32 = OpConstantNull %10 -%34 = OpTypePointer Function %11 -%35 = OpConstantNull %11 -%37 = OpTypePointer Function %13 -%38 = OpConstantNull %13 -%40 = OpTypePointer Function %14 -%41 = OpConstantNull %14 -%44 = OpTypeFunction %2 -%45 = OpConstant %4 0 -%46 = OpConstant %8 0 -%47 = OpConstant %12 0.0 -%43 = OpFunction %2 None %44 -%42 = OpLabel -%33 = OpVariable %34 Function %35 -%24 = OpVariable %25 Function %26 -%15 = OpVariable %16 Function %17 -%36 = OpVariable %37 Function %38 -%27 = OpVariable %28 Function %29 -%18 = OpVariable %19 Function %20 -%39 = OpVariable %40 Function %41 -%30 = OpVariable %31 Function %32 -%21 = OpVariable %22 Function %23 +%17 = OpTypeFunction %2 +%18 = OpConstant %4 0 +%19 = OpConstantComposite %3 %18 %18 +%20 = OpConstantComposite %5 %18 %18 %18 +%21 = OpConstantComposite %6 %18 %18 %18 %18 +%22 = OpConstant %8 0 +%23 = OpConstantComposite %7 %22 %22 +%24 = OpConstantComposite %9 %22 %22 %22 +%25 = OpConstantComposite %10 %22 %22 %22 %22 +%26 = OpConstant %12 0.0 +%27 = OpConstantComposite %11 %26 %26 +%28 = OpConstantComposite %13 %26 %26 %26 +%29 = OpConstantComposite %14 %26 %26 %26 %26 +%31 = OpTypePointer Function %3 +%33 = OpTypePointer Function %5 +%35 = OpTypePointer Function %6 +%37 = OpTypePointer Function %7 +%39 = OpTypePointer Function %9 +%41 = OpTypePointer Function %10 +%43 = OpTypePointer Function %11 +%45 = OpTypePointer Function %13 +%47 = OpTypePointer Function %14 +%16 = OpFunction %2 None %17 +%15 = OpLabel +%42 = OpVariable %43 Function %27 +%36 = OpVariable %37 Function %23 +%30 = OpVariable %31 Function %19 +%44 = OpVariable %45 Function %28 +%38 = OpVariable %39 Function %24 +%32 = OpVariable %33 Function %20 +%46 = OpVariable %47 Function %29 +%40 = OpVariable %41 Function %25 +%34 = OpVariable %35 Function %21 OpBranch %48 %48 = OpLabel -%49 = OpCompositeConstruct %3 %45 %45 -OpStore %15 %49 -%50 = OpCompositeConstruct %5 %45 %45 %45 -OpStore %18 %50 -%51 = OpCompositeConstruct %6 %45 %45 %45 %45 -OpStore %21 %51 -%52 = OpCompositeConstruct %7 %46 %46 -OpStore %24 %52 -%53 = OpCompositeConstruct %9 %46 %46 %46 -OpStore %27 %53 -%54 = OpCompositeConstruct %10 %46 %46 %46 %46 -OpStore %30 %54 -%55 = OpCompositeConstruct %11 %47 %47 -OpStore %33 %55 -%56 = OpCompositeConstruct %13 %47 %47 %47 -OpStore %36 %56 -%57 = OpCompositeConstruct %14 %47 %47 %47 %47 -OpStore %39 %57 -%58 = OpLoad %3 %15 -%59 = OpBitcast %7 %58 -OpStore %24 %59 -%60 = OpLoad %5 %18 -%61 = OpBitcast %9 %60 -OpStore %27 %61 -%62 = OpLoad %6 %21 -%63 = OpBitcast %10 %62 -OpStore %30 %63 -%64 = OpLoad %7 %24 -%65 = OpBitcast %3 %64 -OpStore %15 %65 -%66 = OpLoad %9 %27 -%67 = OpBitcast %5 %66 -OpStore %18 %67 -%68 = OpLoad %10 %30 -%69 = OpBitcast %6 %68 -OpStore %21 %69 -%70 = OpLoad %3 %15 -%71 = OpBitcast %11 %70 -OpStore %33 %71 -%72 = OpLoad %5 %18 -%73 = OpBitcast %13 %72 -OpStore %36 %73 -%74 = OpLoad %6 %21 -%75 = OpBitcast %14 %74 -OpStore %39 %75 +%49 = OpLoad %3 %30 +%50 = OpBitcast %7 %49 +OpStore %36 %50 +%51 = OpLoad %5 %32 +%52 = OpBitcast %9 %51 +OpStore %38 %52 +%53 = OpLoad %6 %34 +%54 = OpBitcast %10 %53 +OpStore %40 %54 +%55 = OpLoad %7 %36 +%56 = OpBitcast %3 %55 +OpStore %30 %56 +%57 = OpLoad %9 %38 +%58 = OpBitcast %5 %57 +OpStore %32 %58 +%59 = OpLoad %10 %40 +%60 = OpBitcast %6 %59 +OpStore %34 %60 +%61 = OpLoad %3 %30 +%62 = OpBitcast %11 %61 +OpStore %42 %62 +%63 = OpLoad %5 %32 +%64 = OpBitcast %13 %63 +OpStore %44 %64 +%65 = OpLoad %6 %34 +%66 = OpBitcast %14 %65 +OpStore %46 %66 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/bits.spvasm b/tests/out/spv/bits.spvasm index 674167359f..a77c4470a6 100644 --- a/tests/out/spv/bits.spvasm +++ b/tests/out/spv/bits.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 165 +; Bound: 155 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %45 "main" -OpExecutionMode %45 LocalSize 1 1 1 +OpEntryPoint GLCompute %15 "main" +OpExecutionMode %15 LocalSize 1 1 1 %2 = OpTypeVoid %3 = OpTypeInt 32 1 %4 = OpTypeVector %3 2 @@ -19,215 +19,195 @@ OpExecutionMode %45 LocalSize 1 1 1 %12 = OpTypeFloat 32 %11 = OpTypeVector %12 2 %13 = OpTypeVector %12 4 -%15 = OpTypePointer Function %3 -%16 = OpConstantNull %3 -%18 = OpTypePointer Function %4 -%19 = OpConstantNull %4 -%21 = OpTypePointer Function %5 -%22 = OpConstantNull %5 -%24 = OpTypePointer Function %6 -%25 = OpConstantNull %6 -%27 = OpTypePointer Function %7 -%28 = OpConstantNull %7 -%30 = OpTypePointer Function %8 -%31 = OpConstantNull %8 -%33 = OpTypePointer Function %9 -%34 = OpConstantNull %9 -%36 = OpTypePointer Function %10 -%37 = OpConstantNull %10 -%39 = OpTypePointer Function %11 -%40 = OpConstantNull %11 -%42 = OpTypePointer Function %13 -%43 = OpConstantNull %13 -%46 = OpTypeFunction %2 -%47 = OpConstant %3 0 -%48 = OpConstant %7 0 -%49 = OpConstant %12 0.0 -%50 = OpConstant %7 5 -%51 = OpConstant %7 10 -%45 = OpFunction %2 None %46 -%44 = OpLabel -%41 = OpVariable %42 Function %43 -%32 = OpVariable %33 Function %34 -%23 = OpVariable %24 Function %25 -%14 = OpVariable %15 Function %16 -%35 = OpVariable %36 Function %37 -%26 = OpVariable %27 Function %28 -%17 = OpVariable %18 Function %19 -%38 = OpVariable %39 Function %40 -%29 = OpVariable %30 Function %31 -%20 = OpVariable %21 Function %22 -OpBranch %52 -%52 = OpLabel -OpStore %14 %47 -%53 = OpCompositeConstruct %4 %47 %47 -OpStore %17 %53 -%54 = OpCompositeConstruct %5 %47 %47 %47 -OpStore %20 %54 -%55 = OpCompositeConstruct %6 %47 %47 %47 %47 -OpStore %23 %55 -OpStore %26 %48 -%56 = OpCompositeConstruct %8 %48 %48 -OpStore %29 %56 -%57 = OpCompositeConstruct %9 %48 %48 %48 -OpStore %32 %57 -%58 = OpCompositeConstruct %10 %48 %48 %48 %48 -OpStore %35 %58 -%59 = OpCompositeConstruct %11 %49 %49 -OpStore %38 %59 -%60 = OpCompositeConstruct %13 %49 %49 %49 %49 -OpStore %41 %60 -%61 = OpLoad %13 %41 -%62 = OpExtInst %7 %1 PackSnorm4x8 %61 -OpStore %26 %62 -%63 = OpLoad %13 %41 -%64 = OpExtInst %7 %1 PackUnorm4x8 %63 -OpStore %26 %64 -%65 = OpLoad %11 %38 -%66 = OpExtInst %7 %1 PackSnorm2x16 %65 -OpStore %26 %66 -%67 = OpLoad %11 %38 -%68 = OpExtInst %7 %1 PackUnorm2x16 %67 -OpStore %26 %68 -%69 = OpLoad %11 %38 -%70 = OpExtInst %7 %1 PackHalf2x16 %69 -OpStore %26 %70 -%71 = OpLoad %7 %26 -%72 = OpExtInst %13 %1 UnpackSnorm4x8 %71 -OpStore %41 %72 -%73 = OpLoad %7 %26 -%74 = OpExtInst %13 %1 UnpackUnorm4x8 %73 -OpStore %41 %74 -%75 = OpLoad %7 %26 -%76 = OpExtInst %11 %1 UnpackSnorm2x16 %75 -OpStore %38 %76 -%77 = OpLoad %7 %26 -%78 = OpExtInst %11 %1 UnpackUnorm2x16 %77 -OpStore %38 %78 -%79 = OpLoad %7 %26 -%80 = OpExtInst %11 %1 UnpackHalf2x16 %79 -OpStore %38 %80 -%81 = OpLoad %3 %14 -%82 = OpLoad %3 %14 -%83 = OpBitFieldInsert %3 %81 %82 %50 %51 -OpStore %14 %83 -%84 = OpLoad %4 %17 -%85 = OpLoad %4 %17 -%86 = OpBitFieldInsert %4 %84 %85 %50 %51 -OpStore %17 %86 -%87 = OpLoad %5 %20 -%88 = OpLoad %5 %20 -%89 = OpBitFieldInsert %5 %87 %88 %50 %51 -OpStore %20 %89 -%90 = OpLoad %6 %23 -%91 = OpLoad %6 %23 -%92 = OpBitFieldInsert %6 %90 %91 %50 %51 -OpStore %23 %92 -%93 = OpLoad %7 %26 -%94 = OpLoad %7 %26 -%95 = OpBitFieldInsert %7 %93 %94 %50 %51 -OpStore %26 %95 -%96 = OpLoad %8 %29 -%97 = OpLoad %8 %29 -%98 = OpBitFieldInsert %8 %96 %97 %50 %51 -OpStore %29 %98 -%99 = OpLoad %9 %32 -%100 = OpLoad %9 %32 -%101 = OpBitFieldInsert %9 %99 %100 %50 %51 -OpStore %32 %101 -%102 = OpLoad %10 %35 -%103 = OpLoad %10 %35 -%104 = OpBitFieldInsert %10 %102 %103 %50 %51 -OpStore %35 %104 -%105 = OpLoad %3 %14 -%106 = OpBitFieldSExtract %3 %105 %50 %51 -OpStore %14 %106 -%107 = OpLoad %4 %17 -%108 = OpBitFieldSExtract %4 %107 %50 %51 -OpStore %17 %108 -%109 = OpLoad %5 %20 -%110 = OpBitFieldSExtract %5 %109 %50 %51 -OpStore %20 %110 -%111 = OpLoad %6 %23 -%112 = OpBitFieldSExtract %6 %111 %50 %51 -OpStore %23 %112 -%113 = OpLoad %7 %26 -%114 = OpBitFieldUExtract %7 %113 %50 %51 -OpStore %26 %114 -%115 = OpLoad %8 %29 -%116 = OpBitFieldUExtract %8 %115 %50 %51 -OpStore %29 %116 -%117 = OpLoad %9 %32 -%118 = OpBitFieldUExtract %9 %117 %50 %51 -OpStore %32 %118 -%119 = OpLoad %10 %35 -%120 = OpBitFieldUExtract %10 %119 %50 %51 -OpStore %35 %120 -%121 = OpLoad %3 %14 -%122 = OpExtInst %3 %1 FindILsb %121 -OpStore %14 %122 -%123 = OpLoad %8 %29 -%124 = OpExtInst %8 %1 FindILsb %123 -OpStore %29 %124 -%125 = OpLoad %5 %20 -%126 = OpExtInst %5 %1 FindSMsb %125 -OpStore %20 %126 -%127 = OpLoad %9 %32 -%128 = OpExtInst %9 %1 FindUMsb %127 -OpStore %32 %128 -%129 = OpLoad %3 %14 -%130 = OpExtInst %3 %1 FindSMsb %129 -OpStore %14 %130 -%131 = OpLoad %7 %26 -%132 = OpExtInst %7 %1 FindUMsb %131 -OpStore %26 %132 -%133 = OpLoad %3 %14 -%134 = OpBitCount %3 %133 -OpStore %14 %134 -%135 = OpLoad %4 %17 -%136 = OpBitCount %4 %135 -OpStore %17 %136 -%137 = OpLoad %5 %20 -%138 = OpBitCount %5 %137 -OpStore %20 %138 -%139 = OpLoad %6 %23 -%140 = OpBitCount %6 %139 -OpStore %23 %140 -%141 = OpLoad %7 %26 -%142 = OpBitCount %7 %141 -OpStore %26 %142 -%143 = OpLoad %8 %29 -%144 = OpBitCount %8 %143 -OpStore %29 %144 -%145 = OpLoad %9 %32 -%146 = OpBitCount %9 %145 -OpStore %32 %146 -%147 = OpLoad %10 %35 -%148 = OpBitCount %10 %147 -OpStore %35 %148 -%149 = OpLoad %3 %14 -%150 = OpBitReverse %3 %149 -OpStore %14 %150 -%151 = OpLoad %4 %17 -%152 = OpBitReverse %4 %151 -OpStore %17 %152 -%153 = OpLoad %5 %20 -%154 = OpBitReverse %5 %153 -OpStore %20 %154 -%155 = OpLoad %6 %23 -%156 = OpBitReverse %6 %155 -OpStore %23 %156 -%157 = OpLoad %7 %26 -%158 = OpBitReverse %7 %157 -OpStore %26 %158 -%159 = OpLoad %8 %29 -%160 = OpBitReverse %8 %159 -OpStore %29 %160 -%161 = OpLoad %9 %32 -%162 = OpBitReverse %9 %161 -OpStore %32 %162 -%163 = OpLoad %10 %35 -%164 = OpBitReverse %10 %163 -OpStore %35 %164 +%16 = OpTypeFunction %2 +%17 = OpConstant %3 0 +%18 = OpConstantComposite %4 %17 %17 +%19 = OpConstantComposite %5 %17 %17 %17 +%20 = OpConstantComposite %6 %17 %17 %17 %17 +%21 = OpConstant %7 0 +%22 = OpConstantComposite %8 %21 %21 +%23 = OpConstantComposite %9 %21 %21 %21 +%24 = OpConstantComposite %10 %21 %21 %21 %21 +%25 = OpConstant %12 0.0 +%26 = OpConstantComposite %11 %25 %25 +%27 = OpConstantComposite %13 %25 %25 %25 %25 +%28 = OpConstant %7 5 +%29 = OpConstant %7 10 +%31 = OpTypePointer Function %3 +%33 = OpTypePointer Function %4 +%35 = OpTypePointer Function %5 +%37 = OpTypePointer Function %6 +%39 = OpTypePointer Function %7 +%41 = OpTypePointer Function %8 +%43 = OpTypePointer Function %9 +%45 = OpTypePointer Function %10 +%47 = OpTypePointer Function %11 +%49 = OpTypePointer Function %13 +%15 = OpFunction %2 None %16 +%14 = OpLabel +%48 = OpVariable %49 Function %27 +%42 = OpVariable %43 Function %23 +%36 = OpVariable %37 Function %20 +%30 = OpVariable %31 Function %17 +%44 = OpVariable %45 Function %24 +%38 = OpVariable %39 Function %21 +%32 = OpVariable %33 Function %18 +%46 = OpVariable %47 Function %26 +%40 = OpVariable %41 Function %22 +%34 = OpVariable %35 Function %19 +OpBranch %50 +%50 = OpLabel +%51 = OpLoad %13 %48 +%52 = OpExtInst %7 %1 PackSnorm4x8 %51 +OpStore %38 %52 +%53 = OpLoad %13 %48 +%54 = OpExtInst %7 %1 PackUnorm4x8 %53 +OpStore %38 %54 +%55 = OpLoad %11 %46 +%56 = OpExtInst %7 %1 PackSnorm2x16 %55 +OpStore %38 %56 +%57 = OpLoad %11 %46 +%58 = OpExtInst %7 %1 PackUnorm2x16 %57 +OpStore %38 %58 +%59 = OpLoad %11 %46 +%60 = OpExtInst %7 %1 PackHalf2x16 %59 +OpStore %38 %60 +%61 = OpLoad %7 %38 +%62 = OpExtInst %13 %1 UnpackSnorm4x8 %61 +OpStore %48 %62 +%63 = OpLoad %7 %38 +%64 = OpExtInst %13 %1 UnpackUnorm4x8 %63 +OpStore %48 %64 +%65 = OpLoad %7 %38 +%66 = OpExtInst %11 %1 UnpackSnorm2x16 %65 +OpStore %46 %66 +%67 = OpLoad %7 %38 +%68 = OpExtInst %11 %1 UnpackUnorm2x16 %67 +OpStore %46 %68 +%69 = OpLoad %7 %38 +%70 = OpExtInst %11 %1 UnpackHalf2x16 %69 +OpStore %46 %70 +%71 = OpLoad %3 %30 +%72 = OpLoad %3 %30 +%73 = OpBitFieldInsert %3 %71 %72 %28 %29 +OpStore %30 %73 +%74 = OpLoad %4 %32 +%75 = OpLoad %4 %32 +%76 = OpBitFieldInsert %4 %74 %75 %28 %29 +OpStore %32 %76 +%77 = OpLoad %5 %34 +%78 = OpLoad %5 %34 +%79 = OpBitFieldInsert %5 %77 %78 %28 %29 +OpStore %34 %79 +%80 = OpLoad %6 %36 +%81 = OpLoad %6 %36 +%82 = OpBitFieldInsert %6 %80 %81 %28 %29 +OpStore %36 %82 +%83 = OpLoad %7 %38 +%84 = OpLoad %7 %38 +%85 = OpBitFieldInsert %7 %83 %84 %28 %29 +OpStore %38 %85 +%86 = OpLoad %8 %40 +%87 = OpLoad %8 %40 +%88 = OpBitFieldInsert %8 %86 %87 %28 %29 +OpStore %40 %88 +%89 = OpLoad %9 %42 +%90 = OpLoad %9 %42 +%91 = OpBitFieldInsert %9 %89 %90 %28 %29 +OpStore %42 %91 +%92 = OpLoad %10 %44 +%93 = OpLoad %10 %44 +%94 = OpBitFieldInsert %10 %92 %93 %28 %29 +OpStore %44 %94 +%95 = OpLoad %3 %30 +%96 = OpBitFieldSExtract %3 %95 %28 %29 +OpStore %30 %96 +%97 = OpLoad %4 %32 +%98 = OpBitFieldSExtract %4 %97 %28 %29 +OpStore %32 %98 +%99 = OpLoad %5 %34 +%100 = OpBitFieldSExtract %5 %99 %28 %29 +OpStore %34 %100 +%101 = OpLoad %6 %36 +%102 = OpBitFieldSExtract %6 %101 %28 %29 +OpStore %36 %102 +%103 = OpLoad %7 %38 +%104 = OpBitFieldUExtract %7 %103 %28 %29 +OpStore %38 %104 +%105 = OpLoad %8 %40 +%106 = OpBitFieldUExtract %8 %105 %28 %29 +OpStore %40 %106 +%107 = OpLoad %9 %42 +%108 = OpBitFieldUExtract %9 %107 %28 %29 +OpStore %42 %108 +%109 = OpLoad %10 %44 +%110 = OpBitFieldUExtract %10 %109 %28 %29 +OpStore %44 %110 +%111 = OpLoad %3 %30 +%112 = OpExtInst %3 %1 FindILsb %111 +OpStore %30 %112 +%113 = OpLoad %8 %40 +%114 = OpExtInst %8 %1 FindILsb %113 +OpStore %40 %114 +%115 = OpLoad %5 %34 +%116 = OpExtInst %5 %1 FindSMsb %115 +OpStore %34 %116 +%117 = OpLoad %9 %42 +%118 = OpExtInst %9 %1 FindUMsb %117 +OpStore %42 %118 +%119 = OpLoad %3 %30 +%120 = OpExtInst %3 %1 FindSMsb %119 +OpStore %30 %120 +%121 = OpLoad %7 %38 +%122 = OpExtInst %7 %1 FindUMsb %121 +OpStore %38 %122 +%123 = OpLoad %3 %30 +%124 = OpBitCount %3 %123 +OpStore %30 %124 +%125 = OpLoad %4 %32 +%126 = OpBitCount %4 %125 +OpStore %32 %126 +%127 = OpLoad %5 %34 +%128 = OpBitCount %5 %127 +OpStore %34 %128 +%129 = OpLoad %6 %36 +%130 = OpBitCount %6 %129 +OpStore %36 %130 +%131 = OpLoad %7 %38 +%132 = OpBitCount %7 %131 +OpStore %38 %132 +%133 = OpLoad %8 %40 +%134 = OpBitCount %8 %133 +OpStore %40 %134 +%135 = OpLoad %9 %42 +%136 = OpBitCount %9 %135 +OpStore %42 %136 +%137 = OpLoad %10 %44 +%138 = OpBitCount %10 %137 +OpStore %44 %138 +%139 = OpLoad %3 %30 +%140 = OpBitReverse %3 %139 +OpStore %30 %140 +%141 = OpLoad %4 %32 +%142 = OpBitReverse %4 %141 +OpStore %32 %142 +%143 = OpLoad %5 %34 +%144 = OpBitReverse %5 %143 +OpStore %34 %144 +%145 = OpLoad %6 %36 +%146 = OpBitReverse %6 %145 +OpStore %36 %146 +%147 = OpLoad %7 %38 +%148 = OpBitReverse %7 %147 +OpStore %38 %148 +%149 = OpLoad %8 %40 +%150 = OpBitReverse %8 %149 +OpStore %40 %150 +%151 = OpLoad %9 %42 +%152 = OpBitReverse %9 %151 +OpStore %42 %152 +%153 = OpLoad %10 %44 +%154 = OpBitReverse %10 %153 +OpStore %44 %154 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/boids.spvasm b/tests/out/spv/boids.spvasm index f57d997238..0e48e0f559 100644 --- a/tests/out/spv/boids.spvasm +++ b/tests/out/spv/boids.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 209 +; Bound: 208 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %39 "main" %36 -OpExecutionMode %39 LocalSize 64 1 1 +OpEntryPoint GLCompute %23 "main" %20 +OpExecutionMode %23 LocalSize 64 1 1 OpMemberName %6 0 "pos" OpMemberName %6 1 "vel" OpName %6 "Particle" @@ -25,18 +25,18 @@ OpName %12 "NUM_PARTICLES" OpName %13 "params" OpName %16 "particlesSrc" OpName %18 "particlesDst" -OpName %19 "vPos" -OpName %22 "vVel" -OpName %23 "cMass" -OpName %24 "cVel" -OpName %25 "colVel" -OpName %26 "cMassCount" -OpName %29 "cVelCount" -OpName %30 "pos" -OpName %31 "vel" -OpName %32 "i" -OpName %36 "global_invocation_id" -OpName %39 "main" +OpName %20 "global_invocation_id" +OpName %23 "main" +OpName %36 "vPos" +OpName %39 "vVel" +OpName %41 "cMass" +OpName %42 "cVel" +OpName %43 "colVel" +OpName %44 "cMassCount" +OpName %46 "cVelCount" +OpName %47 "pos" +OpName %49 "vel" +OpName %51 "i" OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 8 OpMemberDecorate %7 0 Offset 0 @@ -58,7 +58,7 @@ OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 1 OpDecorate %18 DescriptorSet 0 OpDecorate %18 Binding 2 -OpDecorate %36 BuiltIn GlobalInvocationId +OpDecorate %20 BuiltIn GlobalInvocationId %2 = OpTypeVoid %3 = OpTypeInt 32 0 %5 = OpTypeFloat 32 @@ -76,264 +76,257 @@ OpDecorate %36 BuiltIn GlobalInvocationId %17 = OpTypePointer StorageBuffer %9 %16 = OpVariable %17 StorageBuffer %18 = OpVariable %17 StorageBuffer -%20 = OpTypePointer Function %4 -%21 = OpConstantNull %4 -%27 = OpTypePointer Function %11 -%28 = OpConstantNull %11 -%33 = OpTypePointer Function %3 -%34 = OpConstantNull %3 -%37 = OpTypePointer Input %10 -%36 = OpVariable %37 Input -%40 = OpTypeFunction %2 -%41 = OpTypePointer Uniform %7 -%42 = OpConstant %3 0 -%44 = OpConstant %5 0.0 -%45 = OpConstant %11 0 -%46 = OpConstant %11 1 -%47 = OpConstant %3 1 -%48 = OpConstant %5 0.1 -%49 = OpConstant %5 -1.0 -%50 = OpConstant %5 1.0 -%53 = OpTypeBool -%57 = OpTypePointer StorageBuffer %8 -%58 = OpTypePointer StorageBuffer %6 -%59 = OpTypePointer StorageBuffer %4 -%88 = OpTypePointer Uniform %5 -%102 = OpConstant %3 2 -%116 = OpConstant %3 3 -%151 = OpConstant %3 4 -%157 = OpConstant %3 5 -%163 = OpConstant %3 6 -%180 = OpTypePointer Function %5 -%39 = OpFunction %2 None %40 -%35 = OpLabel -%32 = OpVariable %33 Function %34 -%29 = OpVariable %27 Function %28 -%24 = OpVariable %20 Function %21 -%19 = OpVariable %20 Function %21 -%30 = OpVariable %20 Function %21 -%25 = OpVariable %20 Function %21 -%22 = OpVariable %20 Function %21 -%31 = OpVariable %20 Function %21 -%26 = OpVariable %27 Function %28 -%23 = OpVariable %20 Function %21 -%38 = OpLoad %10 %36 -%43 = OpAccessChain %41 %13 %42 -OpBranch %51 -%51 = OpLabel -%52 = OpCompositeExtract %3 %38 0 -%54 = OpUGreaterThanEqual %53 %52 %12 -OpSelectionMerge %55 None -OpBranchConditional %54 %56 %55 -%56 = OpLabel +%21 = OpTypePointer Input %10 +%20 = OpVariable %21 Input +%24 = OpTypeFunction %2 +%25 = OpTypePointer Uniform %7 +%26 = OpConstant %3 0 +%28 = OpConstant %5 0.0 +%29 = OpConstantComposite %4 %28 %28 +%30 = OpConstant %11 0 +%31 = OpConstant %11 1 +%32 = OpConstant %3 1 +%33 = OpConstant %5 0.1 +%34 = OpConstant %5 -1.0 +%35 = OpConstant %5 1.0 +%37 = OpTypePointer Function %4 +%38 = OpConstantNull %4 +%40 = OpConstantNull %4 +%45 = OpTypePointer Function %11 +%48 = OpConstantNull %4 +%50 = OpConstantNull %4 +%52 = OpTypePointer Function %3 +%55 = OpTypeBool +%59 = OpTypePointer StorageBuffer %8 +%60 = OpTypePointer StorageBuffer %6 +%61 = OpTypePointer StorageBuffer %4 +%87 = OpTypePointer Uniform %5 +%101 = OpConstant %3 2 +%115 = OpConstant %3 3 +%150 = OpConstant %3 4 +%156 = OpConstant %3 5 +%162 = OpConstant %3 6 +%179 = OpTypePointer Function %5 +%23 = OpFunction %2 None %24 +%19 = OpLabel +%51 = OpVariable %52 Function %26 +%46 = OpVariable %45 Function %30 +%42 = OpVariable %37 Function %29 +%36 = OpVariable %37 Function %38 +%47 = OpVariable %37 Function %48 +%43 = OpVariable %37 Function %29 +%39 = OpVariable %37 Function %40 +%49 = OpVariable %37 Function %50 +%44 = OpVariable %45 Function %30 +%41 = OpVariable %37 Function %29 +%22 = OpLoad %10 %20 +%27 = OpAccessChain %25 %13 %26 +OpBranch %53 +%53 = OpLabel +%54 = OpCompositeExtract %3 %22 0 +%56 = OpUGreaterThanEqual %55 %54 %12 +OpSelectionMerge %57 None +OpBranchConditional %56 %58 %57 +%58 = OpLabel OpReturn -%55 = OpLabel -%60 = OpAccessChain %59 %16 %42 %52 %42 -%61 = OpLoad %4 %60 -OpStore %19 %61 -%62 = OpAccessChain %59 %16 %42 %52 %47 +%57 = OpLabel +%62 = OpAccessChain %61 %16 %26 %54 %26 %63 = OpLoad %4 %62 -OpStore %22 %63 -%64 = OpCompositeConstruct %4 %44 %44 -OpStore %23 %64 -%65 = OpCompositeConstruct %4 %44 %44 -OpStore %24 %65 -%66 = OpCompositeConstruct %4 %44 %44 -OpStore %25 %66 -OpStore %26 %45 -OpStore %29 %45 -OpStore %32 %42 -OpBranch %67 -%67 = OpLabel -OpLoopMerge %68 %70 None -OpBranch %69 -%69 = OpLabel -%71 = OpLoad %3 %32 -%72 = OpUGreaterThanEqual %53 %71 %12 -OpSelectionMerge %73 None -OpBranchConditional %72 %74 %73 -%74 = OpLabel +OpStore %36 %63 +%64 = OpAccessChain %61 %16 %26 %54 %32 +%65 = OpLoad %4 %64 +OpStore %39 %65 +OpBranch %66 +%66 = OpLabel +OpLoopMerge %67 %69 None OpBranch %68 +%68 = OpLabel +%70 = OpLoad %3 %51 +%71 = OpUGreaterThanEqual %55 %70 %12 +OpSelectionMerge %72 None +OpBranchConditional %71 %73 %72 %73 = OpLabel -%75 = OpLoad %3 %32 -%76 = OpIEqual %53 %75 %52 -OpSelectionMerge %77 None -OpBranchConditional %76 %78 %77 -%78 = OpLabel -OpBranch %70 +OpBranch %67 +%72 = OpLabel +%74 = OpLoad %3 %51 +%75 = OpIEqual %55 %74 %54 +OpSelectionMerge %76 None +OpBranchConditional %75 %77 %76 %77 = OpLabel -%79 = OpLoad %3 %32 -%80 = OpAccessChain %59 %16 %42 %79 %42 -%81 = OpLoad %4 %80 -OpStore %30 %81 -%82 = OpLoad %3 %32 -%83 = OpAccessChain %59 %16 %42 %82 %47 -%84 = OpLoad %4 %83 -OpStore %31 %84 -%85 = OpLoad %4 %30 -%86 = OpLoad %4 %19 -%87 = OpExtInst %5 %1 Distance %85 %86 -%89 = OpAccessChain %88 %43 %47 -%90 = OpLoad %5 %89 -%91 = OpFOrdLessThan %53 %87 %90 -OpSelectionMerge %92 None -OpBranchConditional %91 %93 %92 -%93 = OpLabel -%94 = OpLoad %4 %23 -%95 = OpLoad %4 %30 -%96 = OpFAdd %4 %94 %95 -OpStore %23 %96 -%97 = OpLoad %11 %26 -%98 = OpIAdd %11 %97 %46 -OpStore %26 %98 -OpBranch %92 +OpBranch %69 +%76 = OpLabel +%78 = OpLoad %3 %51 +%79 = OpAccessChain %61 %16 %26 %78 %26 +%80 = OpLoad %4 %79 +OpStore %47 %80 +%81 = OpLoad %3 %51 +%82 = OpAccessChain %61 %16 %26 %81 %32 +%83 = OpLoad %4 %82 +OpStore %49 %83 +%84 = OpLoad %4 %47 +%85 = OpLoad %4 %36 +%86 = OpExtInst %5 %1 Distance %84 %85 +%88 = OpAccessChain %87 %27 %32 +%89 = OpLoad %5 %88 +%90 = OpFOrdLessThan %55 %86 %89 +OpSelectionMerge %91 None +OpBranchConditional %90 %92 %91 %92 = OpLabel -%99 = OpLoad %4 %30 -%100 = OpLoad %4 %19 -%101 = OpExtInst %5 %1 Distance %99 %100 -%103 = OpAccessChain %88 %43 %102 -%104 = OpLoad %5 %103 -%105 = OpFOrdLessThan %53 %101 %104 -OpSelectionMerge %106 None -OpBranchConditional %105 %107 %106 -%107 = OpLabel -%108 = OpLoad %4 %25 -%109 = OpLoad %4 %30 -%110 = OpLoad %4 %19 -%111 = OpFSub %4 %109 %110 -%112 = OpFSub %4 %108 %111 -OpStore %25 %112 -OpBranch %106 +%93 = OpLoad %4 %41 +%94 = OpLoad %4 %47 +%95 = OpFAdd %4 %93 %94 +OpStore %41 %95 +%96 = OpLoad %11 %44 +%97 = OpIAdd %11 %96 %31 +OpStore %44 %97 +OpBranch %91 +%91 = OpLabel +%98 = OpLoad %4 %47 +%99 = OpLoad %4 %36 +%100 = OpExtInst %5 %1 Distance %98 %99 +%102 = OpAccessChain %87 %27 %101 +%103 = OpLoad %5 %102 +%104 = OpFOrdLessThan %55 %100 %103 +OpSelectionMerge %105 None +OpBranchConditional %104 %106 %105 %106 = OpLabel -%113 = OpLoad %4 %30 -%114 = OpLoad %4 %19 -%115 = OpExtInst %5 %1 Distance %113 %114 -%117 = OpAccessChain %88 %43 %116 -%118 = OpLoad %5 %117 -%119 = OpFOrdLessThan %53 %115 %118 -OpSelectionMerge %120 None -OpBranchConditional %119 %121 %120 -%121 = OpLabel -%122 = OpLoad %4 %24 -%123 = OpLoad %4 %31 -%124 = OpFAdd %4 %122 %123 -OpStore %24 %124 -%125 = OpLoad %11 %29 -%126 = OpIAdd %11 %125 %46 -OpStore %29 %126 -OpBranch %120 +%107 = OpLoad %4 %43 +%108 = OpLoad %4 %47 +%109 = OpLoad %4 %36 +%110 = OpFSub %4 %108 %109 +%111 = OpFSub %4 %107 %110 +OpStore %43 %111 +OpBranch %105 +%105 = OpLabel +%112 = OpLoad %4 %47 +%113 = OpLoad %4 %36 +%114 = OpExtInst %5 %1 Distance %112 %113 +%116 = OpAccessChain %87 %27 %115 +%117 = OpLoad %5 %116 +%118 = OpFOrdLessThan %55 %114 %117 +OpSelectionMerge %119 None +OpBranchConditional %118 %120 %119 %120 = OpLabel -OpBranch %70 -%70 = OpLabel -%127 = OpLoad %3 %32 -%128 = OpIAdd %3 %127 %47 -OpStore %32 %128 -OpBranch %67 -%68 = OpLabel -%129 = OpLoad %11 %26 -%130 = OpSGreaterThan %53 %129 %45 -OpSelectionMerge %131 None -OpBranchConditional %130 %132 %131 -%132 = OpLabel -%133 = OpLoad %4 %23 -%134 = OpLoad %11 %26 -%135 = OpConvertSToF %5 %134 -%136 = OpCompositeConstruct %4 %135 %135 -%137 = OpFDiv %4 %133 %136 -%138 = OpLoad %4 %19 -%139 = OpFSub %4 %137 %138 -OpStore %23 %139 -OpBranch %131 +%121 = OpLoad %4 %42 +%122 = OpLoad %4 %49 +%123 = OpFAdd %4 %121 %122 +OpStore %42 %123 +%124 = OpLoad %11 %46 +%125 = OpIAdd %11 %124 %31 +OpStore %46 %125 +OpBranch %119 +%119 = OpLabel +OpBranch %69 +%69 = OpLabel +%126 = OpLoad %3 %51 +%127 = OpIAdd %3 %126 %32 +OpStore %51 %127 +OpBranch %66 +%67 = OpLabel +%128 = OpLoad %11 %44 +%129 = OpSGreaterThan %55 %128 %30 +OpSelectionMerge %130 None +OpBranchConditional %129 %131 %130 %131 = OpLabel -%140 = OpLoad %11 %29 -%141 = OpSGreaterThan %53 %140 %45 -OpSelectionMerge %142 None -OpBranchConditional %141 %143 %142 -%143 = OpLabel -%144 = OpLoad %4 %24 -%145 = OpLoad %11 %29 -%146 = OpConvertSToF %5 %145 -%147 = OpCompositeConstruct %4 %146 %146 -%148 = OpFDiv %4 %144 %147 -OpStore %24 %148 -OpBranch %142 +%132 = OpLoad %4 %41 +%133 = OpLoad %11 %44 +%134 = OpConvertSToF %5 %133 +%135 = OpCompositeConstruct %4 %134 %134 +%136 = OpFDiv %4 %132 %135 +%137 = OpLoad %4 %36 +%138 = OpFSub %4 %136 %137 +OpStore %41 %138 +OpBranch %130 +%130 = OpLabel +%139 = OpLoad %11 %46 +%140 = OpSGreaterThan %55 %139 %30 +OpSelectionMerge %141 None +OpBranchConditional %140 %142 %141 %142 = OpLabel -%149 = OpLoad %4 %22 -%150 = OpLoad %4 %23 -%152 = OpAccessChain %88 %43 %151 -%153 = OpLoad %5 %152 -%154 = OpVectorTimesScalar %4 %150 %153 -%155 = OpFAdd %4 %149 %154 -%156 = OpLoad %4 %25 -%158 = OpAccessChain %88 %43 %157 -%159 = OpLoad %5 %158 -%160 = OpVectorTimesScalar %4 %156 %159 -%161 = OpFAdd %4 %155 %160 -%162 = OpLoad %4 %24 -%164 = OpAccessChain %88 %43 %163 -%165 = OpLoad %5 %164 -%166 = OpVectorTimesScalar %4 %162 %165 -%167 = OpFAdd %4 %161 %166 -OpStore %22 %167 -%168 = OpLoad %4 %22 -%169 = OpExtInst %4 %1 Normalize %168 -%170 = OpLoad %4 %22 -%171 = OpExtInst %5 %1 Length %170 -%172 = OpExtInst %5 %1 FClamp %171 %44 %48 -%173 = OpVectorTimesScalar %4 %169 %172 -OpStore %22 %173 -%174 = OpLoad %4 %19 -%175 = OpLoad %4 %22 -%176 = OpAccessChain %88 %43 %42 -%177 = OpLoad %5 %176 -%178 = OpVectorTimesScalar %4 %175 %177 -%179 = OpFAdd %4 %174 %178 -OpStore %19 %179 -%181 = OpAccessChain %180 %19 %42 -%182 = OpLoad %5 %181 -%183 = OpFOrdLessThan %53 %182 %49 -OpSelectionMerge %184 None -OpBranchConditional %183 %185 %184 -%185 = OpLabel -%186 = OpAccessChain %180 %19 %42 -OpStore %186 %50 -OpBranch %184 +%143 = OpLoad %4 %42 +%144 = OpLoad %11 %46 +%145 = OpConvertSToF %5 %144 +%146 = OpCompositeConstruct %4 %145 %145 +%147 = OpFDiv %4 %143 %146 +OpStore %42 %147 +OpBranch %141 +%141 = OpLabel +%148 = OpLoad %4 %39 +%149 = OpLoad %4 %41 +%151 = OpAccessChain %87 %27 %150 +%152 = OpLoad %5 %151 +%153 = OpVectorTimesScalar %4 %149 %152 +%154 = OpFAdd %4 %148 %153 +%155 = OpLoad %4 %43 +%157 = OpAccessChain %87 %27 %156 +%158 = OpLoad %5 %157 +%159 = OpVectorTimesScalar %4 %155 %158 +%160 = OpFAdd %4 %154 %159 +%161 = OpLoad %4 %42 +%163 = OpAccessChain %87 %27 %162 +%164 = OpLoad %5 %163 +%165 = OpVectorTimesScalar %4 %161 %164 +%166 = OpFAdd %4 %160 %165 +OpStore %39 %166 +%167 = OpLoad %4 %39 +%168 = OpExtInst %4 %1 Normalize %167 +%169 = OpLoad %4 %39 +%170 = OpExtInst %5 %1 Length %169 +%171 = OpExtInst %5 %1 FClamp %170 %28 %33 +%172 = OpVectorTimesScalar %4 %168 %171 +OpStore %39 %172 +%173 = OpLoad %4 %36 +%174 = OpLoad %4 %39 +%175 = OpAccessChain %87 %27 %26 +%176 = OpLoad %5 %175 +%177 = OpVectorTimesScalar %4 %174 %176 +%178 = OpFAdd %4 %173 %177 +OpStore %36 %178 +%180 = OpAccessChain %179 %36 %26 +%181 = OpLoad %5 %180 +%182 = OpFOrdLessThan %55 %181 %34 +OpSelectionMerge %183 None +OpBranchConditional %182 %184 %183 %184 = OpLabel -%187 = OpAccessChain %180 %19 %42 -%188 = OpLoad %5 %187 -%189 = OpFOrdGreaterThan %53 %188 %50 -OpSelectionMerge %190 None -OpBranchConditional %189 %191 %190 -%191 = OpLabel -%192 = OpAccessChain %180 %19 %42 -OpStore %192 %49 -OpBranch %190 +%185 = OpAccessChain %179 %36 %26 +OpStore %185 %35 +OpBranch %183 +%183 = OpLabel +%186 = OpAccessChain %179 %36 %26 +%187 = OpLoad %5 %186 +%188 = OpFOrdGreaterThan %55 %187 %35 +OpSelectionMerge %189 None +OpBranchConditional %188 %190 %189 %190 = OpLabel -%193 = OpAccessChain %180 %19 %47 -%194 = OpLoad %5 %193 -%195 = OpFOrdLessThan %53 %194 %49 -OpSelectionMerge %196 None -OpBranchConditional %195 %197 %196 -%197 = OpLabel -%198 = OpAccessChain %180 %19 %47 -OpStore %198 %50 -OpBranch %196 +%191 = OpAccessChain %179 %36 %26 +OpStore %191 %34 +OpBranch %189 +%189 = OpLabel +%192 = OpAccessChain %179 %36 %32 +%193 = OpLoad %5 %192 +%194 = OpFOrdLessThan %55 %193 %34 +OpSelectionMerge %195 None +OpBranchConditional %194 %196 %195 %196 = OpLabel -%199 = OpAccessChain %180 %19 %47 -%200 = OpLoad %5 %199 -%201 = OpFOrdGreaterThan %53 %200 %50 -OpSelectionMerge %202 None -OpBranchConditional %201 %203 %202 -%203 = OpLabel -%204 = OpAccessChain %180 %19 %47 -OpStore %204 %49 -OpBranch %202 +%197 = OpAccessChain %179 %36 %32 +OpStore %197 %35 +OpBranch %195 +%195 = OpLabel +%198 = OpAccessChain %179 %36 %32 +%199 = OpLoad %5 %198 +%200 = OpFOrdGreaterThan %55 %199 %35 +OpSelectionMerge %201 None +OpBranchConditional %200 %202 %201 %202 = OpLabel -%205 = OpLoad %4 %19 -%206 = OpAccessChain %59 %18 %42 %52 %42 -OpStore %206 %205 -%207 = OpLoad %4 %22 -%208 = OpAccessChain %59 %18 %42 %52 %47 -OpStore %208 %207 +%203 = OpAccessChain %179 %36 %32 +OpStore %203 %34 +OpBranch %201 +%201 = OpLabel +%204 = OpLoad %4 %36 +%205 = OpAccessChain %61 %18 %26 %54 %26 +OpStore %205 %204 +%206 = OpLoad %4 %39 +%207 = OpAccessChain %61 %18 %26 %54 %32 +OpStore %207 %206 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/bounds-check-image-restrict.spvasm b/tests/out/spv/bounds-check-image-restrict.spvasm index 923aadecfb..038685a559 100644 --- a/tests/out/spv/bounds-check-image-restrict.spvasm +++ b/tests/out/spv/bounds-check-image-restrict.spvasm @@ -182,6 +182,7 @@ OpDecorate %267 Location 0 %283 = OpConstantNull %12 %284 = OpConstantNull %6 %285 = OpConstant %4 0.0 +%286 = OpConstantComposite %6 %285 %285 %285 %285 %48 = OpFunction %6 None %49 %46 = OpFunctionParameter %5 %47 = OpFunctionParameter %5 @@ -437,20 +438,19 @@ OpFunctionEnd %277 = OpLoad %18 %39 %278 = OpLoad %19 %41 %279 = OpLoad %20 %43 -OpBranch %286 -%286 = OpLabel -%287 = OpFunctionCall %6 %48 %280 %280 -%288 = OpFunctionCall %6 %63 %281 %280 -%289 = OpFunctionCall %6 %79 %281 %282 %280 -%290 = OpFunctionCall %6 %97 %281 %280 %280 -%291 = OpFunctionCall %6 %113 %283 %280 -%292 = OpFunctionCall %6 %128 %281 %280 -%293 = OpFunctionCall %2 %210 %280 %284 -%294 = OpFunctionCall %2 %220 %281 %284 -%295 = OpFunctionCall %2 %232 %281 %282 %284 -%296 = OpFunctionCall %2 %246 %281 %280 %284 -%297 = OpFunctionCall %2 %258 %283 %284 -%298 = OpCompositeConstruct %6 %285 %285 %285 %285 -OpStore %267 %298 +OpBranch %287 +%287 = OpLabel +%288 = OpFunctionCall %6 %48 %280 %280 +%289 = OpFunctionCall %6 %63 %281 %280 +%290 = OpFunctionCall %6 %79 %281 %282 %280 +%291 = OpFunctionCall %6 %97 %281 %280 %280 +%292 = OpFunctionCall %6 %113 %283 %280 +%293 = OpFunctionCall %6 %128 %281 %280 +%294 = OpFunctionCall %2 %210 %280 %284 +%295 = OpFunctionCall %2 %220 %281 %284 +%296 = OpFunctionCall %2 %232 %281 %282 %284 +%297 = OpFunctionCall %2 %246 %281 %280 %284 +%298 = OpFunctionCall %2 %258 %283 %284 +OpStore %267 %286 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/bounds-check-image-rzsw.spvasm b/tests/out/spv/bounds-check-image-rzsw.spvasm index 8a6cfc1b7d..a9eeb42047 100644 --- a/tests/out/spv/bounds-check-image-rzsw.spvasm +++ b/tests/out/spv/bounds-check-image-rzsw.spvasm @@ -171,6 +171,7 @@ OpDecorate %295 Location 0 %310 = OpConstant %10 0 %311 = OpConstantNull %12 %312 = OpConstant %4 0.0 +%313 = OpConstantComposite %6 %312 %312 %312 %312 %48 = OpFunction %6 None %49 %46 = OpFunctionParameter %5 %47 = OpFunctionParameter %5 @@ -519,20 +520,19 @@ OpFunctionEnd %305 = OpLoad %18 %39 %306 = OpLoad %19 %41 %307 = OpLoad %20 %43 -OpBranch %313 -%313 = OpLabel -%314 = OpFunctionCall %6 %48 %308 %308 -%315 = OpFunctionCall %6 %66 %309 %308 -%316 = OpFunctionCall %6 %85 %309 %310 %308 -%317 = OpFunctionCall %6 %106 %309 %308 %308 -%318 = OpFunctionCall %6 %124 %311 %308 -%319 = OpFunctionCall %6 %141 %309 %308 -%320 = OpFunctionCall %2 %233 %308 %53 -%321 = OpFunctionCall %2 %244 %309 %53 -%322 = OpFunctionCall %2 %257 %309 %310 %53 -%323 = OpFunctionCall %2 %272 %309 %308 %53 -%324 = OpFunctionCall %2 %285 %311 %53 -%325 = OpCompositeConstruct %6 %312 %312 %312 %312 -OpStore %295 %325 +OpBranch %314 +%314 = OpLabel +%315 = OpFunctionCall %6 %48 %308 %308 +%316 = OpFunctionCall %6 %66 %309 %308 +%317 = OpFunctionCall %6 %85 %309 %310 %308 +%318 = OpFunctionCall %6 %106 %309 %308 %308 +%319 = OpFunctionCall %6 %124 %311 %308 +%320 = OpFunctionCall %6 %141 %309 %308 +%321 = OpFunctionCall %2 %233 %308 %53 +%322 = OpFunctionCall %2 %244 %309 %53 +%323 = OpFunctionCall %2 %257 %309 %310 %53 +%324 = OpFunctionCall %2 %272 %309 %308 %53 +%325 = OpFunctionCall %2 %285 %311 %53 +OpStore %295 %313 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/break-if.spvasm b/tests/out/spv/break-if.spvasm index 9b17efb865..ea944130e7 100644 --- a/tests/out/spv/break-if.spvasm +++ b/tests/out/spv/break-if.spvasm @@ -1,19 +1,22 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 47 +; Bound: 50 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %45 "main" -OpExecutionMode %45 LocalSize 1 1 1 +OpEntryPoint GLCompute %48 "main" +OpExecutionMode %48 LocalSize 1 1 1 %2 = OpTypeVoid %3 = OpTypeBool %6 = OpTypeFunction %2 %7 = OpConstantTrue %3 -%14 = OpTypePointer Function %3 -%15 = OpConstantNull %3 -%20 = OpTypeFunction %2 %3 +%16 = OpTypeFunction %2 %3 +%18 = OpTypePointer Function %3 +%19 = OpConstantNull %3 +%21 = OpConstantNull %3 +%35 = OpConstantNull %3 +%37 = OpConstantNull %3 %5 = OpFunction %2 None %6 %4 = OpLabel OpBranch %8 @@ -29,57 +32,57 @@ OpBranchConditional %7 %10 %9 %10 = OpLabel OpReturn OpFunctionEnd -%19 = OpFunction %2 None %20 -%18 = OpFunctionParameter %3 -%17 = OpLabel -%13 = OpVariable %14 Function %15 -%16 = OpVariable %14 Function %15 -OpBranch %21 -%21 = OpLabel +%15 = OpFunction %2 None %16 +%14 = OpFunctionParameter %3 +%13 = OpLabel +%17 = OpVariable %18 Function %19 +%20 = OpVariable %18 Function %21 OpBranch %22 %22 = OpLabel -OpLoopMerge %23 %25 None -OpBranch %24 -%24 = OpLabel +OpBranch %23 +%23 = OpLabel +OpLoopMerge %24 %26 None OpBranch %25 %25 = OpLabel -OpStore %13 %18 -%26 = OpLoad %3 %13 -%27 = OpLogicalNotEqual %3 %18 %26 -OpStore %16 %27 -%28 = OpLoad %3 %16 -%29 = OpLogicalEqual %3 %18 %28 -OpBranchConditional %29 %23 %22 -%23 = OpLabel +OpBranch %26 +%26 = OpLabel +OpStore %17 %14 +%27 = OpLoad %3 %17 +%28 = OpLogicalNotEqual %3 %14 %27 +OpStore %20 %28 +%29 = OpLoad %3 %20 +%30 = OpLogicalEqual %3 %14 %29 +OpBranchConditional %30 %24 %23 +%24 = OpLabel OpReturn OpFunctionEnd -%34 = OpFunction %2 None %20 -%33 = OpFunctionParameter %3 -%32 = OpLabel -%30 = OpVariable %14 Function %15 -%31 = OpVariable %14 Function %15 -OpBranch %35 -%35 = OpLabel -OpBranch %36 -%36 = OpLabel -OpLoopMerge %37 %39 None +%33 = OpFunction %2 None %16 +%32 = OpFunctionParameter %3 +%31 = OpLabel +%34 = OpVariable %18 Function %35 +%36 = OpVariable %18 Function %37 OpBranch %38 %38 = OpLabel -OpStore %30 %33 -%40 = OpLoad %3 %30 -%41 = OpLogicalNotEqual %3 %33 %40 -OpStore %31 %41 OpBranch %39 %39 = OpLabel -%42 = OpLoad %3 %31 -%43 = OpLogicalEqual %3 %33 %42 -OpBranchConditional %43 %37 %36 -%37 = OpLabel +OpLoopMerge %40 %42 None +OpBranch %41 +%41 = OpLabel +OpStore %34 %32 +%43 = OpLoad %3 %34 +%44 = OpLogicalNotEqual %3 %32 %43 +OpStore %36 %44 +OpBranch %42 +%42 = OpLabel +%45 = OpLoad %3 %36 +%46 = OpLogicalEqual %3 %32 %45 +OpBranchConditional %46 %40 %39 +%40 = OpLabel OpReturn OpFunctionEnd -%45 = OpFunction %2 None %6 -%44 = OpLabel -OpBranch %46 -%46 = OpLabel +%48 = OpFunction %2 None %6 +%47 = OpLabel +OpBranch %49 +%49 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/collatz.spvasm b/tests/out/spv/collatz.spvasm index 310bc5c1ef..5c77a52269 100644 --- a/tests/out/spv/collatz.spvasm +++ b/tests/out/spv/collatz.spvasm @@ -11,10 +11,10 @@ OpExecutionMode %51 LocalSize 1 1 1 OpMemberName %5 0 "data" OpName %5 "PrimeIndices" OpName %7 "v_indices" -OpName %9 "n" -OpName %12 "i" -OpName %14 "n_base" -OpName %15 "collatz_iterations" +OpName %10 "n_base" +OpName %11 "collatz_iterations" +OpName %17 "n" +OpName %20 "i" OpName %48 "global_id" OpName %51 "main" OpDecorate %4 ArrayStride 4 @@ -30,35 +30,34 @@ OpDecorate %48 BuiltIn GlobalInvocationId %6 = OpTypeVector %3 3 %8 = OpTypePointer StorageBuffer %5 %7 = OpVariable %8 StorageBuffer -%10 = OpTypePointer Function %3 -%11 = OpConstantNull %3 -%16 = OpTypeFunction %3 %3 -%17 = OpConstant %3 0 -%18 = OpConstant %3 1 -%19 = OpConstant %3 2 -%20 = OpConstant %3 3 +%12 = OpTypeFunction %3 %3 +%13 = OpConstant %3 0 +%14 = OpConstant %3 1 +%15 = OpConstant %3 2 +%16 = OpConstant %3 3 +%18 = OpTypePointer Function %3 +%19 = OpConstantNull %3 %27 = OpTypeBool %49 = OpTypePointer Input %6 %48 = OpVariable %49 Input %52 = OpTypeFunction %2 %54 = OpTypePointer StorageBuffer %4 %56 = OpTypePointer StorageBuffer %3 -%15 = OpFunction %3 None %16 -%14 = OpFunctionParameter %3 -%13 = OpLabel -%9 = OpVariable %10 Function %11 -%12 = OpVariable %10 Function %11 +%11 = OpFunction %3 None %12 +%10 = OpFunctionParameter %3 +%9 = OpLabel +%17 = OpVariable %18 Function %19 +%20 = OpVariable %18 Function %13 OpBranch %21 %21 = OpLabel -OpStore %9 %14 -OpStore %12 %17 +OpStore %17 %10 OpBranch %22 %22 = OpLabel OpLoopMerge %23 %25 None OpBranch %24 %24 = OpLabel -%26 = OpLoad %3 %9 -%28 = OpUGreaterThan %27 %26 %18 +%26 = OpLoad %3 %17 +%28 = OpUGreaterThan %27 %26 %14 OpSelectionMerge %29 None OpBranchConditional %28 %29 %30 %30 = OpLabel @@ -66,33 +65,33 @@ OpBranch %23 %29 = OpLabel OpBranch %31 %31 = OpLabel -%33 = OpLoad %3 %9 -%34 = OpUMod %3 %33 %19 -%35 = OpIEqual %27 %34 %17 +%33 = OpLoad %3 %17 +%34 = OpUMod %3 %33 %15 +%35 = OpIEqual %27 %34 %13 OpSelectionMerge %36 None OpBranchConditional %35 %37 %38 %37 = OpLabel -%39 = OpLoad %3 %9 -%40 = OpUDiv %3 %39 %19 -OpStore %9 %40 +%39 = OpLoad %3 %17 +%40 = OpUDiv %3 %39 %15 +OpStore %17 %40 OpBranch %36 %38 = OpLabel -%41 = OpLoad %3 %9 -%42 = OpIMul %3 %20 %41 -%43 = OpIAdd %3 %42 %18 -OpStore %9 %43 +%41 = OpLoad %3 %17 +%42 = OpIMul %3 %16 %41 +%43 = OpIAdd %3 %42 %14 +OpStore %17 %43 OpBranch %36 %36 = OpLabel -%44 = OpLoad %3 %12 -%45 = OpIAdd %3 %44 %18 -OpStore %12 %45 +%44 = OpLoad %3 %20 +%45 = OpIAdd %3 %44 %14 +OpStore %20 %45 OpBranch %32 %32 = OpLabel OpBranch %25 %25 = OpLabel OpBranch %22 %23 = OpLabel -%46 = OpLoad %3 %12 +%46 = OpLoad %3 %20 OpReturnValue %46 OpFunctionEnd %51 = OpFunction %2 None %52 @@ -102,10 +101,10 @@ OpBranch %53 %53 = OpLabel %55 = OpCompositeExtract %3 %50 0 %57 = OpCompositeExtract %3 %50 0 -%58 = OpAccessChain %56 %7 %17 %57 +%58 = OpAccessChain %56 %7 %13 %57 %59 = OpLoad %3 %58 -%60 = OpFunctionCall %3 %15 %59 -%61 = OpAccessChain %56 %7 %17 %55 +%60 = OpFunctionCall %3 %11 %59 +%61 = OpAccessChain %56 %7 %13 %55 OpStore %61 %60 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/constructors.spvasm b/tests/out/spv/constructors.spvasm index 4670ab39d3..e8e2e25957 100644 --- a/tests/out/spv/constructors.spvasm +++ b/tests/out/spv/constructors.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 73 +; Bound: 70 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %46 "main" -OpExecutionMode %46 LocalSize 1 1 1 +OpEntryPoint GLCompute %44 "main" +OpExecutionMode %44 LocalSize 1 1 1 OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpDecorate %10 ArrayStride 16 @@ -53,35 +53,32 @@ OpDecorate %17 ArrayStride 4 %40 = OpConstant %5 2 %41 = OpConstant %5 3 %42 = OpConstantComposite %17 %38 %39 %40 %41 -%44 = OpTypePointer Function %6 -%47 = OpTypeFunction %2 -%48 = OpConstant %12 0 -%49 = OpConstantNull %20 -%46 = OpFunction %2 None %47 -%45 = OpLabel -%43 = OpVariable %44 Function %37 -OpBranch %50 -%50 = OpLabel -%51 = OpCompositeConstruct %3 %22 %22 %22 %22 -%52 = OpCompositeConstruct %6 %51 %39 -OpStore %43 %52 -%53 = OpCompositeConstruct %9 %22 %21 -%54 = OpCompositeConstruct %9 %21 %22 -%55 = OpCompositeConstruct %8 %53 %54 -%56 = OpCompositeConstruct %3 %22 %21 %21 %21 -%57 = OpCompositeConstruct %3 %21 %22 %21 %21 -%58 = OpCompositeConstruct %3 %21 %21 %22 %21 -%59 = OpCompositeConstruct %3 %21 %21 %21 %22 -%60 = OpCompositeConstruct %19 %56 %57 %58 %59 -%61 = OpCompositeConstruct %14 %48 %48 -%62 = OpCompositeConstruct %9 %21 %21 -%63 = OpCompositeConstruct %9 %21 %21 -%64 = OpCompositeConstruct %8 %62 %63 -%65 = OpCompositeConstruct %17 %38 %39 %40 %41 -%67 = OpCompositeConstruct %14 %48 %48 -%68 = OpCompositeConstruct %7 %21 %21 %21 -%69 = OpCompositeConstruct %7 %21 %21 %21 -%70 = OpCompositeConstruct %20 %68 %69 -%72 = OpCopyObject %20 %49 +%45 = OpTypeFunction %2 +%46 = OpConstantComposite %3 %22 %22 %22 %22 +%47 = OpConstantComposite %6 %46 %39 +%48 = OpConstantComposite %9 %22 %21 +%49 = OpConstantComposite %8 %48 %26 +%50 = OpConstantComposite %3 %22 %21 %21 %21 +%51 = OpConstantComposite %3 %21 %22 %21 %21 +%52 = OpConstantComposite %3 %21 %21 %22 %21 +%53 = OpConstantComposite %3 %21 %21 %21 %22 +%54 = OpConstantComposite %19 %50 %51 %52 %53 +%55 = OpConstant %12 0 +%56 = OpConstantComposite %14 %55 %55 +%57 = OpConstantComposite %9 %21 %21 +%58 = OpConstantComposite %8 %57 %57 +%59 = OpConstantComposite %14 %55 %55 +%60 = OpConstantComposite %7 %21 %21 %21 +%61 = OpConstantComposite %20 %60 %60 +%62 = OpConstantNull %20 +%64 = OpTypePointer Function %6 +%65 = OpConstantNull %6 +%44 = OpFunction %2 None %45 +%43 = OpLabel +%63 = OpVariable %64 Function %65 +OpBranch %66 +%66 = OpLabel +OpStore %63 %47 +%69 = OpCopyObject %20 %62 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/control-flow.spvasm b/tests/out/spv/control-flow.spvasm index eb2f3b62ec..2fc9337cfe 100644 --- a/tests/out/spv/control-flow.spvasm +++ b/tests/out/spv/control-flow.spvasm @@ -5,9 +5,9 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %39 "main" %36 -OpExecutionMode %39 LocalSize 1 1 1 -OpDecorate %36 BuiltIn GlobalInvocationId +OpEntryPoint GLCompute %36 "main" %33 +OpExecutionMode %36 LocalSize 1 1 1 +OpDecorate %33 BuiltIn GlobalInvocationId %2 = OpTypeVoid %4 = OpTypeInt 32 0 %3 = OpTypeVector %4 3 @@ -15,15 +15,15 @@ OpDecorate %36 BuiltIn GlobalInvocationId %9 = OpTypeFunction %2 %5 %15 = OpTypeFunction %2 %16 = OpConstant %5 0 -%33 = OpTypePointer Function %5 -%34 = OpConstantNull %5 -%37 = OpTypePointer Input %3 -%36 = OpVariable %37 Input -%40 = OpConstant %5 1 -%41 = OpConstant %5 2 -%42 = OpConstant %5 3 -%43 = OpConstant %5 4 -%44 = OpConstant %4 0 +%34 = OpTypePointer Input %3 +%33 = OpVariable %34 Input +%37 = OpConstant %5 1 +%38 = OpConstant %5 2 +%39 = OpConstant %5 3 +%40 = OpConstant %5 4 +%41 = OpConstant %4 0 +%43 = OpTypePointer Function %5 +%44 = OpConstantNull %5 %46 = OpConstant %4 2 %47 = OpConstant %4 1 %48 = OpConstant %4 72 @@ -76,62 +76,62 @@ OpBranch %25 %26 = OpLabel OpReturn OpFunctionEnd -%39 = OpFunction %2 None %15 -%35 = OpLabel -%32 = OpVariable %33 Function %34 -%38 = OpLoad %3 %36 +%36 = OpFunction %2 None %15 +%32 = OpLabel +%42 = OpVariable %43 Function %44 +%35 = OpLoad %3 %33 OpBranch %45 %45 = OpLabel OpControlBarrier %46 %47 %48 OpControlBarrier %46 %46 %49 OpSelectionMerge %50 None -OpSwitch %40 %51 +OpSwitch %37 %51 %51 = OpLabel -OpStore %32 %40 +OpStore %42 %37 OpBranch %50 %50 = OpLabel -%52 = OpLoad %5 %32 +%52 = OpLoad %5 %42 OpSelectionMerge %53 None OpSwitch %52 %58 1 %54 2 %55 3 %56 4 %56 5 %57 6 %58 %54 = OpLabel -OpStore %32 %16 +OpStore %42 %16 OpBranch %53 %55 = OpLabel -OpStore %32 %40 +OpStore %42 %37 OpBranch %53 %56 = OpLabel -OpStore %32 %41 +OpStore %42 %38 OpBranch %53 %57 = OpLabel -OpStore %32 %42 +OpStore %42 %39 OpBranch %53 %58 = OpLabel -OpStore %32 %43 +OpStore %42 %40 OpBranch %53 %53 = OpLabel OpSelectionMerge %59 None -OpSwitch %44 %61 0 %60 +OpSwitch %41 %61 0 %60 %60 = OpLabel OpBranch %59 %61 = OpLabel OpBranch %59 %59 = OpLabel -%62 = OpLoad %5 %32 +%62 = OpLoad %5 %42 OpSelectionMerge %63 None OpSwitch %62 %68 1 %64 2 %65 3 %66 4 %67 %64 = OpLabel -OpStore %32 %16 +OpStore %42 %16 OpBranch %63 %65 = OpLabel -OpStore %32 %40 +OpStore %42 %37 OpReturn %66 = OpLabel -OpStore %32 %41 +OpStore %42 %38 OpReturn %67 = OpLabel OpReturn %68 = OpLabel -OpStore %32 %42 +OpStore %42 %39 OpReturn %63 = OpLabel OpReturn diff --git a/tests/out/spv/debug-symbol-simple.spvasm b/tests/out/spv/debug-symbol-simple.spvasm index 8f64c324ce..b2fd1f2607 100644 --- a/tests/out/spv/debug-symbol-simple.spvasm +++ b/tests/out/spv/debug-symbol-simple.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 95 +; Bound: 94 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %24 "vs_main" %15 %18 %20 %22 -OpEntryPoint Fragment %57 "fs_main" %51 %54 %56 -OpExecutionMode %57 OriginUpperLeft +OpEntryPoint Vertex %21 "vs_main" %12 %15 %17 %19 +OpEntryPoint Fragment %49 "fs_main" %43 %46 %48 +OpExecutionMode %49 OriginUpperLeft %3 = OpString "debug-symbol-simple.wgsl" OpSource Unknown 0 %3 "struct VertexInput { @location(0) position: vec3, @@ -48,29 +48,29 @@ OpName %6 "VertexInput" OpMemberName %8 0 "clip_position" OpMemberName %8 1 "color" OpName %8 "VertexOutput" -OpName %10 "out" -OpName %15 "position" -OpName %18 "color" -OpName %20 "clip_position" -OpName %22 "color" -OpName %24 "vs_main" -OpName %41 "color" -OpName %43 "i" -OpName %46 "ii" -OpName %51 "clip_position" -OpName %54 "color" -OpName %57 "fs_main" +OpName %12 "position" +OpName %15 "color" +OpName %17 "clip_position" +OpName %19 "color" +OpName %21 "vs_main" +OpName %24 "out" +OpName %43 "clip_position" +OpName %46 "color" +OpName %49 "fs_main" +OpName %55 "color" +OpName %57 "i" +OpName %59 "ii" OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %8 0 Offset 0 OpMemberDecorate %8 1 Offset 16 -OpDecorate %15 Location 0 -OpDecorate %18 Location 1 -OpDecorate %20 BuiltIn Position -OpDecorate %22 Location 0 -OpDecorate %51 BuiltIn FragCoord -OpDecorate %54 Location 0 -OpDecorate %56 Location 0 +OpDecorate %12 Location 0 +OpDecorate %15 Location 1 +OpDecorate %17 BuiltIn Position +OpDecorate %19 Location 0 +OpDecorate %43 BuiltIn FragCoord +OpDecorate %46 Location 0 +OpDecorate %48 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 3 @@ -78,140 +78,137 @@ OpDecorate %56 Location 0 %7 = OpTypeVector %5 4 %8 = OpTypeStruct %7 %4 %9 = OpTypeInt 32 1 -%11 = OpTypePointer Function %8 -%12 = OpConstantNull %8 -%16 = OpTypePointer Input %4 -%15 = OpVariable %16 Input -%18 = OpVariable %16 Input -%21 = OpTypePointer Output %7 -%20 = OpVariable %21 Output -%23 = OpTypePointer Output %4 -%22 = OpVariable %23 Output -%25 = OpTypeFunction %2 -%26 = OpConstant %5 1.0 +%13 = OpTypePointer Input %4 +%12 = OpVariable %13 Input +%15 = OpVariable %13 Input +%18 = OpTypePointer Output %7 +%17 = OpVariable %18 Output +%20 = OpTypePointer Output %4 +%19 = OpVariable %20 Output +%22 = OpTypeFunction %2 +%23 = OpConstant %5 1.0 +%25 = OpTypePointer Function %8 +%26 = OpConstantNull %8 %28 = OpTypePointer Function %4 %31 = OpTypeInt 32 0 %30 = OpConstant %31 1 %33 = OpTypePointer Function %7 %36 = OpConstant %31 0 -%42 = OpConstantNull %4 -%44 = OpTypePointer Function %9 -%45 = OpConstantNull %9 -%47 = OpTypePointer Function %5 -%48 = OpConstantNull %5 -%52 = OpTypePointer Input %7 -%51 = OpVariable %52 Input -%54 = OpVariable %16 Input -%56 = OpVariable %21 Output -%58 = OpConstant %9 0 -%59 = OpConstant %9 10 -%60 = OpConstant %5 0.001 -%61 = OpConstant %5 0.002 -%62 = OpConstant %9 1 -%70 = OpTypeBool -%78 = OpTypePointer Function %5 -%24 = OpFunction %2 None %25 -%13 = OpLabel -%10 = OpVariable %11 Function %12 -%17 = OpLoad %4 %15 -%19 = OpLoad %4 %18 -%14 = OpCompositeConstruct %6 %17 %19 +%44 = OpTypePointer Input %7 +%43 = OpVariable %44 Input +%46 = OpVariable %13 Input +%48 = OpVariable %18 Output +%50 = OpConstant %9 0 +%51 = OpConstant %9 10 +%52 = OpConstant %5 0.001 +%53 = OpConstant %5 0.002 +%54 = OpConstant %9 1 +%56 = OpConstantNull %4 +%58 = OpTypePointer Function %9 +%60 = OpTypePointer Function %5 +%61 = OpConstantNull %5 +%69 = OpTypeBool +%77 = OpTypePointer Function %5 +%21 = OpFunction %2 None %22 +%10 = OpLabel +%24 = OpVariable %25 Function %26 +%14 = OpLoad %4 %12 +%16 = OpLoad %4 %15 +%11 = OpCompositeConstruct %6 %14 %16 OpBranch %27 %27 = OpLabel OpLine %3 16 5 -%29 = OpCompositeExtract %4 %14 1 +%29 = OpCompositeExtract %4 %11 1 OpLine %3 16 5 -%32 = OpAccessChain %28 %10 %30 +%32 = OpAccessChain %28 %24 %30 OpStore %32 %29 OpLine %3 17 5 -%34 = OpCompositeExtract %4 %14 0 +%34 = OpCompositeExtract %4 %11 0 OpLine %3 17 25 -%35 = OpCompositeConstruct %7 %34 %26 +%35 = OpCompositeConstruct %7 %34 %23 OpLine %3 17 5 -%37 = OpAccessChain %33 %10 %36 +%37 = OpAccessChain %33 %24 %36 OpStore %37 %35 OpLine %3 1 1 -%38 = OpLoad %8 %10 +%38 = OpLoad %8 %24 %39 = OpCompositeExtract %7 %38 0 -OpStore %20 %39 +OpStore %17 %39 %40 = OpCompositeExtract %4 %38 1 -OpStore %22 %40 +OpStore %19 %40 OpReturn OpFunctionEnd -%57 = OpFunction %2 None %25 -%49 = OpLabel -%41 = OpVariable %28 Function %42 -%43 = OpVariable %44 Function %45 -%46 = OpVariable %47 Function %48 -%53 = OpLoad %7 %51 -%55 = OpLoad %4 %54 -%50 = OpCompositeConstruct %8 %53 %55 -OpBranch %63 -%63 = OpLabel +%49 = OpFunction %2 None %22 +%41 = OpLabel +%55 = OpVariable %28 Function %56 +%57 = OpVariable %58 Function %50 +%59 = OpVariable %60 Function %61 +%45 = OpLoad %7 %43 +%47 = OpLoad %4 %46 +%42 = OpCompositeConstruct %8 %45 %47 +OpBranch %62 +%62 = OpLabel OpLine %3 25 17 -%64 = OpCompositeExtract %4 %50 1 +%63 = OpCompositeExtract %4 %42 1 OpLine %3 25 5 -OpStore %41 %64 -OpLine %3 26 10 -OpStore %43 %58 -OpBranch %65 -%65 = OpLabel +OpStore %55 %63 +OpBranch %64 +%64 = OpLabel OpLine %3 26 5 -OpLoopMerge %66 %68 None -OpBranch %67 -%67 = OpLabel +OpLoopMerge %65 %67 None +OpBranch %66 +%66 = OpLabel OpLine %3 1 1 -%69 = OpLoad %9 %43 +%68 = OpLoad %9 %57 OpLine %3 26 21 -%71 = OpSLessThan %70 %69 %59 +%70 = OpSLessThan %69 %68 %51 OpLine %3 26 20 -OpSelectionMerge %72 None -OpBranchConditional %71 %72 %73 -%73 = OpLabel -OpBranch %66 +OpSelectionMerge %71 None +OpBranchConditional %70 %71 %72 %72 = OpLabel -OpBranch %74 -%74 = OpLabel +OpBranch %65 +%71 = OpLabel +OpBranch %73 +%73 = OpLabel OpLine %3 27 18 -%76 = OpLoad %9 %43 -%77 = OpConvertSToF %5 %76 +%75 = OpLoad %9 %57 +%76 = OpConvertSToF %5 %75 OpLine %3 27 9 -OpStore %46 %77 +OpStore %59 %76 OpLine %3 28 9 -%79 = OpLoad %5 %46 +%78 = OpLoad %5 %59 OpLine %3 28 9 -%80 = OpFMul %5 %79 %60 -%81 = OpAccessChain %78 %41 %36 -%82 = OpLoad %5 %81 -%83 = OpFAdd %5 %82 %80 +%79 = OpFMul %5 %78 %52 +%80 = OpAccessChain %77 %55 %36 +%81 = OpLoad %5 %80 +%82 = OpFAdd %5 %81 %79 OpLine %3 28 9 -%84 = OpAccessChain %78 %41 %36 -OpStore %84 %83 +%83 = OpAccessChain %77 %55 %36 +OpStore %83 %82 OpLine %3 29 9 -%85 = OpLoad %5 %46 +%84 = OpLoad %5 %59 OpLine %3 29 9 -%86 = OpFMul %5 %85 %61 -%87 = OpAccessChain %78 %41 %30 -%88 = OpLoad %5 %87 -%89 = OpFAdd %5 %88 %86 +%85 = OpFMul %5 %84 %53 +%86 = OpAccessChain %77 %55 %30 +%87 = OpLoad %5 %86 +%88 = OpFAdd %5 %87 %85 OpLine %3 29 9 -%90 = OpAccessChain %78 %41 %30 -OpStore %90 %89 -OpBranch %75 -%75 = OpLabel -OpBranch %68 -%68 = OpLabel +%89 = OpAccessChain %77 %55 %30 +OpStore %89 %88 +OpBranch %74 +%74 = OpLabel +OpBranch %67 +%67 = OpLabel OpLine %3 26 29 -%91 = OpLoad %9 %43 -%92 = OpIAdd %9 %91 %62 +%90 = OpLoad %9 %57 +%91 = OpIAdd %9 %90 %54 OpLine %3 26 29 -OpStore %43 %92 -OpBranch %65 -%66 = OpLabel +OpStore %57 %91 +OpBranch %64 +%65 = OpLabel OpLine %3 1 1 -%93 = OpLoad %4 %41 +%92 = OpLoad %4 %55 OpLine %3 32 12 -%94 = OpCompositeConstruct %7 %93 %26 -OpStore %56 %94 +%93 = OpCompositeConstruct %7 %92 %23 +OpStore %48 %93 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/debug-symbol-terrain.spvasm b/tests/out/spv/debug-symbol-terrain.spvasm index 044f1f169a..3f53036adc 100644 --- a/tests/out/spv/debug-symbol-terrain.spvasm +++ b/tests/out/spv/debug-symbol-terrain.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 641 +; Bound: 638 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %344 "gen_terrain_compute" %341 -OpEntryPoint Vertex %414 "gen_terrain_vertex" %405 %408 %410 %412 -OpEntryPoint Fragment %464 "gen_terrain_fragment" %454 %456 %459 %462 %463 -OpEntryPoint Vertex %555 "vs_main" %546 %549 %551 %552 %554 -OpEntryPoint Fragment %581 "fs_main" %574 %576 %578 %580 -OpExecutionMode %344 LocalSize 64 1 1 -OpExecutionMode %464 OriginUpperLeft -OpExecutionMode %581 OriginUpperLeft +OpEntryPoint GLCompute %341 "gen_terrain_compute" %338 +OpEntryPoint Vertex %411 "gen_terrain_vertex" %402 %405 %407 %409 +OpEntryPoint Fragment %459 "gen_terrain_fragment" %449 %451 %454 %457 %458 +OpEntryPoint Vertex %552 "vs_main" %543 %546 %548 %549 %551 +OpEntryPoint Fragment %577 "fs_main" %570 %572 %574 %576 +OpExecutionMode %341 LocalSize 64 1 1 +OpExecutionMode %459 OriginUpperLeft +OpExecutionMode %577 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl // ============================ @@ -358,56 +358,56 @@ OpName %49 "t_normal" OpName %50 "s_normal" OpName %52 "x" OpName %53 "permute3" -OpName %65 "i" -OpName %68 "i1" -OpName %69 "x12" -OpName %72 "m" -OpName %76 "v" -OpName %77 "snoise2" -OpName %204 "x" -OpName %205 "v" -OpName %208 "a" -OpName %209 "i" -OpName %213 "p" -OpName %214 "fbm" -OpName %254 "p" -OpName %255 "min_max_height" -OpName %256 "terrain_point" -OpName %267 "p" -OpName %268 "min_max_height" -OpName %269 "terrain_vertex" -OpName %299 "vert_index" -OpName %300 "chunk_size" -OpName %301 "chunk_corner" -OpName %302 "index_to_p" -OpName %318 "p" -OpName %319 "color23" -OpName %341 "gid" -OpName %344 "gen_terrain_compute" -OpName %405 "vindex" -OpName %408 "index" -OpName %410 "position" -OpName %412 "uv" -OpName %414 "gen_terrain_vertex" -OpName %450 "vert_component" -OpName %451 "index" -OpName %454 "index" -OpName %456 "position" -OpName %459 "uv" +OpName %66 "v" +OpName %67 "snoise2" +OpName %90 "i" +OpName %93 "i1" +OpName %95 "x12" +OpName %98 "m" +OpName %203 "p" +OpName %204 "fbm" +OpName %209 "x" +OpName %211 "v" +OpName %213 "a" +OpName %214 "i" +OpName %251 "p" +OpName %252 "min_max_height" +OpName %253 "terrain_point" +OpName %264 "p" +OpName %265 "min_max_height" +OpName %266 "terrain_vertex" +OpName %296 "vert_index" +OpName %297 "chunk_size" +OpName %298 "chunk_corner" +OpName %299 "index_to_p" +OpName %315 "p" +OpName %316 "color23" +OpName %338 "gid" +OpName %341 "gen_terrain_compute" +OpName %402 "vindex" +OpName %405 "index" +OpName %407 "position" +OpName %409 "uv" +OpName %411 "gen_terrain_vertex" +OpName %449 "index" +OpName %451 "position" +OpName %454 "uv" +OpName %457 "vert_component" +OpName %458 "index" +OpName %459 "gen_terrain_fragment" OpName %462 "vert_component" OpName %463 "index" -OpName %464 "gen_terrain_fragment" -OpName %546 "position" +OpName %543 "position" +OpName %546 "normal" +OpName %548 "clip_position" OpName %549 "normal" -OpName %551 "clip_position" -OpName %552 "normal" -OpName %554 "world_pos" -OpName %555 "vs_main" -OpName %571 "color" -OpName %574 "clip_position" -OpName %576 "normal" -OpName %578 "world_pos" -OpName %581 "fs_main" +OpName %551 "world_pos" +OpName %552 "vs_main" +OpName %570 "clip_position" +OpName %572 "normal" +OpName %574 "world_pos" +OpName %577 "fs_main" +OpName %586 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -466,27 +466,27 @@ OpDecorate %49 DescriptorSet 2 OpDecorate %49 Binding 2 OpDecorate %50 DescriptorSet 2 OpDecorate %50 Binding 3 -OpDecorate %341 BuiltIn GlobalInvocationId -OpDecorate %405 BuiltIn VertexIndex -OpDecorate %408 Location 0 -OpDecorate %408 Flat -OpDecorate %410 BuiltIn Position -OpDecorate %412 Location 1 -OpDecorate %454 Location 0 -OpDecorate %454 Flat -OpDecorate %456 BuiltIn FragCoord -OpDecorate %459 Location 1 -OpDecorate %462 Location 0 -OpDecorate %463 Location 1 -OpDecorate %546 Location 0 -OpDecorate %549 Location 1 -OpDecorate %551 BuiltIn Position -OpDecorate %552 Location 0 -OpDecorate %554 Location 1 -OpDecorate %574 BuiltIn FragCoord +OpDecorate %338 BuiltIn GlobalInvocationId +OpDecorate %402 BuiltIn VertexIndex +OpDecorate %405 Location 0 +OpDecorate %405 Flat +OpDecorate %407 BuiltIn Position +OpDecorate %409 Location 1 +OpDecorate %449 Location 0 +OpDecorate %449 Flat +OpDecorate %451 BuiltIn FragCoord +OpDecorate %454 Location 1 +OpDecorate %457 Location 0 +OpDecorate %458 Location 1 +OpDecorate %543 Location 0 +OpDecorate %546 Location 1 +OpDecorate %548 BuiltIn Position +OpDecorate %549 Location 0 +OpDecorate %551 Location 1 +OpDecorate %570 BuiltIn FragCoord +OpDecorate %572 Location 0 +OpDecorate %574 Location 1 OpDecorate %576 Location 0 -OpDecorate %578 Location 1 -OpDecorate %580 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 3 @@ -538,920 +538,907 @@ OpDecorate %580 Location 0 %54 = OpTypeFunction %4 %4 %55 = OpConstant %5 34.0 %56 = OpConstant %5 1.0 -%57 = OpConstant %5 289.0 -%66 = OpTypePointer Function %6 -%67 = OpConstantNull %6 -%70 = OpTypePointer Function %7 -%71 = OpConstantNull %7 -%73 = OpTypePointer Function %4 -%74 = OpConstantNull %4 -%78 = OpTypeFunction %5 %6 -%79 = OpConstant %5 0.21132487 -%80 = OpConstant %5 0.36602542 -%81 = OpConstant %5 -0.57735026 -%82 = OpConstant %5 0.024390243 -%83 = OpConstant %5 0.0 -%84 = OpConstant %5 0.5 -%85 = OpConstant %5 2.0 +%57 = OpConstantComposite %4 %56 %56 %56 +%58 = OpConstant %5 289.0 +%59 = OpConstantComposite %4 %58 %58 %58 +%68 = OpTypeFunction %5 %6 +%69 = OpConstant %5 0.21132487 +%70 = OpConstant %5 0.36602542 +%71 = OpConstant %5 -0.57735026 +%72 = OpConstant %5 0.024390243 +%73 = OpConstantComposite %7 %69 %70 %71 %72 +%74 = OpConstantComposite %6 %70 %70 +%75 = OpConstantComposite %6 %69 %69 +%76 = OpConstant %5 0.0 +%77 = OpConstantComposite %6 %56 %76 +%78 = OpConstantComposite %6 %76 %56 +%79 = OpConstantComposite %7 %69 %69 %71 %71 +%80 = OpConstantComposite %6 %58 %58 +%81 = OpConstant %5 0.5 +%82 = OpConstantComposite %4 %81 %81 %81 +%83 = OpConstantComposite %4 %76 %76 %76 +%84 = OpConstant %5 2.0 +%85 = OpConstantComposite %4 %72 %72 %72 %86 = OpConstant %5 1.7928429 %87 = OpConstant %5 0.85373473 -%88 = OpConstant %5 130.0 -%107 = OpTypeBool -%110 = OpTypeVector %107 2 -%121 = OpTypePointer Function %5 -%122 = OpConstant %8 1 -%131 = OpConstant %8 0 -%206 = OpTypePointer Function %5 -%207 = OpConstantNull %5 -%210 = OpTypePointer Function %8 -%211 = OpConstantNull %8 -%215 = OpConstant %8 5 -%216 = OpConstant %5 0.01 -%217 = OpConstant %5 100.0 -%257 = OpTypeFunction %4 %6 %6 -%270 = OpTypeFunction %14 %6 %6 -%271 = OpConstant %5 0.1 -%272 = OpConstant %5 -0.1 -%303 = OpTypeFunction %6 %8 %10 %11 -%320 = OpTypeFunction %4 %6 -%321 = OpConstant %5 23.0 -%322 = OpConstant %5 32.0 -%323 = OpConstant %5 -43.0 -%324 = OpConstant %5 3.0 -%342 = OpTypePointer Input %19 -%341 = OpVariable %342 Input -%345 = OpTypeFunction %2 -%346 = OpTypePointer Uniform %13 -%348 = OpConstant %8 6 -%349 = OpConstant %8 2 -%350 = OpConstant %8 3 -%351 = OpConstant %8 4 -%354 = OpTypePointer Uniform %10 -%357 = OpTypePointer Uniform %11 -%361 = OpTypePointer StorageBuffer %15 -%362 = OpTypePointer StorageBuffer %14 -%363 = OpTypePointer Uniform %6 -%370 = OpTypePointer Uniform %8 -%391 = OpTypePointer StorageBuffer %17 -%392 = OpTypePointer StorageBuffer %8 -%406 = OpTypePointer Input %8 -%405 = OpVariable %406 Input -%409 = OpTypePointer Output %8 -%408 = OpVariable %409 Output -%411 = OpTypePointer Output %7 -%410 = OpVariable %411 Output -%413 = OpTypePointer Output %6 -%412 = OpVariable %413 Output -%415 = OpTypePointer Uniform %20 -%417 = OpConstant %5 -1.0 -%432 = OpTypePointer Uniform %8 -%454 = OpVariable %406 Input -%457 = OpTypePointer Input %7 -%456 = OpVariable %457 Input -%460 = OpTypePointer Input %6 -%459 = OpVariable %460 Input -%462 = OpVariable %409 Output -%463 = OpVariable %409 Output -%466 = OpConstant %5 6.0 -%547 = OpTypePointer Input %4 -%546 = OpVariable %547 Input -%549 = OpVariable %547 Input -%551 = OpVariable %411 Output -%553 = OpTypePointer Output %4 -%552 = OpVariable %553 Output -%554 = OpVariable %553 Output -%556 = OpTypePointer Uniform %24 -%559 = OpTypePointer Uniform %23 -%574 = OpVariable %457 Input -%576 = OpVariable %547 Input -%578 = OpVariable %547 Input -%580 = OpVariable %411 Output -%583 = OpTypePointer Uniform %25 -%585 = OpConstant %5 0.7 -%586 = OpConstant %5 0.2 -%605 = OpTypePointer Uniform %4 -%614 = OpTypePointer Uniform %7 +%88 = OpConstantComposite %4 %86 %86 %86 +%89 = OpConstant %5 130.0 +%91 = OpTypePointer Function %6 +%92 = OpConstantNull %6 +%94 = OpConstantNull %6 +%96 = OpTypePointer Function %7 +%97 = OpConstantNull %7 +%99 = OpTypePointer Function %4 +%100 = OpConstantNull %4 +%114 = OpTypeBool +%117 = OpTypeVector %114 2 +%126 = OpTypePointer Function %5 +%127 = OpConstant %8 1 +%136 = OpConstant %8 0 +%205 = OpConstant %8 5 +%206 = OpConstant %5 0.01 +%207 = OpConstant %5 100.0 +%208 = OpConstantComposite %6 %207 %207 +%210 = OpConstantNull %6 +%212 = OpTypePointer Function %5 +%215 = OpTypePointer Function %8 +%254 = OpTypeFunction %4 %6 %6 +%267 = OpTypeFunction %14 %6 %6 +%268 = OpConstant %5 0.1 +%269 = OpConstantComposite %6 %268 %76 +%270 = OpConstantComposite %6 %76 %268 +%271 = OpConstant %5 -0.1 +%272 = OpConstantComposite %6 %271 %76 +%273 = OpConstantComposite %6 %76 %271 +%300 = OpTypeFunction %6 %8 %10 %11 +%317 = OpTypeFunction %4 %6 +%318 = OpConstant %5 23.0 +%319 = OpConstant %5 32.0 +%320 = OpConstantComposite %6 %318 %319 +%321 = OpConstant %5 -43.0 +%322 = OpConstant %5 3.0 +%323 = OpConstantComposite %6 %321 %322 +%339 = OpTypePointer Input %19 +%338 = OpVariable %339 Input +%342 = OpTypeFunction %2 +%343 = OpTypePointer Uniform %13 +%345 = OpConstant %8 6 +%346 = OpConstant %8 2 +%347 = OpConstant %8 3 +%348 = OpConstant %8 4 +%351 = OpTypePointer Uniform %10 +%354 = OpTypePointer Uniform %11 +%358 = OpTypePointer StorageBuffer %15 +%359 = OpTypePointer StorageBuffer %14 +%360 = OpTypePointer Uniform %6 +%367 = OpTypePointer Uniform %8 +%388 = OpTypePointer StorageBuffer %17 +%389 = OpTypePointer StorageBuffer %8 +%403 = OpTypePointer Input %8 +%402 = OpVariable %403 Input +%406 = OpTypePointer Output %8 +%405 = OpVariable %406 Output +%408 = OpTypePointer Output %7 +%407 = OpVariable %408 Output +%410 = OpTypePointer Output %6 +%409 = OpVariable %410 Output +%412 = OpTypePointer Uniform %20 +%414 = OpConstant %5 -1.0 +%415 = OpConstantComposite %6 %414 %414 +%429 = OpTypePointer Uniform %8 +%449 = OpVariable %403 Input +%452 = OpTypePointer Input %7 +%451 = OpVariable %452 Input +%455 = OpTypePointer Input %6 +%454 = OpVariable %455 Input +%457 = OpVariable %406 Output +%458 = OpVariable %406 Output +%461 = OpConstant %5 6.0 +%544 = OpTypePointer Input %4 +%543 = OpVariable %544 Input +%546 = OpVariable %544 Input +%548 = OpVariable %408 Output +%550 = OpTypePointer Output %4 +%549 = OpVariable %550 Output +%551 = OpVariable %550 Output +%553 = OpTypePointer Uniform %24 +%556 = OpTypePointer Uniform %23 +%570 = OpVariable %452 Input +%572 = OpVariable %544 Input +%574 = OpVariable %544 Input +%576 = OpVariable %408 Output +%579 = OpTypePointer Uniform %25 +%581 = OpConstantComposite %4 %268 %268 %268 +%582 = OpConstant %5 0.7 +%583 = OpConstantComposite %4 %81 %268 %582 +%584 = OpConstant %5 0.2 +%585 = OpConstantComposite %4 %584 %584 %584 +%587 = OpConstantNull %4 +%602 = OpTypePointer Uniform %4 +%611 = OpTypePointer Uniform %7 %53 = OpFunction %4 None %54 %52 = OpFunctionParameter %4 %51 = OpLabel -OpBranch %58 -%58 = OpLabel +OpBranch %60 +%60 = OpLabel OpLine %3 10 52 -%59 = OpVectorTimesScalar %4 %52 %55 +%61 = OpVectorTimesScalar %4 %52 %55 OpLine %3 10 50 -%60 = OpCompositeConstruct %4 %56 %56 %56 -%61 = OpFAdd %4 %59 %60 -%62 = OpFMul %4 %61 %52 +%62 = OpFAdd %4 %61 %57 +%63 = OpFMul %4 %62 %52 OpLine %3 10 49 -%63 = OpCompositeConstruct %4 %57 %57 %57 -%64 = OpFRem %4 %62 %63 +%64 = OpFRem %4 %63 %59 OpReturnValue %64 OpFunctionEnd -%77 = OpFunction %5 None %78 -%76 = OpFunctionParameter %6 -%75 = OpLabel -%68 = OpVariable %66 Function %67 -%72 = OpVariable %73 Function %74 -%65 = OpVariable %66 Function %67 -%69 = OpVariable %70 Function %71 -OpBranch %89 -%89 = OpLabel +%67 = OpFunction %5 None %68 +%66 = OpFunctionParameter %6 +%65 = OpLabel +%93 = OpVariable %91 Function %94 +%98 = OpVariable %99 Function %100 +%90 = OpVariable %91 Function %92 +%95 = OpVariable %96 Function %97 +OpBranch %101 +%101 = OpLabel OpLine %3 13 13 -%90 = OpCompositeConstruct %7 %79 %80 %81 %82 OpLine %3 14 24 -%91 = OpCompositeConstruct %6 %80 %80 -%92 = OpDot %5 %76 %91 -%93 = OpCompositeConstruct %6 %92 %92 -%94 = OpFAdd %6 %76 %93 -%95 = OpExtInst %6 %1 Floor %94 +%102 = OpDot %5 %66 %74 +%103 = OpCompositeConstruct %6 %102 %102 +%104 = OpFAdd %6 %66 %103 +%105 = OpExtInst %6 %1 Floor %104 OpLine %3 14 5 -OpStore %65 %95 +OpStore %90 %105 OpLine %3 15 14 -%96 = OpLoad %6 %65 -%97 = OpFSub %6 %76 %96 -%98 = OpLoad %6 %65 -%99 = OpCompositeConstruct %6 %79 %79 -%100 = OpDot %5 %98 %99 -%101 = OpCompositeConstruct %6 %100 %100 -%102 = OpFAdd %6 %97 %101 +%106 = OpLoad %6 %90 +%107 = OpFSub %6 %66 %106 +%108 = OpLoad %6 %90 +%109 = OpDot %5 %108 %75 +%110 = OpCompositeConstruct %6 %109 %109 +%111 = OpFAdd %6 %107 %110 OpLine %3 17 32 -%103 = OpCompositeConstruct %6 %56 %83 OpLine %3 17 25 -%104 = OpCompositeConstruct %6 %83 %56 -%105 = OpCompositeExtract %5 %102 0 -%106 = OpCompositeExtract %5 %102 1 -%108 = OpFOrdLessThan %107 %105 %106 -%111 = OpCompositeConstruct %110 %108 %108 -%109 = OpSelect %6 %111 %104 %103 +%112 = OpCompositeExtract %5 %111 0 +%113 = OpCompositeExtract %5 %111 1 +%115 = OpFOrdLessThan %114 %112 %113 +%118 = OpCompositeConstruct %117 %115 %115 +%116 = OpSelect %6 %118 %78 %77 OpLine %3 17 5 -OpStore %68 %109 +OpStore %93 %116 OpLine %3 18 26 -%112 = OpVectorShuffle %7 %102 %102 0 1 0 1 -%113 = OpCompositeConstruct %7 %79 %79 %81 %81 -%114 = OpFAdd %7 %112 %113 -%115 = OpLoad %6 %68 +%119 = OpVectorShuffle %7 %111 %111 0 1 0 1 +%120 = OpFAdd %7 %119 %79 +%121 = OpLoad %6 %93 OpLine %3 18 26 -%116 = OpCompositeConstruct %7 %115 %83 %83 -%117 = OpFSub %7 %114 %116 +%122 = OpCompositeConstruct %7 %121 %76 %76 +%123 = OpFSub %7 %120 %122 OpLine %3 18 5 -OpStore %69 %117 +OpStore %95 %123 OpLine %3 1 1 -%118 = OpLoad %6 %65 +%124 = OpLoad %6 %90 OpLine %3 19 9 -%119 = OpCompositeConstruct %6 %57 %57 -%120 = OpFRem %6 %118 %119 +%125 = OpFRem %6 %124 %80 OpLine %3 19 5 -OpStore %65 %120 +OpStore %90 %125 OpLine %3 20 31 -%123 = OpAccessChain %121 %65 %122 -%124 = OpLoad %5 %123 +%128 = OpAccessChain %126 %90 %127 +%129 = OpLoad %5 %128 OpLine %3 20 51 -%125 = OpAccessChain %121 %68 %122 -%126 = OpLoad %5 %125 +%130 = OpAccessChain %126 %93 %127 +%131 = OpLoad %5 %130 OpLine %3 20 31 -%127 = OpCompositeConstruct %4 %83 %126 %56 -%128 = OpCompositeConstruct %4 %124 %124 %124 -%129 = OpFAdd %4 %128 %127 +%132 = OpCompositeConstruct %4 %76 %131 %56 +%133 = OpCompositeConstruct %4 %129 %129 %129 +%134 = OpFAdd %4 %133 %132 OpLine %3 20 22 -%130 = OpFunctionCall %4 %53 %129 +%135 = OpFunctionCall %4 %53 %134 OpLine %3 20 22 -%132 = OpAccessChain %121 %65 %131 -%133 = OpLoad %5 %132 -%134 = OpCompositeConstruct %4 %133 %133 %133 -%135 = OpFAdd %4 %130 %134 +%137 = OpAccessChain %126 %90 %136 +%138 = OpLoad %5 %137 +%139 = OpCompositeConstruct %4 %138 %138 %138 +%140 = OpFAdd %4 %135 %139 OpLine %3 20 84 -%136 = OpAccessChain %121 %68 %131 -%137 = OpLoad %5 %136 +%141 = OpAccessChain %126 %93 %136 +%142 = OpLoad %5 %141 OpLine %3 20 22 -%138 = OpCompositeConstruct %4 %83 %137 %56 -%139 = OpFAdd %4 %135 %138 +%143 = OpCompositeConstruct %4 %76 %142 %56 +%144 = OpFAdd %4 %140 %143 OpLine %3 20 13 -%140 = OpFunctionCall %4 %53 %139 +%145 = OpFunctionCall %4 %53 %144 OpLine %3 21 28 -%141 = OpDot %5 %102 %102 -%142 = OpLoad %7 %69 -%143 = OpVectorShuffle %6 %142 %142 0 1 -%144 = OpLoad %7 %69 -%145 = OpVectorShuffle %6 %144 %144 0 1 -%146 = OpDot %5 %143 %145 -%147 = OpLoad %7 %69 -%148 = OpVectorShuffle %6 %147 %147 2 3 -%149 = OpLoad %7 %69 -%150 = OpVectorShuffle %6 %149 %149 2 3 +%146 = OpDot %5 %111 %111 +%147 = OpLoad %7 %95 +%148 = OpVectorShuffle %6 %147 %147 0 1 +%149 = OpLoad %7 %95 +%150 = OpVectorShuffle %6 %149 %149 0 1 %151 = OpDot %5 %148 %150 -%152 = OpCompositeConstruct %4 %141 %146 %151 -%153 = OpCompositeConstruct %4 %84 %84 %84 -%154 = OpFSub %4 %153 %152 +%152 = OpLoad %7 %95 +%153 = OpVectorShuffle %6 %152 %152 2 3 +%154 = OpLoad %7 %95 +%155 = OpVectorShuffle %6 %154 %154 2 3 +%156 = OpDot %5 %153 %155 +%157 = OpCompositeConstruct %4 %146 %151 %156 +%158 = OpFSub %4 %82 %157 OpLine %3 21 24 -%155 = OpCompositeConstruct %4 %83 %83 %83 -%156 = OpExtInst %4 %1 FMax %154 %155 +%159 = OpExtInst %4 %1 FMax %158 %83 OpLine %3 21 5 -OpStore %72 %156 +OpStore %98 %159 OpLine %3 22 9 -%157 = OpLoad %4 %72 -%158 = OpLoad %4 %72 -%159 = OpFMul %4 %157 %158 +%160 = OpLoad %4 %98 +%161 = OpLoad %4 %98 +%162 = OpFMul %4 %160 %161 OpLine %3 22 5 -OpStore %72 %159 +OpStore %98 %162 OpLine %3 23 9 -%160 = OpLoad %4 %72 -%161 = OpLoad %4 %72 -%162 = OpFMul %4 %160 %161 +%163 = OpLoad %4 %98 +%164 = OpLoad %4 %98 +%165 = OpFMul %4 %163 %164 OpLine %3 23 5 -OpStore %72 %162 +OpStore %98 %165 OpLine %3 24 13 -%163 = OpCompositeConstruct %4 %82 %82 %82 -%164 = OpFMul %4 %140 %163 -%165 = OpExtInst %4 %1 Fract %164 -%166 = OpVectorTimesScalar %4 %165 %85 +%166 = OpFMul %4 %145 %85 +%167 = OpExtInst %4 %1 Fract %166 +%168 = OpVectorTimesScalar %4 %167 %84 OpLine %3 24 13 -%167 = OpCompositeConstruct %4 %56 %56 %56 -%168 = OpFSub %4 %166 %167 +%169 = OpFSub %4 %168 %57 OpLine %3 25 13 -%169 = OpExtInst %4 %1 FAbs %168 +%170 = OpExtInst %4 %1 FAbs %169 OpLine %3 25 13 -%170 = OpCompositeConstruct %4 %84 %84 %84 -%171 = OpFSub %4 %169 %170 +%171 = OpFSub %4 %170 %82 OpLine %3 26 14 -%172 = OpCompositeConstruct %4 %84 %84 %84 -%173 = OpFAdd %4 %168 %172 -%174 = OpExtInst %4 %1 Floor %173 +%172 = OpFAdd %4 %169 %82 +%173 = OpExtInst %4 %1 Floor %172 OpLine %3 27 14 -%175 = OpFSub %4 %168 %174 +%174 = OpFSub %4 %169 %173 OpLine %3 1 1 -%176 = OpLoad %4 %72 +%175 = OpLoad %4 %98 OpLine %3 28 9 -%177 = OpFMul %4 %175 %175 -%178 = OpFMul %4 %171 %171 -%179 = OpFAdd %4 %177 %178 -%180 = OpVectorTimesScalar %4 %179 %87 -%181 = OpCompositeConstruct %4 %86 %86 %86 -%182 = OpFSub %4 %181 %180 -%183 = OpFMul %4 %176 %182 +%176 = OpFMul %4 %174 %174 +%177 = OpFMul %4 %171 %171 +%178 = OpFAdd %4 %176 %177 +%179 = OpVectorTimesScalar %4 %178 %87 +%180 = OpFSub %4 %88 %179 +%181 = OpFMul %4 %175 %180 OpLine %3 28 5 -OpStore %72 %183 +OpStore %98 %181 OpLine %3 29 13 -%184 = OpCompositeExtract %5 %175 0 -%185 = OpCompositeExtract %5 %102 0 -%186 = OpFMul %5 %184 %185 -%187 = OpCompositeExtract %5 %171 0 -%188 = OpCompositeExtract %5 %102 1 -%189 = OpFMul %5 %187 %188 -%190 = OpFAdd %5 %186 %189 -%191 = OpVectorShuffle %6 %175 %175 1 2 -%192 = OpLoad %7 %69 -%193 = OpVectorShuffle %6 %192 %192 0 2 -%194 = OpFMul %6 %191 %193 -%195 = OpVectorShuffle %6 %171 %171 1 2 -%196 = OpLoad %7 %69 -%197 = OpVectorShuffle %6 %196 %196 1 3 -%198 = OpFMul %6 %195 %197 -%199 = OpFAdd %6 %194 %198 -%200 = OpCompositeConstruct %4 %190 %199 +%182 = OpCompositeExtract %5 %174 0 +%183 = OpCompositeExtract %5 %111 0 +%184 = OpFMul %5 %182 %183 +%185 = OpCompositeExtract %5 %171 0 +%186 = OpCompositeExtract %5 %111 1 +%187 = OpFMul %5 %185 %186 +%188 = OpFAdd %5 %184 %187 +%189 = OpVectorShuffle %6 %174 %174 1 2 +%190 = OpLoad %7 %95 +%191 = OpVectorShuffle %6 %190 %190 0 2 +%192 = OpFMul %6 %189 %191 +%193 = OpVectorShuffle %6 %171 %171 1 2 +%194 = OpLoad %7 %95 +%195 = OpVectorShuffle %6 %194 %194 1 3 +%196 = OpFMul %6 %193 %195 +%197 = OpFAdd %6 %192 %196 +%198 = OpCompositeConstruct %4 %188 %197 OpLine %3 30 12 -%201 = OpLoad %4 %72 -%202 = OpDot %5 %201 %200 -%203 = OpFMul %5 %88 %202 -OpReturnValue %203 +%199 = OpLoad %4 %98 +%200 = OpDot %5 %199 %198 +%201 = OpFMul %5 %89 %200 +OpReturnValue %201 OpFunctionEnd -%214 = OpFunction %5 None %78 -%213 = OpFunctionParameter %6 -%212 = OpLabel -%205 = OpVariable %206 Function %207 -%209 = OpVariable %210 Function %211 -%204 = OpVariable %66 Function %67 -%208 = OpVariable %206 Function %207 -OpBranch %218 -%218 = OpLabel +%204 = OpFunction %5 None %68 +%203 = OpFunctionParameter %6 +%202 = OpLabel +%211 = OpVariable %212 Function %76 +%214 = OpVariable %215 Function %136 +%209 = OpVariable %91 Function %210 +%213 = OpVariable %212 Function %81 +OpBranch %216 +%216 = OpLabel OpLine %3 36 13 -%219 = OpVectorTimesScalar %6 %213 %216 +%217 = OpVectorTimesScalar %6 %203 %206 OpLine %3 36 5 -OpStore %204 %219 -OpLine %3 37 5 -OpStore %205 %83 -OpLine %3 38 5 -OpStore %208 %84 +OpStore %209 %217 OpLine %3 39 17 -%220 = OpCompositeConstruct %6 %217 %217 OpLine %3 40 24 -%221 = OpExtInst %5 %1 Cos %84 +%218 = OpExtInst %5 %1 Cos %81 OpLine %3 40 14 -%222 = OpExtInst %5 %1 Sin %84 -%223 = OpCompositeConstruct %6 %221 %222 +%219 = OpExtInst %5 %1 Sin %81 +%220 = OpCompositeConstruct %6 %218 %219 OpLine %3 41 15 -%224 = OpFNegate %5 %222 -%225 = OpCompositeConstruct %6 %221 %222 -%226 = OpCompositeConstruct %6 %224 %221 -%227 = OpCompositeConstruct %9 %225 %226 -OpLine %3 43 10 -OpStore %209 %131 -OpBranch %228 -%228 = OpLabel +%221 = OpFNegate %5 %219 +%222 = OpCompositeConstruct %6 %218 %219 +%223 = OpCompositeConstruct %6 %221 %218 +%224 = OpCompositeConstruct %9 %222 %223 +OpBranch %225 +%225 = OpLabel OpLine %3 43 5 -OpLoopMerge %229 %231 None -OpBranch %230 -%230 = OpLabel +OpLoopMerge %226 %228 None +OpBranch %227 +%227 = OpLabel OpLine %3 43 22 -%232 = OpLoad %8 %209 -%233 = OpULessThan %107 %232 %215 +%229 = OpLoad %8 %214 +%230 = OpULessThan %114 %229 %205 OpLine %3 43 21 -OpSelectionMerge %234 None -OpBranchConditional %233 %234 %235 -%235 = OpLabel -OpBranch %229 -%234 = OpLabel -OpBranch %236 -%236 = OpLabel +OpSelectionMerge %231 None +OpBranchConditional %230 %231 %232 +%232 = OpLabel +OpBranch %226 +%231 = OpLabel +OpBranch %233 +%233 = OpLabel OpLine %3 1 1 -%238 = OpLoad %5 %205 -%239 = OpLoad %5 %208 -%240 = OpLoad %6 %204 +%235 = OpLoad %5 %211 +%236 = OpLoad %5 %213 +%237 = OpLoad %6 %209 OpLine %3 44 21 -%241 = OpFunctionCall %5 %77 %240 +%238 = OpFunctionCall %5 %67 %237 OpLine %3 44 13 -%242 = OpFMul %5 %239 %241 -%243 = OpFAdd %5 %238 %242 +%239 = OpFMul %5 %236 %238 +%240 = OpFAdd %5 %235 %239 OpLine %3 44 9 -OpStore %205 %243 +OpStore %211 %240 OpLine %3 45 13 -%244 = OpLoad %6 %204 -%245 = OpMatrixTimesVector %6 %227 %244 +%241 = OpLoad %6 %209 +%242 = OpMatrixTimesVector %6 %224 %241 OpLine %3 45 13 -%246 = OpVectorTimesScalar %6 %245 %85 -%247 = OpFAdd %6 %246 %220 +%243 = OpVectorTimesScalar %6 %242 %84 +%244 = OpFAdd %6 %243 %208 OpLine %3 45 9 -OpStore %204 %247 +OpStore %209 %244 OpLine %3 1 1 -%248 = OpLoad %5 %208 +%245 = OpLoad %5 %213 OpLine %3 46 13 -%249 = OpFMul %5 %248 %84 +%246 = OpFMul %5 %245 %81 OpLine %3 46 9 -OpStore %208 %249 -OpBranch %237 -%237 = OpLabel -OpBranch %231 -%231 = OpLabel +OpStore %213 %246 +OpBranch %234 +%234 = OpLabel +OpBranch %228 +%228 = OpLabel OpLine %3 1 1 -%250 = OpLoad %8 %209 +%247 = OpLoad %8 %214 OpLine %3 43 43 -%251 = OpIAdd %8 %250 %122 +%248 = OpIAdd %8 %247 %127 OpLine %3 43 39 -OpStore %209 %251 -OpBranch %228 -%229 = OpLabel +OpStore %214 %248 +OpBranch %225 +%226 = OpLabel OpLine %3 1 1 -%252 = OpLoad %5 %205 -OpReturnValue %252 +%249 = OpLoad %5 %211 +OpReturnValue %249 OpFunctionEnd -%256 = OpFunction %4 None %257 -%254 = OpFunctionParameter %6 -%255 = OpFunctionParameter %6 -%253 = OpLabel -OpBranch %258 -%258 = OpLabel +%253 = OpFunction %4 None %254 +%251 = OpFunctionParameter %6 +%252 = OpFunctionParameter %6 +%250 = OpLabel +OpBranch %255 +%255 = OpLabel OpLine %3 77 9 -%259 = OpCompositeExtract %5 %254 0 -%260 = OpCompositeExtract %5 %255 0 -%261 = OpCompositeExtract %5 %255 1 +%256 = OpCompositeExtract %5 %251 0 +%257 = OpCompositeExtract %5 %252 0 +%258 = OpCompositeExtract %5 %252 1 OpLine %3 78 49 -%262 = OpFunctionCall %5 %214 %254 +%259 = OpFunctionCall %5 %204 %251 OpLine %3 76 12 -%263 = OpExtInst %5 %1 FMix %260 %261 %262 -%264 = OpCompositeExtract %5 %254 1 -%265 = OpCompositeConstruct %4 %259 %263 %264 -OpReturnValue %265 +%260 = OpExtInst %5 %1 FMix %257 %258 %259 +%261 = OpCompositeExtract %5 %251 1 +%262 = OpCompositeConstruct %4 %256 %260 %261 +OpReturnValue %262 OpFunctionEnd -%269 = OpFunction %14 None %270 -%267 = OpFunctionParameter %6 -%268 = OpFunctionParameter %6 -%266 = OpLabel -OpBranch %273 -%273 = OpLabel +%266 = OpFunction %14 None %267 +%264 = OpFunctionParameter %6 +%265 = OpFunctionParameter %6 +%263 = OpLabel +OpBranch %274 +%274 = OpLabel OpLine %3 84 13 -%274 = OpFunctionCall %4 %256 %267 %268 +%275 = OpFunctionCall %4 %253 %264 %265 OpLine %3 86 29 -%275 = OpCompositeConstruct %6 %271 %83 -%276 = OpFAdd %6 %267 %275 +%276 = OpFAdd %6 %264 %269 OpLine %3 86 15 -%277 = OpFunctionCall %4 %256 %276 %268 +%277 = OpFunctionCall %4 %253 %276 %265 OpLine %3 86 15 -%278 = OpFSub %4 %277 %274 +%278 = OpFSub %4 %277 %275 OpLine %3 87 29 -%279 = OpCompositeConstruct %6 %83 %271 -%280 = OpFAdd %6 %267 %279 +%279 = OpFAdd %6 %264 %270 OpLine %3 87 15 -%281 = OpFunctionCall %4 %256 %280 %268 +%280 = OpFunctionCall %4 %253 %279 %265 OpLine %3 87 15 -%282 = OpFSub %4 %281 %274 +%281 = OpFSub %4 %280 %275 OpLine %3 88 29 -%283 = OpCompositeConstruct %6 %272 %83 -%284 = OpFAdd %6 %267 %283 +%282 = OpFAdd %6 %264 %272 OpLine %3 88 15 -%285 = OpFunctionCall %4 %256 %284 %268 +%283 = OpFunctionCall %4 %253 %282 %265 OpLine %3 88 15 -%286 = OpFSub %4 %285 %274 +%284 = OpFSub %4 %283 %275 OpLine %3 89 29 -%287 = OpCompositeConstruct %6 %83 %272 -%288 = OpFAdd %6 %267 %287 +%285 = OpFAdd %6 %264 %273 OpLine %3 89 15 -%289 = OpFunctionCall %4 %256 %288 %268 +%286 = OpFunctionCall %4 %253 %285 %265 OpLine %3 89 15 -%290 = OpFSub %4 %289 %274 +%287 = OpFSub %4 %286 %275 OpLine %3 91 14 -%291 = OpExtInst %4 %1 Cross %282 %278 -%292 = OpExtInst %4 %1 Normalize %291 +%288 = OpExtInst %4 %1 Cross %281 %278 +%289 = OpExtInst %4 %1 Normalize %288 OpLine %3 92 14 -%293 = OpExtInst %4 %1 Cross %290 %286 -%294 = OpExtInst %4 %1 Normalize %293 +%290 = OpExtInst %4 %1 Cross %287 %284 +%291 = OpExtInst %4 %1 Normalize %290 OpLine %3 94 14 -%295 = OpFAdd %4 %292 %294 +%292 = OpFAdd %4 %289 %291 OpLine %3 94 13 -%296 = OpVectorTimesScalar %4 %295 %84 +%293 = OpVectorTimesScalar %4 %292 %81 OpLine %3 96 12 -%297 = OpCompositeConstruct %14 %274 %296 -OpReturnValue %297 +%294 = OpCompositeConstruct %14 %275 %293 +OpReturnValue %294 OpFunctionEnd -%302 = OpFunction %6 None %303 -%299 = OpFunctionParameter %8 -%300 = OpFunctionParameter %10 -%301 = OpFunctionParameter %11 -%298 = OpLabel -OpBranch %304 -%304 = OpLabel +%299 = OpFunction %6 None %300 +%296 = OpFunctionParameter %8 +%297 = OpFunctionParameter %10 +%298 = OpFunctionParameter %11 +%295 = OpLabel +OpBranch %301 +%301 = OpLabel OpLine %3 101 9 -%305 = OpConvertUToF %5 %299 -%306 = OpCompositeExtract %8 %300 0 +%302 = OpConvertUToF %5 %296 +%303 = OpCompositeExtract %8 %297 0 OpLine %3 101 9 -%307 = OpIAdd %8 %306 %122 -%308 = OpConvertUToF %5 %307 -%309 = OpFRem %5 %305 %308 -%310 = OpCompositeExtract %8 %300 0 +%304 = OpIAdd %8 %303 %127 +%305 = OpConvertUToF %5 %304 +%306 = OpFRem %5 %302 %305 +%307 = OpCompositeExtract %8 %297 0 OpLine %3 100 12 -%311 = OpIAdd %8 %310 %122 -%312 = OpUDiv %8 %299 %311 -%313 = OpConvertUToF %5 %312 -%314 = OpCompositeConstruct %6 %309 %313 -%315 = OpConvertSToF %6 %301 -%316 = OpFAdd %6 %314 %315 -OpReturnValue %316 +%308 = OpIAdd %8 %307 %127 +%309 = OpUDiv %8 %296 %308 +%310 = OpConvertUToF %5 %309 +%311 = OpCompositeConstruct %6 %306 %310 +%312 = OpConvertSToF %6 %298 +%313 = OpFAdd %6 %311 %312 +OpReturnValue %313 OpFunctionEnd -%319 = OpFunction %4 None %320 -%318 = OpFunctionParameter %6 -%317 = OpLabel -OpBranch %325 -%325 = OpLabel +%316 = OpFunction %4 None %317 +%315 = OpFunctionParameter %6 +%314 = OpLabel +OpBranch %324 +%324 = OpLabel OpLine %3 270 9 -%326 = OpFunctionCall %5 %77 %318 +%325 = OpFunctionCall %5 %67 %315 OpLine %3 270 9 -%327 = OpFMul %5 %326 %84 +%326 = OpFMul %5 %325 %81 OpLine %3 270 9 -%328 = OpFAdd %5 %327 %84 +%327 = OpFAdd %5 %326 %81 OpLine %3 271 17 -%329 = OpCompositeConstruct %6 %321 %322 -%330 = OpFAdd %6 %318 %329 +%328 = OpFAdd %6 %315 %320 OpLine %3 271 9 -%331 = OpFunctionCall %5 %77 %330 +%329 = OpFunctionCall %5 %67 %328 OpLine %3 271 9 -%332 = OpFMul %5 %331 %84 +%330 = OpFMul %5 %329 %81 OpLine %3 271 9 -%333 = OpFAdd %5 %332 %84 +%331 = OpFAdd %5 %330 %81 OpLine %3 272 17 -%334 = OpCompositeConstruct %6 %323 %324 -%335 = OpFAdd %6 %318 %334 +%332 = OpFAdd %6 %315 %323 OpLine %3 272 9 -%336 = OpFunctionCall %5 %77 %335 +%333 = OpFunctionCall %5 %67 %332 OpLine %3 272 9 -%337 = OpFMul %5 %336 %84 +%334 = OpFMul %5 %333 %81 OpLine %3 269 12 -%338 = OpFAdd %5 %337 %84 -%339 = OpCompositeConstruct %4 %328 %333 %338 -OpReturnValue %339 +%335 = OpFAdd %5 %334 %81 +%336 = OpCompositeConstruct %4 %327 %331 %335 +OpReturnValue %336 OpFunctionEnd -%344 = OpFunction %2 None %345 -%340 = OpLabel -%343 = OpLoad %19 %341 -%347 = OpAccessChain %346 %29 %131 -OpBranch %352 -%352 = OpLabel +%341 = OpFunction %2 None %342 +%337 = OpLabel +%340 = OpLoad %19 %338 +%344 = OpAccessChain %343 %29 %136 +OpBranch %349 +%349 = OpLabel OpLine %3 111 22 -%353 = OpCompositeExtract %8 %343 0 +%350 = OpCompositeExtract %8 %340 0 OpLine %3 113 36 -%355 = OpAccessChain %354 %347 %131 -%356 = OpLoad %10 %355 +%352 = OpAccessChain %351 %344 %136 +%353 = OpLoad %10 %352 OpLine %3 113 59 -%358 = OpAccessChain %357 %347 %122 -%359 = OpLoad %11 %358 +%355 = OpAccessChain %354 %344 %127 +%356 = OpLoad %11 %355 OpLine %3 113 13 -%360 = OpFunctionCall %6 %302 %353 %356 %359 +%357 = OpFunctionCall %6 %299 %350 %353 %356 OpLine %3 115 5 OpLine %3 115 51 -%364 = OpAccessChain %363 %347 %349 -%365 = OpLoad %6 %364 +%361 = OpAccessChain %360 %344 %346 +%362 = OpLoad %6 %361 OpLine %3 115 33 -%366 = OpFunctionCall %14 %269 %360 %365 +%363 = OpFunctionCall %14 %266 %357 %362 OpLine %3 115 5 -%367 = OpAccessChain %362 %32 %131 %353 -OpStore %367 %366 +%364 = OpAccessChain %359 %32 %136 %350 +OpStore %364 %363 OpLine %3 118 23 -%368 = OpCompositeExtract %8 %343 0 +%365 = OpCompositeExtract %8 %340 0 OpLine %3 118 23 -%369 = OpIMul %8 %368 %348 +%366 = OpIMul %8 %365 %345 OpLine %3 120 25 -%371 = OpAccessChain %370 %347 %131 %131 -%372 = OpLoad %8 %371 +%368 = OpAccessChain %367 %344 %136 %136 +%369 = OpLoad %8 %368 OpLine %3 120 25 -%373 = OpAccessChain %370 %347 %131 %122 -%374 = OpLoad %8 %373 -%375 = OpIMul %8 %372 %374 +%370 = OpAccessChain %367 %344 %136 %127 +%371 = OpLoad %8 %370 +%372 = OpIMul %8 %369 %371 OpLine %3 120 9 -%376 = OpIMul %8 %375 %348 -%377 = OpUGreaterThanEqual %107 %369 %376 +%373 = OpIMul %8 %372 %345 +%374 = OpUGreaterThanEqual %114 %366 %373 OpLine %3 120 5 -OpSelectionMerge %378 None -OpBranchConditional %377 %379 %378 -%379 = OpLabel +OpSelectionMerge %375 None +OpBranchConditional %374 %376 %375 +%376 = OpLabel OpReturn -%378 = OpLabel +%375 = OpLabel OpLine %3 122 28 -%380 = OpCompositeExtract %8 %343 0 +%377 = OpCompositeExtract %8 %340 0 OpLine %3 122 15 -%381 = OpAccessChain %370 %347 %131 %131 -%382 = OpLoad %8 %381 -%383 = OpUDiv %8 %380 %382 -%384 = OpIAdd %8 %353 %383 +%378 = OpAccessChain %367 %344 %136 %136 +%379 = OpLoad %8 %378 +%380 = OpUDiv %8 %377 %379 +%381 = OpIAdd %8 %350 %380 OpLine %3 123 15 -%385 = OpIAdd %8 %384 %122 +%382 = OpIAdd %8 %381 %127 OpLine %3 124 15 -%386 = OpAccessChain %370 %347 %131 %131 -%387 = OpLoad %8 %386 -%388 = OpIAdd %8 %384 %387 +%383 = OpAccessChain %367 %344 %136 %136 +%384 = OpLoad %8 %383 +%385 = OpIAdd %8 %381 %384 OpLine %3 124 15 -%389 = OpIAdd %8 %388 %122 +%386 = OpIAdd %8 %385 %127 OpLine %3 125 15 -%390 = OpIAdd %8 %389 %122 +%387 = OpIAdd %8 %386 %127 OpLine %3 127 5 OpLine %3 127 5 -%393 = OpAccessChain %392 %34 %131 %369 -OpStore %393 %384 +%390 = OpAccessChain %389 %34 %136 %366 +OpStore %390 %381 OpLine %3 128 5 OpLine %3 128 5 -%394 = OpIAdd %8 %369 %122 +%391 = OpIAdd %8 %366 %127 OpLine %3 128 5 -%395 = OpAccessChain %392 %34 %131 %394 -OpStore %395 %389 +%392 = OpAccessChain %389 %34 %136 %391 +OpStore %392 %386 OpLine %3 129 5 OpLine %3 129 5 -%396 = OpIAdd %8 %369 %349 +%393 = OpIAdd %8 %366 %346 OpLine %3 129 5 -%397 = OpAccessChain %392 %34 %131 %396 -OpStore %397 %390 +%394 = OpAccessChain %389 %34 %136 %393 +OpStore %394 %387 OpLine %3 130 5 OpLine %3 130 5 -%398 = OpIAdd %8 %369 %350 +%395 = OpIAdd %8 %366 %347 OpLine %3 130 5 -%399 = OpAccessChain %392 %34 %131 %398 -OpStore %399 %384 +%396 = OpAccessChain %389 %34 %136 %395 +OpStore %396 %381 OpLine %3 131 5 OpLine %3 131 5 -%400 = OpIAdd %8 %369 %351 +%397 = OpIAdd %8 %366 %348 OpLine %3 131 5 -%401 = OpAccessChain %392 %34 %131 %400 -OpStore %401 %390 +%398 = OpAccessChain %389 %34 %136 %397 +OpStore %398 %387 OpLine %3 132 5 OpLine %3 132 5 -%402 = OpIAdd %8 %369 %215 +%399 = OpIAdd %8 %366 %205 OpLine %3 132 5 -%403 = OpAccessChain %392 %34 %131 %402 -OpStore %403 %385 +%400 = OpAccessChain %389 %34 %136 %399 +OpStore %400 %382 OpReturn OpFunctionEnd -%414 = OpFunction %2 None %345 -%404 = OpLabel -%407 = OpLoad %8 %405 -%416 = OpAccessChain %415 %36 %131 -OpBranch %418 -%418 = OpLabel +%411 = OpFunction %2 None %342 +%401 = OpLabel +%404 = OpLoad %8 %402 +%413 = OpAccessChain %412 %36 %136 +OpBranch %416 +%416 = OpLabel OpLine %3 161 19 -%419 = OpIAdd %8 %407 %349 +%417 = OpIAdd %8 %404 %346 OpLine %3 161 18 -%420 = OpUDiv %8 %419 %350 +%418 = OpUDiv %8 %417 %347 OpLine %3 161 13 -%421 = OpUMod %8 %420 %349 -%422 = OpConvertUToF %5 %421 +%419 = OpUMod %8 %418 %346 +%420 = OpConvertUToF %5 %419 OpLine %3 162 19 -%423 = OpIAdd %8 %407 %122 +%421 = OpIAdd %8 %404 %127 OpLine %3 162 18 -%424 = OpUDiv %8 %423 %350 +%422 = OpUDiv %8 %421 %347 OpLine %3 162 13 -%425 = OpUMod %8 %424 %349 -%426 = OpConvertUToF %5 %425 +%423 = OpUMod %8 %422 %346 +%424 = OpConvertUToF %5 %423 OpLine %3 163 14 -%427 = OpCompositeConstruct %6 %422 %426 +%425 = OpCompositeConstruct %6 %420 %424 OpLine %3 165 30 -%428 = OpVectorTimesScalar %6 %427 %85 -%429 = OpCompositeConstruct %6 %417 %417 -%430 = OpFAdd %6 %429 %428 +%426 = OpVectorTimesScalar %6 %425 %84 +%427 = OpFAdd %6 %415 %426 OpLine %3 165 20 -%431 = OpCompositeConstruct %7 %430 %83 %56 +%428 = OpCompositeConstruct %7 %427 %76 %56 OpLine %3 168 21 -%433 = OpAccessChain %432 %416 %350 -%434 = OpLoad %8 %433 -%435 = OpConvertUToF %5 %434 -%436 = OpFMul %5 %422 %435 +%430 = OpAccessChain %429 %413 %347 +%431 = OpLoad %8 %430 +%432 = OpConvertUToF %5 %431 +%433 = OpFMul %5 %420 %432 OpLine %3 168 17 -%437 = OpAccessChain %432 %416 %350 -%438 = OpLoad %8 %437 -%439 = OpConvertUToF %5 %438 -%440 = OpFMul %5 %426 %439 -%441 = OpFAdd %5 %436 %440 -%442 = OpConvertFToU %8 %441 +%434 = OpAccessChain %429 %413 %347 +%435 = OpLoad %8 %434 +%436 = OpConvertUToF %5 %435 +%437 = OpFMul %5 %424 %436 +%438 = OpFAdd %5 %433 %437 +%439 = OpConvertFToU %8 %438 OpLine %3 168 17 -%443 = OpAccessChain %432 %416 %351 -%444 = OpLoad %8 %443 -%445 = OpIAdd %8 %442 %444 +%440 = OpAccessChain %429 %413 %348 +%441 = OpLoad %8 %440 +%442 = OpIAdd %8 %439 %441 OpLine %3 170 12 -%446 = OpCompositeConstruct %21 %445 %431 %427 -%447 = OpCompositeExtract %8 %446 0 -OpStore %408 %447 -%448 = OpCompositeExtract %7 %446 1 -OpStore %410 %448 -%449 = OpCompositeExtract %6 %446 2 -OpStore %412 %449 +%443 = OpCompositeConstruct %21 %442 %428 %425 +%444 = OpCompositeExtract %8 %443 0 +OpStore %405 %444 +%445 = OpCompositeExtract %7 %443 1 +OpStore %407 %445 +%446 = OpCompositeExtract %6 %443 2 +OpStore %409 %446 OpReturn OpFunctionEnd -%464 = OpFunction %2 None %345 -%452 = OpLabel -%450 = OpVariable %206 Function %207 -%451 = OpVariable %210 Function %211 -%455 = OpLoad %8 %454 -%458 = OpLoad %7 %456 -%461 = OpLoad %6 %459 -%453 = OpCompositeConstruct %21 %455 %458 %461 -%465 = OpAccessChain %415 %36 %131 -OpBranch %467 -%467 = OpLabel +%459 = OpFunction %2 None %342 +%447 = OpLabel +%462 = OpVariable %212 Function %76 +%463 = OpVariable %215 Function %136 +%450 = OpLoad %8 %449 +%453 = OpLoad %7 %451 +%456 = OpLoad %6 %454 +%448 = OpCompositeConstruct %21 %450 %453 %456 +%460 = OpAccessChain %412 %36 %136 +OpBranch %464 +%464 = OpLabel OpLine %3 181 17 -%468 = OpCompositeExtract %6 %453 2 -%469 = OpCompositeExtract %5 %468 0 +%465 = OpCompositeExtract %6 %448 2 +%466 = OpCompositeExtract %5 %465 0 OpLine %3 181 17 -%470 = OpAccessChain %432 %465 %350 -%471 = OpLoad %8 %470 -%472 = OpConvertUToF %5 %471 -%473 = OpFMul %5 %469 %472 -%474 = OpCompositeExtract %6 %453 2 -%475 = OpCompositeExtract %5 %474 1 +%467 = OpAccessChain %429 %460 %347 +%468 = OpLoad %8 %467 +%469 = OpConvertUToF %5 %468 +%470 = OpFMul %5 %466 %469 +%471 = OpCompositeExtract %6 %448 2 +%472 = OpCompositeExtract %5 %471 1 OpLine %3 181 70 -%476 = OpAccessChain %432 %465 %350 -%477 = OpLoad %8 %476 +%473 = OpAccessChain %429 %460 %347 +%474 = OpLoad %8 %473 OpLine %3 181 13 -%478 = OpAccessChain %432 %465 %350 -%479 = OpLoad %8 %478 -%480 = OpIMul %8 %477 %479 -%481 = OpConvertUToF %5 %480 -%482 = OpFMul %5 %475 %481 -%483 = OpFAdd %5 %473 %482 -%484 = OpConvertFToU %8 %483 +%475 = OpAccessChain %429 %460 %347 +%476 = OpLoad %8 %475 +%477 = OpIMul %8 %474 %476 +%478 = OpConvertUToF %5 %477 +%479 = OpFMul %5 %472 %478 +%480 = OpFAdd %5 %470 %479 +%481 = OpConvertFToU %8 %480 OpLine %3 181 13 -%485 = OpAccessChain %432 %465 %351 -%486 = OpLoad %8 %485 -%487 = OpIAdd %8 %484 %486 +%482 = OpAccessChain %429 %460 %348 +%483 = OpLoad %8 %482 +%484 = OpIAdd %8 %481 %483 OpLine %3 182 32 -%488 = OpConvertUToF %5 %487 +%485 = OpConvertUToF %5 %484 OpLine %3 182 22 -%489 = OpFDiv %5 %488 %466 -%490 = OpExtInst %5 %1 Floor %489 -%491 = OpConvertFToU %8 %490 +%486 = OpFDiv %5 %485 %461 +%487 = OpExtInst %5 %1 Floor %486 +%488 = OpConvertFToU %8 %487 OpLine %3 183 22 -%492 = OpUMod %8 %487 %348 +%489 = OpUMod %8 %484 %345 OpLine %3 185 36 -%493 = OpAccessChain %354 %465 %131 -%494 = OpLoad %10 %493 +%490 = OpAccessChain %351 %460 %136 +%491 = OpLoad %10 %490 OpLine %3 185 57 -%495 = OpAccessChain %357 %465 %122 -%496 = OpLoad %11 %495 +%492 = OpAccessChain %354 %460 %127 +%493 = OpLoad %11 %492 OpLine %3 185 13 -%497 = OpFunctionCall %6 %302 %491 %494 %496 +%494 = OpFunctionCall %6 %299 %488 %491 %493 OpLine %3 186 31 -%498 = OpAccessChain %363 %465 %349 -%499 = OpLoad %6 %498 +%495 = OpAccessChain %360 %460 %346 +%496 = OpLoad %6 %495 OpLine %3 186 13 -%500 = OpFunctionCall %14 %269 %497 %499 -OpLine %3 188 5 -OpStore %450 %83 +%497 = OpFunctionCall %14 %266 %494 %496 OpLine %3 190 5 -OpSelectionMerge %501 None -OpSwitch %492 %508 0 %502 1 %503 2 %504 3 %505 4 %506 5 %507 -%502 = OpLabel +OpSelectionMerge %498 None +OpSwitch %489 %505 0 %499 1 %500 2 %501 3 %502 4 %503 5 %504 +%499 = OpLabel OpLine %3 191 37 -%509 = OpCompositeExtract %4 %500 0 -%510 = OpCompositeExtract %5 %509 0 +%506 = OpCompositeExtract %4 %497 0 +%507 = OpCompositeExtract %5 %506 0 OpLine %3 191 20 -OpStore %450 %510 -OpBranch %501 -%503 = OpLabel +OpStore %462 %507 +OpBranch %498 +%500 = OpLabel OpLine %3 192 37 -%511 = OpCompositeExtract %4 %500 0 -%512 = OpCompositeExtract %5 %511 1 +%508 = OpCompositeExtract %4 %497 0 +%509 = OpCompositeExtract %5 %508 1 OpLine %3 192 20 -OpStore %450 %512 -OpBranch %501 -%504 = OpLabel +OpStore %462 %509 +OpBranch %498 +%501 = OpLabel OpLine %3 193 37 -%513 = OpCompositeExtract %4 %500 0 -%514 = OpCompositeExtract %5 %513 2 +%510 = OpCompositeExtract %4 %497 0 +%511 = OpCompositeExtract %5 %510 2 OpLine %3 193 20 -OpStore %450 %514 -OpBranch %501 -%505 = OpLabel +OpStore %462 %511 +OpBranch %498 +%502 = OpLabel OpLine %3 194 37 -%515 = OpCompositeExtract %4 %500 1 -%516 = OpCompositeExtract %5 %515 0 +%512 = OpCompositeExtract %4 %497 1 +%513 = OpCompositeExtract %5 %512 0 OpLine %3 194 20 -OpStore %450 %516 -OpBranch %501 -%506 = OpLabel +OpStore %462 %513 +OpBranch %498 +%503 = OpLabel OpLine %3 195 37 -%517 = OpCompositeExtract %4 %500 1 -%518 = OpCompositeExtract %5 %517 1 +%514 = OpCompositeExtract %4 %497 1 +%515 = OpCompositeExtract %5 %514 1 OpLine %3 195 20 -OpStore %450 %518 -OpBranch %501 -%507 = OpLabel +OpStore %462 %515 +OpBranch %498 +%504 = OpLabel OpLine %3 196 37 -%519 = OpCompositeExtract %4 %500 1 -%520 = OpCompositeExtract %5 %519 2 +%516 = OpCompositeExtract %4 %497 1 +%517 = OpCompositeExtract %5 %516 2 OpLine %3 196 20 -OpStore %450 %520 -OpBranch %501 -%508 = OpLabel -OpBranch %501 -%501 = OpLabel +OpStore %462 %517 +OpBranch %498 +%505 = OpLabel +OpBranch %498 +%498 = OpLabel OpLine %3 200 15 -%521 = OpAccessChain %370 %465 %131 %131 -%522 = OpLoad %8 %521 -%523 = OpUDiv %8 %491 %522 -%524 = OpIAdd %8 %491 %523 +%518 = OpAccessChain %367 %460 %136 %136 +%519 = OpLoad %8 %518 +%520 = OpUDiv %8 %488 %519 +%521 = OpIAdd %8 %488 %520 OpLine %3 201 15 -%525 = OpIAdd %8 %524 %122 +%522 = OpIAdd %8 %521 %127 OpLine %3 202 15 -%526 = OpAccessChain %370 %465 %131 %131 -%527 = OpLoad %8 %526 -%528 = OpIAdd %8 %524 %527 +%523 = OpAccessChain %367 %460 %136 %136 +%524 = OpLoad %8 %523 +%525 = OpIAdd %8 %521 %524 OpLine %3 202 15 -%529 = OpIAdd %8 %528 %122 +%526 = OpIAdd %8 %525 %127 OpLine %3 203 15 -%530 = OpIAdd %8 %529 %122 -OpLine %3 205 5 -OpStore %451 %131 +%527 = OpIAdd %8 %526 %127 OpLine %3 206 5 -OpSelectionMerge %531 None -OpSwitch %492 %536 0 %532 3 %532 2 %533 4 %533 1 %534 5 %535 -%532 = OpLabel +OpSelectionMerge %528 None +OpSwitch %489 %533 0 %529 3 %529 2 %530 4 %530 1 %531 5 %532 +%529 = OpLabel OpLine %3 207 24 -OpStore %451 %524 -OpBranch %531 -%533 = OpLabel +OpStore %463 %521 +OpBranch %528 +%530 = OpLabel OpLine %3 208 24 -OpStore %451 %530 -OpBranch %531 -%534 = OpLabel +OpStore %463 %527 +OpBranch %528 +%531 = OpLabel OpLine %3 209 20 -OpStore %451 %529 -OpBranch %531 -%535 = OpLabel +OpStore %463 %526 +OpBranch %528 +%532 = OpLabel OpLine %3 210 20 -OpStore %451 %525 -OpBranch %531 -%536 = OpLabel -OpBranch %531 -%531 = OpLabel +OpStore %463 %522 +OpBranch %528 +%533 = OpLabel +OpBranch %528 +%528 = OpLabel OpLine %3 213 13 -%537 = OpCompositeExtract %8 %453 0 +%534 = OpCompositeExtract %8 %448 0 OpLine %3 213 5 -OpStore %451 %537 +OpStore %463 %534 OpLine %3 222 27 -%538 = OpLoad %5 %450 -%539 = OpBitcast %8 %538 +%535 = OpLoad %5 %462 +%536 = OpBitcast %8 %535 OpLine %3 223 12 -%540 = OpLoad %8 %451 -%541 = OpCompositeConstruct %22 %539 %540 -%542 = OpCompositeExtract %8 %541 0 -OpStore %462 %542 -%543 = OpCompositeExtract %8 %541 1 -OpStore %463 %543 +%537 = OpLoad %8 %463 +%538 = OpCompositeConstruct %22 %536 %537 +%539 = OpCompositeExtract %8 %538 0 +OpStore %457 %539 +%540 = OpCompositeExtract %8 %538 1 +OpStore %458 %540 OpReturn OpFunctionEnd -%555 = OpFunction %2 None %345 -%544 = OpLabel -%548 = OpLoad %4 %546 -%550 = OpLoad %4 %549 -%545 = OpCompositeConstruct %14 %548 %550 -%557 = OpAccessChain %556 %39 %131 -OpBranch %558 -%558 = OpLabel +%552 = OpFunction %2 None %342 +%541 = OpLabel +%545 = OpLoad %4 %543 +%547 = OpLoad %4 %546 +%542 = OpCompositeConstruct %14 %545 %547 +%554 = OpAccessChain %553 %39 %136 +OpBranch %555 +%555 = OpLabel OpLine %3 254 25 -%560 = OpAccessChain %559 %557 %122 -%561 = OpLoad %23 %560 -%562 = OpCompositeExtract %4 %545 0 +%557 = OpAccessChain %556 %554 %127 +%558 = OpLoad %23 %557 +%559 = OpCompositeExtract %4 %542 0 OpLine %3 254 25 -%563 = OpCompositeConstruct %7 %562 %56 -%564 = OpMatrixTimesVector %7 %561 %563 +%560 = OpCompositeConstruct %7 %559 %56 +%561 = OpMatrixTimesVector %7 %558 %560 OpLine %3 255 18 -%565 = OpCompositeExtract %4 %545 1 +%562 = OpCompositeExtract %4 %542 1 OpLine %3 256 12 -%566 = OpCompositeExtract %4 %545 0 -%567 = OpCompositeConstruct %26 %564 %565 %566 -%568 = OpCompositeExtract %7 %567 0 -OpStore %551 %568 -%569 = OpCompositeExtract %4 %567 1 -OpStore %552 %569 -%570 = OpCompositeExtract %4 %567 2 -OpStore %554 %570 +%563 = OpCompositeExtract %4 %542 0 +%564 = OpCompositeConstruct %26 %561 %562 %563 +%565 = OpCompositeExtract %7 %564 0 +OpStore %548 %565 +%566 = OpCompositeExtract %4 %564 1 +OpStore %549 %566 +%567 = OpCompositeExtract %4 %564 2 +OpStore %551 %567 OpReturn OpFunctionEnd -%581 = OpFunction %2 None %345 -%572 = OpLabel -%571 = OpVariable %73 Function %74 -%575 = OpLoad %7 %574 -%577 = OpLoad %4 %576 -%579 = OpLoad %4 %578 -%573 = OpCompositeConstruct %26 %575 %577 %579 -%582 = OpAccessChain %556 %39 %131 -%584 = OpAccessChain %583 %42 %131 -OpBranch %587 -%587 = OpLabel +%577 = OpFunction %2 None %342 +%568 = OpLabel +%586 = OpVariable %99 Function %587 +%571 = OpLoad %7 %570 +%573 = OpLoad %4 %572 +%575 = OpLoad %4 %574 +%569 = OpCompositeConstruct %26 %571 %573 %575 +%578 = OpAccessChain %553 %39 %136 +%580 = OpAccessChain %579 %42 %136 +OpBranch %588 +%588 = OpLabel OpLine %3 278 28 -%588 = OpCompositeConstruct %4 %83 %83 %83 OpLine %3 278 17 -%589 = OpCompositeConstruct %4 %271 %271 %271 -%590 = OpCompositeExtract %4 %573 2 -%591 = OpExtInst %4 %1 Fract %590 -%592 = OpExtInst %4 %1 SmoothStep %588 %589 %591 +%589 = OpCompositeExtract %4 %569 2 +%590 = OpExtInst %4 %1 Fract %589 +%591 = OpExtInst %4 %1 SmoothStep %83 %581 %590 OpLine %3 278 5 -OpStore %571 %592 +OpStore %586 %591 OpLine %3 279 17 -%593 = OpCompositeConstruct %4 %84 %271 %585 OpLine %3 279 13 -%594 = OpCompositeConstruct %4 %586 %586 %586 -%595 = OpAccessChain %121 %571 %131 -%596 = OpLoad %5 %595 -%597 = OpAccessChain %121 %571 %122 +%592 = OpAccessChain %126 %586 %136 +%593 = OpLoad %5 %592 +%594 = OpAccessChain %126 %586 %127 +%595 = OpLoad %5 %594 +%596 = OpFMul %5 %593 %595 +%597 = OpAccessChain %126 %586 %346 %598 = OpLoad %5 %597 %599 = OpFMul %5 %596 %598 -%600 = OpAccessChain %121 %571 %349 -%601 = OpLoad %5 %600 -%602 = OpFMul %5 %599 %601 -%603 = OpCompositeConstruct %4 %602 %602 %602 -%604 = OpExtInst %4 %1 FMix %593 %594 %603 +%600 = OpCompositeConstruct %4 %599 %599 %599 +%601 = OpExtInst %4 %1 FMix %583 %585 %600 OpLine %3 279 5 -OpStore %571 %604 +OpStore %586 %601 OpLine %3 282 25 -%606 = OpAccessChain %605 %584 %122 -%607 = OpLoad %4 %606 -%608 = OpVectorTimesScalar %4 %607 %271 +%603 = OpAccessChain %602 %580 %127 +%604 = OpLoad %4 %603 +%605 = OpVectorTimesScalar %4 %604 %268 OpLine %3 284 21 -%609 = OpAccessChain %605 %584 %131 -%610 = OpLoad %4 %609 -%611 = OpCompositeExtract %4 %573 2 -%612 = OpFSub %4 %610 %611 -%613 = OpExtInst %4 %1 Normalize %612 +%606 = OpAccessChain %602 %580 %136 +%607 = OpLoad %4 %606 +%608 = OpCompositeExtract %4 %569 2 +%609 = OpFSub %4 %607 %608 +%610 = OpExtInst %4 %1 Normalize %609 OpLine %3 285 20 -%615 = OpAccessChain %614 %582 %131 -%616 = OpLoad %7 %615 -%617 = OpVectorShuffle %4 %616 %616 0 1 2 -%618 = OpCompositeExtract %4 %573 2 -%619 = OpFSub %4 %617 %618 -%620 = OpExtInst %4 %1 Normalize %619 +%612 = OpAccessChain %611 %578 %136 +%613 = OpLoad %7 %612 +%614 = OpVectorShuffle %4 %613 %613 0 1 2 +%615 = OpCompositeExtract %4 %569 2 +%616 = OpFSub %4 %614 %615 +%617 = OpExtInst %4 %1 Normalize %616 OpLine %3 286 20 -%621 = OpFAdd %4 %620 %613 -%622 = OpExtInst %4 %1 Normalize %621 +%618 = OpFAdd %4 %617 %610 +%619 = OpExtInst %4 %1 Normalize %618 OpLine %3 288 32 -%623 = OpCompositeExtract %4 %573 1 -%624 = OpDot %5 %623 %613 +%620 = OpCompositeExtract %4 %569 1 +%621 = OpDot %5 %620 %610 OpLine %3 288 28 -%625 = OpExtInst %5 %1 FMax %624 %83 +%622 = OpExtInst %5 %1 FMax %621 %76 OpLine %3 289 25 -%626 = OpAccessChain %605 %584 %122 -%627 = OpLoad %4 %626 -%628 = OpVectorTimesScalar %4 %627 %625 +%623 = OpAccessChain %602 %580 %127 +%624 = OpLoad %4 %623 +%625 = OpVectorTimesScalar %4 %624 %622 OpLine %3 291 37 -%629 = OpCompositeExtract %4 %573 1 -%630 = OpDot %5 %629 %622 +%626 = OpCompositeExtract %4 %569 1 +%627 = OpDot %5 %626 %619 OpLine %3 291 33 -%631 = OpExtInst %5 %1 FMax %630 %83 +%628 = OpExtInst %5 %1 FMax %627 %76 OpLine %3 291 29 -%632 = OpExtInst %5 %1 Pow %631 %322 +%629 = OpExtInst %5 %1 Pow %628 %319 OpLine %3 292 26 -%633 = OpAccessChain %605 %584 %122 -%634 = OpLoad %4 %633 -%635 = OpVectorTimesScalar %4 %634 %632 +%630 = OpAccessChain %602 %580 %127 +%631 = OpLoad %4 %630 +%632 = OpVectorTimesScalar %4 %631 %629 OpLine %3 294 18 -%636 = OpFAdd %4 %608 %628 -%637 = OpFAdd %4 %636 %635 -%638 = OpLoad %4 %571 -%639 = OpFMul %4 %637 %638 +%633 = OpFAdd %4 %605 %625 +%634 = OpFAdd %4 %633 %632 +%635 = OpLoad %4 %586 +%636 = OpFMul %4 %634 %635 OpLine %3 296 12 -%640 = OpCompositeConstruct %7 %639 %56 -OpStore %580 %640 +%637 = OpCompositeConstruct %7 %636 %56 +OpStore %576 %637 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/dualsource.spvasm b/tests/out/spv/dualsource.spvasm index 0fba6bb269..a5c692b4c4 100644 --- a/tests/out/spv/dualsource.spvasm +++ b/tests/out/spv/dualsource.spvasm @@ -1,55 +1,52 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 35 +; Bound: 34 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %17 "main" %11 %14 %16 -OpExecutionMode %17 OriginUpperLeft +OpEntryPoint Fragment %13 "main" %7 %10 %12 +OpExecutionMode %13 OriginUpperLeft OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 -OpDecorate %11 BuiltIn FragCoord -OpDecorate %14 Location 0 -OpDecorate %16 Location 0 -OpDecorate %16 Index 1 +OpDecorate %7 BuiltIn FragCoord +OpDecorate %10 Location 0 +OpDecorate %12 Location 0 +OpDecorate %12 Index 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 %5 = OpTypeStruct %3 %3 -%7 = OpTypePointer Function %3 -%8 = OpConstantNull %3 -%12 = OpTypePointer Input %3 -%11 = OpVariable %12 Input -%15 = OpTypePointer Output %3 -%14 = OpVariable %15 Output -%16 = OpVariable %15 Output -%18 = OpTypeFunction %2 -%19 = OpConstant %4 0.4 -%20 = OpConstant %4 0.3 -%21 = OpConstant %4 0.2 -%22 = OpConstant %4 0.1 -%23 = OpConstant %4 0.9 -%24 = OpConstant %4 0.8 -%25 = OpConstant %4 0.7 -%26 = OpConstant %4 0.6 -%17 = OpFunction %2 None %18 -%10 = OpLabel -%6 = OpVariable %7 Function %8 -%9 = OpVariable %7 Function %8 -%13 = OpLoad %3 %11 -OpBranch %27 -%27 = OpLabel -%28 = OpCompositeConstruct %3 %19 %20 %21 %22 -OpStore %6 %28 -%29 = OpCompositeConstruct %3 %23 %24 %25 %26 -OpStore %9 %29 -%30 = OpLoad %3 %6 -%31 = OpLoad %3 %9 -%32 = OpCompositeConstruct %5 %30 %31 -%33 = OpCompositeExtract %3 %32 0 -OpStore %14 %33 -%34 = OpCompositeExtract %3 %32 1 -OpStore %16 %34 +%8 = OpTypePointer Input %3 +%7 = OpVariable %8 Input +%11 = OpTypePointer Output %3 +%10 = OpVariable %11 Output +%12 = OpVariable %11 Output +%14 = OpTypeFunction %2 +%15 = OpConstant %4 0.4 +%16 = OpConstant %4 0.3 +%17 = OpConstant %4 0.2 +%18 = OpConstant %4 0.1 +%19 = OpConstantComposite %3 %15 %16 %17 %18 +%20 = OpConstant %4 0.9 +%21 = OpConstant %4 0.8 +%22 = OpConstant %4 0.7 +%23 = OpConstant %4 0.6 +%24 = OpConstantComposite %3 %20 %21 %22 %23 +%26 = OpTypePointer Function %3 +%13 = OpFunction %2 None %14 +%6 = OpLabel +%25 = OpVariable %26 Function %19 +%27 = OpVariable %26 Function %24 +%9 = OpLoad %3 %7 +OpBranch %28 +%28 = OpLabel +%29 = OpLoad %3 %25 +%30 = OpLoad %3 %27 +%31 = OpCompositeConstruct %5 %29 %30 +%32 = OpCompositeExtract %3 %31 0 +OpStore %10 %32 +%33 = OpCompositeExtract %3 %31 1 +OpStore %12 %33 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/extra.spvasm b/tests/out/spv/extra.spvasm index 93de9e8d99..9c434a8ce2 100644 --- a/tests/out/spv/extra.spvasm +++ b/tests/out/spv/extra.spvasm @@ -40,37 +40,37 @@ OpDecorate %21 Location 0 %25 = OpTypePointer PushConstant %6 %26 = OpConstant %3 0 %28 = OpConstant %8 1.0 -%31 = OpTypePointer PushConstant %3 -%34 = OpTypeBool -%40 = OpTypeVector %8 3 +%29 = OpTypeVector %8 3 +%30 = OpConstantComposite %29 %28 %28 %28 +%33 = OpTypePointer PushConstant %3 +%36 = OpTypeBool %23 = OpFunction %2 None %24 %13 = OpLabel %17 = OpLoad %7 %15 %20 = OpLoad %3 %18 %14 = OpCompositeConstruct %9 %17 %20 %27 = OpAccessChain %25 %10 %26 -OpBranch %29 -%29 = OpLabel -%30 = OpCompositeExtract %3 %14 1 -%32 = OpAccessChain %31 %27 %26 -%33 = OpLoad %3 %32 -%35 = OpIEqual %34 %30 %33 -OpSelectionMerge %36 None -OpBranchConditional %35 %37 %38 -%37 = OpLabel -%39 = OpCompositeExtract %7 %14 0 -OpStore %21 %39 +OpBranch %31 +%31 = OpLabel +%32 = OpCompositeExtract %3 %14 1 +%34 = OpAccessChain %33 %27 %26 +%35 = OpLoad %3 %34 +%37 = OpIEqual %36 %32 %35 +OpSelectionMerge %38 None +OpBranchConditional %37 %39 %40 +%39 = OpLabel +%41 = OpCompositeExtract %7 %14 0 +OpStore %21 %41 OpReturn -%38 = OpLabel -%41 = OpCompositeConstruct %40 %28 %28 %28 +%40 = OpLabel %42 = OpCompositeExtract %7 %14 0 -%43 = OpVectorShuffle %40 %42 %42 0 1 2 -%44 = OpFSub %40 %41 %43 +%43 = OpVectorShuffle %29 %42 %42 0 1 2 +%44 = OpFSub %29 %30 %43 %45 = OpCompositeExtract %7 %14 0 %46 = OpCompositeExtract %8 %45 3 %47 = OpCompositeConstruct %7 %44 %46 OpStore %21 %47 OpReturn -%36 = OpLabel +%38 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/fragment-output.spvasm b/tests/out/spv/fragment-output.spvasm index 0a6541799d..c61ffb8258 100644 --- a/tests/out/spv/fragment-output.spvasm +++ b/tests/out/spv/fragment-output.spvasm @@ -5,10 +5,10 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %33 "main_vec4vec3" %21 %23 %25 %27 %29 %31 -OpEntryPoint Fragment %85 "main_vec2scalar" %73 %75 %77 %79 %81 %83 -OpExecutionMode %33 OriginUpperLeft -OpExecutionMode %85 OriginUpperLeft +OpEntryPoint Fragment %30 "main_vec4vec3" %18 %20 %22 %24 %26 %28 +OpEntryPoint Fragment %82 "main_vec2scalar" %70 %72 %74 %76 %78 %80 +OpExecutionMode %30 OriginUpperLeft +OpExecutionMode %82 OriginUpperLeft OpMemberDecorate %12 0 Offset 0 OpMemberDecorate %12 1 Offset 16 OpMemberDecorate %12 2 Offset 32 @@ -21,18 +21,18 @@ OpMemberDecorate %16 2 Offset 16 OpMemberDecorate %16 3 Offset 24 OpMemberDecorate %16 4 Offset 28 OpMemberDecorate %16 5 Offset 32 -OpDecorate %21 Location 0 -OpDecorate %23 Location 1 -OpDecorate %25 Location 2 -OpDecorate %27 Location 3 -OpDecorate %29 Location 4 -OpDecorate %31 Location 5 -OpDecorate %73 Location 0 -OpDecorate %75 Location 1 -OpDecorate %77 Location 2 -OpDecorate %79 Location 3 -OpDecorate %81 Location 4 -OpDecorate %83 Location 5 +OpDecorate %18 Location 0 +OpDecorate %20 Location 1 +OpDecorate %22 Location 2 +OpDecorate %24 Location 3 +OpDecorate %26 Location 4 +OpDecorate %28 Location 5 +OpDecorate %70 Location 0 +OpDecorate %72 Location 1 +OpDecorate %74 Location 2 +OpDecorate %76 Location 3 +OpDecorate %78 Location 4 +OpDecorate %80 Location 5 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -48,125 +48,125 @@ OpDecorate %83 Location 5 %14 = OpTypeVector %6 2 %15 = OpTypeVector %8 2 %16 = OpTypeStruct %13 %14 %15 %4 %6 %8 -%18 = OpTypePointer Function %12 -%19 = OpConstantNull %12 -%22 = OpTypePointer Output %3 -%21 = OpVariable %22 Output -%24 = OpTypePointer Output %5 -%23 = OpVariable %24 Output -%26 = OpTypePointer Output %7 -%25 = OpVariable %26 Output -%28 = OpTypePointer Output %9 -%27 = OpVariable %28 Output -%30 = OpTypePointer Output %10 -%29 = OpVariable %30 Output -%32 = OpTypePointer Output %11 -%31 = OpVariable %32 Output -%34 = OpTypeFunction %2 -%35 = OpConstant %4 0.0 -%36 = OpConstant %6 0 -%37 = OpConstant %8 0 -%39 = OpTypePointer Function %3 -%42 = OpTypePointer Function %5 -%44 = OpConstant %8 1 -%46 = OpTypePointer Function %7 -%48 = OpConstant %8 2 -%50 = OpTypePointer Function %9 -%52 = OpConstant %8 3 -%54 = OpTypePointer Function %10 -%56 = OpConstant %8 4 -%58 = OpTypePointer Function %11 +%19 = OpTypePointer Output %3 +%18 = OpVariable %19 Output +%21 = OpTypePointer Output %5 +%20 = OpVariable %21 Output +%23 = OpTypePointer Output %7 +%22 = OpVariable %23 Output +%25 = OpTypePointer Output %9 +%24 = OpVariable %25 Output +%27 = OpTypePointer Output %10 +%26 = OpVariable %27 Output +%29 = OpTypePointer Output %11 +%28 = OpVariable %29 Output +%31 = OpTypeFunction %2 +%32 = OpConstant %4 0.0 +%33 = OpConstantComposite %3 %32 %32 %32 %32 +%34 = OpConstant %6 0 +%35 = OpConstantComposite %5 %34 %34 %34 %34 +%36 = OpConstant %8 0 +%37 = OpConstantComposite %7 %36 %36 %36 %36 +%38 = OpConstantComposite %9 %32 %32 %32 +%39 = OpConstantComposite %10 %34 %34 %34 +%40 = OpConstantComposite %11 %36 %36 %36 +%42 = OpTypePointer Function %12 +%43 = OpConstantNull %12 +%45 = OpTypePointer Function %3 +%47 = OpTypePointer Function %5 +%48 = OpConstant %8 1 +%50 = OpTypePointer Function %7 +%51 = OpConstant %8 2 +%53 = OpTypePointer Function %9 +%54 = OpConstant %8 3 +%56 = OpTypePointer Function %10 +%57 = OpConstant %8 4 +%59 = OpTypePointer Function %11 %60 = OpConstant %8 5 -%70 = OpTypePointer Function %16 -%71 = OpConstantNull %16 -%74 = OpTypePointer Output %13 -%73 = OpVariable %74 Output -%76 = OpTypePointer Output %14 -%75 = OpVariable %76 Output -%78 = OpTypePointer Output %15 -%77 = OpVariable %78 Output -%80 = OpTypePointer Output %4 -%79 = OpVariable %80 Output -%82 = OpTypePointer Output %6 -%81 = OpVariable %82 Output -%84 = OpTypePointer Output %8 -%83 = OpVariable %84 Output -%87 = OpTypePointer Function %13 -%90 = OpTypePointer Function %14 -%93 = OpTypePointer Function %15 +%71 = OpTypePointer Output %13 +%70 = OpVariable %71 Output +%73 = OpTypePointer Output %14 +%72 = OpVariable %73 Output +%75 = OpTypePointer Output %15 +%74 = OpVariable %75 Output +%77 = OpTypePointer Output %4 +%76 = OpVariable %77 Output +%79 = OpTypePointer Output %6 +%78 = OpVariable %79 Output +%81 = OpTypePointer Output %8 +%80 = OpVariable %81 Output +%83 = OpConstantComposite %13 %32 %32 +%84 = OpConstantComposite %14 %34 %34 +%85 = OpConstantComposite %15 %36 %36 +%87 = OpTypePointer Function %16 +%88 = OpConstantNull %16 +%90 = OpTypePointer Function %13 +%92 = OpTypePointer Function %14 +%94 = OpTypePointer Function %15 %96 = OpTypePointer Function %4 %98 = OpTypePointer Function %6 %100 = OpTypePointer Function %8 -%33 = OpFunction %2 None %34 -%20 = OpLabel -%17 = OpVariable %18 Function %19 -OpBranch %38 -%38 = OpLabel -%40 = OpCompositeConstruct %3 %35 %35 %35 %35 -%41 = OpAccessChain %39 %17 %37 -OpStore %41 %40 -%43 = OpCompositeConstruct %5 %36 %36 %36 %36 -%45 = OpAccessChain %42 %17 %44 -OpStore %45 %43 -%47 = OpCompositeConstruct %7 %37 %37 %37 %37 -%49 = OpAccessChain %46 %17 %48 -OpStore %49 %47 -%51 = OpCompositeConstruct %9 %35 %35 %35 -%53 = OpAccessChain %50 %17 %52 -OpStore %53 %51 -%55 = OpCompositeConstruct %10 %36 %36 %36 -%57 = OpAccessChain %54 %17 %56 -OpStore %57 %55 -%59 = OpCompositeConstruct %11 %37 %37 %37 -%61 = OpAccessChain %58 %17 %60 -OpStore %61 %59 -%62 = OpLoad %12 %17 +%30 = OpFunction %2 None %31 +%17 = OpLabel +%41 = OpVariable %42 Function %43 +OpBranch %44 +%44 = OpLabel +%46 = OpAccessChain %45 %41 %36 +OpStore %46 %33 +%49 = OpAccessChain %47 %41 %48 +OpStore %49 %35 +%52 = OpAccessChain %50 %41 %51 +OpStore %52 %37 +%55 = OpAccessChain %53 %41 %54 +OpStore %55 %38 +%58 = OpAccessChain %56 %41 %57 +OpStore %58 %39 +%61 = OpAccessChain %59 %41 %60 +OpStore %61 %40 +%62 = OpLoad %12 %41 %63 = OpCompositeExtract %3 %62 0 -OpStore %21 %63 +OpStore %18 %63 %64 = OpCompositeExtract %5 %62 1 -OpStore %23 %64 +OpStore %20 %64 %65 = OpCompositeExtract %7 %62 2 -OpStore %25 %65 +OpStore %22 %65 %66 = OpCompositeExtract %9 %62 3 -OpStore %27 %66 +OpStore %24 %66 %67 = OpCompositeExtract %10 %62 4 -OpStore %29 %67 +OpStore %26 %67 %68 = OpCompositeExtract %11 %62 5 -OpStore %31 %68 +OpStore %28 %68 OpReturn OpFunctionEnd -%85 = OpFunction %2 None %34 -%72 = OpLabel -%69 = OpVariable %70 Function %71 -OpBranch %86 -%86 = OpLabel -%88 = OpCompositeConstruct %13 %35 %35 -%89 = OpAccessChain %87 %69 %37 -OpStore %89 %88 -%91 = OpCompositeConstruct %14 %36 %36 -%92 = OpAccessChain %90 %69 %44 -OpStore %92 %91 -%94 = OpCompositeConstruct %15 %37 %37 -%95 = OpAccessChain %93 %69 %48 -OpStore %95 %94 -%97 = OpAccessChain %96 %69 %52 -OpStore %97 %35 -%99 = OpAccessChain %98 %69 %56 -OpStore %99 %36 -%101 = OpAccessChain %100 %69 %60 -OpStore %101 %37 -%102 = OpLoad %16 %69 +%82 = OpFunction %2 None %31 +%69 = OpLabel +%86 = OpVariable %87 Function %88 +OpBranch %89 +%89 = OpLabel +%91 = OpAccessChain %90 %86 %36 +OpStore %91 %83 +%93 = OpAccessChain %92 %86 %48 +OpStore %93 %84 +%95 = OpAccessChain %94 %86 %51 +OpStore %95 %85 +%97 = OpAccessChain %96 %86 %54 +OpStore %97 %32 +%99 = OpAccessChain %98 %86 %57 +OpStore %99 %34 +%101 = OpAccessChain %100 %86 %60 +OpStore %101 %36 +%102 = OpLoad %16 %86 %103 = OpCompositeExtract %13 %102 0 -OpStore %73 %103 +OpStore %70 %103 %104 = OpCompositeExtract %14 %102 1 -OpStore %75 %104 +OpStore %72 %104 %105 = OpCompositeExtract %15 %102 2 -OpStore %77 %105 +OpStore %74 %105 %106 = OpCompositeExtract %4 %102 3 -OpStore %79 %106 +OpStore %76 %106 %107 = OpCompositeExtract %6 %102 4 -OpStore %81 %107 +OpStore %78 %107 %108 = OpCompositeExtract %8 %102 5 -OpStore %83 %108 +OpStore %80 %108 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/functions.spvasm b/tests/out/spv/functions.spvasm index a7338a932d..463f7da0b2 100644 --- a/tests/out/spv/functions.spvasm +++ b/tests/out/spv/functions.spvasm @@ -1,94 +1,91 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 78 +; Bound: 75 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %73 "main" -OpExecutionMode %73 LocalSize 1 1 1 +OpEntryPoint GLCompute %70 "main" +OpExecutionMode %70 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 2 %5 = OpTypeInt 32 1 %8 = OpTypeFunction %3 %9 = OpConstant %4 2.0 -%10 = OpConstant %4 0.5 -%18 = OpTypeFunction %5 -%19 = OpConstant %5 1 -%20 = OpTypeInt 32 0 -%21 = OpConstant %20 1 -%22 = OpConstant %5 4 -%23 = OpConstant %5 2 -%25 = OpTypeVector %5 2 -%29 = OpConstantNull %5 -%37 = OpTypeVector %20 3 -%41 = OpConstantNull %20 -%53 = OpTypeVector %5 4 -%74 = OpTypeFunction %2 +%10 = OpConstantComposite %3 %9 %9 +%11 = OpConstant %4 0.5 +%12 = OpConstantComposite %3 %11 %11 +%17 = OpTypeFunction %5 +%18 = OpConstant %5 1 +%19 = OpTypeVector %5 2 +%20 = OpConstantComposite %19 %18 %18 +%21 = OpTypeInt 32 0 +%22 = OpConstant %21 1 +%23 = OpTypeVector %21 3 +%24 = OpConstantComposite %23 %22 %22 %22 +%25 = OpConstant %5 4 +%26 = OpTypeVector %5 4 +%27 = OpConstantComposite %26 %25 %25 %25 %25 +%28 = OpConstant %5 2 +%29 = OpConstantComposite %26 %28 %28 %28 %28 +%32 = OpConstantNull %5 +%41 = OpConstantNull %21 +%71 = OpTypeFunction %2 %7 = OpFunction %3 None %8 %6 = OpLabel -OpBranch %11 -%11 = OpLabel -%12 = OpCompositeConstruct %3 %9 %9 -%13 = OpCompositeConstruct %3 %10 %10 -%14 = OpCompositeConstruct %3 %10 %10 -%15 = OpExtInst %3 %1 Fma %12 %13 %14 -OpReturnValue %15 +OpBranch %13 +%13 = OpLabel +%14 = OpExtInst %3 %1 Fma %10 %12 %12 +OpReturnValue %14 OpFunctionEnd -%17 = OpFunction %5 None %18 -%16 = OpLabel -OpBranch %24 -%24 = OpLabel -%26 = OpCompositeConstruct %25 %19 %19 -%27 = OpCompositeConstruct %25 %19 %19 -%30 = OpCompositeExtract %5 %26 0 -%31 = OpCompositeExtract %5 %27 0 -%32 = OpIMul %5 %30 %31 -%33 = OpIAdd %5 %29 %32 -%34 = OpCompositeExtract %5 %26 1 -%35 = OpCompositeExtract %5 %27 1 -%36 = OpIMul %5 %34 %35 -%28 = OpIAdd %5 %33 %36 -%38 = OpCompositeConstruct %37 %21 %21 %21 -%39 = OpCompositeConstruct %37 %21 %21 %21 -%42 = OpCompositeExtract %20 %38 0 -%43 = OpCompositeExtract %20 %39 0 -%44 = OpIMul %20 %42 %43 -%45 = OpIAdd %20 %41 %44 -%46 = OpCompositeExtract %20 %38 1 -%47 = OpCompositeExtract %20 %39 1 -%48 = OpIMul %20 %46 %47 -%49 = OpIAdd %20 %45 %48 -%50 = OpCompositeExtract %20 %38 2 -%51 = OpCompositeExtract %20 %39 2 -%52 = OpIMul %20 %50 %51 -%40 = OpIAdd %20 %49 %52 -%54 = OpCompositeConstruct %53 %22 %22 %22 %22 -%55 = OpCompositeConstruct %53 %23 %23 %23 %23 -%57 = OpCompositeExtract %5 %54 0 -%58 = OpCompositeExtract %5 %55 0 -%59 = OpIMul %5 %57 %58 -%60 = OpIAdd %5 %29 %59 -%61 = OpCompositeExtract %5 %54 1 -%62 = OpCompositeExtract %5 %55 1 -%63 = OpIMul %5 %61 %62 -%64 = OpIAdd %5 %60 %63 -%65 = OpCompositeExtract %5 %54 2 -%66 = OpCompositeExtract %5 %55 2 -%67 = OpIMul %5 %65 %66 -%68 = OpIAdd %5 %64 %67 -%69 = OpCompositeExtract %5 %54 3 -%70 = OpCompositeExtract %5 %55 3 -%71 = OpIMul %5 %69 %70 -%56 = OpIAdd %5 %68 %71 -OpReturnValue %56 +%16 = OpFunction %5 None %17 +%15 = OpLabel +OpBranch %30 +%30 = OpLabel +%33 = OpCompositeExtract %5 %20 0 +%34 = OpCompositeExtract %5 %20 0 +%35 = OpIMul %5 %33 %34 +%36 = OpIAdd %5 %32 %35 +%37 = OpCompositeExtract %5 %20 1 +%38 = OpCompositeExtract %5 %20 1 +%39 = OpIMul %5 %37 %38 +%31 = OpIAdd %5 %36 %39 +%42 = OpCompositeExtract %21 %24 0 +%43 = OpCompositeExtract %21 %24 0 +%44 = OpIMul %21 %42 %43 +%45 = OpIAdd %21 %41 %44 +%46 = OpCompositeExtract %21 %24 1 +%47 = OpCompositeExtract %21 %24 1 +%48 = OpIMul %21 %46 %47 +%49 = OpIAdd %21 %45 %48 +%50 = OpCompositeExtract %21 %24 2 +%51 = OpCompositeExtract %21 %24 2 +%52 = OpIMul %21 %50 %51 +%40 = OpIAdd %21 %49 %52 +%54 = OpCompositeExtract %5 %27 0 +%55 = OpCompositeExtract %5 %29 0 +%56 = OpIMul %5 %54 %55 +%57 = OpIAdd %5 %32 %56 +%58 = OpCompositeExtract %5 %27 1 +%59 = OpCompositeExtract %5 %29 1 +%60 = OpIMul %5 %58 %59 +%61 = OpIAdd %5 %57 %60 +%62 = OpCompositeExtract %5 %27 2 +%63 = OpCompositeExtract %5 %29 2 +%64 = OpIMul %5 %62 %63 +%65 = OpIAdd %5 %61 %64 +%66 = OpCompositeExtract %5 %27 3 +%67 = OpCompositeExtract %5 %29 3 +%68 = OpIMul %5 %66 %67 +%53 = OpIAdd %5 %65 %68 +OpReturnValue %53 OpFunctionEnd -%73 = OpFunction %2 None %74 +%70 = OpFunction %2 None %71 +%69 = OpLabel +OpBranch %72 %72 = OpLabel -OpBranch %75 -%75 = OpLabel -%76 = OpFunctionCall %3 %7 -%77 = OpFunctionCall %5 %17 +%73 = OpFunctionCall %3 %7 +%74 = OpFunctionCall %5 %16 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/globals.spvasm b/tests/out/spv/globals.spvasm index 9050f944bb..4aa6a10ad5 100644 --- a/tests/out/spv/globals.spvasm +++ b/tests/out/spv/globals.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 177 +; Bound: 174 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %100 "main" %119 -OpExecutionMode %100 LocalSize 1 1 1 +OpEntryPoint GLCompute %93 "main" %116 +OpExecutionMode %93 LocalSize 1 1 1 OpDecorate %5 ArrayStride 4 OpMemberDecorate %9 0 Offset 0 OpMemberDecorate %9 1 Offset 12 @@ -48,7 +48,7 @@ OpDecorate %48 DescriptorSet 0 OpDecorate %48 Binding 7 OpDecorate %49 Block OpMemberDecorate %49 0 Offset 0 -OpDecorate %119 BuiltIn LocalInvocationId +OpDecorate %116 BuiltIn LocalInvocationId %2 = OpTypeVoid %3 = OpTypeBool %4 = OpTypeFloat 32 @@ -99,55 +99,53 @@ OpDecorate %119 BuiltIn LocalInvocationId %50 = OpTypePointer Uniform %49 %48 = OpVariable %50 Uniform %54 = OpTypeFunction %2 %8 -%57 = OpTypePointer Function %23 -%58 = OpConstantNull %23 -%61 = OpTypeFunction %2 -%62 = OpTypePointer StorageBuffer %9 -%63 = OpConstant %7 0 -%65 = OpConstant %4 1.0 -%66 = OpConstant %23 1 -%67 = OpConstant %4 2.0 -%68 = OpConstant %4 3.0 -%69 = OpConstantNull %24 +%58 = OpTypeFunction %2 +%59 = OpTypePointer StorageBuffer %9 +%60 = OpConstant %7 0 +%62 = OpConstant %4 1.0 +%63 = OpConstantComposite %8 %62 %62 %62 +%64 = OpConstant %23 1 +%65 = OpConstant %4 2.0 +%66 = OpConstant %4 3.0 +%67 = OpConstantNull %24 +%69 = OpTypePointer Function %23 %71 = OpTypePointer StorageBuffer %8 -%74 = OpTypePointer StorageBuffer %4 -%94 = OpTypePointer Function %4 -%95 = OpConstantNull %4 -%97 = OpTypePointer Function %3 -%98 = OpConstantNull %3 -%102 = OpTypePointer StorageBuffer %11 -%104 = OpTypePointer Uniform %13 -%106 = OpTypePointer Uniform %8 -%108 = OpTypePointer Uniform %15 -%110 = OpTypePointer Uniform %19 -%112 = OpTypePointer Uniform %22 -%114 = OpConstant %4 4.0 -%116 = OpConstantNull %5 -%117 = OpConstantNull %7 -%118 = OpTypeVector %7 3 -%120 = OpTypePointer Input %118 -%119 = OpVariable %120 Input -%122 = OpConstantNull %118 -%123 = OpTypeVector %3 3 -%128 = OpConstant %7 264 -%131 = OpTypePointer Workgroup %4 -%132 = OpTypePointer Uniform %21 -%133 = OpTypePointer Uniform %20 -%136 = OpTypePointer Uniform %17 -%137 = OpTypePointer Uniform %16 -%138 = OpTypePointer Uniform %12 -%143 = OpConstant %7 7 -%149 = OpConstant %7 6 -%151 = OpTypePointer StorageBuffer %10 -%152 = OpConstant %7 1 -%155 = OpConstant %7 5 -%157 = OpTypePointer Uniform %12 -%158 = OpTypePointer Uniform %4 -%159 = OpConstant %7 3 -%162 = OpConstant %7 4 -%164 = OpTypePointer StorageBuffer %4 -%175 = OpConstant %23 2 -%176 = OpConstant %7 256 +%73 = OpTypePointer StorageBuffer %4 +%95 = OpTypePointer StorageBuffer %11 +%97 = OpTypePointer Uniform %13 +%99 = OpTypePointer Uniform %8 +%101 = OpTypePointer Uniform %15 +%103 = OpTypePointer Uniform %19 +%105 = OpTypePointer Uniform %22 +%107 = OpConstant %4 4.0 +%109 = OpTypePointer Function %4 +%111 = OpTypePointer Function %3 +%113 = OpConstantNull %5 +%114 = OpConstantNull %7 +%115 = OpTypeVector %7 3 +%117 = OpTypePointer Input %115 +%116 = OpVariable %117 Input +%119 = OpConstantNull %115 +%120 = OpTypeVector %3 3 +%125 = OpConstant %7 264 +%128 = OpTypePointer Workgroup %4 +%129 = OpTypePointer Uniform %21 +%130 = OpTypePointer Uniform %20 +%133 = OpTypePointer Uniform %17 +%134 = OpTypePointer Uniform %16 +%135 = OpTypePointer Uniform %12 +%140 = OpConstant %7 7 +%146 = OpConstant %7 6 +%148 = OpTypePointer StorageBuffer %10 +%149 = OpConstant %7 1 +%152 = OpConstant %7 5 +%154 = OpTypePointer Uniform %12 +%155 = OpTypePointer Uniform %4 +%156 = OpConstant %7 3 +%159 = OpConstant %7 4 +%161 = OpTypePointer StorageBuffer %4 +%172 = OpConstant %23 2 +%173 = OpConstant %7 256 %53 = OpFunction %2 None %54 %52 = OpFunctionParameter %8 %51 = OpLabel @@ -155,104 +153,100 @@ OpBranch %55 %55 = OpLabel OpReturn OpFunctionEnd -%60 = OpFunction %2 None %61 -%59 = OpLabel -%56 = OpVariable %57 Function %58 -%64 = OpAccessChain %62 %30 %63 +%57 = OpFunction %2 None %58 +%56 = OpLabel +%68 = OpVariable %69 Function %64 +%61 = OpAccessChain %59 %30 %60 OpBranch %70 %70 = OpLabel -%72 = OpCompositeConstruct %8 %65 %65 %65 -%73 = OpAccessChain %71 %64 %63 -OpStore %73 %72 -OpStore %56 %66 -%75 = OpAccessChain %74 %64 %63 %63 +%72 = OpAccessChain %71 %61 %60 +OpStore %72 %63 +%74 = OpAccessChain %73 %61 %60 %60 +OpStore %74 %62 +%75 = OpAccessChain %73 %61 %60 %60 OpStore %75 %65 -%76 = OpAccessChain %74 %64 %63 %63 -OpStore %76 %67 -%77 = OpLoad %23 %56 -%78 = OpAccessChain %74 %64 %63 %77 -OpStore %78 %68 -%79 = OpLoad %9 %64 -%80 = OpCompositeExtract %8 %79 0 -%81 = OpCompositeExtract %8 %79 0 -%82 = OpVectorShuffle %10 %81 %81 2 0 -%83 = OpCompositeExtract %8 %79 0 -%84 = OpFunctionCall %2 %53 %83 -%85 = OpCompositeExtract %8 %79 0 -%86 = OpVectorTimesMatrix %8 %85 %69 -%87 = OpCompositeExtract %8 %79 0 -%88 = OpMatrixTimesVector %8 %69 %87 -%89 = OpCompositeExtract %8 %79 0 -%90 = OpVectorTimesScalar %8 %89 %67 -%91 = OpCompositeExtract %8 %79 0 -%92 = OpVectorTimesScalar %8 %91 %67 +%76 = OpLoad %23 %68 +%77 = OpAccessChain %73 %61 %60 %76 +OpStore %77 %66 +%78 = OpLoad %9 %61 +%79 = OpCompositeExtract %8 %78 0 +%80 = OpCompositeExtract %8 %78 0 +%81 = OpVectorShuffle %10 %80 %80 2 0 +%82 = OpCompositeExtract %8 %78 0 +%83 = OpFunctionCall %2 %53 %82 +%84 = OpCompositeExtract %8 %78 0 +%85 = OpVectorTimesMatrix %8 %84 %67 +%86 = OpCompositeExtract %8 %78 0 +%87 = OpMatrixTimesVector %8 %67 %86 +%88 = OpCompositeExtract %8 %78 0 +%89 = OpVectorTimesScalar %8 %88 %65 +%90 = OpCompositeExtract %8 %78 0 +%91 = OpVectorTimesScalar %8 %90 %65 OpReturn OpFunctionEnd -%100 = OpFunction %2 None %61 -%99 = OpLabel -%93 = OpVariable %94 Function %95 -%96 = OpVariable %97 Function %98 -%101 = OpAccessChain %62 %30 %63 -%103 = OpAccessChain %102 %33 %63 -%105 = OpAccessChain %104 %36 %63 -%107 = OpAccessChain %106 %39 %63 -%109 = OpAccessChain %108 %42 %63 -%111 = OpAccessChain %110 %45 %63 -%113 = OpAccessChain %112 %48 %63 -OpBranch %115 -%115 = OpLabel -%121 = OpLoad %118 %119 -%124 = OpIEqual %123 %121 %122 -%125 = OpAll %3 %124 -OpSelectionMerge %126 None -OpBranchConditional %125 %127 %126 -%127 = OpLabel -OpStore %26 %116 -OpStore %28 %117 +%93 = OpFunction %2 None %58 +%92 = OpLabel +%108 = OpVariable %109 Function %62 +%110 = OpVariable %111 Function %25 +%94 = OpAccessChain %59 %30 %60 +%96 = OpAccessChain %95 %33 %60 +%98 = OpAccessChain %97 %36 %60 +%100 = OpAccessChain %99 %39 %60 +%102 = OpAccessChain %101 %42 %60 +%104 = OpAccessChain %103 %45 %60 +%106 = OpAccessChain %105 %48 %60 +OpBranch %112 +%112 = OpLabel +%118 = OpLoad %115 %116 +%121 = OpIEqual %120 %118 %119 +%122 = OpAll %3 %121 +OpSelectionMerge %123 None +OpBranchConditional %122 %124 %123 +%124 = OpLabel +OpStore %26 %113 +OpStore %28 %114 +OpBranch %123 +%123 = OpLabel +OpControlBarrier %18 %18 %125 OpBranch %126 %126 = OpLabel -OpControlBarrier %18 %18 %128 -OpBranch %129 -%129 = OpLabel -%130 = OpFunctionCall %2 %60 -%134 = OpAccessChain %133 %113 %63 %63 -%135 = OpLoad %20 %134 -%139 = OpAccessChain %138 %111 %63 %63 %63 -%140 = OpLoad %12 %139 -%141 = OpMatrixTimesVector %10 %135 %140 -%142 = OpCompositeExtract %4 %141 0 -%144 = OpAccessChain %131 %26 %143 -OpStore %144 %142 -%145 = OpLoad %15 %109 -%146 = OpLoad %8 %107 -%147 = OpMatrixTimesVector %10 %145 %146 -%148 = OpCompositeExtract %4 %147 0 -%150 = OpAccessChain %131 %26 %149 -OpStore %150 %148 -%153 = OpAccessChain %74 %103 %152 %152 -%154 = OpLoad %4 %153 -%156 = OpAccessChain %131 %26 %155 -OpStore %156 %154 -%160 = OpAccessChain %158 %105 %63 %159 -%161 = OpLoad %4 %160 -%163 = OpAccessChain %131 %26 %162 -OpStore %163 %161 -%165 = OpAccessChain %164 %101 %152 +%127 = OpFunctionCall %2 %57 +%131 = OpAccessChain %130 %106 %60 %60 +%132 = OpLoad %20 %131 +%136 = OpAccessChain %135 %104 %60 %60 %60 +%137 = OpLoad %12 %136 +%138 = OpMatrixTimesVector %10 %132 %137 +%139 = OpCompositeExtract %4 %138 0 +%141 = OpAccessChain %128 %26 %140 +OpStore %141 %139 +%142 = OpLoad %15 %102 +%143 = OpLoad %8 %100 +%144 = OpMatrixTimesVector %10 %142 %143 +%145 = OpCompositeExtract %4 %144 0 +%147 = OpAccessChain %128 %26 %146 +OpStore %147 %145 +%150 = OpAccessChain %73 %96 %149 %149 +%151 = OpLoad %4 %150 +%153 = OpAccessChain %128 %26 %152 +OpStore %153 %151 +%157 = OpAccessChain %155 %98 %60 %156 +%158 = OpLoad %4 %157 +%160 = OpAccessChain %128 %26 %159 +OpStore %160 %158 +%162 = OpAccessChain %161 %94 %149 +%163 = OpLoad %4 %162 +%164 = OpAccessChain %128 %26 %156 +OpStore %164 %163 +%165 = OpAccessChain %73 %94 %60 %60 %166 = OpLoad %4 %165 -%167 = OpAccessChain %131 %26 %159 +%167 = OpAccessChain %128 %26 %18 OpStore %167 %166 -%168 = OpAccessChain %74 %101 %63 %63 -%169 = OpLoad %4 %168 -%170 = OpAccessChain %131 %26 %18 -OpStore %170 %169 -%171 = OpAccessChain %164 %101 %152 -OpStore %171 %114 -%172 = OpArrayLength %7 %33 0 -%173 = OpConvertUToF %4 %172 -%174 = OpAccessChain %131 %26 %152 -OpStore %174 %173 -OpAtomicStore %28 %175 %176 %18 -OpStore %93 %65 -OpStore %96 %25 +%168 = OpAccessChain %161 %94 %149 +OpStore %168 %107 +%169 = OpArrayLength %7 %33 0 +%170 = OpConvertUToF %4 %169 +%171 = OpAccessChain %128 %26 %149 +OpStore %171 %170 +OpAtomicStore %28 %172 %173 %18 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/image.spvasm b/tests/out/spv/image.spvasm index 06aa36bcb2..ec35372f8a 100644 --- a/tests/out/spv/image.spvasm +++ b/tests/out/spv/image.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 522 +; Bound: 517 OpCapability Shader OpCapability Image1D OpCapability Sampled1D @@ -11,18 +11,18 @@ OpCapability ImageQuery OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %78 "main" %75 OpEntryPoint GLCompute %169 "depth_load" %167 -OpEntryPoint Vertex %190 "queries" %188 -OpEntryPoint Vertex %242 "levels_queries" %241 -OpEntryPoint Fragment %274 "texture_sample" %273 -OpEntryPoint Fragment %420 "texture_sample_comparison" %418 -OpEntryPoint Fragment %475 "gather" %474 -OpEntryPoint Fragment %510 "depth_no_comparison" %509 +OpEntryPoint Vertex %189 "queries" %187 +OpEntryPoint Vertex %241 "levels_queries" %240 +OpEntryPoint Fragment %270 "texture_sample" %269 +OpEntryPoint Fragment %416 "texture_sample_comparison" %414 +OpEntryPoint Fragment %472 "gather" %471 +OpEntryPoint Fragment %506 "depth_no_comparison" %505 OpExecutionMode %78 LocalSize 16 1 1 OpExecutionMode %169 LocalSize 16 1 1 -OpExecutionMode %274 OriginUpperLeft -OpExecutionMode %420 OriginUpperLeft -OpExecutionMode %475 OriginUpperLeft -OpExecutionMode %510 OriginUpperLeft +OpExecutionMode %270 OriginUpperLeft +OpExecutionMode %416 OriginUpperLeft +OpExecutionMode %472 OriginUpperLeft +OpExecutionMode %506 OriginUpperLeft OpName %31 "image_mipmapped_src" OpName %33 "image_multisampled_src" OpName %35 "image_depth_multisampled_src" @@ -49,14 +49,14 @@ OpName %75 "local_id" OpName %78 "main" OpName %167 "local_id" OpName %169 "depth_load" -OpName %190 "queries" -OpName %242 "levels_queries" -OpName %269 "a" -OpName %274 "texture_sample" -OpName %414 "a" -OpName %420 "texture_sample_comparison" -OpName %475 "gather" -OpName %510 "depth_no_comparison" +OpName %189 "queries" +OpName %241 "levels_queries" +OpName %270 "texture_sample" +OpName %284 "a" +OpName %416 "texture_sample_comparison" +OpName %421 "a" +OpName %472 "gather" +OpName %506 "depth_no_comparison" OpDecorate %31 DescriptorSet 0 OpDecorate %31 Binding 0 OpDecorate %33 DescriptorSet 0 @@ -106,12 +106,12 @@ OpDecorate %72 DescriptorSet 1 OpDecorate %72 Binding 4 OpDecorate %75 BuiltIn LocalInvocationId OpDecorate %167 BuiltIn LocalInvocationId -OpDecorate %188 BuiltIn Position -OpDecorate %241 BuiltIn Position -OpDecorate %273 Location 0 -OpDecorate %418 Location 0 -OpDecorate %474 Location 0 -OpDecorate %509 Location 0 +OpDecorate %187 BuiltIn Position +OpDecorate %240 BuiltIn Position +OpDecorate %269 Location 0 +OpDecorate %414 Location 0 +OpDecorate %471 Location 0 +OpDecorate %505 Location 0 %2 = OpTypeVoid %4 = OpTypeInt 32 0 %3 = OpTypeImage %4 2D 0 0 0 1 Unknown @@ -189,42 +189,45 @@ OpDecorate %509 Location 0 %79 = OpTypeFunction %2 %86 = OpConstant %14 10 %87 = OpConstant %14 20 -%89 = OpTypeVector %4 2 +%88 = OpConstantComposite %13 %86 %87 +%90 = OpTypeVector %4 2 %98 = OpTypeVector %4 4 %109 = OpTypeVector %14 3 %167 = OpVariable %76 Input -%189 = OpTypePointer Output %23 -%188 = OpVariable %189 Output -%199 = OpConstant %4 0 -%241 = OpVariable %189 Output -%270 = OpTypePointer Function %23 -%271 = OpConstantNull %23 -%273 = OpVariable %189 Output -%280 = OpConstant %7 0.5 +%188 = OpTypePointer Output %23 +%187 = OpVariable %188 Output +%198 = OpConstant %4 0 +%240 = OpVariable %188 Output +%269 = OpVariable %188 Output +%276 = OpConstant %7 0.5 +%277 = OpTypeVector %7 2 +%278 = OpConstantComposite %277 %276 %276 +%279 = OpTypeVector %7 3 +%280 = OpConstantComposite %279 %276 %276 %276 %281 = OpConstant %7 2.3 %282 = OpConstant %7 2.0 %283 = OpConstant %14 0 -%285 = OpTypeVector %7 2 -%287 = OpTypeVector %7 3 -%289 = OpTypeSampledImage %15 -%294 = OpTypeSampledImage %16 -%315 = OpTypeSampledImage %18 -%376 = OpTypeSampledImage %20 -%415 = OpTypePointer Function %7 -%416 = OpConstantNull %7 -%419 = OpTypePointer Output %7 -%418 = OpVariable %419 Output -%428 = OpTypeSampledImage %25 -%433 = OpTypeSampledImage %26 -%446 = OpTypeSampledImage %27 -%453 = OpConstant %7 0.0 -%474 = OpVariable %189 Output -%486 = OpConstant %4 1 -%489 = OpConstant %4 3 -%494 = OpTypeSampledImage %3 -%497 = OpTypeVector %14 4 -%498 = OpTypeSampledImage %17 -%509 = OpVariable %189 Output +%285 = OpTypePointer Function %23 +%286 = OpConstantNull %23 +%288 = OpTypeSampledImage %15 +%293 = OpTypeSampledImage %16 +%314 = OpTypeSampledImage %18 +%375 = OpTypeSampledImage %20 +%415 = OpTypePointer Output %7 +%414 = OpVariable %415 Output +%422 = OpTypePointer Function %7 +%423 = OpConstantNull %7 +%425 = OpTypeSampledImage %25 +%430 = OpTypeSampledImage %26 +%443 = OpTypeSampledImage %27 +%450 = OpConstant %7 0.0 +%471 = OpVariable %188 Output +%482 = OpConstant %4 1 +%485 = OpConstant %4 3 +%490 = OpTypeSampledImage %3 +%493 = OpTypeVector %14 4 +%494 = OpTypeSampledImage %17 +%505 = OpVariable %188 Output %78 = OpFunction %2 None %79 %74 = OpLabel %77 = OpLoad %12 %75 @@ -234,14 +237,13 @@ OpDecorate %509 Location 0 %83 = OpLoad %9 %39 %84 = OpLoad %11 %43 %85 = OpLoad %10 %45 -OpBranch %88 -%88 = OpLabel -%90 = OpImageQuerySize %89 %82 -%91 = OpVectorShuffle %89 %77 %77 0 1 -%92 = OpIMul %89 %90 %91 -%93 = OpBitcast %13 %92 -%94 = OpCompositeConstruct %13 %86 %87 -%95 = OpSRem %13 %93 %94 +OpBranch %89 +%89 = OpLabel +%91 = OpImageQuerySize %90 %82 +%92 = OpVectorShuffle %90 %77 %77 0 1 +%93 = OpIMul %90 %91 %92 +%94 = OpBitcast %13 %93 +%95 = OpSRem %13 %94 %88 %96 = OpCompositeExtract %4 %77 2 %97 = OpBitcast %14 %96 %99 = OpImageFetch %98 %80 %95 Lod %97 @@ -268,24 +270,24 @@ OpBranch %88 %121 = OpCompositeExtract %4 %77 2 %122 = OpBitcast %14 %121 %123 = OpImageFetch %98 %84 %120 Lod %122 -%124 = OpBitcast %89 %95 +%124 = OpBitcast %90 %95 %125 = OpCompositeExtract %4 %77 2 %126 = OpBitcast %14 %125 %127 = OpImageFetch %98 %80 %124 Lod %126 -%128 = OpBitcast %89 %95 +%128 = OpBitcast %90 %95 %129 = OpCompositeExtract %4 %77 2 %130 = OpBitcast %14 %129 %131 = OpImageFetch %98 %81 %128 Sample %130 -%132 = OpBitcast %89 %95 +%132 = OpBitcast %90 %95 %133 = OpImageRead %98 %82 %132 -%134 = OpBitcast %89 %95 +%134 = OpBitcast %90 %95 %135 = OpCompositeExtract %4 %77 2 %136 = OpCompositeExtract %4 %77 2 %137 = OpBitcast %14 %136 %138 = OpIAdd %14 %137 %29 %139 = OpCompositeConstruct %12 %134 %135 %140 = OpImageFetch %98 %83 %139 Lod %138 -%141 = OpBitcast %89 %95 +%141 = OpBitcast %90 %95 %142 = OpCompositeExtract %4 %77 2 %143 = OpBitcast %14 %142 %144 = OpCompositeExtract %4 %77 2 @@ -321,376 +323,369 @@ OpFunctionEnd %172 = OpLoad %10 %45 OpBranch %173 %173 = OpLabel -%174 = OpImageQuerySize %89 %171 -%175 = OpVectorShuffle %89 %168 %168 0 1 -%176 = OpIMul %89 %174 %175 +%174 = OpImageQuerySize %90 %171 +%175 = OpVectorShuffle %90 %168 %168 0 1 +%176 = OpIMul %90 %174 %175 %177 = OpBitcast %13 %176 -%178 = OpCompositeConstruct %13 %86 %87 -%179 = OpSRem %13 %177 %178 -%180 = OpCompositeExtract %4 %168 2 -%181 = OpBitcast %14 %180 -%182 = OpImageFetch %23 %170 %179 Sample %181 -%183 = OpCompositeExtract %7 %182 0 -%184 = OpCompositeExtract %14 %179 0 -%185 = OpConvertFToU %4 %183 -%186 = OpCompositeConstruct %98 %185 %185 %185 %185 -OpImageWrite %172 %184 %186 +%178 = OpSRem %13 %177 %88 +%179 = OpCompositeExtract %4 %168 2 +%180 = OpBitcast %14 %179 +%181 = OpImageFetch %23 %170 %178 Sample %180 +%182 = OpCompositeExtract %7 %181 0 +%183 = OpCompositeExtract %14 %178 0 +%184 = OpConvertFToU %4 %182 +%185 = OpCompositeConstruct %98 %184 %184 %184 %184 +OpImageWrite %172 %183 %185 OpReturn OpFunctionEnd -%190 = OpFunction %2 None %79 -%187 = OpLabel -%191 = OpLoad %15 %47 -%192 = OpLoad %16 %49 -%193 = OpLoad %18 %54 -%194 = OpLoad %19 %56 -%195 = OpLoad %20 %58 -%196 = OpLoad %21 %60 -%197 = OpLoad %22 %62 -OpBranch %198 -%198 = OpLabel -%200 = OpImageQuerySizeLod %4 %191 %199 -%201 = OpBitcast %14 %200 -%202 = OpImageQuerySizeLod %4 %191 %201 -%203 = OpImageQuerySizeLod %89 %192 %199 -%204 = OpImageQuerySizeLod %89 %192 %29 -%205 = OpImageQuerySizeLod %12 %193 %199 -%206 = OpVectorShuffle %89 %205 %205 0 1 -%207 = OpImageQuerySizeLod %12 %193 %29 -%208 = OpVectorShuffle %89 %207 %207 0 1 -%209 = OpImageQuerySizeLod %89 %194 %199 -%210 = OpImageQuerySizeLod %89 %194 %29 -%211 = OpImageQuerySizeLod %12 %195 %199 -%212 = OpVectorShuffle %89 %211 %211 0 0 -%213 = OpImageQuerySizeLod %12 %195 %29 -%214 = OpVectorShuffle %89 %213 %213 0 0 -%215 = OpImageQuerySizeLod %12 %196 %199 -%216 = OpImageQuerySizeLod %12 %196 %29 -%217 = OpImageQuerySize %89 %197 -%218 = OpCompositeExtract %4 %203 1 -%219 = OpIAdd %4 %200 %218 -%220 = OpCompositeExtract %4 %204 1 -%221 = OpIAdd %4 %219 %220 -%222 = OpCompositeExtract %4 %206 1 -%223 = OpIAdd %4 %221 %222 -%224 = OpCompositeExtract %4 %208 1 -%225 = OpIAdd %4 %223 %224 -%226 = OpCompositeExtract %4 %209 1 -%227 = OpIAdd %4 %225 %226 -%228 = OpCompositeExtract %4 %210 1 -%229 = OpIAdd %4 %227 %228 -%230 = OpCompositeExtract %4 %212 1 -%231 = OpIAdd %4 %229 %230 -%232 = OpCompositeExtract %4 %214 1 -%233 = OpIAdd %4 %231 %232 -%234 = OpCompositeExtract %4 %215 2 -%235 = OpIAdd %4 %233 %234 -%236 = OpCompositeExtract %4 %216 2 -%237 = OpIAdd %4 %235 %236 -%238 = OpConvertUToF %7 %237 -%239 = OpCompositeConstruct %23 %238 %238 %238 %238 -OpStore %188 %239 +%189 = OpFunction %2 None %79 +%186 = OpLabel +%190 = OpLoad %15 %47 +%191 = OpLoad %16 %49 +%192 = OpLoad %18 %54 +%193 = OpLoad %19 %56 +%194 = OpLoad %20 %58 +%195 = OpLoad %21 %60 +%196 = OpLoad %22 %62 +OpBranch %197 +%197 = OpLabel +%199 = OpImageQuerySizeLod %4 %190 %198 +%200 = OpBitcast %14 %199 +%201 = OpImageQuerySizeLod %4 %190 %200 +%202 = OpImageQuerySizeLod %90 %191 %198 +%203 = OpImageQuerySizeLod %90 %191 %29 +%204 = OpImageQuerySizeLod %12 %192 %198 +%205 = OpVectorShuffle %90 %204 %204 0 1 +%206 = OpImageQuerySizeLod %12 %192 %29 +%207 = OpVectorShuffle %90 %206 %206 0 1 +%208 = OpImageQuerySizeLod %90 %193 %198 +%209 = OpImageQuerySizeLod %90 %193 %29 +%210 = OpImageQuerySizeLod %12 %194 %198 +%211 = OpVectorShuffle %90 %210 %210 0 0 +%212 = OpImageQuerySizeLod %12 %194 %29 +%213 = OpVectorShuffle %90 %212 %212 0 0 +%214 = OpImageQuerySizeLod %12 %195 %198 +%215 = OpImageQuerySizeLod %12 %195 %29 +%216 = OpImageQuerySize %90 %196 +%217 = OpCompositeExtract %4 %202 1 +%218 = OpIAdd %4 %199 %217 +%219 = OpCompositeExtract %4 %203 1 +%220 = OpIAdd %4 %218 %219 +%221 = OpCompositeExtract %4 %205 1 +%222 = OpIAdd %4 %220 %221 +%223 = OpCompositeExtract %4 %207 1 +%224 = OpIAdd %4 %222 %223 +%225 = OpCompositeExtract %4 %208 1 +%226 = OpIAdd %4 %224 %225 +%227 = OpCompositeExtract %4 %209 1 +%228 = OpIAdd %4 %226 %227 +%229 = OpCompositeExtract %4 %211 1 +%230 = OpIAdd %4 %228 %229 +%231 = OpCompositeExtract %4 %213 1 +%232 = OpIAdd %4 %230 %231 +%233 = OpCompositeExtract %4 %214 2 +%234 = OpIAdd %4 %232 %233 +%235 = OpCompositeExtract %4 %215 2 +%236 = OpIAdd %4 %234 %235 +%237 = OpConvertUToF %7 %236 +%238 = OpCompositeConstruct %23 %237 %237 %237 %237 +OpStore %187 %238 OpReturn OpFunctionEnd -%242 = OpFunction %2 None %79 -%240 = OpLabel -%243 = OpLoad %16 %49 -%244 = OpLoad %18 %54 -%245 = OpLoad %19 %56 -%246 = OpLoad %20 %58 -%247 = OpLoad %21 %60 -%248 = OpLoad %22 %62 -OpBranch %249 -%249 = OpLabel +%241 = OpFunction %2 None %79 +%239 = OpLabel +%242 = OpLoad %16 %49 +%243 = OpLoad %18 %54 +%244 = OpLoad %19 %56 +%245 = OpLoad %20 %58 +%246 = OpLoad %21 %60 +%247 = OpLoad %22 %62 +OpBranch %248 +%248 = OpLabel +%249 = OpImageQueryLevels %4 %242 %250 = OpImageQueryLevels %4 %243 -%251 = OpImageQueryLevels %4 %244 -%252 = OpImageQuerySizeLod %12 %244 %199 -%253 = OpCompositeExtract %4 %252 2 +%251 = OpImageQuerySizeLod %12 %243 %198 +%252 = OpCompositeExtract %4 %251 2 +%253 = OpImageQueryLevels %4 %244 %254 = OpImageQueryLevels %4 %245 -%255 = OpImageQueryLevels %4 %246 -%256 = OpImageQuerySizeLod %12 %246 %199 -%257 = OpCompositeExtract %4 %256 2 -%258 = OpImageQueryLevels %4 %247 -%259 = OpImageQuerySamples %4 %248 -%260 = OpIAdd %4 %253 %257 -%261 = OpIAdd %4 %260 %259 +%255 = OpImageQuerySizeLod %12 %245 %198 +%256 = OpCompositeExtract %4 %255 2 +%257 = OpImageQueryLevels %4 %246 +%258 = OpImageQuerySamples %4 %247 +%259 = OpIAdd %4 %252 %256 +%260 = OpIAdd %4 %259 %258 +%261 = OpIAdd %4 %260 %249 %262 = OpIAdd %4 %261 %250 -%263 = OpIAdd %4 %262 %251 -%264 = OpIAdd %4 %263 %258 +%263 = OpIAdd %4 %262 %257 +%264 = OpIAdd %4 %263 %253 %265 = OpIAdd %4 %264 %254 -%266 = OpIAdd %4 %265 %255 -%267 = OpConvertUToF %7 %266 -%268 = OpCompositeConstruct %23 %267 %267 %267 %267 -OpStore %241 %268 +%266 = OpConvertUToF %7 %265 +%267 = OpCompositeConstruct %23 %266 %266 %266 %266 +OpStore %240 %267 OpReturn OpFunctionEnd -%274 = OpFunction %2 None %79 -%272 = OpLabel -%269 = OpVariable %270 Function %271 -%275 = OpLoad %15 %47 -%276 = OpLoad %16 %49 -%277 = OpLoad %18 %54 -%278 = OpLoad %20 %58 -%279 = OpLoad %24 %64 -OpBranch %284 -%284 = OpLabel -%286 = OpCompositeConstruct %285 %280 %280 -%288 = OpCompositeConstruct %287 %280 %280 %280 -%290 = OpSampledImage %289 %275 %279 -%291 = OpImageSampleImplicitLod %23 %290 %280 -%292 = OpLoad %23 %269 -%293 = OpFAdd %23 %292 %291 -OpStore %269 %293 -%295 = OpSampledImage %294 %276 %279 -%296 = OpImageSampleImplicitLod %23 %295 %286 -%297 = OpLoad %23 %269 -%298 = OpFAdd %23 %297 %296 -OpStore %269 %298 -%299 = OpSampledImage %294 %276 %279 -%300 = OpImageSampleImplicitLod %23 %299 %286 ConstOffset %30 -%301 = OpLoad %23 %269 -%302 = OpFAdd %23 %301 %300 -OpStore %269 %302 -%303 = OpSampledImage %294 %276 %279 -%304 = OpImageSampleExplicitLod %23 %303 %286 Lod %281 -%305 = OpLoad %23 %269 -%306 = OpFAdd %23 %305 %304 -OpStore %269 %306 -%307 = OpSampledImage %294 %276 %279 -%308 = OpImageSampleExplicitLod %23 %307 %286 Lod|ConstOffset %281 %30 -%309 = OpLoad %23 %269 -%310 = OpFAdd %23 %309 %308 -OpStore %269 %310 -%311 = OpSampledImage %294 %276 %279 -%312 = OpImageSampleImplicitLod %23 %311 %286 Bias|ConstOffset %282 %30 -%313 = OpLoad %23 %269 -%314 = OpFAdd %23 %313 %312 -OpStore %269 %314 -%316 = OpConvertUToF %7 %199 -%317 = OpCompositeConstruct %287 %286 %316 -%318 = OpSampledImage %315 %277 %279 -%319 = OpImageSampleImplicitLod %23 %318 %317 -%320 = OpLoad %23 %269 -%321 = OpFAdd %23 %320 %319 -OpStore %269 %321 -%322 = OpConvertUToF %7 %199 -%323 = OpCompositeConstruct %287 %286 %322 -%324 = OpSampledImage %315 %277 %279 -%325 = OpImageSampleImplicitLod %23 %324 %323 ConstOffset %30 -%326 = OpLoad %23 %269 -%327 = OpFAdd %23 %326 %325 -OpStore %269 %327 -%328 = OpConvertUToF %7 %199 -%329 = OpCompositeConstruct %287 %286 %328 -%330 = OpSampledImage %315 %277 %279 -%331 = OpImageSampleExplicitLod %23 %330 %329 Lod %281 -%332 = OpLoad %23 %269 -%333 = OpFAdd %23 %332 %331 -OpStore %269 %333 -%334 = OpConvertUToF %7 %199 -%335 = OpCompositeConstruct %287 %286 %334 -%336 = OpSampledImage %315 %277 %279 -%337 = OpImageSampleExplicitLod %23 %336 %335 Lod|ConstOffset %281 %30 -%338 = OpLoad %23 %269 -%339 = OpFAdd %23 %338 %337 -OpStore %269 %339 -%340 = OpConvertUToF %7 %199 -%341 = OpCompositeConstruct %287 %286 %340 -%342 = OpSampledImage %315 %277 %279 -%343 = OpImageSampleImplicitLod %23 %342 %341 Bias|ConstOffset %282 %30 -%344 = OpLoad %23 %269 -%345 = OpFAdd %23 %344 %343 -OpStore %269 %345 -%346 = OpConvertSToF %7 %283 -%347 = OpCompositeConstruct %287 %286 %346 -%348 = OpSampledImage %315 %277 %279 -%349 = OpImageSampleImplicitLod %23 %348 %347 -%350 = OpLoad %23 %269 -%351 = OpFAdd %23 %350 %349 -OpStore %269 %351 -%352 = OpConvertSToF %7 %283 -%353 = OpCompositeConstruct %287 %286 %352 -%354 = OpSampledImage %315 %277 %279 -%355 = OpImageSampleImplicitLod %23 %354 %353 ConstOffset %30 -%356 = OpLoad %23 %269 -%357 = OpFAdd %23 %356 %355 -OpStore %269 %357 -%358 = OpConvertSToF %7 %283 -%359 = OpCompositeConstruct %287 %286 %358 -%360 = OpSampledImage %315 %277 %279 -%361 = OpImageSampleExplicitLod %23 %360 %359 Lod %281 -%362 = OpLoad %23 %269 -%363 = OpFAdd %23 %362 %361 -OpStore %269 %363 -%364 = OpConvertSToF %7 %283 -%365 = OpCompositeConstruct %287 %286 %364 -%366 = OpSampledImage %315 %277 %279 -%367 = OpImageSampleExplicitLod %23 %366 %365 Lod|ConstOffset %281 %30 -%368 = OpLoad %23 %269 -%369 = OpFAdd %23 %368 %367 -OpStore %269 %369 -%370 = OpConvertSToF %7 %283 -%371 = OpCompositeConstruct %287 %286 %370 -%372 = OpSampledImage %315 %277 %279 -%373 = OpImageSampleImplicitLod %23 %372 %371 Bias|ConstOffset %282 %30 -%374 = OpLoad %23 %269 -%375 = OpFAdd %23 %374 %373 -OpStore %269 %375 -%377 = OpConvertUToF %7 %199 -%378 = OpCompositeConstruct %23 %288 %377 -%379 = OpSampledImage %376 %278 %279 -%380 = OpImageSampleImplicitLod %23 %379 %378 -%381 = OpLoad %23 %269 -%382 = OpFAdd %23 %381 %380 -OpStore %269 %382 -%383 = OpConvertUToF %7 %199 -%384 = OpCompositeConstruct %23 %288 %383 -%385 = OpSampledImage %376 %278 %279 -%386 = OpImageSampleExplicitLod %23 %385 %384 Lod %281 -%387 = OpLoad %23 %269 -%388 = OpFAdd %23 %387 %386 -OpStore %269 %388 -%389 = OpConvertUToF %7 %199 -%390 = OpCompositeConstruct %23 %288 %389 -%391 = OpSampledImage %376 %278 %279 -%392 = OpImageSampleImplicitLod %23 %391 %390 Bias %282 -%393 = OpLoad %23 %269 -%394 = OpFAdd %23 %393 %392 -OpStore %269 %394 -%395 = OpConvertSToF %7 %283 -%396 = OpCompositeConstruct %23 %288 %395 -%397 = OpSampledImage %376 %278 %279 -%398 = OpImageSampleImplicitLod %23 %397 %396 -%399 = OpLoad %23 %269 -%400 = OpFAdd %23 %399 %398 -OpStore %269 %400 -%401 = OpConvertSToF %7 %283 -%402 = OpCompositeConstruct %23 %288 %401 -%403 = OpSampledImage %376 %278 %279 -%404 = OpImageSampleExplicitLod %23 %403 %402 Lod %281 -%405 = OpLoad %23 %269 -%406 = OpFAdd %23 %405 %404 -OpStore %269 %406 -%407 = OpConvertSToF %7 %283 -%408 = OpCompositeConstruct %23 %288 %407 -%409 = OpSampledImage %376 %278 %279 -%410 = OpImageSampleImplicitLod %23 %409 %408 Bias %282 -%411 = OpLoad %23 %269 -%412 = OpFAdd %23 %411 %410 +%270 = OpFunction %2 None %79 +%268 = OpLabel +%284 = OpVariable %285 Function %286 +%271 = OpLoad %15 %47 +%272 = OpLoad %16 %49 +%273 = OpLoad %18 %54 +%274 = OpLoad %20 %58 +%275 = OpLoad %24 %64 +OpBranch %287 +%287 = OpLabel +%289 = OpSampledImage %288 %271 %275 +%290 = OpImageSampleImplicitLod %23 %289 %276 +%291 = OpLoad %23 %284 +%292 = OpFAdd %23 %291 %290 +OpStore %284 %292 +%294 = OpSampledImage %293 %272 %275 +%295 = OpImageSampleImplicitLod %23 %294 %278 +%296 = OpLoad %23 %284 +%297 = OpFAdd %23 %296 %295 +OpStore %284 %297 +%298 = OpSampledImage %293 %272 %275 +%299 = OpImageSampleImplicitLod %23 %298 %278 ConstOffset %30 +%300 = OpLoad %23 %284 +%301 = OpFAdd %23 %300 %299 +OpStore %284 %301 +%302 = OpSampledImage %293 %272 %275 +%303 = OpImageSampleExplicitLod %23 %302 %278 Lod %281 +%304 = OpLoad %23 %284 +%305 = OpFAdd %23 %304 %303 +OpStore %284 %305 +%306 = OpSampledImage %293 %272 %275 +%307 = OpImageSampleExplicitLod %23 %306 %278 Lod|ConstOffset %281 %30 +%308 = OpLoad %23 %284 +%309 = OpFAdd %23 %308 %307 +OpStore %284 %309 +%310 = OpSampledImage %293 %272 %275 +%311 = OpImageSampleImplicitLod %23 %310 %278 Bias|ConstOffset %282 %30 +%312 = OpLoad %23 %284 +%313 = OpFAdd %23 %312 %311 +OpStore %284 %313 +%315 = OpConvertUToF %7 %198 +%316 = OpCompositeConstruct %279 %278 %315 +%317 = OpSampledImage %314 %273 %275 +%318 = OpImageSampleImplicitLod %23 %317 %316 +%319 = OpLoad %23 %284 +%320 = OpFAdd %23 %319 %318 +OpStore %284 %320 +%321 = OpConvertUToF %7 %198 +%322 = OpCompositeConstruct %279 %278 %321 +%323 = OpSampledImage %314 %273 %275 +%324 = OpImageSampleImplicitLod %23 %323 %322 ConstOffset %30 +%325 = OpLoad %23 %284 +%326 = OpFAdd %23 %325 %324 +OpStore %284 %326 +%327 = OpConvertUToF %7 %198 +%328 = OpCompositeConstruct %279 %278 %327 +%329 = OpSampledImage %314 %273 %275 +%330 = OpImageSampleExplicitLod %23 %329 %328 Lod %281 +%331 = OpLoad %23 %284 +%332 = OpFAdd %23 %331 %330 +OpStore %284 %332 +%333 = OpConvertUToF %7 %198 +%334 = OpCompositeConstruct %279 %278 %333 +%335 = OpSampledImage %314 %273 %275 +%336 = OpImageSampleExplicitLod %23 %335 %334 Lod|ConstOffset %281 %30 +%337 = OpLoad %23 %284 +%338 = OpFAdd %23 %337 %336 +OpStore %284 %338 +%339 = OpConvertUToF %7 %198 +%340 = OpCompositeConstruct %279 %278 %339 +%341 = OpSampledImage %314 %273 %275 +%342 = OpImageSampleImplicitLod %23 %341 %340 Bias|ConstOffset %282 %30 +%343 = OpLoad %23 %284 +%344 = OpFAdd %23 %343 %342 +OpStore %284 %344 +%345 = OpConvertSToF %7 %283 +%346 = OpCompositeConstruct %279 %278 %345 +%347 = OpSampledImage %314 %273 %275 +%348 = OpImageSampleImplicitLod %23 %347 %346 +%349 = OpLoad %23 %284 +%350 = OpFAdd %23 %349 %348 +OpStore %284 %350 +%351 = OpConvertSToF %7 %283 +%352 = OpCompositeConstruct %279 %278 %351 +%353 = OpSampledImage %314 %273 %275 +%354 = OpImageSampleImplicitLod %23 %353 %352 ConstOffset %30 +%355 = OpLoad %23 %284 +%356 = OpFAdd %23 %355 %354 +OpStore %284 %356 +%357 = OpConvertSToF %7 %283 +%358 = OpCompositeConstruct %279 %278 %357 +%359 = OpSampledImage %314 %273 %275 +%360 = OpImageSampleExplicitLod %23 %359 %358 Lod %281 +%361 = OpLoad %23 %284 +%362 = OpFAdd %23 %361 %360 +OpStore %284 %362 +%363 = OpConvertSToF %7 %283 +%364 = OpCompositeConstruct %279 %278 %363 +%365 = OpSampledImage %314 %273 %275 +%366 = OpImageSampleExplicitLod %23 %365 %364 Lod|ConstOffset %281 %30 +%367 = OpLoad %23 %284 +%368 = OpFAdd %23 %367 %366 +OpStore %284 %368 +%369 = OpConvertSToF %7 %283 +%370 = OpCompositeConstruct %279 %278 %369 +%371 = OpSampledImage %314 %273 %275 +%372 = OpImageSampleImplicitLod %23 %371 %370 Bias|ConstOffset %282 %30 +%373 = OpLoad %23 %284 +%374 = OpFAdd %23 %373 %372 +OpStore %284 %374 +%376 = OpConvertUToF %7 %198 +%377 = OpCompositeConstruct %23 %280 %376 +%378 = OpSampledImage %375 %274 %275 +%379 = OpImageSampleImplicitLod %23 %378 %377 +%380 = OpLoad %23 %284 +%381 = OpFAdd %23 %380 %379 +OpStore %284 %381 +%382 = OpConvertUToF %7 %198 +%383 = OpCompositeConstruct %23 %280 %382 +%384 = OpSampledImage %375 %274 %275 +%385 = OpImageSampleExplicitLod %23 %384 %383 Lod %281 +%386 = OpLoad %23 %284 +%387 = OpFAdd %23 %386 %385 +OpStore %284 %387 +%388 = OpConvertUToF %7 %198 +%389 = OpCompositeConstruct %23 %280 %388 +%390 = OpSampledImage %375 %274 %275 +%391 = OpImageSampleImplicitLod %23 %390 %389 Bias %282 +%392 = OpLoad %23 %284 +%393 = OpFAdd %23 %392 %391 +OpStore %284 %393 +%394 = OpConvertSToF %7 %283 +%395 = OpCompositeConstruct %23 %280 %394 +%396 = OpSampledImage %375 %274 %275 +%397 = OpImageSampleImplicitLod %23 %396 %395 +%398 = OpLoad %23 %284 +%399 = OpFAdd %23 %398 %397 +OpStore %284 %399 +%400 = OpConvertSToF %7 %283 +%401 = OpCompositeConstruct %23 %280 %400 +%402 = OpSampledImage %375 %274 %275 +%403 = OpImageSampleExplicitLod %23 %402 %401 Lod %281 +%404 = OpLoad %23 %284 +%405 = OpFAdd %23 %404 %403 +OpStore %284 %405 +%406 = OpConvertSToF %7 %283 +%407 = OpCompositeConstruct %23 %280 %406 +%408 = OpSampledImage %375 %274 %275 +%409 = OpImageSampleImplicitLod %23 %408 %407 Bias %282 +%410 = OpLoad %23 %284 +%411 = OpFAdd %23 %410 %409 +OpStore %284 %411 +%412 = OpLoad %23 %284 OpStore %269 %412 -%413 = OpLoad %23 %269 -OpStore %273 %413 OpReturn OpFunctionEnd -%420 = OpFunction %2 None %79 -%417 = OpLabel -%414 = OpVariable %415 Function %416 -%421 = OpLoad %24 %66 -%422 = OpLoad %25 %68 -%423 = OpLoad %26 %70 -%424 = OpLoad %27 %72 -OpBranch %425 -%425 = OpLabel -%426 = OpCompositeConstruct %285 %280 %280 -%427 = OpCompositeConstruct %287 %280 %280 %280 -%429 = OpSampledImage %428 %422 %421 -%430 = OpImageSampleDrefImplicitLod %7 %429 %426 %280 -%431 = OpLoad %7 %414 -%432 = OpFAdd %7 %431 %430 -OpStore %414 %432 -%434 = OpConvertUToF %7 %199 -%435 = OpCompositeConstruct %287 %426 %434 -%436 = OpSampledImage %433 %423 %421 -%437 = OpImageSampleDrefImplicitLod %7 %436 %435 %280 -%438 = OpLoad %7 %414 -%439 = OpFAdd %7 %438 %437 -OpStore %414 %439 -%440 = OpConvertSToF %7 %283 -%441 = OpCompositeConstruct %287 %426 %440 -%442 = OpSampledImage %433 %423 %421 -%443 = OpImageSampleDrefImplicitLod %7 %442 %441 %280 -%444 = OpLoad %7 %414 -%445 = OpFAdd %7 %444 %443 -OpStore %414 %445 -%447 = OpSampledImage %446 %424 %421 -%448 = OpImageSampleDrefImplicitLod %7 %447 %427 %280 -%449 = OpLoad %7 %414 -%450 = OpFAdd %7 %449 %448 -OpStore %414 %450 -%451 = OpSampledImage %428 %422 %421 -%452 = OpImageSampleDrefExplicitLod %7 %451 %426 %280 Lod %453 -%454 = OpLoad %7 %414 -%455 = OpFAdd %7 %454 %452 -OpStore %414 %455 -%456 = OpConvertUToF %7 %199 -%457 = OpCompositeConstruct %287 %426 %456 -%458 = OpSampledImage %433 %423 %421 -%459 = OpImageSampleDrefExplicitLod %7 %458 %457 %280 Lod %453 -%460 = OpLoad %7 %414 -%461 = OpFAdd %7 %460 %459 -OpStore %414 %461 -%462 = OpConvertSToF %7 %283 -%463 = OpCompositeConstruct %287 %426 %462 -%464 = OpSampledImage %433 %423 %421 -%465 = OpImageSampleDrefExplicitLod %7 %464 %463 %280 Lod %453 -%466 = OpLoad %7 %414 -%467 = OpFAdd %7 %466 %465 -OpStore %414 %467 -%468 = OpSampledImage %446 %424 %421 -%469 = OpImageSampleDrefExplicitLod %7 %468 %427 %280 Lod %453 -%470 = OpLoad %7 %414 -%471 = OpFAdd %7 %470 %469 -OpStore %414 %471 -%472 = OpLoad %7 %414 -OpStore %418 %472 +%416 = OpFunction %2 None %79 +%413 = OpLabel +%421 = OpVariable %422 Function %423 +%417 = OpLoad %24 %66 +%418 = OpLoad %25 %68 +%419 = OpLoad %26 %70 +%420 = OpLoad %27 %72 +OpBranch %424 +%424 = OpLabel +%426 = OpSampledImage %425 %418 %417 +%427 = OpImageSampleDrefImplicitLod %7 %426 %278 %276 +%428 = OpLoad %7 %421 +%429 = OpFAdd %7 %428 %427 +OpStore %421 %429 +%431 = OpConvertUToF %7 %198 +%432 = OpCompositeConstruct %279 %278 %431 +%433 = OpSampledImage %430 %419 %417 +%434 = OpImageSampleDrefImplicitLod %7 %433 %432 %276 +%435 = OpLoad %7 %421 +%436 = OpFAdd %7 %435 %434 +OpStore %421 %436 +%437 = OpConvertSToF %7 %283 +%438 = OpCompositeConstruct %279 %278 %437 +%439 = OpSampledImage %430 %419 %417 +%440 = OpImageSampleDrefImplicitLod %7 %439 %438 %276 +%441 = OpLoad %7 %421 +%442 = OpFAdd %7 %441 %440 +OpStore %421 %442 +%444 = OpSampledImage %443 %420 %417 +%445 = OpImageSampleDrefImplicitLod %7 %444 %280 %276 +%446 = OpLoad %7 %421 +%447 = OpFAdd %7 %446 %445 +OpStore %421 %447 +%448 = OpSampledImage %425 %418 %417 +%449 = OpImageSampleDrefExplicitLod %7 %448 %278 %276 Lod %450 +%451 = OpLoad %7 %421 +%452 = OpFAdd %7 %451 %449 +OpStore %421 %452 +%453 = OpConvertUToF %7 %198 +%454 = OpCompositeConstruct %279 %278 %453 +%455 = OpSampledImage %430 %419 %417 +%456 = OpImageSampleDrefExplicitLod %7 %455 %454 %276 Lod %450 +%457 = OpLoad %7 %421 +%458 = OpFAdd %7 %457 %456 +OpStore %421 %458 +%459 = OpConvertSToF %7 %283 +%460 = OpCompositeConstruct %279 %278 %459 +%461 = OpSampledImage %430 %419 %417 +%462 = OpImageSampleDrefExplicitLod %7 %461 %460 %276 Lod %450 +%463 = OpLoad %7 %421 +%464 = OpFAdd %7 %463 %462 +OpStore %421 %464 +%465 = OpSampledImage %443 %420 %417 +%466 = OpImageSampleDrefExplicitLod %7 %465 %280 %276 Lod %450 +%467 = OpLoad %7 %421 +%468 = OpFAdd %7 %467 %466 +OpStore %421 %468 +%469 = OpLoad %7 %421 +OpStore %414 %469 OpReturn OpFunctionEnd -%475 = OpFunction %2 None %79 -%473 = OpLabel -%476 = OpLoad %16 %49 -%477 = OpLoad %3 %51 -%478 = OpLoad %17 %52 -%479 = OpLoad %24 %64 -%480 = OpLoad %24 %66 -%481 = OpLoad %25 %68 -OpBranch %482 -%482 = OpLabel -%483 = OpCompositeConstruct %285 %280 %280 -%484 = OpSampledImage %294 %476 %479 -%485 = OpImageGather %23 %484 %483 %486 -%487 = OpSampledImage %294 %476 %479 -%488 = OpImageGather %23 %487 %483 %489 ConstOffset %30 -%490 = OpSampledImage %428 %481 %480 -%491 = OpImageDrefGather %23 %490 %483 %280 -%492 = OpSampledImage %428 %481 %480 -%493 = OpImageDrefGather %23 %492 %483 %280 ConstOffset %30 -%495 = OpSampledImage %494 %477 %479 -%496 = OpImageGather %98 %495 %483 %199 -%499 = OpSampledImage %498 %478 %479 -%500 = OpImageGather %497 %499 %483 %199 -%501 = OpConvertUToF %23 %496 -%502 = OpConvertSToF %23 %500 -%503 = OpFAdd %23 %501 %502 -%504 = OpFAdd %23 %485 %488 -%505 = OpFAdd %23 %504 %491 -%506 = OpFAdd %23 %505 %493 -%507 = OpFAdd %23 %506 %503 -OpStore %474 %507 +%472 = OpFunction %2 None %79 +%470 = OpLabel +%473 = OpLoad %16 %49 +%474 = OpLoad %3 %51 +%475 = OpLoad %17 %52 +%476 = OpLoad %24 %64 +%477 = OpLoad %24 %66 +%478 = OpLoad %25 %68 +OpBranch %479 +%479 = OpLabel +%480 = OpSampledImage %293 %473 %476 +%481 = OpImageGather %23 %480 %278 %482 +%483 = OpSampledImage %293 %473 %476 +%484 = OpImageGather %23 %483 %278 %485 ConstOffset %30 +%486 = OpSampledImage %425 %478 %477 +%487 = OpImageDrefGather %23 %486 %278 %276 +%488 = OpSampledImage %425 %478 %477 +%489 = OpImageDrefGather %23 %488 %278 %276 ConstOffset %30 +%491 = OpSampledImage %490 %474 %476 +%492 = OpImageGather %98 %491 %278 %198 +%495 = OpSampledImage %494 %475 %476 +%496 = OpImageGather %493 %495 %278 %198 +%497 = OpConvertUToF %23 %492 +%498 = OpConvertSToF %23 %496 +%499 = OpFAdd %23 %497 %498 +%500 = OpFAdd %23 %481 %484 +%501 = OpFAdd %23 %500 %487 +%502 = OpFAdd %23 %501 %489 +%503 = OpFAdd %23 %502 %499 +OpStore %471 %503 OpReturn OpFunctionEnd -%510 = OpFunction %2 None %79 -%508 = OpLabel -%511 = OpLoad %24 %64 -%512 = OpLoad %25 %68 -OpBranch %513 -%513 = OpLabel -%514 = OpCompositeConstruct %285 %280 %280 -%515 = OpSampledImage %428 %512 %511 -%516 = OpImageSampleImplicitLod %23 %515 %514 -%517 = OpCompositeExtract %7 %516 0 -%518 = OpSampledImage %428 %512 %511 -%519 = OpImageGather %23 %518 %514 %199 -%520 = OpCompositeConstruct %23 %517 %517 %517 %517 -%521 = OpFAdd %23 %520 %519 -OpStore %509 %521 +%506 = OpFunction %2 None %79 +%504 = OpLabel +%507 = OpLoad %24 %64 +%508 = OpLoad %25 %68 +OpBranch %509 +%509 = OpLabel +%510 = OpSampledImage %425 %508 %507 +%511 = OpImageSampleImplicitLod %23 %510 %278 +%512 = OpCompositeExtract %7 %511 0 +%513 = OpSampledImage %425 %508 %507 +%514 = OpImageGather %23 %513 %278 %198 +%515 = OpCompositeConstruct %23 %512 %512 %512 %512 +%516 = OpFAdd %23 %515 %514 +OpStore %505 %516 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/interface.vertex.spvasm b/tests/out/spv/interface.vertex.spvasm index d2c9492962..eaa947f5b3 100644 --- a/tests/out/spv/interface.vertex.spvasm +++ b/tests/out/spv/interface.vertex.spvasm @@ -45,19 +45,19 @@ OpDecorate %26 BuiltIn PointSize %26 = OpVariable %27 Output %28 = OpConstant %4 1.0 %30 = OpTypeFunction %2 +%31 = OpConstantComposite %3 %28 %28 %28 %28 %29 = OpFunction %2 None %30 %14 = OpLabel %17 = OpLoad %6 %15 %19 = OpLoad %6 %18 %21 = OpLoad %6 %20 OpStore %26 %28 -OpBranch %31 -%31 = OpLabel -%32 = OpIAdd %6 %17 %19 -%33 = OpIAdd %6 %32 %21 -%34 = OpCompositeConstruct %3 %28 %28 %28 %28 -%35 = OpConvertUToF %4 %33 -%36 = OpCompositeConstruct %5 %34 %35 +OpBranch %32 +%32 = OpLabel +%33 = OpIAdd %6 %17 %19 +%34 = OpIAdd %6 %33 %21 +%35 = OpConvertUToF %4 %34 +%36 = OpCompositeConstruct %5 %31 %35 %37 = OpCompositeExtract %3 %36 0 OpStore %22 %37 %38 = OpCompositeExtract %4 %36 1 diff --git a/tests/out/spv/interface.vertex_two_structs.spvasm b/tests/out/spv/interface.vertex_two_structs.spvasm index 505c558433..bcc4aab4e5 100644 --- a/tests/out/spv/interface.vertex_two_structs.spvasm +++ b/tests/out/spv/interface.vertex_two_structs.spvasm @@ -1,11 +1,11 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 42 +; Bound: 41 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %30 "vertex_two_structs" %19 %23 %25 %27 +OpEntryPoint Vertex %27 "vertex_two_structs" %16 %20 %22 %24 OpMemberDecorate %5 0 Offset 0 OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 @@ -14,11 +14,11 @@ OpMemberDecorate %7 2 Offset 8 OpDecorate %9 ArrayStride 4 OpMemberDecorate %12 0 Offset 0 OpMemberDecorate %13 0 Offset 0 -OpDecorate %19 BuiltIn VertexIndex -OpDecorate %23 BuiltIn InstanceIndex -OpDecorate %25 Invariant -OpDecorate %25 BuiltIn Position -OpDecorate %27 BuiltIn PointSize +OpDecorate %16 BuiltIn VertexIndex +OpDecorate %20 BuiltIn InstanceIndex +OpDecorate %22 Invariant +OpDecorate %22 BuiltIn Position +OpDecorate %24 BuiltIn PointSize %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -31,37 +31,35 @@ OpDecorate %27 BuiltIn PointSize %11 = OpTypeVector %6 3 %12 = OpTypeStruct %6 %13 = OpTypeStruct %6 -%15 = OpTypePointer Function %6 -%16 = OpConstantNull %6 -%20 = OpTypePointer Input %6 -%19 = OpVariable %20 Input -%23 = OpVariable %20 Input -%26 = OpTypePointer Output %3 -%25 = OpVariable %26 Output -%28 = OpTypePointer Output %4 -%27 = OpVariable %28 Output -%29 = OpConstant %4 1.0 -%31 = OpTypeFunction %2 -%32 = OpConstant %6 2 -%33 = OpConstant %4 0.0 -%30 = OpFunction %2 None %31 -%17 = OpLabel -%14 = OpVariable %15 Function %16 -%21 = OpLoad %6 %19 -%18 = OpCompositeConstruct %12 %21 -%24 = OpLoad %6 %23 -%22 = OpCompositeConstruct %13 %24 -OpStore %27 %29 -OpBranch %34 -%34 = OpLabel -OpStore %14 %32 -%35 = OpCompositeExtract %6 %18 0 -%36 = OpConvertUToF %4 %35 -%37 = OpCompositeExtract %6 %22 0 -%38 = OpConvertUToF %4 %37 -%39 = OpLoad %6 %14 -%40 = OpConvertUToF %4 %39 -%41 = OpCompositeConstruct %3 %36 %38 %40 %33 -OpStore %25 %41 +%17 = OpTypePointer Input %6 +%16 = OpVariable %17 Input +%20 = OpVariable %17 Input +%23 = OpTypePointer Output %3 +%22 = OpVariable %23 Output +%25 = OpTypePointer Output %4 +%24 = OpVariable %25 Output +%26 = OpConstant %4 1.0 +%28 = OpTypeFunction %2 +%29 = OpConstant %6 2 +%30 = OpConstant %4 0.0 +%32 = OpTypePointer Function %6 +%27 = OpFunction %2 None %28 +%14 = OpLabel +%31 = OpVariable %32 Function %29 +%18 = OpLoad %6 %16 +%15 = OpCompositeConstruct %12 %18 +%21 = OpLoad %6 %20 +%19 = OpCompositeConstruct %13 %21 +OpStore %24 %26 +OpBranch %33 +%33 = OpLabel +%34 = OpCompositeExtract %6 %15 0 +%35 = OpConvertUToF %4 %34 +%36 = OpCompositeExtract %6 %19 0 +%37 = OpConvertUToF %4 %36 +%38 = OpLoad %6 %31 +%39 = OpConvertUToF %4 %38 +%40 = OpCompositeConstruct %3 %35 %37 %39 %30 +OpStore %22 %40 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/interpolate.spvasm b/tests/out/spv/interpolate.spvasm index bcfad15c14..d2a67a9fd2 100644 --- a/tests/out/spv/interpolate.spvasm +++ b/tests/out/spv/interpolate.spvasm @@ -6,7 +6,7 @@ OpCapability Shader OpCapability SampleRateShading %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %29 "vert_main" %13 %15 %17 %19 %21 %23 %24 %25 %26 +OpEntryPoint Vertex %26 "vert_main" %10 %12 %14 %16 %18 %20 %21 %22 %23 OpEntryPoint Fragment %109 "frag_main" %88 %91 %94 %97 %100 %103 %105 %107 OpExecutionMode %109 OriginUpperLeft OpMemberName %8 0 "position" @@ -18,16 +18,16 @@ OpMemberName %8 5 "perspective" OpMemberName %8 6 "perspective_centroid" OpMemberName %8 7 "perspective_sample" OpName %8 "FragmentInput" -OpName %9 "out" -OpName %13 "position" -OpName %15 "_flat" -OpName %17 "_linear" -OpName %19 "linear_centroid" -OpName %21 "linear_sample" -OpName %23 "perspective" -OpName %24 "perspective_centroid" -OpName %25 "perspective_sample" -OpName %29 "vert_main" +OpName %10 "position" +OpName %12 "_flat" +OpName %14 "_linear" +OpName %16 "linear_centroid" +OpName %18 "linear_sample" +OpName %20 "perspective" +OpName %21 "perspective_centroid" +OpName %22 "perspective_sample" +OpName %26 "vert_main" +OpName %49 "out" OpName %88 "position" OpName %91 "_flat" OpName %94 "_linear" @@ -45,23 +45,23 @@ OpMemberDecorate %8 4 Offset 32 OpMemberDecorate %8 5 Offset 48 OpMemberDecorate %8 6 Offset 64 OpMemberDecorate %8 7 Offset 68 -OpDecorate %13 BuiltIn Position -OpDecorate %15 Location 0 -OpDecorate %15 Flat -OpDecorate %17 Location 1 -OpDecorate %17 NoPerspective -OpDecorate %19 Location 2 -OpDecorate %19 NoPerspective -OpDecorate %19 Centroid -OpDecorate %21 Location 3 -OpDecorate %21 NoPerspective -OpDecorate %21 Sample -OpDecorate %23 Location 4 -OpDecorate %24 Location 5 -OpDecorate %24 Centroid -OpDecorate %25 Location 6 -OpDecorate %25 Sample -OpDecorate %26 BuiltIn PointSize +OpDecorate %10 BuiltIn Position +OpDecorate %12 Location 0 +OpDecorate %12 Flat +OpDecorate %14 Location 1 +OpDecorate %14 NoPerspective +OpDecorate %16 Location 2 +OpDecorate %16 NoPerspective +OpDecorate %16 Centroid +OpDecorate %18 Location 3 +OpDecorate %18 NoPerspective +OpDecorate %18 Sample +OpDecorate %20 Location 4 +OpDecorate %21 Location 5 +OpDecorate %21 Centroid +OpDecorate %22 Location 6 +OpDecorate %22 Sample +OpDecorate %23 BuiltIn PointSize OpDecorate %88 BuiltIn FragCoord OpDecorate %91 Location 0 OpDecorate %91 Flat @@ -85,52 +85,56 @@ OpDecorate %107 Sample %6 = OpTypeVector %4 2 %7 = OpTypeVector %4 3 %8 = OpTypeStruct %3 %5 %4 %6 %7 %3 %4 %4 -%10 = OpTypePointer Function %8 -%11 = OpConstantNull %8 -%14 = OpTypePointer Output %3 -%13 = OpVariable %14 Output -%16 = OpTypePointer Output %5 -%15 = OpVariable %16 Output -%18 = OpTypePointer Output %4 -%17 = OpVariable %18 Output -%20 = OpTypePointer Output %6 -%19 = OpVariable %20 Output -%22 = OpTypePointer Output %7 -%21 = OpVariable %22 Output -%23 = OpVariable %14 Output -%24 = OpVariable %18 Output -%25 = OpVariable %18 Output -%27 = OpTypePointer Output %4 -%26 = OpVariable %27 Output -%28 = OpConstant %4 1.0 -%30 = OpTypeFunction %2 -%31 = OpConstant %4 2.0 -%32 = OpConstant %4 4.0 -%33 = OpConstant %4 5.0 -%34 = OpConstant %4 6.0 -%35 = OpConstant %5 8 -%36 = OpConstant %4 27.0 -%37 = OpConstant %4 64.0 -%38 = OpConstant %4 125.0 -%39 = OpConstant %4 216.0 -%40 = OpConstant %4 343.0 -%41 = OpConstant %4 512.0 +%11 = OpTypePointer Output %3 +%10 = OpVariable %11 Output +%13 = OpTypePointer Output %5 +%12 = OpVariable %13 Output +%15 = OpTypePointer Output %4 +%14 = OpVariable %15 Output +%17 = OpTypePointer Output %6 +%16 = OpVariable %17 Output +%19 = OpTypePointer Output %7 +%18 = OpVariable %19 Output +%20 = OpVariable %11 Output +%21 = OpVariable %15 Output +%22 = OpVariable %15 Output +%24 = OpTypePointer Output %4 +%23 = OpVariable %24 Output +%25 = OpConstant %4 1.0 +%27 = OpTypeFunction %2 +%28 = OpConstant %4 2.0 +%29 = OpConstant %4 4.0 +%30 = OpConstant %4 5.0 +%31 = OpConstant %4 6.0 +%32 = OpConstantComposite %3 %28 %29 %30 %31 +%33 = OpConstant %5 8 +%34 = OpConstant %4 27.0 +%35 = OpConstant %4 64.0 +%36 = OpConstant %4 125.0 +%37 = OpConstantComposite %6 %35 %36 +%38 = OpConstant %4 216.0 +%39 = OpConstant %4 343.0 +%40 = OpConstant %4 512.0 +%41 = OpConstantComposite %7 %38 %39 %40 %42 = OpConstant %4 729.0 %43 = OpConstant %4 1000.0 %44 = OpConstant %4 1331.0 %45 = OpConstant %4 1728.0 -%46 = OpConstant %4 2197.0 -%47 = OpConstant %4 2744.0 -%49 = OpTypePointer Function %3 -%51 = OpConstant %5 0 -%53 = OpTypePointer Function %5 -%54 = OpConstant %5 1 -%56 = OpTypePointer Function %4 -%57 = OpConstant %5 2 -%59 = OpTypePointer Function %6 -%61 = OpConstant %5 3 -%63 = OpTypePointer Function %7 -%65 = OpConstant %5 4 +%46 = OpConstantComposite %3 %42 %43 %44 %45 +%47 = OpConstant %4 2197.0 +%48 = OpConstant %4 2744.0 +%50 = OpTypePointer Function %8 +%51 = OpConstantNull %8 +%53 = OpTypePointer Function %3 +%54 = OpConstant %5 0 +%56 = OpTypePointer Function %5 +%57 = OpConstant %5 1 +%59 = OpTypePointer Function %4 +%60 = OpConstant %5 2 +%62 = OpTypePointer Function %6 +%63 = OpConstant %5 3 +%65 = OpTypePointer Function %7 +%66 = OpConstant %5 4 %68 = OpConstant %5 5 %70 = OpConstant %5 6 %72 = OpConstant %5 7 @@ -147,56 +151,52 @@ OpDecorate %107 Sample %103 = OpVariable %89 Input %105 = OpVariable %95 Input %107 = OpVariable %95 Input -%29 = OpFunction %2 None %30 -%12 = OpLabel -%9 = OpVariable %10 Function %11 -OpStore %26 %28 -OpBranch %48 -%48 = OpLabel -%50 = OpCompositeConstruct %3 %31 %32 %33 %34 -%52 = OpAccessChain %49 %9 %51 -OpStore %52 %50 -%55 = OpAccessChain %53 %9 %54 -OpStore %55 %35 -%58 = OpAccessChain %56 %9 %57 -OpStore %58 %36 -%60 = OpCompositeConstruct %6 %37 %38 -%62 = OpAccessChain %59 %9 %61 -OpStore %62 %60 -%64 = OpCompositeConstruct %7 %39 %40 %41 -%66 = OpAccessChain %63 %9 %65 -OpStore %66 %64 -%67 = OpCompositeConstruct %3 %42 %43 %44 %45 -%69 = OpAccessChain %49 %9 %68 -OpStore %69 %67 -%71 = OpAccessChain %56 %9 %70 -OpStore %71 %46 -%73 = OpAccessChain %56 %9 %72 -OpStore %73 %47 -%74 = OpLoad %8 %9 +%26 = OpFunction %2 None %27 +%9 = OpLabel +%49 = OpVariable %50 Function %51 +OpStore %23 %25 +OpBranch %52 +%52 = OpLabel +%55 = OpAccessChain %53 %49 %54 +OpStore %55 %32 +%58 = OpAccessChain %56 %49 %57 +OpStore %58 %33 +%61 = OpAccessChain %59 %49 %60 +OpStore %61 %34 +%64 = OpAccessChain %62 %49 %63 +OpStore %64 %37 +%67 = OpAccessChain %65 %49 %66 +OpStore %67 %41 +%69 = OpAccessChain %53 %49 %68 +OpStore %69 %46 +%71 = OpAccessChain %59 %49 %70 +OpStore %71 %47 +%73 = OpAccessChain %59 %49 %72 +OpStore %73 %48 +%74 = OpLoad %8 %49 %75 = OpCompositeExtract %3 %74 0 -OpStore %13 %75 -%76 = OpAccessChain %27 %13 %54 +OpStore %10 %75 +%76 = OpAccessChain %24 %10 %57 %77 = OpLoad %4 %76 %78 = OpFNegate %4 %77 OpStore %76 %78 %79 = OpCompositeExtract %5 %74 1 -OpStore %15 %79 +OpStore %12 %79 %80 = OpCompositeExtract %4 %74 2 -OpStore %17 %80 +OpStore %14 %80 %81 = OpCompositeExtract %6 %74 3 -OpStore %19 %81 +OpStore %16 %81 %82 = OpCompositeExtract %7 %74 4 -OpStore %21 %82 +OpStore %18 %82 %83 = OpCompositeExtract %3 %74 5 -OpStore %23 %83 +OpStore %20 %83 %84 = OpCompositeExtract %4 %74 6 -OpStore %24 %84 +OpStore %21 %84 %85 = OpCompositeExtract %4 %74 7 -OpStore %25 %85 +OpStore %22 %85 OpReturn OpFunctionEnd -%109 = OpFunction %2 None %30 +%109 = OpFunction %2 None %27 %86 = OpLabel %90 = OpLoad %3 %88 %93 = OpLoad %5 %91 diff --git a/tests/out/spv/math-functions.spvasm b/tests/out/spv/math-functions.spvasm index 7edb0e26b4..ba3e7cffb9 100644 --- a/tests/out/spv/math-functions.spvasm +++ b/tests/out/spv/math-functions.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 134 +; Bound: 126 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 @@ -32,123 +32,115 @@ OpMemberDecorate %13 1 Offset 16 %16 = OpTypeFunction %2 %17 = OpConstant %4 1.0 %18 = OpConstant %4 0.0 -%19 = OpConstant %6 -1 -%20 = OpConstant %4 -1.0 -%21 = OpConstantNull %5 -%22 = OpTypeInt 32 0 -%23 = OpConstant %22 0 -%24 = OpConstant %22 1 -%25 = OpConstant %6 0 -%26 = OpConstant %22 4294967295 -%27 = OpConstant %6 1 -%28 = OpConstant %6 2 -%29 = OpConstant %4 2.0 -%30 = OpConstant %6 3 -%31 = OpConstant %6 4 -%32 = OpConstant %4 1.5 -%40 = OpConstantComposite %3 %18 %18 %18 %18 -%41 = OpConstantComposite %3 %17 %17 %17 %17 -%50 = OpConstantNull %6 -%63 = OpTypeVector %22 2 -%73 = OpConstant %22 32 -%83 = OpConstantComposite %63 %73 %73 +%19 = OpConstantComposite %3 %18 %18 %18 %18 +%20 = OpConstant %6 -1 +%21 = OpConstantComposite %12 %20 %20 %20 %20 +%22 = OpConstant %4 -1.0 +%23 = OpConstantComposite %3 %22 %22 %22 %22 +%24 = OpConstantNull %5 +%25 = OpTypeInt 32 0 +%26 = OpConstant %25 0 +%27 = OpConstantComposite %5 %20 %20 +%28 = OpConstant %25 1 +%29 = OpTypeVector %25 2 +%30 = OpConstantComposite %29 %28 %28 +%31 = OpConstant %6 0 +%32 = OpConstant %25 4294967295 +%33 = OpConstantComposite %29 %26 %26 +%34 = OpConstantComposite %5 %31 %31 +%35 = OpConstant %6 1 +%36 = OpConstantComposite %5 %35 %35 +%37 = OpConstant %6 2 +%38 = OpConstant %4 2.0 +%39 = OpConstantComposite %7 %17 %38 +%40 = OpConstant %6 3 +%41 = OpConstant %6 4 +%42 = OpConstantComposite %5 %40 %41 +%43 = OpConstant %4 1.5 +%44 = OpConstantComposite %7 %43 %43 +%45 = OpConstantComposite %3 %43 %43 %43 %43 +%52 = OpConstantComposite %3 %17 %17 %17 %17 +%59 = OpConstantNull %6 +%77 = OpConstant %25 32 +%86 = OpConstantComposite %29 %77 %77 %95 = OpConstant %6 31 -%101 = OpConstantComposite %5 %95 %95 +%100 = OpConstantComposite %5 %95 %95 %15 = OpFunction %2 None %16 %14 = OpLabel -OpBranch %33 -%33 = OpLabel -%34 = OpCompositeConstruct %3 %18 %18 %18 %18 -%35 = OpExtInst %4 %1 Degrees %17 -%36 = OpExtInst %4 %1 Radians %17 -%37 = OpExtInst %3 %1 Degrees %34 -%38 = OpExtInst %3 %1 Radians %34 -%39 = OpExtInst %3 %1 FClamp %34 %40 %41 -%42 = OpExtInst %3 %1 Refract %34 %34 %17 -%43 = OpExtInst %6 %1 SSign %19 -%44 = OpCompositeConstruct %12 %19 %19 %19 %19 -%45 = OpExtInst %12 %1 SSign %44 -%46 = OpExtInst %4 %1 FSign %20 -%47 = OpCompositeConstruct %3 %20 %20 %20 %20 -%48 = OpExtInst %3 %1 FSign %47 -%51 = OpCompositeExtract %6 %21 0 -%52 = OpCompositeExtract %6 %21 0 -%53 = OpIMul %6 %51 %52 -%54 = OpIAdd %6 %50 %53 -%55 = OpCompositeExtract %6 %21 1 -%56 = OpCompositeExtract %6 %21 1 -%57 = OpIMul %6 %55 %56 -%49 = OpIAdd %6 %54 %57 -%58 = OpCopyObject %22 %23 -%59 = OpExtInst %22 %1 FindUMsb %58 -%60 = OpExtInst %6 %1 FindSMsb %19 -%61 = OpCompositeConstruct %5 %19 %19 -%62 = OpExtInst %5 %1 FindSMsb %61 -%64 = OpCompositeConstruct %63 %24 %24 -%65 = OpExtInst %63 %1 FindUMsb %64 -%66 = OpExtInst %6 %1 FindILsb %19 -%67 = OpExtInst %22 %1 FindILsb %24 -%68 = OpCompositeConstruct %5 %19 %19 -%69 = OpExtInst %5 %1 FindILsb %68 -%70 = OpCompositeConstruct %63 %24 %24 -%71 = OpExtInst %63 %1 FindILsb %70 -%74 = OpExtInst %22 %1 FindILsb %23 -%72 = OpExtInst %22 %1 UMin %73 %74 -%76 = OpExtInst %6 %1 FindILsb %25 -%75 = OpExtInst %6 %1 UMin %73 %76 -%78 = OpExtInst %22 %1 FindILsb %26 -%77 = OpExtInst %22 %1 UMin %73 %78 -%80 = OpExtInst %6 %1 FindILsb %19 -%79 = OpExtInst %6 %1 UMin %73 %80 -%81 = OpCompositeConstruct %63 %23 %23 -%84 = OpExtInst %63 %1 FindILsb %81 -%82 = OpExtInst %63 %1 UMin %83 %84 -%85 = OpCompositeConstruct %5 %25 %25 -%87 = OpExtInst %5 %1 FindILsb %85 -%86 = OpExtInst %5 %1 UMin %83 %87 -%88 = OpCompositeConstruct %63 %24 %24 -%90 = OpExtInst %63 %1 FindILsb %88 -%89 = OpExtInst %63 %1 UMin %83 %90 -%91 = OpCompositeConstruct %5 %27 %27 -%93 = OpExtInst %5 %1 FindILsb %91 -%92 = OpExtInst %5 %1 UMin %83 %93 -%96 = OpExtInst %6 %1 FindUMsb %19 +OpBranch %46 +%46 = OpLabel +%47 = OpExtInst %4 %1 Degrees %17 +%48 = OpExtInst %4 %1 Radians %17 +%49 = OpExtInst %3 %1 Degrees %19 +%50 = OpExtInst %3 %1 Radians %19 +%51 = OpExtInst %3 %1 FClamp %19 %19 %52 +%53 = OpExtInst %3 %1 Refract %19 %19 %17 +%54 = OpExtInst %6 %1 SSign %20 +%55 = OpExtInst %12 %1 SSign %21 +%56 = OpExtInst %4 %1 FSign %22 +%57 = OpExtInst %3 %1 FSign %23 +%60 = OpCompositeExtract %6 %24 0 +%61 = OpCompositeExtract %6 %24 0 +%62 = OpIMul %6 %60 %61 +%63 = OpIAdd %6 %59 %62 +%64 = OpCompositeExtract %6 %24 1 +%65 = OpCompositeExtract %6 %24 1 +%66 = OpIMul %6 %64 %65 +%58 = OpIAdd %6 %63 %66 +%67 = OpCopyObject %25 %26 +%68 = OpExtInst %25 %1 FindUMsb %67 +%69 = OpExtInst %6 %1 FindSMsb %20 +%70 = OpExtInst %5 %1 FindSMsb %27 +%71 = OpExtInst %29 %1 FindUMsb %30 +%72 = OpExtInst %6 %1 FindILsb %20 +%73 = OpExtInst %25 %1 FindILsb %28 +%74 = OpExtInst %5 %1 FindILsb %27 +%75 = OpExtInst %29 %1 FindILsb %30 +%78 = OpExtInst %25 %1 FindILsb %26 +%76 = OpExtInst %25 %1 UMin %77 %78 +%80 = OpExtInst %6 %1 FindILsb %31 +%79 = OpExtInst %6 %1 UMin %77 %80 +%82 = OpExtInst %25 %1 FindILsb %32 +%81 = OpExtInst %25 %1 UMin %77 %82 +%84 = OpExtInst %6 %1 FindILsb %20 +%83 = OpExtInst %6 %1 UMin %77 %84 +%87 = OpExtInst %29 %1 FindILsb %33 +%85 = OpExtInst %29 %1 UMin %86 %87 +%89 = OpExtInst %5 %1 FindILsb %34 +%88 = OpExtInst %5 %1 UMin %86 %89 +%91 = OpExtInst %29 %1 FindILsb %30 +%90 = OpExtInst %29 %1 UMin %86 %91 +%93 = OpExtInst %5 %1 FindILsb %36 +%92 = OpExtInst %5 %1 UMin %86 %93 +%96 = OpExtInst %6 %1 FindUMsb %20 %94 = OpISub %6 %95 %96 -%98 = OpExtInst %6 %1 FindUMsb %24 -%97 = OpISub %22 %95 %98 -%99 = OpCompositeConstruct %5 %19 %19 -%102 = OpExtInst %5 %1 FindUMsb %99 -%100 = OpISub %5 %101 %102 -%103 = OpCompositeConstruct %63 %24 %24 -%105 = OpExtInst %5 %1 FindUMsb %103 -%104 = OpISub %63 %101 %105 -%106 = OpExtInst %4 %1 Ldexp %17 %28 -%107 = OpCompositeConstruct %7 %17 %29 -%108 = OpCompositeConstruct %5 %30 %31 -%109 = OpExtInst %7 %1 Ldexp %107 %108 -%110 = OpExtInst %8 %1 ModfStruct %32 -%111 = OpExtInst %8 %1 ModfStruct %32 -%112 = OpCompositeExtract %4 %111 0 -%113 = OpExtInst %8 %1 ModfStruct %32 -%114 = OpCompositeExtract %4 %113 1 -%115 = OpCompositeConstruct %7 %32 %32 -%116 = OpExtInst %9 %1 ModfStruct %115 -%117 = OpCompositeConstruct %3 %32 %32 %32 %32 -%118 = OpExtInst %10 %1 ModfStruct %117 -%119 = OpCompositeExtract %3 %118 1 +%98 = OpExtInst %6 %1 FindUMsb %28 +%97 = OpISub %25 %95 %98 +%101 = OpExtInst %5 %1 FindUMsb %27 +%99 = OpISub %5 %100 %101 +%103 = OpExtInst %5 %1 FindUMsb %30 +%102 = OpISub %29 %100 %103 +%104 = OpExtInst %4 %1 Ldexp %17 %37 +%105 = OpExtInst %7 %1 Ldexp %39 %42 +%106 = OpExtInst %8 %1 ModfStruct %43 +%107 = OpExtInst %8 %1 ModfStruct %43 +%108 = OpCompositeExtract %4 %107 0 +%109 = OpExtInst %8 %1 ModfStruct %43 +%110 = OpCompositeExtract %4 %109 1 +%111 = OpExtInst %9 %1 ModfStruct %44 +%112 = OpExtInst %10 %1 ModfStruct %45 +%113 = OpCompositeExtract %3 %112 1 +%114 = OpCompositeExtract %4 %113 0 +%115 = OpExtInst %9 %1 ModfStruct %44 +%116 = OpCompositeExtract %7 %115 0 +%117 = OpCompositeExtract %4 %116 1 +%118 = OpExtInst %11 %1 FrexpStruct %43 +%119 = OpExtInst %11 %1 FrexpStruct %43 %120 = OpCompositeExtract %4 %119 0 -%121 = OpCompositeConstruct %7 %32 %32 -%122 = OpExtInst %9 %1 ModfStruct %121 -%123 = OpCompositeExtract %7 %122 0 -%124 = OpCompositeExtract %4 %123 1 -%125 = OpExtInst %11 %1 FrexpStruct %32 -%126 = OpExtInst %11 %1 FrexpStruct %32 -%127 = OpCompositeExtract %4 %126 0 -%128 = OpExtInst %11 %1 FrexpStruct %32 -%129 = OpCompositeExtract %6 %128 1 -%130 = OpCompositeConstruct %3 %32 %32 %32 %32 -%131 = OpExtInst %13 %1 FrexpStruct %130 -%132 = OpCompositeExtract %12 %131 1 -%133 = OpCompositeExtract %6 %132 0 +%121 = OpExtInst %11 %1 FrexpStruct %43 +%122 = OpCompositeExtract %6 %121 1 +%123 = OpExtInst %13 %1 FrexpStruct %45 +%124 = OpCompositeExtract %12 %123 1 +%125 = OpCompositeExtract %6 %124 0 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/operators.spvasm b/tests/out/spv/operators.spvasm index 5e2125b723..538c080e36 100644 --- a/tests/out/spv/operators.spvasm +++ b/tests/out/spv/operators.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 450 +; Bound: 308 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %439 "main" -OpExecutionMode %439 LocalSize 1 1 1 +OpEntryPoint GLCompute %297 "main" +OpExecutionMode %297 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -37,476 +37,331 @@ OpExecutionMode %439 LocalSize 1 1 1 %31 = OpConstantTrue %8 %32 = OpConstant %6 0 %33 = OpConstantFalse %8 -%34 = OpConstant %4 0.1 +%34 = OpConstantComposite %7 %33 %33 %33 %33 +%35 = OpConstant %4 0.1 +%36 = OpConstantComposite %5 %32 %32 %32 %32 %58 = OpConstant %4 2.0 -%59 = OpConstant %4 3.0 -%60 = OpConstant %4 4.0 -%61 = OpConstant %6 5 -%62 = OpConstant %6 2 -%78 = OpTypePointer Function %9 -%79 = OpConstantNull %9 -%82 = OpTypeFunction %9 -%98 = OpTypeFunction %10 %10 -%100 = OpTypeVector %8 3 -%101 = OpConstantComposite %10 %22 %22 %22 -%103 = OpConstantComposite %10 %20 %20 %20 -%107 = OpTypeFunction %2 -%120 = OpConstant %4 -1.0 -%121 = OpConstant %6 -1 -%122 = OpConstant %6 3 -%123 = OpConstant %14 3 -%124 = OpConstant %14 2 +%59 = OpConstantComposite %9 %58 %58 +%60 = OpConstantComposite %9 %20 %20 +%61 = OpConstant %4 3.0 +%62 = OpConstantComposite %9 %61 %61 +%63 = OpConstant %4 4.0 +%64 = OpConstantComposite %9 %63 %63 +%65 = OpConstant %6 5 +%66 = OpConstantComposite %5 %65 %65 %65 %65 +%67 = OpConstant %6 2 +%68 = OpConstantComposite %5 %67 %67 %67 %67 +%79 = OpTypeFunction %9 +%81 = OpTypePointer Function %9 +%93 = OpTypeFunction %10 %10 +%95 = OpTypeVector %8 3 +%96 = OpConstantComposite %10 %22 %22 %22 +%98 = OpConstantComposite %10 %20 %20 %20 +%102 = OpTypeFunction %2 +%103 = OpConstantComposite %11 %33 %33 +%104 = OpConstantComposite %95 %31 %31 %31 +%105 = OpConstantComposite %95 %33 %33 %33 +%106 = OpConstantComposite %7 %31 %31 %31 %31 +%107 = OpConstantComposite %7 %33 %33 %33 %33 +%115 = OpConstant %4 -1.0 +%116 = OpConstant %6 -1 +%117 = OpConstantComposite %12 %116 %116 +%118 = OpConstantComposite %9 %115 %115 +%119 = OpConstant %6 3 +%120 = OpConstant %14 3 +%121 = OpConstantComposite %12 %67 %67 +%122 = OpConstantComposite %12 %26 %26 +%123 = OpConstant %14 2 +%124 = OpConstantComposite %13 %123 %123 %123 %125 = OpConstant %14 1 -%126 = OpConstant %14 0 -%127 = OpConstantNull %16 -%128 = OpConstantNull %17 -%129 = OpConstantNull %18 -%293 = OpConstant %6 -2 -%294 = OpConstant %14 4294967294 -%295 = OpConstant %6 4 -%296 = OpConstant %14 4 -%388 = OpTypePointer Function %6 -%389 = OpConstantNull %6 -%391 = OpTypePointer Function %19 -%392 = OpConstantNull %19 -%422 = OpTypePointer Function %6 -%433 = OpConstant %6 -5 -%434 = OpConstant %6 6 -%435 = OpConstant %6 -7 -%436 = OpConstant %6 -8 +%126 = OpConstantComposite %13 %125 %125 %125 +%127 = OpConstantComposite %3 %58 %58 %58 %58 +%128 = OpConstantComposite %3 %20 %20 %20 %20 +%129 = OpConstant %14 0 +%130 = OpConstantComposite %15 %123 %123 +%131 = OpConstantComposite %15 %125 %125 +%132 = OpConstantComposite %12 %67 %67 +%133 = OpConstantComposite %15 %123 %123 +%134 = OpConstantComposite %9 %58 %58 +%135 = OpConstantNull %16 +%136 = OpConstantComposite %10 %22 %22 %22 +%137 = OpConstantComposite %16 %136 %136 %136 +%138 = OpConstantNull %17 +%139 = OpConstantComposite %10 %58 %58 %58 +%140 = OpConstantNull %18 +%208 = OpConstant %6 -2 +%209 = OpConstant %14 4294967294 +%210 = OpConstantComposite %12 %208 %208 +%211 = OpConstantComposite %13 %209 %209 %209 +%212 = OpConstant %6 4 +%213 = OpConstant %14 4 +%248 = OpConstantNull %19 +%250 = OpTypePointer Function %6 +%252 = OpTypePointer Function %19 +%280 = OpTypePointer Function %6 +%291 = OpConstant %6 -5 +%292 = OpConstant %6 6 +%293 = OpConstant %6 -7 +%294 = OpConstant %6 -8 +%298 = OpConstantComposite %10 %20 %20 %20 %29 = OpFunction %3 None %30 %28 = OpLabel -OpBranch %35 -%35 = OpLabel -%36 = OpSelect %6 %31 %26 %32 -%38 = OpCompositeConstruct %7 %31 %31 %31 %31 -%37 = OpSelect %3 %38 %21 %23 -%39 = OpCompositeConstruct %7 %33 %33 %33 %33 -%40 = OpSelect %3 %39 %23 %21 -%41 = OpExtInst %3 %1 FMix %23 %21 %25 -%43 = OpCompositeConstruct %3 %34 %34 %34 %34 -%42 = OpExtInst %3 %1 FMix %23 %21 %43 -%44 = OpBitcast %4 %26 -%45 = OpBitcast %3 %27 -%46 = OpCompositeConstruct %5 %32 %32 %32 %32 -%47 = OpCompositeConstruct %5 %36 %36 %36 %36 -%48 = OpIAdd %5 %47 %46 +OpBranch %37 +%37 = OpLabel +%38 = OpSelect %6 %31 %26 %32 +%40 = OpCompositeConstruct %7 %31 %31 %31 %31 +%39 = OpSelect %3 %40 %21 %23 +%41 = OpSelect %3 %34 %23 %21 +%42 = OpExtInst %3 %1 FMix %23 %21 %25 +%44 = OpCompositeConstruct %3 %35 %35 %35 %35 +%43 = OpExtInst %3 %1 FMix %23 %21 %44 +%45 = OpBitcast %4 %26 +%46 = OpBitcast %3 %27 +%47 = OpCompositeConstruct %5 %38 %38 %38 %38 +%48 = OpIAdd %5 %47 %36 %49 = OpConvertSToF %3 %48 -%50 = OpFAdd %3 %49 %37 -%51 = OpFAdd %3 %50 %41 -%52 = OpFAdd %3 %51 %42 -%53 = OpCompositeConstruct %3 %44 %44 %44 %44 +%50 = OpFAdd %3 %49 %39 +%51 = OpFAdd %3 %50 %42 +%52 = OpFAdd %3 %51 %43 +%53 = OpCompositeConstruct %3 %45 %45 %45 %45 %54 = OpFAdd %3 %52 %53 -%55 = OpFAdd %3 %54 %45 +%55 = OpFAdd %3 %54 %46 OpReturnValue %55 OpFunctionEnd %57 = OpFunction %3 None %30 %56 = OpLabel -OpBranch %63 -%63 = OpLabel -%64 = OpCompositeConstruct %9 %58 %58 -%65 = OpCompositeConstruct %9 %20 %20 -%66 = OpFAdd %9 %65 %64 -%67 = OpCompositeConstruct %9 %59 %59 -%68 = OpFSub %9 %66 %67 -%69 = OpCompositeConstruct %9 %60 %60 -%70 = OpFDiv %9 %68 %69 -%71 = OpCompositeConstruct %5 %61 %61 %61 %61 -%72 = OpCompositeConstruct %5 %62 %62 %62 %62 -%73 = OpSRem %5 %71 %72 -%74 = OpVectorShuffle %3 %70 %70 0 1 0 1 +OpBranch %69 +%69 = OpLabel +%70 = OpFAdd %9 %60 %59 +%71 = OpFSub %9 %70 %62 +%72 = OpFDiv %9 %71 %64 +%73 = OpSRem %5 %66 %68 +%74 = OpVectorShuffle %3 %72 %72 0 1 0 1 %75 = OpConvertSToF %3 %73 %76 = OpFAdd %3 %74 %75 OpReturnValue %76 OpFunctionEnd -%81 = OpFunction %9 None %82 -%80 = OpLabel -%77 = OpVariable %78 Function %79 -OpBranch %83 -%83 = OpLabel -%84 = OpCompositeConstruct %9 %58 %58 -OpStore %77 %84 -%85 = OpLoad %9 %77 -%86 = OpCompositeConstruct %9 %20 %20 -%87 = OpFAdd %9 %85 %86 -OpStore %77 %87 -%88 = OpLoad %9 %77 -%89 = OpCompositeConstruct %9 %59 %59 -%90 = OpFSub %9 %88 %89 -OpStore %77 %90 -%91 = OpLoad %9 %77 -%92 = OpCompositeConstruct %9 %60 %60 -%93 = OpFDiv %9 %91 %92 -OpStore %77 %93 -%94 = OpLoad %9 %77 -OpReturnValue %94 +%78 = OpFunction %9 None %79 +%77 = OpLabel +%80 = OpVariable %81 Function %59 +OpBranch %82 +%82 = OpLabel +%83 = OpLoad %9 %80 +%84 = OpFAdd %9 %83 %60 +OpStore %80 %84 +%85 = OpLoad %9 %80 +%86 = OpFSub %9 %85 %62 +OpStore %80 %86 +%87 = OpLoad %9 %80 +%88 = OpFDiv %9 %87 %64 +OpStore %80 %88 +%89 = OpLoad %9 %80 +OpReturnValue %89 OpFunctionEnd -%97 = OpFunction %10 None %98 -%96 = OpFunctionParameter %10 -%95 = OpLabel -OpBranch %99 -%99 = OpLabel -%102 = OpFUnordNotEqual %100 %96 %101 -%104 = OpSelect %10 %102 %103 %101 -OpReturnValue %104 +%92 = OpFunction %10 None %93 +%91 = OpFunctionParameter %10 +%90 = OpLabel +OpBranch %94 +%94 = OpLabel +%97 = OpFUnordNotEqual %95 %91 %96 +%99 = OpSelect %10 %97 %98 %96 +OpReturnValue %99 OpFunctionEnd -%106 = OpFunction %2 None %107 -%105 = OpLabel +%101 = OpFunction %2 None %102 +%100 = OpLabel OpBranch %108 %108 = OpLabel -%109 = OpCompositeConstruct %11 %33 %33 -%110 = OpLogicalOr %8 %31 %33 -%111 = OpCompositeConstruct %100 %31 %31 %31 -%112 = OpCompositeConstruct %100 %33 %33 %33 -%113 = OpLogicalOr %100 %111 %112 -%114 = OpLogicalAnd %8 %31 %33 -%115 = OpCompositeConstruct %7 %31 %31 %31 %31 -%116 = OpCompositeConstruct %7 %33 %33 %33 %33 -%117 = OpLogicalAnd %7 %115 %116 +%109 = OpLogicalOr %8 %31 %33 +%110 = OpLogicalOr %95 %104 %105 +%111 = OpLogicalAnd %8 %31 %33 +%112 = OpLogicalAnd %7 %106 %107 OpReturn OpFunctionEnd -%119 = OpFunction %2 None %107 -%118 = OpLabel -OpBranch %130 -%130 = OpLabel -%131 = OpCompositeConstruct %12 %121 %121 -%132 = OpCompositeConstruct %9 %120 %120 -%133 = OpCompositeConstruct %12 %62 %62 -%134 = OpCompositeConstruct %12 %26 %26 -%135 = OpIAdd %12 %133 %134 -%136 = OpCompositeConstruct %13 %124 %124 %124 -%137 = OpCompositeConstruct %13 %125 %125 %125 -%138 = OpIAdd %13 %136 %137 -%139 = OpCompositeConstruct %3 %58 %58 %58 %58 -%140 = OpCompositeConstruct %3 %20 %20 %20 %20 -%141 = OpFAdd %3 %139 %140 -%142 = OpCompositeConstruct %12 %62 %62 -%143 = OpCompositeConstruct %12 %26 %26 -%144 = OpISub %12 %142 %143 -%145 = OpCompositeConstruct %13 %124 %124 %124 -%146 = OpCompositeConstruct %13 %125 %125 %125 -%147 = OpISub %13 %145 %146 -%148 = OpCompositeConstruct %3 %58 %58 %58 %58 -%149 = OpCompositeConstruct %3 %20 %20 %20 %20 -%150 = OpFSub %3 %148 %149 -%151 = OpCompositeConstruct %12 %62 %62 -%152 = OpCompositeConstruct %12 %26 %26 -%153 = OpIMul %12 %151 %152 -%154 = OpCompositeConstruct %13 %124 %124 %124 -%155 = OpCompositeConstruct %13 %125 %125 %125 -%156 = OpIMul %13 %154 %155 -%157 = OpCompositeConstruct %3 %58 %58 %58 %58 -%158 = OpCompositeConstruct %3 %20 %20 %20 %20 -%159 = OpFMul %3 %157 %158 -%160 = OpCompositeConstruct %12 %62 %62 -%161 = OpCompositeConstruct %12 %26 %26 -%162 = OpSDiv %12 %160 %161 -%163 = OpCompositeConstruct %13 %124 %124 %124 -%164 = OpCompositeConstruct %13 %125 %125 %125 -%165 = OpUDiv %13 %163 %164 -%166 = OpCompositeConstruct %3 %58 %58 %58 %58 -%167 = OpCompositeConstruct %3 %20 %20 %20 %20 -%168 = OpFDiv %3 %166 %167 -%169 = OpCompositeConstruct %12 %62 %62 -%170 = OpCompositeConstruct %12 %26 %26 -%171 = OpSRem %12 %169 %170 -%172 = OpCompositeConstruct %13 %124 %124 %124 -%173 = OpCompositeConstruct %13 %125 %125 %125 -%174 = OpUMod %13 %172 %173 -%175 = OpCompositeConstruct %3 %58 %58 %58 %58 -%176 = OpCompositeConstruct %3 %20 %20 %20 %20 -%177 = OpFRem %3 %175 %176 -OpBranch %178 -%178 = OpLabel -%180 = OpCompositeConstruct %12 %62 %62 -%181 = OpCompositeConstruct %12 %26 %26 -%182 = OpIAdd %12 %180 %181 -%183 = OpCompositeConstruct %12 %26 %26 -%184 = OpCompositeConstruct %12 %62 %62 -%185 = OpIAdd %12 %184 %183 -%186 = OpCompositeConstruct %15 %124 %124 -%187 = OpCompositeConstruct %15 %125 %125 -%188 = OpIAdd %15 %186 %187 -%189 = OpCompositeConstruct %15 %125 %125 -%190 = OpCompositeConstruct %15 %124 %124 -%191 = OpIAdd %15 %190 %189 -%192 = OpCompositeConstruct %9 %58 %58 -%193 = OpCompositeConstruct %9 %20 %20 -%194 = OpFAdd %9 %192 %193 -%195 = OpCompositeConstruct %9 %20 %20 -%196 = OpCompositeConstruct %9 %58 %58 -%197 = OpFAdd %9 %196 %195 -%198 = OpCompositeConstruct %12 %62 %62 -%199 = OpCompositeConstruct %12 %26 %26 -%200 = OpISub %12 %198 %199 -%201 = OpCompositeConstruct %12 %26 %26 -%202 = OpCompositeConstruct %12 %62 %62 -%203 = OpISub %12 %202 %201 -%204 = OpCompositeConstruct %15 %124 %124 -%205 = OpCompositeConstruct %15 %125 %125 -%206 = OpISub %15 %204 %205 -%207 = OpCompositeConstruct %15 %125 %125 -%208 = OpCompositeConstruct %15 %124 %124 -%209 = OpISub %15 %208 %207 -%210 = OpCompositeConstruct %9 %58 %58 -%211 = OpCompositeConstruct %9 %20 %20 -%212 = OpFSub %9 %210 %211 -%213 = OpCompositeConstruct %9 %20 %20 -%214 = OpCompositeConstruct %9 %58 %58 -%215 = OpFSub %9 %214 %213 -%216 = OpCompositeConstruct %12 %62 %62 -%217 = OpCompositeConstruct %12 %62 %62 -%218 = OpCompositeConstruct %15 %124 %124 -%219 = OpCompositeConstruct %15 %124 %124 -%220 = OpCompositeConstruct %9 %58 %58 -%221 = OpCompositeConstruct %9 %58 %58 -%222 = OpCompositeConstruct %12 %62 %62 -%223 = OpCompositeConstruct %12 %26 %26 -%224 = OpSDiv %12 %222 %223 -%225 = OpCompositeConstruct %12 %26 %26 -%226 = OpCompositeConstruct %12 %62 %62 -%227 = OpSDiv %12 %226 %225 -%228 = OpCompositeConstruct %15 %124 %124 -%229 = OpCompositeConstruct %15 %125 %125 -%230 = OpUDiv %15 %228 %229 -%231 = OpCompositeConstruct %15 %125 %125 -%232 = OpCompositeConstruct %15 %124 %124 -%233 = OpUDiv %15 %232 %231 -%234 = OpCompositeConstruct %9 %58 %58 -%235 = OpCompositeConstruct %9 %20 %20 -%236 = OpFDiv %9 %234 %235 -%237 = OpCompositeConstruct %9 %20 %20 -%238 = OpCompositeConstruct %9 %58 %58 -%239 = OpFDiv %9 %238 %237 -%240 = OpCompositeConstruct %12 %62 %62 -%241 = OpCompositeConstruct %12 %26 %26 -%242 = OpSRem %12 %240 %241 -%243 = OpCompositeConstruct %12 %26 %26 -%244 = OpCompositeConstruct %12 %62 %62 -%245 = OpSRem %12 %244 %243 -%246 = OpCompositeConstruct %15 %124 %124 -%247 = OpCompositeConstruct %15 %125 %125 -%248 = OpUMod %15 %246 %247 -%249 = OpCompositeConstruct %15 %125 %125 -%250 = OpCompositeConstruct %15 %124 %124 -%251 = OpUMod %15 %250 %249 -%252 = OpCompositeConstruct %9 %58 %58 -%253 = OpCompositeConstruct %9 %20 %20 -%254 = OpFRem %9 %252 %253 -%255 = OpCompositeConstruct %9 %20 %20 -%256 = OpCompositeConstruct %9 %58 %58 -%257 = OpFRem %9 %256 %255 -OpBranch %179 -%179 = OpLabel -%259 = OpCompositeExtract %10 %127 0 -%260 = OpCompositeExtract %10 %127 0 -%261 = OpFAdd %10 %259 %260 -%262 = OpCompositeExtract %10 %127 1 -%263 = OpCompositeExtract %10 %127 1 -%264 = OpFAdd %10 %262 %263 -%265 = OpCompositeExtract %10 %127 2 -%266 = OpCompositeExtract %10 %127 2 -%267 = OpFAdd %10 %265 %266 -%258 = OpCompositeConstruct %16 %261 %264 %267 -%269 = OpCompositeExtract %10 %127 0 -%270 = OpCompositeExtract %10 %127 0 -%271 = OpFSub %10 %269 %270 -%272 = OpCompositeExtract %10 %127 1 -%273 = OpCompositeExtract %10 %127 1 -%274 = OpFSub %10 %272 %273 -%275 = OpCompositeExtract %10 %127 2 -%276 = OpCompositeExtract %10 %127 2 -%277 = OpFSub %10 %275 %276 -%268 = OpCompositeConstruct %16 %271 %274 %277 -%278 = OpCompositeConstruct %10 %22 %22 %22 -%279 = OpCompositeConstruct %10 %22 %22 %22 -%280 = OpCompositeConstruct %10 %22 %22 %22 -%281 = OpCompositeConstruct %16 %278 %279 %280 -%282 = OpCompositeConstruct %10 %22 %22 %22 -%283 = OpCompositeConstruct %10 %22 %22 %22 -%284 = OpCompositeConstruct %10 %22 %22 %22 -%285 = OpCompositeConstruct %16 %282 %283 %284 -%286 = OpCompositeConstruct %3 %20 %20 %20 %20 -%287 = OpMatrixTimesVector %10 %128 %286 -%288 = OpCompositeConstruct %10 %58 %58 %58 -%289 = OpVectorTimesMatrix %3 %288 %128 -%290 = OpMatrixTimesMatrix %16 %128 %129 +%114 = OpFunction %2 None %102 +%113 = OpLabel +OpBranch %141 +%141 = OpLabel +%142 = OpIAdd %12 %121 %122 +%143 = OpIAdd %13 %124 %126 +%144 = OpFAdd %3 %127 %128 +%145 = OpISub %12 %121 %122 +%146 = OpISub %13 %124 %126 +%147 = OpFSub %3 %127 %128 +%148 = OpIMul %12 %121 %122 +%149 = OpIMul %13 %124 %126 +%150 = OpFMul %3 %127 %128 +%151 = OpSDiv %12 %121 %122 +%152 = OpUDiv %13 %124 %126 +%153 = OpFDiv %3 %127 %128 +%154 = OpSRem %12 %121 %122 +%155 = OpUMod %13 %124 %126 +%156 = OpFRem %3 %127 %128 +OpBranch %157 +%157 = OpLabel +%159 = OpIAdd %12 %121 %122 +%160 = OpIAdd %12 %121 %122 +%161 = OpIAdd %15 %130 %131 +%162 = OpIAdd %15 %130 %131 +%163 = OpFAdd %9 %59 %60 +%164 = OpFAdd %9 %59 %60 +%165 = OpISub %12 %121 %122 +%166 = OpISub %12 %121 %122 +%167 = OpISub %15 %130 %131 +%168 = OpISub %15 %130 %131 +%169 = OpFSub %9 %59 %60 +%170 = OpFSub %9 %59 %60 +%171 = OpSDiv %12 %121 %122 +%172 = OpSDiv %12 %121 %122 +%173 = OpUDiv %15 %130 %131 +%174 = OpUDiv %15 %130 %131 +%175 = OpFDiv %9 %59 %60 +%176 = OpFDiv %9 %59 %60 +%177 = OpSRem %12 %121 %122 +%178 = OpSRem %12 %121 %122 +%179 = OpUMod %15 %130 %131 +%180 = OpUMod %15 %130 %131 +%181 = OpFRem %9 %59 %60 +%182 = OpFRem %9 %59 %60 +OpBranch %158 +%158 = OpLabel +%184 = OpCompositeExtract %10 %135 0 +%185 = OpCompositeExtract %10 %135 0 +%186 = OpFAdd %10 %184 %185 +%187 = OpCompositeExtract %10 %135 1 +%188 = OpCompositeExtract %10 %135 1 +%189 = OpFAdd %10 %187 %188 +%190 = OpCompositeExtract %10 %135 2 +%191 = OpCompositeExtract %10 %135 2 +%192 = OpFAdd %10 %190 %191 +%183 = OpCompositeConstruct %16 %186 %189 %192 +%194 = OpCompositeExtract %10 %135 0 +%195 = OpCompositeExtract %10 %135 0 +%196 = OpFSub %10 %194 %195 +%197 = OpCompositeExtract %10 %135 1 +%198 = OpCompositeExtract %10 %135 1 +%199 = OpFSub %10 %197 %198 +%200 = OpCompositeExtract %10 %135 2 +%201 = OpCompositeExtract %10 %135 2 +%202 = OpFSub %10 %200 %201 +%193 = OpCompositeConstruct %16 %196 %199 %202 +%203 = OpMatrixTimesVector %10 %138 %128 +%204 = OpVectorTimesMatrix %3 %139 %138 +%205 = OpMatrixTimesMatrix %16 %138 %140 OpReturn OpFunctionEnd -%292 = OpFunction %2 None %107 -%291 = OpLabel -OpBranch %297 -%297 = OpLabel -%298 = OpCompositeConstruct %12 %293 %293 -%299 = OpCompositeConstruct %13 %294 %294 %294 -%300 = OpCompositeConstruct %12 %62 %62 -%301 = OpCompositeConstruct %12 %26 %26 -%302 = OpBitwiseOr %12 %300 %301 -%303 = OpCompositeConstruct %13 %124 %124 %124 -%304 = OpCompositeConstruct %13 %125 %125 %125 -%305 = OpBitwiseOr %13 %303 %304 -%306 = OpCompositeConstruct %12 %62 %62 -%307 = OpCompositeConstruct %12 %26 %26 -%308 = OpBitwiseAnd %12 %306 %307 -%309 = OpCompositeConstruct %13 %124 %124 %124 -%310 = OpCompositeConstruct %13 %125 %125 %125 -%311 = OpBitwiseAnd %13 %309 %310 -%312 = OpCompositeConstruct %12 %62 %62 -%313 = OpCompositeConstruct %12 %26 %26 -%314 = OpBitwiseXor %12 %312 %313 -%315 = OpCompositeConstruct %13 %124 %124 %124 -%316 = OpCompositeConstruct %13 %125 %125 %125 -%317 = OpBitwiseXor %13 %315 %316 -%318 = OpCompositeConstruct %12 %62 %62 -%319 = OpCompositeConstruct %15 %125 %125 -%320 = OpShiftLeftLogical %12 %318 %319 -%321 = OpCompositeConstruct %13 %124 %124 %124 -%322 = OpCompositeConstruct %13 %125 %125 %125 -%323 = OpShiftLeftLogical %13 %321 %322 -%324 = OpCompositeConstruct %12 %62 %62 -%325 = OpCompositeConstruct %15 %125 %125 -%326 = OpShiftRightArithmetic %12 %324 %325 -%327 = OpCompositeConstruct %13 %124 %124 %124 -%328 = OpCompositeConstruct %13 %125 %125 %125 -%329 = OpShiftRightLogical %13 %327 %328 +%207 = OpFunction %2 None %102 +%206 = OpLabel +OpBranch %214 +%214 = OpLabel +%215 = OpBitwiseOr %12 %121 %122 +%216 = OpBitwiseOr %13 %124 %126 +%217 = OpBitwiseAnd %12 %121 %122 +%218 = OpBitwiseAnd %13 %124 %126 +%219 = OpBitwiseXor %12 %121 %122 +%220 = OpBitwiseXor %13 %124 %126 +%221 = OpShiftLeftLogical %12 %121 %131 +%222 = OpShiftLeftLogical %13 %124 %126 +%223 = OpShiftRightArithmetic %12 %121 %131 +%224 = OpShiftRightLogical %13 %124 %126 OpReturn OpFunctionEnd -%331 = OpFunction %2 None %107 -%330 = OpLabel -OpBranch %332 -%332 = OpLabel -%333 = OpCompositeConstruct %12 %62 %62 -%334 = OpCompositeConstruct %12 %26 %26 -%335 = OpIEqual %11 %333 %334 -%336 = OpCompositeConstruct %13 %124 %124 %124 -%337 = OpCompositeConstruct %13 %125 %125 %125 -%338 = OpIEqual %100 %336 %337 -%339 = OpCompositeConstruct %3 %58 %58 %58 %58 -%340 = OpCompositeConstruct %3 %20 %20 %20 %20 -%341 = OpFOrdEqual %7 %339 %340 -%342 = OpCompositeConstruct %12 %62 %62 -%343 = OpCompositeConstruct %12 %26 %26 -%344 = OpINotEqual %11 %342 %343 -%345 = OpCompositeConstruct %13 %124 %124 %124 -%346 = OpCompositeConstruct %13 %125 %125 %125 -%347 = OpINotEqual %100 %345 %346 -%348 = OpCompositeConstruct %3 %58 %58 %58 %58 -%349 = OpCompositeConstruct %3 %20 %20 %20 %20 -%350 = OpFOrdNotEqual %7 %348 %349 -%351 = OpCompositeConstruct %12 %62 %62 -%352 = OpCompositeConstruct %12 %26 %26 -%353 = OpSLessThan %11 %351 %352 -%354 = OpCompositeConstruct %13 %124 %124 %124 -%355 = OpCompositeConstruct %13 %125 %125 %125 -%356 = OpULessThan %100 %354 %355 -%357 = OpCompositeConstruct %3 %58 %58 %58 %58 -%358 = OpCompositeConstruct %3 %20 %20 %20 %20 -%359 = OpFOrdLessThan %7 %357 %358 -%360 = OpCompositeConstruct %12 %62 %62 -%361 = OpCompositeConstruct %12 %26 %26 -%362 = OpSLessThanEqual %11 %360 %361 -%363 = OpCompositeConstruct %13 %124 %124 %124 -%364 = OpCompositeConstruct %13 %125 %125 %125 -%365 = OpULessThanEqual %100 %363 %364 -%366 = OpCompositeConstruct %3 %58 %58 %58 %58 -%367 = OpCompositeConstruct %3 %20 %20 %20 %20 -%368 = OpFOrdLessThanEqual %7 %366 %367 -%369 = OpCompositeConstruct %12 %62 %62 -%370 = OpCompositeConstruct %12 %26 %26 -%371 = OpSGreaterThan %11 %369 %370 -%372 = OpCompositeConstruct %13 %124 %124 %124 -%373 = OpCompositeConstruct %13 %125 %125 %125 -%374 = OpUGreaterThan %100 %372 %373 -%375 = OpCompositeConstruct %3 %58 %58 %58 %58 -%376 = OpCompositeConstruct %3 %20 %20 %20 %20 -%377 = OpFOrdGreaterThan %7 %375 %376 -%378 = OpCompositeConstruct %12 %62 %62 -%379 = OpCompositeConstruct %12 %26 %26 -%380 = OpSGreaterThanEqual %11 %378 %379 -%381 = OpCompositeConstruct %13 %124 %124 %124 -%382 = OpCompositeConstruct %13 %125 %125 %125 -%383 = OpUGreaterThanEqual %100 %381 %382 -%384 = OpCompositeConstruct %3 %58 %58 %58 %58 -%385 = OpCompositeConstruct %3 %20 %20 %20 %20 -%386 = OpFOrdGreaterThanEqual %7 %384 %385 +%226 = OpFunction %2 None %102 +%225 = OpLabel +OpBranch %227 +%227 = OpLabel +%228 = OpIEqual %11 %121 %122 +%229 = OpIEqual %95 %124 %126 +%230 = OpFOrdEqual %7 %127 %128 +%231 = OpINotEqual %11 %121 %122 +%232 = OpINotEqual %95 %124 %126 +%233 = OpFOrdNotEqual %7 %127 %128 +%234 = OpSLessThan %11 %121 %122 +%235 = OpULessThan %95 %124 %126 +%236 = OpFOrdLessThan %7 %127 %128 +%237 = OpSLessThanEqual %11 %121 %122 +%238 = OpULessThanEqual %95 %124 %126 +%239 = OpFOrdLessThanEqual %7 %127 %128 +%240 = OpSGreaterThan %11 %121 %122 +%241 = OpUGreaterThan %95 %124 %126 +%242 = OpFOrdGreaterThan %7 %127 %128 +%243 = OpSGreaterThanEqual %11 %121 %122 +%244 = OpUGreaterThanEqual %95 %124 %126 +%245 = OpFOrdGreaterThanEqual %7 %127 %128 OpReturn OpFunctionEnd -%394 = OpFunction %2 None %107 -%393 = OpLabel -%387 = OpVariable %388 Function %389 -%390 = OpVariable %391 Function %392 -OpBranch %395 -%395 = OpLabel -OpStore %387 %26 -%396 = OpLoad %6 %387 -%397 = OpIAdd %6 %396 %26 -OpStore %387 %397 -%398 = OpLoad %6 %387 -%399 = OpISub %6 %398 %26 -OpStore %387 %399 -%400 = OpLoad %6 %387 -%401 = OpLoad %6 %387 -%402 = OpIMul %6 %401 %400 -OpStore %387 %402 -%403 = OpLoad %6 %387 -%404 = OpLoad %6 %387 -%405 = OpSDiv %6 %404 %403 -OpStore %387 %405 -%406 = OpLoad %6 %387 -%407 = OpSRem %6 %406 %26 -OpStore %387 %407 -%408 = OpLoad %6 %387 -%409 = OpBitwiseAnd %6 %408 %32 -OpStore %387 %409 -%410 = OpLoad %6 %387 -%411 = OpBitwiseOr %6 %410 %32 -OpStore %387 %411 -%412 = OpLoad %6 %387 -%413 = OpBitwiseXor %6 %412 %32 -OpStore %387 %413 -%414 = OpLoad %6 %387 -%415 = OpShiftLeftLogical %6 %414 %124 -OpStore %387 %415 -%416 = OpLoad %6 %387 -%417 = OpShiftRightArithmetic %6 %416 %125 -OpStore %387 %417 -%418 = OpLoad %6 %387 -%419 = OpIAdd %6 %418 %26 -OpStore %387 %419 -%420 = OpLoad %6 %387 -%421 = OpISub %6 %420 %26 -OpStore %387 %421 -OpStore %390 %392 -%423 = OpAccessChain %422 %390 %125 -%424 = OpLoad %6 %423 -%425 = OpIAdd %6 %424 %26 -%426 = OpAccessChain %422 %390 %125 -OpStore %426 %425 -%427 = OpAccessChain %422 %390 %125 -%428 = OpLoad %6 %427 -%429 = OpISub %6 %428 %26 -%430 = OpAccessChain %422 %390 %125 -OpStore %430 %429 +%247 = OpFunction %2 None %102 +%246 = OpLabel +%249 = OpVariable %250 Function %26 +%251 = OpVariable %252 Function %248 +OpBranch %253 +%253 = OpLabel +%254 = OpLoad %6 %249 +%255 = OpIAdd %6 %254 %26 +OpStore %249 %255 +%256 = OpLoad %6 %249 +%257 = OpISub %6 %256 %26 +OpStore %249 %257 +%258 = OpLoad %6 %249 +%259 = OpLoad %6 %249 +%260 = OpIMul %6 %259 %258 +OpStore %249 %260 +%261 = OpLoad %6 %249 +%262 = OpLoad %6 %249 +%263 = OpSDiv %6 %262 %261 +OpStore %249 %263 +%264 = OpLoad %6 %249 +%265 = OpSRem %6 %264 %26 +OpStore %249 %265 +%266 = OpLoad %6 %249 +%267 = OpBitwiseAnd %6 %266 %32 +OpStore %249 %267 +%268 = OpLoad %6 %249 +%269 = OpBitwiseOr %6 %268 %32 +OpStore %249 %269 +%270 = OpLoad %6 %249 +%271 = OpBitwiseXor %6 %270 %32 +OpStore %249 %271 +%272 = OpLoad %6 %249 +%273 = OpShiftLeftLogical %6 %272 %123 +OpStore %249 %273 +%274 = OpLoad %6 %249 +%275 = OpShiftRightArithmetic %6 %274 %125 +OpStore %249 %275 +%276 = OpLoad %6 %249 +%277 = OpIAdd %6 %276 %26 +OpStore %249 %277 +%278 = OpLoad %6 %249 +%279 = OpISub %6 %278 %26 +OpStore %249 %279 +%281 = OpAccessChain %280 %251 %125 +%282 = OpLoad %6 %281 +%283 = OpIAdd %6 %282 %26 +%284 = OpAccessChain %280 %251 %125 +OpStore %284 %283 +%285 = OpAccessChain %280 %251 %125 +%286 = OpLoad %6 %285 +%287 = OpISub %6 %286 %26 +%288 = OpAccessChain %280 %251 %125 +OpStore %288 %287 OpReturn OpFunctionEnd -%432 = OpFunction %2 None %107 -%431 = OpLabel -OpBranch %437 -%437 = OpLabel +%290 = OpFunction %2 None %102 +%289 = OpLabel +OpBranch %295 +%295 = OpLabel OpReturn OpFunctionEnd -%439 = OpFunction %2 None %107 -%438 = OpLabel -OpBranch %440 -%440 = OpLabel -%441 = OpFunctionCall %3 %29 -%442 = OpFunctionCall %3 %57 -%443 = OpCompositeConstruct %10 %20 %20 %20 -%444 = OpFunctionCall %10 %97 %443 -%445 = OpFunctionCall %2 %106 -%446 = OpFunctionCall %2 %119 -%447 = OpFunctionCall %2 %292 -%448 = OpFunctionCall %2 %331 -%449 = OpFunctionCall %2 %394 +%297 = OpFunction %2 None %102 +%296 = OpLabel +OpBranch %299 +%299 = OpLabel +%300 = OpFunctionCall %3 %29 +%301 = OpFunctionCall %3 %57 +%302 = OpFunctionCall %10 %92 %298 +%303 = OpFunctionCall %2 %101 +%304 = OpFunctionCall %2 %114 +%305 = OpFunctionCall %2 %207 +%306 = OpFunctionCall %2 %226 +%307 = OpFunctionCall %2 %247 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/padding.spvasm b/tests/out/spv/padding.spvasm index e0b4251ae4..aae9f2cb74 100644 --- a/tests/out/spv/padding.spvasm +++ b/tests/out/spv/padding.spvasm @@ -73,6 +73,7 @@ OpDecorate %24 BuiltIn Position %31 = OpTypePointer Uniform %10 %33 = OpTypePointer Uniform %12 %35 = OpConstant %4 1.0 +%36 = OpConstantComposite %13 %35 %35 %35 %35 %38 = OpTypePointer Uniform %4 %39 = OpConstant %9 1 %26 = OpFunction %2 None %27 @@ -80,12 +81,11 @@ OpDecorate %24 BuiltIn Position %30 = OpAccessChain %28 %14 %29 %32 = OpAccessChain %31 %17 %29 %34 = OpAccessChain %33 %20 %29 -OpBranch %36 -%36 = OpLabel -%37 = OpCompositeConstruct %13 %35 %35 %35 %35 +OpBranch %37 +%37 = OpLabel %40 = OpAccessChain %38 %30 %39 %41 = OpLoad %4 %40 -%42 = OpVectorTimesScalar %13 %37 %41 +%42 = OpVectorTimesScalar %13 %36 %41 %43 = OpAccessChain %38 %32 %39 %44 = OpLoad %4 %43 %45 = OpVectorTimesScalar %13 %42 %44 diff --git a/tests/out/spv/pointers.spvasm b/tests/out/spv/pointers.spvasm index 2de4a49711..ae42aed2e0 100644 --- a/tests/out/spv/pointers.spvasm +++ b/tests/out/spv/pointers.spvasm @@ -10,8 +10,8 @@ OpMemoryModel Logical GLSL450 OpMemberName %7 0 "arr" OpName %7 "DynamicArray" OpName %8 "dynamic_array" -OpName %10 "v" -OpName %14 "f" +OpName %11 "f" +OpName %14 "v" OpName %22 "i" OpName %23 "v" OpName %24 "index_unsized" @@ -31,22 +31,22 @@ OpDecorate %8 Binding 0 %7 = OpTypeStruct %6 %9 = OpTypePointer StorageBuffer %7 %8 = OpVariable %9 StorageBuffer -%11 = OpTypePointer Function %3 -%12 = OpConstantNull %3 -%15 = OpTypeFunction %2 -%16 = OpConstant %4 10 +%12 = OpTypeFunction %2 +%13 = OpConstant %4 10 +%15 = OpTypePointer Function %3 +%16 = OpConstantNull %3 %18 = OpTypePointer Function %4 %19 = OpConstant %5 0 %25 = OpTypeFunction %2 %4 %5 %27 = OpTypePointer StorageBuffer %6 %28 = OpTypePointer StorageBuffer %5 -%14 = OpFunction %2 None %15 -%13 = OpLabel -%10 = OpVariable %11 Function %12 +%11 = OpFunction %2 None %12 +%10 = OpLabel +%14 = OpVariable %15 Function %16 OpBranch %17 %17 = OpLabel -%20 = OpAccessChain %18 %10 %19 -OpStore %20 %16 +%20 = OpAccessChain %18 %14 %19 +OpStore %20 %13 OpReturn OpFunctionEnd %24 = OpFunction %2 None %25 diff --git a/tests/out/spv/policy-mix.spvasm b/tests/out/spv/policy-mix.spvasm index a23714d9de..a10ff1121f 100644 --- a/tests/out/spv/policy-mix.spvasm +++ b/tests/out/spv/policy-mix.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 101 +; Bound: 100 OpCapability Shader OpCapability ImageQuery OpCapability Linkage @@ -17,11 +17,11 @@ OpName %24 "in_uniform" OpName %27 "image_2d_array" OpName %29 "in_workgroup" OpName %31 "in_private" -OpName %34 "in_function" -OpName %38 "c" -OpName %39 "i" -OpName %40 "l" -OpName %41 "mock_function" +OpName %35 "c" +OpName %36 "i" +OpName %37 "l" +OpName %38 "mock_function" +OpName %52 "in_function" OpDecorate %5 ArrayStride 16 OpMemberDecorate %8 0 Offset 0 OpDecorate %9 ArrayStride 16 @@ -72,78 +72,76 @@ OpDecorate %27 Binding 2 %32 = OpTypePointer Private %15 %33 = OpConstantNull %15 %31 = OpVariable %32 Private %33 -%35 = OpTypePointer Function %19 -%36 = OpConstantNull %19 -%42 = OpTypeFunction %3 %17 %18 %18 -%43 = OpTypePointer StorageBuffer %8 -%44 = OpConstant %7 0 -%46 = OpTypePointer Uniform %11 -%49 = OpConstant %4 0.707 -%50 = OpConstant %4 0.0 -%51 = OpConstant %4 1.0 -%56 = OpTypePointer StorageBuffer %5 -%57 = OpTypePointer StorageBuffer %3 -%60 = OpTypePointer Uniform %9 -%61 = OpTypePointer Uniform %3 -%65 = OpTypeVector %18 3 -%67 = OpTypeBool -%68 = OpConstantNull %3 -%74 = OpTypeVector %67 3 -%81 = OpTypePointer Workgroup %4 -%82 = OpConstant %7 29 -%88 = OpTypePointer Private %4 -%89 = OpConstant %7 39 -%95 = OpTypePointer Function %3 -%96 = OpConstant %7 1 -%41 = OpFunction %3 None %42 -%38 = OpFunctionParameter %17 -%39 = OpFunctionParameter %18 -%40 = OpFunctionParameter %18 -%37 = OpLabel -%34 = OpVariable %35 Function %36 -%45 = OpAccessChain %43 %21 %44 -%47 = OpAccessChain %46 %24 %44 -%48 = OpLoad %12 %27 -OpBranch %52 -%52 = OpLabel -%53 = OpCompositeConstruct %3 %49 %50 %50 %51 -%54 = OpCompositeConstruct %3 %50 %49 %50 %51 -%55 = OpCompositeConstruct %19 %53 %54 -OpStore %34 %55 -%58 = OpAccessChain %57 %45 %44 %39 -%59 = OpLoad %3 %58 -%62 = OpAccessChain %61 %47 %44 %39 -%63 = OpLoad %3 %62 -%64 = OpFAdd %3 %59 %63 -%66 = OpCompositeConstruct %65 %38 %39 -%69 = OpImageQueryLevels %18 %48 -%70 = OpULessThan %67 %40 %69 -OpSelectionMerge %71 None -OpBranchConditional %70 %72 %71 -%72 = OpLabel -%73 = OpImageQuerySizeLod %65 %48 %40 -%75 = OpULessThan %74 %66 %73 -%76 = OpAll %67 %75 -OpBranchConditional %76 %77 %71 -%77 = OpLabel -%78 = OpImageFetch %3 %48 %66 Lod %40 -OpBranch %71 +%39 = OpTypeFunction %3 %17 %18 %18 +%40 = OpTypePointer StorageBuffer %8 +%41 = OpConstant %7 0 +%43 = OpTypePointer Uniform %11 +%46 = OpConstant %4 0.707 +%47 = OpConstant %4 0.0 +%48 = OpConstant %4 1.0 +%49 = OpConstantComposite %3 %46 %47 %47 %48 +%50 = OpConstantComposite %3 %47 %46 %47 %48 +%51 = OpConstantComposite %19 %49 %50 +%53 = OpTypePointer Function %19 +%55 = OpTypePointer StorageBuffer %5 +%56 = OpTypePointer StorageBuffer %3 +%59 = OpTypePointer Uniform %9 +%60 = OpTypePointer Uniform %3 +%64 = OpTypeVector %18 3 +%66 = OpTypeBool +%67 = OpConstantNull %3 +%73 = OpTypeVector %66 3 +%80 = OpTypePointer Workgroup %4 +%81 = OpConstant %7 29 +%87 = OpTypePointer Private %4 +%88 = OpConstant %7 39 +%94 = OpTypePointer Function %3 +%95 = OpConstant %7 1 +%38 = OpFunction %3 None %39 +%35 = OpFunctionParameter %17 +%36 = OpFunctionParameter %18 +%37 = OpFunctionParameter %18 +%34 = OpLabel +%52 = OpVariable %53 Function %51 +%42 = OpAccessChain %40 %21 %41 +%44 = OpAccessChain %43 %24 %41 +%45 = OpLoad %12 %27 +OpBranch %54 +%54 = OpLabel +%57 = OpAccessChain %56 %42 %41 %36 +%58 = OpLoad %3 %57 +%61 = OpAccessChain %60 %44 %41 %36 +%62 = OpLoad %3 %61 +%63 = OpFAdd %3 %58 %62 +%65 = OpCompositeConstruct %64 %35 %36 +%68 = OpImageQueryLevels %18 %45 +%69 = OpULessThan %66 %37 %68 +OpSelectionMerge %70 None +OpBranchConditional %69 %71 %70 %71 = OpLabel -%79 = OpPhi %3 %68 %52 %68 %72 %78 %77 -%80 = OpFAdd %3 %64 %79 -%83 = OpExtInst %7 %1 UMin %39 %82 -%84 = OpAccessChain %81 %29 %83 -%85 = OpLoad %4 %84 -%86 = OpCompositeConstruct %3 %85 %85 %85 %85 -%87 = OpFAdd %3 %80 %86 -%90 = OpExtInst %7 %1 UMin %39 %89 -%91 = OpAccessChain %88 %31 %90 -%92 = OpLoad %4 %91 -%93 = OpCompositeConstruct %3 %92 %92 %92 %92 -%94 = OpFAdd %3 %87 %93 -%97 = OpExtInst %7 %1 UMin %39 %96 -%98 = OpAccessChain %95 %34 %97 -%99 = OpLoad %3 %98 -%100 = OpFAdd %3 %94 %99 -OpReturnValue %100 +%72 = OpImageQuerySizeLod %64 %45 %37 +%74 = OpULessThan %73 %65 %72 +%75 = OpAll %66 %74 +OpBranchConditional %75 %76 %70 +%76 = OpLabel +%77 = OpImageFetch %3 %45 %65 Lod %37 +OpBranch %70 +%70 = OpLabel +%78 = OpPhi %3 %67 %54 %67 %71 %77 %76 +%79 = OpFAdd %3 %63 %78 +%82 = OpExtInst %7 %1 UMin %36 %81 +%83 = OpAccessChain %80 %29 %82 +%84 = OpLoad %4 %83 +%85 = OpCompositeConstruct %3 %84 %84 %84 %84 +%86 = OpFAdd %3 %79 %85 +%89 = OpExtInst %7 %1 UMin %36 %88 +%90 = OpAccessChain %87 %31 %89 +%91 = OpLoad %4 %90 +%92 = OpCompositeConstruct %3 %91 %91 %91 %91 +%93 = OpFAdd %3 %86 %92 +%96 = OpExtInst %7 %1 UMin %36 %95 +%97 = OpAccessChain %94 %52 %96 +%98 = OpLoad %3 %97 +%99 = OpFAdd %3 %93 %98 +OpReturnValue %99 OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/quad.spvasm b/tests/out/spv/quad.spvasm index 3de529f6b5..b77ed65e07 100644 --- a/tests/out/spv/quad.spvasm +++ b/tests/out/spv/quad.spvasm @@ -68,6 +68,7 @@ OpDecorate %59 Location 0 %52 = OpTypeBool %59 = OpVariable %23 Output %61 = OpConstant %3 0.5 +%62 = OpConstantComposite %5 %26 %61 %26 %61 %24 = OpFunction %2 None %25 %14 = OpLabel %17 = OpLoad %4 %15 @@ -110,9 +111,8 @@ OpReturn OpFunctionEnd %60 = OpFunction %2 None %25 %58 = OpLabel -OpBranch %62 -%62 = OpLabel -%63 = OpCompositeConstruct %5 %26 %61 %26 %61 -OpStore %59 %63 +OpBranch %63 +%63 = OpLabel +OpStore %59 %62 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/ray-query.spvasm b/tests/out/spv/ray-query.spvasm index 2445b31697..d96dbb315b 100644 --- a/tests/out/spv/ray-query.spvasm +++ b/tests/out/spv/ray-query.spvasm @@ -7,8 +7,8 @@ OpCapability RayQueryKHR OpExtension "SPV_KHR_ray_query" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %43 "main" %15 %17 -OpExecutionMode %43 LocalSize 1 1 1 +OpEntryPoint GLCompute %41 "main" %15 %17 +OpExecutionMode %41 LocalSize 1 1 1 OpMemberDecorate %7 0 Offset 0 OpMemberDecorate %7 1 Offset 16 OpMemberDecorate %11 0 Offset 0 @@ -60,14 +60,17 @@ OpMemberDecorate %18 0 Offset 0 %25 = OpConstant %6 1.0 %26 = OpConstant %6 2.4 %27 = OpConstant %6 0.0 -%41 = OpTypePointer Function %13 -%44 = OpTypeFunction %2 -%46 = OpTypePointer StorageBuffer %7 -%47 = OpConstant %4 0 -%49 = OpConstant %4 4 -%50 = OpConstant %4 255 -%51 = OpConstant %6 0.1 -%52 = OpConstant %6 100.0 +%42 = OpTypeFunction %2 +%44 = OpTypePointer StorageBuffer %7 +%45 = OpConstant %4 0 +%47 = OpConstantComposite %5 %27 %25 %27 +%48 = OpConstant %4 4 +%49 = OpConstant %4 255 +%50 = OpConstant %6 0.1 +%51 = OpConstant %6 100.0 +%52 = OpConstantComposite %5 %27 %27 %27 +%53 = OpConstantComposite %14 %48 %49 %50 %51 %52 %47 +%55 = OpTypePointer Function %13 %72 = OpConstant %4 1 %85 = OpTypePointer StorageBuffer %4 %90 = OpTypePointer StorageBuffer %5 @@ -90,29 +93,26 @@ OpBranch %28 %39 = OpExtInst %5 %1 Normalize %38 OpReturnValue %39 OpFunctionEnd -%43 = OpFunction %2 None %44 -%42 = OpLabel -%40 = OpVariable %41 Function -%45 = OpLoad %3 %15 -%48 = OpAccessChain %46 %17 %47 -OpBranch %53 -%53 = OpLabel -%54 = OpCompositeConstruct %5 %27 %25 %27 -%55 = OpCompositeConstruct %5 %27 %27 %27 -%56 = OpCompositeConstruct %14 %49 %50 %51 %52 %55 %54 -%57 = OpCompositeExtract %4 %56 0 -%58 = OpCompositeExtract %4 %56 1 -%59 = OpCompositeExtract %6 %56 2 -%60 = OpCompositeExtract %6 %56 3 -%61 = OpCompositeExtract %5 %56 4 -%62 = OpCompositeExtract %5 %56 5 -OpRayQueryInitializeKHR %40 %45 %57 %58 %61 %59 %62 %60 +%41 = OpFunction %2 None %42 +%40 = OpLabel +%54 = OpVariable %55 Function +%43 = OpLoad %3 %15 +%46 = OpAccessChain %44 %17 %45 +OpBranch %56 +%56 = OpLabel +%57 = OpCompositeExtract %4 %53 0 +%58 = OpCompositeExtract %4 %53 1 +%59 = OpCompositeExtract %6 %53 2 +%60 = OpCompositeExtract %6 %53 3 +%61 = OpCompositeExtract %5 %53 4 +%62 = OpCompositeExtract %5 %53 5 +OpRayQueryInitializeKHR %54 %43 %57 %58 %61 %59 %62 %60 OpBranch %63 %63 = OpLabel OpLoopMerge %64 %66 None OpBranch %65 %65 = OpLabel -%67 = OpRayQueryProceedKHR %9 %40 +%67 = OpRayQueryProceedKHR %9 %54 OpSelectionMerge %68 None OpBranchConditional %67 %68 %69 %69 = OpLabel @@ -126,27 +126,27 @@ OpBranch %66 %66 = OpLabel OpBranch %63 %64 = OpLabel -%73 = OpRayQueryGetIntersectionTypeKHR %4 %40 %72 -%74 = OpRayQueryGetIntersectionInstanceCustomIndexKHR %4 %40 %72 -%75 = OpRayQueryGetIntersectionInstanceIdKHR %4 %40 %72 -%76 = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR %4 %40 %72 -%77 = OpRayQueryGetIntersectionGeometryIndexKHR %4 %40 %72 -%78 = OpRayQueryGetIntersectionPrimitiveIndexKHR %4 %40 %72 -%79 = OpRayQueryGetIntersectionTKHR %6 %40 %72 -%80 = OpRayQueryGetIntersectionBarycentricsKHR %8 %40 %72 -%81 = OpRayQueryGetIntersectionFrontFaceKHR %9 %40 %72 -%82 = OpRayQueryGetIntersectionObjectToWorldKHR %10 %40 %72 -%83 = OpRayQueryGetIntersectionWorldToObjectKHR %10 %40 %72 +%73 = OpRayQueryGetIntersectionTypeKHR %4 %54 %72 +%74 = OpRayQueryGetIntersectionInstanceCustomIndexKHR %4 %54 %72 +%75 = OpRayQueryGetIntersectionInstanceIdKHR %4 %54 %72 +%76 = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR %4 %54 %72 +%77 = OpRayQueryGetIntersectionGeometryIndexKHR %4 %54 %72 +%78 = OpRayQueryGetIntersectionPrimitiveIndexKHR %4 %54 %72 +%79 = OpRayQueryGetIntersectionTKHR %6 %54 %72 +%80 = OpRayQueryGetIntersectionBarycentricsKHR %8 %54 %72 +%81 = OpRayQueryGetIntersectionFrontFaceKHR %9 %54 %72 +%82 = OpRayQueryGetIntersectionObjectToWorldKHR %10 %54 %72 +%83 = OpRayQueryGetIntersectionWorldToObjectKHR %10 %54 %72 %84 = OpCompositeConstruct %11 %73 %79 %74 %75 %76 %77 %78 %80 %81 %82 %83 %86 = OpCompositeExtract %4 %84 0 -%87 = OpIEqual %9 %86 %47 -%88 = OpSelect %4 %87 %72 %47 -%89 = OpAccessChain %85 %48 %47 +%87 = OpIEqual %9 %86 %45 +%88 = OpSelect %4 %87 %72 %45 +%89 = OpAccessChain %85 %46 %45 OpStore %89 %88 %91 = OpCompositeExtract %6 %84 1 -%92 = OpVectorTimesScalar %5 %54 %91 +%92 = OpVectorTimesScalar %5 %47 %91 %93 = OpFunctionCall %5 %23 %92 %84 -%94 = OpAccessChain %90 %48 %72 +%94 = OpAccessChain %90 %46 %72 OpStore %94 %93 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/shadow.spvasm b/tests/out/spv/shadow.spvasm index d0e3309c23..55bfa4fec0 100644 --- a/tests/out/spv/shadow.spvasm +++ b/tests/out/spv/shadow.spvasm @@ -1,16 +1,16 @@ ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 267 +; Bound: 265 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %87 "vs_main" %77 %80 %82 %84 %86 -OpEntryPoint Fragment %147 "fs_main" %138 %141 %144 %146 -OpEntryPoint Fragment %214 "fs_main_without_storage" %207 %209 %211 %213 -OpExecutionMode %147 OriginUpperLeft -OpExecutionMode %214 OriginUpperLeft +OpEntryPoint Vertex %84 "vs_main" %74 %77 %79 %81 %83 +OpEntryPoint Fragment %142 "fs_main" %133 %136 %139 %141 +OpEntryPoint Fragment %210 "fs_main_without_storage" %203 %205 %207 %209 +OpExecutionMode %142 OriginUpperLeft +OpExecutionMode %210 OriginUpperLeft OpMemberName %8 0 "view_proj" OpMemberName %8 1 "num_lights" OpName %8 "Globals" @@ -36,25 +36,25 @@ OpName %38 "sampler_shadow" OpName %41 "light_id" OpName %42 "homogeneous_coords" OpName %43 "fetch_shadow" -OpName %73 "out" -OpName %77 "position" -OpName %80 "normal" -OpName %82 "proj_position" -OpName %84 "world_normal" -OpName %86 "world_position" -OpName %87 "vs_main" -OpName %131 "color" -OpName %133 "i" -OpName %138 "proj_position" -OpName %141 "world_normal" -OpName %144 "world_position" -OpName %147 "fs_main" -OpName %203 "color" -OpName %204 "i" -OpName %207 "proj_position" -OpName %209 "world_normal" -OpName %211 "world_position" -OpName %214 "fs_main_without_storage" +OpName %74 "position" +OpName %77 "normal" +OpName %79 "proj_position" +OpName %81 "world_normal" +OpName %83 "world_position" +OpName %84 "vs_main" +OpName %91 "out" +OpName %133 "proj_position" +OpName %136 "world_normal" +OpName %139 "world_position" +OpName %142 "fs_main" +OpName %149 "color" +OpName %150 "i" +OpName %203 "proj_position" +OpName %205 "world_normal" +OpName %207 "world_position" +OpName %210 "fs_main_without_storage" +OpName %217 "color" +OpName %218 "i" OpMemberDecorate %8 0 Offset 0 OpMemberDecorate %8 0 ColMajor OpMemberDecorate %8 0 MatrixStride 16 @@ -94,19 +94,19 @@ OpDecorate %36 DescriptorSet 0 OpDecorate %36 Binding 2 OpDecorate %38 DescriptorSet 0 OpDecorate %38 Binding 3 -OpDecorate %77 Location 0 -OpDecorate %80 Location 1 -OpDecorate %82 BuiltIn Position -OpDecorate %84 Location 0 -OpDecorate %86 Location 1 -OpDecorate %138 BuiltIn FragCoord +OpDecorate %74 Location 0 +OpDecorate %77 Location 1 +OpDecorate %79 BuiltIn Position +OpDecorate %81 Location 0 +OpDecorate %83 Location 1 +OpDecorate %133 BuiltIn FragCoord +OpDecorate %136 Location 0 +OpDecorate %139 Location 1 OpDecorate %141 Location 0 -OpDecorate %144 Location 1 -OpDecorate %146 Location 0 -OpDecorate %207 BuiltIn FragCoord +OpDecorate %203 BuiltIn FragCoord +OpDecorate %205 Location 0 +OpDecorate %207 Location 1 OpDecorate %209 Location 0 -OpDecorate %211 Location 1 -OpDecorate %213 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 4 @@ -150,22 +150,24 @@ OpDecorate %213 Location 0 %48 = OpConstant %5 1.0 %49 = OpConstant %5 0.5 %50 = OpConstant %5 -0.5 -%53 = OpTypeBool +%51 = OpConstantComposite %21 %49 %50 +%52 = OpConstantComposite %21 %49 %49 +%55 = OpTypeBool %68 = OpTypeSampledImage %19 -%74 = OpTypePointer Function %11 -%75 = OpConstantNull %11 -%78 = OpTypePointer Input %12 -%77 = OpVariable %78 Input -%80 = OpVariable %78 Input -%83 = OpTypePointer Output %4 -%82 = OpVariable %83 Output -%85 = OpTypePointer Output %10 -%84 = OpVariable %85 Output -%86 = OpVariable %83 Output -%88 = OpTypeFunction %2 -%89 = OpTypePointer Uniform %8 -%90 = OpConstant %7 0 -%92 = OpTypePointer Uniform %9 +%75 = OpTypePointer Input %12 +%74 = OpVariable %75 Input +%77 = OpVariable %75 Input +%80 = OpTypePointer Output %4 +%79 = OpVariable %80 Output +%82 = OpTypePointer Output %10 +%81 = OpVariable %82 Output +%83 = OpVariable %80 Output +%85 = OpTypeFunction %2 +%86 = OpTypePointer Uniform %8 +%87 = OpConstant %7 0 +%89 = OpTypePointer Uniform %9 +%92 = OpTypePointer Function %11 +%93 = OpConstantNull %11 %95 = OpTypePointer Uniform %3 %102 = OpTypePointer Function %10 %110 = OpTypeVector %13 3 @@ -173,72 +175,68 @@ OpDecorate %213 Location 0 %116 = OpTypePointer Function %4 %117 = OpConstant %7 2 %125 = OpTypePointer Output %5 -%132 = OpConstantNull %10 -%134 = OpTypePointer Function %7 -%135 = OpConstantNull %7 -%139 = OpTypePointer Input %4 -%138 = OpVariable %139 Input -%142 = OpTypePointer Input %10 -%141 = OpVariable %142 Input -%144 = OpVariable %139 Input -%146 = OpVariable %83 Output -%150 = OpTypePointer StorageBuffer %16 -%162 = OpTypePointer Uniform %6 -%163 = OpTypePointer Uniform %7 -%173 = OpTypePointer StorageBuffer %15 -%199 = OpTypePointer Uniform %4 -%207 = OpVariable %139 Input -%209 = OpVariable %142 Input -%211 = OpVariable %139 Input -%213 = OpVariable %83 Output -%217 = OpTypePointer Uniform %17 -%238 = OpTypePointer Uniform %15 +%134 = OpTypePointer Input %4 +%133 = OpVariable %134 Input +%137 = OpTypePointer Input %10 +%136 = OpVariable %137 Input +%139 = OpVariable %134 Input +%141 = OpVariable %80 Output +%145 = OpTypePointer StorageBuffer %16 +%151 = OpTypePointer Function %7 +%160 = OpTypePointer Uniform %6 +%161 = OpTypePointer Uniform %7 +%171 = OpTypePointer StorageBuffer %15 +%197 = OpTypePointer Uniform %4 +%203 = OpVariable %134 Input +%205 = OpVariable %137 Input +%207 = OpVariable %134 Input +%209 = OpVariable %80 Output +%213 = OpTypePointer Uniform %17 +%236 = OpTypePointer Uniform %15 %43 = OpFunction %5 None %44 %41 = OpFunctionParameter %7 %42 = OpFunctionParameter %4 %40 = OpLabel %45 = OpLoad %19 %36 %46 = OpLoad %20 %38 -OpBranch %51 -%51 = OpLabel -%52 = OpCompositeExtract %5 %42 3 -%54 = OpFOrdLessThanEqual %53 %52 %47 -OpSelectionMerge %55 None -OpBranchConditional %54 %56 %55 -%56 = OpLabel +OpBranch %53 +%53 = OpLabel +%54 = OpCompositeExtract %5 %42 3 +%56 = OpFOrdLessThanEqual %55 %54 %47 +OpSelectionMerge %57 None +OpBranchConditional %56 %58 %57 +%58 = OpLabel OpReturnValue %48 -%55 = OpLabel -%57 = OpCompositeConstruct %21 %49 %50 -%58 = OpCompositeExtract %5 %42 3 -%59 = OpFDiv %5 %48 %58 -%60 = OpVectorShuffle %21 %42 %42 0 1 -%61 = OpFMul %21 %60 %57 -%62 = OpVectorTimesScalar %21 %61 %59 -%63 = OpCompositeConstruct %21 %49 %49 -%64 = OpFAdd %21 %62 %63 +%57 = OpLabel +%59 = OpCompositeExtract %5 %42 3 +%60 = OpFDiv %5 %48 %59 +%61 = OpVectorShuffle %21 %42 %42 0 1 +%62 = OpFMul %21 %61 %51 +%63 = OpVectorTimesScalar %21 %62 %60 +%64 = OpFAdd %21 %63 %52 %65 = OpBitcast %13 %41 %66 = OpCompositeExtract %5 %42 2 -%67 = OpFMul %5 %66 %59 +%67 = OpFMul %5 %66 %60 %69 = OpConvertSToF %5 %65 %70 = OpCompositeConstruct %10 %64 %69 %71 = OpSampledImage %68 %45 %46 %72 = OpImageSampleDrefExplicitLod %5 %71 %70 %67 Lod %47 OpReturnValue %72 OpFunctionEnd -%87 = OpFunction %2 None %88 -%76 = OpLabel -%73 = OpVariable %74 Function %75 -%79 = OpLoad %12 %77 -%81 = OpLoad %12 %80 -%91 = OpAccessChain %89 %24 %90 -%93 = OpAccessChain %92 %27 %90 +%84 = OpFunction %2 None %85 +%73 = OpLabel +%91 = OpVariable %92 Function %93 +%76 = OpLoad %12 %74 +%78 = OpLoad %12 %77 +%88 = OpAccessChain %86 %24 %87 +%90 = OpAccessChain %89 %27 %87 OpBranch %94 %94 = OpLabel -%96 = OpAccessChain %95 %93 %90 +%96 = OpAccessChain %95 %90 %87 %97 = OpLoad %3 %96 -%98 = OpAccessChain %95 %93 %90 +%98 = OpAccessChain %95 %90 %87 %99 = OpLoad %3 %98 -%100 = OpConvertSToF %4 %79 +%100 = OpConvertSToF %4 %76 %101 = OpMatrixTimesVector %4 %99 %100 %103 = OpCompositeExtract %4 %97 0 %104 = OpVectorShuffle %10 %103 %103 0 1 2 @@ -247,180 +245,176 @@ OpBranch %94 %107 = OpCompositeExtract %4 %97 2 %108 = OpVectorShuffle %10 %107 %107 0 1 2 %109 = OpCompositeConstruct %14 %104 %106 %108 -%111 = OpVectorShuffle %110 %81 %81 0 1 2 +%111 = OpVectorShuffle %110 %78 %78 0 1 2 %112 = OpConvertSToF %10 %111 %113 = OpMatrixTimesVector %10 %109 %112 -%115 = OpAccessChain %102 %73 %114 +%115 = OpAccessChain %102 %91 %114 OpStore %115 %113 -%118 = OpAccessChain %116 %73 %117 +%118 = OpAccessChain %116 %91 %117 OpStore %118 %101 -%119 = OpAccessChain %95 %91 %90 +%119 = OpAccessChain %95 %88 %87 %120 = OpLoad %3 %119 %121 = OpMatrixTimesVector %4 %120 %101 -%122 = OpAccessChain %116 %73 %90 +%122 = OpAccessChain %116 %91 %87 OpStore %122 %121 -%123 = OpLoad %11 %73 +%123 = OpLoad %11 %91 %124 = OpCompositeExtract %4 %123 0 -OpStore %82 %124 -%126 = OpAccessChain %125 %82 %114 +OpStore %79 %124 +%126 = OpAccessChain %125 %79 %114 %127 = OpLoad %5 %126 %128 = OpFNegate %5 %127 OpStore %126 %128 %129 = OpCompositeExtract %10 %123 1 -OpStore %84 %129 +OpStore %81 %129 %130 = OpCompositeExtract %4 %123 2 -OpStore %86 %130 +OpStore %83 %130 OpReturn OpFunctionEnd -%147 = OpFunction %2 None %88 -%136 = OpLabel -%131 = OpVariable %102 Function %132 -%133 = OpVariable %134 Function %135 -%140 = OpLoad %4 %138 -%143 = OpLoad %10 %141 -%145 = OpLoad %4 %144 -%137 = OpCompositeConstruct %11 %140 %143 %145 -%148 = OpAccessChain %89 %24 %90 -%149 = OpAccessChain %92 %27 %90 -%151 = OpAccessChain %150 %30 %90 -%152 = OpLoad %19 %36 -%153 = OpLoad %20 %38 -OpBranch %154 -%154 = OpLabel -%155 = OpCompositeExtract %10 %137 1 -%156 = OpExtInst %10 %1 Normalize %155 -OpStore %131 %23 -OpStore %133 %90 +%142 = OpFunction %2 None %85 +%131 = OpLabel +%149 = OpVariable %102 Function %23 +%150 = OpVariable %151 Function %87 +%135 = OpLoad %4 %133 +%138 = OpLoad %10 %136 +%140 = OpLoad %4 %139 +%132 = OpCompositeConstruct %11 %135 %138 %140 +%143 = OpAccessChain %86 %24 %87 +%144 = OpAccessChain %89 %27 %87 +%146 = OpAccessChain %145 %30 %87 +%147 = OpLoad %19 %36 +%148 = OpLoad %20 %38 +OpBranch %152 +%152 = OpLabel +%153 = OpCompositeExtract %10 %132 1 +%154 = OpExtInst %10 %1 Normalize %153 +OpBranch %155 +%155 = OpLabel +OpLoopMerge %156 %158 None OpBranch %157 %157 = OpLabel -OpLoopMerge %158 %160 None -OpBranch %159 -%159 = OpLabel -%161 = OpLoad %7 %133 -%164 = OpAccessChain %163 %148 %114 %90 -%165 = OpLoad %7 %164 -%166 = OpExtInst %7 %1 UMin %165 %18 -%167 = OpULessThan %53 %161 %166 -OpSelectionMerge %168 None -OpBranchConditional %167 %168 %169 -%169 = OpLabel -OpBranch %158 +%159 = OpLoad %7 %150 +%162 = OpAccessChain %161 %143 %114 %87 +%163 = OpLoad %7 %162 +%164 = OpExtInst %7 %1 UMin %163 %18 +%165 = OpULessThan %55 %159 %164 +OpSelectionMerge %166 None +OpBranchConditional %165 %166 %167 +%167 = OpLabel +OpBranch %156 +%166 = OpLabel +OpBranch %168 %168 = OpLabel -OpBranch %170 -%170 = OpLabel -%172 = OpLoad %7 %133 -%174 = OpAccessChain %173 %151 %172 -%175 = OpLoad %15 %174 -%176 = OpLoad %7 %133 -%177 = OpCompositeExtract %3 %175 0 -%178 = OpCompositeExtract %4 %137 2 -%179 = OpMatrixTimesVector %4 %177 %178 -%180 = OpFunctionCall %5 %43 %176 %179 -%181 = OpCompositeExtract %4 %175 1 +%170 = OpLoad %7 %150 +%172 = OpAccessChain %171 %146 %170 +%173 = OpLoad %15 %172 +%174 = OpLoad %7 %150 +%175 = OpCompositeExtract %3 %173 0 +%176 = OpCompositeExtract %4 %132 2 +%177 = OpMatrixTimesVector %4 %175 %176 +%178 = OpFunctionCall %5 %43 %174 %177 +%179 = OpCompositeExtract %4 %173 1 +%180 = OpVectorShuffle %10 %179 %179 0 1 2 +%181 = OpCompositeExtract %4 %132 2 %182 = OpVectorShuffle %10 %181 %181 0 1 2 -%183 = OpCompositeExtract %4 %137 2 -%184 = OpVectorShuffle %10 %183 %183 0 1 2 -%185 = OpFSub %10 %182 %184 -%186 = OpExtInst %10 %1 Normalize %185 -%187 = OpDot %5 %156 %186 -%188 = OpExtInst %5 %1 FMax %47 %187 -%189 = OpFMul %5 %180 %188 -%190 = OpCompositeExtract %4 %175 2 -%191 = OpVectorShuffle %10 %190 %190 0 1 2 -%192 = OpVectorTimesScalar %10 %191 %189 -%193 = OpLoad %10 %131 -%194 = OpFAdd %10 %193 %192 -OpStore %131 %194 -OpBranch %171 -%171 = OpLabel -OpBranch %160 -%160 = OpLabel -%195 = OpLoad %7 %133 -%196 = OpIAdd %7 %195 %114 -OpStore %133 %196 -OpBranch %157 +%183 = OpFSub %10 %180 %182 +%184 = OpExtInst %10 %1 Normalize %183 +%185 = OpDot %5 %154 %184 +%186 = OpExtInst %5 %1 FMax %47 %185 +%187 = OpFMul %5 %178 %186 +%188 = OpCompositeExtract %4 %173 2 +%189 = OpVectorShuffle %10 %188 %188 0 1 2 +%190 = OpVectorTimesScalar %10 %189 %187 +%191 = OpLoad %10 %149 +%192 = OpFAdd %10 %191 %190 +OpStore %149 %192 +OpBranch %169 +%169 = OpLabel +OpBranch %158 %158 = OpLabel -%197 = OpLoad %10 %131 -%198 = OpCompositeConstruct %4 %197 %48 -%200 = OpAccessChain %199 %149 %114 -%201 = OpLoad %4 %200 -%202 = OpFMul %4 %198 %201 -OpStore %146 %202 +%193 = OpLoad %7 %150 +%194 = OpIAdd %7 %193 %114 +OpStore %150 %194 +OpBranch %155 +%156 = OpLabel +%195 = OpLoad %10 %149 +%196 = OpCompositeConstruct %4 %195 %48 +%198 = OpAccessChain %197 %144 %114 +%199 = OpLoad %4 %198 +%200 = OpFMul %4 %196 %199 +OpStore %141 %200 OpReturn OpFunctionEnd -%214 = OpFunction %2 None %88 -%205 = OpLabel -%203 = OpVariable %102 Function %132 -%204 = OpVariable %134 Function %135 +%210 = OpFunction %2 None %85 +%201 = OpLabel +%217 = OpVariable %102 Function %23 +%218 = OpVariable %151 Function %87 +%204 = OpLoad %4 %203 +%206 = OpLoad %10 %205 %208 = OpLoad %4 %207 -%210 = OpLoad %10 %209 -%212 = OpLoad %4 %211 -%206 = OpCompositeConstruct %11 %208 %210 %212 -%215 = OpAccessChain %89 %24 %90 -%216 = OpAccessChain %92 %27 %90 -%218 = OpAccessChain %217 %33 %90 -%219 = OpLoad %19 %36 -%220 = OpLoad %20 %38 -OpBranch %221 -%221 = OpLabel -%222 = OpCompositeExtract %10 %206 1 -%223 = OpExtInst %10 %1 Normalize %222 -OpStore %203 %23 -OpStore %204 %90 +%202 = OpCompositeConstruct %11 %204 %206 %208 +%211 = OpAccessChain %86 %24 %87 +%212 = OpAccessChain %89 %27 %87 +%214 = OpAccessChain %213 %33 %87 +%215 = OpLoad %19 %36 +%216 = OpLoad %20 %38 +OpBranch %219 +%219 = OpLabel +%220 = OpCompositeExtract %10 %202 1 +%221 = OpExtInst %10 %1 Normalize %220 +OpBranch %222 +%222 = OpLabel +OpLoopMerge %223 %225 None OpBranch %224 %224 = OpLabel -OpLoopMerge %225 %227 None -OpBranch %226 -%226 = OpLabel -%228 = OpLoad %7 %204 -%229 = OpAccessChain %163 %215 %114 %90 -%230 = OpLoad %7 %229 -%231 = OpExtInst %7 %1 UMin %230 %18 -%232 = OpULessThan %53 %228 %231 -OpSelectionMerge %233 None -OpBranchConditional %232 %233 %234 -%234 = OpLabel -OpBranch %225 +%226 = OpLoad %7 %218 +%227 = OpAccessChain %161 %211 %114 %87 +%228 = OpLoad %7 %227 +%229 = OpExtInst %7 %1 UMin %228 %18 +%230 = OpULessThan %55 %226 %229 +OpSelectionMerge %231 None +OpBranchConditional %230 %231 %232 +%232 = OpLabel +OpBranch %223 +%231 = OpLabel +OpBranch %233 %233 = OpLabel -OpBranch %235 -%235 = OpLabel -%237 = OpLoad %7 %204 -%239 = OpAccessChain %238 %218 %237 -%240 = OpLoad %15 %239 -%241 = OpLoad %7 %204 -%242 = OpCompositeExtract %3 %240 0 -%243 = OpCompositeExtract %4 %206 2 -%244 = OpMatrixTimesVector %4 %242 %243 -%245 = OpFunctionCall %5 %43 %241 %244 -%246 = OpCompositeExtract %4 %240 1 +%235 = OpLoad %7 %218 +%237 = OpAccessChain %236 %214 %235 +%238 = OpLoad %15 %237 +%239 = OpLoad %7 %218 +%240 = OpCompositeExtract %3 %238 0 +%241 = OpCompositeExtract %4 %202 2 +%242 = OpMatrixTimesVector %4 %240 %241 +%243 = OpFunctionCall %5 %43 %239 %242 +%244 = OpCompositeExtract %4 %238 1 +%245 = OpVectorShuffle %10 %244 %244 0 1 2 +%246 = OpCompositeExtract %4 %202 2 %247 = OpVectorShuffle %10 %246 %246 0 1 2 -%248 = OpCompositeExtract %4 %206 2 -%249 = OpVectorShuffle %10 %248 %248 0 1 2 -%250 = OpFSub %10 %247 %249 -%251 = OpExtInst %10 %1 Normalize %250 -%252 = OpDot %5 %223 %251 -%253 = OpExtInst %5 %1 FMax %47 %252 -%254 = OpFMul %5 %245 %253 -%255 = OpCompositeExtract %4 %240 2 -%256 = OpVectorShuffle %10 %255 %255 0 1 2 -%257 = OpVectorTimesScalar %10 %256 %254 -%258 = OpLoad %10 %203 -%259 = OpFAdd %10 %258 %257 -OpStore %203 %259 -OpBranch %236 -%236 = OpLabel -OpBranch %227 -%227 = OpLabel -%260 = OpLoad %7 %204 -%261 = OpIAdd %7 %260 %114 -OpStore %204 %261 -OpBranch %224 +%248 = OpFSub %10 %245 %247 +%249 = OpExtInst %10 %1 Normalize %248 +%250 = OpDot %5 %221 %249 +%251 = OpExtInst %5 %1 FMax %47 %250 +%252 = OpFMul %5 %243 %251 +%253 = OpCompositeExtract %4 %238 2 +%254 = OpVectorShuffle %10 %253 %253 0 1 2 +%255 = OpVectorTimesScalar %10 %254 %252 +%256 = OpLoad %10 %217 +%257 = OpFAdd %10 %256 %255 +OpStore %217 %257 +OpBranch %234 +%234 = OpLabel +OpBranch %225 %225 = OpLabel -%262 = OpLoad %10 %203 -%263 = OpCompositeConstruct %4 %262 %48 -%264 = OpAccessChain %199 %216 %114 -%265 = OpLoad %4 %264 -%266 = OpFMul %4 %263 %265 -OpStore %213 %266 +%258 = OpLoad %7 %218 +%259 = OpIAdd %7 %258 %114 +OpStore %218 %259 +OpBranch %222 +%223 = OpLabel +%260 = OpLoad %10 %217 +%261 = OpCompositeConstruct %4 %260 %48 +%262 = OpAccessChain %197 %212 %114 +%263 = OpLoad %4 %262 +%264 = OpFMul %4 %261 %263 +OpStore %209 %264 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/skybox.spvasm b/tests/out/spv/skybox.spvasm index dda9382c64..4d541321a9 100644 --- a/tests/out/spv/skybox.spvasm +++ b/tests/out/spv/skybox.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.0 ; Generator: rspirv -; Bound: 97 +; Bound: 98 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %33 "vs_main" %26 %29 %31 -OpEntryPoint Fragment %89 "fs_main" %82 %85 %88 -OpExecutionMode %89 OriginUpperLeft +OpEntryPoint Vertex %29 "vs_main" %22 %25 %27 +OpEntryPoint Fragment %90 "fs_main" %83 %86 %89 +OpExecutionMode %90 OriginUpperLeft OpMemberDecorate %6 0 Offset 0 OpMemberDecorate %6 1 Offset 16 OpMemberDecorate %8 0 Offset 0 @@ -24,12 +24,12 @@ OpDecorate %17 DescriptorSet 0 OpDecorate %17 Binding 1 OpDecorate %19 DescriptorSet 0 OpDecorate %19 Binding 2 -OpDecorate %26 BuiltIn VertexIndex -OpDecorate %29 BuiltIn Position -OpDecorate %31 Location 0 -OpDecorate %82 BuiltIn FragCoord -OpDecorate %85 Location 0 -OpDecorate %88 Location 0 +OpDecorate %22 BuiltIn VertexIndex +OpDecorate %25 BuiltIn Position +OpDecorate %27 Location 0 +OpDecorate %83 BuiltIn FragCoord +OpDecorate %86 Location 0 +OpDecorate %89 Location 0 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -49,90 +49,91 @@ OpDecorate %88 Location 0 %17 = OpVariable %18 UniformConstant %20 = OpTypePointer UniformConstant %13 %19 = OpVariable %20 UniformConstant -%22 = OpTypePointer Function %10 -%23 = OpConstantNull %10 -%27 = OpTypePointer Input %9 -%26 = OpVariable %27 Input -%30 = OpTypePointer Output %3 -%29 = OpVariable %30 Output -%32 = OpTypePointer Output %5 -%31 = OpVariable %32 Output -%34 = OpTypeFunction %2 -%35 = OpTypePointer Uniform %8 -%36 = OpConstant %9 0 -%38 = OpConstant %10 2 -%39 = OpConstant %10 1 -%40 = OpConstant %4 4.0 -%41 = OpConstant %4 1.0 -%42 = OpConstant %4 0.0 -%57 = OpTypePointer Uniform %7 -%58 = OpTypePointer Uniform %3 -%59 = OpConstant %9 1 -%66 = OpConstant %9 2 -%83 = OpTypePointer Input %3 -%82 = OpVariable %83 Input -%86 = OpTypePointer Input %5 -%85 = OpVariable %86 Input -%88 = OpVariable %30 Output -%94 = OpTypeSampledImage %12 -%33 = OpFunction %2 None %34 -%25 = OpLabel -%21 = OpVariable %22 Function %23 -%24 = OpVariable %22 Function %23 -%28 = OpLoad %9 %26 -%37 = OpAccessChain %35 %14 %36 -OpBranch %43 -%43 = OpLabel -%44 = OpBitcast %10 %28 -%45 = OpSDiv %10 %44 %38 -OpStore %21 %45 -%46 = OpBitcast %10 %28 -%47 = OpBitwiseAnd %10 %46 %39 -OpStore %24 %47 -%48 = OpLoad %10 %21 -%49 = OpConvertSToF %4 %48 -%50 = OpFMul %4 %49 %40 -%51 = OpFSub %4 %50 %41 -%52 = OpLoad %10 %24 -%53 = OpConvertSToF %4 %52 -%54 = OpFMul %4 %53 %40 -%55 = OpFSub %4 %54 %41 -%56 = OpCompositeConstruct %3 %51 %55 %42 %41 -%60 = OpAccessChain %58 %37 %59 %36 -%61 = OpLoad %3 %60 -%62 = OpVectorShuffle %5 %61 %61 0 1 2 -%63 = OpAccessChain %58 %37 %59 %59 -%64 = OpLoad %3 %63 -%65 = OpVectorShuffle %5 %64 %64 0 1 2 -%67 = OpAccessChain %58 %37 %59 %66 -%68 = OpLoad %3 %67 -%69 = OpVectorShuffle %5 %68 %68 0 1 2 -%70 = OpCompositeConstruct %11 %62 %65 %69 -%71 = OpTranspose %11 %70 -%72 = OpAccessChain %57 %37 %36 -%73 = OpLoad %7 %72 -%74 = OpMatrixTimesVector %3 %73 %56 -%75 = OpVectorShuffle %5 %74 %74 0 1 2 -%76 = OpMatrixTimesVector %5 %71 %75 -%77 = OpCompositeConstruct %6 %56 %76 -%78 = OpCompositeExtract %3 %77 0 -OpStore %29 %78 -%79 = OpCompositeExtract %5 %77 1 -OpStore %31 %79 +%23 = OpTypePointer Input %9 +%22 = OpVariable %23 Input +%26 = OpTypePointer Output %3 +%25 = OpVariable %26 Output +%28 = OpTypePointer Output %5 +%27 = OpVariable %28 Output +%30 = OpTypeFunction %2 +%31 = OpTypePointer Uniform %8 +%32 = OpConstant %9 0 +%34 = OpConstant %10 2 +%35 = OpConstant %10 1 +%36 = OpConstant %4 4.0 +%37 = OpConstant %4 1.0 +%38 = OpConstant %4 0.0 +%40 = OpTypePointer Function %10 +%41 = OpConstantNull %10 +%43 = OpConstantNull %10 +%58 = OpTypePointer Uniform %7 +%59 = OpTypePointer Uniform %3 +%60 = OpConstant %9 1 +%67 = OpConstant %9 2 +%84 = OpTypePointer Input %3 +%83 = OpVariable %84 Input +%87 = OpTypePointer Input %5 +%86 = OpVariable %87 Input +%89 = OpVariable %26 Output +%95 = OpTypeSampledImage %12 +%29 = OpFunction %2 None %30 +%21 = OpLabel +%39 = OpVariable %40 Function %41 +%42 = OpVariable %40 Function %43 +%24 = OpLoad %9 %22 +%33 = OpAccessChain %31 %14 %32 +OpBranch %44 +%44 = OpLabel +%45 = OpBitcast %10 %24 +%46 = OpSDiv %10 %45 %34 +OpStore %39 %46 +%47 = OpBitcast %10 %24 +%48 = OpBitwiseAnd %10 %47 %35 +OpStore %42 %48 +%49 = OpLoad %10 %39 +%50 = OpConvertSToF %4 %49 +%51 = OpFMul %4 %50 %36 +%52 = OpFSub %4 %51 %37 +%53 = OpLoad %10 %42 +%54 = OpConvertSToF %4 %53 +%55 = OpFMul %4 %54 %36 +%56 = OpFSub %4 %55 %37 +%57 = OpCompositeConstruct %3 %52 %56 %38 %37 +%61 = OpAccessChain %59 %33 %60 %32 +%62 = OpLoad %3 %61 +%63 = OpVectorShuffle %5 %62 %62 0 1 2 +%64 = OpAccessChain %59 %33 %60 %60 +%65 = OpLoad %3 %64 +%66 = OpVectorShuffle %5 %65 %65 0 1 2 +%68 = OpAccessChain %59 %33 %60 %67 +%69 = OpLoad %3 %68 +%70 = OpVectorShuffle %5 %69 %69 0 1 2 +%71 = OpCompositeConstruct %11 %63 %66 %70 +%72 = OpTranspose %11 %71 +%73 = OpAccessChain %58 %33 %32 +%74 = OpLoad %7 %73 +%75 = OpMatrixTimesVector %3 %74 %57 +%76 = OpVectorShuffle %5 %75 %75 0 1 2 +%77 = OpMatrixTimesVector %5 %72 %76 +%78 = OpCompositeConstruct %6 %57 %77 +%79 = OpCompositeExtract %3 %78 0 +OpStore %25 %79 +%80 = OpCompositeExtract %5 %78 1 +OpStore %27 %80 OpReturn OpFunctionEnd -%89 = OpFunction %2 None %34 -%80 = OpLabel -%84 = OpLoad %3 %82 -%87 = OpLoad %5 %85 -%81 = OpCompositeConstruct %6 %84 %87 -%90 = OpLoad %12 %17 -%91 = OpLoad %13 %19 -OpBranch %92 -%92 = OpLabel -%93 = OpCompositeExtract %5 %81 1 -%95 = OpSampledImage %94 %90 %91 -%96 = OpImageSampleImplicitLod %3 %95 %93 -OpStore %88 %96 +%90 = OpFunction %2 None %30 +%81 = OpLabel +%85 = OpLoad %3 %83 +%88 = OpLoad %5 %86 +%82 = OpCompositeConstruct %6 %85 %88 +%91 = OpLoad %12 %17 +%92 = OpLoad %13 %19 +OpBranch %93 +%93 = OpLabel +%94 = OpCompositeExtract %5 %82 1 +%96 = OpSampledImage %95 %91 %92 +%97 = OpImageSampleImplicitLod %3 %96 %94 +OpStore %89 %97 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/standard.spvasm b/tests/out/spv/standard.spvasm index 07bb2a7908..50026e6dcd 100644 --- a/tests/out/spv/standard.spvasm +++ b/tests/out/spv/standard.spvasm @@ -1,66 +1,68 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 40 +; Bound: 42 OpCapability Shader OpCapability DerivativeControl %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Fragment %22 "derivatives" %17 %20 -OpExecutionMode %22 OriginUpperLeft -OpDecorate %17 BuiltIn FragCoord -OpDecorate %20 Location 0 +OpEntryPoint Fragment %17 "derivatives" %12 %15 +OpExecutionMode %17 OriginUpperLeft +OpDecorate %12 BuiltIn FragCoord +OpDecorate %15 Location 0 %2 = OpTypeVoid %3 = OpTypeBool %5 = OpTypeFloat 32 %4 = OpTypeVector %5 4 %8 = OpTypeFunction %3 %9 = OpConstantTrue %3 -%12 = OpTypePointer Function %4 -%13 = OpConstantNull %4 -%18 = OpTypePointer Input %4 -%17 = OpVariable %18 Input -%21 = OpTypePointer Output %4 -%20 = OpVariable %21 Output -%23 = OpTypeFunction %2 +%13 = OpTypePointer Input %4 +%12 = OpVariable %13 Input +%16 = OpTypePointer Output %4 +%15 = OpVariable %16 Output +%18 = OpTypeFunction %2 +%20 = OpTypePointer Function %4 +%21 = OpConstantNull %4 +%23 = OpConstantNull %4 +%25 = OpConstantNull %4 %7 = OpFunction %3 None %8 %6 = OpLabel OpBranch %10 %10 = OpLabel OpReturnValue %9 OpFunctionEnd -%22 = OpFunction %2 None %23 -%16 = OpLabel -%11 = OpVariable %12 Function %13 -%14 = OpVariable %12 Function %13 -%15 = OpVariable %12 Function %13 -%19 = OpLoad %4 %17 -OpBranch %24 -%24 = OpLabel -%25 = OpDPdxCoarse %4 %19 -OpStore %11 %25 -%26 = OpDPdyCoarse %4 %19 -OpStore %14 %26 -%27 = OpFwidthCoarse %4 %19 -OpStore %15 %27 -%28 = OpDPdxFine %4 %19 -OpStore %11 %28 -%29 = OpDPdyFine %4 %19 -OpStore %14 %29 -%30 = OpFwidthFine %4 %19 -OpStore %15 %30 -%31 = OpDPdx %4 %19 -OpStore %11 %31 -%32 = OpDPdy %4 %19 -OpStore %14 %32 -%33 = OpFwidth %4 %19 -OpStore %15 %33 -%34 = OpFunctionCall %3 %7 -%35 = OpLoad %4 %11 -%36 = OpLoad %4 %14 -%37 = OpFAdd %4 %35 %36 -%38 = OpLoad %4 %15 -%39 = OpFMul %4 %37 %38 -OpStore %20 %39 +%17 = OpFunction %2 None %18 +%11 = OpLabel +%19 = OpVariable %20 Function %21 +%22 = OpVariable %20 Function %23 +%24 = OpVariable %20 Function %25 +%14 = OpLoad %4 %12 +OpBranch %26 +%26 = OpLabel +%27 = OpDPdxCoarse %4 %14 +OpStore %19 %27 +%28 = OpDPdyCoarse %4 %14 +OpStore %22 %28 +%29 = OpFwidthCoarse %4 %14 +OpStore %24 %29 +%30 = OpDPdxFine %4 %14 +OpStore %19 %30 +%31 = OpDPdyFine %4 %14 +OpStore %22 %31 +%32 = OpFwidthFine %4 %14 +OpStore %24 %32 +%33 = OpDPdx %4 %14 +OpStore %19 %33 +%34 = OpDPdy %4 %14 +OpStore %22 %34 +%35 = OpFwidth %4 %14 +OpStore %24 %35 +%36 = OpFunctionCall %3 %7 +%37 = OpLoad %4 %19 +%38 = OpLoad %4 %22 +%39 = OpFAdd %4 %37 %38 +%40 = OpLoad %4 %24 +%41 = OpFMul %4 %39 %40 +OpStore %15 %41 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/texture-arg.spvasm b/tests/out/spv/texture-arg.spvasm index 485b2d7d9a..88832eb193 100644 --- a/tests/out/spv/texture-arg.spvasm +++ b/tests/out/spv/texture-arg.spvasm @@ -30,6 +30,7 @@ OpDecorate %26 Location 0 %10 = OpVariable %11 UniformConstant %18 = OpTypeFunction %6 %9 %11 %19 = OpConstant %4 0.0 +%20 = OpConstantComposite %7 %19 %19 %22 = OpTypeSampledImage %3 %27 = OpTypePointer Output %6 %26 = OpVariable %27 Output @@ -40,11 +41,10 @@ OpDecorate %26 Location 0 %12 = OpLabel %14 = OpLoad %3 %13 %16 = OpLoad %5 %15 -OpBranch %20 -%20 = OpLabel -%21 = OpCompositeConstruct %7 %19 %19 +OpBranch %21 +%21 = OpLabel %23 = OpSampledImage %22 %14 %16 -%24 = OpImageSampleImplicitLod %6 %23 %21 +%24 = OpImageSampleImplicitLod %6 %23 %20 OpReturnValue %24 OpFunctionEnd %28 = OpFunction %2 None %29 diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index c01c4247c5..ba268dca96 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -37,10 +37,9 @@ var nested_mat_cx2_: MatCx2InArray; var val: u32; fn test_matrix_within_struct_accesses() { - var idx: i32; - var t: Baz; + var idx: i32 = 1; + var t: Baz = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); - idx = 1; let _e3 = idx; idx = (_e3 - 1); let l0_ = baz.m; @@ -55,7 +54,6 @@ fn test_matrix_within_struct_accesses() { let _e36 = idx; let _e38 = idx; let l6_ = baz.m[_e36][_e38]; - t = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); let _e51 = idx; idx = (_e51 + 1); t.m = mat3x2(vec2(6.0), vec2(5.0), vec2(4.0)); @@ -74,10 +72,9 @@ fn test_matrix_within_struct_accesses() { } fn test_matrix_within_array_within_struct_accesses() { - var idx_1: i32; - var t_1: MatCx2InArray; + var idx_1: i32 = 1; + var t_1: MatCx2InArray = MatCx2InArray(array, 2>()); - idx_1 = 1; let _e3 = idx_1; idx_1 = (_e3 - 1); let l0_1 = nested_mat_cx2_.am; @@ -93,7 +90,6 @@ fn test_matrix_within_array_within_struct_accesses() { let _e46 = idx_1; let _e48 = idx_1; let l7_ = nested_mat_cx2_.am[0][_e46][_e48]; - t_1 = MatCx2InArray(array, 2>()); let _e55 = idx_1; idx_1 = (_e55 + 1); t_1.am = array, 2>(); @@ -133,10 +129,9 @@ fn assign_array_through_ptr_fn(foo_2: ptr, 2>>) { @vertex fn foo_vert(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { - var foo: f32; + var foo: f32 = 0.0; var c2_: array; - foo = 0.0; let baz_1 = foo; foo = 1.0; test_matrix_within_struct_accesses(); @@ -167,9 +162,8 @@ fn foo_frag() -> @location(0) vec4 { @compute @workgroup_size(1, 1, 1) fn assign_through_ptr() { - var arr: array, 2>; + var arr: array, 2> = array, 2>(vec4(6.0), vec4(7.0)); - arr = array, 2>(vec4(6.0), vec4(7.0)); assign_through_ptr_fn((&val)); assign_array_through_ptr_fn((&arr)); return; diff --git a/tests/out/wgsl/atomicCompareExchange.wgsl b/tests/out/wgsl/atomicCompareExchange.wgsl index b659bed2b5..f68017028f 100644 --- a/tests/out/wgsl/atomicCompareExchange.wgsl +++ b/tests/out/wgsl/atomicCompareExchange.wgsl @@ -7,11 +7,10 @@ var arr_u32_: array, 128>; @compute @workgroup_size(1, 1, 1) fn test_atomic_compare_exchange_i32_() { - var i: u32; + var i: u32 = 0u; var old: i32; - var exchanged: bool; + var exchanged: bool = false; - i = 0u; loop { let _e2 = i; if (_e2 < SIZE) { @@ -50,11 +49,10 @@ fn test_atomic_compare_exchange_i32_() { @compute @workgroup_size(1, 1, 1) fn test_atomic_compare_exchange_u32_() { - var i_1: u32; + var i_1: u32 = 0u; var old_1: u32; - var exchanged_1: bool; + var exchanged_1: bool = false; - i_1 = 0u; loop { let _e2 = i_1; if (_e2 < SIZE) { diff --git a/tests/out/wgsl/binding-arrays.wgsl b/tests/out/wgsl/binding-arrays.wgsl index e9513c725d..c7a01fc5c3 100644 --- a/tests/out/wgsl/binding-arrays.wgsl +++ b/tests/out/wgsl/binding-arrays.wgsl @@ -27,17 +27,13 @@ var uni: UniformIndex; @fragment fn main(fragment_in: FragmentIn) -> @location(0) vec4 { - var u1_: u32; - var u2_: vec2; - var v1_: f32; - var v4_: vec4; + var u1_: u32 = 0u; + var u2_: vec2 = vec2(0u); + var v1_: f32 = 0.0; + var v4_: vec4 = vec4(0.0); let uniform_index = uni.index; let non_uniform_index = fragment_in.index; - u1_ = 0u; - u2_ = vec2(0u); - v1_ = 0.0; - v4_ = vec4(0.0); let uv = vec2(0.0); let pix = vec2(0); let _e21 = textureDimensions(texture_array_unbounded[0]); diff --git a/tests/out/wgsl/binding-buffer-arrays.wgsl b/tests/out/wgsl/binding-buffer-arrays.wgsl index d28237d758..317a386239 100644 --- a/tests/out/wgsl/binding-buffer-arrays.wgsl +++ b/tests/out/wgsl/binding-buffer-arrays.wgsl @@ -17,11 +17,10 @@ var uni: UniformIndex; @fragment fn main(fragment_in: FragmentIn) -> @location(0) @interpolate(flat) u32 { - var u1_: u32; + var u1_: u32 = 0u; let uniform_index = uni.index; let non_uniform_index = fragment_in.index; - u1_ = 0u; let _e10 = storage_array[0].x; let _e11 = u1_; u1_ = (_e11 + _e10); diff --git a/tests/out/wgsl/bitcast.wgsl b/tests/out/wgsl/bitcast.wgsl index a8699e0a9f..a426c26ca0 100644 --- a/tests/out/wgsl/bitcast.wgsl +++ b/tests/out/wgsl/bitcast.wgsl @@ -1,24 +1,15 @@ @compute @workgroup_size(1, 1, 1) fn main() { - var i2_: vec2; - var i3_: vec3; - var i4_: vec4; - var u2_: vec2; - var u3_: vec3; - var u4_: vec4; - var f2_: vec2; - var f3_: vec3; - var f4_: vec4; + var i2_: vec2 = vec2(0); + var i3_: vec3 = vec3(0); + var i4_: vec4 = vec4(0); + var u2_: vec2 = vec2(0u); + var u3_: vec3 = vec3(0u); + var u4_: vec4 = vec4(0u); + var f2_: vec2 = vec2(0.0); + var f3_: vec3 = vec3(0.0); + var f4_: vec4 = vec4(0.0); - i2_ = vec2(0); - i3_ = vec3(0); - i4_ = vec4(0); - u2_ = vec2(0u); - u3_ = vec3(0u); - u4_ = vec4(0u); - f2_ = vec2(0.0); - f3_ = vec3(0.0); - f4_ = vec4(0.0); let _e27 = i2_; u2_ = bitcast>(_e27); let _e29 = i3_; diff --git a/tests/out/wgsl/bits.wgsl b/tests/out/wgsl/bits.wgsl index 4458a0740b..fb4f396a52 100644 --- a/tests/out/wgsl/bits.wgsl +++ b/tests/out/wgsl/bits.wgsl @@ -1,26 +1,16 @@ @compute @workgroup_size(1, 1, 1) fn main() { - var i: i32; - var i2_: vec2; - var i3_: vec3; - var i4_: vec4; - var u: u32; - var u2_: vec2; - var u3_: vec3; - var u4_: vec4; - var f2_: vec2; - var f4_: vec4; + var i: i32 = 0; + var i2_: vec2 = vec2(0); + var i3_: vec3 = vec3(0); + var i4_: vec4 = vec4(0); + var u: u32 = 0u; + var u2_: vec2 = vec2(0u); + var u3_: vec3 = vec3(0u); + var u4_: vec4 = vec4(0u); + var f2_: vec2 = vec2(0.0); + var f4_: vec4 = vec4(0.0); - i = 0; - i2_ = vec2(0); - i3_ = vec3(0); - i4_ = vec4(0); - u = 0u; - u2_ = vec2(0u); - u3_ = vec3(0u); - u4_ = vec4(0u); - f2_ = vec2(0.0); - f4_ = vec4(0.0); let _e28 = f4_; u = pack4x8snorm(_e28); let _e30 = f4_; diff --git a/tests/out/wgsl/boids.wgsl b/tests/out/wgsl/boids.wgsl index af5d5247d8..b87d3ed91d 100644 --- a/tests/out/wgsl/boids.wgsl +++ b/tests/out/wgsl/boids.wgsl @@ -30,14 +30,14 @@ var particlesDst: Particles; fn main(@builtin(global_invocation_id) global_invocation_id: vec3) { var vPos: vec2; var vVel: vec2; - var cMass: vec2; - var cVel: vec2; - var colVel: vec2; - var cMassCount: i32; - var cVelCount: i32; + var cMass: vec2 = vec2(0.0, 0.0); + var cVel: vec2 = vec2(0.0, 0.0); + var colVel: vec2 = vec2(0.0, 0.0); + var cMassCount: i32 = 0; + var cVelCount: i32 = 0; var pos: vec2; var vel: vec2; - var i: u32; + var i: u32 = 0u; let index = global_invocation_id.x; if (index >= NUM_PARTICLES) { @@ -47,12 +47,6 @@ fn main(@builtin(global_invocation_id) global_invocation_id: vec3) { vPos = _e8; let _e14 = particlesSrc.particles[index].vel; vVel = _e14; - cMass = vec2(0.0, 0.0); - cVel = vec2(0.0, 0.0); - colVel = vec2(0.0, 0.0); - cMassCount = 0; - cVelCount = 0; - i = 0u; loop { let _e36 = i; if (_e36 >= NUM_PARTICLES) { diff --git a/tests/out/wgsl/collatz.wgsl b/tests/out/wgsl/collatz.wgsl index a25f795360..477317594f 100644 --- a/tests/out/wgsl/collatz.wgsl +++ b/tests/out/wgsl/collatz.wgsl @@ -7,10 +7,9 @@ var v_indices: PrimeIndices; fn collatz_iterations(n_base: u32) -> u32 { var n: u32; - var i: u32; + var i: u32 = 0u; n = n_base; - i = 0u; loop { let _e4 = n; if (_e4 > 1u) { diff --git a/tests/out/wgsl/dualsource.wgsl b/tests/out/wgsl/dualsource.wgsl index d7cc4cbfdc..8d03f244a9 100644 --- a/tests/out/wgsl/dualsource.wgsl +++ b/tests/out/wgsl/dualsource.wgsl @@ -5,11 +5,9 @@ struct FragmentOutput { @fragment fn main(@builtin(position) position: vec4) -> FragmentOutput { - var color: vec4; - var mask: vec4; + var color: vec4 = vec4(0.4, 0.3, 0.2, 0.1); + var mask: vec4 = vec4(0.9, 0.8, 0.7, 0.6); - color = vec4(0.4, 0.3, 0.2, 0.1); - mask = vec4(0.9, 0.8, 0.7, 0.6); let _e13 = color; let _e14 = mask; return FragmentOutput(_e13, _e14); diff --git a/tests/out/wgsl/expressions.frag.wgsl b/tests/out/wgsl/expressions.frag.wgsl index d947a0df71..1a1a6fd3b3 100644 --- a/tests/out/wgsl/expressions.frag.wgsl +++ b/tests/out/wgsl/expressions.frag.wgsl @@ -407,8 +407,8 @@ fn indexConstantNonConstantIndex(i: i32) { i_1 = i; let _e6 = i_1; - let _e10 = local_5.array_[_e6]; - a_26 = _e10; + let _e11 = local_5.array_[_e6]; + a_26 = _e11; return; } diff --git a/tests/out/wgsl/globals.wgsl b/tests/out/wgsl/globals.wgsl index af72c0cb81..562533156e 100644 --- a/tests/out/wgsl/globals.wgsl +++ b/tests/out/wgsl/globals.wgsl @@ -27,10 +27,9 @@ fn test_msl_packed_vec3_as_arg(arg: vec3) { } fn test_msl_packed_vec3_() { - var idx: i32; + var idx: i32 = 1; alignment.v3_ = vec3(1.0); - idx = 1; alignment.v3_.x = 1.0; alignment.v3_.x = 2.0; let _e16 = idx; @@ -47,8 +46,8 @@ fn test_msl_packed_vec3_() { @compute @workgroup_size(1, 1, 1) fn main() { - var Foo: f32; - var at: bool; + var Foo: f32 = 1.0; + var at: bool = true; test_msl_packed_vec3_(); let _e5 = global_nested_arrays_of_matrices_4x2_[0][0]; @@ -68,7 +67,5 @@ fn main() { alignment.v1_ = 4.0; wg[1] = f32(arrayLength((&dummy))); atomicStore((&at_1), 2u); - Foo = 1.0; - at = true; return; } diff --git a/tests/out/wgsl/interface.wgsl b/tests/out/wgsl/interface.wgsl index 8654c13d95..96713aae95 100644 --- a/tests/out/wgsl/interface.wgsl +++ b/tests/out/wgsl/interface.wgsl @@ -40,9 +40,8 @@ fn compute(@builtin(global_invocation_id) global_id: vec3, @builtin(local_i @vertex fn vertex_two_structs(in1_: Input1_, in2_: Input2_) -> @builtin(position) @invariant vec4 { - var index: u32; + var index: u32 = 2u; - index = 2u; let _e8: u32 = index; return vec4(f32(in1_.index), f32(in2_.index), f32(_e8), 0.0); } diff --git a/tests/out/wgsl/lexical-scopes.wgsl b/tests/out/wgsl/lexical-scopes.wgsl index 22e59030ce..f3756b61bf 100644 --- a/tests/out/wgsl/lexical-scopes.wgsl +++ b/tests/out/wgsl/lexical-scopes.wgsl @@ -21,9 +21,8 @@ fn loopLexicalScope(a_2: bool) { } fn forLexicalScope(a_3: f32) { - var a_4: i32; + var a_4: i32 = 0; - a_4 = 0; loop { let _e3 = a_4; if (_e3 < 1) { diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index caedce204b..9c07526d39 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -22,9 +22,8 @@ fn splat() -> vec4 { } fn splat_assignment() -> vec2 { - var a: vec2; + var a: vec2 = vec2(2.0); - a = vec2(2.0); let _e4 = a; a = (_e4 + vec2(1.0)); let _e8 = a; @@ -144,10 +143,9 @@ fn comparison() { } fn assignment() { - var a_1: i32; - var vec0_: vec3; + var a_1: i32 = 1; + var vec0_: vec3 = vec3(); - a_1 = 1; let _e3 = a_1; a_1 = (_e3 + 1); let _e6 = a_1; @@ -174,7 +172,6 @@ fn assignment() { a_1 = (_e33 + 1); let _e36 = a_1; a_1 = (_e36 - 1); - vec0_ = vec3(); let _e42 = vec0_.y; vec0_.y = (_e42 + 1); let _e46 = vec0_.y; diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index 8000e785ff..b768fab2f1 100644 --- a/tests/out/wgsl/shadow.wgsl +++ b/tests/out/wgsl/shadow.wgsl @@ -64,12 +64,10 @@ fn vs_main(@location(0) @interpolate(flat) position: vec4, @location(1) @in @fragment fn fs_main(in: VertexOutput) -> @location(0) vec4 { - var color: vec3; - var i: u32; + var color: vec3 = c_ambient; + var i: u32 = 0u; let normal_1 = normalize(in.world_normal); - color = c_ambient; - i = 0u; loop { let _e7 = i; let _e11 = u_globals.num_lights.x; @@ -99,12 +97,10 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4 { @fragment fn fs_main_without_storage(in_1: VertexOutput) -> @location(0) vec4 { - var color_1: vec3; - var i_1: u32; + var color_1: vec3 = c_ambient; + var i_1: u32 = 0u; let normal_2 = normalize(in_1.world_normal); - color_1 = c_ambient; - i_1 = 0u; loop { let _e7 = i_1; let _e11 = u_globals.num_lights.x; From f190b48acc8fd738b6d4ec52b697926b44ca7e80 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 3 May 2023 16:53:17 +0200 Subject: [PATCH 03/37] [glsl-in] const eval as soon as possible --- src/front/glsl/builtins.rs | 2 +- src/front/glsl/context.rs | 82 ++-- src/front/glsl/functions.rs | 10 +- src/front/glsl/parser.rs | 6 +- src/front/glsl/parser/declarations.rs | 32 +- src/front/glsl/types.rs | 95 +++-- src/front/glsl/variables.rs | 2 +- src/proc/constant_evaluator.rs | 145 ------- tests/out/wgsl/246-collatz.comp.wgsl | 11 +- tests/out/wgsl/277-casting.frag.wgsl | 2 +- tests/out/wgsl/280-matrix-cast.frag.wgsl | 3 +- .../wgsl/900-implicit-conversions.frag.wgsl | 4 +- tests/out/wgsl/bevy-pbr.frag.wgsl | 22 +- tests/out/wgsl/bits_glsl.frag.wgsl | 40 +- tests/out/wgsl/buffer.frag.wgsl | 2 +- tests/out/wgsl/constant-array-size.frag.wgsl | 2 +- tests/out/wgsl/declarations.frag.wgsl | 4 +- tests/out/wgsl/expressions.frag.wgsl | 50 ++- tests/out/wgsl/fma.frag.wgsl | 9 +- tests/out/wgsl/images.frag.wgsl | 12 +- tests/out/wgsl/long-form-matrix.frag.wgsl | 31 +- tests/out/wgsl/prepostfix.frag.wgsl | 5 +- tests/out/wgsl/quad_glsl.vert.wgsl | 10 +- tests/out/wgsl/sampler-functions.frag.wgsl | 2 +- tests/out/wgsl/samplers.frag.wgsl | 400 ++++++++---------- 25 files changed, 416 insertions(+), 567 deletions(-) diff --git a/src/front/glsl/builtins.rs b/src/front/glsl/builtins.rs index ff386e2e1e..8d57b66da2 100644 --- a/src/front/glsl/builtins.rs +++ b/src/front/glsl/builtins.rs @@ -1795,7 +1795,7 @@ impl MacroCall { true => { let offset_arg = args[num_args]; num_args += 1; - match ctx.eval_constant(offset_arg, meta) { + match ctx.lift_up_const_expression(offset_arg) { Ok(v) => Some(v), Err(e) => { frontend.errors.push(e); diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index a13e6ac5ba..d767f93588 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -71,15 +71,17 @@ pub struct Context<'a> { pub symbol_table: crate::front::SymbolTable, pub samplers: FastHashMap, Handle>, + pub const_typifier: Typifier, pub typifier: Typifier, emitter: Emitter, stmt_ctx: Option, pub body: Block, pub module: &'a mut crate::Module, + pub is_const: bool, } impl<'a> Context<'a> { - pub fn new(frontend: &Frontend, module: &'a mut crate::Module) -> Result { + pub fn new(frontend: &Frontend, module: &'a mut crate::Module, is_const: bool) -> Result { let mut this = Context { expressions: Arena::new(), locals: Arena::new(), @@ -91,11 +93,13 @@ impl<'a> Context<'a> { symbol_table: crate::front::SymbolTable::default(), samplers: FastHashMap::default(), + const_typifier: Typifier::new(), typifier: Typifier::new(), emitter: Emitter::default(), stmt_ctx: Some(StmtContext::new()), body: Block::new(), module, + is_const: false, }; this.emit_start(); @@ -103,6 +107,7 @@ impl<'a> Context<'a> { for &(ref name, lookup) in frontend.global_variables.iter() { this.add_global(name, lookup)? } + this.is_const = is_const; Ok(this) } @@ -241,15 +246,43 @@ impl<'a> Context<'a> { } pub fn add_expression(&mut self, expr: Expression, meta: Span) -> Result> { - let needs_pre_emit = expr.needs_pre_emit(); - if needs_pre_emit { - self.emit_end(); - } - let handle = self.expressions.append(expr, meta); - if needs_pre_emit { - self.emit_start(); + let mut append = |arena: &mut Arena, expr: Expression, span| { + let is_running = self.emitter.is_running(); + let needs_pre_emit = expr.needs_pre_emit(); + if is_running && needs_pre_emit { + self.body.extend(self.emitter.finish(arena)); + } + let h = arena.append(expr, span); + if is_running && needs_pre_emit { + self.emitter.start(arena); + } + h + }; + + let (expressions, const_expressions) = if self.is_const { + (&mut self.module.const_expressions, None) + } else { + (&mut self.expressions, Some(&self.module.const_expressions)) + }; + + let mut eval = crate::proc::ConstantEvaluator { + types: &mut self.module.types, + constants: &self.module.constants, + expressions, + const_expressions, + append: (!self.is_const).then_some(&mut append), + }; + + let res = eval.try_eval_and_append(&expr, meta).map_err(|e| Error { + kind: e.into(), + meta, + }); + + match res { + Ok(expr) => Ok(expr), + Err(e) if self.is_const => Err(e), + Err(_) => Ok(append(&mut self.expressions, expr, meta)), } - Ok(handle) } /// Add variable to current scope @@ -513,13 +546,16 @@ impl<'a> Context<'a> { let handle = match *kind { HirExprKind::Access { base, index } => { - let (index, index_meta) = - self.lower_expect_inner(stmt, frontend, index, ExprPos::Rhs)?; + let (index, _) = self.lower_expect_inner(stmt, frontend, index, ExprPos::Rhs)?; let maybe_constant_index = match pos { // Don't try to generate `AccessIndex` if in a LHS position, since it // wouldn't produce a pointer. ExprPos::Lhs => None, - _ => self.eval_constant(index, index_meta).ok(), + _ => self + .module + .to_ctx() + .eval_expr_to_u32_from(index, &self.expressions) + .ok(), }; let base = self @@ -532,15 +568,7 @@ impl<'a> Context<'a> { .0; let pointer = maybe_constant_index - .and_then(|const_expr| { - Some(self.add_expression( - Expression::AccessIndex { - base, - index: self.module.to_ctx().eval_expr_to_u32(const_expr).ok()?, - }, - meta, - )) - }) + .map(|index| self.add_expression(Expression::AccessIndex { base, index }, meta)) .unwrap_or_else(|| { self.add_expression(Expression::Access { base, index }, meta) })?; @@ -582,8 +610,8 @@ impl<'a> Context<'a> { self.typifier_grow(left, left_meta)?; self.typifier_grow(right, right_meta)?; - let left_inner = self.typifier.get(left, &self.module.types); - let right_inner = self.typifier.get(right, &self.module.types); + let left_inner = self.get_type(left); + let right_inner = self.get_type(right); match (left_inner, right_inner) { ( @@ -1010,7 +1038,13 @@ impl<'a> Context<'a> { _ if var.load => { self.add_expression(Expression::Load { pointer: var.expr }, meta)? } - ExprPos::Rhs => var.expr, + ExprPos::Rhs => { + if let Some((constant, _)) = self.is_const.then_some(var.constant).flatten() { + self.add_expression(Expression::Constant(constant), meta)? + } else { + var.expr + } + } }, HirExprKind::Call(ref call) if pos != ExprPos::Lhs => { let maybe_expr = frontend.function_or_constructor_call( diff --git a/src/front/glsl/functions.rs b/src/front/glsl/functions.rs index fe96d2c4eb..8bbef9162d 100644 --- a/src/front/glsl/functions.rs +++ b/src/front/glsl/functions.rs @@ -531,10 +531,8 @@ impl Frontend { } // Check if the passed arguments require any special variations - let mut variations = builtin_required_variations( - args.iter() - .map(|&(expr, _)| ctx.typifier.get(expr, &ctx.module.types)), - ); + let mut variations = + builtin_required_variations(args.iter().map(|&(expr, _)| ctx.get_type(expr))); // Initiate the declaration if it wasn't previously initialized and inject builtins let declaration = self.lookup_function.entry(name.clone()).or_insert_with(|| { @@ -592,7 +590,7 @@ impl Frontend { ctx.typifier_grow(call_argument.0, call_argument.1)?; let overload_param_ty = &ctx.module.types[*overload_parameter].inner; - let call_arg_ty = ctx.typifier.get(call_argument.0, &ctx.module.types); + let call_arg_ty = ctx.get_type(call_argument.0); log::trace!( "Testing parameter {}\n\tOverload = {:?}\n\tCall = {:?}", @@ -937,7 +935,7 @@ impl Frontend { ctx.typifier_grow(call_argument.0, call_argument.1)?; let overload_param_ty = &ctx.module.types[parameter_ty].inner; - let call_arg_ty = ctx.typifier.get(call_argument.0, &ctx.module.types); + let call_arg_ty = ctx.get_type(call_argument.0); let needs_conversion = call_arg_ty != overload_param_ty; let arg_scalar_comps = scalar_components(call_arg_ty); diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index 075dce17e0..3913576688 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -166,7 +166,7 @@ impl<'source> ParsingContext<'source> { let mut module = Module::default(); // Body and expression arena for global initialization - let mut ctx = Context::new(frontend, &mut module)?; + let mut ctx = Context::new(frontend, &mut module, false)?; while self.peek(frontend).is_some() { self.parse_external_declaration(frontend, &mut ctx)?; @@ -220,13 +220,13 @@ impl<'source> ParsingContext<'source> { frontend: &mut Frontend, module: &mut Module, ) -> Result<(Handle, Span)> { - let mut ctx = Context::new(frontend, module)?; + let mut ctx = Context::new(frontend, module, true)?; let mut stmt_ctx = ctx.stmt_ctx(); let expr = self.parse_conditional(frontend, &mut ctx, &mut stmt_ctx, None)?; let (root, meta) = ctx.lower_expect(stmt_ctx, frontend, expr, ExprPos::Rhs)?; - Ok((ctx.eval_constant(root, meta)?, meta)) + Ok((root, meta)) } } diff --git a/src/front/glsl/parser/declarations.rs b/src/front/glsl/parser/declarations.rs index 75e18ea3b6..da75b0ba61 100644 --- a/src/front/glsl/parser/declarations.rs +++ b/src/front/glsl/parser/declarations.rs @@ -221,9 +221,15 @@ impl<'source> ParsingContext<'source> { // returns Ok(None) rather than an error if there is not one self.parse_array_specifier(frontend, ctx.ctx, &mut meta, &mut ty)?; + let is_global_const = + ctx.qualifiers.storage.0 == StorageQualifier::Const && ctx.external; + let init = self .bump_if(frontend, TokenValue::Assign) .map::, _>(|_| { + let prev_const = ctx.ctx.is_const; + ctx.ctx.is_const = is_global_const; + let (mut expr, init_meta) = self.parse_initializer(frontend, ty, ctx.ctx)?; let scalar_components = scalar_components(&ctx.ctx.module.types[ty].inner); @@ -232,32 +238,26 @@ impl<'source> ParsingContext<'source> { .implicit_conversion(&mut expr, init_meta, kind, width)?; } + ctx.ctx.is_const = prev_const; + meta.subsume(init_meta); - Ok((expr, init_meta)) + Ok(expr) }) .transpose()?; - let is_const = ctx.qualifiers.storage.0 == StorageQualifier::Const; - let maybe_const_expr = if ctx.external { - if let Some((root, meta)) = init { - match ctx.ctx.eval_constant(root, meta) { - Ok(res) => Some(res), - // If the declaration is external (global scope) and is constant qualified - // then the initializer must be a constant expression - Err(err) if is_const => return Err(err), - _ => None, - } - } else { - None - } + let maybe_const_expr = if is_global_const { + init + } else if ctx.external { + init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok()) } else { None + // init.filter(|expr| ctx.ctx.expressions.is_const(*expr)) }; let pointer = ctx.add_var(frontend, ty, name, maybe_const_expr, meta)?; - if let Some((value, _)) = init.filter(|_| maybe_const_expr.is_none()) { + if let Some(value) = init.filter(|_| maybe_const_expr.is_none()) { ctx.ctx.emit_restart(); ctx.ctx.body.push(Statement::Store { pointer, value }, meta); } @@ -317,7 +317,7 @@ impl<'source> ParsingContext<'source> { let result = ty.map(|ty| FunctionResult { ty, binding: None }); - let mut context = Context::new(frontend, ctx.module)?; + let mut context = Context::new(frontend, ctx.module, false)?; self.parse_function_args(frontend, &mut context)?; diff --git a/src/front/glsl/types.rs b/src/front/glsl/types.rs index a8bb047e47..ffa879506e 100644 --- a/src/front/glsl/types.rs +++ b/src/front/glsl/types.rs @@ -241,14 +241,36 @@ impl Context<'_> { pub(crate) fn typifier_grow(&mut self, expr: Handle, meta: Span) -> Result<()> { let resolve_ctx = ResolveContext::with_locals(self.module, &self.locals, &self.arguments); - self.typifier - .grow(expr, &self.expressions, &resolve_ctx) + let typifier = if self.is_const { + &mut self.const_typifier + } else { + &mut self.typifier + }; + + let expressions = if self.is_const { + &self.module.const_expressions + } else { + &self.expressions + }; + + typifier + .grow(expr, expressions, &resolve_ctx) .map_err(|error| Error { kind: ErrorKind::SemanticError(format!("Can't resolve type: {error:?}").into()), meta, }) } + pub(crate) fn get_type(&self, expr: Handle) -> &TypeInner { + let typifier = if self.is_const { + &self.const_typifier + } else { + &self.typifier + }; + + typifier.get(expr, &self.module.types) + } + /// Gets the type for the result of the `expr` expression /// /// Automatically grows the [`typifier`] to `expr` so calling @@ -262,7 +284,7 @@ impl Context<'_> { meta: Span, ) -> Result<&TypeInner> { self.typifier_grow(expr, meta)?; - Ok(self.typifier.get(expr, &self.module.types)) + Ok(self.get_type(expr)) } /// Gets the type handle for the result of the `expr` expression @@ -286,7 +308,14 @@ impl Context<'_> { meta: Span, ) -> Result> { self.typifier_grow(expr, meta)?; - Ok(self.typifier.register_type(expr, &mut self.module.types)) + + let typifier = if self.is_const { + &mut self.const_typifier + } else { + &mut self.typifier + }; + + Ok(typifier.register_type(expr, &mut self.module.types)) } /// Invalidates the cached type resolution for `expr` forcing a recomputation @@ -297,7 +326,13 @@ impl Context<'_> { ) -> Result<()> { let resolve_ctx = ResolveContext::with_locals(self.module, &self.locals, &self.arguments); - self.typifier + let typifier = if self.is_const { + &mut self.const_typifier + } else { + &mut self.typifier + }; + + typifier .invalidate(expr, &self.expressions, &resolve_ctx) .map_err(|error| Error { kind: ErrorKind::SemanticError(format!("Can't resolve type: {error:?}").into()), @@ -305,30 +340,36 @@ impl Context<'_> { }) } - pub(crate) fn eval_constant( + pub(crate) fn lift_up_const_expression( &mut self, - root: Handle, - meta: Span, + expr: Handle, ) -> Result> { - let mut solver = crate::proc::ConstantEvaluator { - types: &mut self.module.types, - expressions: &mut self.module.const_expressions, - constants: &mut self.module.constants, - const_expressions: Some(&self.expressions), - append: None::< - Box< - dyn FnMut( - &mut crate::Arena, - Expression, - Span, - ) -> Handle, - >, - >, - }; - - solver.eval(root).map_err(|e| Error { - kind: e.into(), - meta, + let meta = self.expressions.get_span(expr); + Ok(match self.expressions[expr] { + ref expr @ (Expression::Literal(_) + | Expression::Constant(_) + | Expression::ZeroValue(_)) => self.module.const_expressions.append(expr.clone(), meta), + Expression::Compose { ty, ref components } => { + let mut components = components.clone(); + for component in &mut components { + *component = self.lift_up_const_expression(*component)?; + } + self.module + .const_expressions + .append(Expression::Compose { ty, components }, meta) + } + Expression::Splat { size, value } => { + let value = self.lift_up_const_expression(value)?; + self.module + .const_expressions + .append(Expression::Splat { size, value }, meta) + } + _ => { + return Err(Error { + kind: ErrorKind::SemanticError("Expression is not const-expression".into()), + meta, + }) + } }) } } diff --git a/src/front/glsl/variables.rs b/src/front/glsl/variables.rs index 58cc31461e..794f181b56 100644 --- a/src/front/glsl/variables.rs +++ b/src/front/glsl/variables.rs @@ -638,7 +638,7 @@ impl Frontend { LocalVariable { name: decl.name.clone(), ty: decl.ty, - init: None, + init: decl.init, }, decl.meta, ); diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 6778a0bf93..218252e1f9 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -74,12 +74,6 @@ pub enum ConstantEvaluatorError { NotImplemented(String), } -#[derive(Clone, Copy)] -pub enum ExprType { - Regular, - Constant, -} - // Access // AccessIndex // Splat @@ -231,145 +225,6 @@ impl<'a, F: FnMut(&mut Arena, Expression, Span) -> Handle, - ) -> Result, ConstantEvaluatorError> { - self.eval_impl(expr, ExprType::Regular, true) - } - - pub fn eval_impl( - &mut self, - expr: Handle, - expr_type: ExprType, - top_level: bool, - ) -> Result, ConstantEvaluatorError> { - let expressions = match expr_type { - ExprType::Regular => self.const_expressions.unwrap(), - ExprType::Constant => self.expressions, - }; - let span = expressions.get_span(expr); - match expressions[expr] { - ref expression @ (Expression::Literal(_) | Expression::ZeroValue(_)) => match expr_type - { - ExprType::Regular => Ok(self.register_evaluated_expr(expression.clone(), span)), - ExprType::Constant => Ok(expr), - }, - Expression::Compose { ty, ref components } => match expr_type { - ExprType::Regular => { - let mut components = components.clone(); - for component in &mut components { - *component = self.eval_impl(*component, expr_type, false)?; - } - Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) - } - ExprType::Constant => Ok(expr), - }, - Expression::Constant(constant) => { - if top_level { - match expr_type { - ExprType::Regular => { - Ok(self.register_evaluated_expr(Expression::Constant(constant), span)) - } - ExprType::Constant => Ok(expr), - } - } else { - self.eval_impl(self.constants[constant].init, ExprType::Constant, false) - } - } - Expression::AccessIndex { base, index } => { - let base = self.eval_impl(base, expr_type, false)?; - - self.access(base, index as usize, span) - } - Expression::Access { base, index } => { - let base = self.eval_impl(base, expr_type, false)?; - let index = self.eval_impl(index, expr_type, false)?; - - self.access(base, self.constant_index(index)?, span) - } - Expression::Splat { size, value } => { - let value = self.eval_impl(value, expr_type, false)?; - - self.splat(value, size, span) - } - Expression::Swizzle { - size, - vector: src_vector, - pattern, - } => { - let src_constant = self.eval_impl(src_vector, expr_type, false)?; - - self.swizzle(size, span, src_constant, pattern) - } - Expression::Unary { expr, op } => { - let expr_constant = self.eval_impl(expr, expr_type, false)?; - - self.unary_op(op, expr_constant, span) - } - Expression::Binary { left, right, op } => { - let left_constant = self.eval_impl(left, expr_type, false)?; - let right_constant = self.eval_impl(right, expr_type, false)?; - - self.binary_op(op, left_constant, right_constant, span) - } - Expression::Math { - fun, - arg, - arg1, - arg2, - arg3, - } => { - let arg = self.eval_impl(arg, expr_type, false)?; - let arg1 = arg1 - .map(|arg| self.eval_impl(arg, expr_type, false)) - .transpose()?; - let arg2 = arg2 - .map(|arg| self.eval_impl(arg, expr_type, false)) - .transpose()?; - let arg3 = arg3 - .map(|arg| self.eval_impl(arg, expr_type, false)) - .transpose()?; - - self.math(arg, arg1, arg2, arg3, fun, span) - } - Expression::As { - convert, - expr, - kind, - } => { - let expr_constant = self.eval_impl(expr, expr_type, false)?; - - match convert { - Some(width) => self.cast(expr_constant, kind, width, span), - None => Err(ConstantEvaluatorError::Bitcast), - } - } - Expression::ArrayLength(expr) => { - let array = self.eval_impl(expr, expr_type, false)?; - - self.array_length(array, span) - } - - Expression::Load { .. } => Err(ConstantEvaluatorError::Load), - Expression::Select { .. } => Err(ConstantEvaluatorError::Select), - Expression::LocalVariable(_) => Err(ConstantEvaluatorError::LocalVariable), - Expression::Derivative { .. } => Err(ConstantEvaluatorError::Derivative), - Expression::Relational { .. } => Err(ConstantEvaluatorError::Relational), - Expression::CallResult { .. } => Err(ConstantEvaluatorError::Call), - Expression::WorkGroupUniformLoadResult { .. } => unreachable!(), - Expression::AtomicResult { .. } => Err(ConstantEvaluatorError::Atomic), - Expression::FunctionArgument(_) => Err(ConstantEvaluatorError::FunctionArg), - Expression::GlobalVariable(_) => Err(ConstantEvaluatorError::GlobalVariable), - Expression::ImageSample { .. } - | Expression::ImageLoad { .. } - | Expression::ImageQuery { .. } => Err(ConstantEvaluatorError::ImageExpression), - Expression::RayQueryProceedResult | Expression::RayQueryGetIntersection { .. } => { - Err(ConstantEvaluatorError::RayQueryExpression) - } - } - } - fn splat( &mut self, value: Handle, diff --git a/tests/out/wgsl/246-collatz.comp.wgsl b/tests/out/wgsl/246-collatz.comp.wgsl index e92cf8127c..e79d619649 100644 --- a/tests/out/wgsl/246-collatz.comp.wgsl +++ b/tests/out/wgsl/246-collatz.comp.wgsl @@ -11,25 +11,24 @@ fn collatz_iterations(n: u32) -> u32 { var i: u32; n_1 = n; - i = u32(0); + i = 0u; loop { let _e7 = n_1; - if !((_e7 != u32(1))) { + if !((_e7 != 1u)) { break; } { let _e14 = n_1; let _e15 = f32(_e14); - let _e17 = f32(2); - if ((_e15 - (floor((_e15 / _e17)) * _e17)) == f32(0)) { + if ((_e15 - (floor((_e15 / 2.0)) * 2.0)) == 0.0) { { let _e25 = n_1; - n_1 = (_e25 / u32(2)); + n_1 = (_e25 / 2u); } } else { { let _e30 = n_1; - n_1 = ((u32(3) * _e30) + u32(1)); + n_1 = ((3u * _e30) + 1u); } } let _e36 = i; diff --git a/tests/out/wgsl/277-casting.frag.wgsl b/tests/out/wgsl/277-casting.frag.wgsl index 26a3db792d..84c50ddd45 100644 --- a/tests/out/wgsl/277-casting.frag.wgsl +++ b/tests/out/wgsl/277-casting.frag.wgsl @@ -1,7 +1,7 @@ fn main_1() { var a: f32; - a = f32(1); + a = 1.0; return; } diff --git a/tests/out/wgsl/280-matrix-cast.frag.wgsl b/tests/out/wgsl/280-matrix-cast.frag.wgsl index 316d936518..ad9f85b74e 100644 --- a/tests/out/wgsl/280-matrix-cast.frag.wgsl +++ b/tests/out/wgsl/280-matrix-cast.frag.wgsl @@ -1,8 +1,7 @@ fn main_1() { var a: mat4x4; - let _e1 = f32(1); - a = mat4x4(vec4(_e1, 0.0, 0.0, 0.0), vec4(0.0, _e1, 0.0, 0.0), vec4(0.0, 0.0, _e1, 0.0), vec4(0.0, 0.0, 0.0, _e1)); + a = 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)); return; } diff --git a/tests/out/wgsl/900-implicit-conversions.frag.wgsl b/tests/out/wgsl/900-implicit-conversions.frag.wgsl index 58ed87e1ea..dc4855efa5 100644 --- a/tests/out/wgsl/900-implicit-conversions.frag.wgsl +++ b/tests/out/wgsl/900-implicit-conversions.frag.wgsl @@ -56,8 +56,8 @@ fn implicit_dims_3(v_6: vec4) { fn main_1() { exact_1(1); - implicit(f32(1u)); - implicit_dims_2(vec3(vec3(1))); + implicit(1.0); + implicit_dims_2(vec3(1.0, 1.0, 1.0)); return; } diff --git a/tests/out/wgsl/bevy-pbr.frag.wgsl b/tests/out/wgsl/bevy-pbr.frag.wgsl index 85bbafd042..73501b99f4 100644 --- a/tests/out/wgsl/bevy-pbr.frag.wgsl +++ b/tests/out/wgsl/bevy-pbr.frag.wgsl @@ -157,9 +157,9 @@ fn D_GGX(roughness: f32, NoH: f32, h: vec3) -> f32 { k = (_e55 / (_e56 + (_e57 * _e58))); let _e63 = k; let _e64 = k; - d = ((_e63 * _e64) * (1.0 / PI)); - let _e70 = d; - return _e70; + d = ((_e63 * _e64) * 0.31830987); + let _e71 = d; + return _e71; } fn V_SmithGGXCorrelated(roughness_2: f32, NoV: f32, NoL: f32) -> f32 { @@ -247,7 +247,7 @@ fn fresnel(f0_3: vec3, LoH: f32) -> vec3 { LoH_1 = LoH; let _e49 = f0_4; let _e62 = f0_4; - f90_4 = clamp(dot(_e62, vec3((50.0 * 0.33))), 0.0, 1.0); + f90_4 = clamp(dot(_e62, vec3(16.5)), 0.0, 1.0); let _e75 = f0_4; let _e76 = f90_4; let _e77 = LoH_1; @@ -321,7 +321,7 @@ fn Fd_Burley(roughness_6: f32, NoV_4: f32, NoL_4: f32, LoH_4: f32) -> f32 { viewScatter = _e72; let _e74 = lightScatter; let _e75 = viewScatter; - return ((_e74 * _e75) * (1.0 / PI)); + return ((_e74 * _e75) * 0.31830987); } fn EnvBRDFApprox(f0_7: vec3, perceptual_roughness: f32, NoV_6: f32) -> vec3 { @@ -337,8 +337,8 @@ fn EnvBRDFApprox(f0_7: vec3, perceptual_roughness: f32, NoV_6: f32) -> vec3 f0_8 = f0_7; perceptual_roughness_1 = perceptual_roughness; NoV_7 = NoV_6; - c0_ = vec4(-(1.0), -(0.0275), -(0.572), 0.022); - c1_ = vec4(1.0, 0.0425, 1.04, -(0.04)); + c0_ = vec4(-1.0, -0.0275, -0.572, 0.022); + c1_ = vec4(1.0, 0.0425, 1.04, -0.04); let _e62 = perceptual_roughness_1; let _e64 = c0_; let _e66 = c1_; @@ -353,10 +353,10 @@ fn EnvBRDFApprox(f0_7: vec3, perceptual_roughness: f32, NoV_6: f32) -> vec3 let _e94 = NoV_7; let _e98 = r; let _e101 = r; - a004_ = ((min((_e83.x * _e85.x), exp2((-(9.28) * _e94))) * _e98.x) + _e101.y); + a004_ = ((min((_e83.x * _e85.x), exp2((-9.28 * _e94))) * _e98.x) + _e101.y); let _e109 = a004_; let _e112 = r; - AB = ((vec2(-(1.04), 1.04) * vec2(_e109)) + _e112.zw); + AB = ((vec2(-1.04, 1.04) * vec2(_e109)) + _e112.zw); let _e116 = f0_8; let _e117 = AB; let _e121 = AB; @@ -934,6 +934,6 @@ fn main(@location(0) v_WorldPosition: vec3, @location(1) v_WorldNormal: vec v_WorldTangent_1 = v_WorldTangent; gl_FrontFacing = param; main_1(); - let _e72 = o_Target; - return FragmentOutput(_e72); + let _e69 = o_Target; + return FragmentOutput(_e69); } diff --git a/tests/out/wgsl/bits_glsl.frag.wgsl b/tests/out/wgsl/bits_glsl.frag.wgsl index d81c3319d7..13f2a9925e 100644 --- a/tests/out/wgsl/bits_glsl.frag.wgsl +++ b/tests/out/wgsl/bits_glsl.frag.wgsl @@ -14,10 +14,10 @@ fn main_1() { i2_ = vec2(0); i3_ = vec3(0); i4_ = vec4(0); - u = u32(0); - u2_ = vec2(u32(0)); - u3_ = vec3(u32(0)); - u4_ = vec4(u32(0)); + u = 0u; + u2_ = vec2(0u); + u3_ = vec3(0u); + u4_ = vec4(0u); f2_ = vec2(0.0); f4_ = vec4(0.0); let _e33 = f4_; @@ -42,44 +42,44 @@ fn main_1() { f2_ = unpack2x16float(_e60); let _e66 = i; let _e67 = i; - i = insertBits(_e66, _e67, u32(5), u32(10)); + i = insertBits(_e66, _e67, 5u, 10u); let _e77 = i2_; let _e78 = i2_; - i2_ = insertBits(_e77, _e78, u32(5), u32(10)); + i2_ = insertBits(_e77, _e78, 5u, 10u); let _e88 = i3_; let _e89 = i3_; - i3_ = insertBits(_e88, _e89, u32(5), u32(10)); + i3_ = insertBits(_e88, _e89, 5u, 10u); let _e99 = i4_; let _e100 = i4_; - i4_ = insertBits(_e99, _e100, u32(5), u32(10)); + i4_ = insertBits(_e99, _e100, 5u, 10u); let _e110 = u; let _e111 = u; - u = insertBits(_e110, _e111, u32(5), u32(10)); + u = insertBits(_e110, _e111, 5u, 10u); let _e121 = u2_; let _e122 = u2_; - u2_ = insertBits(_e121, _e122, u32(5), u32(10)); + u2_ = insertBits(_e121, _e122, 5u, 10u); let _e132 = u3_; let _e133 = u3_; - u3_ = insertBits(_e132, _e133, u32(5), u32(10)); + u3_ = insertBits(_e132, _e133, 5u, 10u); let _e143 = u4_; let _e144 = u4_; - u4_ = insertBits(_e143, _e144, u32(5), u32(10)); + u4_ = insertBits(_e143, _e144, 5u, 10u); let _e153 = i; - i = extractBits(_e153, u32(5), u32(10)); + i = extractBits(_e153, 5u, 10u); let _e162 = i2_; - i2_ = extractBits(_e162, u32(5), u32(10)); + i2_ = extractBits(_e162, 5u, 10u); let _e171 = i3_; - i3_ = extractBits(_e171, u32(5), u32(10)); + i3_ = extractBits(_e171, 5u, 10u); let _e180 = i4_; - i4_ = extractBits(_e180, u32(5), u32(10)); + i4_ = extractBits(_e180, 5u, 10u); let _e189 = u; - u = extractBits(_e189, u32(5), u32(10)); + u = extractBits(_e189, 5u, 10u); let _e198 = u2_; - u2_ = extractBits(_e198, u32(5), u32(10)); + u2_ = extractBits(_e198, 5u, 10u); let _e207 = u3_; - u3_ = extractBits(_e207, u32(5), u32(10)); + u3_ = extractBits(_e207, 5u, 10u); let _e216 = u4_; - u4_ = extractBits(_e216, u32(5), u32(10)); + u4_ = extractBits(_e216, 5u, 10u); let _e223 = i; i = firstTrailingBit(_e223); let _e226 = i2_; diff --git a/tests/out/wgsl/buffer.frag.wgsl b/tests/out/wgsl/buffer.frag.wgsl index 73e543ca76..43bcceb0d5 100644 --- a/tests/out/wgsl/buffer.frag.wgsl +++ b/tests/out/wgsl/buffer.frag.wgsl @@ -17,7 +17,7 @@ fn main_1() { let _e9 = testBuffer.data[0]; a = _e9; - testBuffer.data[1] = u32(2); + testBuffer.data[1] = 2u; let _e19 = testBufferReadOnly.data[0]; b = _e19; return; diff --git a/tests/out/wgsl/constant-array-size.frag.wgsl b/tests/out/wgsl/constant-array-size.frag.wgsl index 1aff03c79c..18da4f7cd9 100644 --- a/tests/out/wgsl/constant-array-size.frag.wgsl +++ b/tests/out/wgsl/constant-array-size.frag.wgsl @@ -11,7 +11,7 @@ fn function() -> vec4 { var sum: vec4; var i: i32; - sum = vec4(f32(0)); + sum = vec4(0.0); i = 0; loop { let _e9 = i; diff --git a/tests/out/wgsl/declarations.frag.wgsl b/tests/out/wgsl/declarations.frag.wgsl index 1720296896..6b2d133f7e 100644 --- a/tests/out/wgsl/declarations.frag.wgsl +++ b/tests/out/wgsl/declarations.frag.wgsl @@ -44,8 +44,8 @@ fn main_1() { var a_1: f32; var b: f32; - positions = array, 2>(vec3(-(1.0), 1.0, 0.0), vec3(-(1.0), -(1.0), 0.0)); - strct = TestStruct(f32(1), f32(2)); + positions = array, 2>(vec3(-1.0, 1.0, 0.0), vec3(-1.0, -1.0, 0.0)); + strct = TestStruct(1.0, 2.0); let _e35 = in_array_2[1]; from_input_array = _e35; let _e41 = array_2d[0][0]; diff --git a/tests/out/wgsl/expressions.frag.wgsl b/tests/out/wgsl/expressions.frag.wgsl index 1a1a6fd3b3..8a9776947c 100644 --- a/tests/out/wgsl/expressions.frag.wgsl +++ b/tests/out/wgsl/expressions.frag.wgsl @@ -14,7 +14,7 @@ struct FragmentOutput { @location(0) o_color: vec4, } -const strct: TestStruct = TestStruct(array, 2>(vec4(0u, 0u, 0u, 0u), vec4(1u, 1u, 1u, 1u))); +const strct: TestStruct = TestStruct(array, 2>(vec4(0u), vec4(1u))); var global: f32; @group(0) @binding(0) @@ -289,7 +289,7 @@ fn testStructConstructor() { fn testNonScalarToScalarConstructor() { var f: f32; - f = f32(mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0))[0].x); + f = 1.0; return; } @@ -308,7 +308,7 @@ fn testNonImplicitCastVectorCast() { var a_18: u32; var b_16: vec4; - a_18 = u32(1); + a_18 = 1u; let _e3 = a_18; b_16 = vec4(i32(_e3)); return; @@ -332,7 +332,7 @@ fn ternary(a_20: bool) { a_21 = a_20; let _e3 = a_21; if _e3 { - local = u32(0); + local = 0u; } else { local = 1u; } @@ -342,7 +342,7 @@ fn ternary(a_20: bool) { if _e10 { local_1 = 0u; } else { - local_1 = u32(1); + local_1 = 1u; } let _e15 = local_1; c_1 = _e15; @@ -354,7 +354,7 @@ fn ternary(a_20: bool) { if _e19 { local_2 = 2u; } else { - local_2 = u32(3); + local_2 = 3u; } let _e24 = local_2; local_3 = _e24; @@ -364,7 +364,7 @@ fn ternary(a_20: bool) { let _e27 = local_3; local_4 = _e27; } else { - local_4 = u32(5); + local_4 = 5u; } let _e31 = local_4; nested = _e31; @@ -396,7 +396,7 @@ fn testConstantLength(a_24: array) { var len_1: i32; a_25 = a_24; - len_1 = i32(4u); + len_1 = 4; return; } @@ -417,18 +417,17 @@ fn testSwizzleWrites(a_27: vec3) { a_28 = a_27; let _e6 = a_28; - let _e11 = vec2(3.0, 4.0); - a_28.z = _e11.x; - a_28.x = _e11.y; + a_28.z = 3.0; + a_28.x = 4.0; + let _e14 = a_28; let _e16 = a_28; - let _e18 = a_28; - let _e21 = (_e18.xy * 5.0); - a_28.x = _e21.x; - a_28.y = _e21.y; - let _e26 = a_28; - let _e30 = (_e26.zy + vec2(1.0)); - a_28.z = _e30.x; - a_28.y = _e30.y; + let _e19 = (_e16.xy * 5.0); + a_28.x = _e19.x; + a_28.y = _e19.y; + let _e24 = a_28; + let _e28 = (_e24.zy + vec2(1.0)); + a_28.z = _e28.x; + a_28.y = _e28.y; return; } @@ -441,17 +440,16 @@ fn main_1() { let _e8 = local_6; global = _e8; let _e9 = o_color; - let _e12 = vec4(1.0); - o_color.x = _e12.x; - o_color.y = _e12.y; - o_color.z = _e12.z; - o_color.w = _e12.w; + o_color.x = 1.0; + o_color.y = 1.0; + o_color.z = 1.0; + o_color.w = 1.0; return; } @fragment fn main() -> FragmentOutput { main_1(); - let _e17 = o_color; - return FragmentOutput(_e17); + let _e9 = o_color; + return FragmentOutput(_e9); } diff --git a/tests/out/wgsl/fma.frag.wgsl b/tests/out/wgsl/fma.frag.wgsl index 56677056f7..8708539786 100644 --- a/tests/out/wgsl/fma.frag.wgsl +++ b/tests/out/wgsl/fma.frag.wgsl @@ -33,11 +33,10 @@ fn Fma(d: ptr, m: Mat4x3_, s: f32) { fn main_1() { let _e1 = o_color; - let _e4 = vec4(1.0); - o_color.x = _e4.x; - o_color.y = _e4.y; - o_color.z = _e4.z; - o_color.w = _e4.w; + o_color.x = 1.0; + o_color.y = 1.0; + o_color.z = 1.0; + o_color.w = 1.0; return; } diff --git a/tests/out/wgsl/images.frag.wgsl b/tests/out/wgsl/images.frag.wgsl index 8b77c3e94d..2edcb9c0ea 100644 --- a/tests/out/wgsl/images.frag.wgsl +++ b/tests/out/wgsl/images.frag.wgsl @@ -24,7 +24,7 @@ fn testImg1D(coord: i32) { let _e10 = textureDimensions(img1D); size = i32(_e10); let _e17 = coord_1; - textureStore(img1D, _e17, vec4(f32(2))); + textureStore(img1D, _e17, vec4(2.0)); let _e22 = coord_1; let _e23 = textureLoad(img1D, _e22); c = _e23; @@ -44,7 +44,7 @@ fn testImg1DArray(coord_2: vec2) { let _e20 = textureLoad(img1DArray, _e17.x, _e17.y); c_1 = _e20; let _e26 = coord_3; - textureStore(img1DArray, _e26.x, _e26.y, vec4(f32(2))); + textureStore(img1DArray, _e26.x, _e26.y, vec4(2.0)); return; } @@ -60,7 +60,7 @@ fn testImg2D(coord_4: vec2) { let _e16 = textureLoad(img2D, _e15); c_2 = _e16; let _e22 = coord_5; - textureStore(img2D, _e22, vec4(f32(2))); + textureStore(img2D, _e22, vec4(2.0)); return; } @@ -77,7 +77,7 @@ fn testImg2DArray(coord_6: vec3) { let _e22 = textureLoad(img2DArray, _e19.xy, _e19.z); c_3 = _e22; let _e28 = coord_7; - textureStore(img2DArray, _e28.xy, _e28.z, vec4(f32(2))); + textureStore(img2DArray, _e28.xy, _e28.z, vec4(2.0)); return; } @@ -93,7 +93,7 @@ fn testImg3D(coord_8: vec3) { let _e16 = textureLoad(img3D, _e15); c_4 = _e16; let _e22 = coord_9; - textureStore(img3D, _e22, vec4(f32(2))); + textureStore(img3D, _e22, vec4(2.0)); return; } @@ -119,7 +119,7 @@ fn testImgWriteOnly(coord_12: vec2) { let _e10 = textureDimensions(img2D); size_6 = vec2(vec2(_e10)); let _e18 = coord_13; - textureStore(imgWriteOnly, _e18, vec4(f32(2))); + textureStore(imgWriteOnly, _e18, vec4(2.0)); return; } diff --git a/tests/out/wgsl/long-form-matrix.frag.wgsl b/tests/out/wgsl/long-form-matrix.frag.wgsl index f335452e1f..7cc26f1ff4 100644 --- a/tests/out/wgsl/long-form-matrix.frag.wgsl +++ b/tests/out/wgsl/long-form-matrix.frag.wgsl @@ -8,29 +8,14 @@ fn main_1() { var d: mat3x3; var e: mat4x4; - let _e1 = f32(1); - splat = mat2x2(vec2(_e1, 0.0), vec2(0.0, _e1)); - let _e9 = vec2(f32(1)); - let _e12 = vec2(f32(2)); - normal = mat2x2(vec2(_e9.x, _e9.y), vec2(_e12.x, _e12.y)); - let _e26 = mat3x3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0)); - from_matrix = mat2x4(vec4(_e26[0].x, _e26[0].y, _e26[0].z, 0.0), vec4(_e26[1].x, _e26[1].y, _e26[1].z, 0.0)); - a = mat2x2(vec2(f32(1), f32(2)), vec2(f32(3), f32(4))); - let _e58 = vec2(f32(2), f32(3)); - b = mat2x2(vec2(f32(1), _e58.x), vec2(_e58.y, f32(4))); - let _e73 = vec3(f32(1)); - let _e76 = vec3(f32(1)); - c = mat3x3(vec3(f32(1), f32(2), f32(3)), vec3(_e73.x, _e73.y, _e73.z), vec3(_e76.x, _e76.y, _e76.z)); - let _e93 = vec2(f32(2)); - let _e97 = vec3(f32(1)); - let _e100 = vec3(f32(1)); - d = mat3x3(vec3(_e93.x, _e93.y, f32(1)), vec3(_e97.x, _e97.y, _e97.z), vec3(_e100.x, _e100.y, _e100.z)); - let _e117 = vec2(f32(2)); - let _e120 = vec4(f32(1)); - let _e123 = vec2(f32(2)); - let _e126 = vec4(f32(1)); - let _e129 = vec4(f32(1)); - e = mat4x4(vec4(_e117.x, _e117.y, _e120.x, _e120.y), vec4(_e120.z, _e120.w, _e123.x, _e123.y), vec4(_e126.x, _e126.y, _e126.z, _e126.w), vec4(_e129.x, _e129.y, _e129.z, _e129.w)); + splat = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); + normal = mat2x2(vec2(1.0, 1.0), vec2(2.0, 2.0)); + from_matrix = mat2x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0)); + a = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + b = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + c = mat3x3(vec3(1.0, 2.0, 3.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); + d = mat3x3(vec3(2.0, 2.0, 1.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); + e = mat4x4(vec4(2.0, 2.0, 1.0, 1.0), vec4(1.0, 1.0, 2.0, 2.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0)); return; } diff --git a/tests/out/wgsl/prepostfix.frag.wgsl b/tests/out/wgsl/prepostfix.frag.wgsl index 296a8151eb..5b8f1bfb6e 100644 --- a/tests/out/wgsl/prepostfix.frag.wgsl +++ b/tests/out/wgsl/prepostfix.frag.wgsl @@ -14,7 +14,7 @@ fn main_1() { let _e8 = (_e6 - 1); scalar = _e8; scalar_target = _e8; - vec = vec2(u32(1)); + vec = vec2(1u); let _e14 = vec; vec = (_e14 - vec2(1u)); vec_target = _e14; @@ -22,8 +22,7 @@ fn main_1() { let _e21 = (_e18 + vec2(1u)); vec = _e21; vec_target = _e21; - let _e24 = f32(1); - mat = mat4x3(vec3(_e24, 0.0, 0.0), vec3(0.0, _e24, 0.0), vec3(0.0, 0.0, _e24), vec3(0.0, 0.0, 0.0)); + mat = mat4x3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 0.0)); let _e32 = mat; let _e34 = vec3(1.0); mat = (_e32 + mat4x3(_e34, _e34, _e34, _e34)); diff --git a/tests/out/wgsl/quad_glsl.vert.wgsl b/tests/out/wgsl/quad_glsl.vert.wgsl index b8d52e04c9..1cec36afaf 100644 --- a/tests/out/wgsl/quad_glsl.vert.wgsl +++ b/tests/out/wgsl/quad_glsl.vert.wgsl @@ -14,8 +14,8 @@ fn main_1() { let _e4 = a_uv_1; v_uv = _e4; let _e6 = a_pos_1; - let _e7 = (c_scale * _e6); - gl_Position = vec4(_e7.x, _e7.y, 0.0, 1.0); + let _e8 = (c_scale * _e6); + gl_Position = vec4(_e8.x, _e8.y, 0.0, 1.0); return; } @@ -24,7 +24,7 @@ fn main(@location(0) a_pos: vec2, @location(1) a_uv: vec2) -> VertexOu a_pos_1 = a_pos; a_uv_1 = a_uv; main_1(); - let _e14 = v_uv; - let _e16 = gl_Position; - return VertexOutput(_e14, _e16); + let _e13 = v_uv; + let _e15 = gl_Position; + return VertexOutput(_e13, _e15); } diff --git a/tests/out/wgsl/sampler-functions.frag.wgsl b/tests/out/wgsl/sampler-functions.frag.wgsl index 89a5c35dc4..7b2b01772f 100644 --- a/tests/out/wgsl/sampler-functions.frag.wgsl +++ b/tests/out/wgsl/sampler-functions.frag.wgsl @@ -9,7 +9,7 @@ fn CalcShadowPCF1_(T_P_t_TextureDepth: texture_depth_2d, S_P_t_TextureDepth: sam let _e9 = t_ProjCoord_1; let _e10 = _e9.xyz; let _e13 = textureSampleCompare(T_P_t_TextureDepth, S_P_t_TextureDepth, _e10.xy, _e10.z); - t_Res = (_e6 + (_e13 * (1.0 / 5.0))); + t_Res = (_e6 + (_e13 * 0.2)); let _e19 = t_Res; return _e19; } diff --git a/tests/out/wgsl/samplers.frag.wgsl b/tests/out/wgsl/samplers.frag.wgsl index 96b6626522..1009fd5cd8 100644 --- a/tests/out/wgsl/samplers.frag.wgsl +++ b/tests/out/wgsl/samplers.frag.wgsl @@ -65,92 +65,76 @@ fn testTex1D(coord: f32) { c = _e71; let _e72 = coord_1; let _e75 = coord_1; - let _e77 = vec2(_e75, 6.0); - let _e81 = textureSample(tex1D, samp, (_e77.x / _e77.y)); - c = _e81; - let _e82 = coord_1; - let _e87 = coord_1; - let _e91 = vec4(_e87, 0.0, 0.0, 6.0); - let _e97 = textureSample(tex1D, samp, (_e91.xyz / vec3(_e91.w)).x); - c = _e97; - let _e98 = coord_1; - let _e102 = coord_1; - let _e104 = vec2(_e102, 6.0); - let _e109 = textureSampleBias(tex1D, samp, (_e104.x / _e104.y), 2.0); - c = _e109; - let _e110 = coord_1; - let _e116 = coord_1; - let _e120 = vec4(_e116, 0.0, 0.0, 6.0); - let _e127 = textureSampleBias(tex1D, samp, (_e120.xyz / vec3(_e120.w)).x, 2.0); - c = _e127; - let _e128 = coord_1; - let _e133 = coord_1; - let _e135 = vec2(_e133, 6.0); - let _e141 = textureSampleGrad(tex1D, samp, (_e135.x / _e135.y), 4.0, 4.0); - c = _e141; - let _e142 = coord_1; - let _e149 = coord_1; - let _e153 = vec4(_e149, 0.0, 0.0, 6.0); - let _e161 = textureSampleGrad(tex1D, samp, (_e153.xyz / vec3(_e153.w)).x, 4.0, 4.0); - c = _e161; + let _e79 = textureSample(tex1D, samp, (_e75 / 6.0)); + c = _e79; + let _e80 = coord_1; + let _e85 = coord_1; + let _e95 = textureSample(tex1D, samp, (vec3(_e85, 0.0, 0.0) / vec3(6.0)).x); + c = _e95; + let _e96 = coord_1; + let _e100 = coord_1; + let _e105 = textureSampleBias(tex1D, samp, (_e100 / 6.0), 2.0); + c = _e105; + let _e106 = coord_1; + let _e112 = coord_1; + let _e123 = textureSampleBias(tex1D, samp, (vec3(_e112, 0.0, 0.0) / vec3(6.0)).x, 2.0); + c = _e123; + let _e124 = coord_1; + let _e129 = coord_1; + let _e135 = textureSampleGrad(tex1D, samp, (_e129 / 6.0), 4.0, 4.0); + c = _e135; + let _e136 = coord_1; + let _e143 = coord_1; + let _e155 = textureSampleGrad(tex1D, samp, (vec3(_e143, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0); + c = _e155; + let _e156 = coord_1; let _e162 = coord_1; - let _e168 = coord_1; - let _e170 = vec2(_e168, 6.0); - let _e177 = textureSampleGrad(tex1D, samp, (_e170.x / _e170.y), 4.0, 4.0, 5); - c = _e177; + let _e169 = textureSampleGrad(tex1D, samp, (_e162 / 6.0), 4.0, 4.0, 5); + c = _e169; + let _e170 = coord_1; let _e178 = coord_1; - let _e186 = coord_1; - let _e190 = vec4(_e186, 0.0, 0.0, 6.0); - let _e199 = textureSampleGrad(tex1D, samp, (_e190.xyz / vec3(_e190.w)).x, 4.0, 4.0, 5); - c = _e199; - let _e200 = coord_1; - let _e204 = coord_1; - let _e206 = vec2(_e204, 6.0); - let _e211 = textureSampleLevel(tex1D, samp, (_e206.x / _e206.y), 3.0); - c = _e211; - let _e212 = coord_1; - let _e218 = coord_1; - let _e222 = vec4(_e218, 0.0, 0.0, 6.0); - let _e229 = textureSampleLevel(tex1D, samp, (_e222.xyz / vec3(_e222.w)).x, 3.0); - c = _e229; - let _e230 = coord_1; - let _e235 = coord_1; - let _e237 = vec2(_e235, 6.0); - let _e243 = textureSampleLevel(tex1D, samp, (_e237.x / _e237.y), 3.0, 5); - c = _e243; - let _e244 = coord_1; - let _e251 = coord_1; - let _e255 = vec4(_e251, 0.0, 0.0, 6.0); - let _e263 = textureSampleLevel(tex1D, samp, (_e255.xyz / vec3(_e255.w)).x, 3.0, 5); - c = _e263; - let _e264 = coord_1; + let _e191 = textureSampleGrad(tex1D, samp, (vec3(_e178, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0, 5); + c = _e191; + let _e192 = coord_1; + let _e196 = coord_1; + let _e201 = textureSampleLevel(tex1D, samp, (_e196 / 6.0), 3.0); + c = _e201; + let _e202 = coord_1; + let _e208 = coord_1; + let _e219 = textureSampleLevel(tex1D, samp, (vec3(_e208, 0.0, 0.0) / vec3(6.0)).x, 3.0); + c = _e219; + let _e220 = coord_1; + let _e225 = coord_1; + let _e231 = textureSampleLevel(tex1D, samp, (_e225 / 6.0), 3.0, 5); + c = _e231; + let _e232 = coord_1; + let _e239 = coord_1; + let _e251 = textureSampleLevel(tex1D, samp, (vec3(_e239, 0.0, 0.0) / vec3(6.0)).x, 3.0, 5); + c = _e251; + let _e252 = coord_1; + let _e256 = coord_1; + let _e261 = textureSample(tex1D, samp, (_e256 / 6.0), 5); + c = _e261; + let _e262 = coord_1; let _e268 = coord_1; - let _e270 = vec2(_e268, 6.0); - let _e275 = textureSample(tex1D, samp, (_e270.x / _e270.y), 5); - c = _e275; - let _e276 = coord_1; - let _e282 = coord_1; - let _e286 = vec4(_e282, 0.0, 0.0, 6.0); - let _e293 = textureSample(tex1D, samp, (_e286.xyz / vec3(_e286.w)).x, 5); - c = _e293; - let _e294 = coord_1; + let _e279 = textureSample(tex1D, samp, (vec3(_e268, 0.0, 0.0) / vec3(6.0)).x, 5); + c = _e279; + let _e280 = coord_1; + let _e285 = coord_1; + let _e291 = textureSampleBias(tex1D, samp, (_e285 / 6.0), 2.0, 5); + c = _e291; + let _e292 = coord_1; let _e299 = coord_1; - let _e301 = vec2(_e299, 6.0); - let _e307 = textureSampleBias(tex1D, samp, (_e301.x / _e301.y), 2.0, 5); - c = _e307; - let _e308 = coord_1; + let _e311 = textureSampleBias(tex1D, samp, (vec3(_e299, 0.0, 0.0) / vec3(6.0)).x, 2.0, 5); + c = _e311; + let _e312 = coord_1; let _e315 = coord_1; - let _e319 = vec4(_e315, 0.0, 0.0, 6.0); - let _e327 = textureSampleBias(tex1D, samp, (_e319.xyz / vec3(_e319.w)).x, 2.0, 5); + let _e318 = textureLoad(tex1D, i32(_e315), 3); + c = _e318; + let _e319 = coord_1; + let _e323 = coord_1; + let _e327 = textureLoad(tex1D, i32(_e323), 3); c = _e327; - let _e328 = coord_1; - let _e331 = coord_1; - let _e334 = textureLoad(tex1D, i32(_e331), 3); - c = _e334; - let _e335 = coord_1; - let _e339 = coord_1; - let _e343 = textureLoad(tex1D, i32(_e339), 3); - c = _e343; return; } @@ -218,99 +202,83 @@ fn testTex2D(coord_4: vec2) { let _e42 = textureSampleGrad(tex2D, samp, _e37, vec2(4.0), vec2(4.0)); c_2 = _e42; let _e50 = coord_5; - let _e57 = textureSampleGrad(tex2D, samp, _e50, vec2(4.0), vec2(4.0), vec2(5, 5)); + let _e57 = textureSampleGrad(tex2D, samp, _e50, vec2(4.0), vec2(4.0), vec2(5)); c_2 = _e57; let _e60 = coord_5; let _e62 = textureSampleLevel(tex2D, samp, _e60, 3.0); c_2 = _e62; let _e67 = coord_5; - let _e71 = textureSampleLevel(tex2D, samp, _e67, 3.0, vec2(5, 5)); + let _e71 = textureSampleLevel(tex2D, samp, _e67, 3.0, vec2(5)); c_2 = _e71; let _e75 = coord_5; - let _e78 = textureSample(tex2D, samp, _e75, vec2(5, 5)); + let _e78 = textureSample(tex2D, samp, _e75, vec2(5)); c_2 = _e78; let _e83 = coord_5; - let _e87 = textureSampleBias(tex2D, samp, _e83, 2.0, vec2(5, 5)); + let _e87 = textureSampleBias(tex2D, samp, _e83, 2.0, vec2(5)); c_2 = _e87; let _e88 = coord_5; let _e93 = coord_5; - let _e97 = vec3(_e93.x, _e93.y, 6.0); - let _e102 = textureSample(tex2D, samp, (_e97.xy / vec2(_e97.z))); + let _e102 = textureSample(tex2D, samp, (vec2(_e93.x, _e93.y) / vec2(6.0))); c_2 = _e102; let _e103 = coord_5; let _e109 = coord_5; - let _e114 = vec4(_e109.x, _e109.y, 0.0, 6.0); - let _e120 = textureSample(tex2D, samp, (_e114.xyz / vec3(_e114.w)).xy); + let _e120 = textureSample(tex2D, samp, (vec3(_e109.x, _e109.y, 0.0) / vec3(6.0)).xy); c_2 = _e120; let _e121 = coord_5; let _e127 = coord_5; - let _e131 = vec3(_e127.x, _e127.y, 6.0); - let _e137 = textureSampleBias(tex2D, samp, (_e131.xy / vec2(_e131.z)), 2.0); + let _e137 = textureSampleBias(tex2D, samp, (vec2(_e127.x, _e127.y) / vec2(6.0)), 2.0); c_2 = _e137; let _e138 = coord_5; let _e145 = coord_5; - let _e150 = vec4(_e145.x, _e145.y, 0.0, 6.0); - let _e157 = textureSampleBias(tex2D, samp, (_e150.xyz / vec3(_e150.w)).xy, 2.0); + let _e157 = textureSampleBias(tex2D, samp, (vec3(_e145.x, _e145.y, 0.0) / vec3(6.0)).xy, 2.0); c_2 = _e157; let _e158 = coord_5; let _e167 = coord_5; - let _e171 = vec3(_e167.x, _e167.y, 6.0); - let _e180 = textureSampleGrad(tex2D, samp, (_e171.xy / vec2(_e171.z)), vec2(4.0), vec2(4.0)); + let _e180 = textureSampleGrad(tex2D, samp, (vec2(_e167.x, _e167.y) / vec2(6.0)), vec2(4.0), vec2(4.0)); c_2 = _e180; let _e181 = coord_5; let _e191 = coord_5; - let _e196 = vec4(_e191.x, _e191.y, 0.0, 6.0); - let _e206 = textureSampleGrad(tex2D, samp, (_e196.xyz / vec3(_e196.w)).xy, vec2(4.0), vec2(4.0)); + let _e206 = textureSampleGrad(tex2D, samp, (vec3(_e191.x, _e191.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0)); c_2 = _e206; let _e207 = coord_5; let _e218 = coord_5; - let _e222 = vec3(_e218.x, _e218.y, 6.0); - let _e233 = textureSampleGrad(tex2D, samp, (_e222.xy / vec2(_e222.z)), vec2(4.0), vec2(4.0), vec2(5, 5)); + let _e233 = textureSampleGrad(tex2D, samp, (vec2(_e218.x, _e218.y) / vec2(6.0)), vec2(4.0), vec2(4.0), vec2(5)); c_2 = _e233; let _e234 = coord_5; let _e246 = coord_5; - let _e251 = vec4(_e246.x, _e246.y, 0.0, 6.0); - let _e263 = textureSampleGrad(tex2D, samp, (_e251.xyz / vec3(_e251.w)).xy, vec2(4.0), vec2(4.0), vec2(5, 5)); + let _e263 = textureSampleGrad(tex2D, samp, (vec3(_e246.x, _e246.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0), vec2(5)); c_2 = _e263; let _e264 = coord_5; let _e270 = coord_5; - let _e274 = vec3(_e270.x, _e270.y, 6.0); - let _e280 = textureSampleLevel(tex2D, samp, (_e274.xy / vec2(_e274.z)), 3.0); + let _e280 = textureSampleLevel(tex2D, samp, (vec2(_e270.x, _e270.y) / vec2(6.0)), 3.0); c_2 = _e280; let _e281 = coord_5; let _e288 = coord_5; - let _e293 = vec4(_e288.x, _e288.y, 0.0, 6.0); - let _e300 = textureSampleLevel(tex2D, samp, (_e293.xyz / vec3(_e293.w)).xy, 3.0); + let _e300 = textureSampleLevel(tex2D, samp, (vec3(_e288.x, _e288.y, 0.0) / vec3(6.0)).xy, 3.0); c_2 = _e300; let _e301 = coord_5; let _e309 = coord_5; - let _e313 = vec3(_e309.x, _e309.y, 6.0); - let _e321 = textureSampleLevel(tex2D, samp, (_e313.xy / vec2(_e313.z)), 3.0, vec2(5, 5)); + let _e321 = textureSampleLevel(tex2D, samp, (vec2(_e309.x, _e309.y) / vec2(6.0)), 3.0, vec2(5)); c_2 = _e321; let _e322 = coord_5; let _e331 = coord_5; - let _e336 = vec4(_e331.x, _e331.y, 0.0, 6.0); - let _e345 = textureSampleLevel(tex2D, samp, (_e336.xyz / vec3(_e336.w)).xy, 3.0, vec2(5, 5)); + let _e345 = textureSampleLevel(tex2D, samp, (vec3(_e331.x, _e331.y, 0.0) / vec3(6.0)).xy, 3.0, vec2(5)); c_2 = _e345; let _e346 = coord_5; let _e353 = coord_5; - let _e357 = vec3(_e353.x, _e353.y, 6.0); - let _e364 = textureSample(tex2D, samp, (_e357.xy / vec2(_e357.z)), vec2(5, 5)); + let _e364 = textureSample(tex2D, samp, (vec2(_e353.x, _e353.y) / vec2(6.0)), vec2(5)); c_2 = _e364; let _e365 = coord_5; let _e373 = coord_5; - let _e378 = vec4(_e373.x, _e373.y, 0.0, 6.0); - let _e386 = textureSample(tex2D, samp, (_e378.xyz / vec3(_e378.w)).xy, vec2(5, 5)); + let _e386 = textureSample(tex2D, samp, (vec3(_e373.x, _e373.y, 0.0) / vec3(6.0)).xy, vec2(5)); c_2 = _e386; let _e387 = coord_5; let _e395 = coord_5; - let _e399 = vec3(_e395.x, _e395.y, 6.0); - let _e407 = textureSampleBias(tex2D, samp, (_e399.xy / vec2(_e399.z)), 2.0, vec2(5, 5)); + let _e407 = textureSampleBias(tex2D, samp, (vec2(_e395.x, _e395.y) / vec2(6.0)), 2.0, vec2(5)); c_2 = _e407; let _e408 = coord_5; let _e417 = coord_5; - let _e422 = vec4(_e417.x, _e417.y, 0.0, 6.0); - let _e431 = textureSampleBias(tex2D, samp, (_e422.xyz / vec3(_e422.w)).xy, 2.0, vec2(5, 5)); + let _e431 = textureSampleBias(tex2D, samp, (vec3(_e417.x, _e417.y, 0.0) / vec3(6.0)).xy, 2.0, vec2(5)); c_2 = _e431; let _e432 = coord_5; let _e435 = coord_5; @@ -333,70 +301,58 @@ fn testTex2DShadow(coord_6: vec2) { size2DShadow = vec2(_e20); let _e24 = coord_7; let _e29 = coord_7; - let _e33 = vec3(_e29.x, _e29.y, 1.0); - let _e36 = textureSampleCompare(tex2DShadow, sampShadow, _e33.xy, _e33.z); - d = _e36; - let _e37 = coord_7; - let _e46 = coord_7; - let _e50 = vec3(_e46.x, _e46.y, 1.0); - let _e57 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e50.xy, _e50.z); - d = _e57; - let _e58 = coord_7; - let _e69 = coord_7; - let _e73 = vec3(_e69.x, _e69.y, 1.0); - let _e82 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e73.xy, _e73.z, vec2(5, 5)); - d = _e82; - let _e83 = coord_7; - let _e89 = coord_7; - let _e93 = vec3(_e89.x, _e89.y, 1.0); - let _e97 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e93.xy, _e93.z); - d = _e97; - let _e98 = coord_7; - let _e106 = coord_7; - let _e110 = vec3(_e106.x, _e106.y, 1.0); - let _e116 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e110.xy, _e110.z, vec2(5, 5)); - d = _e116; - let _e117 = coord_7; - let _e124 = coord_7; - let _e128 = vec3(_e124.x, _e124.y, 1.0); - let _e133 = textureSampleCompare(tex2DShadow, sampShadow, _e128.xy, _e128.z, vec2(5, 5)); - d = _e133; + let _e35 = textureSampleCompare(tex2DShadow, sampShadow, vec2(_e29.x, _e29.y), 1.0); + d = _e35; + let _e36 = coord_7; + let _e45 = coord_7; + let _e55 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e45.x, _e45.y), 1.0); + d = _e55; + let _e56 = coord_7; + let _e67 = coord_7; + let _e79 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e67.x, _e67.y), 1.0, vec2(5)); + d = _e79; + let _e80 = coord_7; + let _e86 = coord_7; + let _e93 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e86.x, _e86.y), 1.0); + d = _e93; + let _e94 = coord_7; + let _e102 = coord_7; + let _e111 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e102.x, _e102.y), 1.0, vec2(5)); + d = _e111; + let _e112 = coord_7; + let _e119 = coord_7; + let _e127 = textureSampleCompare(tex2DShadow, sampShadow, vec2(_e119.x, _e119.y), 1.0, vec2(5)); + d = _e127; + let _e128 = coord_7; let _e134 = coord_7; - let _e140 = coord_7; - let _e145 = vec4(_e140.x, _e140.y, 1.0, 6.0); - let _e149 = (_e145.xyz / vec3(_e145.w)); - let _e152 = textureSampleCompare(tex2DShadow, sampShadow, _e149.xy, _e149.z); - d = _e152; - let _e153 = coord_7; - let _e163 = coord_7; - let _e168 = vec4(_e163.x, _e163.y, 1.0, 6.0); - let _e176 = (_e168.xyz / vec3(_e168.w)); - let _e179 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e176.xy, _e176.z); - d = _e179; - let _e180 = coord_7; - let _e192 = coord_7; - let _e197 = vec4(_e192.x, _e192.y, 1.0, 6.0); - let _e207 = (_e197.xyz / vec3(_e197.w)); - let _e210 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e207.xy, _e207.z, vec2(5, 5)); - d = _e210; - let _e211 = coord_7; - let _e218 = coord_7; - let _e223 = vec4(_e218.x, _e218.y, 1.0, 6.0); - let _e228 = (_e223.xyz / vec3(_e223.w)); - let _e231 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e228.xy, _e228.z); - d = _e231; - let _e232 = coord_7; - let _e241 = coord_7; - let _e246 = vec4(_e241.x, _e241.y, 1.0, 6.0); - let _e253 = (_e246.xyz / vec3(_e246.w)); - let _e256 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e253.xy, _e253.z, vec2(5, 5)); - d = _e256; - let _e257 = coord_7; - let _e265 = coord_7; - let _e270 = vec4(_e265.x, _e265.y, 1.0, 6.0); - let _e276 = (_e270.xyz / vec3(_e270.w)); - let _e279 = textureSampleCompare(tex2DShadow, sampShadow, _e276.xy, _e276.z, vec2(5, 5)); - d = _e279; + let _e143 = (vec3(_e134.x, _e134.y, 1.0) / vec3(6.0)); + let _e146 = textureSampleCompare(tex2DShadow, sampShadow, _e143.xy, _e143.z); + d = _e146; + let _e147 = coord_7; + let _e157 = coord_7; + let _e170 = (vec3(_e157.x, _e157.y, 1.0) / vec3(6.0)); + let _e173 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e170.xy, _e170.z); + d = _e173; + let _e174 = coord_7; + let _e186 = coord_7; + let _e201 = (vec3(_e186.x, _e186.y, 1.0) / vec3(6.0)); + let _e204 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e201.xy, _e201.z, vec2(5)); + d = _e204; + let _e205 = coord_7; + let _e212 = coord_7; + let _e222 = (vec3(_e212.x, _e212.y, 1.0) / vec3(6.0)); + let _e225 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e222.xy, _e222.z); + d = _e225; + let _e226 = coord_7; + let _e235 = coord_7; + let _e247 = (vec3(_e235.x, _e235.y, 1.0) / vec3(6.0)); + let _e250 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e247.xy, _e247.z, vec2(5)); + d = _e250; + let _e251 = coord_7; + let _e259 = coord_7; + let _e270 = (vec3(_e259.x, _e259.y, 1.0) / vec3(6.0)); + let _e273 = textureSampleCompare(tex2DShadow, sampShadow, _e270.xy, _e270.z, vec2(5)); + d = _e273; return; } @@ -419,19 +375,19 @@ fn testTex2DArray(coord_8: vec3) { let _e55 = textureSampleGrad(tex2DArray, samp, _e47.xy, i32(_e47.z), vec2(4.0), vec2(4.0)); c_3 = _e55; let _e63 = coord_9; - let _e73 = textureSampleGrad(tex2DArray, samp, _e63.xy, i32(_e63.z), vec2(4.0), vec2(4.0), vec2(5, 5)); + let _e73 = textureSampleGrad(tex2DArray, samp, _e63.xy, i32(_e63.z), vec2(4.0), vec2(4.0), vec2(5)); c_3 = _e73; let _e76 = coord_9; let _e81 = textureSampleLevel(tex2DArray, samp, _e76.xy, i32(_e76.z), 3.0); c_3 = _e81; let _e86 = coord_9; - let _e93 = textureSampleLevel(tex2DArray, samp, _e86.xy, i32(_e86.z), 3.0, vec2(5, 5)); + let _e93 = textureSampleLevel(tex2DArray, samp, _e86.xy, i32(_e86.z), 3.0, vec2(5)); c_3 = _e93; let _e97 = coord_9; - let _e103 = textureSample(tex2DArray, samp, _e97.xy, i32(_e97.z), vec2(5, 5)); + let _e103 = textureSample(tex2DArray, samp, _e97.xy, i32(_e97.z), vec2(5)); c_3 = _e103; let _e108 = coord_9; - let _e115 = textureSampleBias(tex2DArray, samp, _e108.xy, i32(_e108.z), 2.0, vec2(5, 5)); + let _e115 = textureSampleBias(tex2DArray, samp, _e108.xy, i32(_e108.z), 2.0, vec2(5)); c_3 = _e115; let _e116 = coord_9; let _e119 = coord_9; @@ -457,24 +413,20 @@ fn testTex2DArrayShadow(coord_10: vec3) { size2DArrayShadow = vec3(vec3(_e20.x, _e20.y, _e23)); let _e28 = coord_11; let _e34 = coord_11; - let _e39 = vec4(_e34.x, _e34.y, _e34.z, 1.0); - let _e44 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e39.xy, i32(_e39.z), _e39.w); - d_1 = _e44; - let _e45 = coord_11; - let _e55 = coord_11; - let _e60 = vec4(_e55.x, _e55.y, _e55.z, 1.0); - let _e69 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e60.xy, i32(_e60.z), _e60.w); - d_1 = _e69; - let _e70 = coord_11; - let _e82 = coord_11; - let _e87 = vec4(_e82.x, _e82.y, _e82.z, 1.0); - let _e98 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e87.xy, i32(_e87.z), _e87.w, vec2(5, 5)); - d_1 = _e98; - let _e99 = coord_11; - let _e107 = coord_11; - let _e112 = vec4(_e107.x, _e107.y, _e107.z, 1.0); - let _e119 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e112.xy, i32(_e112.z), _e112.w, vec2(5, 5)); - d_1 = _e119; + let _e42 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2(_e34.x, _e34.y), i32(_e34.z), 1.0); + d_1 = _e42; + let _e43 = coord_11; + let _e53 = coord_11; + let _e65 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2(_e53.x, _e53.y), i32(_e53.z), 1.0); + d_1 = _e65; + let _e66 = coord_11; + let _e78 = coord_11; + let _e92 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2(_e78.x, _e78.y), i32(_e78.z), 1.0, vec2(5)); + d_1 = _e92; + let _e93 = coord_11; + let _e101 = coord_11; + let _e111 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2(_e101.x, _e101.y), i32(_e101.z), 1.0, vec2(5)); + d_1 = _e111; return; } @@ -511,14 +463,12 @@ fn testTexCubeShadow(coord_14: vec3) { sizeCubeShadow = vec2(_e20); let _e24 = coord_15; let _e30 = coord_15; - let _e35 = vec4(_e30.x, _e30.y, _e30.z, 1.0); - let _e38 = textureSampleCompare(texCubeShadow, sampShadow, _e35.xyz, _e35.w); - d_2 = _e38; - let _e39 = coord_15; - let _e49 = coord_15; - let _e54 = vec4(_e49.x, _e49.y, _e49.z, 1.0); - let _e61 = textureSampleCompareLevel(texCubeShadow, sampShadow, _e54.xyz, _e54.w); - d_2 = _e61; + let _e37 = textureSampleCompare(texCubeShadow, sampShadow, vec3(_e30.x, _e30.y, _e30.z), 1.0); + d_2 = _e37; + let _e38 = coord_15; + let _e48 = coord_15; + let _e59 = textureSampleCompareLevel(texCubeShadow, sampShadow, vec3(_e48.x, _e48.y, _e48.z), 1.0); + d_2 = _e59; return; } @@ -577,61 +527,53 @@ fn testTex3D(coord_20: vec3) { c_6 = _e31; let _e32 = coord_21; let _e38 = coord_21; - let _e43 = vec4(_e38.x, _e38.y, _e38.z, 6.0); - let _e48 = textureSample(tex3D, samp, (_e43.xyz / vec3(_e43.w))); + let _e48 = textureSample(tex3D, samp, (vec3(_e38.x, _e38.y, _e38.z) / vec3(6.0))); c_6 = _e48; let _e49 = coord_21; let _e56 = coord_21; - let _e61 = vec4(_e56.x, _e56.y, _e56.z, 6.0); - let _e67 = textureSampleBias(tex3D, samp, (_e61.xyz / vec3(_e61.w)), 2.0); + let _e67 = textureSampleBias(tex3D, samp, (vec3(_e56.x, _e56.y, _e56.z) / vec3(6.0)), 2.0); c_6 = _e67; let _e68 = coord_21; let _e76 = coord_21; - let _e81 = vec4(_e76.x, _e76.y, _e76.z, 6.0); - let _e88 = textureSample(tex3D, samp, (_e81.xyz / vec3(_e81.w)), vec3(5, 5, 5)); + let _e88 = textureSample(tex3D, samp, (vec3(_e76.x, _e76.y, _e76.z) / vec3(6.0)), vec3(5)); c_6 = _e88; let _e89 = coord_21; let _e98 = coord_21; - let _e103 = vec4(_e98.x, _e98.y, _e98.z, 6.0); - let _e111 = textureSampleBias(tex3D, samp, (_e103.xyz / vec3(_e103.w)), 2.0, vec3(5, 5, 5)); + let _e111 = textureSampleBias(tex3D, samp, (vec3(_e98.x, _e98.y, _e98.z) / vec3(6.0)), 2.0, vec3(5)); c_6 = _e111; let _e112 = coord_21; let _e119 = coord_21; - let _e124 = vec4(_e119.x, _e119.y, _e119.z, 6.0); - let _e130 = textureSampleLevel(tex3D, samp, (_e124.xyz / vec3(_e124.w)), 3.0); + let _e130 = textureSampleLevel(tex3D, samp, (vec3(_e119.x, _e119.y, _e119.z) / vec3(6.0)), 3.0); c_6 = _e130; let _e131 = coord_21; let _e140 = coord_21; - let _e145 = vec4(_e140.x, _e140.y, _e140.z, 6.0); - let _e153 = textureSampleLevel(tex3D, samp, (_e145.xyz / vec3(_e145.w)), 3.0, vec3(5, 5, 5)); + let _e153 = textureSampleLevel(tex3D, samp, (vec3(_e140.x, _e140.y, _e140.z) / vec3(6.0)), 3.0, vec3(5)); c_6 = _e153; let _e154 = coord_21; let _e164 = coord_21; - let _e169 = vec4(_e164.x, _e164.y, _e164.z, 6.0); - let _e178 = textureSampleGrad(tex3D, samp, (_e169.xyz / vec3(_e169.w)), vec3(4.0), vec3(4.0)); + let _e178 = textureSampleGrad(tex3D, samp, (vec3(_e164.x, _e164.y, _e164.z) / vec3(6.0)), vec3(4.0), vec3(4.0)); c_6 = _e178; let _e179 = coord_21; let _e191 = coord_21; - let _e196 = vec4(_e191.x, _e191.y, _e191.z, 6.0); - let _e207 = textureSampleGrad(tex3D, samp, (_e196.xyz / vec3(_e196.w)), vec3(4.0), vec3(4.0), vec3(5, 5, 5)); + let _e207 = textureSampleGrad(tex3D, samp, (vec3(_e191.x, _e191.y, _e191.z) / vec3(6.0)), vec3(4.0), vec3(4.0), vec3(5)); c_6 = _e207; let _e213 = coord_21; let _e218 = textureSampleGrad(tex3D, samp, _e213, vec3(4.0), vec3(4.0)); c_6 = _e218; let _e226 = coord_21; - let _e233 = textureSampleGrad(tex3D, samp, _e226, vec3(4.0), vec3(4.0), vec3(5, 5, 5)); + let _e233 = textureSampleGrad(tex3D, samp, _e226, vec3(4.0), vec3(4.0), vec3(5)); c_6 = _e233; let _e236 = coord_21; let _e238 = textureSampleLevel(tex3D, samp, _e236, 3.0); c_6 = _e238; let _e243 = coord_21; - let _e247 = textureSampleLevel(tex3D, samp, _e243, 3.0, vec3(5, 5, 5)); + let _e247 = textureSampleLevel(tex3D, samp, _e243, 3.0, vec3(5)); c_6 = _e247; let _e251 = coord_21; - let _e254 = textureSample(tex3D, samp, _e251, vec3(5, 5, 5)); + let _e254 = textureSample(tex3D, samp, _e251, vec3(5)); c_6 = _e254; let _e259 = coord_21; - let _e263 = textureSampleBias(tex3D, samp, _e259, 2.0, vec3(5, 5, 5)); + let _e263 = textureSampleBias(tex3D, samp, _e259, 2.0, vec3(5)); c_6 = _e263; let _e264 = coord_21; let _e267 = coord_21; From 6bae04677619275a3ea5d2b18e2fb3bd8440687c Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 3 May 2023 16:55:27 +0200 Subject: [PATCH 04/37] [glsl-in] set initializer of local variables --- src/front/glsl/parser.rs | 1 + src/front/glsl/parser/declarations.rs | 24 +++++++---- src/front/glsl/parser/functions.rs | 40 +++++++++++++------ tests/in/glsl/local-var-init-in-loop.comp | 7 ++++ tests/out/wgsl/246-collatz.comp.wgsl | 3 +- tests/out/wgsl/277-casting.frag.wgsl | 3 +- tests/out/wgsl/280-matrix-cast.frag.wgsl | 4 +- tests/out/wgsl/901-lhs-field-select.frag.wgsl | 3 +- tests/out/wgsl/932-for-loop-if.frag.wgsl | 3 +- tests/out/wgsl/bevy-pbr.frag.wgsl | 18 +++------ tests/out/wgsl/bits_glsl.frag.wgsl | 30 +++++--------- tests/out/wgsl/constant-array-size.frag.wgsl | 6 +-- tests/out/wgsl/declarations.frag.wgsl | 6 +-- tests/out/wgsl/expressions.frag.wgsl | 19 +++------ .../out/wgsl/local-var-init-in-loop.comp.wgsl | 30 ++++++++++++++ tests/out/wgsl/long-form-matrix.frag.wgsl | 25 ++++-------- tests/out/wgsl/math-functions.frag.wgsl | 9 ++--- tests/out/wgsl/prepostfix.frag.wgsl | 9 ++--- tests/out/wgsl/sampler-functions.frag.wgsl | 3 +- 19 files changed, 127 insertions(+), 116 deletions(-) create mode 100644 tests/in/glsl/local-var-init-in-loop.comp create mode 100644 tests/out/wgsl/local-var-init-in-loop.comp.wgsl diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index 3913576688..851d2e1d79 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -395,6 +395,7 @@ pub struct DeclarationContext<'ctx, 'qualifiers, 'a> { qualifiers: TypeQualifiers<'qualifiers>, /// Indicates a global declaration external: bool, + is_inside_loop: bool, ctx: &'ctx mut Context<'a>, } diff --git a/src/front/glsl/parser/declarations.rs b/src/front/glsl/parser/declarations.rs index da75b0ba61..d213669612 100644 --- a/src/front/glsl/parser/declarations.rs +++ b/src/front/glsl/parser/declarations.rs @@ -75,7 +75,7 @@ impl<'source> ParsingContext<'source> { global_ctx: &mut Context, ) -> Result<()> { if self - .parse_declaration(frontend, global_ctx, true)? + .parse_declaration(frontend, global_ctx, true, false)? .is_none() { let token = self.bump(frontend)?; @@ -246,18 +246,23 @@ impl<'source> ParsingContext<'source> { }) .transpose()?; - let maybe_const_expr = if is_global_const { - init + let (decl_initializer, late_initializer) = if is_global_const { + (init, None) } else if ctx.external { - init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok()) + let decl_initializer = + init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok()); + (decl_initializer, None) } else { - None - // init.filter(|expr| ctx.ctx.expressions.is_const(*expr)) + let decl_initializer = init.filter(|expr| ctx.ctx.expressions.is_const(*expr)); + let late_initializer = (decl_initializer.is_none() || ctx.is_inside_loop) + .then_some(init) + .flatten(); + (decl_initializer, late_initializer) }; - let pointer = ctx.add_var(frontend, ty, name, maybe_const_expr, meta)?; + let pointer = ctx.add_var(frontend, ty, name, decl_initializer, meta)?; - if let Some(value) = init.filter(|_| maybe_const_expr.is_none()) { + if let Some(value) = late_initializer { ctx.ctx.emit_restart(); ctx.ctx.body.push(Statement::Store { pointer, value }, meta); } @@ -287,6 +292,7 @@ impl<'source> ParsingContext<'source> { frontend: &mut Frontend, ctx: &mut Context, external: bool, + is_inside_loop: bool, ) -> Result> { //declaration: // function_prototype SEMICOLON @@ -343,6 +349,7 @@ impl<'source> ParsingContext<'source> { frontend, &mut context, &mut None, + false, )?; frontend.add_function(context, name, result, meta); @@ -385,6 +392,7 @@ impl<'source> ParsingContext<'source> { let mut ctx = DeclarationContext { qualifiers, external, + is_inside_loop, ctx, }; diff --git a/src/front/glsl/parser/functions.rs b/src/front/glsl/parser/functions.rs index 91b7787875..eebaec2698 100644 --- a/src/front/glsl/parser/functions.rs +++ b/src/front/glsl/parser/functions.rs @@ -41,10 +41,11 @@ impl<'source> ParsingContext<'source> { frontend: &mut Frontend, ctx: &mut Context, terminator: &mut Option, + is_inside_loop: bool, ) -> Result> { // Type qualifiers always identify a declaration statement if self.peek_type_qualifier(frontend) { - return self.parse_declaration(frontend, ctx, false); + return self.parse_declaration(frontend, ctx, false, is_inside_loop); } // Type names can identify either declaration statements or type constructors @@ -60,7 +61,7 @@ impl<'source> ParsingContext<'source> { self.backtrack(token)?; if declaration { - return self.parse_declaration(frontend, ctx, false); + return self.parse_declaration(frontend, ctx, false, is_inside_loop); } } @@ -132,7 +133,9 @@ impl<'source> ParsingContext<'source> { self.expect(frontend, TokenValue::RightParen)?; let accept = ctx.new_body(|ctx| { - if let Some(more_meta) = self.parse_statement(frontend, ctx, &mut None)? { + if let Some(more_meta) = + self.parse_statement(frontend, ctx, &mut None, is_inside_loop)? + { meta.subsume(more_meta); } Ok(()) @@ -140,7 +143,9 @@ impl<'source> ParsingContext<'source> { let reject = ctx.new_body(|ctx| { if self.bump_if(frontend, TokenValue::Else).is_some() { - if let Some(more_meta) = self.parse_statement(frontend, ctx, &mut None)? { + if let Some(more_meta) = + self.parse_statement(frontend, ctx, &mut None, is_inside_loop)? + { meta.subsume(more_meta); } } @@ -252,7 +257,12 @@ impl<'source> ParsingContext<'source> { break } _ => { - self.parse_statement(frontend, ctx, &mut case_terminator)?; + self.parse_statement( + frontend, + ctx, + &mut case_terminator, + is_inside_loop, + )?; } } } @@ -347,7 +357,7 @@ impl<'source> ParsingContext<'source> { meta.subsume(expr_meta); - if let Some(body_meta) = self.parse_statement(frontend, ctx, &mut None)? { + if let Some(body_meta) = self.parse_statement(frontend, ctx, &mut None, true)? { meta.subsume(body_meta); } Ok(()) @@ -369,7 +379,7 @@ impl<'source> ParsingContext<'source> { let loop_body = ctx.new_body(|ctx| { let mut terminator = None; - self.parse_statement(frontend, ctx, &mut terminator)?; + self.parse_statement(frontend, ctx, &mut terminator, true)?; let mut stmt = ctx.stmt_ctx(); @@ -425,7 +435,7 @@ impl<'source> ParsingContext<'source> { if self.bump_if(frontend, TokenValue::Semicolon).is_none() { if self.peek_type_name(frontend) || self.peek_type_qualifier(frontend) { - self.parse_declaration(frontend, ctx, false)?; + self.parse_declaration(frontend, ctx, false, false)?; } else { let mut stmt = ctx.stmt_ctx(); let expr = self.parse_expression(frontend, ctx, &mut stmt)?; @@ -508,7 +518,7 @@ impl<'source> ParsingContext<'source> { meta.subsume(self.expect(frontend, TokenValue::RightParen)?.meta); let loop_body = ctx.with_body(loop_body, |ctx| { - if let Some(stmt_meta) = self.parse_statement(frontend, ctx, &mut None)? { + if let Some(stmt_meta) = self.parse_statement(frontend, ctx, &mut None, true)? { meta.subsume(stmt_meta); } Ok(()) @@ -533,8 +543,13 @@ impl<'source> ParsingContext<'source> { let mut block_terminator = None; let block = ctx.new_body(|ctx| { - let block_meta = - self.parse_compound_statement(meta, frontend, ctx, &mut block_terminator)?; + let block_meta = self.parse_compound_statement( + meta, + frontend, + ctx, + &mut block_terminator, + is_inside_loop, + )?; meta.subsume(block_meta); Ok(()) })?; @@ -568,6 +583,7 @@ impl<'source> ParsingContext<'source> { frontend: &mut Frontend, ctx: &mut Context, terminator: &mut Option, + is_inside_loop: bool, ) -> Result { ctx.symbol_table.push_scope(); @@ -580,7 +596,7 @@ impl<'source> ParsingContext<'source> { break; } - let stmt = self.parse_statement(frontend, ctx, terminator)?; + let stmt = self.parse_statement(frontend, ctx, terminator, is_inside_loop)?; if let Some(stmt_meta) = stmt { meta.subsume(stmt_meta); diff --git a/tests/in/glsl/local-var-init-in-loop.comp b/tests/in/glsl/local-var-init-in-loop.comp new file mode 100644 index 0000000000..e8b83ec40f --- /dev/null +++ b/tests/in/glsl/local-var-init-in-loop.comp @@ -0,0 +1,7 @@ +void main() { + vec4 sum = vec4(0); + for (int i = 0; i < 4; i++) { + vec4 a = vec4(1); + sum += a; + } +} \ No newline at end of file diff --git a/tests/out/wgsl/246-collatz.comp.wgsl b/tests/out/wgsl/246-collatz.comp.wgsl index e79d619649..5d1ea64833 100644 --- a/tests/out/wgsl/246-collatz.comp.wgsl +++ b/tests/out/wgsl/246-collatz.comp.wgsl @@ -8,10 +8,9 @@ var gl_GlobalInvocationID: vec3; fn collatz_iterations(n: u32) -> u32 { var n_1: u32; - var i: u32; + var i: u32 = 0u; n_1 = n; - i = 0u; loop { let _e7 = n_1; if !((_e7 != 1u)) { diff --git a/tests/out/wgsl/277-casting.frag.wgsl b/tests/out/wgsl/277-casting.frag.wgsl index 84c50ddd45..87761aff4e 100644 --- a/tests/out/wgsl/277-casting.frag.wgsl +++ b/tests/out/wgsl/277-casting.frag.wgsl @@ -1,7 +1,6 @@ fn main_1() { - var a: f32; + var a: f32 = 1.0; - a = 1.0; return; } diff --git a/tests/out/wgsl/280-matrix-cast.frag.wgsl b/tests/out/wgsl/280-matrix-cast.frag.wgsl index ad9f85b74e..7d432ee496 100644 --- a/tests/out/wgsl/280-matrix-cast.frag.wgsl +++ b/tests/out/wgsl/280-matrix-cast.frag.wgsl @@ -1,8 +1,6 @@ fn main_1() { - var a: mat4x4; + var a: mat4x4 = 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)); - a = 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)); - return; } @fragment diff --git a/tests/out/wgsl/901-lhs-field-select.frag.wgsl b/tests/out/wgsl/901-lhs-field-select.frag.wgsl index 71b9870512..341ef150e1 100644 --- a/tests/out/wgsl/901-lhs-field-select.frag.wgsl +++ b/tests/out/wgsl/901-lhs-field-select.frag.wgsl @@ -1,7 +1,6 @@ fn main_1() { - var a: vec4; + var a: vec4 = vec4(1.0); - a = vec4(1.0); a.x = 2.0; return; } diff --git a/tests/out/wgsl/932-for-loop-if.frag.wgsl b/tests/out/wgsl/932-for-loop-if.frag.wgsl index f9a29ae87e..ad1fdd34ee 100644 --- a/tests/out/wgsl/932-for-loop-if.frag.wgsl +++ b/tests/out/wgsl/932-for-loop-if.frag.wgsl @@ -1,7 +1,6 @@ fn main_1() { - var i: i32; + var i: i32 = 0; - i = 0; loop { let _e2 = i; if !((_e2 < 1)) { diff --git a/tests/out/wgsl/bevy-pbr.frag.wgsl b/tests/out/wgsl/bevy-pbr.frag.wgsl index 73501b99f4..c40b6dd73d 100644 --- a/tests/out/wgsl/bevy-pbr.frag.wgsl +++ b/tests/out/wgsl/bevy-pbr.frag.wgsl @@ -328,8 +328,8 @@ fn EnvBRDFApprox(f0_7: vec3, perceptual_roughness: f32, NoV_6: f32) -> vec3 var f0_8: vec3; var perceptual_roughness_1: f32; var NoV_7: f32; - var c0_: vec4; - var c1_: vec4; + var c0_: vec4 = vec4(-1.0, -0.0275, -0.572, 0.022); + var c1_: vec4 = vec4(1.0, 0.0425, 1.04, -0.04); var r: vec4; var a004_: f32; var AB: vec2; @@ -337,8 +337,6 @@ fn EnvBRDFApprox(f0_7: vec3, perceptual_roughness: f32, NoV_6: f32) -> vec3 f0_8 = f0_7; perceptual_roughness_1 = perceptual_roughness; NoV_7 = NoV_6; - c0_ = vec4(-1.0, -0.0275, -0.572, 0.022); - c1_ = vec4(1.0, 0.0425, 1.04, -0.04); let _e62 = perceptual_roughness_1; let _e64 = c0_; let _e66 = c1_; @@ -638,7 +636,7 @@ fn dir_light(light_2: DirectionalLight, roughness_10: f32, NdotV_2: f32, normal: var NoH_5: f32; var LoH_7: f32; var diffuse_1: vec3; - var specularIntensity_3: f32; + var specularIntensity_3: f32 = 1.0; var specular_2: vec3; light_3 = light_2; @@ -678,7 +676,6 @@ fn dir_light(light_2: DirectionalLight, roughness_10: f32, NdotV_2: f32, normal: let _e124 = LoH_7; let _e125 = Fd_Burley(_e121, _e122, _e123, _e124); diffuse_1 = (_e116 * _e125); - specularIntensity_3 = 1.0; let _e138 = F0_3; let _e139 = roughness_11; let _e140 = half_vector; @@ -716,9 +713,9 @@ fn main_1() { var F0_4: vec3; var diffuseColor_4: vec3; var R_4: vec3; - var light_accum: vec3; - var i: i32; - var i_1: i32; + var light_accum: vec3 = vec3(0.0); + var i: i32 = 0; + var i_1: i32 = 0; var diffuse_ambient: vec3; var specular_ambient: vec3; @@ -825,8 +822,6 @@ fn main_1() { let _e217 = V_3; let _e219 = N_2; R_4 = reflect(-(_e217), _e219); - light_accum = vec3(0.0); - i = 0; loop { let _e227 = i; let _e228 = global_2.NumLights; @@ -854,7 +849,6 @@ fn main_1() { i = (_e236 + 1); } } - i_1 = 0; loop { let _e264 = i_1; let _e265 = global_2.NumLights; diff --git a/tests/out/wgsl/bits_glsl.frag.wgsl b/tests/out/wgsl/bits_glsl.frag.wgsl index 13f2a9925e..597d5aa1c5 100644 --- a/tests/out/wgsl/bits_glsl.frag.wgsl +++ b/tests/out/wgsl/bits_glsl.frag.wgsl @@ -1,25 +1,15 @@ fn main_1() { - var i: i32; - var i2_: vec2; - var i3_: vec3; - var i4_: vec4; - var u: u32; - var u2_: vec2; - var u3_: vec3; - var u4_: vec4; - var f2_: vec2; - var f4_: vec4; + var i: i32 = 0; + var i2_: vec2 = vec2(0); + var i3_: vec3 = vec3(0); + var i4_: vec4 = vec4(0); + var u: u32 = 0u; + var u2_: vec2 = vec2(0u); + var u3_: vec3 = vec3(0u); + var u4_: vec4 = vec4(0u); + var f2_: vec2 = vec2(0.0); + var f4_: vec4 = vec4(0.0); - i = 0; - i2_ = vec2(0); - i3_ = vec3(0); - i4_ = vec4(0); - u = 0u; - u2_ = vec2(0u); - u3_ = vec3(0u); - u4_ = vec4(0u); - f2_ = vec2(0.0); - f4_ = vec4(0.0); let _e33 = f4_; u = pack4x8snorm(_e33); let _e36 = f4_; diff --git a/tests/out/wgsl/constant-array-size.frag.wgsl b/tests/out/wgsl/constant-array-size.frag.wgsl index 18da4f7cd9..f4baa8c129 100644 --- a/tests/out/wgsl/constant-array-size.frag.wgsl +++ b/tests/out/wgsl/constant-array-size.frag.wgsl @@ -8,11 +8,9 @@ const NUM_VECS: i32 = 42; var global: Data; fn function() -> vec4 { - var sum: vec4; - var i: i32; + var sum: vec4 = vec4(0.0); + var i: i32 = 0; - sum = vec4(0.0); - i = 0; loop { let _e9 = i; if !((_e9 < NUM_VECS)) { diff --git a/tests/out/wgsl/declarations.frag.wgsl b/tests/out/wgsl/declarations.frag.wgsl index 6b2d133f7e..bfe6da8e2d 100644 --- a/tests/out/wgsl/declarations.frag.wgsl +++ b/tests/out/wgsl/declarations.frag.wgsl @@ -38,14 +38,12 @@ var array_2d: array, 2>; var array_toomanyd: array, 2>, 2>, 2>, 2>, 2>, 2>; fn main_1() { - var positions: array, 2>; - var strct: TestStruct; + var positions: array, 2> = array, 2>(vec3(-1.0, 1.0, 0.0), vec3(-1.0, -1.0, 0.0)); + var strct: TestStruct = TestStruct(1.0, 2.0); var from_input_array: vec4; var a_1: f32; var b: f32; - positions = array, 2>(vec3(-1.0, 1.0, 0.0), vec3(-1.0, -1.0, 0.0)); - strct = TestStruct(1.0, 2.0); let _e35 = in_array_2[1]; from_input_array = _e35; let _e41 = array_2d[0][0]; diff --git a/tests/out/wgsl/expressions.frag.wgsl b/tests/out/wgsl/expressions.frag.wgsl index 8a9776947c..c3817d8d78 100644 --- a/tests/out/wgsl/expressions.frag.wgsl +++ b/tests/out/wgsl/expressions.frag.wgsl @@ -280,24 +280,18 @@ fn testUnaryOpMat(a_16: mat3x3) { } fn testStructConstructor() { - var tree: BST; + var tree: BST = BST(1); - tree = BST(1); - return; } fn testNonScalarToScalarConstructor() { - var f: f32; + var f: f32 = 1.0; - f = 1.0; - return; } fn testArrayConstructor() { - var tree_1: array; + var tree_1: array = array(0.0); - tree_1 = array(0.0); - return; } fn testFreestandingConstructor() { @@ -305,10 +299,9 @@ fn testFreestandingConstructor() { } fn testNonImplicitCastVectorCast() { - var a_18: u32; + var a_18: u32 = 1u; var b_16: vec4; - a_18 = 1u; let _e3 = a_18; b_16 = vec4(i32(_e3)); return; @@ -393,11 +386,9 @@ fn testLength() { fn testConstantLength(a_24: array) { var a_25: array; - var len_1: i32; + var len_1: i32 = 4; a_25 = a_24; - len_1 = 4; - return; } fn indexConstantNonConstantIndex(i: i32) { diff --git a/tests/out/wgsl/local-var-init-in-loop.comp.wgsl b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl new file mode 100644 index 0000000000..750e32e6d3 --- /dev/null +++ b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl @@ -0,0 +1,30 @@ +fn main_1() { + var sum: vec4 = vec4(0.0); + var i: i32 = 0; + var a: vec4 = vec4(1.0); + + loop { + let _e6 = i; + if !((_e6 < 4)) { + break; + } + { + let _e15 = vec4(1.0); + a = _e15; + let _e17 = sum; + let _e18 = a; + sum = (_e17 + _e18); + } + continuing { + let _e10 = i; + i = (_e10 + 1); + } + } + return; +} + +@compute @workgroup_size(1, 1, 1) +fn main() { + main_1(); + return; +} diff --git a/tests/out/wgsl/long-form-matrix.frag.wgsl b/tests/out/wgsl/long-form-matrix.frag.wgsl index 7cc26f1ff4..cadfe936c4 100644 --- a/tests/out/wgsl/long-form-matrix.frag.wgsl +++ b/tests/out/wgsl/long-form-matrix.frag.wgsl @@ -1,22 +1,13 @@ fn main_1() { - var splat: mat2x2; - var normal: mat2x2; - var from_matrix: mat2x4; - var a: mat2x2; - var b: mat2x2; - var c: mat3x3; - var d: mat3x3; - var e: mat4x4; + var splat: mat2x2 = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); + var normal: mat2x2 = mat2x2(vec2(1.0, 1.0), vec2(2.0, 2.0)); + var from_matrix: mat2x4 = mat2x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0)); + var a: mat2x2 = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + var b: mat2x2 = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); + var c: mat3x3 = mat3x3(vec3(1.0, 2.0, 3.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); + var d: mat3x3 = mat3x3(vec3(2.0, 2.0, 1.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); + var e: mat4x4 = mat4x4(vec4(2.0, 2.0, 1.0, 1.0), vec4(1.0, 1.0, 2.0, 2.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0)); - splat = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); - normal = mat2x2(vec2(1.0, 1.0), vec2(2.0, 2.0)); - from_matrix = mat2x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0)); - a = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); - b = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); - c = mat3x3(vec3(1.0, 2.0, 3.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); - d = mat3x3(vec3(2.0, 2.0, 1.0), vec3(1.0, 1.0, 1.0), vec3(1.0, 1.0, 1.0)); - e = mat4x4(vec4(2.0, 2.0, 1.0, 1.0), vec4(1.0, 1.0, 2.0, 2.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(1.0, 1.0, 1.0, 1.0)); - return; } @fragment diff --git a/tests/out/wgsl/math-functions.frag.wgsl b/tests/out/wgsl/math-functions.frag.wgsl index 0bcc5f5334..0e3b5c3844 100644 --- a/tests/out/wgsl/math-functions.frag.wgsl +++ b/tests/out/wgsl/math-functions.frag.wgsl @@ -1,8 +1,8 @@ fn main_1() { - var a: vec4; - var b: vec4; + var a: vec4 = vec4(1.0); + var b: vec4 = vec4(2.0); var m: mat4x4; - var i: i32; + var i: i32 = 5; var ceilOut: vec4; var roundOut: vec4; var floorOut: vec4; @@ -48,14 +48,11 @@ fn main_1() { var smoothStepVector: vec4; var smoothStepMixed: vec4; - a = vec4(1.0); - b = vec4(2.0); let _e6 = a; let _e7 = b; let _e8 = a; let _e9 = b; m = mat4x4(vec4(_e6.x, _e6.y, _e6.z, _e6.w), vec4(_e7.x, _e7.y, _e7.z, _e7.w), vec4(_e8.x, _e8.y, _e8.z, _e8.w), vec4(_e9.x, _e9.y, _e9.z, _e9.w)); - i = 5; let _e35 = a; ceilOut = ceil(_e35); let _e39 = a; diff --git a/tests/out/wgsl/prepostfix.frag.wgsl b/tests/out/wgsl/prepostfix.frag.wgsl index 5b8f1bfb6e..3a98925a90 100644 --- a/tests/out/wgsl/prepostfix.frag.wgsl +++ b/tests/out/wgsl/prepostfix.frag.wgsl @@ -1,12 +1,11 @@ fn main_1() { var scalar_target: i32; - var scalar: i32; + var scalar: i32 = 1; var vec_target: vec2; - var vec: vec2; + var vec: vec2 = vec2(1u); var mat_target: mat4x3; - var mat: mat4x3; + var mat: mat4x3 = mat4x3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 0.0)); - scalar = 1; let _e3 = scalar; scalar = (_e3 + 1); scalar_target = _e3; @@ -14,7 +13,6 @@ fn main_1() { let _e8 = (_e6 - 1); scalar = _e8; scalar_target = _e8; - vec = vec2(1u); let _e14 = vec; vec = (_e14 - vec2(1u)); vec_target = _e14; @@ -22,7 +20,6 @@ fn main_1() { let _e21 = (_e18 + vec2(1u)); vec = _e21; vec_target = _e21; - mat = mat4x3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0), vec3(0.0, 0.0, 0.0)); let _e32 = mat; let _e34 = vec3(1.0); mat = (_e32 + mat4x3(_e34, _e34, _e34, _e34)); diff --git a/tests/out/wgsl/sampler-functions.frag.wgsl b/tests/out/wgsl/sampler-functions.frag.wgsl index 7b2b01772f..39e51e93de 100644 --- a/tests/out/wgsl/sampler-functions.frag.wgsl +++ b/tests/out/wgsl/sampler-functions.frag.wgsl @@ -1,9 +1,8 @@ fn CalcShadowPCF1_(T_P_t_TextureDepth: texture_depth_2d, S_P_t_TextureDepth: sampler_comparison, t_ProjCoord: vec3) -> f32 { var t_ProjCoord_1: vec3; - var t_Res: f32; + var t_Res: f32 = 0.0; t_ProjCoord_1 = t_ProjCoord; - t_Res = 0.0; let _e6 = t_Res; let _e7 = t_ProjCoord_1; let _e9 = t_ProjCoord_1; From 6feb1383feee6270032e76e4f9251d633cbcacf5 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 13 Sep 2023 15:56:59 -0700 Subject: [PATCH 05/37] Move `front::Emitter` to `proc`. With the addition of the constant evaluator to the `proc` module, it is now concerned with constructing expressions. Any code that constructs expressions will generally also need to deal with `Emit` statements, which are handled by the `Emitter` type. However, `Emitter` is private to the `front` module. This patch moves it to `proc` and makes it accessible to both the constant evaluator and the front ends. --- src/front/glsl/context.rs | 7 +++---- src/front/mod.rs | 39 ------------------------------------ src/front/spv/function.rs | 2 +- src/front/spv/image.rs | 8 ++++---- src/front/spv/mod.rs | 20 +++++++++---------- src/front/wgsl/lower/mod.rs | 5 +++-- src/proc/emitter.rs | 40 +++++++++++++++++++++++++++++++++++++ src/proc/mod.rs | 2 ++ 8 files changed, 63 insertions(+), 60 deletions(-) create mode 100644 src/proc/emitter.rs diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index d767f93588..0f836def69 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -8,10 +8,9 @@ use super::{ Frontend, Result, }; use crate::{ - front::{Emitter, Typifier}, - AddressSpace, Arena, BinaryOperator, Block, Expression, FastHashMap, FunctionArgument, Handle, - Literal, LocalVariable, RelationalFunction, ScalarKind, Span, Statement, Type, TypeInner, - VectorSize, + front::Typifier, proc::Emitter, AddressSpace, Arena, BinaryOperator, Block, Expression, + FastHashMap, FunctionArgument, Handle, Literal, LocalVariable, RelationalFunction, ScalarKind, + Span, Statement, Type, TypeInner, VectorSize, }; use std::ops::Index; diff --git a/src/front/mod.rs b/src/front/mod.rs index faebde4e24..634c809fb9 100644 --- a/src/front/mod.rs +++ b/src/front/mod.rs @@ -19,45 +19,6 @@ use crate::{ }; use std::ops; -/// Helper class to emit expressions -#[allow(dead_code)] -#[derive(Default, Debug)] -struct Emitter { - start_len: Option, -} - -#[allow(dead_code)] -impl Emitter { - fn start(&mut self, arena: &Arena) { - if self.start_len.is_some() { - unreachable!("Emitting has already started!"); - } - self.start_len = Some(arena.len()); - } - const fn is_running(&self) -> bool { - self.start_len.is_some() - } - #[must_use] - fn finish( - &mut self, - arena: &Arena, - ) -> Option<(crate::Statement, crate::span::Span)> { - let start_len = self.start_len.take().unwrap(); - if start_len != arena.len() { - #[allow(unused_mut)] - let mut span = crate::span::Span::default(); - let range = arena.range_from(start_len); - #[cfg(feature = "span")] - for handle in range.clone() { - span.subsume(arena.get_span(handle)) - } - Some((crate::Statement::Emit(range), span)) - } else { - None - } - } -} - /// A table of types for an `Arena`. /// /// A front end can use a `Typifier` to get types for an arena's expressions diff --git a/src/front/spv/function.rs b/src/front/spv/function.rs index 7a874ae4e0..198d9c52dd 100644 --- a/src/front/spv/function.rs +++ b/src/front/spv/function.rs @@ -4,7 +4,7 @@ use crate::{ }; use super::{Error, Instruction, LookupExpression, LookupHelper as _}; -use crate::front::Emitter; +use crate::proc::Emitter; pub type BlockId = u32; diff --git a/src/front/spv/image.rs b/src/front/spv/image.rs index 1cefeb4fcc..ee58c7ba14 100644 --- a/src/front/spv/image.rs +++ b/src/front/spv/image.rs @@ -256,7 +256,7 @@ impl> super::Frontend { &mut self, words_left: u16, ctx: &mut super::BlockContext, - emitter: &mut crate::front::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, body_idx: usize, ) -> Result { @@ -315,7 +315,7 @@ impl> super::Frontend { &mut self, mut words_left: u16, ctx: &mut super::BlockContext, - emitter: &mut crate::front::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -415,7 +415,7 @@ impl> super::Frontend { mut words_left: u16, options: SamplingOptions, ctx: &mut super::BlockContext, - emitter: &mut crate::front::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -663,7 +663,7 @@ impl> super::Frontend { &mut self, at_level: bool, ctx: &mut super::BlockContext, - emitter: &mut crate::front::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 1609868efa..4bb696a63a 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -789,7 +789,7 @@ impl> Frontend { id: spirv::Word, lookup: &LookupExpression, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, body_idx: BodyIndex, ) -> Handle { @@ -851,7 +851,7 @@ impl> Frontend { fn parse_expr_unary_op( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -880,7 +880,7 @@ impl> Frontend { fn parse_expr_binary_op( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -914,7 +914,7 @@ impl> Frontend { fn parse_expr_unary_op_sign_adjusted( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -969,7 +969,7 @@ impl> Frontend { fn parse_expr_binary_op_sign_adjusted( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -1047,7 +1047,7 @@ impl> Frontend { fn parse_expr_int_comparison( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -1118,7 +1118,7 @@ impl> Frontend { fn parse_expr_shift_op( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -1161,7 +1161,7 @@ impl> Frontend { fn parse_expr_derivative( &mut self, ctx: &mut BlockContext, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, block: &mut crate::Block, block_id: spirv::Word, body_idx: usize, @@ -1292,7 +1292,7 @@ impl> Frontend { }) } - let mut emitter = super::Emitter::default(); + let mut emitter = crate::proc::Emitter::default(); emitter.start(ctx.expressions); // Find the `Body` to which this block contributes. @@ -5282,7 +5282,7 @@ fn make_index_literal( ctx: &mut BlockContext, index: u32, block: &mut crate::Block, - emitter: &mut super::Emitter, + emitter: &mut crate::proc::Emitter, index_type: Handle, index_type_id: spirv::Word, span: crate::Span, diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index edb4f6d490..905eb55ea5 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -4,9 +4,10 @@ use crate::front::wgsl::error::{Error, ExpectedToken, InvalidAssignmentType}; use crate::front::wgsl::index::Index; use crate::front::wgsl::parse::number::Number; use crate::front::wgsl::parse::{ast, conv}; -use crate::front::{Emitter, Typifier}; +use crate::front::Typifier; use crate::proc::{ - ensure_block_returns, Alignment, ConstantEvaluator, Layouter, ResolveContext, TypeResolution, + ensure_block_returns, Alignment, ConstantEvaluator, Emitter, Layouter, ResolveContext, + TypeResolution, }; use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span}; diff --git a/src/proc/emitter.rs b/src/proc/emitter.rs new file mode 100644 index 0000000000..281a55e2ad --- /dev/null +++ b/src/proc/emitter.rs @@ -0,0 +1,40 @@ +use crate::arena::Arena; + +/// Helper class to emit expressions +#[allow(dead_code)] +#[derive(Default, Debug)] +pub struct Emitter { + start_len: Option, +} + +#[allow(dead_code)] +impl Emitter { + pub fn start(&mut self, arena: &Arena) { + if self.start_len.is_some() { + unreachable!("Emitting has already started!"); + } + self.start_len = Some(arena.len()); + } + pub const fn is_running(&self) -> bool { + self.start_len.is_some() + } + #[must_use] + pub fn finish( + &mut self, + arena: &Arena, + ) -> Option<(crate::Statement, crate::span::Span)> { + let start_len = self.start_len.take().unwrap(); + if start_len != arena.len() { + #[allow(unused_mut)] + let mut span = crate::span::Span::default(); + let range = arena.range_from(start_len); + #[cfg(feature = "span")] + for handle in range.clone() { + span.subsume(arena.get_span(handle)) + } + Some((crate::Statement::Emit(range), span)) + } else { + None + } + } +} diff --git a/src/proc/mod.rs b/src/proc/mod.rs index c91e0cb3ee..bbdd75eb32 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -3,6 +3,7 @@ */ mod constant_evaluator; +mod emitter; pub mod index; mod layouter; mod namer; @@ -10,6 +11,7 @@ mod terminator; mod typifier; pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorError}; +pub use emitter::Emitter; pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; pub use namer::{EntryPointIndex, NameKey, Namer}; From 8fcadcb2cf692499b637ac5390b1b9c3b4e495d5 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 13 Sep 2023 16:24:03 -0700 Subject: [PATCH 06/37] Replace `ConstantEvaluator`'s closure with optional emitter data. Instead of letting the user supply an arbitrary closure for appending expressions, instead give `ConstantEvaluator` an `Option` that holds an `Emitter` to interrupt, and a `block` to add any new `Emit` statements to. --- src/front/glsl/context.rs | 30 +++++++-------- src/front/wgsl/lower/mod.rs | 32 ++++------------ src/proc/constant_evaluator.rs | 68 +++++++++++++++------------------- src/proc/mod.rs | 2 +- 4 files changed, 52 insertions(+), 80 deletions(-) diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 0f836def69..0fe0f734a3 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -245,19 +245,6 @@ impl<'a> Context<'a> { } pub fn add_expression(&mut self, expr: Expression, meta: Span) -> Result> { - let mut append = |arena: &mut Arena, expr: Expression, span| { - let is_running = self.emitter.is_running(); - let needs_pre_emit = expr.needs_pre_emit(); - if is_running && needs_pre_emit { - self.body.extend(self.emitter.finish(arena)); - } - let h = arena.append(expr, span); - if is_running && needs_pre_emit { - self.emitter.start(arena); - } - h - }; - let (expressions, const_expressions) = if self.is_const { (&mut self.module.const_expressions, None) } else { @@ -269,7 +256,10 @@ impl<'a> Context<'a> { constants: &self.module.constants, expressions, const_expressions, - append: (!self.is_const).then_some(&mut append), + emitter: (!self.is_const).then_some(crate::proc::ConstantEvaluatorEmitter { + emitter: &mut self.emitter, + block: &mut self.body, + }), }; let res = eval.try_eval_and_append(&expr, meta).map_err(|e| Error { @@ -280,7 +270,17 @@ impl<'a> Context<'a> { match res { Ok(expr) => Ok(expr), Err(e) if self.is_const => Err(e), - Err(_) => Ok(append(&mut self.expressions, expr, meta)), + Err(_) => { + let needs_pre_emit = expr.needs_pre_emit(); + if needs_pre_emit { + self.body.extend(self.emitter.finish(expressions)); + } + let h = expressions.append(expr, meta); + if needs_pre_emit { + self.emitter.start(expressions); + } + Ok(h) + } } } diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 905eb55ea5..f36840d3f1 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -6,8 +6,8 @@ use crate::front::wgsl::parse::number::Number; use crate::front::wgsl::parse::{ast, conv}; use crate::front::Typifier; use crate::proc::{ - ensure_block_returns, Alignment, ConstantEvaluator, Emitter, Layouter, ResolveContext, - TypeResolution, + ensure_block_returns, Alignment, ConstantEvaluator, ConstantEvaluatorEmitter, Emitter, + Layouter, ResolveContext, TypeResolution, }; use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span}; @@ -338,20 +338,10 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { constants: &self.module.constants, expressions: rctx.naga_expressions, const_expressions: Some(&self.module.const_expressions), - append: Some( - |arena: &mut Arena, expr: crate::Expression, span| { - let is_running = rctx.emitter.is_running(); - let needs_pre_emit = expr.needs_pre_emit(); - if is_running && needs_pre_emit { - rctx.block.extend(rctx.emitter.finish(arena)); - } - let h = arena.append(expr, span); - if is_running && needs_pre_emit { - rctx.emitter.start(arena); - } - h - }, - ), + emitter: Some(ConstantEvaluatorEmitter { + emitter: rctx.emitter, + block: rctx.block, + }), }; match eval.try_eval_and_append(&expr, span) { @@ -365,15 +355,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { constants: &self.module.constants, expressions: &mut self.module.const_expressions, const_expressions: None, - append: None::< - Box< - dyn FnMut( - &mut Arena, - crate::Expression, - Span, - ) -> Handle, - >, - >, + emitter: None, }; eval.try_eval_and_append(&expr, span) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 218252e1f9..2580cadf2d 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -5,15 +5,22 @@ use crate::{ }; #[derive(Debug)] -pub struct ConstantEvaluator< - 'a, - F: FnMut(&mut Arena, Expression, Span) -> Handle, -> { +pub struct ConstantEvaluator<'a> { pub types: &'a mut UniqueArena, pub constants: &'a Arena, pub expressions: &'a mut Arena, pub const_expressions: Option<&'a Arena>, - pub append: Option, + + /// When `expressions` refers to a function's local expression + /// arena, this is the emitter we should interrupt when inserting + /// new things into it. + pub emitter: Option>, +} + +#[derive(Debug)] +pub struct ConstantEvaluatorEmitter<'a> { + pub emitter: &'a mut super::Emitter, + pub block: &'a mut crate::Block, } #[derive(Clone, Debug, PartialEq, thiserror::Error)] @@ -99,9 +106,7 @@ impl Arena { } } -impl<'a, F: FnMut(&mut Arena, Expression, Span) -> Handle> - ConstantEvaluator<'a, F> -{ +impl ConstantEvaluator<'_> { fn check_and_get( &mut self, expr: Handle, @@ -800,11 +805,20 @@ impl<'a, F: FnMut(&mut Arena, Expression, Span) -> Handle Handle { - if let Some(ref mut append) = self.append { - append(self.expressions, expr, span) - } else { - self.expressions.append(expr, span) + if let Some(ref mut emitter) = self.emitter { + let is_running = emitter.emitter.is_running(); + let needs_pre_emit = expr.needs_pre_emit(); + if is_running && needs_pre_emit { + emitter + .block + .extend(emitter.emitter.finish(self.expressions)); + let h = self.expressions.append(expr, span); + emitter.emitter.start(self.expressions); + return h; + } } + + self.expressions.append(expr, span) } } @@ -973,15 +987,7 @@ mod tests { constants: &constants, expressions: &mut const_expressions, const_expressions: None, - append: None::< - Box< - dyn FnMut( - &mut Arena, - Expression, - crate::Span, - ) -> crate::Handle, - >, - >, + emitter: None, }; let res1 = solver @@ -1068,15 +1074,7 @@ mod tests { constants: &constants, expressions: &mut const_expressions, const_expressions: None, - append: None::< - Box< - dyn FnMut( - &mut Arena, - Expression, - crate::Span, - ) -> crate::Handle, - >, - >, + emitter: None, }; let res = solver @@ -1195,15 +1193,7 @@ mod tests { constants: &constants, expressions: &mut const_expressions, const_expressions: None, - append: None::< - Box< - dyn FnMut( - &mut Arena, - Expression, - crate::Span, - ) -> crate::Handle, - >, - >, + emitter: None, }; let root1 = Expression::AccessIndex { base, index: 1 }; diff --git a/src/proc/mod.rs b/src/proc/mod.rs index bbdd75eb32..2282520a3a 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -10,7 +10,7 @@ mod namer; mod terminator; mod typifier; -pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorError}; +pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorEmitter, ConstantEvaluatorError}; pub use emitter::Emitter; pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; From a53de15ea356a22ee1d1b50d7e5c9a9fa0c9f593 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 19 Sep 2023 06:36:50 -0700 Subject: [PATCH 07/37] Add a bit of logging to `ConstantEvaluator`. (#2488) --- src/proc/constant_evaluator.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 2580cadf2d..249b365c59 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -123,7 +123,10 @@ impl ConstantEvaluator<'_> { Ok(self.constants[c].init) } } - _ => Err(ConstantEvaluatorError::SubexpressionsAreNotConstant), + _ => { + log::debug!("check_and_get: SubexpressionsAreNotConstant"); + Err(ConstantEvaluatorError::SubexpressionsAreNotConstant) + } } } @@ -132,6 +135,7 @@ impl ConstantEvaluator<'_> { expr: &Expression, span: Span, ) -> Result, ConstantEvaluatorError> { + log::trace!("try_eval_and_append: {:?}", expr); match *expr { Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { Ok(self.register_evaluated_expr(expr.clone(), span)) @@ -800,7 +804,10 @@ impl ConstantEvaluator<'_> { let value = self.copy_from(value, expressions)?; Ok(self.register_evaluated_expr(Expression::Splat { size, value }, span)) } - _ => Err(ConstantEvaluatorError::SubexpressionsAreNotConstant), + _ => { + log::debug!("copy_from: SubexpressionsAreNotConstant"); + Err(ConstantEvaluatorError::SubexpressionsAreNotConstant) + } } } From 908d74e041bf5d76d4296be6ebac77871dec615d Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 19 Sep 2023 06:38:29 -0700 Subject: [PATCH 08/37] Document some parts of `ConstantEvaluator`. (#2489) --- src/proc/constant_evaluator.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 249b365c59..88c03bf57f 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -117,9 +117,13 @@ impl ConstantEvaluator<'_> { | Expression::Compose { .. } | Expression::Splat { .. } => Ok(expr), Expression::Constant(c) => { + // Are we working in a function's expression arena, or the + // module's constant expression arena? if let Some(const_expressions) = self.const_expressions { + // Deep-copy the constant's value into our arena. self.copy_from(self.constants[c].init, const_expressions) } else { + // "See through" the constant and use its initializer. Ok(self.constants[c].init) } } @@ -783,6 +787,13 @@ impl ConstantEvaluator<'_> { Ok(self.register_evaluated_expr(expr, span)) } + /// Deep copy `expr` from `expressions` into `self.expressions`. + /// + /// Return the root of the new copy. + /// + /// This is used when we're evaluating expressions in a function's + /// expression arena that refer to a constant: we need to copy the + /// constant's value into the function's arena so we can operate on it. fn copy_from( &mut self, handle: Handle, From 946c5f2ea51724a5be5c8c3c5ab47c16b78b20a6 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 19 Sep 2023 06:38:37 -0700 Subject: [PATCH 09/37] ConstantEvaluator::copy_from: Rename argument `handle` to `expr`. (#2490) --- src/proc/constant_evaluator.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 88c03bf57f..6b917c4d67 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -796,11 +796,11 @@ impl ConstantEvaluator<'_> { /// constant's value into the function's arena so we can operate on it. fn copy_from( &mut self, - handle: Handle, + expr: Handle, expressions: &Arena, ) -> Result, ConstantEvaluatorError> { - let span = expressions.get_span(handle); - match expressions[handle] { + let span = expressions.get_span(expr); + match expressions[expr] { ref expr @ (Expression::Literal(_) | Expression::Constant(_) | Expression::ZeroValue(_)) => Ok(self.register_evaluated_expr(expr.clone(), span)), From 2e5a24422171b1f148123e42f76afe549140ad59 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 20 Sep 2023 07:45:30 -0700 Subject: [PATCH 10/37] ConstantEvaluator::swizzle: Handle vector concatenation and indexing (#2485) * ConstantEvaluator::swizzle: Handle vector concatenation, indexing. * Handle vector Compose expressions nested two deep. * Move `flatten_compose` to `proc`, and make it a free function. * [spv-out] Ensure that we flatten Compose for OpConstantCompose. --- src/back/spv/block.rs | 27 +++++---- src/back/spv/writer.rs | 12 ++-- src/proc/constant_evaluator.rs | 36 ++++++++---- src/proc/mod.rs | 55 ++++++++++++++++++ tests/in/const-exprs.wgsl | 14 +++++ tests/out/glsl/const-exprs.main.Compute.glsl | 23 ++++++++ tests/out/hlsl/const-exprs.hlsl | 14 +++++ tests/out/hlsl/const-exprs.ron | 12 ++++ tests/out/msl/const-exprs.msl | 19 +++++++ tests/out/spv/const-exprs.spvasm | 60 ++++++++++++++++++++ tests/out/wgsl/const-exprs.wgsl | 16 ++++++ tests/snapshots.rs | 4 ++ 12 files changed, 264 insertions(+), 28 deletions(-) create mode 100644 tests/in/const-exprs.wgsl create mode 100644 tests/out/glsl/const-exprs.main.Compute.glsl create mode 100644 tests/out/hlsl/const-exprs.hlsl create mode 100644 tests/out/hlsl/const-exprs.ron create mode 100644 tests/out/msl/const-exprs.msl create mode 100644 tests/out/spv/const-exprs.spvasm create mode 100644 tests/out/wgsl/const-exprs.wgsl diff --git a/src/back/spv/block.rs b/src/back/spv/block.rs index d698931f6d..342a3805f5 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -243,21 +243,24 @@ impl<'w> BlockContext<'w> { self.writer.constant_ids[init.index()] } crate::Expression::ZeroValue(_) => self.writer.get_constant_null(result_type_id), - crate::Expression::Compose { - ty: _, - ref components, - } => { + crate::Expression::Compose { ty, ref components } => { self.temp_list.clear(); - for &component in components { - self.temp_list.push(self.cached[component]); - } - if self.ir_function.expressions.is_const(expr_handle) { - let ty = self - .writer - .get_expression_lookup_type(&self.fun_info[expr_handle].ty); - self.writer.get_constant_composite(ty, &self.temp_list) + self.temp_list.extend( + crate::proc::flatten_compose( + ty, + components, + &self.ir_function.expressions, + &self.ir_module.types, + ) + .map(|component| self.cached[component]), + ); + self.writer + .get_constant_composite(LookupType::Handle(ty), &self.temp_list) } else { + self.temp_list + .extend(components.iter().map(|&component| self.cached[component])); + let id = self.gen_id(); block.body.push(Instruction::composite_construct( result_type_id, diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 7d79377786..0f4809565c 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -1269,10 +1269,14 @@ impl Writer { self.get_constant_null(type_id) } crate::Expression::Compose { ty, ref components } => { - let component_ids: Vec<_> = components - .iter() - .map(|component| self.constant_ids[component.index()]) - .collect(); + let component_ids: Vec<_> = crate::proc::flatten_compose( + ty, + components, + &ir_module.const_expressions, + &ir_module.types, + ) + .map(|component| self.constant_ids[component.index()]) + .collect(); self.get_constant_composite(LookupType::Handle(ty), component_ids.as_slice()) } crate::Expression::Splat { size, value } => { diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 6b917c4d67..9d2055ff6a 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -73,6 +73,8 @@ pub enum ConstantEvaluatorError { SplatScalarOnly, #[error("Can only swizzle vector constants")] SwizzleVectorOnly, + #[error("swizzle component not present in source expression")] + SwizzleOutOfBounds, #[error("Type is not constructible")] TypeNotConstructible, #[error("Subexpression(s) are not constant")] @@ -306,20 +308,31 @@ impl ConstantEvaluator<'_> { let expr = Expression::Splat { size, value }; Ok(self.register_evaluated_expr(expr, span)) } - Expression::Compose { - ty, - components: ref src_components, - } => { + Expression::Compose { ty, ref components } => { let dst_ty = get_dst_ty(ty)?; - let components = pattern + let mut flattened = [src_constant; 4]; // dummy value + let len = + crate::proc::flatten_compose(ty, components, self.expressions, self.types) + .zip(flattened.iter_mut()) + .map(|(component, elt)| *elt = component) + .count(); + let flattened = &flattened[..len]; + + let swizzled_components = pattern[..size as usize] .iter() - .take(size as usize) - .map(|&sc| src_components[sc as usize]) - .collect(); + .map(|&sc| { + let sc = sc as usize; + if let Some(elt) = flattened.get(sc) { + Ok(*elt) + } else { + Err(ConstantEvaluatorError::SwizzleOutOfBounds) + } + }) + .collect::>, _>>()?; let expr = Expression::Compose { ty: dst_ty, - components, + components: swizzled_components, }; Ok(self.register_evaluated_expr(expr, span)) } @@ -455,9 +468,8 @@ impl ConstantEvaluator<'_> { .components() .ok_or(ConstantEvaluatorError::InvalidAccessBase)?; - components - .get(index) - .copied() + crate::proc::flatten_compose(ty, components, self.expressions, self.types) + .nth(index) .ok_or(ConstantEvaluatorError::InvalidAccessIndex) } _ => Err(ConstantEvaluatorError::InvalidAccessBase), diff --git a/src/proc/mod.rs b/src/proc/mod.rs index 2282520a3a..2121da01bb 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -638,6 +638,61 @@ impl GlobalCtx<'_> { } } +/// Return an iterator over the individual components assembled by a +/// `Compose` expression. +/// +/// Given `ty` and `components` from an `Expression::Compose`, return an +/// iterator over the components of the resulting value. +/// +/// Normally, this would just be an iterator over `components`. However, +/// `Compose` expressions can concatenate vectors, in which case the i'th +/// value being composed is not generally the i'th element of `components`. +/// This function consults `ty` to decide if this concatenation is occuring, +/// and returns an iterator that produces the components of the result of +/// the `Compose` expression in either case. +pub fn flatten_compose<'arenas>( + ty: crate::Handle, + components: &'arenas [crate::Handle], + expressions: &'arenas crate::Arena, + types: &'arenas crate::UniqueArena, +) -> impl Iterator> + 'arenas { + // Returning `impl Iterator` is a bit tricky. We may or may not want to + // flatten the components, but we have to settle on a single concrete + // type to return. The below is a single iterator chain that handles + // both the flattening and non-flattening cases. + let (size, is_vector) = if let crate::TypeInner::Vector { size, .. } = types[ty].inner { + (size as usize, true) + } else { + (components.len(), false) + }; + + fn flattener<'c>( + component: &'c crate::Handle, + is_vector: bool, + expressions: &'c crate::Arena, + ) -> &'c [crate::Handle] { + if is_vector { + if let crate::Expression::Compose { + ty: _, + components: ref subcomponents, + } = expressions[*component] + { + return subcomponents; + } + } + std::slice::from_ref(component) + } + + // Expressions like `vec4(vec3(vec2(6, 7), 8), 9)` require us to flatten + // two levels. + components + .iter() + .flat_map(move |component| flattener(component, is_vector, expressions)) + .flat_map(move |component| flattener(component, is_vector, expressions)) + .take(size) + .cloned() +} + #[test] fn test_matrix_size() { let module = crate::Module::default(); diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl new file mode 100644 index 0000000000..c89e61d499 --- /dev/null +++ b/tests/in/const-exprs.wgsl @@ -0,0 +1,14 @@ +@group(0) @binding(0) var out: vec4; +@group(0) @binding(1) var out2: i32; +@group(0) @binding(2) var out3: i32; + +@compute @workgroup_size(1) +fn main() { + let a = vec2(1, 2); + let b = vec2(3, 4); + out = vec4(a, b).wzyx; + + out2 = vec4(a, b)[1]; + + out3 = vec4(vec3(vec2(6, 7), 8), 9)[0]; +} diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl new file mode 100644 index 0000000000..ff634004ca --- /dev/null +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -0,0 +1,23 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; + +layout(std430) buffer type_1_block_1Compute { int _group_0_binding_1_cs; }; + +layout(std430) buffer type_1_block_2Compute { int _group_0_binding_2_cs; }; + + +void main() { + ivec2 a = ivec2(1, 2); + ivec2 b = ivec2(3, 4); + _group_0_binding_0_cs = ivec4(4, 3, 2, 1); + _group_0_binding_1_cs = 2; + _group_0_binding_2_cs = 6; + return; +} + diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl new file mode 100644 index 0000000000..f6faee1d40 --- /dev/null +++ b/tests/out/hlsl/const-exprs.hlsl @@ -0,0 +1,14 @@ +RWByteAddressBuffer out_ : register(u0); +RWByteAddressBuffer out2_ : register(u1); +RWByteAddressBuffer out3_ : register(u2); + +[numthreads(1, 1, 1)] +void main() +{ + int2 a = int2(1, 2); + int2 b = int2(3, 4); + out_.Store4(0, asuint(int4(4, 3, 2, 1))); + out2_.Store(0, asuint(2)); + out3_.Store(0, asuint(6)); + return; +} diff --git a/tests/out/hlsl/const-exprs.ron b/tests/out/hlsl/const-exprs.ron new file mode 100644 index 0000000000..a07b03300b --- /dev/null +++ b/tests/out/hlsl/const-exprs.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl new file mode 100644 index 0000000000..19b9b727fb --- /dev/null +++ b/tests/out/msl/const-exprs.msl @@ -0,0 +1,19 @@ +// language: metal2.0 +#include +#include + +using metal::uint; + + +kernel void main_( + device metal::int4& out [[user(fake0)]] +, device int& out2_ [[user(fake0)]] +, device int& out3_ [[user(fake0)]] +) { + metal::int2 a = metal::int2(1, 2); + metal::int2 b = metal::int2(3, 4); + out = metal::int4(4, 3, 2, 1); + out2_ = 2; + out3_ = 6; + return; +} diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm new file mode 100644 index 0000000000..23f7d242eb --- /dev/null +++ b/tests/out/spv/const-exprs.spvasm @@ -0,0 +1,60 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 34 +OpCapability Shader +OpExtension "SPV_KHR_storage_buffer_storage_class" +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %16 "main" +OpExecutionMode %16 LocalSize 1 1 1 +OpDecorate %6 DescriptorSet 0 +OpDecorate %6 Binding 0 +OpDecorate %7 Block +OpMemberDecorate %7 0 Offset 0 +OpDecorate %9 DescriptorSet 0 +OpDecorate %9 Binding 1 +OpDecorate %10 Block +OpMemberDecorate %10 0 Offset 0 +OpDecorate %12 DescriptorSet 0 +OpDecorate %12 Binding 2 +OpDecorate %13 Block +OpMemberDecorate %13 0 Offset 0 +%2 = OpTypeVoid +%4 = OpTypeInt 32 1 +%3 = OpTypeVector %4 4 +%5 = OpTypeVector %4 2 +%7 = OpTypeStruct %3 +%8 = OpTypePointer StorageBuffer %7 +%6 = OpVariable %8 StorageBuffer +%10 = OpTypeStruct %4 +%11 = OpTypePointer StorageBuffer %10 +%9 = OpVariable %11 StorageBuffer +%13 = OpTypeStruct %4 +%14 = OpTypePointer StorageBuffer %13 +%12 = OpVariable %14 StorageBuffer +%17 = OpTypeFunction %2 +%18 = OpTypePointer StorageBuffer %3 +%20 = OpTypeInt 32 0 +%19 = OpConstant %20 0 +%22 = OpTypePointer StorageBuffer %4 +%25 = OpConstant %4 1 +%26 = OpConstant %4 2 +%27 = OpConstantComposite %5 %25 %26 +%28 = OpConstant %4 3 +%29 = OpConstant %4 4 +%30 = OpConstantComposite %5 %28 %29 +%31 = OpConstantComposite %3 %29 %28 %26 %25 +%32 = OpConstant %4 6 +%16 = OpFunction %2 None %17 +%15 = OpLabel +%21 = OpAccessChain %18 %6 %19 +%23 = OpAccessChain %22 %9 %19 +%24 = OpAccessChain %22 %12 %19 +OpBranch %33 +%33 = OpLabel +OpStore %21 %31 +OpStore %23 %26 +OpStore %24 %32 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl new file mode 100644 index 0000000000..201535836e --- /dev/null +++ b/tests/out/wgsl/const-exprs.wgsl @@ -0,0 +1,16 @@ +@group(0) @binding(0) +var out: vec4; +@group(0) @binding(1) +var out2_: i32; +@group(0) @binding(2) +var out3_: i32; + +@compute @workgroup_size(1, 1, 1) +fn main() { + let a = vec2(1, 2); + let b = vec2(3, 4); + out = vec4(4, 3, 2, 1); + out2_ = 2; + out3_ = 6; + return; +} diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 495bea9598..2bc7f45444 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -777,6 +777,10 @@ fn convert_wgsl() { Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, ), ("msl-varyings", Targets::METAL), + ( + "const-exprs", + Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, + ), ]; for &(name, targets) in inputs.iter() { From 938ce3d8610a76daa6906ae627f488b3b39edab7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 20 Sep 2023 16:01:00 -0700 Subject: [PATCH 11/37] Split `const-exprs.rs` test into separate functions. Also, just use a single out variable for each type. rather than introducing a new output variable for every test we add. --- tests/in/const-exprs.wgsl | 22 ++++- tests/out/glsl/const-exprs.main.Compute.glsl | 27 ++++-- tests/out/hlsl/const-exprs.hlsl | 31 +++++-- tests/out/msl/const-exprs.msl | 36 ++++++-- tests/out/spv/const-exprs.spvasm | 86 ++++++++++++-------- tests/out/wgsl/const-exprs.wgsl | 29 +++++-- 6 files changed, 172 insertions(+), 59 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index c89e61d499..d2b084c383 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -1,14 +1,28 @@ @group(0) @binding(0) var out: vec4; @group(0) @binding(1) var out2: i32; -@group(0) @binding(2) var out3: i32; @compute @workgroup_size(1) fn main() { + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); +} + +// Swizzle the value of nested Compose expressions. +fn swizzle_of_compose() { let a = vec2(1, 2); let b = vec2(3, 4); - out = vec4(a, b).wzyx; + out = vec4(a, b).wzyx; // should assign vec4(4, 3, 2, 1); +} - out2 = vec4(a, b)[1]; +// Index the value of nested Compose expressions. +fn index_of_compose() { + let a = vec2(1, 2); + let b = vec2(3, 4); + out2 += vec4(a, b)[1]; // should assign 2 +} - out3 = vec4(vec3(vec2(6, 7), 8), 9)[0]; +// Index the value of Compose expressions nested three deep +fn compose_three_deep() { + out2 += vec4(vec3(vec2(6, 7), 8), 9)[0]; // should assign 6 } diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index ff634004ca..9b676196d7 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -9,15 +9,32 @@ layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; layout(std430) buffer type_1_block_1Compute { int _group_0_binding_1_cs; }; -layout(std430) buffer type_1_block_2Compute { int _group_0_binding_2_cs; }; - -void main() { +void swizzle_of_compose() { ivec2 a = ivec2(1, 2); ivec2 b = ivec2(3, 4); _group_0_binding_0_cs = ivec4(4, 3, 2, 1); - _group_0_binding_1_cs = 2; - _group_0_binding_2_cs = 6; + return; +} + +void index_of_compose() { + ivec2 a_1 = ivec2(1, 2); + ivec2 b_1 = ivec2(3, 4); + int _e7 = _group_0_binding_1_cs; + _group_0_binding_1_cs = (_e7 + 2); + return; +} + +void compose_three_deep() { + int _e2 = _group_0_binding_1_cs; + _group_0_binding_1_cs = (_e2 + 6); + return; +} + +void main() { + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); return; } diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index f6faee1d40..4275b52360 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -1,14 +1,35 @@ RWByteAddressBuffer out_ : register(u0); RWByteAddressBuffer out2_ : register(u1); -RWByteAddressBuffer out3_ : register(u2); -[numthreads(1, 1, 1)] -void main() +void swizzle_of_compose() { int2 a = int2(1, 2); int2 b = int2(3, 4); out_.Store4(0, asuint(int4(4, 3, 2, 1))); - out2_.Store(0, asuint(2)); - out3_.Store(0, asuint(6)); + return; +} + +void index_of_compose() +{ + int2 a_1 = int2(1, 2); + int2 b_1 = int2(3, 4); + int _expr7 = asint(out2_.Load(0)); + out2_.Store(0, asuint((_expr7 + 2))); + return; +} + +void compose_three_deep() +{ + int _expr2 = asint(out2_.Load(0)); + out2_.Store(0, asuint((_expr2 + 6))); + return; +} + +[numthreads(1, 1, 1)] +void main() +{ + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); return; } diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 19b9b727fb..4c55afb43a 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -5,15 +5,39 @@ using metal::uint; -kernel void main_( - device metal::int4& out [[user(fake0)]] -, device int& out2_ [[user(fake0)]] -, device int& out3_ [[user(fake0)]] +void swizzle_of_compose( + device metal::int4& out ) { metal::int2 a = metal::int2(1, 2); metal::int2 b = metal::int2(3, 4); out = metal::int4(4, 3, 2, 1); - out2_ = 2; - out3_ = 6; + return; +} + +void index_of_compose( + device int& out2_ +) { + metal::int2 a_1 = metal::int2(1, 2); + metal::int2 b_1 = metal::int2(3, 4); + int _e7 = out2_; + out2_ = _e7 + 2; + return; +} + +void compose_three_deep( + device int& out2_ +) { + int _e2 = out2_; + out2_ = _e2 + 6; + return; +} + +kernel void main_( + device metal::int4& out [[user(fake0)]] +, device int& out2_ [[user(fake0)]] +) { + swizzle_of_compose(out); + index_of_compose(out2_); + compose_three_deep(out2_); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 23f7d242eb..091ad78d10 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 34 +; Bound: 49 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %16 "main" -OpExecutionMode %16 LocalSize 1 1 1 +OpEntryPoint GLCompute %42 "main" +OpExecutionMode %42 LocalSize 1 1 1 OpDecorate %6 DescriptorSet 0 OpDecorate %6 Binding 0 OpDecorate %7 Block @@ -16,10 +16,6 @@ OpDecorate %9 DescriptorSet 0 OpDecorate %9 Binding 1 OpDecorate %10 Block OpMemberDecorate %10 0 Offset 0 -OpDecorate %12 DescriptorSet 0 -OpDecorate %12 Binding 2 -OpDecorate %13 Block -OpMemberDecorate %13 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 @@ -30,31 +26,55 @@ OpMemberDecorate %13 0 Offset 0 %10 = OpTypeStruct %4 %11 = OpTypePointer StorageBuffer %10 %9 = OpVariable %11 StorageBuffer -%13 = OpTypeStruct %4 -%14 = OpTypePointer StorageBuffer %13 -%12 = OpVariable %14 StorageBuffer -%17 = OpTypeFunction %2 -%18 = OpTypePointer StorageBuffer %3 -%20 = OpTypeInt 32 0 -%19 = OpConstant %20 0 -%22 = OpTypePointer StorageBuffer %4 -%25 = OpConstant %4 1 -%26 = OpConstant %4 2 -%27 = OpConstantComposite %5 %25 %26 -%28 = OpConstant %4 3 -%29 = OpConstant %4 4 -%30 = OpConstantComposite %5 %28 %29 -%31 = OpConstantComposite %3 %29 %28 %26 %25 -%32 = OpConstant %4 6 -%16 = OpFunction %2 None %17 -%15 = OpLabel -%21 = OpAccessChain %18 %6 %19 -%23 = OpAccessChain %22 %9 %19 -%24 = OpAccessChain %22 %12 %19 -OpBranch %33 -%33 = OpLabel -OpStore %21 %31 -OpStore %23 %26 -OpStore %24 %32 +%14 = OpTypeFunction %2 +%15 = OpTypePointer StorageBuffer %3 +%17 = OpTypeInt 32 0 +%16 = OpConstant %17 0 +%19 = OpConstant %4 1 +%20 = OpConstant %4 2 +%21 = OpConstantComposite %5 %19 %20 +%22 = OpConstant %4 3 +%23 = OpConstant %4 4 +%24 = OpConstantComposite %5 %22 %23 +%25 = OpConstantComposite %3 %23 %22 %20 %19 +%29 = OpTypePointer StorageBuffer %4 +%37 = OpConstant %4 6 +%13 = OpFunction %2 None %14 +%12 = OpLabel +%18 = OpAccessChain %15 %6 %16 +OpBranch %26 +%26 = OpLabel +OpStore %18 %25 +OpReturn +OpFunctionEnd +%28 = OpFunction %2 None %14 +%27 = OpLabel +%30 = OpAccessChain %29 %9 %16 +OpBranch %31 +%31 = OpLabel +%32 = OpLoad %4 %30 +%33 = OpIAdd %4 %32 %20 +OpStore %30 %33 +OpReturn +OpFunctionEnd +%35 = OpFunction %2 None %14 +%34 = OpLabel +%36 = OpAccessChain %29 %9 %16 +OpBranch %38 +%38 = OpLabel +%39 = OpLoad %4 %36 +%40 = OpIAdd %4 %39 %37 +OpStore %36 %40 +OpReturn +OpFunctionEnd +%42 = OpFunction %2 None %14 +%41 = OpLabel +%43 = OpAccessChain %15 %6 %16 +%44 = OpAccessChain %29 %9 %16 +OpBranch %45 +%45 = OpLabel +%46 = OpFunctionCall %2 %13 +%47 = OpFunctionCall %2 %28 +%48 = OpFunctionCall %2 %35 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 201535836e..d93369f761 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -2,15 +2,32 @@ var out: vec4; @group(0) @binding(1) var out2_: i32; -@group(0) @binding(2) -var out3_: i32; -@compute @workgroup_size(1, 1, 1) -fn main() { +fn swizzle_of_compose() { let a = vec2(1, 2); let b = vec2(3, 4); out = vec4(4, 3, 2, 1); - out2_ = 2; - out3_ = 6; + return; +} + +fn index_of_compose() { + let a_1 = vec2(1, 2); + let b_1 = vec2(3, 4); + let _e7 = out2_; + out2_ = (_e7 + 2); + return; +} + +fn compose_three_deep() { + let _e2 = out2_; + out2_ = (_e2 + 6); + return; +} + +@compute @workgroup_size(1, 1, 1) +fn main() { + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); return; } From 85b578ab04274480546b108b32f741142ff9a62c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 20 Sep 2023 16:01:00 -0700 Subject: [PATCH 12/37] Test that only constant expressions are hoisted to initializers. --- tests/in/const-exprs.wgsl | 20 +++++++++ tests/out/glsl/const-exprs.main.Compute.glsl | 19 ++++++++ tests/out/hlsl/const-exprs.hlsl | 21 +++++++++ tests/out/msl/const-exprs.msl | 21 +++++++++ tests/out/spv/const-exprs.spvasm | 47 ++++++++++++++++---- tests/out/wgsl/const-exprs.wgsl | 20 +++++++++ 6 files changed, 139 insertions(+), 9 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index d2b084c383..fd1b9c31bf 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -6,6 +6,7 @@ fn main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); + non_constant_initializers(); } // Swizzle the value of nested Compose expressions. @@ -26,3 +27,22 @@ fn index_of_compose() { fn compose_three_deep() { out2 += vec4(vec3(vec2(6, 7), 8), 9)[0]; // should assign 6 } + +// While WGSL allows local variables to be declared anywhere in the function, +// Naga treats them all as appearing at the top of the function. To ensure that +// WGSL initializer expressions are evaluated at the right time, in the general +// case they need to be turned into Naga `Store` statements executed at the +// point of the WGSL declaration. +// +// When a variable's initializer is a constant expression, however, it can be +// evaluated at any time. The WGSL front end thus renders locals with +// initializers that are constants as Naga locals with initializers. This test +// checks that Naga local variable initializers are only used when safe. +fn non_constant_initializers() { + var w = 10 + 20; + var x = w; + var y = x; + var z = 30 + 40; + + out += vec4(w, x, y, z); +} diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 9b676196d7..df029bdaaa 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -31,10 +31,29 @@ void compose_three_deep() { return; } +void non_constant_initializers() { + int w = 30; + int x = 0; + int y = 0; + int z = 70; + int _e2 = w; + x = _e2; + int _e4 = x; + y = _e4; + int _e9 = w; + int _e10 = x; + int _e11 = y; + int _e12 = z; + ivec4 _e14 = _group_0_binding_0_cs; + _group_0_binding_0_cs = (_e14 + ivec4(_e9, _e10, _e11, _e12)); + return; +} + void main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); + non_constant_initializers(); return; } diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 4275b52360..a43f27b02a 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -25,11 +25,32 @@ void compose_three_deep() return; } +void non_constant_initializers() +{ + int w = 30; + int x = (int)0; + int y = (int)0; + int z = 70; + + int _expr2 = w; + x = _expr2; + int _expr4 = x; + y = _expr4; + int _expr9 = w; + int _expr10 = x; + int _expr11 = y; + int _expr12 = z; + int4 _expr14 = asint(out_.Load4(0)); + out_.Store4(0, asuint((_expr14 + int4(_expr9, _expr10, _expr11, _expr12)))); + return; +} + [numthreads(1, 1, 1)] void main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); + non_constant_initializers(); return; } diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 4c55afb43a..a9aa559993 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -32,6 +32,26 @@ void compose_three_deep( return; } +void non_constant_initializers( + device metal::int4& out +) { + int w = 30; + int x = {}; + int y = {}; + int z = 70; + int _e2 = w; + x = _e2; + int _e4 = x; + y = _e4; + int _e9 = w; + int _e10 = x; + int _e11 = y; + int _e12 = z; + metal::int4 _e14 = out; + out = _e14 + metal::int4(_e9, _e10, _e11, _e12); + return; +} + kernel void main_( device metal::int4& out [[user(fake0)]] , device int& out2_ [[user(fake0)]] @@ -39,5 +59,6 @@ kernel void main_( swizzle_of_compose(out); index_of_compose(out2_); compose_three_deep(out2_); + non_constant_initializers(out); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 091ad78d10..50b0373a46 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 49 +; Bound: 72 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %42 "main" -OpExecutionMode %42 LocalSize 1 1 1 +OpEntryPoint GLCompute %64 "main" +OpExecutionMode %64 LocalSize 1 1 1 OpDecorate %6 DescriptorSet 0 OpDecorate %6 Binding 0 OpDecorate %7 Block @@ -39,6 +39,11 @@ OpMemberDecorate %10 0 Offset 0 %25 = OpConstantComposite %3 %23 %22 %20 %19 %29 = OpTypePointer StorageBuffer %4 %37 = OpConstant %4 6 +%44 = OpConstant %4 30 +%45 = OpConstant %4 70 +%47 = OpTypePointer Function %4 +%49 = OpConstantNull %4 +%51 = OpConstantNull %4 %13 = OpFunction %2 None %14 %12 = OpLabel %18 = OpAccessChain %15 %6 %16 @@ -69,12 +74,36 @@ OpReturn OpFunctionEnd %42 = OpFunction %2 None %14 %41 = OpLabel +%48 = OpVariable %47 Function %49 +%52 = OpVariable %47 Function %45 +%46 = OpVariable %47 Function %44 +%50 = OpVariable %47 Function %51 %43 = OpAccessChain %15 %6 %16 -%44 = OpAccessChain %29 %9 %16 -OpBranch %45 -%45 = OpLabel -%46 = OpFunctionCall %2 %13 -%47 = OpFunctionCall %2 %28 -%48 = OpFunctionCall %2 %35 +OpBranch %53 +%53 = OpLabel +%54 = OpLoad %4 %46 +OpStore %48 %54 +%55 = OpLoad %4 %48 +OpStore %50 %55 +%56 = OpLoad %4 %46 +%57 = OpLoad %4 %48 +%58 = OpLoad %4 %50 +%59 = OpLoad %4 %52 +%60 = OpCompositeConstruct %3 %56 %57 %58 %59 +%61 = OpLoad %3 %43 +%62 = OpIAdd %3 %61 %60 +OpStore %43 %62 +OpReturn +OpFunctionEnd +%64 = OpFunction %2 None %14 +%63 = OpLabel +%65 = OpAccessChain %15 %6 %16 +%66 = OpAccessChain %29 %9 %16 +OpBranch %67 +%67 = OpLabel +%68 = OpFunctionCall %2 %13 +%69 = OpFunctionCall %2 %28 +%70 = OpFunctionCall %2 %35 +%71 = OpFunctionCall %2 %42 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index d93369f761..dcef1812b9 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -24,10 +24,30 @@ fn compose_three_deep() { return; } +fn non_constant_initializers() { + var w: i32 = 30; + var x: i32; + var y: i32; + var z: i32 = 70; + + let _e2 = w; + x = _e2; + let _e4 = x; + y = _e4; + let _e9 = w; + let _e10 = x; + let _e11 = y; + let _e12 = z; + let _e14 = out; + out = (_e14 + vec4(_e9, _e10, _e11, _e12)); + return; +} + @compute @workgroup_size(1, 1, 1) fn main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); + non_constant_initializers(); return; } From a2a917c66563debfedd70b4181e73ea0cab2e34e Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 22 Sep 2023 18:49:05 +0200 Subject: [PATCH 13/37] add an expression constness tracker --- src/back/spv/block.rs | 7 +- src/back/spv/mod.rs | 3 + src/back/spv/writer.rs | 10 +- src/front/glsl/context.rs | 49 +- src/front/glsl/parser/declarations.rs | 26 +- src/front/wgsl/lower/mod.rs | 40 +- src/proc/constant_evaluator.rs | 169 ++- src/proc/mod.rs | 4 +- tests/out/spv/debug-symbol-terrain.spvasm | 1123 +++++++++-------- .../out/wgsl/local-var-init-in-loop.comp.wgsl | 5 +- tests/out/wgsl/samplers.frag.wgsl | 376 +++--- 11 files changed, 983 insertions(+), 829 deletions(-) diff --git a/src/back/spv/block.rs b/src/back/spv/block.rs index 342a3805f5..4dba7ea0ca 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -245,7 +245,7 @@ impl<'w> BlockContext<'w> { crate::Expression::ZeroValue(_) => self.writer.get_constant_null(result_type_id), crate::Expression::Compose { ty, ref components } => { self.temp_list.clear(); - if self.ir_function.expressions.is_const(expr_handle) { + if self.expression_constness.is_const(expr_handle) { self.temp_list.extend( crate::proc::flatten_compose( ty, @@ -274,7 +274,7 @@ impl<'w> BlockContext<'w> { let value_id = self.cached[value]; let components = &[value_id; 4][..size as usize]; - if self.ir_function.expressions.is_const(expr_handle) { + if self.expression_constness.is_const(expr_handle) { let ty = self .writer .get_expression_lookup_type(&self.fun_info[expr_handle].ty); @@ -1776,7 +1776,8 @@ impl<'w> BlockContext<'w> { match *statement { crate::Statement::Emit(ref range) => { for handle in range.clone() { - if !self.ir_function.expressions.is_const(handle) { + // omit const expressions as we've already cached those + if !self.expression_constness.is_const(handle) { self.cache_expression_value(handle, &mut block)?; } } diff --git a/src/back/spv/mod.rs b/src/back/spv/mod.rs index c528279087..ac7281fc6b 100644 --- a/src/back/spv/mod.rs +++ b/src/back/spv/mod.rs @@ -557,6 +557,9 @@ struct BlockContext<'w> { /// The `Writer`'s temporary vector, for convenience. temp_list: Vec, + + /// Tracks the constness of `Expression`s residing in `self.ir_function.expressions` + expression_constness: crate::proc::ExpressionConstnessTracker, } impl BlockContext<'_> { diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 0f4809565c..2e133985af 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -620,13 +620,16 @@ impl Writer { // Steal the Writer's temp list for a bit. temp_list: std::mem::take(&mut self.temp_list), writer: self, + expression_constness: crate::proc::ExpressionConstnessTracker::from_arena( + &ir_function.expressions, + ), }; - // fill up the pre-emitted expressions + // fill up the pre-emitted and const expressions context.cached.reset(ir_function.expressions.len()); for (handle, expr) in ir_function.expressions.iter() { if (expr.needs_pre_emit() && !matches!(*expr, crate::Expression::LocalVariable(_))) - || ir_function.expressions.is_const(handle) + || context.expression_constness.is_const(handle) { context.cache_expression_value(handle, &mut prelude)?; } @@ -665,8 +668,9 @@ impl Writer { .insert(handle, LocalVariable { id, instruction }); } + // cache local variable expressions for (handle, expr) in ir_function.expressions.iter() { - if expr.needs_pre_emit() && matches!(*expr, crate::Expression::LocalVariable(_)) { + if matches!(*expr, crate::Expression::LocalVariable(_)) { context.cache_expression_value(handle, &mut prelude)?; } } diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 0fe0f734a3..871d110c76 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -77,6 +77,8 @@ pub struct Context<'a> { pub body: Block, pub module: &'a mut crate::Module, pub is_const: bool, + /// Tracks the constness of `Expression`s residing in `self.expressions` + pub expression_constness: crate::proc::ExpressionConstnessTracker, } impl<'a> Context<'a> { @@ -99,6 +101,7 @@ impl<'a> Context<'a> { body: Block::new(), module, is_const: false, + expression_constness: crate::proc::ExpressionConstnessTracker::new(), }; this.emit_start(); @@ -245,21 +248,16 @@ impl<'a> Context<'a> { } pub fn add_expression(&mut self, expr: Expression, meta: Span) -> Result> { - let (expressions, const_expressions) = if self.is_const { - (&mut self.module.const_expressions, None) + let mut eval = if self.is_const { + crate::proc::ConstantEvaluator::for_module(self.module) } else { - (&mut self.expressions, Some(&self.module.const_expressions)) - }; - - let mut eval = crate::proc::ConstantEvaluator { - types: &mut self.module.types, - constants: &self.module.constants, - expressions, - const_expressions, - emitter: (!self.is_const).then_some(crate::proc::ConstantEvaluatorEmitter { - emitter: &mut self.emitter, - block: &mut self.body, - }), + crate::proc::ConstantEvaluator::for_function( + self.module, + &mut self.expressions, + &mut self.expression_constness, + &mut self.emitter, + &mut self.body, + ) }; let res = eval.try_eval_and_append(&expr, meta).map_err(|e| Error { @@ -269,17 +267,20 @@ impl<'a> Context<'a> { match res { Ok(expr) => Ok(expr), - Err(e) if self.is_const => Err(e), - Err(_) => { - let needs_pre_emit = expr.needs_pre_emit(); - if needs_pre_emit { - self.body.extend(self.emitter.finish(expressions)); - } - let h = expressions.append(expr, meta); - if needs_pre_emit { - self.emitter.start(expressions); + Err(e) => { + if self.is_const { + Err(e) + } else { + let needs_pre_emit = expr.needs_pre_emit(); + if needs_pre_emit { + self.body.extend(self.emitter.finish(&self.expressions)); + } + let h = self.expressions.append(expr, meta); + if needs_pre_emit { + self.emitter.start(&self.expressions); + } + Ok(h) } - Ok(h) } } } diff --git a/src/front/glsl/parser/declarations.rs b/src/front/glsl/parser/declarations.rs index d213669612..02ee2bedea 100644 --- a/src/front/glsl/parser/declarations.rs +++ b/src/front/glsl/parser/declarations.rs @@ -246,18 +246,26 @@ impl<'source> ParsingContext<'source> { }) .transpose()?; - let (decl_initializer, late_initializer) = if is_global_const { - (init, None) + let decl_initializer; + let late_initializer; + if is_global_const { + decl_initializer = init; + late_initializer = None; } else if ctx.external { - let decl_initializer = + decl_initializer = init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok()); - (decl_initializer, None) + late_initializer = None; + } else if let Some(init) = init { + if ctx.is_inside_loop || !ctx.ctx.expression_constness.is_const(init) { + decl_initializer = None; + late_initializer = Some(init); + } else { + decl_initializer = Some(init); + late_initializer = None; + } } else { - let decl_initializer = init.filter(|expr| ctx.ctx.expressions.is_const(*expr)); - let late_initializer = (decl_initializer.is_none() || ctx.is_inside_loop) - .then_some(init) - .flatten(); - (decl_initializer, late_initializer) + decl_initializer = None; + late_initializer = None; }; let pointer = ctx.add_var(frontend, ty, name, decl_initializer, meta)?; diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index f36840d3f1..d419f29115 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -6,8 +6,8 @@ use crate::front::wgsl::parse::number::Number; use crate::front::wgsl::parse::{ast, conv}; use crate::front::Typifier; use crate::proc::{ - ensure_block_returns, Alignment, ConstantEvaluator, ConstantEvaluatorEmitter, Emitter, - Layouter, ResolveContext, TypeResolution, + ensure_block_returns, Alignment, ConstantEvaluator, Emitter, Layouter, ResolveContext, + TypeResolution, }; use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span}; @@ -106,6 +106,8 @@ pub struct StatementContext<'source, 'temp, 'out> { named_expressions: &'out mut FastIndexMap, (String, Span)>, arguments: &'out [crate::FunctionArgument], module: &'out mut crate::Module, + /// Tracks the constness of `Expression`s residing in `self.naga_expressions` + expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker, } impl<'a, 'temp> StatementContext<'a, 'temp, '_> { @@ -122,6 +124,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { named_expressions: self.named_expressions, arguments: self.arguments, module: self.module, + expression_constness: self.expression_constness, } } @@ -147,6 +150,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { typifier: self.typifier, block, emitter, + expression_constness: self.expression_constness, }), } } @@ -188,6 +192,8 @@ pub struct RuntimeExpressionContext<'temp, 'out> { block: &'temp mut crate::Block, emitter: &'temp mut Emitter, typifier: &'temp mut Typifier, + /// Tracks the constness of `Expression`s residing in `self.naga_expressions` + expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker, } impl RuntimeExpressionContext<'_, '_> { @@ -200,6 +206,7 @@ impl RuntimeExpressionContext<'_, '_> { block: self.block, emitter: self.emitter, typifier: self.typifier, + expression_constness: self.expression_constness, } } } @@ -333,16 +340,13 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { ) -> Result, Error<'source>> { match self.expr_type { ExpressionContextType::Runtime(ref mut rctx) => { - let mut eval = ConstantEvaluator { - types: &mut self.module.types, - constants: &self.module.constants, - expressions: rctx.naga_expressions, - const_expressions: Some(&self.module.const_expressions), - emitter: Some(ConstantEvaluatorEmitter { - emitter: rctx.emitter, - block: rctx.block, - }), - }; + let mut eval = ConstantEvaluator::for_function( + self.module, + rctx.naga_expressions, + rctx.expression_constness, + rctx.emitter, + rctx.block, + ); match eval.try_eval_and_append(&expr, span) { Ok(expr) => Ok(expr), @@ -350,14 +354,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } ExpressionContextType::Constant => { - let mut eval = ConstantEvaluator { - types: &mut self.module.types, - constants: &self.module.constants, - expressions: &mut self.module.const_expressions, - const_expressions: None, - emitter: None, - }; - + let mut eval = ConstantEvaluator::for_module(self.module); eval.try_eval_and_append(&expr, span) .map_err(|e| Error::ConstantEvaluatorError(e, span)) } @@ -1027,6 +1024,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { types: ctx.types, module: ctx.module, arguments: &arguments, + expression_constness: &mut crate::proc::ExpressionConstnessTracker::new(), }, )?; ensure_block_returns(&mut body); @@ -1179,7 +1177,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let (const_initializer, initializer) = { match initializer { - Some(init) if ctx.naga_expressions.is_const(init) => { + Some(init) if ctx.expression_constness.is_const(init) => { (Some(init), is_inside_loop.then_some(init)) } Some(init) => (None, Some(init)), diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 9d2055ff6a..9dc021275d 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -6,21 +6,64 @@ use crate::{ #[derive(Debug)] pub struct ConstantEvaluator<'a> { - pub types: &'a mut UniqueArena, - pub constants: &'a Arena, - pub expressions: &'a mut Arena, - pub const_expressions: Option<&'a Arena>, - - /// When `expressions` refers to a function's local expression - /// arena, this is the emitter we should interrupt when inserting - /// new things into it. - pub emitter: Option>, + types: &'a mut UniqueArena, + constants: &'a Arena, + expressions: &'a mut Arena, + + /// When `self.expressions` refers to a function's local expression + /// arena, this needs to be populated + function_local_data: Option>, +} + +#[derive(Debug)] +struct FunctionLocalData<'a> { + /// Global constant expressions + const_expressions: &'a Arena, + /// Tracks the constness of expressions residing in `ConstantEvaluator.expressions` + expression_constness: &'a mut ExpressionConstnessTracker, + emitter: &'a mut super::Emitter, + block: &'a mut crate::Block, } #[derive(Debug)] -pub struct ConstantEvaluatorEmitter<'a> { - pub emitter: &'a mut super::Emitter, - pub block: &'a mut crate::Block, +pub struct ExpressionConstnessTracker { + inner: bit_set::BitSet, +} + +impl ExpressionConstnessTracker { + pub fn new() -> Self { + Self { + inner: bit_set::BitSet::new(), + } + } + + fn insert(&mut self, value: Handle) { + self.inner.insert(value.index()); + } + + pub fn is_const(&self, value: Handle) -> bool { + self.inner.contains(value.index()) + } + + pub fn from_arena(arena: &Arena) -> Self { + let mut tracker = Self::new(); + for (handle, expr) in arena.iter() { + let insert = match *expr { + crate::Expression::Literal(_) + | crate::Expression::ZeroValue(_) + | crate::Expression::Constant(_) => true, + crate::Expression::Compose { ref components, .. } => { + components.iter().all(|h| tracker.is_const(*h)) + } + crate::Expression::Splat { value, .. } => tracker.is_const(value), + _ => false, + }; + if insert { + tracker.insert(handle); + } + } + tracker + } } #[derive(Clone, Debug, PartialEq, thiserror::Error)] @@ -94,44 +137,68 @@ pub enum ConstantEvaluatorError { // Math // As -// TODO(teoxoy): consider accumulating this metadata instead of recursing through subexpressions -impl Arena { - pub fn is_const(&self, handle: Handle) -> bool { - match self[handle] { - Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => true, - Expression::Compose { ref components, .. } => { - components.iter().all(|h| self.is_const(*h)) +impl<'a> ConstantEvaluator<'a> { + pub fn for_module(module: &'a mut crate::Module) -> Self { + Self { + types: &mut module.types, + constants: &module.constants, + expressions: &mut module.const_expressions, + function_local_data: None, + } + } + + pub fn for_function( + module: &'a mut crate::Module, + expressions: &'a mut Arena, + expression_constness: &'a mut ExpressionConstnessTracker, + emitter: &'a mut super::Emitter, + block: &'a mut crate::Block, + ) -> Self { + Self { + types: &mut module.types, + constants: &module.constants, + expressions, + function_local_data: Some(FunctionLocalData { + const_expressions: &module.const_expressions, + expression_constness, + emitter, + block, + }), + } + } + + fn check(&self, expr: Handle) -> Result<(), ConstantEvaluatorError> { + if let Some(ref function_local_data) = self.function_local_data { + if !function_local_data.expression_constness.is_const(expr) { + log::debug!("check: SubexpressionsAreNotConstant"); + return Err(ConstantEvaluatorError::SubexpressionsAreNotConstant); } - Expression::Splat { ref value, .. } => self.is_const(*value), - _ => false, } + Ok(()) } -} -impl ConstantEvaluator<'_> { fn check_and_get( &mut self, expr: Handle, ) -> Result, ConstantEvaluatorError> { match self.expressions[expr] { - Expression::Literal(_) - | Expression::ZeroValue(_) - | Expression::Compose { .. } - | Expression::Splat { .. } => Ok(expr), Expression::Constant(c) => { // Are we working in a function's expression arena, or the // module's constant expression arena? - if let Some(const_expressions) = self.const_expressions { + if let Some(ref function_local_data) = self.function_local_data { // Deep-copy the constant's value into our arena. - self.copy_from(self.constants[c].init, const_expressions) + self.copy_from( + self.constants[c].init, + function_local_data.const_expressions, + ) } else { // "See through" the constant and use its initializer. Ok(self.constants[c].init) } } _ => { - log::debug!("check_and_get: SubexpressionsAreNotConstant"); - Err(ConstantEvaluatorError::SubexpressionsAreNotConstant) + self.check(expr)?; + Ok(expr) } } } @@ -148,12 +215,12 @@ impl ConstantEvaluator<'_> { } Expression::Compose { ref components, .. } => { for component in components { - self.check_and_get(*component)?; + self.check(*component)?; } Ok(self.register_evaluated_expr(expr.clone(), span)) } Expression::Splat { value, .. } => { - self.check_and_get(value)?; + self.check(value)?; Ok(self.register_evaluated_expr(expr.clone(), span)) } Expression::AccessIndex { base, index } => { @@ -835,20 +902,29 @@ impl ConstantEvaluator<'_> { } fn register_evaluated_expr(&mut self, expr: Expression, span: Span) -> Handle { - if let Some(ref mut emitter) = self.emitter { - let is_running = emitter.emitter.is_running(); + if let Some(FunctionLocalData { + ref mut emitter, + ref mut block, + ref mut expression_constness, + .. + }) = self.function_local_data + { + let is_running = emitter.is_running(); let needs_pre_emit = expr.needs_pre_emit(); if is_running && needs_pre_emit { - emitter - .block - .extend(emitter.emitter.finish(self.expressions)); + block.extend(emitter.finish(self.expressions)); + let h = self.expressions.append(expr, span); + emitter.start(self.expressions); + expression_constness.insert(h); + h + } else { let h = self.expressions.append(expr, span); - emitter.emitter.start(self.expressions); - return h; + expression_constness.insert(h); + h } + } else { + self.expressions.append(expr, span) } - - self.expressions.append(expr, span) } } @@ -1016,8 +1092,7 @@ mod tests { types: &mut types, constants: &constants, expressions: &mut const_expressions, - const_expressions: None, - emitter: None, + function_local_data: None, }; let res1 = solver @@ -1103,8 +1178,7 @@ mod tests { types: &mut types, constants: &constants, expressions: &mut const_expressions, - const_expressions: None, - emitter: None, + function_local_data: None, }; let res = solver @@ -1222,8 +1296,7 @@ mod tests { types: &mut types, constants: &constants, expressions: &mut const_expressions, - const_expressions: None, - emitter: None, + function_local_data: None, }; let root1 = Expression::AccessIndex { base, index: 1 }; diff --git a/src/proc/mod.rs b/src/proc/mod.rs index 2121da01bb..bfa0d160cc 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -10,7 +10,9 @@ mod namer; mod terminator; mod typifier; -pub use constant_evaluator::{ConstantEvaluator, ConstantEvaluatorEmitter, ConstantEvaluatorError}; +pub use constant_evaluator::{ + ConstantEvaluator, ConstantEvaluatorError, ExpressionConstnessTracker, +}; pub use emitter::Emitter; pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; diff --git a/tests/out/spv/debug-symbol-terrain.spvasm b/tests/out/spv/debug-symbol-terrain.spvasm index 3f53036adc..30ecd2f8f6 100644 --- a/tests/out/spv/debug-symbol-terrain.spvasm +++ b/tests/out/spv/debug-symbol-terrain.spvasm @@ -1,19 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 638 +; Bound: 644 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %341 "gen_terrain_compute" %338 -OpEntryPoint Vertex %411 "gen_terrain_vertex" %402 %405 %407 %409 -OpEntryPoint Fragment %459 "gen_terrain_fragment" %449 %451 %454 %457 %458 -OpEntryPoint Vertex %552 "vs_main" %543 %546 %548 %549 %551 -OpEntryPoint Fragment %577 "fs_main" %570 %572 %574 %576 -OpExecutionMode %341 LocalSize 64 1 1 -OpExecutionMode %459 OriginUpperLeft -OpExecutionMode %577 OriginUpperLeft +OpEntryPoint GLCompute %345 "gen_terrain_compute" %342 +OpEntryPoint Vertex %415 "gen_terrain_vertex" %406 %409 %411 %413 +OpEntryPoint Fragment %465 "gen_terrain_fragment" %455 %457 %460 %463 %464 +OpEntryPoint Vertex %558 "vs_main" %549 %552 %554 %555 %557 +OpEntryPoint Fragment %583 "fs_main" %576 %578 %580 %582 +OpExecutionMode %345 LocalSize 64 1 1 +OpExecutionMode %465 OriginUpperLeft +OpExecutionMode %583 OriginUpperLeft %3 = OpString "debug-symbol-terrain.wgsl" OpSource Unknown 0 %3 "// Taken from https://github.com/sotrh/learn-wgpu/blob/11820796f5e1dbce42fb1119f04ddeb4b167d2a0/code/intermediate/tutorial13-terrain/src/terrain.wgsl // ============================ @@ -370,44 +370,44 @@ OpName %209 "x" OpName %211 "v" OpName %213 "a" OpName %214 "i" -OpName %251 "p" -OpName %252 "min_max_height" -OpName %253 "terrain_point" -OpName %264 "p" -OpName %265 "min_max_height" -OpName %266 "terrain_vertex" -OpName %296 "vert_index" -OpName %297 "chunk_size" -OpName %298 "chunk_corner" -OpName %299 "index_to_p" -OpName %315 "p" -OpName %316 "color23" -OpName %338 "gid" -OpName %341 "gen_terrain_compute" -OpName %402 "vindex" -OpName %405 "index" -OpName %407 "position" -OpName %409 "uv" -OpName %411 "gen_terrain_vertex" -OpName %449 "index" -OpName %451 "position" -OpName %454 "uv" -OpName %457 "vert_component" -OpName %458 "index" -OpName %459 "gen_terrain_fragment" -OpName %462 "vert_component" -OpName %463 "index" -OpName %543 "position" -OpName %546 "normal" -OpName %548 "clip_position" -OpName %549 "normal" -OpName %551 "world_pos" -OpName %552 "vs_main" -OpName %570 "clip_position" -OpName %572 "normal" -OpName %574 "world_pos" -OpName %577 "fs_main" -OpName %586 "color" +OpName %255 "p" +OpName %256 "min_max_height" +OpName %257 "terrain_point" +OpName %268 "p" +OpName %269 "min_max_height" +OpName %270 "terrain_vertex" +OpName %300 "vert_index" +OpName %301 "chunk_size" +OpName %302 "chunk_corner" +OpName %303 "index_to_p" +OpName %319 "p" +OpName %320 "color23" +OpName %342 "gid" +OpName %345 "gen_terrain_compute" +OpName %406 "vindex" +OpName %409 "index" +OpName %411 "position" +OpName %413 "uv" +OpName %415 "gen_terrain_vertex" +OpName %455 "index" +OpName %457 "position" +OpName %460 "uv" +OpName %463 "vert_component" +OpName %464 "index" +OpName %465 "gen_terrain_fragment" +OpName %468 "vert_component" +OpName %469 "index" +OpName %549 "position" +OpName %552 "normal" +OpName %554 "clip_position" +OpName %555 "normal" +OpName %557 "world_pos" +OpName %558 "vs_main" +OpName %576 "clip_position" +OpName %578 "normal" +OpName %580 "world_pos" +OpName %583 "fs_main" +OpName %592 "color" OpMemberDecorate %13 0 Offset 0 OpMemberDecorate %13 1 Offset 8 OpMemberDecorate %13 2 Offset 16 @@ -466,27 +466,27 @@ OpDecorate %49 DescriptorSet 2 OpDecorate %49 Binding 2 OpDecorate %50 DescriptorSet 2 OpDecorate %50 Binding 3 -OpDecorate %338 BuiltIn GlobalInvocationId -OpDecorate %402 BuiltIn VertexIndex -OpDecorate %405 Location 0 -OpDecorate %405 Flat -OpDecorate %407 BuiltIn Position -OpDecorate %409 Location 1 -OpDecorate %449 Location 0 -OpDecorate %449 Flat -OpDecorate %451 BuiltIn FragCoord -OpDecorate %454 Location 1 -OpDecorate %457 Location 0 -OpDecorate %458 Location 1 -OpDecorate %543 Location 0 -OpDecorate %546 Location 1 -OpDecorate %548 BuiltIn Position +OpDecorate %342 BuiltIn GlobalInvocationId +OpDecorate %406 BuiltIn VertexIndex +OpDecorate %409 Location 0 +OpDecorate %409 Flat +OpDecorate %411 BuiltIn Position +OpDecorate %413 Location 1 +OpDecorate %455 Location 0 +OpDecorate %455 Flat +OpDecorate %457 BuiltIn FragCoord +OpDecorate %460 Location 1 +OpDecorate %463 Location 0 +OpDecorate %464 Location 1 OpDecorate %549 Location 0 -OpDecorate %551 Location 1 -OpDecorate %570 BuiltIn FragCoord -OpDecorate %572 Location 0 -OpDecorate %574 Location 1 -OpDecorate %576 Location 0 +OpDecorate %552 Location 1 +OpDecorate %554 BuiltIn Position +OpDecorate %555 Location 0 +OpDecorate %557 Location 1 +OpDecorate %576 BuiltIn FragCoord +OpDecorate %578 Location 0 +OpDecorate %580 Location 1 +OpDecorate %582 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 3 @@ -582,80 +582,80 @@ OpDecorate %576 Location 0 %210 = OpConstantNull %6 %212 = OpTypePointer Function %5 %215 = OpTypePointer Function %8 -%254 = OpTypeFunction %4 %6 %6 -%267 = OpTypeFunction %14 %6 %6 -%268 = OpConstant %5 0.1 -%269 = OpConstantComposite %6 %268 %76 -%270 = OpConstantComposite %6 %76 %268 -%271 = OpConstant %5 -0.1 -%272 = OpConstantComposite %6 %271 %76 -%273 = OpConstantComposite %6 %76 %271 -%300 = OpTypeFunction %6 %8 %10 %11 -%317 = OpTypeFunction %4 %6 -%318 = OpConstant %5 23.0 -%319 = OpConstant %5 32.0 -%320 = OpConstantComposite %6 %318 %319 -%321 = OpConstant %5 -43.0 -%322 = OpConstant %5 3.0 -%323 = OpConstantComposite %6 %321 %322 -%339 = OpTypePointer Input %19 -%338 = OpVariable %339 Input -%342 = OpTypeFunction %2 -%343 = OpTypePointer Uniform %13 -%345 = OpConstant %8 6 -%346 = OpConstant %8 2 -%347 = OpConstant %8 3 -%348 = OpConstant %8 4 -%351 = OpTypePointer Uniform %10 -%354 = OpTypePointer Uniform %11 -%358 = OpTypePointer StorageBuffer %15 -%359 = OpTypePointer StorageBuffer %14 -%360 = OpTypePointer Uniform %6 -%367 = OpTypePointer Uniform %8 -%388 = OpTypePointer StorageBuffer %17 -%389 = OpTypePointer StorageBuffer %8 -%403 = OpTypePointer Input %8 -%402 = OpVariable %403 Input -%406 = OpTypePointer Output %8 -%405 = OpVariable %406 Output -%408 = OpTypePointer Output %7 -%407 = OpVariable %408 Output -%410 = OpTypePointer Output %6 +%258 = OpTypeFunction %4 %6 %6 +%271 = OpTypeFunction %14 %6 %6 +%272 = OpConstant %5 0.1 +%273 = OpConstantComposite %6 %272 %76 +%274 = OpConstantComposite %6 %76 %272 +%275 = OpConstant %5 -0.1 +%276 = OpConstantComposite %6 %275 %76 +%277 = OpConstantComposite %6 %76 %275 +%304 = OpTypeFunction %6 %8 %10 %11 +%321 = OpTypeFunction %4 %6 +%322 = OpConstant %5 23.0 +%323 = OpConstant %5 32.0 +%324 = OpConstantComposite %6 %322 %323 +%325 = OpConstant %5 -43.0 +%326 = OpConstant %5 3.0 +%327 = OpConstantComposite %6 %325 %326 +%343 = OpTypePointer Input %19 +%342 = OpVariable %343 Input +%346 = OpTypeFunction %2 +%347 = OpTypePointer Uniform %13 +%349 = OpConstant %8 6 +%350 = OpConstant %8 2 +%351 = OpConstant %8 3 +%352 = OpConstant %8 4 +%355 = OpTypePointer Uniform %10 +%358 = OpTypePointer Uniform %11 +%362 = OpTypePointer StorageBuffer %15 +%363 = OpTypePointer StorageBuffer %14 +%364 = OpTypePointer Uniform %6 +%371 = OpTypePointer Uniform %8 +%392 = OpTypePointer StorageBuffer %17 +%393 = OpTypePointer StorageBuffer %8 +%407 = OpTypePointer Input %8 +%406 = OpVariable %407 Input +%410 = OpTypePointer Output %8 %409 = OpVariable %410 Output -%412 = OpTypePointer Uniform %20 -%414 = OpConstant %5 -1.0 -%415 = OpConstantComposite %6 %414 %414 -%429 = OpTypePointer Uniform %8 -%449 = OpVariable %403 Input -%452 = OpTypePointer Input %7 -%451 = OpVariable %452 Input -%455 = OpTypePointer Input %6 -%454 = OpVariable %455 Input -%457 = OpVariable %406 Output -%458 = OpVariable %406 Output -%461 = OpConstant %5 6.0 -%544 = OpTypePointer Input %4 -%543 = OpVariable %544 Input -%546 = OpVariable %544 Input -%548 = OpVariable %408 Output -%550 = OpTypePointer Output %4 -%549 = OpVariable %550 Output -%551 = OpVariable %550 Output -%553 = OpTypePointer Uniform %24 -%556 = OpTypePointer Uniform %23 -%570 = OpVariable %452 Input -%572 = OpVariable %544 Input -%574 = OpVariable %544 Input -%576 = OpVariable %408 Output -%579 = OpTypePointer Uniform %25 -%581 = OpConstantComposite %4 %268 %268 %268 -%582 = OpConstant %5 0.7 -%583 = OpConstantComposite %4 %81 %268 %582 -%584 = OpConstant %5 0.2 -%585 = OpConstantComposite %4 %584 %584 %584 -%587 = OpConstantNull %4 -%602 = OpTypePointer Uniform %4 -%611 = OpTypePointer Uniform %7 +%412 = OpTypePointer Output %7 +%411 = OpVariable %412 Output +%414 = OpTypePointer Output %6 +%413 = OpVariable %414 Output +%416 = OpTypePointer Uniform %20 +%418 = OpConstant %5 -1.0 +%419 = OpConstantComposite %6 %418 %418 +%434 = OpTypePointer Uniform %8 +%455 = OpVariable %407 Input +%458 = OpTypePointer Input %7 +%457 = OpVariable %458 Input +%461 = OpTypePointer Input %6 +%460 = OpVariable %461 Input +%463 = OpVariable %410 Output +%464 = OpVariable %410 Output +%467 = OpConstant %5 6.0 +%550 = OpTypePointer Input %4 +%549 = OpVariable %550 Input +%552 = OpVariable %550 Input +%554 = OpVariable %412 Output +%556 = OpTypePointer Output %4 +%555 = OpVariable %556 Output +%557 = OpVariable %556 Output +%559 = OpTypePointer Uniform %24 +%562 = OpTypePointer Uniform %23 +%576 = OpVariable %458 Input +%578 = OpVariable %550 Input +%580 = OpVariable %550 Input +%582 = OpVariable %412 Output +%585 = OpTypePointer Uniform %25 +%587 = OpConstantComposite %4 %272 %272 %272 +%588 = OpConstant %5 0.7 +%589 = OpConstantComposite %4 %81 %272 %588 +%590 = OpConstant %5 0.2 +%591 = OpConstantComposite %4 %590 %590 %590 +%593 = OpConstantNull %4 +%608 = OpTypePointer Uniform %4 +%617 = OpTypePointer Uniform %7 %53 = OpFunction %4 None %54 %52 = OpFunctionParameter %4 %51 = OpLabel @@ -843,602 +843,609 @@ OpLine %3 40 14 %219 = OpExtInst %5 %1 Sin %81 %220 = OpCompositeConstruct %6 %218 %219 OpLine %3 41 15 -%221 = OpFNegate %5 %219 -%222 = OpCompositeConstruct %6 %218 %219 -%223 = OpCompositeConstruct %6 %221 %218 -%224 = OpCompositeConstruct %9 %222 %223 -OpBranch %225 -%225 = OpLabel +%221 = OpCompositeExtract %5 %220 0 +%222 = OpCompositeExtract %5 %220 1 +%223 = OpCompositeExtract %5 %220 1 +%224 = OpFNegate %5 %223 +%225 = OpCompositeExtract %5 %220 0 +%226 = OpCompositeConstruct %6 %221 %222 +%227 = OpCompositeConstruct %6 %224 %225 +%228 = OpCompositeConstruct %9 %226 %227 +OpBranch %229 +%229 = OpLabel OpLine %3 43 5 -OpLoopMerge %226 %228 None -OpBranch %227 -%227 = OpLabel +OpLoopMerge %230 %232 None +OpBranch %231 +%231 = OpLabel OpLine %3 43 22 -%229 = OpLoad %8 %214 -%230 = OpULessThan %114 %229 %205 +%233 = OpLoad %8 %214 +%234 = OpULessThan %114 %233 %205 OpLine %3 43 21 -OpSelectionMerge %231 None -OpBranchConditional %230 %231 %232 -%232 = OpLabel -OpBranch %226 -%231 = OpLabel -OpBranch %233 -%233 = OpLabel +OpSelectionMerge %235 None +OpBranchConditional %234 %235 %236 +%236 = OpLabel +OpBranch %230 +%235 = OpLabel +OpBranch %237 +%237 = OpLabel OpLine %3 1 1 -%235 = OpLoad %5 %211 -%236 = OpLoad %5 %213 -%237 = OpLoad %6 %209 +%239 = OpLoad %5 %211 +%240 = OpLoad %5 %213 +%241 = OpLoad %6 %209 OpLine %3 44 21 -%238 = OpFunctionCall %5 %67 %237 +%242 = OpFunctionCall %5 %67 %241 OpLine %3 44 13 -%239 = OpFMul %5 %236 %238 -%240 = OpFAdd %5 %235 %239 +%243 = OpFMul %5 %240 %242 +%244 = OpFAdd %5 %239 %243 OpLine %3 44 9 -OpStore %211 %240 +OpStore %211 %244 OpLine %3 45 13 -%241 = OpLoad %6 %209 -%242 = OpMatrixTimesVector %6 %224 %241 +%245 = OpLoad %6 %209 +%246 = OpMatrixTimesVector %6 %228 %245 OpLine %3 45 13 -%243 = OpVectorTimesScalar %6 %242 %84 -%244 = OpFAdd %6 %243 %208 +%247 = OpVectorTimesScalar %6 %246 %84 +%248 = OpFAdd %6 %247 %208 OpLine %3 45 9 -OpStore %209 %244 +OpStore %209 %248 OpLine %3 1 1 -%245 = OpLoad %5 %213 +%249 = OpLoad %5 %213 OpLine %3 46 13 -%246 = OpFMul %5 %245 %81 +%250 = OpFMul %5 %249 %81 OpLine %3 46 9 -OpStore %213 %246 -OpBranch %234 -%234 = OpLabel -OpBranch %228 -%228 = OpLabel +OpStore %213 %250 +OpBranch %238 +%238 = OpLabel +OpBranch %232 +%232 = OpLabel OpLine %3 1 1 -%247 = OpLoad %8 %214 +%251 = OpLoad %8 %214 OpLine %3 43 43 -%248 = OpIAdd %8 %247 %127 +%252 = OpIAdd %8 %251 %127 OpLine %3 43 39 -OpStore %214 %248 -OpBranch %225 -%226 = OpLabel +OpStore %214 %252 +OpBranch %229 +%230 = OpLabel OpLine %3 1 1 -%249 = OpLoad %5 %211 -OpReturnValue %249 +%253 = OpLoad %5 %211 +OpReturnValue %253 OpFunctionEnd -%253 = OpFunction %4 None %254 -%251 = OpFunctionParameter %6 -%252 = OpFunctionParameter %6 -%250 = OpLabel -OpBranch %255 -%255 = OpLabel +%257 = OpFunction %4 None %258 +%255 = OpFunctionParameter %6 +%256 = OpFunctionParameter %6 +%254 = OpLabel +OpBranch %259 +%259 = OpLabel OpLine %3 77 9 -%256 = OpCompositeExtract %5 %251 0 -%257 = OpCompositeExtract %5 %252 0 -%258 = OpCompositeExtract %5 %252 1 +%260 = OpCompositeExtract %5 %255 0 +%261 = OpCompositeExtract %5 %256 0 +%262 = OpCompositeExtract %5 %256 1 OpLine %3 78 49 -%259 = OpFunctionCall %5 %204 %251 +%263 = OpFunctionCall %5 %204 %255 OpLine %3 76 12 -%260 = OpExtInst %5 %1 FMix %257 %258 %259 -%261 = OpCompositeExtract %5 %251 1 -%262 = OpCompositeConstruct %4 %256 %260 %261 -OpReturnValue %262 +%264 = OpExtInst %5 %1 FMix %261 %262 %263 +%265 = OpCompositeExtract %5 %255 1 +%266 = OpCompositeConstruct %4 %260 %264 %265 +OpReturnValue %266 OpFunctionEnd -%266 = OpFunction %14 None %267 -%264 = OpFunctionParameter %6 -%265 = OpFunctionParameter %6 -%263 = OpLabel -OpBranch %274 -%274 = OpLabel +%270 = OpFunction %14 None %271 +%268 = OpFunctionParameter %6 +%269 = OpFunctionParameter %6 +%267 = OpLabel +OpBranch %278 +%278 = OpLabel OpLine %3 84 13 -%275 = OpFunctionCall %4 %253 %264 %265 +%279 = OpFunctionCall %4 %257 %268 %269 OpLine %3 86 29 -%276 = OpFAdd %6 %264 %269 +%280 = OpFAdd %6 %268 %273 OpLine %3 86 15 -%277 = OpFunctionCall %4 %253 %276 %265 +%281 = OpFunctionCall %4 %257 %280 %269 OpLine %3 86 15 -%278 = OpFSub %4 %277 %275 +%282 = OpFSub %4 %281 %279 OpLine %3 87 29 -%279 = OpFAdd %6 %264 %270 +%283 = OpFAdd %6 %268 %274 OpLine %3 87 15 -%280 = OpFunctionCall %4 %253 %279 %265 +%284 = OpFunctionCall %4 %257 %283 %269 OpLine %3 87 15 -%281 = OpFSub %4 %280 %275 +%285 = OpFSub %4 %284 %279 OpLine %3 88 29 -%282 = OpFAdd %6 %264 %272 +%286 = OpFAdd %6 %268 %276 OpLine %3 88 15 -%283 = OpFunctionCall %4 %253 %282 %265 +%287 = OpFunctionCall %4 %257 %286 %269 OpLine %3 88 15 -%284 = OpFSub %4 %283 %275 +%288 = OpFSub %4 %287 %279 OpLine %3 89 29 -%285 = OpFAdd %6 %264 %273 +%289 = OpFAdd %6 %268 %277 OpLine %3 89 15 -%286 = OpFunctionCall %4 %253 %285 %265 +%290 = OpFunctionCall %4 %257 %289 %269 OpLine %3 89 15 -%287 = OpFSub %4 %286 %275 +%291 = OpFSub %4 %290 %279 OpLine %3 91 14 -%288 = OpExtInst %4 %1 Cross %281 %278 -%289 = OpExtInst %4 %1 Normalize %288 +%292 = OpExtInst %4 %1 Cross %285 %282 +%293 = OpExtInst %4 %1 Normalize %292 OpLine %3 92 14 -%290 = OpExtInst %4 %1 Cross %287 %284 -%291 = OpExtInst %4 %1 Normalize %290 +%294 = OpExtInst %4 %1 Cross %291 %288 +%295 = OpExtInst %4 %1 Normalize %294 OpLine %3 94 14 -%292 = OpFAdd %4 %289 %291 +%296 = OpFAdd %4 %293 %295 OpLine %3 94 13 -%293 = OpVectorTimesScalar %4 %292 %81 +%297 = OpVectorTimesScalar %4 %296 %81 OpLine %3 96 12 -%294 = OpCompositeConstruct %14 %275 %293 -OpReturnValue %294 +%298 = OpCompositeConstruct %14 %279 %297 +OpReturnValue %298 OpFunctionEnd -%299 = OpFunction %6 None %300 -%296 = OpFunctionParameter %8 -%297 = OpFunctionParameter %10 -%298 = OpFunctionParameter %11 -%295 = OpLabel -OpBranch %301 -%301 = OpLabel +%303 = OpFunction %6 None %304 +%300 = OpFunctionParameter %8 +%301 = OpFunctionParameter %10 +%302 = OpFunctionParameter %11 +%299 = OpLabel +OpBranch %305 +%305 = OpLabel OpLine %3 101 9 -%302 = OpConvertUToF %5 %296 -%303 = OpCompositeExtract %8 %297 0 +%306 = OpConvertUToF %5 %300 +%307 = OpCompositeExtract %8 %301 0 OpLine %3 101 9 -%304 = OpIAdd %8 %303 %127 -%305 = OpConvertUToF %5 %304 -%306 = OpFRem %5 %302 %305 -%307 = OpCompositeExtract %8 %297 0 -OpLine %3 100 12 %308 = OpIAdd %8 %307 %127 -%309 = OpUDiv %8 %296 %308 -%310 = OpConvertUToF %5 %309 -%311 = OpCompositeConstruct %6 %306 %310 -%312 = OpConvertSToF %6 %298 -%313 = OpFAdd %6 %311 %312 -OpReturnValue %313 +%309 = OpConvertUToF %5 %308 +%310 = OpFRem %5 %306 %309 +%311 = OpCompositeExtract %8 %301 0 +OpLine %3 100 12 +%312 = OpIAdd %8 %311 %127 +%313 = OpUDiv %8 %300 %312 +%314 = OpConvertUToF %5 %313 +%315 = OpCompositeConstruct %6 %310 %314 +%316 = OpConvertSToF %6 %302 +%317 = OpFAdd %6 %315 %316 +OpReturnValue %317 OpFunctionEnd -%316 = OpFunction %4 None %317 -%315 = OpFunctionParameter %6 -%314 = OpLabel -OpBranch %324 -%324 = OpLabel +%320 = OpFunction %4 None %321 +%319 = OpFunctionParameter %6 +%318 = OpLabel +OpBranch %328 +%328 = OpLabel OpLine %3 270 9 -%325 = OpFunctionCall %5 %67 %315 +%329 = OpFunctionCall %5 %67 %319 OpLine %3 270 9 -%326 = OpFMul %5 %325 %81 +%330 = OpFMul %5 %329 %81 OpLine %3 270 9 -%327 = OpFAdd %5 %326 %81 +%331 = OpFAdd %5 %330 %81 OpLine %3 271 17 -%328 = OpFAdd %6 %315 %320 +%332 = OpFAdd %6 %319 %324 OpLine %3 271 9 -%329 = OpFunctionCall %5 %67 %328 +%333 = OpFunctionCall %5 %67 %332 OpLine %3 271 9 -%330 = OpFMul %5 %329 %81 +%334 = OpFMul %5 %333 %81 OpLine %3 271 9 -%331 = OpFAdd %5 %330 %81 +%335 = OpFAdd %5 %334 %81 OpLine %3 272 17 -%332 = OpFAdd %6 %315 %323 +%336 = OpFAdd %6 %319 %327 OpLine %3 272 9 -%333 = OpFunctionCall %5 %67 %332 +%337 = OpFunctionCall %5 %67 %336 OpLine %3 272 9 -%334 = OpFMul %5 %333 %81 +%338 = OpFMul %5 %337 %81 OpLine %3 269 12 -%335 = OpFAdd %5 %334 %81 -%336 = OpCompositeConstruct %4 %327 %331 %335 -OpReturnValue %336 +%339 = OpFAdd %5 %338 %81 +%340 = OpCompositeConstruct %4 %331 %335 %339 +OpReturnValue %340 OpFunctionEnd -%341 = OpFunction %2 None %342 -%337 = OpLabel -%340 = OpLoad %19 %338 -%344 = OpAccessChain %343 %29 %136 -OpBranch %349 -%349 = OpLabel +%345 = OpFunction %2 None %346 +%341 = OpLabel +%344 = OpLoad %19 %342 +%348 = OpAccessChain %347 %29 %136 +OpBranch %353 +%353 = OpLabel OpLine %3 111 22 -%350 = OpCompositeExtract %8 %340 0 +%354 = OpCompositeExtract %8 %344 0 OpLine %3 113 36 -%352 = OpAccessChain %351 %344 %136 -%353 = OpLoad %10 %352 +%356 = OpAccessChain %355 %348 %136 +%357 = OpLoad %10 %356 OpLine %3 113 59 -%355 = OpAccessChain %354 %344 %127 -%356 = OpLoad %11 %355 +%359 = OpAccessChain %358 %348 %127 +%360 = OpLoad %11 %359 OpLine %3 113 13 -%357 = OpFunctionCall %6 %299 %350 %353 %356 +%361 = OpFunctionCall %6 %303 %354 %357 %360 OpLine %3 115 5 OpLine %3 115 51 -%361 = OpAccessChain %360 %344 %346 -%362 = OpLoad %6 %361 +%365 = OpAccessChain %364 %348 %350 +%366 = OpLoad %6 %365 OpLine %3 115 33 -%363 = OpFunctionCall %14 %266 %357 %362 +%367 = OpFunctionCall %14 %270 %361 %366 OpLine %3 115 5 -%364 = OpAccessChain %359 %32 %136 %350 -OpStore %364 %363 +%368 = OpAccessChain %363 %32 %136 %354 +OpStore %368 %367 OpLine %3 118 23 -%365 = OpCompositeExtract %8 %340 0 +%369 = OpCompositeExtract %8 %344 0 OpLine %3 118 23 -%366 = OpIMul %8 %365 %345 +%370 = OpIMul %8 %369 %349 OpLine %3 120 25 -%368 = OpAccessChain %367 %344 %136 %136 -%369 = OpLoad %8 %368 +%372 = OpAccessChain %371 %348 %136 %136 +%373 = OpLoad %8 %372 OpLine %3 120 25 -%370 = OpAccessChain %367 %344 %136 %127 -%371 = OpLoad %8 %370 -%372 = OpIMul %8 %369 %371 +%374 = OpAccessChain %371 %348 %136 %127 +%375 = OpLoad %8 %374 +%376 = OpIMul %8 %373 %375 OpLine %3 120 9 -%373 = OpIMul %8 %372 %345 -%374 = OpUGreaterThanEqual %114 %366 %373 +%377 = OpIMul %8 %376 %349 +%378 = OpUGreaterThanEqual %114 %370 %377 OpLine %3 120 5 -OpSelectionMerge %375 None -OpBranchConditional %374 %376 %375 -%376 = OpLabel +OpSelectionMerge %379 None +OpBranchConditional %378 %380 %379 +%380 = OpLabel OpReturn -%375 = OpLabel +%379 = OpLabel OpLine %3 122 28 -%377 = OpCompositeExtract %8 %340 0 +%381 = OpCompositeExtract %8 %344 0 OpLine %3 122 15 -%378 = OpAccessChain %367 %344 %136 %136 -%379 = OpLoad %8 %378 -%380 = OpUDiv %8 %377 %379 -%381 = OpIAdd %8 %350 %380 +%382 = OpAccessChain %371 %348 %136 %136 +%383 = OpLoad %8 %382 +%384 = OpUDiv %8 %381 %383 +%385 = OpIAdd %8 %354 %384 OpLine %3 123 15 -%382 = OpIAdd %8 %381 %127 +%386 = OpIAdd %8 %385 %127 OpLine %3 124 15 -%383 = OpAccessChain %367 %344 %136 %136 -%384 = OpLoad %8 %383 -%385 = OpIAdd %8 %381 %384 +%387 = OpAccessChain %371 %348 %136 %136 +%388 = OpLoad %8 %387 +%389 = OpIAdd %8 %385 %388 OpLine %3 124 15 -%386 = OpIAdd %8 %385 %127 +%390 = OpIAdd %8 %389 %127 OpLine %3 125 15 -%387 = OpIAdd %8 %386 %127 +%391 = OpIAdd %8 %390 %127 OpLine %3 127 5 OpLine %3 127 5 -%390 = OpAccessChain %389 %34 %136 %366 -OpStore %390 %381 +%394 = OpAccessChain %393 %34 %136 %370 +OpStore %394 %385 OpLine %3 128 5 OpLine %3 128 5 -%391 = OpIAdd %8 %366 %127 +%395 = OpIAdd %8 %370 %127 OpLine %3 128 5 -%392 = OpAccessChain %389 %34 %136 %391 -OpStore %392 %386 +%396 = OpAccessChain %393 %34 %136 %395 +OpStore %396 %390 OpLine %3 129 5 OpLine %3 129 5 -%393 = OpIAdd %8 %366 %346 +%397 = OpIAdd %8 %370 %350 OpLine %3 129 5 -%394 = OpAccessChain %389 %34 %136 %393 -OpStore %394 %387 +%398 = OpAccessChain %393 %34 %136 %397 +OpStore %398 %391 OpLine %3 130 5 OpLine %3 130 5 -%395 = OpIAdd %8 %366 %347 +%399 = OpIAdd %8 %370 %351 OpLine %3 130 5 -%396 = OpAccessChain %389 %34 %136 %395 -OpStore %396 %381 +%400 = OpAccessChain %393 %34 %136 %399 +OpStore %400 %385 OpLine %3 131 5 OpLine %3 131 5 -%397 = OpIAdd %8 %366 %348 +%401 = OpIAdd %8 %370 %352 OpLine %3 131 5 -%398 = OpAccessChain %389 %34 %136 %397 -OpStore %398 %387 +%402 = OpAccessChain %393 %34 %136 %401 +OpStore %402 %391 OpLine %3 132 5 OpLine %3 132 5 -%399 = OpIAdd %8 %366 %205 +%403 = OpIAdd %8 %370 %205 OpLine %3 132 5 -%400 = OpAccessChain %389 %34 %136 %399 -OpStore %400 %382 +%404 = OpAccessChain %393 %34 %136 %403 +OpStore %404 %386 OpReturn OpFunctionEnd -%411 = OpFunction %2 None %342 -%401 = OpLabel -%404 = OpLoad %8 %402 -%413 = OpAccessChain %412 %36 %136 -OpBranch %416 -%416 = OpLabel +%415 = OpFunction %2 None %346 +%405 = OpLabel +%408 = OpLoad %8 %406 +%417 = OpAccessChain %416 %36 %136 +OpBranch %420 +%420 = OpLabel OpLine %3 161 19 -%417 = OpIAdd %8 %404 %346 +%421 = OpIAdd %8 %408 %350 OpLine %3 161 18 -%418 = OpUDiv %8 %417 %347 +%422 = OpUDiv %8 %421 %351 OpLine %3 161 13 -%419 = OpUMod %8 %418 %346 -%420 = OpConvertUToF %5 %419 +%423 = OpUMod %8 %422 %350 +%424 = OpConvertUToF %5 %423 OpLine %3 162 19 -%421 = OpIAdd %8 %404 %127 +%425 = OpIAdd %8 %408 %127 OpLine %3 162 18 -%422 = OpUDiv %8 %421 %347 +%426 = OpUDiv %8 %425 %351 OpLine %3 162 13 -%423 = OpUMod %8 %422 %346 -%424 = OpConvertUToF %5 %423 +%427 = OpUMod %8 %426 %350 +%428 = OpConvertUToF %5 %427 OpLine %3 163 14 -%425 = OpCompositeConstruct %6 %420 %424 +%429 = OpCompositeConstruct %6 %424 %428 OpLine %3 165 30 -%426 = OpVectorTimesScalar %6 %425 %84 -%427 = OpFAdd %6 %415 %426 +%430 = OpVectorTimesScalar %6 %429 %84 +%431 = OpFAdd %6 %419 %430 OpLine %3 165 20 -%428 = OpCompositeConstruct %7 %427 %76 %56 +%432 = OpCompositeConstruct %7 %431 %76 %56 OpLine %3 168 21 -%430 = OpAccessChain %429 %413 %347 -%431 = OpLoad %8 %430 -%432 = OpConvertUToF %5 %431 -%433 = OpFMul %5 %420 %432 -OpLine %3 168 17 -%434 = OpAccessChain %429 %413 %347 -%435 = OpLoad %8 %434 -%436 = OpConvertUToF %5 %435 -%437 = OpFMul %5 %424 %436 -%438 = OpFAdd %5 %433 %437 -%439 = OpConvertFToU %8 %438 +%433 = OpCompositeExtract %5 %429 0 +OpLine %3 168 21 +%435 = OpAccessChain %434 %417 %351 +%436 = OpLoad %8 %435 +%437 = OpConvertUToF %5 %436 +%438 = OpFMul %5 %433 %437 +%439 = OpCompositeExtract %5 %429 1 OpLine %3 168 17 -%440 = OpAccessChain %429 %413 %348 +%440 = OpAccessChain %434 %417 %351 %441 = OpLoad %8 %440 -%442 = OpIAdd %8 %439 %441 +%442 = OpConvertUToF %5 %441 +%443 = OpFMul %5 %439 %442 +%444 = OpFAdd %5 %438 %443 +%445 = OpConvertFToU %8 %444 +OpLine %3 168 17 +%446 = OpAccessChain %434 %417 %352 +%447 = OpLoad %8 %446 +%448 = OpIAdd %8 %445 %447 OpLine %3 170 12 -%443 = OpCompositeConstruct %21 %442 %428 %425 -%444 = OpCompositeExtract %8 %443 0 -OpStore %405 %444 -%445 = OpCompositeExtract %7 %443 1 -OpStore %407 %445 -%446 = OpCompositeExtract %6 %443 2 -OpStore %409 %446 +%449 = OpCompositeConstruct %21 %448 %432 %429 +%450 = OpCompositeExtract %8 %449 0 +OpStore %409 %450 +%451 = OpCompositeExtract %7 %449 1 +OpStore %411 %451 +%452 = OpCompositeExtract %6 %449 2 +OpStore %413 %452 OpReturn OpFunctionEnd -%459 = OpFunction %2 None %342 -%447 = OpLabel -%462 = OpVariable %212 Function %76 -%463 = OpVariable %215 Function %136 -%450 = OpLoad %8 %449 -%453 = OpLoad %7 %451 -%456 = OpLoad %6 %454 -%448 = OpCompositeConstruct %21 %450 %453 %456 -%460 = OpAccessChain %412 %36 %136 -OpBranch %464 -%464 = OpLabel +%465 = OpFunction %2 None %346 +%453 = OpLabel +%468 = OpVariable %212 Function %76 +%469 = OpVariable %215 Function %136 +%456 = OpLoad %8 %455 +%459 = OpLoad %7 %457 +%462 = OpLoad %6 %460 +%454 = OpCompositeConstruct %21 %456 %459 %462 +%466 = OpAccessChain %416 %36 %136 +OpBranch %470 +%470 = OpLabel OpLine %3 181 17 -%465 = OpCompositeExtract %6 %448 2 -%466 = OpCompositeExtract %5 %465 0 +%471 = OpCompositeExtract %6 %454 2 +%472 = OpCompositeExtract %5 %471 0 OpLine %3 181 17 -%467 = OpAccessChain %429 %460 %347 -%468 = OpLoad %8 %467 -%469 = OpConvertUToF %5 %468 -%470 = OpFMul %5 %466 %469 -%471 = OpCompositeExtract %6 %448 2 -%472 = OpCompositeExtract %5 %471 1 -OpLine %3 181 70 -%473 = OpAccessChain %429 %460 %347 +%473 = OpAccessChain %434 %466 %351 %474 = OpLoad %8 %473 +%475 = OpConvertUToF %5 %474 +%476 = OpFMul %5 %472 %475 +%477 = OpCompositeExtract %6 %454 2 +%478 = OpCompositeExtract %5 %477 1 +OpLine %3 181 70 +%479 = OpAccessChain %434 %466 %351 +%480 = OpLoad %8 %479 OpLine %3 181 13 -%475 = OpAccessChain %429 %460 %347 -%476 = OpLoad %8 %475 -%477 = OpIMul %8 %474 %476 -%478 = OpConvertUToF %5 %477 -%479 = OpFMul %5 %472 %478 -%480 = OpFAdd %5 %470 %479 -%481 = OpConvertFToU %8 %480 +%481 = OpAccessChain %434 %466 %351 +%482 = OpLoad %8 %481 +%483 = OpIMul %8 %480 %482 +%484 = OpConvertUToF %5 %483 +%485 = OpFMul %5 %478 %484 +%486 = OpFAdd %5 %476 %485 +%487 = OpConvertFToU %8 %486 OpLine %3 181 13 -%482 = OpAccessChain %429 %460 %348 -%483 = OpLoad %8 %482 -%484 = OpIAdd %8 %481 %483 +%488 = OpAccessChain %434 %466 %352 +%489 = OpLoad %8 %488 +%490 = OpIAdd %8 %487 %489 OpLine %3 182 32 -%485 = OpConvertUToF %5 %484 +%491 = OpConvertUToF %5 %490 OpLine %3 182 22 -%486 = OpFDiv %5 %485 %461 -%487 = OpExtInst %5 %1 Floor %486 -%488 = OpConvertFToU %8 %487 +%492 = OpFDiv %5 %491 %467 +%493 = OpExtInst %5 %1 Floor %492 +%494 = OpConvertFToU %8 %493 OpLine %3 183 22 -%489 = OpUMod %8 %484 %345 +%495 = OpUMod %8 %490 %349 OpLine %3 185 36 -%490 = OpAccessChain %351 %460 %136 -%491 = OpLoad %10 %490 +%496 = OpAccessChain %355 %466 %136 +%497 = OpLoad %10 %496 OpLine %3 185 57 -%492 = OpAccessChain %354 %460 %127 -%493 = OpLoad %11 %492 +%498 = OpAccessChain %358 %466 %127 +%499 = OpLoad %11 %498 OpLine %3 185 13 -%494 = OpFunctionCall %6 %299 %488 %491 %493 +%500 = OpFunctionCall %6 %303 %494 %497 %499 OpLine %3 186 31 -%495 = OpAccessChain %360 %460 %346 -%496 = OpLoad %6 %495 +%501 = OpAccessChain %364 %466 %350 +%502 = OpLoad %6 %501 OpLine %3 186 13 -%497 = OpFunctionCall %14 %266 %494 %496 +%503 = OpFunctionCall %14 %270 %500 %502 OpLine %3 190 5 -OpSelectionMerge %498 None -OpSwitch %489 %505 0 %499 1 %500 2 %501 3 %502 4 %503 5 %504 -%499 = OpLabel +OpSelectionMerge %504 None +OpSwitch %495 %511 0 %505 1 %506 2 %507 3 %508 4 %509 5 %510 +%505 = OpLabel OpLine %3 191 37 -%506 = OpCompositeExtract %4 %497 0 -%507 = OpCompositeExtract %5 %506 0 +%512 = OpCompositeExtract %4 %503 0 +%513 = OpCompositeExtract %5 %512 0 OpLine %3 191 20 -OpStore %462 %507 -OpBranch %498 -%500 = OpLabel +OpStore %468 %513 +OpBranch %504 +%506 = OpLabel OpLine %3 192 37 -%508 = OpCompositeExtract %4 %497 0 -%509 = OpCompositeExtract %5 %508 1 +%514 = OpCompositeExtract %4 %503 0 +%515 = OpCompositeExtract %5 %514 1 OpLine %3 192 20 -OpStore %462 %509 -OpBranch %498 -%501 = OpLabel +OpStore %468 %515 +OpBranch %504 +%507 = OpLabel OpLine %3 193 37 -%510 = OpCompositeExtract %4 %497 0 -%511 = OpCompositeExtract %5 %510 2 +%516 = OpCompositeExtract %4 %503 0 +%517 = OpCompositeExtract %5 %516 2 OpLine %3 193 20 -OpStore %462 %511 -OpBranch %498 -%502 = OpLabel +OpStore %468 %517 +OpBranch %504 +%508 = OpLabel OpLine %3 194 37 -%512 = OpCompositeExtract %4 %497 1 -%513 = OpCompositeExtract %5 %512 0 +%518 = OpCompositeExtract %4 %503 1 +%519 = OpCompositeExtract %5 %518 0 OpLine %3 194 20 -OpStore %462 %513 -OpBranch %498 -%503 = OpLabel +OpStore %468 %519 +OpBranch %504 +%509 = OpLabel OpLine %3 195 37 -%514 = OpCompositeExtract %4 %497 1 -%515 = OpCompositeExtract %5 %514 1 +%520 = OpCompositeExtract %4 %503 1 +%521 = OpCompositeExtract %5 %520 1 OpLine %3 195 20 -OpStore %462 %515 -OpBranch %498 -%504 = OpLabel +OpStore %468 %521 +OpBranch %504 +%510 = OpLabel OpLine %3 196 37 -%516 = OpCompositeExtract %4 %497 1 -%517 = OpCompositeExtract %5 %516 2 +%522 = OpCompositeExtract %4 %503 1 +%523 = OpCompositeExtract %5 %522 2 OpLine %3 196 20 -OpStore %462 %517 -OpBranch %498 -%505 = OpLabel -OpBranch %498 -%498 = OpLabel +OpStore %468 %523 +OpBranch %504 +%511 = OpLabel +OpBranch %504 +%504 = OpLabel OpLine %3 200 15 -%518 = OpAccessChain %367 %460 %136 %136 -%519 = OpLoad %8 %518 -%520 = OpUDiv %8 %488 %519 -%521 = OpIAdd %8 %488 %520 +%524 = OpAccessChain %371 %466 %136 %136 +%525 = OpLoad %8 %524 +%526 = OpUDiv %8 %494 %525 +%527 = OpIAdd %8 %494 %526 OpLine %3 201 15 -%522 = OpIAdd %8 %521 %127 +%528 = OpIAdd %8 %527 %127 OpLine %3 202 15 -%523 = OpAccessChain %367 %460 %136 %136 -%524 = OpLoad %8 %523 -%525 = OpIAdd %8 %521 %524 +%529 = OpAccessChain %371 %466 %136 %136 +%530 = OpLoad %8 %529 +%531 = OpIAdd %8 %527 %530 OpLine %3 202 15 -%526 = OpIAdd %8 %525 %127 +%532 = OpIAdd %8 %531 %127 OpLine %3 203 15 -%527 = OpIAdd %8 %526 %127 +%533 = OpIAdd %8 %532 %127 OpLine %3 206 5 -OpSelectionMerge %528 None -OpSwitch %489 %533 0 %529 3 %529 2 %530 4 %530 1 %531 5 %532 -%529 = OpLabel +OpSelectionMerge %534 None +OpSwitch %495 %539 0 %535 3 %535 2 %536 4 %536 1 %537 5 %538 +%535 = OpLabel OpLine %3 207 24 -OpStore %463 %521 -OpBranch %528 -%530 = OpLabel +OpStore %469 %527 +OpBranch %534 +%536 = OpLabel OpLine %3 208 24 -OpStore %463 %527 -OpBranch %528 -%531 = OpLabel +OpStore %469 %533 +OpBranch %534 +%537 = OpLabel OpLine %3 209 20 -OpStore %463 %526 -OpBranch %528 -%532 = OpLabel +OpStore %469 %532 +OpBranch %534 +%538 = OpLabel OpLine %3 210 20 -OpStore %463 %522 -OpBranch %528 -%533 = OpLabel -OpBranch %528 -%528 = OpLabel +OpStore %469 %528 +OpBranch %534 +%539 = OpLabel +OpBranch %534 +%534 = OpLabel OpLine %3 213 13 -%534 = OpCompositeExtract %8 %448 0 +%540 = OpCompositeExtract %8 %454 0 OpLine %3 213 5 -OpStore %463 %534 +OpStore %469 %540 OpLine %3 222 27 -%535 = OpLoad %5 %462 -%536 = OpBitcast %8 %535 +%541 = OpLoad %5 %468 +%542 = OpBitcast %8 %541 OpLine %3 223 12 -%537 = OpLoad %8 %463 -%538 = OpCompositeConstruct %22 %536 %537 -%539 = OpCompositeExtract %8 %538 0 -OpStore %457 %539 -%540 = OpCompositeExtract %8 %538 1 -OpStore %458 %540 +%543 = OpLoad %8 %469 +%544 = OpCompositeConstruct %22 %542 %543 +%545 = OpCompositeExtract %8 %544 0 +OpStore %463 %545 +%546 = OpCompositeExtract %8 %544 1 +OpStore %464 %546 OpReturn OpFunctionEnd -%552 = OpFunction %2 None %342 -%541 = OpLabel -%545 = OpLoad %4 %543 -%547 = OpLoad %4 %546 -%542 = OpCompositeConstruct %14 %545 %547 -%554 = OpAccessChain %553 %39 %136 -OpBranch %555 -%555 = OpLabel +%558 = OpFunction %2 None %346 +%547 = OpLabel +%551 = OpLoad %4 %549 +%553 = OpLoad %4 %552 +%548 = OpCompositeConstruct %14 %551 %553 +%560 = OpAccessChain %559 %39 %136 +OpBranch %561 +%561 = OpLabel OpLine %3 254 25 -%557 = OpAccessChain %556 %554 %127 -%558 = OpLoad %23 %557 -%559 = OpCompositeExtract %4 %542 0 +%563 = OpAccessChain %562 %560 %127 +%564 = OpLoad %23 %563 +%565 = OpCompositeExtract %4 %548 0 OpLine %3 254 25 -%560 = OpCompositeConstruct %7 %559 %56 -%561 = OpMatrixTimesVector %7 %558 %560 +%566 = OpCompositeConstruct %7 %565 %56 +%567 = OpMatrixTimesVector %7 %564 %566 OpLine %3 255 18 -%562 = OpCompositeExtract %4 %542 1 +%568 = OpCompositeExtract %4 %548 1 OpLine %3 256 12 -%563 = OpCompositeExtract %4 %542 0 -%564 = OpCompositeConstruct %26 %561 %562 %563 -%565 = OpCompositeExtract %7 %564 0 -OpStore %548 %565 -%566 = OpCompositeExtract %4 %564 1 -OpStore %549 %566 -%567 = OpCompositeExtract %4 %564 2 -OpStore %551 %567 +%569 = OpCompositeExtract %4 %548 0 +%570 = OpCompositeConstruct %26 %567 %568 %569 +%571 = OpCompositeExtract %7 %570 0 +OpStore %554 %571 +%572 = OpCompositeExtract %4 %570 1 +OpStore %555 %572 +%573 = OpCompositeExtract %4 %570 2 +OpStore %557 %573 OpReturn OpFunctionEnd -%577 = OpFunction %2 None %342 -%568 = OpLabel -%586 = OpVariable %99 Function %587 -%571 = OpLoad %7 %570 -%573 = OpLoad %4 %572 -%575 = OpLoad %4 %574 -%569 = OpCompositeConstruct %26 %571 %573 %575 -%578 = OpAccessChain %553 %39 %136 -%580 = OpAccessChain %579 %42 %136 -OpBranch %588 -%588 = OpLabel +%583 = OpFunction %2 None %346 +%574 = OpLabel +%592 = OpVariable %99 Function %593 +%577 = OpLoad %7 %576 +%579 = OpLoad %4 %578 +%581 = OpLoad %4 %580 +%575 = OpCompositeConstruct %26 %577 %579 %581 +%584 = OpAccessChain %559 %39 %136 +%586 = OpAccessChain %585 %42 %136 +OpBranch %594 +%594 = OpLabel OpLine %3 278 28 OpLine %3 278 17 -%589 = OpCompositeExtract %4 %569 2 -%590 = OpExtInst %4 %1 Fract %589 -%591 = OpExtInst %4 %1 SmoothStep %83 %581 %590 +%595 = OpCompositeExtract %4 %575 2 +%596 = OpExtInst %4 %1 Fract %595 +%597 = OpExtInst %4 %1 SmoothStep %83 %587 %596 OpLine %3 278 5 -OpStore %586 %591 +OpStore %592 %597 OpLine %3 279 17 OpLine %3 279 13 -%592 = OpAccessChain %126 %586 %136 -%593 = OpLoad %5 %592 -%594 = OpAccessChain %126 %586 %127 -%595 = OpLoad %5 %594 -%596 = OpFMul %5 %593 %595 -%597 = OpAccessChain %126 %586 %346 -%598 = OpLoad %5 %597 -%599 = OpFMul %5 %596 %598 -%600 = OpCompositeConstruct %4 %599 %599 %599 -%601 = OpExtInst %4 %1 FMix %583 %585 %600 +%598 = OpAccessChain %126 %592 %136 +%599 = OpLoad %5 %598 +%600 = OpAccessChain %126 %592 %127 +%601 = OpLoad %5 %600 +%602 = OpFMul %5 %599 %601 +%603 = OpAccessChain %126 %592 %350 +%604 = OpLoad %5 %603 +%605 = OpFMul %5 %602 %604 +%606 = OpCompositeConstruct %4 %605 %605 %605 +%607 = OpExtInst %4 %1 FMix %589 %591 %606 OpLine %3 279 5 -OpStore %586 %601 +OpStore %592 %607 OpLine %3 282 25 -%603 = OpAccessChain %602 %580 %127 -%604 = OpLoad %4 %603 -%605 = OpVectorTimesScalar %4 %604 %268 +%609 = OpAccessChain %608 %586 %127 +%610 = OpLoad %4 %609 +%611 = OpVectorTimesScalar %4 %610 %272 OpLine %3 284 21 -%606 = OpAccessChain %602 %580 %136 -%607 = OpLoad %4 %606 -%608 = OpCompositeExtract %4 %569 2 -%609 = OpFSub %4 %607 %608 -%610 = OpExtInst %4 %1 Normalize %609 +%612 = OpAccessChain %608 %586 %136 +%613 = OpLoad %4 %612 +%614 = OpCompositeExtract %4 %575 2 +%615 = OpFSub %4 %613 %614 +%616 = OpExtInst %4 %1 Normalize %615 OpLine %3 285 20 -%612 = OpAccessChain %611 %578 %136 -%613 = OpLoad %7 %612 -%614 = OpVectorShuffle %4 %613 %613 0 1 2 -%615 = OpCompositeExtract %4 %569 2 -%616 = OpFSub %4 %614 %615 -%617 = OpExtInst %4 %1 Normalize %616 +%618 = OpAccessChain %617 %584 %136 +%619 = OpLoad %7 %618 +%620 = OpVectorShuffle %4 %619 %619 0 1 2 +%621 = OpCompositeExtract %4 %575 2 +%622 = OpFSub %4 %620 %621 +%623 = OpExtInst %4 %1 Normalize %622 OpLine %3 286 20 -%618 = OpFAdd %4 %617 %610 -%619 = OpExtInst %4 %1 Normalize %618 +%624 = OpFAdd %4 %623 %616 +%625 = OpExtInst %4 %1 Normalize %624 OpLine %3 288 32 -%620 = OpCompositeExtract %4 %569 1 -%621 = OpDot %5 %620 %610 +%626 = OpCompositeExtract %4 %575 1 +%627 = OpDot %5 %626 %616 OpLine %3 288 28 -%622 = OpExtInst %5 %1 FMax %621 %76 +%628 = OpExtInst %5 %1 FMax %627 %76 OpLine %3 289 25 -%623 = OpAccessChain %602 %580 %127 -%624 = OpLoad %4 %623 -%625 = OpVectorTimesScalar %4 %624 %622 +%629 = OpAccessChain %608 %586 %127 +%630 = OpLoad %4 %629 +%631 = OpVectorTimesScalar %4 %630 %628 OpLine %3 291 37 -%626 = OpCompositeExtract %4 %569 1 -%627 = OpDot %5 %626 %619 +%632 = OpCompositeExtract %4 %575 1 +%633 = OpDot %5 %632 %625 OpLine %3 291 33 -%628 = OpExtInst %5 %1 FMax %627 %76 +%634 = OpExtInst %5 %1 FMax %633 %76 OpLine %3 291 29 -%629 = OpExtInst %5 %1 Pow %628 %319 +%635 = OpExtInst %5 %1 Pow %634 %323 OpLine %3 292 26 -%630 = OpAccessChain %602 %580 %127 -%631 = OpLoad %4 %630 -%632 = OpVectorTimesScalar %4 %631 %629 +%636 = OpAccessChain %608 %586 %127 +%637 = OpLoad %4 %636 +%638 = OpVectorTimesScalar %4 %637 %635 OpLine %3 294 18 -%633 = OpFAdd %4 %605 %625 -%634 = OpFAdd %4 %633 %632 -%635 = OpLoad %4 %586 -%636 = OpFMul %4 %634 %635 +%639 = OpFAdd %4 %611 %631 +%640 = OpFAdd %4 %639 %638 +%641 = OpLoad %4 %592 +%642 = OpFMul %4 %640 %641 OpLine %3 296 12 -%637 = OpCompositeConstruct %7 %636 %56 -OpStore %576 %637 +%643 = OpCompositeConstruct %7 %642 %56 +OpStore %582 %643 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/local-var-init-in-loop.comp.wgsl b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl index 750e32e6d3..7675a54cef 100644 --- a/tests/out/wgsl/local-var-init-in-loop.comp.wgsl +++ b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl @@ -1,7 +1,7 @@ fn main_1() { var sum: vec4 = vec4(0.0); var i: i32 = 0; - var a: vec4 = vec4(1.0); + var a: vec4; loop { let _e6 = i; @@ -9,8 +9,7 @@ fn main_1() { break; } { - let _e15 = vec4(1.0); - a = _e15; + a = vec4(1.0); let _e17 = sum; let _e18 = a; sum = (_e17 + _e18); diff --git a/tests/out/wgsl/samplers.frag.wgsl b/tests/out/wgsl/samplers.frag.wgsl index 1009fd5cd8..11565d1f5a 100644 --- a/tests/out/wgsl/samplers.frag.wgsl +++ b/tests/out/wgsl/samplers.frag.wgsl @@ -65,76 +65,92 @@ fn testTex1D(coord: f32) { c = _e71; let _e72 = coord_1; let _e75 = coord_1; - let _e79 = textureSample(tex1D, samp, (_e75 / 6.0)); - c = _e79; - let _e80 = coord_1; - let _e85 = coord_1; - let _e95 = textureSample(tex1D, samp, (vec3(_e85, 0.0, 0.0) / vec3(6.0)).x); - c = _e95; - let _e96 = coord_1; - let _e100 = coord_1; - let _e105 = textureSampleBias(tex1D, samp, (_e100 / 6.0), 2.0); - c = _e105; - let _e106 = coord_1; - let _e112 = coord_1; - let _e123 = textureSampleBias(tex1D, samp, (vec3(_e112, 0.0, 0.0) / vec3(6.0)).x, 2.0); - c = _e123; - let _e124 = coord_1; - let _e129 = coord_1; - let _e135 = textureSampleGrad(tex1D, samp, (_e129 / 6.0), 4.0, 4.0); - c = _e135; - let _e136 = coord_1; - let _e143 = coord_1; - let _e155 = textureSampleGrad(tex1D, samp, (vec3(_e143, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0); - c = _e155; - let _e156 = coord_1; + let _e77 = vec2(_e75, 6.0); + let _e81 = textureSample(tex1D, samp, (_e77.x / _e77.y)); + c = _e81; + let _e82 = coord_1; + let _e87 = coord_1; + let _e91 = vec4(_e87, 0.0, 0.0, 6.0); + let _e97 = textureSample(tex1D, samp, (_e91.xyz / vec3(_e91.w)).x); + c = _e97; + let _e98 = coord_1; + let _e102 = coord_1; + let _e104 = vec2(_e102, 6.0); + let _e109 = textureSampleBias(tex1D, samp, (_e104.x / _e104.y), 2.0); + c = _e109; + let _e110 = coord_1; + let _e116 = coord_1; + let _e120 = vec4(_e116, 0.0, 0.0, 6.0); + let _e127 = textureSampleBias(tex1D, samp, (_e120.xyz / vec3(_e120.w)).x, 2.0); + c = _e127; + let _e128 = coord_1; + let _e133 = coord_1; + let _e135 = vec2(_e133, 6.0); + let _e141 = textureSampleGrad(tex1D, samp, (_e135.x / _e135.y), 4.0, 4.0); + c = _e141; + let _e142 = coord_1; + let _e149 = coord_1; + let _e153 = vec4(_e149, 0.0, 0.0, 6.0); + let _e161 = textureSampleGrad(tex1D, samp, (_e153.xyz / vec3(_e153.w)).x, 4.0, 4.0); + c = _e161; let _e162 = coord_1; - let _e169 = textureSampleGrad(tex1D, samp, (_e162 / 6.0), 4.0, 4.0, 5); - c = _e169; - let _e170 = coord_1; + let _e168 = coord_1; + let _e170 = vec2(_e168, 6.0); + let _e177 = textureSampleGrad(tex1D, samp, (_e170.x / _e170.y), 4.0, 4.0, 5); + c = _e177; let _e178 = coord_1; - let _e191 = textureSampleGrad(tex1D, samp, (vec3(_e178, 0.0, 0.0) / vec3(6.0)).x, 4.0, 4.0, 5); - c = _e191; - let _e192 = coord_1; - let _e196 = coord_1; - let _e201 = textureSampleLevel(tex1D, samp, (_e196 / 6.0), 3.0); - c = _e201; - let _e202 = coord_1; - let _e208 = coord_1; - let _e219 = textureSampleLevel(tex1D, samp, (vec3(_e208, 0.0, 0.0) / vec3(6.0)).x, 3.0); - c = _e219; - let _e220 = coord_1; - let _e225 = coord_1; - let _e231 = textureSampleLevel(tex1D, samp, (_e225 / 6.0), 3.0, 5); - c = _e231; - let _e232 = coord_1; - let _e239 = coord_1; - let _e251 = textureSampleLevel(tex1D, samp, (vec3(_e239, 0.0, 0.0) / vec3(6.0)).x, 3.0, 5); - c = _e251; - let _e252 = coord_1; - let _e256 = coord_1; - let _e261 = textureSample(tex1D, samp, (_e256 / 6.0), 5); - c = _e261; - let _e262 = coord_1; + let _e186 = coord_1; + let _e190 = vec4(_e186, 0.0, 0.0, 6.0); + let _e199 = textureSampleGrad(tex1D, samp, (_e190.xyz / vec3(_e190.w)).x, 4.0, 4.0, 5); + c = _e199; + let _e200 = coord_1; + let _e204 = coord_1; + let _e206 = vec2(_e204, 6.0); + let _e211 = textureSampleLevel(tex1D, samp, (_e206.x / _e206.y), 3.0); + c = _e211; + let _e212 = coord_1; + let _e218 = coord_1; + let _e222 = vec4(_e218, 0.0, 0.0, 6.0); + let _e229 = textureSampleLevel(tex1D, samp, (_e222.xyz / vec3(_e222.w)).x, 3.0); + c = _e229; + let _e230 = coord_1; + let _e235 = coord_1; + let _e237 = vec2(_e235, 6.0); + let _e243 = textureSampleLevel(tex1D, samp, (_e237.x / _e237.y), 3.0, 5); + c = _e243; + let _e244 = coord_1; + let _e251 = coord_1; + let _e255 = vec4(_e251, 0.0, 0.0, 6.0); + let _e263 = textureSampleLevel(tex1D, samp, (_e255.xyz / vec3(_e255.w)).x, 3.0, 5); + c = _e263; + let _e264 = coord_1; let _e268 = coord_1; - let _e279 = textureSample(tex1D, samp, (vec3(_e268, 0.0, 0.0) / vec3(6.0)).x, 5); - c = _e279; - let _e280 = coord_1; - let _e285 = coord_1; - let _e291 = textureSampleBias(tex1D, samp, (_e285 / 6.0), 2.0, 5); - c = _e291; - let _e292 = coord_1; + let _e270 = vec2(_e268, 6.0); + let _e275 = textureSample(tex1D, samp, (_e270.x / _e270.y), 5); + c = _e275; + let _e276 = coord_1; + let _e282 = coord_1; + let _e286 = vec4(_e282, 0.0, 0.0, 6.0); + let _e293 = textureSample(tex1D, samp, (_e286.xyz / vec3(_e286.w)).x, 5); + c = _e293; + let _e294 = coord_1; let _e299 = coord_1; - let _e311 = textureSampleBias(tex1D, samp, (vec3(_e299, 0.0, 0.0) / vec3(6.0)).x, 2.0, 5); - c = _e311; - let _e312 = coord_1; + let _e301 = vec2(_e299, 6.0); + let _e307 = textureSampleBias(tex1D, samp, (_e301.x / _e301.y), 2.0, 5); + c = _e307; + let _e308 = coord_1; let _e315 = coord_1; - let _e318 = textureLoad(tex1D, i32(_e315), 3); - c = _e318; - let _e319 = coord_1; - let _e323 = coord_1; - let _e327 = textureLoad(tex1D, i32(_e323), 3); + let _e319 = vec4(_e315, 0.0, 0.0, 6.0); + let _e327 = textureSampleBias(tex1D, samp, (_e319.xyz / vec3(_e319.w)).x, 2.0, 5); c = _e327; + let _e328 = coord_1; + let _e331 = coord_1; + let _e334 = textureLoad(tex1D, i32(_e331), 3); + c = _e334; + let _e335 = coord_1; + let _e339 = coord_1; + let _e343 = textureLoad(tex1D, i32(_e339), 3); + c = _e343; return; } @@ -218,67 +234,83 @@ fn testTex2D(coord_4: vec2) { c_2 = _e87; let _e88 = coord_5; let _e93 = coord_5; - let _e102 = textureSample(tex2D, samp, (vec2(_e93.x, _e93.y) / vec2(6.0))); + let _e97 = vec3(_e93.x, _e93.y, 6.0); + let _e102 = textureSample(tex2D, samp, (_e97.xy / vec2(_e97.z))); c_2 = _e102; let _e103 = coord_5; let _e109 = coord_5; - let _e120 = textureSample(tex2D, samp, (vec3(_e109.x, _e109.y, 0.0) / vec3(6.0)).xy); + let _e114 = vec4(_e109.x, _e109.y, 0.0, 6.0); + let _e120 = textureSample(tex2D, samp, (_e114.xyz / vec3(_e114.w)).xy); c_2 = _e120; let _e121 = coord_5; let _e127 = coord_5; - let _e137 = textureSampleBias(tex2D, samp, (vec2(_e127.x, _e127.y) / vec2(6.0)), 2.0); + let _e131 = vec3(_e127.x, _e127.y, 6.0); + let _e137 = textureSampleBias(tex2D, samp, (_e131.xy / vec2(_e131.z)), 2.0); c_2 = _e137; let _e138 = coord_5; let _e145 = coord_5; - let _e157 = textureSampleBias(tex2D, samp, (vec3(_e145.x, _e145.y, 0.0) / vec3(6.0)).xy, 2.0); + let _e150 = vec4(_e145.x, _e145.y, 0.0, 6.0); + let _e157 = textureSampleBias(tex2D, samp, (_e150.xyz / vec3(_e150.w)).xy, 2.0); c_2 = _e157; let _e158 = coord_5; let _e167 = coord_5; - let _e180 = textureSampleGrad(tex2D, samp, (vec2(_e167.x, _e167.y) / vec2(6.0)), vec2(4.0), vec2(4.0)); + let _e171 = vec3(_e167.x, _e167.y, 6.0); + let _e180 = textureSampleGrad(tex2D, samp, (_e171.xy / vec2(_e171.z)), vec2(4.0), vec2(4.0)); c_2 = _e180; let _e181 = coord_5; let _e191 = coord_5; - let _e206 = textureSampleGrad(tex2D, samp, (vec3(_e191.x, _e191.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0)); + let _e196 = vec4(_e191.x, _e191.y, 0.0, 6.0); + let _e206 = textureSampleGrad(tex2D, samp, (_e196.xyz / vec3(_e196.w)).xy, vec2(4.0), vec2(4.0)); c_2 = _e206; let _e207 = coord_5; let _e218 = coord_5; - let _e233 = textureSampleGrad(tex2D, samp, (vec2(_e218.x, _e218.y) / vec2(6.0)), vec2(4.0), vec2(4.0), vec2(5)); + let _e222 = vec3(_e218.x, _e218.y, 6.0); + let _e233 = textureSampleGrad(tex2D, samp, (_e222.xy / vec2(_e222.z)), vec2(4.0), vec2(4.0), vec2(5)); c_2 = _e233; let _e234 = coord_5; let _e246 = coord_5; - let _e263 = textureSampleGrad(tex2D, samp, (vec3(_e246.x, _e246.y, 0.0) / vec3(6.0)).xy, vec2(4.0), vec2(4.0), vec2(5)); + let _e251 = vec4(_e246.x, _e246.y, 0.0, 6.0); + let _e263 = textureSampleGrad(tex2D, samp, (_e251.xyz / vec3(_e251.w)).xy, vec2(4.0), vec2(4.0), vec2(5)); c_2 = _e263; let _e264 = coord_5; let _e270 = coord_5; - let _e280 = textureSampleLevel(tex2D, samp, (vec2(_e270.x, _e270.y) / vec2(6.0)), 3.0); + let _e274 = vec3(_e270.x, _e270.y, 6.0); + let _e280 = textureSampleLevel(tex2D, samp, (_e274.xy / vec2(_e274.z)), 3.0); c_2 = _e280; let _e281 = coord_5; let _e288 = coord_5; - let _e300 = textureSampleLevel(tex2D, samp, (vec3(_e288.x, _e288.y, 0.0) / vec3(6.0)).xy, 3.0); + let _e293 = vec4(_e288.x, _e288.y, 0.0, 6.0); + let _e300 = textureSampleLevel(tex2D, samp, (_e293.xyz / vec3(_e293.w)).xy, 3.0); c_2 = _e300; let _e301 = coord_5; let _e309 = coord_5; - let _e321 = textureSampleLevel(tex2D, samp, (vec2(_e309.x, _e309.y) / vec2(6.0)), 3.0, vec2(5)); + let _e313 = vec3(_e309.x, _e309.y, 6.0); + let _e321 = textureSampleLevel(tex2D, samp, (_e313.xy / vec2(_e313.z)), 3.0, vec2(5)); c_2 = _e321; let _e322 = coord_5; let _e331 = coord_5; - let _e345 = textureSampleLevel(tex2D, samp, (vec3(_e331.x, _e331.y, 0.0) / vec3(6.0)).xy, 3.0, vec2(5)); + let _e336 = vec4(_e331.x, _e331.y, 0.0, 6.0); + let _e345 = textureSampleLevel(tex2D, samp, (_e336.xyz / vec3(_e336.w)).xy, 3.0, vec2(5)); c_2 = _e345; let _e346 = coord_5; let _e353 = coord_5; - let _e364 = textureSample(tex2D, samp, (vec2(_e353.x, _e353.y) / vec2(6.0)), vec2(5)); + let _e357 = vec3(_e353.x, _e353.y, 6.0); + let _e364 = textureSample(tex2D, samp, (_e357.xy / vec2(_e357.z)), vec2(5)); c_2 = _e364; let _e365 = coord_5; let _e373 = coord_5; - let _e386 = textureSample(tex2D, samp, (vec3(_e373.x, _e373.y, 0.0) / vec3(6.0)).xy, vec2(5)); + let _e378 = vec4(_e373.x, _e373.y, 0.0, 6.0); + let _e386 = textureSample(tex2D, samp, (_e378.xyz / vec3(_e378.w)).xy, vec2(5)); c_2 = _e386; let _e387 = coord_5; let _e395 = coord_5; - let _e407 = textureSampleBias(tex2D, samp, (vec2(_e395.x, _e395.y) / vec2(6.0)), 2.0, vec2(5)); + let _e399 = vec3(_e395.x, _e395.y, 6.0); + let _e407 = textureSampleBias(tex2D, samp, (_e399.xy / vec2(_e399.z)), 2.0, vec2(5)); c_2 = _e407; let _e408 = coord_5; let _e417 = coord_5; - let _e431 = textureSampleBias(tex2D, samp, (vec3(_e417.x, _e417.y, 0.0) / vec3(6.0)).xy, 2.0, vec2(5)); + let _e422 = vec4(_e417.x, _e417.y, 0.0, 6.0); + let _e431 = textureSampleBias(tex2D, samp, (_e422.xyz / vec3(_e422.w)).xy, 2.0, vec2(5)); c_2 = _e431; let _e432 = coord_5; let _e435 = coord_5; @@ -301,58 +333,70 @@ fn testTex2DShadow(coord_6: vec2) { size2DShadow = vec2(_e20); let _e24 = coord_7; let _e29 = coord_7; - let _e35 = textureSampleCompare(tex2DShadow, sampShadow, vec2(_e29.x, _e29.y), 1.0); - d = _e35; - let _e36 = coord_7; - let _e45 = coord_7; - let _e55 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e45.x, _e45.y), 1.0); - d = _e55; - let _e56 = coord_7; - let _e67 = coord_7; - let _e79 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e67.x, _e67.y), 1.0, vec2(5)); - d = _e79; - let _e80 = coord_7; - let _e86 = coord_7; - let _e93 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e86.x, _e86.y), 1.0); - d = _e93; - let _e94 = coord_7; - let _e102 = coord_7; - let _e111 = textureSampleCompareLevel(tex2DShadow, sampShadow, vec2(_e102.x, _e102.y), 1.0, vec2(5)); - d = _e111; - let _e112 = coord_7; - let _e119 = coord_7; - let _e127 = textureSampleCompare(tex2DShadow, sampShadow, vec2(_e119.x, _e119.y), 1.0, vec2(5)); - d = _e127; - let _e128 = coord_7; + let _e33 = vec3(_e29.x, _e29.y, 1.0); + let _e36 = textureSampleCompare(tex2DShadow, sampShadow, _e33.xy, _e33.z); + d = _e36; + let _e37 = coord_7; + let _e46 = coord_7; + let _e50 = vec3(_e46.x, _e46.y, 1.0); + let _e57 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e50.xy, _e50.z); + d = _e57; + let _e58 = coord_7; + let _e69 = coord_7; + let _e73 = vec3(_e69.x, _e69.y, 1.0); + let _e82 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e73.xy, _e73.z, vec2(5)); + d = _e82; + let _e83 = coord_7; + let _e89 = coord_7; + let _e93 = vec3(_e89.x, _e89.y, 1.0); + let _e97 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e93.xy, _e93.z); + d = _e97; + let _e98 = coord_7; + let _e106 = coord_7; + let _e110 = vec3(_e106.x, _e106.y, 1.0); + let _e116 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e110.xy, _e110.z, vec2(5)); + d = _e116; + let _e117 = coord_7; + let _e124 = coord_7; + let _e128 = vec3(_e124.x, _e124.y, 1.0); + let _e133 = textureSampleCompare(tex2DShadow, sampShadow, _e128.xy, _e128.z, vec2(5)); + d = _e133; let _e134 = coord_7; - let _e143 = (vec3(_e134.x, _e134.y, 1.0) / vec3(6.0)); - let _e146 = textureSampleCompare(tex2DShadow, sampShadow, _e143.xy, _e143.z); - d = _e146; - let _e147 = coord_7; - let _e157 = coord_7; - let _e170 = (vec3(_e157.x, _e157.y, 1.0) / vec3(6.0)); - let _e173 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e170.xy, _e170.z); - d = _e173; - let _e174 = coord_7; - let _e186 = coord_7; - let _e201 = (vec3(_e186.x, _e186.y, 1.0) / vec3(6.0)); - let _e204 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e201.xy, _e201.z, vec2(5)); - d = _e204; - let _e205 = coord_7; - let _e212 = coord_7; - let _e222 = (vec3(_e212.x, _e212.y, 1.0) / vec3(6.0)); - let _e225 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e222.xy, _e222.z); - d = _e225; - let _e226 = coord_7; - let _e235 = coord_7; - let _e247 = (vec3(_e235.x, _e235.y, 1.0) / vec3(6.0)); - let _e250 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e247.xy, _e247.z, vec2(5)); - d = _e250; - let _e251 = coord_7; - let _e259 = coord_7; - let _e270 = (vec3(_e259.x, _e259.y, 1.0) / vec3(6.0)); - let _e273 = textureSampleCompare(tex2DShadow, sampShadow, _e270.xy, _e270.z, vec2(5)); - d = _e273; + let _e140 = coord_7; + let _e145 = vec4(_e140.x, _e140.y, 1.0, 6.0); + let _e149 = (_e145.xyz / vec3(_e145.w)); + let _e152 = textureSampleCompare(tex2DShadow, sampShadow, _e149.xy, _e149.z); + d = _e152; + let _e153 = coord_7; + let _e163 = coord_7; + let _e168 = vec4(_e163.x, _e163.y, 1.0, 6.0); + let _e176 = (_e168.xyz / vec3(_e168.w)); + let _e179 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e176.xy, _e176.z); + d = _e179; + let _e180 = coord_7; + let _e192 = coord_7; + let _e197 = vec4(_e192.x, _e192.y, 1.0, 6.0); + let _e207 = (_e197.xyz / vec3(_e197.w)); + let _e210 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e207.xy, _e207.z, vec2(5)); + d = _e210; + let _e211 = coord_7; + let _e218 = coord_7; + let _e223 = vec4(_e218.x, _e218.y, 1.0, 6.0); + let _e228 = (_e223.xyz / vec3(_e223.w)); + let _e231 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e228.xy, _e228.z); + d = _e231; + let _e232 = coord_7; + let _e241 = coord_7; + let _e246 = vec4(_e241.x, _e241.y, 1.0, 6.0); + let _e253 = (_e246.xyz / vec3(_e246.w)); + let _e256 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e253.xy, _e253.z, vec2(5)); + d = _e256; + let _e257 = coord_7; + let _e265 = coord_7; + let _e270 = vec4(_e265.x, _e265.y, 1.0, 6.0); + let _e276 = (_e270.xyz / vec3(_e270.w)); + let _e279 = textureSampleCompare(tex2DShadow, sampShadow, _e276.xy, _e276.z, vec2(5)); + d = _e279; return; } @@ -413,20 +457,24 @@ fn testTex2DArrayShadow(coord_10: vec3) { size2DArrayShadow = vec3(vec3(_e20.x, _e20.y, _e23)); let _e28 = coord_11; let _e34 = coord_11; - let _e42 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2(_e34.x, _e34.y), i32(_e34.z), 1.0); - d_1 = _e42; - let _e43 = coord_11; - let _e53 = coord_11; - let _e65 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2(_e53.x, _e53.y), i32(_e53.z), 1.0); - d_1 = _e65; - let _e66 = coord_11; - let _e78 = coord_11; - let _e92 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, vec2(_e78.x, _e78.y), i32(_e78.z), 1.0, vec2(5)); - d_1 = _e92; - let _e93 = coord_11; - let _e101 = coord_11; - let _e111 = textureSampleCompare(tex2DArrayShadow, sampShadow, vec2(_e101.x, _e101.y), i32(_e101.z), 1.0, vec2(5)); - d_1 = _e111; + let _e39 = vec4(_e34.x, _e34.y, _e34.z, 1.0); + let _e44 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e39.xy, i32(_e39.z), _e39.w); + d_1 = _e44; + let _e45 = coord_11; + let _e55 = coord_11; + let _e60 = vec4(_e55.x, _e55.y, _e55.z, 1.0); + let _e69 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e60.xy, i32(_e60.z), _e60.w); + d_1 = _e69; + let _e70 = coord_11; + let _e82 = coord_11; + let _e87 = vec4(_e82.x, _e82.y, _e82.z, 1.0); + let _e98 = textureSampleCompareLevel(tex2DArrayShadow, sampShadow, _e87.xy, i32(_e87.z), _e87.w, vec2(5)); + d_1 = _e98; + let _e99 = coord_11; + let _e107 = coord_11; + let _e112 = vec4(_e107.x, _e107.y, _e107.z, 1.0); + let _e119 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e112.xy, i32(_e112.z), _e112.w, vec2(5)); + d_1 = _e119; return; } @@ -463,12 +511,14 @@ fn testTexCubeShadow(coord_14: vec3) { sizeCubeShadow = vec2(_e20); let _e24 = coord_15; let _e30 = coord_15; - let _e37 = textureSampleCompare(texCubeShadow, sampShadow, vec3(_e30.x, _e30.y, _e30.z), 1.0); - d_2 = _e37; - let _e38 = coord_15; - let _e48 = coord_15; - let _e59 = textureSampleCompareLevel(texCubeShadow, sampShadow, vec3(_e48.x, _e48.y, _e48.z), 1.0); - d_2 = _e59; + let _e35 = vec4(_e30.x, _e30.y, _e30.z, 1.0); + let _e38 = textureSampleCompare(texCubeShadow, sampShadow, _e35.xyz, _e35.w); + d_2 = _e38; + let _e39 = coord_15; + let _e49 = coord_15; + let _e54 = vec4(_e49.x, _e49.y, _e49.z, 1.0); + let _e61 = textureSampleCompareLevel(texCubeShadow, sampShadow, _e54.xyz, _e54.w); + d_2 = _e61; return; } @@ -527,35 +577,43 @@ fn testTex3D(coord_20: vec3) { c_6 = _e31; let _e32 = coord_21; let _e38 = coord_21; - let _e48 = textureSample(tex3D, samp, (vec3(_e38.x, _e38.y, _e38.z) / vec3(6.0))); + let _e43 = vec4(_e38.x, _e38.y, _e38.z, 6.0); + let _e48 = textureSample(tex3D, samp, (_e43.xyz / vec3(_e43.w))); c_6 = _e48; let _e49 = coord_21; let _e56 = coord_21; - let _e67 = textureSampleBias(tex3D, samp, (vec3(_e56.x, _e56.y, _e56.z) / vec3(6.0)), 2.0); + let _e61 = vec4(_e56.x, _e56.y, _e56.z, 6.0); + let _e67 = textureSampleBias(tex3D, samp, (_e61.xyz / vec3(_e61.w)), 2.0); c_6 = _e67; let _e68 = coord_21; let _e76 = coord_21; - let _e88 = textureSample(tex3D, samp, (vec3(_e76.x, _e76.y, _e76.z) / vec3(6.0)), vec3(5)); + let _e81 = vec4(_e76.x, _e76.y, _e76.z, 6.0); + let _e88 = textureSample(tex3D, samp, (_e81.xyz / vec3(_e81.w)), vec3(5)); c_6 = _e88; let _e89 = coord_21; let _e98 = coord_21; - let _e111 = textureSampleBias(tex3D, samp, (vec3(_e98.x, _e98.y, _e98.z) / vec3(6.0)), 2.0, vec3(5)); + let _e103 = vec4(_e98.x, _e98.y, _e98.z, 6.0); + let _e111 = textureSampleBias(tex3D, samp, (_e103.xyz / vec3(_e103.w)), 2.0, vec3(5)); c_6 = _e111; let _e112 = coord_21; let _e119 = coord_21; - let _e130 = textureSampleLevel(tex3D, samp, (vec3(_e119.x, _e119.y, _e119.z) / vec3(6.0)), 3.0); + let _e124 = vec4(_e119.x, _e119.y, _e119.z, 6.0); + let _e130 = textureSampleLevel(tex3D, samp, (_e124.xyz / vec3(_e124.w)), 3.0); c_6 = _e130; let _e131 = coord_21; let _e140 = coord_21; - let _e153 = textureSampleLevel(tex3D, samp, (vec3(_e140.x, _e140.y, _e140.z) / vec3(6.0)), 3.0, vec3(5)); + let _e145 = vec4(_e140.x, _e140.y, _e140.z, 6.0); + let _e153 = textureSampleLevel(tex3D, samp, (_e145.xyz / vec3(_e145.w)), 3.0, vec3(5)); c_6 = _e153; let _e154 = coord_21; let _e164 = coord_21; - let _e178 = textureSampleGrad(tex3D, samp, (vec3(_e164.x, _e164.y, _e164.z) / vec3(6.0)), vec3(4.0), vec3(4.0)); + let _e169 = vec4(_e164.x, _e164.y, _e164.z, 6.0); + let _e178 = textureSampleGrad(tex3D, samp, (_e169.xyz / vec3(_e169.w)), vec3(4.0), vec3(4.0)); c_6 = _e178; let _e179 = coord_21; let _e191 = coord_21; - let _e207 = textureSampleGrad(tex3D, samp, (vec3(_e191.x, _e191.y, _e191.z) / vec3(6.0)), vec3(4.0), vec3(4.0), vec3(5)); + let _e196 = vec4(_e191.x, _e191.y, _e191.z, 6.0); + let _e207 = textureSampleGrad(tex3D, samp, (_e196.xyz / vec3(_e196.w)), vec3(4.0), vec3(4.0), vec3(5)); c_6 = _e207; let _e213 = coord_21; let _e218 = textureSampleGrad(tex3D, samp, _e213, vec3(4.0), vec3(4.0)); From 170fd8c01ad3e2f1081a7550a2540c8279bb1e6f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 28 Sep 2023 16:31:59 -0700 Subject: [PATCH 14/37] Add snapshot tests for constant evaluation of splats and composes. --- tests/in/const-exprs.wgsl | 14 +++ tests/out/glsl/const-exprs.main.Compute.glsl | 14 +++ tests/out/hlsl/const-exprs.hlsl | 16 +++ tests/out/msl/const-exprs.msl | 17 +++ tests/out/spv/const-exprs.spvasm | 114 +++++++++++-------- tests/out/wgsl/const-exprs.wgsl | 14 +++ 6 files changed, 143 insertions(+), 46 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index fd1b9c31bf..73d5b4af2f 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -7,6 +7,8 @@ fn main() { index_of_compose(); compose_three_deep(); non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); } // Swizzle the value of nested Compose expressions. @@ -46,3 +48,15 @@ fn non_constant_initializers() { out += vec4(w, x, y, z); } + +// Constant evaluation should be able to see through constants to +// their values. +const FOUR: i32 = 4; + +fn splat_of_constant() { + out = -vec4(FOUR); +} + +fn compose_of_constant() { + out = -vec4(FOUR, FOUR, FOUR, FOUR); +} diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index df029bdaaa..fde4c96156 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -5,6 +5,8 @@ precision highp int; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +const int FOUR = 4; + layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; layout(std430) buffer type_1_block_1Compute { int _group_0_binding_1_cs; }; @@ -49,11 +51,23 @@ void non_constant_initializers() { return; } +void splat_of_constant() { + _group_0_binding_0_cs = -(ivec4(FOUR)); + return; +} + +void compose_of_constant() { + _group_0_binding_0_cs = -(ivec4(FOUR, FOUR, FOUR, FOUR)); + return; +} + void main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); return; } diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index a43f27b02a..6e325a9bf1 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -1,3 +1,5 @@ +static const int FOUR = 4; + RWByteAddressBuffer out_ : register(u0); RWByteAddressBuffer out2_ : register(u1); @@ -45,6 +47,18 @@ void non_constant_initializers() return; } +void splat_of_constant() +{ + out_.Store4(0, asuint(-((FOUR).xxxx))); + return; +} + +void compose_of_constant() +{ + out_.Store4(0, asuint(-(int4(FOUR, FOUR, FOUR, FOUR)))); + return; +} + [numthreads(1, 1, 1)] void main() { @@ -52,5 +66,7 @@ void main() index_of_compose(); compose_three_deep(); non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); return; } diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index a9aa559993..1d9c8e9caf 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -4,6 +4,7 @@ using metal::uint; +constant int FOUR = 4; void swizzle_of_compose( device metal::int4& out @@ -52,6 +53,20 @@ void non_constant_initializers( return; } +void splat_of_constant( + device metal::int4& out +) { + out = -(metal::int4(FOUR)); + return; +} + +void compose_of_constant( + device metal::int4& out +) { + out = -(metal::int4(FOUR, FOUR, FOUR, FOUR)); + return; +} + kernel void main_( device metal::int4& out [[user(fake0)]] , device int& out2_ [[user(fake0)]] @@ -60,5 +75,7 @@ kernel void main_( index_of_compose(out2_); compose_three_deep(out2_); non_constant_initializers(out); + splat_of_constant(out); + compose_of_constant(out); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 50b0373a46..9e0d6c14cf 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,42 +1,42 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 72 +; Bound: 86 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %64 "main" -OpExecutionMode %64 LocalSize 1 1 1 -OpDecorate %6 DescriptorSet 0 -OpDecorate %6 Binding 0 -OpDecorate %7 Block -OpMemberDecorate %7 0 Offset 0 -OpDecorate %9 DescriptorSet 0 -OpDecorate %9 Binding 1 -OpDecorate %10 Block -OpMemberDecorate %10 0 Offset 0 +OpEntryPoint GLCompute %76 "main" +OpExecutionMode %76 LocalSize 1 1 1 +OpDecorate %7 DescriptorSet 0 +OpDecorate %7 Binding 0 +OpDecorate %8 Block +OpMemberDecorate %8 0 Offset 0 +OpDecorate %10 DescriptorSet 0 +OpDecorate %10 Binding 1 +OpDecorate %11 Block +OpMemberDecorate %11 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 %5 = OpTypeVector %4 2 -%7 = OpTypeStruct %3 -%8 = OpTypePointer StorageBuffer %7 -%6 = OpVariable %8 StorageBuffer -%10 = OpTypeStruct %4 -%11 = OpTypePointer StorageBuffer %10 -%9 = OpVariable %11 StorageBuffer -%14 = OpTypeFunction %2 -%15 = OpTypePointer StorageBuffer %3 -%17 = OpTypeInt 32 0 -%16 = OpConstant %17 0 -%19 = OpConstant %4 1 -%20 = OpConstant %4 2 -%21 = OpConstantComposite %5 %19 %20 -%22 = OpConstant %4 3 -%23 = OpConstant %4 4 -%24 = OpConstantComposite %5 %22 %23 -%25 = OpConstantComposite %3 %23 %22 %20 %19 +%6 = OpConstant %4 4 +%8 = OpTypeStruct %3 +%9 = OpTypePointer StorageBuffer %8 +%7 = OpVariable %9 StorageBuffer +%11 = OpTypeStruct %4 +%12 = OpTypePointer StorageBuffer %11 +%10 = OpVariable %12 StorageBuffer +%15 = OpTypeFunction %2 +%16 = OpTypePointer StorageBuffer %3 +%18 = OpTypeInt 32 0 +%17 = OpConstant %18 0 +%20 = OpConstant %4 1 +%21 = OpConstant %4 2 +%22 = OpConstantComposite %5 %20 %21 +%23 = OpConstant %4 3 +%24 = OpConstantComposite %5 %23 %6 +%25 = OpConstantComposite %3 %6 %23 %21 %20 %29 = OpTypePointer StorageBuffer %4 %37 = OpConstant %4 6 %44 = OpConstant %4 30 @@ -44,27 +44,29 @@ OpMemberDecorate %10 0 Offset 0 %47 = OpTypePointer Function %4 %49 = OpConstantNull %4 %51 = OpConstantNull %4 -%13 = OpFunction %2 None %14 -%12 = OpLabel -%18 = OpAccessChain %15 %6 %16 +%66 = OpConstantComposite %3 %6 %6 %6 %6 +%72 = OpConstantComposite %3 %6 %6 %6 %6 +%14 = OpFunction %2 None %15 +%13 = OpLabel +%19 = OpAccessChain %16 %7 %17 OpBranch %26 %26 = OpLabel -OpStore %18 %25 +OpStore %19 %25 OpReturn OpFunctionEnd -%28 = OpFunction %2 None %14 +%28 = OpFunction %2 None %15 %27 = OpLabel -%30 = OpAccessChain %29 %9 %16 +%30 = OpAccessChain %29 %10 %17 OpBranch %31 %31 = OpLabel %32 = OpLoad %4 %30 -%33 = OpIAdd %4 %32 %20 +%33 = OpIAdd %4 %32 %21 OpStore %30 %33 OpReturn OpFunctionEnd -%35 = OpFunction %2 None %14 +%35 = OpFunction %2 None %15 %34 = OpLabel -%36 = OpAccessChain %29 %9 %16 +%36 = OpAccessChain %29 %10 %17 OpBranch %38 %38 = OpLabel %39 = OpLoad %4 %36 @@ -72,13 +74,13 @@ OpBranch %38 OpStore %36 %40 OpReturn OpFunctionEnd -%42 = OpFunction %2 None %14 +%42 = OpFunction %2 None %15 %41 = OpLabel %48 = OpVariable %47 Function %49 %52 = OpVariable %47 Function %45 %46 = OpVariable %47 Function %44 %50 = OpVariable %47 Function %51 -%43 = OpAccessChain %15 %6 %16 +%43 = OpAccessChain %16 %7 %17 OpBranch %53 %53 = OpLabel %54 = OpLoad %4 %46 @@ -95,15 +97,35 @@ OpStore %50 %55 OpStore %43 %62 OpReturn OpFunctionEnd -%64 = OpFunction %2 None %14 +%64 = OpFunction %2 None %15 %63 = OpLabel -%65 = OpAccessChain %15 %6 %16 -%66 = OpAccessChain %29 %9 %16 +%65 = OpAccessChain %16 %7 %17 OpBranch %67 %67 = OpLabel -%68 = OpFunctionCall %2 %13 -%69 = OpFunctionCall %2 %28 -%70 = OpFunctionCall %2 %35 -%71 = OpFunctionCall %2 %42 +%68 = OpSNegate %3 %66 +OpStore %65 %68 +OpReturn +OpFunctionEnd +%70 = OpFunction %2 None %15 +%69 = OpLabel +%71 = OpAccessChain %16 %7 %17 +OpBranch %73 +%73 = OpLabel +%74 = OpSNegate %3 %72 +OpStore %71 %74 +OpReturn +OpFunctionEnd +%76 = OpFunction %2 None %15 +%75 = OpLabel +%77 = OpAccessChain %16 %7 %17 +%78 = OpAccessChain %29 %10 %17 +OpBranch %79 +%79 = OpLabel +%80 = OpFunctionCall %2 %14 +%81 = OpFunctionCall %2 %28 +%82 = OpFunctionCall %2 %35 +%83 = OpFunctionCall %2 %42 +%84 = OpFunctionCall %2 %64 +%85 = OpFunctionCall %2 %70 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index dcef1812b9..47744ede0d 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -1,3 +1,5 @@ +const FOUR: i32 = 4; + @group(0) @binding(0) var out: vec4; @group(0) @binding(1) @@ -43,11 +45,23 @@ fn non_constant_initializers() { return; } +fn splat_of_constant() { + out = -(vec4(FOUR)); + return; +} + +fn compose_of_constant() { + out = -(vec4(FOUR, FOUR, FOUR, FOUR)); + return; +} + @compute @workgroup_size(1, 1, 1) fn main() { swizzle_of_compose(); index_of_compose(); compose_three_deep(); non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); return; } From b151a2abb9b210657a2bbe4406fc4a6a2aec6c8e Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 28 Sep 2023 16:18:41 -0700 Subject: [PATCH 15/37] Let ConstantEvaluator see through Constant exprs in Compose exprs. --- src/proc/constant_evaluator.rs | 94 ++++++++++++++++++-- tests/out/glsl/const-exprs.main.Compute.glsl | 2 +- tests/out/hlsl/const-exprs.hlsl | 2 +- tests/out/msl/const-exprs.msl | 2 +- tests/out/spv/const-exprs.spvasm | 10 +-- tests/out/wgsl/const-exprs.wgsl | 2 +- tests/out/wgsl/module-scope.wgsl | 2 +- 7 files changed, 99 insertions(+), 15 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 9dc021275d..75b5d0c0ae 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -213,11 +213,12 @@ impl<'a> ConstantEvaluator<'a> { Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { Ok(self.register_evaluated_expr(expr.clone(), span)) } - Expression::Compose { ref components, .. } => { - for component in components { - self.check(*component)?; - } - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Compose { ty, ref components } => { + let components = components + .iter() + .map(|component| self.check_and_get(*component)) + .collect::, _>>()?; + Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) } Expression::Splat { value, .. } => { self.check(value)?; @@ -1343,4 +1344,87 @@ mod tests { Expression::Literal(Literal::F32(5.)) ); } + + #[test] + fn compose_of_constants() { + let mut types = UniqueArena::new(); + let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); + + let i32_ty = types.insert( + Type { + name: None, + inner: TypeInner::Scalar { + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let vec2_i32_ty = types.insert( + Type { + name: None, + inner: TypeInner::Vector { + size: VectorSize::Bi, + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let h = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: i32_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(4)), Default::default()), + }, + Default::default(), + ); + + let h_expr = const_expressions.append(Expression::Constant(h), Default::default()); + + let mut solver = ConstantEvaluator { + types: &mut types, + constants: &constants, + expressions: &mut const_expressions, + function_local_data: None, + }; + + let solved_compose = solver + .try_eval_and_append( + &Expression::Compose { + ty: vec2_i32_ty, + components: vec![h_expr, h_expr], + }, + Default::default(), + ) + .unwrap(); + let solved_negate = solver + .try_eval_and_append( + &Expression::Unary { + op: UnaryOperator::Negate, + expr: solved_compose, + }, + Default::default(), + ) + .unwrap(); + + let pass = match const_expressions[solved_negate] { + Expression::Compose { ty, ref components } => { + ty == vec2_i32_ty + && components.iter().all(|&component| { + let component = &const_expressions[component]; + matches!(*component, Expression::Literal(Literal::I32(-4))) + }) + } + _ => false, + }; + if !pass { + panic!("unexpected evaluation result") + } + } } diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index fde4c96156..2d60807e90 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -57,7 +57,7 @@ void splat_of_constant() { } void compose_of_constant() { - _group_0_binding_0_cs = -(ivec4(FOUR, FOUR, FOUR, FOUR)); + _group_0_binding_0_cs = ivec4(-4, -4, -4, -4); return; } diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 6e325a9bf1..572e95e819 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -55,7 +55,7 @@ void splat_of_constant() void compose_of_constant() { - out_.Store4(0, asuint(-(int4(FOUR, FOUR, FOUR, FOUR)))); + out_.Store4(0, asuint(int4(-4, -4, -4, -4))); return; } diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 1d9c8e9caf..e9db1d0fbb 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -63,7 +63,7 @@ void splat_of_constant( void compose_of_constant( device metal::int4& out ) { - out = -(metal::int4(FOUR, FOUR, FOUR, FOUR)); + out = metal::int4(-4, -4, -4, -4); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 9e0d6c14cf..357ecf9196 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -45,7 +45,8 @@ OpMemberDecorate %11 0 Offset 0 %49 = OpConstantNull %4 %51 = OpConstantNull %4 %66 = OpConstantComposite %3 %6 %6 %6 %6 -%72 = OpConstantComposite %3 %6 %6 %6 %6 +%72 = OpConstant %4 -4 +%73 = OpConstantComposite %3 %72 %72 %72 %72 %14 = OpFunction %2 None %15 %13 = OpLabel %19 = OpAccessChain %16 %7 %17 @@ -109,10 +110,9 @@ OpFunctionEnd %70 = OpFunction %2 None %15 %69 = OpLabel %71 = OpAccessChain %16 %7 %17 -OpBranch %73 -%73 = OpLabel -%74 = OpSNegate %3 %72 -OpStore %71 %74 +OpBranch %74 +%74 = OpLabel +OpStore %71 %73 OpReturn OpFunctionEnd %76 = OpFunction %2 None %15 diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 47744ede0d..77d24bbdfa 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -51,7 +51,7 @@ fn splat_of_constant() { } fn compose_of_constant() { - out = -(vec4(FOUR, FOUR, FOUR, FOUR)); + out = vec4(-4, -4, -4, -4); return; } diff --git a/tests/out/wgsl/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index c30052dd1d..b746ff37ca 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -14,7 +14,7 @@ fn statement() { } fn returns() -> S { - return S(Value); + return S(1); } fn call() { From f733ac1908456aad9477e8fe02ad1b0c11eecfba Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 28 Sep 2023 16:19:25 -0700 Subject: [PATCH 16/37] Let ConstantEvaluator see through Constant exprs in Splat exprs. --- src/proc/constant_evaluator.rs | 89 +++++++++++++++++++- tests/out/glsl/const-exprs.main.Compute.glsl | 2 +- tests/out/hlsl/const-exprs.hlsl | 2 +- tests/out/msl/const-exprs.msl | 2 +- tests/out/spv/const-exprs.spvasm | 48 +++++------ tests/out/wgsl/const-exprs.wgsl | 2 +- 6 files changed, 113 insertions(+), 32 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 75b5d0c0ae..e22b1275eb 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -220,9 +220,9 @@ impl<'a> ConstantEvaluator<'a> { .collect::, _>>()?; Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) } - Expression::Splat { value, .. } => { - self.check(value)?; - Ok(self.register_evaluated_expr(expr.clone(), span)) + Expression::Splat { size, value } => { + let value = self.check_and_get(value)?; + Ok(self.register_evaluated_expr(Expression::Splat { size, value }, span)) } Expression::AccessIndex { base, index } => { let base = self.check_and_get(base)?; @@ -1427,4 +1427,87 @@ mod tests { panic!("unexpected evaluation result") } } + + #[test] + fn splat_of_constant() { + let mut types = UniqueArena::new(); + let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); + + let i32_ty = types.insert( + Type { + name: None, + inner: TypeInner::Scalar { + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let vec2_i32_ty = types.insert( + Type { + name: None, + inner: TypeInner::Vector { + size: VectorSize::Bi, + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let h = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: i32_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(4)), Default::default()), + }, + Default::default(), + ); + + let h_expr = const_expressions.append(Expression::Constant(h), Default::default()); + + let mut solver = ConstantEvaluator { + types: &mut types, + constants: &constants, + expressions: &mut const_expressions, + function_local_data: None, + }; + + let solved_compose = solver + .try_eval_and_append( + &Expression::Splat { + size: VectorSize::Bi, + value: h_expr, + }, + Default::default(), + ) + .unwrap(); + let solved_negate = solver + .try_eval_and_append( + &Expression::Unary { + op: UnaryOperator::Negate, + expr: solved_compose, + }, + Default::default(), + ) + .unwrap(); + + let pass = match const_expressions[solved_negate] { + Expression::Compose { ty, ref components } => { + ty == vec2_i32_ty + && components.iter().all(|&component| { + let component = &const_expressions[component]; + matches!(*component, Expression::Literal(Literal::I32(-4))) + }) + } + _ => false, + }; + if !pass { + panic!("unexpected evaluation result") + } + } } diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 2d60807e90..86263b45cf 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -52,7 +52,7 @@ void non_constant_initializers() { } void splat_of_constant() { - _group_0_binding_0_cs = -(ivec4(FOUR)); + _group_0_binding_0_cs = ivec4(-4, -4, -4, -4); return; } diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 572e95e819..87b2a48d72 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -49,7 +49,7 @@ void non_constant_initializers() void splat_of_constant() { - out_.Store4(0, asuint(-((FOUR).xxxx))); + out_.Store4(0, asuint(int4(-4, -4, -4, -4))); return; } diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index e9db1d0fbb..8cf66d6179 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -56,7 +56,7 @@ void non_constant_initializers( void splat_of_constant( device metal::int4& out ) { - out = -(metal::int4(FOUR)); + out = metal::int4(-4, -4, -4, -4); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 357ecf9196..86cb57a918 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,13 +1,13 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 86 +; Bound: 84 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %76 "main" -OpExecutionMode %76 LocalSize 1 1 1 +OpEntryPoint GLCompute %74 "main" +OpExecutionMode %74 LocalSize 1 1 1 OpDecorate %7 DescriptorSet 0 OpDecorate %7 Binding 0 OpDecorate %8 Block @@ -44,9 +44,8 @@ OpMemberDecorate %11 0 Offset 0 %47 = OpTypePointer Function %4 %49 = OpConstantNull %4 %51 = OpConstantNull %4 -%66 = OpConstantComposite %3 %6 %6 %6 %6 -%72 = OpConstant %4 -4 -%73 = OpConstantComposite %3 %72 %72 %72 %72 +%66 = OpConstant %4 -4 +%67 = OpConstantComposite %3 %66 %66 %66 %66 %14 = OpFunction %2 None %15 %13 = OpLabel %19 = OpAccessChain %16 %7 %17 @@ -101,31 +100,30 @@ OpFunctionEnd %64 = OpFunction %2 None %15 %63 = OpLabel %65 = OpAccessChain %16 %7 %17 -OpBranch %67 -%67 = OpLabel -%68 = OpSNegate %3 %66 -OpStore %65 %68 +OpBranch %68 +%68 = OpLabel +OpStore %65 %67 OpReturn OpFunctionEnd %70 = OpFunction %2 None %15 %69 = OpLabel %71 = OpAccessChain %16 %7 %17 -OpBranch %74 -%74 = OpLabel -OpStore %71 %73 +OpBranch %72 +%72 = OpLabel +OpStore %71 %67 OpReturn OpFunctionEnd -%76 = OpFunction %2 None %15 -%75 = OpLabel -%77 = OpAccessChain %16 %7 %17 -%78 = OpAccessChain %29 %10 %17 -OpBranch %79 -%79 = OpLabel -%80 = OpFunctionCall %2 %14 -%81 = OpFunctionCall %2 %28 -%82 = OpFunctionCall %2 %35 -%83 = OpFunctionCall %2 %42 -%84 = OpFunctionCall %2 %64 -%85 = OpFunctionCall %2 %70 +%74 = OpFunction %2 None %15 +%73 = OpLabel +%75 = OpAccessChain %16 %7 %17 +%76 = OpAccessChain %29 %10 %17 +OpBranch %77 +%77 = OpLabel +%78 = OpFunctionCall %2 %14 +%79 = OpFunctionCall %2 %28 +%80 = OpFunctionCall %2 %35 +%81 = OpFunctionCall %2 %42 +%82 = OpFunctionCall %2 %64 +%83 = OpFunctionCall %2 %70 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 77d24bbdfa..ded8e5042e 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -46,7 +46,7 @@ fn non_constant_initializers() { } fn splat_of_constant() { - out = -(vec4(FOUR)); + out = vec4(-4, -4, -4, -4); return; } From f72d5c10973082f09a4b242293615eaf0cb574ef Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:55:58 +0200 Subject: [PATCH 17/37] [wgsl-in] use ast spans for errors since they are more accurate --- src/front/wgsl/lower/construction.rs | 16 +--- src/front/wgsl/lower/mod.rs | 119 ++++++++++++--------------- 2 files changed, 56 insertions(+), 79 deletions(-) diff --git a/src/front/wgsl/lower/construction.rs b/src/front/wgsl/lower/construction.rs index 970f63dca7..59d7b17435 100644 --- a/src/front/wgsl/lower/construction.rs +++ b/src/front/wgsl/lower/construction.rs @@ -582,20 +582,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ast::ConstructorType::PartialArray => ConcreteConstructorHandle::PartialArray, ast::ConstructorType::Array { base, size } => { let base = self.resolve_ast_type(base, ctx.as_global())?; - let size = match size { - ast::ArraySize::Constant(expr) => { - let const_expr = self.expression(expr, ctx.as_const())?; - crate::ArraySize::Constant(ctx.as_const().array_length(const_expr)?) - } - ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, - }; + let size = self.array_size(size, ctx.as_global())?; self.layouter.update(ctx.module.to_ctx()).unwrap(); - let ty = ctx.ensure_type_exists(crate::TypeInner::Array { - base, - size, - stride: self.layouter[base].to_stride(), - }); + let stride = self.layouter[base].to_stride(); + + let ty = ctx.ensure_type_exists(crate::TypeInner::Array { base, size, stride }); ConcreteConstructorHandle::Type(ty) } ast::ConstructorType::Type(ty) => ConcreteConstructorHandle::Type(ty), diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index d419f29115..6f06a3232c 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -396,57 +396,30 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } - fn array_length( - &mut self, - const_expr: Handle, - ) -> Result> { - match self.expr_type { - ExpressionContextType::Runtime(_) => { - unreachable!() - } - ExpressionContextType::Constant => { - let span = self.module.const_expressions.get_span(const_expr); - let len = - self.module - .to_ctx() - .eval_expr_to_u32(const_expr) - .map_err(|err| match err { - crate::proc::U32EvalError::NonConst => { - Error::ExpectedConstExprConcreteIntegerScalar(span) - } - crate::proc::U32EvalError::Negative => { - Error::ExpectedPositiveArrayLength(span) - } - })?; - NonZeroU32::new(len).ok_or(Error::ExpectedPositiveArrayLength(span)) - } - } - } - fn gather_component( &mut self, expr: Handle, + component_span: Span, gather_span: Span, ) -> Result> { match self.expr_type { ExpressionContextType::Runtime(ref rctx) => { - let expr_span = rctx.naga_expressions.get_span(expr); let index = self .module .to_ctx() .eval_expr_to_u32_from(expr, rctx.naga_expressions) .map_err(|err| match err { crate::proc::U32EvalError::NonConst => { - Error::ExpectedConstExprConcreteIntegerScalar(expr_span) + Error::ExpectedConstExprConcreteIntegerScalar(component_span) } crate::proc::U32EvalError::Negative => { - Error::ExpectedNonNegative(expr_span) + Error::ExpectedNonNegative(component_span) } })?; crate::SwizzleComponent::XYZW .get(index as usize) .copied() - .ok_or(Error::InvalidGatherComponent(expr_span)) + .ok_or(Error::InvalidGatherComponent(component_span)) } // This means a `gather` operation appeared in a constant expression. // This error refers to the `gather` itself, not its "component" argument. @@ -1258,6 +1231,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(crate::SwitchCase { value: match case.value { ast::SwitchValue::Expr(expr) => { + let span = ctx.ast_expressions.get_span(expr); let expr = self.expression(expr, ctx.as_global().as_const())?; match ctx.module.to_ctx().eval_expr_to_literal(expr) { Some(crate::Literal::I32(value)) if !uint => { @@ -1267,10 +1241,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { crate::SwitchValue::U32(value) } _ => { - return Err(Error::InvalidSwitchValue { - uint, - span: ctx.module.const_expressions.get_span(expr), - }); + return Err(Error::InvalidSwitchValue { uint, span }); } } } @@ -2338,6 +2309,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let (image, image_span, gather) = match fun { Texture::Gather => { let image_or_component = args.next()?; + let image_or_component_span = ctx.ast_expressions.get_span(image_or_component); // Gathers from depth textures don't take an initial `component` argument. let lowered_image_or_component = self.expression(image_or_component, ctx.reborrow())?; @@ -2347,20 +2319,21 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { crate::TypeInner::Image { class: crate::ImageClass::Depth { .. }, .. - } => { - let image_span = ctx.ast_expressions.get_span(image_or_component); - ( - lowered_image_or_component, - image_span, - Some(crate::SwizzleComponent::X), - ) - } + } => ( + lowered_image_or_component, + image_or_component_span, + Some(crate::SwizzleComponent::X), + ), _ => { let (image, image_span) = get_image_and_span(self, &mut args, &mut ctx)?; ( image, image_span, - Some(ctx.gather_component(lowered_image_or_component, span)?), + Some(ctx.gather_component( + lowered_image_or_component, + image_or_component_span, + span, + )?), ) } } @@ -2516,8 +2489,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { expr: Handle>, mut ctx: ExpressionContext<'source, '_, '_>, ) -> Result<(u32, Span), Error<'source>> { + let span = ctx.ast_expressions.get_span(expr); let expr = self.expression(expr, ctx.reborrow())?; - let span = ctx.module.const_expressions.get_span(expr); let value = ctx .module .to_ctx() @@ -2531,6 +2504,34 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok((value, span)) } + fn array_size( + &mut self, + size: ast::ArraySize<'source>, + mut ctx: GlobalContext<'source, '_, '_>, + ) -> Result> { + Ok(match size { + ast::ArraySize::Constant(expr) => { + let span = ctx.ast_expressions.get_span(expr); + let const_expr = self.expression(expr, ctx.as_const())?; + let len = + ctx.module + .to_ctx() + .eval_expr_to_u32(const_expr) + .map_err(|err| match err { + crate::proc::U32EvalError::NonConst => { + Error::ExpectedConstExprConcreteIntegerScalar(span) + } + crate::proc::U32EvalError::Negative => { + Error::ExpectedPositiveArrayLength(span) + } + })?; + let size = NonZeroU32::new(len).ok_or(Error::ExpectedPositiveArrayLength(span))?; + crate::ArraySize::Constant(size) + } + ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, + }) + } + /// Return a Naga `Handle` representing the front-end type `handle`. fn resolve_ast_type( &mut self, @@ -2558,19 +2559,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } ast::Type::Array { base, size } => { let base = self.resolve_ast_type(base, ctx.reborrow())?; + let size = self.array_size(size, ctx.reborrow())?; + self.layouter.update(ctx.module.to_ctx()).unwrap(); + let stride = self.layouter[base].to_stride(); - crate::TypeInner::Array { - base, - size: match size { - ast::ArraySize::Constant(constant) => { - let const_expr = self.expression(constant, ctx.as_const())?; - crate::ArraySize::Constant(ctx.as_const().array_length(const_expr)?) - } - ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, - }, - stride: self.layouter[base].to_stride(), - } + crate::TypeInner::Array { base, size, stride } } ast::Type::Image { dim, @@ -2586,17 +2580,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ast::Type::RayQuery => crate::TypeInner::RayQuery, ast::Type::BindingArray { base, size } => { let base = self.resolve_ast_type(base, ctx.reborrow())?; - - crate::TypeInner::BindingArray { - base, - size: match size { - ast::ArraySize::Constant(constant) => { - let const_expr = self.expression(constant, ctx.as_const())?; - crate::ArraySize::Constant(ctx.as_const().array_length(const_expr)?) - } - ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, - }, - } + let size = self.array_size(size, ctx.reborrow())?; + crate::TypeInner::BindingArray { base, size } } ast::Type::RayDesc => { return Ok(ctx.module.generate_ray_desc_type()); From 4b4b0d3b88dea7b1803a456df3bcbb7b1d1bf06a Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:08:04 +0200 Subject: [PATCH 18/37] avoid having constants pointing to other constants --- src/front/glsl/parser_tests.rs | 17 +- src/proc/constant_evaluator.rs | 5 + tests/in/const-exprs.wgsl | 5 + tests/out/glsl/const-exprs.main.Compute.glsl | 3 + tests/out/hlsl/const-exprs.hlsl | 3 + tests/out/msl/const-exprs.msl | 3 + tests/out/spv/const-exprs.spvasm | 205 ++++++++++--------- tests/out/wgsl/const-exprs.wgsl | 3 + 8 files changed, 130 insertions(+), 114 deletions(-) diff --git a/src/front/glsl/parser_tests.rs b/src/front/glsl/parser_tests.rs index dd5880068c..1813a4ce49 100644 --- a/src/front/glsl/parser_tests.rs +++ b/src/front/glsl/parser_tests.rs @@ -543,33 +543,26 @@ fn constants() { } ); - let (init_a_handle, init_a) = const_expressions.next().unwrap(); - assert_eq!(init_a, &Expression::Literal(crate::Literal::F32(1.0))); + let (init_handle, init) = const_expressions.next().unwrap(); + assert_eq!(init, &Expression::Literal(crate::Literal::F32(1.0))); - let (constant_a_handle, constant_a) = constants.next().unwrap(); assert_eq!( - constant_a, + constants.next().unwrap().1, &Constant { name: Some("a".to_owned()), r#override: crate::Override::None, ty: ty_handle, - init: init_a_handle + init: init_handle } ); - // skip const expr that was inserted for `global` var - const_expressions.next().unwrap(); - - let (init_b_handle, init_b) = const_expressions.next().unwrap(); - assert_eq!(init_b, &Expression::Constant(constant_a_handle)); - assert_eq!( constants.next().unwrap().1, &Constant { name: Some("b".to_owned()), r#override: crate::Override::None, ty: ty_handle, - init: init_b_handle + init: init_handle } ); diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index e22b1275eb..a95684e78b 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -210,6 +210,11 @@ impl<'a> ConstantEvaluator<'a> { ) -> Result, ConstantEvaluatorError> { log::trace!("try_eval_and_append: {:?}", expr); match *expr { + Expression::Constant(c) if self.function_local_data.is_none() => { + // "See through" the constant and use its initializer. + // This is mainly done to avoid having constants pointing to other constants. + Ok(self.constants[c].init) + } Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { Ok(self.register_evaluated_expr(expr.clone(), span)) } diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index 73d5b4af2f..89d8976f5b 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -53,6 +53,11 @@ fn non_constant_initializers() { // their values. const FOUR: i32 = 4; +const FOUR_ALIAS: i32 = FOUR; + +const TEST_CONSTANT_ADDITION: i32 = FOUR + FOUR; +const TEST_CONSTANT_ALIAS_ADDITION: i32 = FOUR_ALIAS + FOUR_ALIAS; + fn splat_of_constant() { out = -vec4(FOUR); } diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 86263b45cf..00714b34f3 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -6,6 +6,9 @@ precision highp int; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; const int FOUR = 4; +const int FOUR_ALIAS = 4; +const int TEST_CONSTANT_ADDITION = 8; +const int TEST_CONSTANT_ALIAS_ADDITION = 8; layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 87b2a48d72..46961977e9 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -1,4 +1,7 @@ static const int FOUR = 4; +static const int FOUR_ALIAS = 4; +static const int TEST_CONSTANT_ADDITION = 8; +static const int TEST_CONSTANT_ALIAS_ADDITION = 8; RWByteAddressBuffer out_ : register(u0); RWByteAddressBuffer out2_ : register(u1); diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 8cf66d6179..135b4ec10b 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -5,6 +5,9 @@ using metal::uint; constant int FOUR = 4; +constant int FOUR_ALIAS = 4; +constant int TEST_CONSTANT_ADDITION = 8; +constant int TEST_CONSTANT_ALIAS_ADDITION = 8; void swizzle_of_compose( device metal::int4& out diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 86cb57a918..0b5c91317c 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,129 +1,130 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 84 +; Bound: 85 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %74 "main" -OpExecutionMode %74 LocalSize 1 1 1 -OpDecorate %7 DescriptorSet 0 -OpDecorate %7 Binding 0 -OpDecorate %8 Block -OpMemberDecorate %8 0 Offset 0 -OpDecorate %10 DescriptorSet 0 -OpDecorate %10 Binding 1 -OpDecorate %11 Block -OpMemberDecorate %11 0 Offset 0 +OpEntryPoint GLCompute %75 "main" +OpExecutionMode %75 LocalSize 1 1 1 +OpDecorate %8 DescriptorSet 0 +OpDecorate %8 Binding 0 +OpDecorate %9 Block +OpMemberDecorate %9 0 Offset 0 +OpDecorate %11 DescriptorSet 0 +OpDecorate %11 Binding 1 +OpDecorate %12 Block +OpMemberDecorate %12 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 %5 = OpTypeVector %4 2 %6 = OpConstant %4 4 -%8 = OpTypeStruct %3 -%9 = OpTypePointer StorageBuffer %8 -%7 = OpVariable %9 StorageBuffer -%11 = OpTypeStruct %4 -%12 = OpTypePointer StorageBuffer %11 -%10 = OpVariable %12 StorageBuffer -%15 = OpTypeFunction %2 -%16 = OpTypePointer StorageBuffer %3 -%18 = OpTypeInt 32 0 -%17 = OpConstant %18 0 -%20 = OpConstant %4 1 -%21 = OpConstant %4 2 -%22 = OpConstantComposite %5 %20 %21 -%23 = OpConstant %4 3 -%24 = OpConstantComposite %5 %23 %6 -%25 = OpConstantComposite %3 %6 %23 %21 %20 -%29 = OpTypePointer StorageBuffer %4 -%37 = OpConstant %4 6 -%44 = OpConstant %4 30 -%45 = OpConstant %4 70 -%47 = OpTypePointer Function %4 -%49 = OpConstantNull %4 -%51 = OpConstantNull %4 -%66 = OpConstant %4 -4 -%67 = OpConstantComposite %3 %66 %66 %66 %66 -%14 = OpFunction %2 None %15 -%13 = OpLabel -%19 = OpAccessChain %16 %7 %17 -OpBranch %26 -%26 = OpLabel -OpStore %19 %25 -OpReturn -OpFunctionEnd -%28 = OpFunction %2 None %15 +%7 = OpConstant %4 8 +%9 = OpTypeStruct %3 +%10 = OpTypePointer StorageBuffer %9 +%8 = OpVariable %10 StorageBuffer +%12 = OpTypeStruct %4 +%13 = OpTypePointer StorageBuffer %12 +%11 = OpVariable %13 StorageBuffer +%16 = OpTypeFunction %2 +%17 = OpTypePointer StorageBuffer %3 +%19 = OpTypeInt 32 0 +%18 = OpConstant %19 0 +%21 = OpConstant %4 1 +%22 = OpConstant %4 2 +%23 = OpConstantComposite %5 %21 %22 +%24 = OpConstant %4 3 +%25 = OpConstantComposite %5 %24 %6 +%26 = OpConstantComposite %3 %6 %24 %22 %21 +%30 = OpTypePointer StorageBuffer %4 +%38 = OpConstant %4 6 +%45 = OpConstant %4 30 +%46 = OpConstant %4 70 +%48 = OpTypePointer Function %4 +%50 = OpConstantNull %4 +%52 = OpConstantNull %4 +%67 = OpConstant %4 -4 +%68 = OpConstantComposite %3 %67 %67 %67 %67 +%15 = OpFunction %2 None %16 +%14 = OpLabel +%20 = OpAccessChain %17 %8 %18 +OpBranch %27 %27 = OpLabel -%30 = OpAccessChain %29 %10 %17 -OpBranch %31 -%31 = OpLabel -%32 = OpLoad %4 %30 -%33 = OpIAdd %4 %32 %21 -OpStore %30 %33 +OpStore %20 %26 OpReturn OpFunctionEnd -%35 = OpFunction %2 None %15 -%34 = OpLabel -%36 = OpAccessChain %29 %10 %17 -OpBranch %38 -%38 = OpLabel -%39 = OpLoad %4 %36 -%40 = OpIAdd %4 %39 %37 -OpStore %36 %40 +%29 = OpFunction %2 None %16 +%28 = OpLabel +%31 = OpAccessChain %30 %11 %18 +OpBranch %32 +%32 = OpLabel +%33 = OpLoad %4 %31 +%34 = OpIAdd %4 %33 %22 +OpStore %31 %34 OpReturn OpFunctionEnd -%42 = OpFunction %2 None %15 -%41 = OpLabel -%48 = OpVariable %47 Function %49 -%52 = OpVariable %47 Function %45 -%46 = OpVariable %47 Function %44 -%50 = OpVariable %47 Function %51 -%43 = OpAccessChain %16 %7 %17 -OpBranch %53 -%53 = OpLabel -%54 = OpLoad %4 %46 -OpStore %48 %54 -%55 = OpLoad %4 %48 -OpStore %50 %55 -%56 = OpLoad %4 %46 -%57 = OpLoad %4 %48 -%58 = OpLoad %4 %50 -%59 = OpLoad %4 %52 -%60 = OpCompositeConstruct %3 %56 %57 %58 %59 -%61 = OpLoad %3 %43 -%62 = OpIAdd %3 %61 %60 -OpStore %43 %62 +%36 = OpFunction %2 None %16 +%35 = OpLabel +%37 = OpAccessChain %30 %11 %18 +OpBranch %39 +%39 = OpLabel +%40 = OpLoad %4 %37 +%41 = OpIAdd %4 %40 %38 +OpStore %37 %41 OpReturn OpFunctionEnd -%64 = OpFunction %2 None %15 -%63 = OpLabel -%65 = OpAccessChain %16 %7 %17 -OpBranch %68 -%68 = OpLabel -OpStore %65 %67 +%43 = OpFunction %2 None %16 +%42 = OpLabel +%49 = OpVariable %48 Function %50 +%53 = OpVariable %48 Function %46 +%47 = OpVariable %48 Function %45 +%51 = OpVariable %48 Function %52 +%44 = OpAccessChain %17 %8 %18 +OpBranch %54 +%54 = OpLabel +%55 = OpLoad %4 %47 +OpStore %49 %55 +%56 = OpLoad %4 %49 +OpStore %51 %56 +%57 = OpLoad %4 %47 +%58 = OpLoad %4 %49 +%59 = OpLoad %4 %51 +%60 = OpLoad %4 %53 +%61 = OpCompositeConstruct %3 %57 %58 %59 %60 +%62 = OpLoad %3 %44 +%63 = OpIAdd %3 %62 %61 +OpStore %44 %63 OpReturn OpFunctionEnd -%70 = OpFunction %2 None %15 +%65 = OpFunction %2 None %16 +%64 = OpLabel +%66 = OpAccessChain %17 %8 %18 +OpBranch %69 %69 = OpLabel -%71 = OpAccessChain %16 %7 %17 -OpBranch %72 -%72 = OpLabel -OpStore %71 %67 +OpStore %66 %68 OpReturn OpFunctionEnd -%74 = OpFunction %2 None %15 +%71 = OpFunction %2 None %16 +%70 = OpLabel +%72 = OpAccessChain %17 %8 %18 +OpBranch %73 %73 = OpLabel -%75 = OpAccessChain %16 %7 %17 -%76 = OpAccessChain %29 %10 %17 -OpBranch %77 -%77 = OpLabel -%78 = OpFunctionCall %2 %14 -%79 = OpFunctionCall %2 %28 -%80 = OpFunctionCall %2 %35 -%81 = OpFunctionCall %2 %42 -%82 = OpFunctionCall %2 %64 -%83 = OpFunctionCall %2 %70 +OpStore %72 %68 +OpReturn +OpFunctionEnd +%75 = OpFunction %2 None %16 +%74 = OpLabel +%76 = OpAccessChain %17 %8 %18 +%77 = OpAccessChain %30 %11 %18 +OpBranch %78 +%78 = OpLabel +%79 = OpFunctionCall %2 %15 +%80 = OpFunctionCall %2 %29 +%81 = OpFunctionCall %2 %36 +%82 = OpFunctionCall %2 %43 +%83 = OpFunctionCall %2 %65 +%84 = OpFunctionCall %2 %71 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index ded8e5042e..57f3ba6a4e 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -1,4 +1,7 @@ const FOUR: i32 = 4; +const FOUR_ALIAS: i32 = 4; +const TEST_CONSTANT_ADDITION: i32 = 8; +const TEST_CONSTANT_ALIAS_ADDITION: i32 = 8; @group(0) @binding(0) var out: vec4; From 9d87d9e5d86f10a1c4acdef0f266e6a0c7bc90d1 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 19:20:50 +0200 Subject: [PATCH 19/37] [wgsl-in] don't treat `let` declarations as `const` declarations --- src/front/wgsl/lower/mod.rs | 22 +- src/proc/constant_evaluator.rs | 5 + src/proc/mod.rs | 2 +- tests/in/const-exprs.wgsl | 8 +- tests/out/analysis/access.info.ron | 2 +- tests/out/glsl/access.foo_vert.Vertex.glsl | 2 +- tests/out/glsl/const-exprs.main.Compute.glsl | 8 +- .../glsl/image.texture_sample.Fragment.glsl | 136 ++--- tests/out/hlsl/access.hlsl | 2 +- tests/out/hlsl/const-exprs.hlsl | 8 +- tests/out/hlsl/image.hlsl | 136 ++--- tests/out/ir/access.compact.ron | 4 +- tests/out/ir/access.ron | 4 +- tests/out/msl/access.msl | 2 +- tests/out/msl/const-exprs.msl | 8 +- tests/out/msl/image.msl | 136 ++--- tests/out/spv/const-exprs.spvasm | 207 ++++--- tests/out/spv/debug-symbol-terrain.spvasm | 382 ++++++------ tests/out/spv/image.spvasm | 561 +++++++++--------- tests/out/wgsl/access.wgsl | 2 +- tests/out/wgsl/const-exprs.wgsl | 8 +- tests/out/wgsl/image.wgsl | 136 ++--- tests/out/wgsl/type-alias.wgsl | 2 +- tests/wgsl-errors.rs | 82 +-- 24 files changed, 930 insertions(+), 935 deletions(-) diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 6f06a3232c..fe0c4f92d6 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -363,11 +363,16 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { fn const_access(&self, handle: Handle) -> Option { match self.expr_type { - ExpressionContextType::Runtime(ref ctx) => self - .module - .to_ctx() - .eval_expr_to_u32_from(handle, ctx.naga_expressions) - .ok(), + ExpressionContextType::Runtime(ref ctx) => { + if !ctx.expression_constness.is_const(handle) { + return None; + } + + self.module + .to_ctx() + .eval_expr_to_u32_from(handle, ctx.naga_expressions) + .ok() + } ExpressionContextType::Constant => self.module.to_ctx().eval_expr_to_u32(handle).ok(), } } @@ -404,6 +409,12 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { ) -> Result> { match self.expr_type { ExpressionContextType::Runtime(ref rctx) => { + if !rctx.expression_constness.is_const(expr) { + return Err(Error::ExpectedConstExprConcreteIntegerScalar( + component_span, + )); + } + let index = self .module .to_ctx() @@ -1076,6 +1087,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { emitter.start(ctx.naga_expressions); let value = self.expression(l.init, ctx.as_expression(block, &mut emitter))?; + ctx.expression_constness.force_non_const(value); let explicit_ty = l.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_global())) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index a95684e78b..6453989b38 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -37,6 +37,11 @@ impl ExpressionConstnessTracker { } } + /// Forces the the expression to not be const + pub fn force_non_const(&mut self, value: Handle) { + self.inner.remove(value.index()); + } + fn insert(&mut self, value: Handle) { self.inner.insert(value.index()); } diff --git a/src/proc/mod.rs b/src/proc/mod.rs index bfa0d160cc..481ea89021 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -612,7 +612,7 @@ impl GlobalCtx<'_> { self.eval_expr_to_literal_from(handle, self.const_expressions) } - pub(crate) fn eval_expr_to_literal_from( + fn eval_expr_to_literal_from( &self, handle: crate::Handle, arena: &crate::Arena, diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index 89d8976f5b..49e95a275f 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -13,16 +13,12 @@ fn main() { // Swizzle the value of nested Compose expressions. fn swizzle_of_compose() { - let a = vec2(1, 2); - let b = vec2(3, 4); - out = vec4(a, b).wzyx; // should assign vec4(4, 3, 2, 1); + out = vec4(vec2(1, 2), vec2(3, 4)).wzyx; // should assign vec4(4, 3, 2, 1); } // Index the value of nested Compose expressions. fn index_of_compose() { - let a = vec2(1, 2); - let b = vec2(3, 4); - out2 += vec4(a, b)[1]; // should assign 2 + out2 += vec4(vec2(1, 2), vec2(3, 4))[1]; // should assign 2 } // Index the value of Compose expressions nested three deep diff --git a/tests/out/analysis/access.info.ron b/tests/out/analysis/access.info.ron index f66a792858..80a2cb1621 100644 --- a/tests/out/analysis/access.info.ron +++ b/tests/out/analysis/access.info.ron @@ -2774,7 +2774,7 @@ non_uniform_result: None, requirements: (""), ), - ref_count: 0, + ref_count: 1, assignable_global: None, ty: Value(Scalar( kind: Uint, diff --git a/tests/out/glsl/access.foo_vert.Vertex.glsl b/tests/out/glsl/access.foo_vert.Vertex.glsl index a79ff3039d..edc7ce1e6b 100644 --- a/tests/out/glsl/access.foo_vert.Vertex.glsl +++ b/tests/out/glsl/access.foo_vert.Vertex.glsl @@ -132,7 +132,7 @@ void main() { test_matrix_within_array_within_struct_accesses(); mat4x3 _matrix = _group_0_binding_0_vs._matrix; uvec2 arr_1[2] = _group_0_binding_0_vs.arr; - float b = _group_0_binding_0_vs._matrix[3][0]; + float b = _group_0_binding_0_vs._matrix[3u][0]; int a_1 = _group_0_binding_0_vs.data[(uint(_group_0_binding_0_vs.data.length()) - 2u)].value; ivec2 c = _group_0_binding_2_vs; float _e33 = read_from_private(foo); diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 00714b34f3..e75ffa6506 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -16,17 +16,13 @@ layout(std430) buffer type_1_block_1Compute { int _group_0_binding_1_cs; }; void swizzle_of_compose() { - ivec2 a = ivec2(1, 2); - ivec2 b = ivec2(3, 4); _group_0_binding_0_cs = ivec4(4, 3, 2, 1); return; } void index_of_compose() { - ivec2 a_1 = ivec2(1, 2); - ivec2 b_1 = ivec2(3, 4); - int _e7 = _group_0_binding_1_cs; - _group_0_binding_1_cs = (_e7 + 2); + int _e2 = _group_0_binding_1_cs; + _group_0_binding_1_cs = (_e2 + 2); return; } diff --git a/tests/out/glsl/image.texture_sample.Fragment.glsl b/tests/out/glsl/image.texture_sample.Fragment.glsl index dc17cedc26..97be5a59d0 100644 --- a/tests/out/glsl/image.texture_sample.Fragment.glsl +++ b/tests/out/glsl/image.texture_sample.Fragment.glsl @@ -18,74 +18,74 @@ void main() { vec4 a = vec4(0.0); vec2 tc = vec2(0.5); vec3 tc3_ = vec3(0.5); - vec4 _e8 = texture(_group_0_binding_0_fs, vec2(0.5, 0.0)); - vec4 _e9 = a; - a = (_e9 + _e8); - vec4 _e13 = texture(_group_0_binding_1_fs, vec2(tc)); - vec4 _e14 = a; - a = (_e14 + _e13); - vec4 _e18 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1)); - vec4 _e19 = a; - a = (_e19 + _e18); - vec4 _e23 = textureLod(_group_0_binding_1_fs, vec2(tc), 2.3); - vec4 _e24 = a; - a = (_e24 + _e23); - vec4 _e28 = textureLodOffset(_group_0_binding_1_fs, vec2(tc), 2.3, ivec2(3, 1)); - vec4 _e29 = a; - a = (_e29 + _e28); - vec4 _e34 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1), 2.0); - vec4 _e35 = a; - a = (_e35 + _e34); - vec4 _e40 = texture(_group_0_binding_4_fs, vec3(tc, 0u)); - vec4 _e41 = a; - a = (_e41 + _e40); - vec4 _e46 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1)); - vec4 _e47 = a; - a = (_e47 + _e46); - vec4 _e52 = textureLod(_group_0_binding_4_fs, vec3(tc, 0u), 2.3); - vec4 _e53 = a; - a = (_e53 + _e52); - vec4 _e58 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0u), 2.3, ivec2(3, 1)); - vec4 _e59 = a; - a = (_e59 + _e58); - vec4 _e65 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1), 2.0); - vec4 _e66 = a; - a = (_e66 + _e65); - vec4 _e71 = texture(_group_0_binding_4_fs, vec3(tc, 0)); - vec4 _e72 = a; - a = (_e72 + _e71); - vec4 _e77 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1)); - vec4 _e78 = a; - a = (_e78 + _e77); - vec4 _e83 = textureLod(_group_0_binding_4_fs, vec3(tc, 0), 2.3); - vec4 _e84 = a; - a = (_e84 + _e83); - vec4 _e89 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0), 2.3, ivec2(3, 1)); - vec4 _e90 = a; - a = (_e90 + _e89); - vec4 _e96 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1), 2.0); - vec4 _e97 = a; - a = (_e97 + _e96); - vec4 _e102 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u)); - vec4 _e103 = a; - a = (_e103 + _e102); - vec4 _e108 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.3); - vec4 _e109 = a; - a = (_e109 + _e108); - vec4 _e115 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.0); - vec4 _e116 = a; - a = (_e116 + _e115); - vec4 _e121 = texture(_group_0_binding_6_fs, vec4(tc3_, 0)); - vec4 _e122 = a; - a = (_e122 + _e121); - vec4 _e127 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0), 2.3); - vec4 _e128 = a; - a = (_e128 + _e127); - vec4 _e134 = texture(_group_0_binding_6_fs, vec4(tc3_, 0), 2.0); - vec4 _e135 = a; - a = (_e135 + _e134); - vec4 _e137 = a; - _fs2p_location0 = _e137; + vec4 _e9 = texture(_group_0_binding_0_fs, vec2(tc.x, 0.0)); + vec4 _e10 = a; + a = (_e10 + _e9); + vec4 _e14 = texture(_group_0_binding_1_fs, vec2(tc)); + vec4 _e15 = a; + a = (_e15 + _e14); + vec4 _e19 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1)); + vec4 _e20 = a; + a = (_e20 + _e19); + vec4 _e24 = textureLod(_group_0_binding_1_fs, vec2(tc), 2.3); + vec4 _e25 = a; + a = (_e25 + _e24); + vec4 _e29 = textureLodOffset(_group_0_binding_1_fs, vec2(tc), 2.3, ivec2(3, 1)); + vec4 _e30 = a; + a = (_e30 + _e29); + vec4 _e35 = textureOffset(_group_0_binding_1_fs, vec2(tc), ivec2(3, 1), 2.0); + vec4 _e36 = a; + a = (_e36 + _e35); + vec4 _e41 = texture(_group_0_binding_4_fs, vec3(tc, 0u)); + vec4 _e42 = a; + a = (_e42 + _e41); + vec4 _e47 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1)); + vec4 _e48 = a; + a = (_e48 + _e47); + vec4 _e53 = textureLod(_group_0_binding_4_fs, vec3(tc, 0u), 2.3); + vec4 _e54 = a; + a = (_e54 + _e53); + vec4 _e59 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0u), 2.3, ivec2(3, 1)); + vec4 _e60 = a; + a = (_e60 + _e59); + vec4 _e66 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0u), ivec2(3, 1), 2.0); + vec4 _e67 = a; + a = (_e67 + _e66); + vec4 _e72 = texture(_group_0_binding_4_fs, vec3(tc, 0)); + vec4 _e73 = a; + a = (_e73 + _e72); + vec4 _e78 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1)); + vec4 _e79 = a; + a = (_e79 + _e78); + vec4 _e84 = textureLod(_group_0_binding_4_fs, vec3(tc, 0), 2.3); + vec4 _e85 = a; + a = (_e85 + _e84); + vec4 _e90 = textureLodOffset(_group_0_binding_4_fs, vec3(tc, 0), 2.3, ivec2(3, 1)); + vec4 _e91 = a; + a = (_e91 + _e90); + vec4 _e97 = textureOffset(_group_0_binding_4_fs, vec3(tc, 0), ivec2(3, 1), 2.0); + vec4 _e98 = a; + a = (_e98 + _e97); + vec4 _e103 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u)); + vec4 _e104 = a; + a = (_e104 + _e103); + vec4 _e109 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.3); + vec4 _e110 = a; + a = (_e110 + _e109); + vec4 _e116 = texture(_group_0_binding_6_fs, vec4(tc3_, 0u), 2.0); + vec4 _e117 = a; + a = (_e117 + _e116); + vec4 _e122 = texture(_group_0_binding_6_fs, vec4(tc3_, 0)); + vec4 _e123 = a; + a = (_e123 + _e122); + vec4 _e128 = textureLod(_group_0_binding_6_fs, vec4(tc3_, 0), 2.3); + vec4 _e129 = a; + a = (_e129 + _e128); + vec4 _e135 = texture(_group_0_binding_6_fs, vec4(tc3_, 0), 2.0); + vec4 _e136 = a; + a = (_e136 + _e135); + vec4 _e138 = a; + _fs2p_location0 = _e138; return; } diff --git a/tests/out/hlsl/access.hlsl b/tests/out/hlsl/access.hlsl index 6f44bdb07f..a4c739d74b 100644 --- a/tests/out/hlsl/access.hlsl +++ b/tests/out/hlsl/access.hlsl @@ -256,7 +256,7 @@ float4 foo_vert(uint vi : SV_VertexID) : SV_Position test_matrix_within_array_within_struct_accesses(); float4x3 _matrix = float4x3(asfloat(bar.Load3(0+0)), asfloat(bar.Load3(0+16)), asfloat(bar.Load3(0+32)), asfloat(bar.Load3(0+48))); uint2 arr_1[2] = Constructarray2_uint2_(asuint(bar.Load2(144+0)), asuint(bar.Load2(144+8))); - float b = asfloat(bar.Load(0+48+0)); + float b = asfloat(bar.Load(0+3u*16+0)); int a_1 = asint(bar.Load(0+(((NagaBufferLengthRW(bar) - 160) / 8) - 2u)*8+160)); int2 c = asint(qux.Load2(0)); const float _e33 = read_from_private(foo); diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 46961977e9..91b82ec56d 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -8,18 +8,14 @@ RWByteAddressBuffer out2_ : register(u1); void swizzle_of_compose() { - int2 a = int2(1, 2); - int2 b = int2(3, 4); out_.Store4(0, asuint(int4(4, 3, 2, 1))); return; } void index_of_compose() { - int2 a_1 = int2(1, 2); - int2 b_1 = int2(3, 4); - int _expr7 = asint(out2_.Load(0)); - out2_.Store(0, asuint((_expr7 + 2))); + int _expr2 = asint(out2_.Load(0)); + out2_.Store(0, asuint((_expr2 + 2))); return; } diff --git a/tests/out/hlsl/image.hlsl b/tests/out/hlsl/image.hlsl index 05825e18cf..7fbd68b105 100644 --- a/tests/out/hlsl/image.hlsl +++ b/tests/out/hlsl/image.hlsl @@ -246,74 +246,74 @@ float4 texture_sample() : SV_Target0 float2 tc = (0.5).xx; float3 tc3_ = (0.5).xxx; - float4 _expr8 = image_1d.Sample(sampler_reg, 0.5); - float4 _expr9 = a; - a = (_expr9 + _expr8); - float4 _expr13 = image_2d.Sample(sampler_reg, tc); - float4 _expr14 = a; - a = (_expr14 + _expr13); - float4 _expr18 = image_2d.Sample(sampler_reg, tc, int2(int2(3, 1))); - float4 _expr19 = a; - a = (_expr19 + _expr18); - float4 _expr23 = image_2d.SampleLevel(sampler_reg, tc, 2.3); - float4 _expr24 = a; - a = (_expr24 + _expr23); - float4 _expr28 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(3, 1))); - float4 _expr29 = a; - a = (_expr29 + _expr28); - float4 _expr34 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(3, 1))); - float4 _expr35 = a; - a = (_expr35 + _expr34); - float4 _expr40 = image_2d_array.Sample(sampler_reg, float3(tc, 0u)); - float4 _expr41 = a; - a = (_expr41 + _expr40); - float4 _expr46 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(int2(3, 1))); - float4 _expr47 = a; - a = (_expr47 + _expr46); - float4 _expr52 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3); - float4 _expr53 = a; - a = (_expr53 + _expr52); - float4 _expr58 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(int2(3, 1))); - float4 _expr59 = a; - a = (_expr59 + _expr58); - float4 _expr65 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(int2(3, 1))); - float4 _expr66 = a; - a = (_expr66 + _expr65); - float4 _expr71 = image_2d_array.Sample(sampler_reg, float3(tc, 0)); - float4 _expr72 = a; - a = (_expr72 + _expr71); - float4 _expr77 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(int2(3, 1))); - float4 _expr78 = a; - a = (_expr78 + _expr77); - float4 _expr83 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3); - float4 _expr84 = a; - a = (_expr84 + _expr83); - float4 _expr89 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(int2(3, 1))); - float4 _expr90 = a; - a = (_expr90 + _expr89); - float4 _expr96 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(int2(3, 1))); - float4 _expr97 = a; - a = (_expr97 + _expr96); - float4 _expr102 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u)); - float4 _expr103 = a; - a = (_expr103 + _expr102); - float4 _expr108 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3); - float4 _expr109 = a; - a = (_expr109 + _expr108); - float4 _expr115 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0); - float4 _expr116 = a; - a = (_expr116 + _expr115); - float4 _expr121 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0)); - float4 _expr122 = a; - a = (_expr122 + _expr121); - float4 _expr127 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3); - float4 _expr128 = a; - a = (_expr128 + _expr127); - float4 _expr134 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0); - float4 _expr135 = a; - a = (_expr135 + _expr134); - float4 _expr137 = a; - return _expr137; + float4 _expr9 = image_1d.Sample(sampler_reg, tc.x); + float4 _expr10 = a; + a = (_expr10 + _expr9); + float4 _expr14 = image_2d.Sample(sampler_reg, tc); + float4 _expr15 = a; + a = (_expr15 + _expr14); + float4 _expr19 = image_2d.Sample(sampler_reg, tc, int2(int2(3, 1))); + float4 _expr20 = a; + a = (_expr20 + _expr19); + float4 _expr24 = image_2d.SampleLevel(sampler_reg, tc, 2.3); + float4 _expr25 = a; + a = (_expr25 + _expr24); + float4 _expr29 = image_2d.SampleLevel(sampler_reg, tc, 2.3, int2(int2(3, 1))); + float4 _expr30 = a; + a = (_expr30 + _expr29); + float4 _expr35 = image_2d.SampleBias(sampler_reg, tc, 2.0, int2(int2(3, 1))); + float4 _expr36 = a; + a = (_expr36 + _expr35); + float4 _expr41 = image_2d_array.Sample(sampler_reg, float3(tc, 0u)); + float4 _expr42 = a; + a = (_expr42 + _expr41); + float4 _expr47 = image_2d_array.Sample(sampler_reg, float3(tc, 0u), int2(int2(3, 1))); + float4 _expr48 = a; + a = (_expr48 + _expr47); + float4 _expr53 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3); + float4 _expr54 = a; + a = (_expr54 + _expr53); + float4 _expr59 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0u), 2.3, int2(int2(3, 1))); + float4 _expr60 = a; + a = (_expr60 + _expr59); + float4 _expr66 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0u), 2.0, int2(int2(3, 1))); + float4 _expr67 = a; + a = (_expr67 + _expr66); + float4 _expr72 = image_2d_array.Sample(sampler_reg, float3(tc, 0)); + float4 _expr73 = a; + a = (_expr73 + _expr72); + float4 _expr78 = image_2d_array.Sample(sampler_reg, float3(tc, 0), int2(int2(3, 1))); + float4 _expr79 = a; + a = (_expr79 + _expr78); + float4 _expr84 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3); + float4 _expr85 = a; + a = (_expr85 + _expr84); + float4 _expr90 = image_2d_array.SampleLevel(sampler_reg, float3(tc, 0), 2.3, int2(int2(3, 1))); + float4 _expr91 = a; + a = (_expr91 + _expr90); + float4 _expr97 = image_2d_array.SampleBias(sampler_reg, float3(tc, 0), 2.0, int2(int2(3, 1))); + float4 _expr98 = a; + a = (_expr98 + _expr97); + float4 _expr103 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0u)); + float4 _expr104 = a; + a = (_expr104 + _expr103); + float4 _expr109 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0u), 2.3); + float4 _expr110 = a; + a = (_expr110 + _expr109); + float4 _expr116 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0u), 2.0); + float4 _expr117 = a; + a = (_expr117 + _expr116); + float4 _expr122 = image_cube_array.Sample(sampler_reg, float4(tc3_, 0)); + float4 _expr123 = a; + a = (_expr123 + _expr122); + float4 _expr128 = image_cube_array.SampleLevel(sampler_reg, float4(tc3_, 0), 2.3); + float4 _expr129 = a; + a = (_expr129 + _expr128); + float4 _expr135 = image_cube_array.SampleBias(sampler_reg, float4(tc3_, 0), 2.0); + float4 _expr136 = a; + a = (_expr136 + _expr135); + float4 _expr138 = a; + return _expr138; } float texture_sample_comparison() : SV_Target0 diff --git a/tests/out/ir/access.compact.ron b/tests/out/ir/access.compact.ron index 1c0220141d..f24f830af8 100644 --- a/tests/out/ir/access.compact.ron +++ b/tests/out/ir/access.compact.ron @@ -1697,9 +1697,9 @@ base: 13, index: 0, ), - AccessIndex( + Access( base: 14, - index: 3, + index: 12, ), AccessIndex( base: 15, diff --git a/tests/out/ir/access.ron b/tests/out/ir/access.ron index fcdd3b8b7c..9a1820fc8d 100644 --- a/tests/out/ir/access.ron +++ b/tests/out/ir/access.ron @@ -1792,9 +1792,9 @@ base: 13, index: 0, ), - AccessIndex( + Access( base: 14, - index: 3, + index: 12, ), AccessIndex( base: 15, diff --git a/tests/out/msl/access.msl b/tests/out/msl/access.msl index 3d57ebd7c8..7c901c35a4 100644 --- a/tests/out/msl/access.msl +++ b/tests/out/msl/access.msl @@ -180,7 +180,7 @@ vertex foo_vertOutput foo_vert( test_matrix_within_array_within_struct_accesses(nested_mat_cx2_); metal::float4x3 _matrix = bar._matrix; type_9 arr_1 = bar.arr; - float b = bar._matrix[3].x; + float b = bar._matrix[3u].x; int a_1 = bar.data[(1 + (_buffer_sizes.size1 - 160 - 8) / 8) - 2u].value; metal::int2 c = qux; float _e33 = read_from_private(foo); diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 135b4ec10b..5cbc23a006 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -12,8 +12,6 @@ constant int TEST_CONSTANT_ALIAS_ADDITION = 8; void swizzle_of_compose( device metal::int4& out ) { - metal::int2 a = metal::int2(1, 2); - metal::int2 b = metal::int2(3, 4); out = metal::int4(4, 3, 2, 1); return; } @@ -21,10 +19,8 @@ void swizzle_of_compose( void index_of_compose( device int& out2_ ) { - metal::int2 a_1 = metal::int2(1, 2); - metal::int2 b_1 = metal::int2(3, 4); - int _e7 = out2_; - out2_ = _e7 + 2; + int _e2 = out2_; + out2_ = _e2 + 2; return; } diff --git a/tests/out/msl/image.msl b/tests/out/msl/image.msl index 1612314ec8..e390c2e0fc 100644 --- a/tests/out/msl/image.msl +++ b/tests/out/msl/image.msl @@ -119,74 +119,74 @@ fragment texture_sampleOutput texture_sample( metal::float4 a = {}; metal::float2 tc = metal::float2(0.5); metal::float3 tc3_ = metal::float3(0.5); - metal::float4 _e8 = image_1d.sample(sampler_reg, 0.5); - metal::float4 _e9 = a; - a = _e9 + _e8; - metal::float4 _e13 = image_2d.sample(sampler_reg, tc); - metal::float4 _e14 = a; - a = _e14 + _e13; - metal::float4 _e18 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); - metal::float4 _e19 = a; - a = _e19 + _e18; - metal::float4 _e23 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); - metal::float4 _e24 = a; - a = _e24 + _e23; - metal::float4 _e28 = image_2d.sample(sampler_reg, tc, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e29 = a; - a = _e29 + _e28; - metal::float4 _e34 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e35 = a; - a = _e35 + _e34; - metal::float4 _e40 = image_2d_array.sample(sampler_reg, tc, 0u); - metal::float4 _e41 = a; - a = _e41 + _e40; - metal::float4 _e46 = image_2d_array.sample(sampler_reg, tc, 0u, metal::int2(3, 1)); - metal::float4 _e47 = a; - a = _e47 + _e46; - metal::float4 _e52 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); - metal::float4 _e53 = a; - a = _e53 + _e52; - metal::float4 _e58 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e59 = a; - a = _e59 + _e58; - metal::float4 _e65 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e66 = a; - a = _e66 + _e65; - metal::float4 _e71 = image_2d_array.sample(sampler_reg, tc, 0); - metal::float4 _e72 = a; - a = _e72 + _e71; - metal::float4 _e77 = image_2d_array.sample(sampler_reg, tc, 0, metal::int2(3, 1)); - metal::float4 _e78 = a; - a = _e78 + _e77; - metal::float4 _e83 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); - metal::float4 _e84 = a; - a = _e84 + _e83; - metal::float4 _e89 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), metal::int2(3, 1)); - metal::float4 _e90 = a; - a = _e90 + _e89; - metal::float4 _e96 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), metal::int2(3, 1)); - metal::float4 _e97 = a; - a = _e97 + _e96; - metal::float4 _e102 = image_cube_array.sample(sampler_reg, tc3_, 0u); - metal::float4 _e103 = a; - a = _e103 + _e102; - metal::float4 _e108 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::level(2.3)); - metal::float4 _e109 = a; - a = _e109 + _e108; - metal::float4 _e115 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::bias(2.0)); - metal::float4 _e116 = a; - a = _e116 + _e115; - metal::float4 _e121 = image_cube_array.sample(sampler_reg, tc3_, 0); - metal::float4 _e122 = a; - a = _e122 + _e121; - metal::float4 _e127 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::level(2.3)); - metal::float4 _e128 = a; - a = _e128 + _e127; - metal::float4 _e134 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::bias(2.0)); - metal::float4 _e135 = a; - a = _e135 + _e134; - metal::float4 _e137 = a; - return texture_sampleOutput { _e137 }; + metal::float4 _e9 = image_1d.sample(sampler_reg, tc.x); + metal::float4 _e10 = a; + a = _e10 + _e9; + metal::float4 _e14 = image_2d.sample(sampler_reg, tc); + metal::float4 _e15 = a; + a = _e15 + _e14; + metal::float4 _e19 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); + metal::float4 _e20 = a; + a = _e20 + _e19; + metal::float4 _e24 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); + metal::float4 _e25 = a; + a = _e25 + _e24; + metal::float4 _e29 = image_2d.sample(sampler_reg, tc, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e30 = a; + a = _e30 + _e29; + metal::float4 _e35 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e36 = a; + a = _e36 + _e35; + metal::float4 _e41 = image_2d_array.sample(sampler_reg, tc, 0u); + metal::float4 _e42 = a; + a = _e42 + _e41; + metal::float4 _e47 = image_2d_array.sample(sampler_reg, tc, 0u, metal::int2(3, 1)); + metal::float4 _e48 = a; + a = _e48 + _e47; + metal::float4 _e53 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); + metal::float4 _e54 = a; + a = _e54 + _e53; + metal::float4 _e59 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e60 = a; + a = _e60 + _e59; + metal::float4 _e66 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e67 = a; + a = _e67 + _e66; + metal::float4 _e72 = image_2d_array.sample(sampler_reg, tc, 0); + metal::float4 _e73 = a; + a = _e73 + _e72; + metal::float4 _e78 = image_2d_array.sample(sampler_reg, tc, 0, metal::int2(3, 1)); + metal::float4 _e79 = a; + a = _e79 + _e78; + metal::float4 _e84 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); + metal::float4 _e85 = a; + a = _e85 + _e84; + metal::float4 _e90 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), metal::int2(3, 1)); + metal::float4 _e91 = a; + a = _e91 + _e90; + metal::float4 _e97 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), metal::int2(3, 1)); + metal::float4 _e98 = a; + a = _e98 + _e97; + metal::float4 _e103 = image_cube_array.sample(sampler_reg, tc3_, 0u); + metal::float4 _e104 = a; + a = _e104 + _e103; + metal::float4 _e109 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::level(2.3)); + metal::float4 _e110 = a; + a = _e110 + _e109; + metal::float4 _e116 = image_cube_array.sample(sampler_reg, tc3_, 0u, metal::bias(2.0)); + metal::float4 _e117 = a; + a = _e117 + _e116; + metal::float4 _e122 = image_cube_array.sample(sampler_reg, tc3_, 0); + metal::float4 _e123 = a; + a = _e123 + _e122; + metal::float4 _e128 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::level(2.3)); + metal::float4 _e129 = a; + a = _e129 + _e128; + metal::float4 _e135 = image_cube_array.sample(sampler_reg, tc3_, 0, metal::bias(2.0)); + metal::float4 _e136 = a; + a = _e136 + _e135; + metal::float4 _e138 = a; + return texture_sampleOutput { _e138 }; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 0b5c91317c..1f7bf5c8ce 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,130 +1,127 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 85 +; Bound: 82 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %75 "main" -OpExecutionMode %75 LocalSize 1 1 1 -OpDecorate %8 DescriptorSet 0 -OpDecorate %8 Binding 0 -OpDecorate %9 Block -OpMemberDecorate %9 0 Offset 0 -OpDecorate %11 DescriptorSet 0 -OpDecorate %11 Binding 1 -OpDecorate %12 Block -OpMemberDecorate %12 0 Offset 0 +OpEntryPoint GLCompute %72 "main" +OpExecutionMode %72 LocalSize 1 1 1 +OpDecorate %7 DescriptorSet 0 +OpDecorate %7 Binding 0 +OpDecorate %8 Block +OpMemberDecorate %8 0 Offset 0 +OpDecorate %10 DescriptorSet 0 +OpDecorate %10 Binding 1 +OpDecorate %11 Block +OpMemberDecorate %11 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 -%5 = OpTypeVector %4 2 -%6 = OpConstant %4 4 -%7 = OpConstant %4 8 -%9 = OpTypeStruct %3 -%10 = OpTypePointer StorageBuffer %9 -%8 = OpVariable %10 StorageBuffer -%12 = OpTypeStruct %4 -%13 = OpTypePointer StorageBuffer %12 -%11 = OpVariable %13 StorageBuffer -%16 = OpTypeFunction %2 -%17 = OpTypePointer StorageBuffer %3 -%19 = OpTypeInt 32 0 -%18 = OpConstant %19 0 -%21 = OpConstant %4 1 -%22 = OpConstant %4 2 -%23 = OpConstantComposite %5 %21 %22 -%24 = OpConstant %4 3 -%25 = OpConstantComposite %5 %24 %6 -%26 = OpConstantComposite %3 %6 %24 %22 %21 -%30 = OpTypePointer StorageBuffer %4 -%38 = OpConstant %4 6 -%45 = OpConstant %4 30 -%46 = OpConstant %4 70 -%48 = OpTypePointer Function %4 -%50 = OpConstantNull %4 -%52 = OpConstantNull %4 -%67 = OpConstant %4 -4 -%68 = OpConstantComposite %3 %67 %67 %67 %67 -%15 = OpFunction %2 None %16 -%14 = OpLabel -%20 = OpAccessChain %17 %8 %18 -OpBranch %27 -%27 = OpLabel -OpStore %20 %26 +%5 = OpConstant %4 4 +%6 = OpConstant %4 8 +%8 = OpTypeStruct %3 +%9 = OpTypePointer StorageBuffer %8 +%7 = OpVariable %9 StorageBuffer +%11 = OpTypeStruct %4 +%12 = OpTypePointer StorageBuffer %11 +%10 = OpVariable %12 StorageBuffer +%15 = OpTypeFunction %2 +%16 = OpTypePointer StorageBuffer %3 +%18 = OpTypeInt 32 0 +%17 = OpConstant %18 0 +%20 = OpConstant %4 1 +%21 = OpConstant %4 2 +%22 = OpConstant %4 3 +%23 = OpConstantComposite %3 %5 %22 %21 %20 +%27 = OpTypePointer StorageBuffer %4 +%35 = OpConstant %4 6 +%42 = OpConstant %4 30 +%43 = OpConstant %4 70 +%45 = OpTypePointer Function %4 +%47 = OpConstantNull %4 +%49 = OpConstantNull %4 +%64 = OpConstant %4 -4 +%65 = OpConstantComposite %3 %64 %64 %64 %64 +%14 = OpFunction %2 None %15 +%13 = OpLabel +%19 = OpAccessChain %16 %7 %17 +OpBranch %24 +%24 = OpLabel +OpStore %19 %23 OpReturn OpFunctionEnd -%29 = OpFunction %2 None %16 -%28 = OpLabel -%31 = OpAccessChain %30 %11 %18 -OpBranch %32 -%32 = OpLabel -%33 = OpLoad %4 %31 -%34 = OpIAdd %4 %33 %22 -OpStore %31 %34 +%26 = OpFunction %2 None %15 +%25 = OpLabel +%28 = OpAccessChain %27 %10 %17 +OpBranch %29 +%29 = OpLabel +%30 = OpLoad %4 %28 +%31 = OpIAdd %4 %30 %21 +OpStore %28 %31 OpReturn OpFunctionEnd -%36 = OpFunction %2 None %16 -%35 = OpLabel -%37 = OpAccessChain %30 %11 %18 -OpBranch %39 -%39 = OpLabel -%40 = OpLoad %4 %37 -%41 = OpIAdd %4 %40 %38 -OpStore %37 %41 +%33 = OpFunction %2 None %15 +%32 = OpLabel +%34 = OpAccessChain %27 %10 %17 +OpBranch %36 +%36 = OpLabel +%37 = OpLoad %4 %34 +%38 = OpIAdd %4 %37 %35 +OpStore %34 %38 OpReturn OpFunctionEnd -%43 = OpFunction %2 None %16 -%42 = OpLabel -%49 = OpVariable %48 Function %50 -%53 = OpVariable %48 Function %46 -%47 = OpVariable %48 Function %45 -%51 = OpVariable %48 Function %52 -%44 = OpAccessChain %17 %8 %18 -OpBranch %54 -%54 = OpLabel -%55 = OpLoad %4 %47 -OpStore %49 %55 -%56 = OpLoad %4 %49 -OpStore %51 %56 -%57 = OpLoad %4 %47 -%58 = OpLoad %4 %49 -%59 = OpLoad %4 %51 -%60 = OpLoad %4 %53 -%61 = OpCompositeConstruct %3 %57 %58 %59 %60 -%62 = OpLoad %3 %44 -%63 = OpIAdd %3 %62 %61 -OpStore %44 %63 +%40 = OpFunction %2 None %15 +%39 = OpLabel +%46 = OpVariable %45 Function %47 +%50 = OpVariable %45 Function %43 +%44 = OpVariable %45 Function %42 +%48 = OpVariable %45 Function %49 +%41 = OpAccessChain %16 %7 %17 +OpBranch %51 +%51 = OpLabel +%52 = OpLoad %4 %44 +OpStore %46 %52 +%53 = OpLoad %4 %46 +OpStore %48 %53 +%54 = OpLoad %4 %44 +%55 = OpLoad %4 %46 +%56 = OpLoad %4 %48 +%57 = OpLoad %4 %50 +%58 = OpCompositeConstruct %3 %54 %55 %56 %57 +%59 = OpLoad %3 %41 +%60 = OpIAdd %3 %59 %58 +OpStore %41 %60 OpReturn OpFunctionEnd -%65 = OpFunction %2 None %16 -%64 = OpLabel -%66 = OpAccessChain %17 %8 %18 -OpBranch %69 -%69 = OpLabel -OpStore %66 %68 +%62 = OpFunction %2 None %15 +%61 = OpLabel +%63 = OpAccessChain %16 %7 %17 +OpBranch %66 +%66 = OpLabel +OpStore %63 %65 OpReturn OpFunctionEnd -%71 = OpFunction %2 None %16 +%68 = OpFunction %2 None %15 +%67 = OpLabel +%69 = OpAccessChain %16 %7 %17 +OpBranch %70 %70 = OpLabel -%72 = OpAccessChain %17 %8 %18 -OpBranch %73 -%73 = OpLabel -OpStore %72 %68 +OpStore %69 %65 OpReturn OpFunctionEnd -%75 = OpFunction %2 None %16 -%74 = OpLabel -%76 = OpAccessChain %17 %8 %18 -%77 = OpAccessChain %30 %11 %18 -OpBranch %78 -%78 = OpLabel -%79 = OpFunctionCall %2 %15 -%80 = OpFunctionCall %2 %29 -%81 = OpFunctionCall %2 %36 -%82 = OpFunctionCall %2 %43 -%83 = OpFunctionCall %2 %65 -%84 = OpFunctionCall %2 %71 +%72 = OpFunction %2 None %15 +%71 = OpLabel +%73 = OpAccessChain %16 %7 %17 +%74 = OpAccessChain %27 %10 %17 +OpBranch %75 +%75 = OpLabel +%76 = OpFunctionCall %2 %14 +%77 = OpFunctionCall %2 %26 +%78 = OpFunctionCall %2 %33 +%79 = OpFunctionCall %2 %40 +%80 = OpFunctionCall %2 %62 +%81 = OpFunctionCall %2 %68 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/debug-symbol-terrain.spvasm b/tests/out/spv/debug-symbol-terrain.spvasm index 30ecd2f8f6..36fae9d60a 100644 --- a/tests/out/spv/debug-symbol-terrain.spvasm +++ b/tests/out/spv/debug-symbol-terrain.spvasm @@ -360,10 +360,10 @@ OpName %52 "x" OpName %53 "permute3" OpName %66 "v" OpName %67 "snoise2" -OpName %90 "i" -OpName %93 "i1" -OpName %95 "x12" -OpName %98 "m" +OpName %86 "i" +OpName %89 "i1" +OpName %91 "x12" +OpName %94 "m" OpName %203 "p" OpName %204 "fbm" OpName %209 "x" @@ -547,34 +547,30 @@ OpDecorate %582 Location 0 %71 = OpConstant %5 -0.57735026 %72 = OpConstant %5 0.024390243 %73 = OpConstantComposite %7 %69 %70 %71 %72 -%74 = OpConstantComposite %6 %70 %70 -%75 = OpConstantComposite %6 %69 %69 -%76 = OpConstant %5 0.0 -%77 = OpConstantComposite %6 %56 %76 -%78 = OpConstantComposite %6 %76 %56 -%79 = OpConstantComposite %7 %69 %69 %71 %71 -%80 = OpConstantComposite %6 %58 %58 -%81 = OpConstant %5 0.5 -%82 = OpConstantComposite %4 %81 %81 %81 -%83 = OpConstantComposite %4 %76 %76 %76 -%84 = OpConstant %5 2.0 -%85 = OpConstantComposite %4 %72 %72 %72 -%86 = OpConstant %5 1.7928429 -%87 = OpConstant %5 0.85373473 -%88 = OpConstantComposite %4 %86 %86 %86 -%89 = OpConstant %5 130.0 -%91 = OpTypePointer Function %6 -%92 = OpConstantNull %6 -%94 = OpConstantNull %6 -%96 = OpTypePointer Function %7 -%97 = OpConstantNull %7 -%99 = OpTypePointer Function %4 -%100 = OpConstantNull %4 -%114 = OpTypeBool -%117 = OpTypeVector %114 2 -%126 = OpTypePointer Function %5 -%127 = OpConstant %8 1 -%136 = OpConstant %8 0 +%74 = OpConstant %5 0.0 +%75 = OpConstantComposite %6 %56 %74 +%76 = OpConstantComposite %6 %74 %56 +%77 = OpConstantComposite %6 %58 %58 +%78 = OpConstant %5 0.5 +%79 = OpConstantComposite %4 %78 %78 %78 +%80 = OpConstantComposite %4 %74 %74 %74 +%81 = OpConstant %5 2.0 +%82 = OpConstant %5 1.7928429 +%83 = OpConstant %5 0.85373473 +%84 = OpConstantComposite %4 %82 %82 %82 +%85 = OpConstant %5 130.0 +%87 = OpTypePointer Function %6 +%88 = OpConstantNull %6 +%90 = OpConstantNull %6 +%92 = OpTypePointer Function %7 +%93 = OpConstantNull %7 +%95 = OpTypePointer Function %4 +%96 = OpConstantNull %4 +%112 = OpTypeBool +%115 = OpTypeVector %112 2 +%125 = OpTypePointer Function %5 +%126 = OpConstant %8 1 +%135 = OpConstant %8 0 %205 = OpConstant %8 5 %206 = OpConstant %5 0.01 %207 = OpConstant %5 100.0 @@ -585,11 +581,11 @@ OpDecorate %582 Location 0 %258 = OpTypeFunction %4 %6 %6 %271 = OpTypeFunction %14 %6 %6 %272 = OpConstant %5 0.1 -%273 = OpConstantComposite %6 %272 %76 -%274 = OpConstantComposite %6 %76 %272 +%273 = OpConstantComposite %6 %272 %74 +%274 = OpConstantComposite %6 %74 %272 %275 = OpConstant %5 -0.1 -%276 = OpConstantComposite %6 %275 %76 -%277 = OpConstantComposite %6 %76 %275 +%276 = OpConstantComposite %6 %275 %74 +%277 = OpConstantComposite %6 %74 %275 %304 = OpTypeFunction %6 %8 %10 %11 %321 = OpTypeFunction %4 %6 %322 = OpConstant %5 23.0 @@ -650,7 +646,7 @@ OpDecorate %582 Location 0 %585 = OpTypePointer Uniform %25 %587 = OpConstantComposite %4 %272 %272 %272 %588 = OpConstant %5 0.7 -%589 = OpConstantComposite %4 %81 %272 %588 +%589 = OpConstantComposite %4 %78 %272 %588 %590 = OpConstant %5 0.2 %591 = OpConstantComposite %4 %590 %590 %590 %593 = OpConstantNull %4 @@ -673,163 +669,167 @@ OpFunctionEnd %67 = OpFunction %5 None %68 %66 = OpFunctionParameter %6 %65 = OpLabel -%93 = OpVariable %91 Function %94 -%98 = OpVariable %99 Function %100 -%90 = OpVariable %91 Function %92 -%95 = OpVariable %96 Function %97 -OpBranch %101 -%101 = OpLabel +%89 = OpVariable %87 Function %90 +%94 = OpVariable %95 Function %96 +%86 = OpVariable %87 Function %88 +%91 = OpVariable %92 Function %93 +OpBranch %97 +%97 = OpLabel OpLine %3 13 13 OpLine %3 14 24 -%102 = OpDot %5 %66 %74 -%103 = OpCompositeConstruct %6 %102 %102 -%104 = OpFAdd %6 %66 %103 -%105 = OpExtInst %6 %1 Floor %104 +%98 = OpVectorShuffle %6 %73 %73 1 1 +%99 = OpDot %5 %66 %98 +%100 = OpCompositeConstruct %6 %99 %99 +%101 = OpFAdd %6 %66 %100 +%102 = OpExtInst %6 %1 Floor %101 OpLine %3 14 5 -OpStore %90 %105 +OpStore %86 %102 OpLine %3 15 14 -%106 = OpLoad %6 %90 -%107 = OpFSub %6 %66 %106 -%108 = OpLoad %6 %90 -%109 = OpDot %5 %108 %75 -%110 = OpCompositeConstruct %6 %109 %109 -%111 = OpFAdd %6 %107 %110 +%103 = OpLoad %6 %86 +%104 = OpFSub %6 %66 %103 +%105 = OpLoad %6 %86 +%106 = OpVectorShuffle %6 %73 %73 0 0 +%107 = OpDot %5 %105 %106 +%108 = OpCompositeConstruct %6 %107 %107 +%109 = OpFAdd %6 %104 %108 OpLine %3 17 32 OpLine %3 17 25 -%112 = OpCompositeExtract %5 %111 0 -%113 = OpCompositeExtract %5 %111 1 -%115 = OpFOrdLessThan %114 %112 %113 -%118 = OpCompositeConstruct %117 %115 %115 -%116 = OpSelect %6 %118 %78 %77 +%110 = OpCompositeExtract %5 %109 0 +%111 = OpCompositeExtract %5 %109 1 +%113 = OpFOrdLessThan %112 %110 %111 +%116 = OpCompositeConstruct %115 %113 %113 +%114 = OpSelect %6 %116 %76 %75 OpLine %3 17 5 -OpStore %93 %116 +OpStore %89 %114 OpLine %3 18 26 -%119 = OpVectorShuffle %7 %111 %111 0 1 0 1 -%120 = OpFAdd %7 %119 %79 -%121 = OpLoad %6 %93 +%117 = OpVectorShuffle %7 %109 %109 0 1 0 1 +%118 = OpVectorShuffle %7 %73 %73 0 0 2 2 +%119 = OpFAdd %7 %117 %118 +%120 = OpLoad %6 %89 OpLine %3 18 26 -%122 = OpCompositeConstruct %7 %121 %76 %76 -%123 = OpFSub %7 %120 %122 +%121 = OpCompositeConstruct %7 %120 %74 %74 +%122 = OpFSub %7 %119 %121 OpLine %3 18 5 -OpStore %95 %123 +OpStore %91 %122 OpLine %3 1 1 -%124 = OpLoad %6 %90 +%123 = OpLoad %6 %86 OpLine %3 19 9 -%125 = OpFRem %6 %124 %80 +%124 = OpFRem %6 %123 %77 OpLine %3 19 5 -OpStore %90 %125 +OpStore %86 %124 OpLine %3 20 31 -%128 = OpAccessChain %126 %90 %127 -%129 = OpLoad %5 %128 +%127 = OpAccessChain %125 %86 %126 +%128 = OpLoad %5 %127 OpLine %3 20 51 -%130 = OpAccessChain %126 %93 %127 -%131 = OpLoad %5 %130 +%129 = OpAccessChain %125 %89 %126 +%130 = OpLoad %5 %129 OpLine %3 20 31 -%132 = OpCompositeConstruct %4 %76 %131 %56 -%133 = OpCompositeConstruct %4 %129 %129 %129 -%134 = OpFAdd %4 %133 %132 +%131 = OpCompositeConstruct %4 %74 %130 %56 +%132 = OpCompositeConstruct %4 %128 %128 %128 +%133 = OpFAdd %4 %132 %131 OpLine %3 20 22 -%135 = OpFunctionCall %4 %53 %134 +%134 = OpFunctionCall %4 %53 %133 OpLine %3 20 22 -%137 = OpAccessChain %126 %90 %136 -%138 = OpLoad %5 %137 -%139 = OpCompositeConstruct %4 %138 %138 %138 -%140 = OpFAdd %4 %135 %139 +%136 = OpAccessChain %125 %86 %135 +%137 = OpLoad %5 %136 +%138 = OpCompositeConstruct %4 %137 %137 %137 +%139 = OpFAdd %4 %134 %138 OpLine %3 20 84 -%141 = OpAccessChain %126 %93 %136 -%142 = OpLoad %5 %141 +%140 = OpAccessChain %125 %89 %135 +%141 = OpLoad %5 %140 OpLine %3 20 22 -%143 = OpCompositeConstruct %4 %76 %142 %56 -%144 = OpFAdd %4 %140 %143 +%142 = OpCompositeConstruct %4 %74 %141 %56 +%143 = OpFAdd %4 %139 %142 OpLine %3 20 13 -%145 = OpFunctionCall %4 %53 %144 +%144 = OpFunctionCall %4 %53 %143 OpLine %3 21 28 -%146 = OpDot %5 %111 %111 -%147 = OpLoad %7 %95 -%148 = OpVectorShuffle %6 %147 %147 0 1 -%149 = OpLoad %7 %95 -%150 = OpVectorShuffle %6 %149 %149 0 1 -%151 = OpDot %5 %148 %150 -%152 = OpLoad %7 %95 -%153 = OpVectorShuffle %6 %152 %152 2 3 -%154 = OpLoad %7 %95 -%155 = OpVectorShuffle %6 %154 %154 2 3 -%156 = OpDot %5 %153 %155 -%157 = OpCompositeConstruct %4 %146 %151 %156 -%158 = OpFSub %4 %82 %157 +%145 = OpDot %5 %109 %109 +%146 = OpLoad %7 %91 +%147 = OpVectorShuffle %6 %146 %146 0 1 +%148 = OpLoad %7 %91 +%149 = OpVectorShuffle %6 %148 %148 0 1 +%150 = OpDot %5 %147 %149 +%151 = OpLoad %7 %91 +%152 = OpVectorShuffle %6 %151 %151 2 3 +%153 = OpLoad %7 %91 +%154 = OpVectorShuffle %6 %153 %153 2 3 +%155 = OpDot %5 %152 %154 +%156 = OpCompositeConstruct %4 %145 %150 %155 +%157 = OpFSub %4 %79 %156 OpLine %3 21 24 -%159 = OpExtInst %4 %1 FMax %158 %83 +%158 = OpExtInst %4 %1 FMax %157 %80 OpLine %3 21 5 -OpStore %98 %159 +OpStore %94 %158 OpLine %3 22 9 -%160 = OpLoad %4 %98 -%161 = OpLoad %4 %98 -%162 = OpFMul %4 %160 %161 +%159 = OpLoad %4 %94 +%160 = OpLoad %4 %94 +%161 = OpFMul %4 %159 %160 OpLine %3 22 5 -OpStore %98 %162 +OpStore %94 %161 OpLine %3 23 9 -%163 = OpLoad %4 %98 -%164 = OpLoad %4 %98 -%165 = OpFMul %4 %163 %164 +%162 = OpLoad %4 %94 +%163 = OpLoad %4 %94 +%164 = OpFMul %4 %162 %163 OpLine %3 23 5 -OpStore %98 %165 +OpStore %94 %164 OpLine %3 24 13 -%166 = OpFMul %4 %145 %85 +%165 = OpVectorShuffle %4 %73 %73 3 3 3 +%166 = OpFMul %4 %144 %165 %167 = OpExtInst %4 %1 Fract %166 -%168 = OpVectorTimesScalar %4 %167 %84 +%168 = OpVectorTimesScalar %4 %167 %81 OpLine %3 24 13 %169 = OpFSub %4 %168 %57 OpLine %3 25 13 %170 = OpExtInst %4 %1 FAbs %169 OpLine %3 25 13 -%171 = OpFSub %4 %170 %82 +%171 = OpFSub %4 %170 %79 OpLine %3 26 14 -%172 = OpFAdd %4 %169 %82 +%172 = OpFAdd %4 %169 %79 %173 = OpExtInst %4 %1 Floor %172 OpLine %3 27 14 %174 = OpFSub %4 %169 %173 OpLine %3 1 1 -%175 = OpLoad %4 %98 +%175 = OpLoad %4 %94 OpLine %3 28 9 %176 = OpFMul %4 %174 %174 %177 = OpFMul %4 %171 %171 %178 = OpFAdd %4 %176 %177 -%179 = OpVectorTimesScalar %4 %178 %87 -%180 = OpFSub %4 %88 %179 +%179 = OpVectorTimesScalar %4 %178 %83 +%180 = OpFSub %4 %84 %179 %181 = OpFMul %4 %175 %180 OpLine %3 28 5 -OpStore %98 %181 +OpStore %94 %181 OpLine %3 29 13 %182 = OpCompositeExtract %5 %174 0 -%183 = OpCompositeExtract %5 %111 0 +%183 = OpCompositeExtract %5 %109 0 %184 = OpFMul %5 %182 %183 %185 = OpCompositeExtract %5 %171 0 -%186 = OpCompositeExtract %5 %111 1 +%186 = OpCompositeExtract %5 %109 1 %187 = OpFMul %5 %185 %186 %188 = OpFAdd %5 %184 %187 %189 = OpVectorShuffle %6 %174 %174 1 2 -%190 = OpLoad %7 %95 +%190 = OpLoad %7 %91 %191 = OpVectorShuffle %6 %190 %190 0 2 %192 = OpFMul %6 %189 %191 %193 = OpVectorShuffle %6 %171 %171 1 2 -%194 = OpLoad %7 %95 +%194 = OpLoad %7 %91 %195 = OpVectorShuffle %6 %194 %194 1 3 %196 = OpFMul %6 %193 %195 %197 = OpFAdd %6 %192 %196 %198 = OpCompositeConstruct %4 %188 %197 OpLine %3 30 12 -%199 = OpLoad %4 %98 +%199 = OpLoad %4 %94 %200 = OpDot %5 %199 %198 -%201 = OpFMul %5 %89 %200 +%201 = OpFMul %5 %85 %200 OpReturnValue %201 OpFunctionEnd %204 = OpFunction %5 None %68 %203 = OpFunctionParameter %6 %202 = OpLabel -%211 = OpVariable %212 Function %76 -%214 = OpVariable %215 Function %136 -%209 = OpVariable %91 Function %210 -%213 = OpVariable %212 Function %81 +%211 = OpVariable %212 Function %74 +%214 = OpVariable %215 Function %135 +%209 = OpVariable %87 Function %210 +%213 = OpVariable %212 Function %78 OpBranch %216 %216 = OpLabel OpLine %3 36 13 @@ -838,9 +838,9 @@ OpLine %3 36 5 OpStore %209 %217 OpLine %3 39 17 OpLine %3 40 24 -%218 = OpExtInst %5 %1 Cos %81 +%218 = OpExtInst %5 %1 Cos %78 OpLine %3 40 14 -%219 = OpExtInst %5 %1 Sin %81 +%219 = OpExtInst %5 %1 Sin %78 %220 = OpCompositeConstruct %6 %218 %219 OpLine %3 41 15 %221 = OpCompositeExtract %5 %220 0 @@ -859,7 +859,7 @@ OpBranch %231 %231 = OpLabel OpLine %3 43 22 %233 = OpLoad %8 %214 -%234 = OpULessThan %114 %233 %205 +%234 = OpULessThan %112 %233 %205 OpLine %3 43 21 OpSelectionMerge %235 None OpBranchConditional %234 %235 %236 @@ -883,14 +883,14 @@ OpLine %3 45 13 %245 = OpLoad %6 %209 %246 = OpMatrixTimesVector %6 %228 %245 OpLine %3 45 13 -%247 = OpVectorTimesScalar %6 %246 %84 +%247 = OpVectorTimesScalar %6 %246 %81 %248 = OpFAdd %6 %247 %208 OpLine %3 45 9 OpStore %209 %248 OpLine %3 1 1 %249 = OpLoad %5 %213 OpLine %3 46 13 -%250 = OpFMul %5 %249 %81 +%250 = OpFMul %5 %249 %78 OpLine %3 46 9 OpStore %213 %250 OpBranch %238 @@ -900,7 +900,7 @@ OpBranch %232 OpLine %3 1 1 %251 = OpLoad %8 %214 OpLine %3 43 43 -%252 = OpIAdd %8 %251 %127 +%252 = OpIAdd %8 %251 %126 OpLine %3 43 39 OpStore %214 %252 OpBranch %229 @@ -968,7 +968,7 @@ OpLine %3 92 14 OpLine %3 94 14 %296 = OpFAdd %4 %293 %295 OpLine %3 94 13 -%297 = OpVectorTimesScalar %4 %296 %81 +%297 = OpVectorTimesScalar %4 %296 %78 OpLine %3 96 12 %298 = OpCompositeConstruct %14 %279 %297 OpReturnValue %298 @@ -984,12 +984,12 @@ OpLine %3 101 9 %306 = OpConvertUToF %5 %300 %307 = OpCompositeExtract %8 %301 0 OpLine %3 101 9 -%308 = OpIAdd %8 %307 %127 +%308 = OpIAdd %8 %307 %126 %309 = OpConvertUToF %5 %308 %310 = OpFRem %5 %306 %309 %311 = OpCompositeExtract %8 %301 0 OpLine %3 100 12 -%312 = OpIAdd %8 %311 %127 +%312 = OpIAdd %8 %311 %126 %313 = OpUDiv %8 %300 %312 %314 = OpConvertUToF %5 %313 %315 = OpCompositeConstruct %6 %310 %314 @@ -1005,41 +1005,41 @@ OpBranch %328 OpLine %3 270 9 %329 = OpFunctionCall %5 %67 %319 OpLine %3 270 9 -%330 = OpFMul %5 %329 %81 +%330 = OpFMul %5 %329 %78 OpLine %3 270 9 -%331 = OpFAdd %5 %330 %81 +%331 = OpFAdd %5 %330 %78 OpLine %3 271 17 %332 = OpFAdd %6 %319 %324 OpLine %3 271 9 %333 = OpFunctionCall %5 %67 %332 OpLine %3 271 9 -%334 = OpFMul %5 %333 %81 +%334 = OpFMul %5 %333 %78 OpLine %3 271 9 -%335 = OpFAdd %5 %334 %81 +%335 = OpFAdd %5 %334 %78 OpLine %3 272 17 %336 = OpFAdd %6 %319 %327 OpLine %3 272 9 %337 = OpFunctionCall %5 %67 %336 OpLine %3 272 9 -%338 = OpFMul %5 %337 %81 +%338 = OpFMul %5 %337 %78 OpLine %3 269 12 -%339 = OpFAdd %5 %338 %81 +%339 = OpFAdd %5 %338 %78 %340 = OpCompositeConstruct %4 %331 %335 %339 OpReturnValue %340 OpFunctionEnd %345 = OpFunction %2 None %346 %341 = OpLabel %344 = OpLoad %19 %342 -%348 = OpAccessChain %347 %29 %136 +%348 = OpAccessChain %347 %29 %135 OpBranch %353 %353 = OpLabel OpLine %3 111 22 %354 = OpCompositeExtract %8 %344 0 OpLine %3 113 36 -%356 = OpAccessChain %355 %348 %136 +%356 = OpAccessChain %355 %348 %135 %357 = OpLoad %10 %356 OpLine %3 113 59 -%359 = OpAccessChain %358 %348 %127 +%359 = OpAccessChain %358 %348 %126 %360 = OpLoad %11 %359 OpLine %3 113 13 %361 = OpFunctionCall %6 %303 %354 %357 %360 @@ -1050,22 +1050,22 @@ OpLine %3 115 51 OpLine %3 115 33 %367 = OpFunctionCall %14 %270 %361 %366 OpLine %3 115 5 -%368 = OpAccessChain %363 %32 %136 %354 +%368 = OpAccessChain %363 %32 %135 %354 OpStore %368 %367 OpLine %3 118 23 %369 = OpCompositeExtract %8 %344 0 OpLine %3 118 23 %370 = OpIMul %8 %369 %349 OpLine %3 120 25 -%372 = OpAccessChain %371 %348 %136 %136 +%372 = OpAccessChain %371 %348 %135 %135 %373 = OpLoad %8 %372 OpLine %3 120 25 -%374 = OpAccessChain %371 %348 %136 %127 +%374 = OpAccessChain %371 %348 %135 %126 %375 = OpLoad %8 %374 %376 = OpIMul %8 %373 %375 OpLine %3 120 9 %377 = OpIMul %8 %376 %349 -%378 = OpUGreaterThanEqual %114 %370 %377 +%378 = OpUGreaterThanEqual %112 %370 %377 OpLine %3 120 5 OpSelectionMerge %379 None OpBranchConditional %378 %380 %379 @@ -1075,60 +1075,60 @@ OpReturn OpLine %3 122 28 %381 = OpCompositeExtract %8 %344 0 OpLine %3 122 15 -%382 = OpAccessChain %371 %348 %136 %136 +%382 = OpAccessChain %371 %348 %135 %135 %383 = OpLoad %8 %382 %384 = OpUDiv %8 %381 %383 %385 = OpIAdd %8 %354 %384 OpLine %3 123 15 -%386 = OpIAdd %8 %385 %127 +%386 = OpIAdd %8 %385 %126 OpLine %3 124 15 -%387 = OpAccessChain %371 %348 %136 %136 +%387 = OpAccessChain %371 %348 %135 %135 %388 = OpLoad %8 %387 %389 = OpIAdd %8 %385 %388 OpLine %3 124 15 -%390 = OpIAdd %8 %389 %127 +%390 = OpIAdd %8 %389 %126 OpLine %3 125 15 -%391 = OpIAdd %8 %390 %127 +%391 = OpIAdd %8 %390 %126 OpLine %3 127 5 OpLine %3 127 5 -%394 = OpAccessChain %393 %34 %136 %370 +%394 = OpAccessChain %393 %34 %135 %370 OpStore %394 %385 OpLine %3 128 5 OpLine %3 128 5 -%395 = OpIAdd %8 %370 %127 +%395 = OpIAdd %8 %370 %126 OpLine %3 128 5 -%396 = OpAccessChain %393 %34 %136 %395 +%396 = OpAccessChain %393 %34 %135 %395 OpStore %396 %390 OpLine %3 129 5 OpLine %3 129 5 %397 = OpIAdd %8 %370 %350 OpLine %3 129 5 -%398 = OpAccessChain %393 %34 %136 %397 +%398 = OpAccessChain %393 %34 %135 %397 OpStore %398 %391 OpLine %3 130 5 OpLine %3 130 5 %399 = OpIAdd %8 %370 %351 OpLine %3 130 5 -%400 = OpAccessChain %393 %34 %136 %399 +%400 = OpAccessChain %393 %34 %135 %399 OpStore %400 %385 OpLine %3 131 5 OpLine %3 131 5 %401 = OpIAdd %8 %370 %352 OpLine %3 131 5 -%402 = OpAccessChain %393 %34 %136 %401 +%402 = OpAccessChain %393 %34 %135 %401 OpStore %402 %391 OpLine %3 132 5 OpLine %3 132 5 %403 = OpIAdd %8 %370 %205 OpLine %3 132 5 -%404 = OpAccessChain %393 %34 %136 %403 +%404 = OpAccessChain %393 %34 %135 %403 OpStore %404 %386 OpReturn OpFunctionEnd %415 = OpFunction %2 None %346 %405 = OpLabel %408 = OpLoad %8 %406 -%417 = OpAccessChain %416 %36 %136 +%417 = OpAccessChain %416 %36 %135 OpBranch %420 %420 = OpLabel OpLine %3 161 19 @@ -1139,7 +1139,7 @@ OpLine %3 161 13 %423 = OpUMod %8 %422 %350 %424 = OpConvertUToF %5 %423 OpLine %3 162 19 -%425 = OpIAdd %8 %408 %127 +%425 = OpIAdd %8 %408 %126 OpLine %3 162 18 %426 = OpUDiv %8 %425 %351 OpLine %3 162 13 @@ -1148,10 +1148,10 @@ OpLine %3 162 13 OpLine %3 163 14 %429 = OpCompositeConstruct %6 %424 %428 OpLine %3 165 30 -%430 = OpVectorTimesScalar %6 %429 %84 +%430 = OpVectorTimesScalar %6 %429 %81 %431 = OpFAdd %6 %419 %430 OpLine %3 165 20 -%432 = OpCompositeConstruct %7 %431 %76 %56 +%432 = OpCompositeConstruct %7 %431 %74 %56 OpLine %3 168 21 %433 = OpCompositeExtract %5 %429 0 OpLine %3 168 21 @@ -1183,13 +1183,13 @@ OpReturn OpFunctionEnd %465 = OpFunction %2 None %346 %453 = OpLabel -%468 = OpVariable %212 Function %76 -%469 = OpVariable %215 Function %136 +%468 = OpVariable %212 Function %74 +%469 = OpVariable %215 Function %135 %456 = OpLoad %8 %455 %459 = OpLoad %7 %457 %462 = OpLoad %6 %460 %454 = OpCompositeConstruct %21 %456 %459 %462 -%466 = OpAccessChain %416 %36 %136 +%466 = OpAccessChain %416 %36 %135 OpBranch %470 %470 = OpLabel OpLine %3 181 17 @@ -1226,10 +1226,10 @@ OpLine %3 182 22 OpLine %3 183 22 %495 = OpUMod %8 %490 %349 OpLine %3 185 36 -%496 = OpAccessChain %355 %466 %136 +%496 = OpAccessChain %355 %466 %135 %497 = OpLoad %10 %496 OpLine %3 185 57 -%498 = OpAccessChain %358 %466 %127 +%498 = OpAccessChain %358 %466 %126 %499 = OpLoad %11 %498 OpLine %3 185 13 %500 = OpFunctionCall %6 %303 %494 %497 %499 @@ -1287,20 +1287,20 @@ OpBranch %504 OpBranch %504 %504 = OpLabel OpLine %3 200 15 -%524 = OpAccessChain %371 %466 %136 %136 +%524 = OpAccessChain %371 %466 %135 %135 %525 = OpLoad %8 %524 %526 = OpUDiv %8 %494 %525 %527 = OpIAdd %8 %494 %526 OpLine %3 201 15 -%528 = OpIAdd %8 %527 %127 +%528 = OpIAdd %8 %527 %126 OpLine %3 202 15 -%529 = OpAccessChain %371 %466 %136 %136 +%529 = OpAccessChain %371 %466 %135 %135 %530 = OpLoad %8 %529 %531 = OpIAdd %8 %527 %530 OpLine %3 202 15 -%532 = OpIAdd %8 %531 %127 +%532 = OpIAdd %8 %531 %126 OpLine %3 203 15 -%533 = OpIAdd %8 %532 %127 +%533 = OpIAdd %8 %532 %126 OpLine %3 206 5 OpSelectionMerge %534 None OpSwitch %495 %539 0 %535 3 %535 2 %536 4 %536 1 %537 5 %538 @@ -1344,11 +1344,11 @@ OpFunctionEnd %551 = OpLoad %4 %549 %553 = OpLoad %4 %552 %548 = OpCompositeConstruct %14 %551 %553 -%560 = OpAccessChain %559 %39 %136 +%560 = OpAccessChain %559 %39 %135 OpBranch %561 %561 = OpLabel OpLine %3 254 25 -%563 = OpAccessChain %562 %560 %127 +%563 = OpAccessChain %562 %560 %126 %564 = OpLoad %23 %563 %565 = OpCompositeExtract %4 %548 0 OpLine %3 254 25 @@ -1369,30 +1369,30 @@ OpReturn OpFunctionEnd %583 = OpFunction %2 None %346 %574 = OpLabel -%592 = OpVariable %99 Function %593 +%592 = OpVariable %95 Function %593 %577 = OpLoad %7 %576 %579 = OpLoad %4 %578 %581 = OpLoad %4 %580 %575 = OpCompositeConstruct %26 %577 %579 %581 -%584 = OpAccessChain %559 %39 %136 -%586 = OpAccessChain %585 %42 %136 +%584 = OpAccessChain %559 %39 %135 +%586 = OpAccessChain %585 %42 %135 OpBranch %594 %594 = OpLabel OpLine %3 278 28 OpLine %3 278 17 %595 = OpCompositeExtract %4 %575 2 %596 = OpExtInst %4 %1 Fract %595 -%597 = OpExtInst %4 %1 SmoothStep %83 %587 %596 +%597 = OpExtInst %4 %1 SmoothStep %80 %587 %596 OpLine %3 278 5 OpStore %592 %597 OpLine %3 279 17 OpLine %3 279 13 -%598 = OpAccessChain %126 %592 %136 +%598 = OpAccessChain %125 %592 %135 %599 = OpLoad %5 %598 -%600 = OpAccessChain %126 %592 %127 +%600 = OpAccessChain %125 %592 %126 %601 = OpLoad %5 %600 %602 = OpFMul %5 %599 %601 -%603 = OpAccessChain %126 %592 %350 +%603 = OpAccessChain %125 %592 %350 %604 = OpLoad %5 %603 %605 = OpFMul %5 %602 %604 %606 = OpCompositeConstruct %4 %605 %605 %605 @@ -1400,17 +1400,17 @@ OpLine %3 279 13 OpLine %3 279 5 OpStore %592 %607 OpLine %3 282 25 -%609 = OpAccessChain %608 %586 %127 +%609 = OpAccessChain %608 %586 %126 %610 = OpLoad %4 %609 %611 = OpVectorTimesScalar %4 %610 %272 OpLine %3 284 21 -%612 = OpAccessChain %608 %586 %136 +%612 = OpAccessChain %608 %586 %135 %613 = OpLoad %4 %612 %614 = OpCompositeExtract %4 %575 2 %615 = OpFSub %4 %613 %614 %616 = OpExtInst %4 %1 Normalize %615 OpLine %3 285 20 -%618 = OpAccessChain %617 %584 %136 +%618 = OpAccessChain %617 %584 %135 %619 = OpLoad %7 %618 %620 = OpVectorShuffle %4 %619 %619 0 1 2 %621 = OpCompositeExtract %4 %575 2 @@ -1423,20 +1423,20 @@ OpLine %3 288 32 %626 = OpCompositeExtract %4 %575 1 %627 = OpDot %5 %626 %616 OpLine %3 288 28 -%628 = OpExtInst %5 %1 FMax %627 %76 +%628 = OpExtInst %5 %1 FMax %627 %74 OpLine %3 289 25 -%629 = OpAccessChain %608 %586 %127 +%629 = OpAccessChain %608 %586 %126 %630 = OpLoad %4 %629 %631 = OpVectorTimesScalar %4 %630 %628 OpLine %3 291 37 %632 = OpCompositeExtract %4 %575 1 %633 = OpDot %5 %632 %625 OpLine %3 291 33 -%634 = OpExtInst %5 %1 FMax %633 %76 +%634 = OpExtInst %5 %1 FMax %633 %74 OpLine %3 291 29 %635 = OpExtInst %5 %1 Pow %634 %323 OpLine %3 292 26 -%636 = OpAccessChain %608 %586 %127 +%636 = OpAccessChain %608 %586 %126 %637 = OpLoad %4 %636 %638 = OpVectorTimesScalar %4 %637 %635 OpLine %3 294 18 diff --git a/tests/out/spv/image.spvasm b/tests/out/spv/image.spvasm index ec35372f8a..708cd65f28 100644 --- a/tests/out/spv/image.spvasm +++ b/tests/out/spv/image.spvasm @@ -1,7 +1,7 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 517 +; Bound: 518 OpCapability Shader OpCapability Image1D OpCapability Sampled1D @@ -14,15 +14,15 @@ OpEntryPoint GLCompute %169 "depth_load" %167 OpEntryPoint Vertex %189 "queries" %187 OpEntryPoint Vertex %241 "levels_queries" %240 OpEntryPoint Fragment %270 "texture_sample" %269 -OpEntryPoint Fragment %416 "texture_sample_comparison" %414 -OpEntryPoint Fragment %472 "gather" %471 -OpEntryPoint Fragment %506 "depth_no_comparison" %505 +OpEntryPoint Fragment %417 "texture_sample_comparison" %415 +OpEntryPoint Fragment %473 "gather" %472 +OpEntryPoint Fragment %507 "depth_no_comparison" %506 OpExecutionMode %78 LocalSize 16 1 1 OpExecutionMode %169 LocalSize 16 1 1 OpExecutionMode %270 OriginUpperLeft -OpExecutionMode %416 OriginUpperLeft -OpExecutionMode %472 OriginUpperLeft -OpExecutionMode %506 OriginUpperLeft +OpExecutionMode %417 OriginUpperLeft +OpExecutionMode %473 OriginUpperLeft +OpExecutionMode %507 OriginUpperLeft OpName %31 "image_mipmapped_src" OpName %33 "image_multisampled_src" OpName %35 "image_depth_multisampled_src" @@ -53,10 +53,10 @@ OpName %189 "queries" OpName %241 "levels_queries" OpName %270 "texture_sample" OpName %284 "a" -OpName %416 "texture_sample_comparison" -OpName %421 "a" -OpName %472 "gather" -OpName %506 "depth_no_comparison" +OpName %417 "texture_sample_comparison" +OpName %422 "a" +OpName %473 "gather" +OpName %507 "depth_no_comparison" OpDecorate %31 DescriptorSet 0 OpDecorate %31 Binding 0 OpDecorate %33 DescriptorSet 0 @@ -109,9 +109,9 @@ OpDecorate %167 BuiltIn LocalInvocationId OpDecorate %187 BuiltIn Position OpDecorate %240 BuiltIn Position OpDecorate %269 Location 0 -OpDecorate %414 Location 0 -OpDecorate %471 Location 0 -OpDecorate %505 Location 0 +OpDecorate %415 Location 0 +OpDecorate %472 Location 0 +OpDecorate %506 Location 0 %2 = OpTypeVoid %4 = OpTypeInt 32 0 %3 = OpTypeImage %4 2D 0 0 0 1 Unknown @@ -209,25 +209,25 @@ OpDecorate %505 Location 0 %283 = OpConstant %14 0 %285 = OpTypePointer Function %23 %286 = OpConstantNull %23 -%288 = OpTypeSampledImage %15 -%293 = OpTypeSampledImage %16 -%314 = OpTypeSampledImage %18 -%375 = OpTypeSampledImage %20 -%415 = OpTypePointer Output %7 -%414 = OpVariable %415 Output -%422 = OpTypePointer Function %7 -%423 = OpConstantNull %7 -%425 = OpTypeSampledImage %25 -%430 = OpTypeSampledImage %26 -%443 = OpTypeSampledImage %27 -%450 = OpConstant %7 0.0 -%471 = OpVariable %188 Output -%482 = OpConstant %4 1 -%485 = OpConstant %4 3 -%490 = OpTypeSampledImage %3 -%493 = OpTypeVector %14 4 -%494 = OpTypeSampledImage %17 -%505 = OpVariable %188 Output +%289 = OpTypeSampledImage %15 +%294 = OpTypeSampledImage %16 +%315 = OpTypeSampledImage %18 +%376 = OpTypeSampledImage %20 +%416 = OpTypePointer Output %7 +%415 = OpVariable %416 Output +%423 = OpTypePointer Function %7 +%424 = OpConstantNull %7 +%426 = OpTypeSampledImage %25 +%431 = OpTypeSampledImage %26 +%444 = OpTypeSampledImage %27 +%451 = OpConstant %7 0.0 +%472 = OpVariable %188 Output +%483 = OpConstant %4 1 +%486 = OpConstant %4 3 +%491 = OpTypeSampledImage %3 +%494 = OpTypeVector %14 4 +%495 = OpTypeSampledImage %17 +%506 = OpVariable %188 Output %78 = OpFunction %2 None %79 %74 = OpLabel %77 = OpLoad %12 %75 @@ -434,258 +434,259 @@ OpFunctionEnd %275 = OpLoad %24 %64 OpBranch %287 %287 = OpLabel -%289 = OpSampledImage %288 %271 %275 -%290 = OpImageSampleImplicitLod %23 %289 %276 -%291 = OpLoad %23 %284 -%292 = OpFAdd %23 %291 %290 -OpStore %284 %292 -%294 = OpSampledImage %293 %272 %275 -%295 = OpImageSampleImplicitLod %23 %294 %278 -%296 = OpLoad %23 %284 -%297 = OpFAdd %23 %296 %295 -OpStore %284 %297 -%298 = OpSampledImage %293 %272 %275 -%299 = OpImageSampleImplicitLod %23 %298 %278 ConstOffset %30 -%300 = OpLoad %23 %284 -%301 = OpFAdd %23 %300 %299 -OpStore %284 %301 -%302 = OpSampledImage %293 %272 %275 -%303 = OpImageSampleExplicitLod %23 %302 %278 Lod %281 -%304 = OpLoad %23 %284 -%305 = OpFAdd %23 %304 %303 -OpStore %284 %305 -%306 = OpSampledImage %293 %272 %275 -%307 = OpImageSampleExplicitLod %23 %306 %278 Lod|ConstOffset %281 %30 -%308 = OpLoad %23 %284 -%309 = OpFAdd %23 %308 %307 -OpStore %284 %309 -%310 = OpSampledImage %293 %272 %275 -%311 = OpImageSampleImplicitLod %23 %310 %278 Bias|ConstOffset %282 %30 -%312 = OpLoad %23 %284 -%313 = OpFAdd %23 %312 %311 -OpStore %284 %313 -%315 = OpConvertUToF %7 %198 -%316 = OpCompositeConstruct %279 %278 %315 -%317 = OpSampledImage %314 %273 %275 -%318 = OpImageSampleImplicitLod %23 %317 %316 -%319 = OpLoad %23 %284 -%320 = OpFAdd %23 %319 %318 -OpStore %284 %320 -%321 = OpConvertUToF %7 %198 -%322 = OpCompositeConstruct %279 %278 %321 -%323 = OpSampledImage %314 %273 %275 -%324 = OpImageSampleImplicitLod %23 %323 %322 ConstOffset %30 -%325 = OpLoad %23 %284 -%326 = OpFAdd %23 %325 %324 -OpStore %284 %326 -%327 = OpConvertUToF %7 %198 -%328 = OpCompositeConstruct %279 %278 %327 -%329 = OpSampledImage %314 %273 %275 -%330 = OpImageSampleExplicitLod %23 %329 %328 Lod %281 -%331 = OpLoad %23 %284 -%332 = OpFAdd %23 %331 %330 -OpStore %284 %332 -%333 = OpConvertUToF %7 %198 -%334 = OpCompositeConstruct %279 %278 %333 -%335 = OpSampledImage %314 %273 %275 -%336 = OpImageSampleExplicitLod %23 %335 %334 Lod|ConstOffset %281 %30 -%337 = OpLoad %23 %284 -%338 = OpFAdd %23 %337 %336 -OpStore %284 %338 -%339 = OpConvertUToF %7 %198 -%340 = OpCompositeConstruct %279 %278 %339 -%341 = OpSampledImage %314 %273 %275 -%342 = OpImageSampleImplicitLod %23 %341 %340 Bias|ConstOffset %282 %30 -%343 = OpLoad %23 %284 -%344 = OpFAdd %23 %343 %342 -OpStore %284 %344 -%345 = OpConvertSToF %7 %283 -%346 = OpCompositeConstruct %279 %278 %345 -%347 = OpSampledImage %314 %273 %275 -%348 = OpImageSampleImplicitLod %23 %347 %346 -%349 = OpLoad %23 %284 -%350 = OpFAdd %23 %349 %348 -OpStore %284 %350 -%351 = OpConvertSToF %7 %283 -%352 = OpCompositeConstruct %279 %278 %351 -%353 = OpSampledImage %314 %273 %275 -%354 = OpImageSampleImplicitLod %23 %353 %352 ConstOffset %30 -%355 = OpLoad %23 %284 -%356 = OpFAdd %23 %355 %354 -OpStore %284 %356 -%357 = OpConvertSToF %7 %283 -%358 = OpCompositeConstruct %279 %278 %357 -%359 = OpSampledImage %314 %273 %275 -%360 = OpImageSampleExplicitLod %23 %359 %358 Lod %281 -%361 = OpLoad %23 %284 -%362 = OpFAdd %23 %361 %360 -OpStore %284 %362 -%363 = OpConvertSToF %7 %283 -%364 = OpCompositeConstruct %279 %278 %363 -%365 = OpSampledImage %314 %273 %275 -%366 = OpImageSampleExplicitLod %23 %365 %364 Lod|ConstOffset %281 %30 -%367 = OpLoad %23 %284 -%368 = OpFAdd %23 %367 %366 -OpStore %284 %368 -%369 = OpConvertSToF %7 %283 -%370 = OpCompositeConstruct %279 %278 %369 -%371 = OpSampledImage %314 %273 %275 -%372 = OpImageSampleImplicitLod %23 %371 %370 Bias|ConstOffset %282 %30 -%373 = OpLoad %23 %284 -%374 = OpFAdd %23 %373 %372 -OpStore %284 %374 -%376 = OpConvertUToF %7 %198 -%377 = OpCompositeConstruct %23 %280 %376 -%378 = OpSampledImage %375 %274 %275 -%379 = OpImageSampleImplicitLod %23 %378 %377 -%380 = OpLoad %23 %284 -%381 = OpFAdd %23 %380 %379 -OpStore %284 %381 -%382 = OpConvertUToF %7 %198 -%383 = OpCompositeConstruct %23 %280 %382 -%384 = OpSampledImage %375 %274 %275 -%385 = OpImageSampleExplicitLod %23 %384 %383 Lod %281 -%386 = OpLoad %23 %284 -%387 = OpFAdd %23 %386 %385 -OpStore %284 %387 -%388 = OpConvertUToF %7 %198 -%389 = OpCompositeConstruct %23 %280 %388 -%390 = OpSampledImage %375 %274 %275 -%391 = OpImageSampleImplicitLod %23 %390 %389 Bias %282 -%392 = OpLoad %23 %284 -%393 = OpFAdd %23 %392 %391 -OpStore %284 %393 -%394 = OpConvertSToF %7 %283 -%395 = OpCompositeConstruct %23 %280 %394 -%396 = OpSampledImage %375 %274 %275 -%397 = OpImageSampleImplicitLod %23 %396 %395 -%398 = OpLoad %23 %284 -%399 = OpFAdd %23 %398 %397 -OpStore %284 %399 -%400 = OpConvertSToF %7 %283 -%401 = OpCompositeConstruct %23 %280 %400 -%402 = OpSampledImage %375 %274 %275 -%403 = OpImageSampleExplicitLod %23 %402 %401 Lod %281 -%404 = OpLoad %23 %284 -%405 = OpFAdd %23 %404 %403 -OpStore %284 %405 -%406 = OpConvertSToF %7 %283 -%407 = OpCompositeConstruct %23 %280 %406 -%408 = OpSampledImage %375 %274 %275 -%409 = OpImageSampleImplicitLod %23 %408 %407 Bias %282 -%410 = OpLoad %23 %284 -%411 = OpFAdd %23 %410 %409 -OpStore %284 %411 -%412 = OpLoad %23 %284 -OpStore %269 %412 +%288 = OpCompositeExtract %7 %278 0 +%290 = OpSampledImage %289 %271 %275 +%291 = OpImageSampleImplicitLod %23 %290 %288 +%292 = OpLoad %23 %284 +%293 = OpFAdd %23 %292 %291 +OpStore %284 %293 +%295 = OpSampledImage %294 %272 %275 +%296 = OpImageSampleImplicitLod %23 %295 %278 +%297 = OpLoad %23 %284 +%298 = OpFAdd %23 %297 %296 +OpStore %284 %298 +%299 = OpSampledImage %294 %272 %275 +%300 = OpImageSampleImplicitLod %23 %299 %278 ConstOffset %30 +%301 = OpLoad %23 %284 +%302 = OpFAdd %23 %301 %300 +OpStore %284 %302 +%303 = OpSampledImage %294 %272 %275 +%304 = OpImageSampleExplicitLod %23 %303 %278 Lod %281 +%305 = OpLoad %23 %284 +%306 = OpFAdd %23 %305 %304 +OpStore %284 %306 +%307 = OpSampledImage %294 %272 %275 +%308 = OpImageSampleExplicitLod %23 %307 %278 Lod|ConstOffset %281 %30 +%309 = OpLoad %23 %284 +%310 = OpFAdd %23 %309 %308 +OpStore %284 %310 +%311 = OpSampledImage %294 %272 %275 +%312 = OpImageSampleImplicitLod %23 %311 %278 Bias|ConstOffset %282 %30 +%313 = OpLoad %23 %284 +%314 = OpFAdd %23 %313 %312 +OpStore %284 %314 +%316 = OpConvertUToF %7 %198 +%317 = OpCompositeConstruct %279 %278 %316 +%318 = OpSampledImage %315 %273 %275 +%319 = OpImageSampleImplicitLod %23 %318 %317 +%320 = OpLoad %23 %284 +%321 = OpFAdd %23 %320 %319 +OpStore %284 %321 +%322 = OpConvertUToF %7 %198 +%323 = OpCompositeConstruct %279 %278 %322 +%324 = OpSampledImage %315 %273 %275 +%325 = OpImageSampleImplicitLod %23 %324 %323 ConstOffset %30 +%326 = OpLoad %23 %284 +%327 = OpFAdd %23 %326 %325 +OpStore %284 %327 +%328 = OpConvertUToF %7 %198 +%329 = OpCompositeConstruct %279 %278 %328 +%330 = OpSampledImage %315 %273 %275 +%331 = OpImageSampleExplicitLod %23 %330 %329 Lod %281 +%332 = OpLoad %23 %284 +%333 = OpFAdd %23 %332 %331 +OpStore %284 %333 +%334 = OpConvertUToF %7 %198 +%335 = OpCompositeConstruct %279 %278 %334 +%336 = OpSampledImage %315 %273 %275 +%337 = OpImageSampleExplicitLod %23 %336 %335 Lod|ConstOffset %281 %30 +%338 = OpLoad %23 %284 +%339 = OpFAdd %23 %338 %337 +OpStore %284 %339 +%340 = OpConvertUToF %7 %198 +%341 = OpCompositeConstruct %279 %278 %340 +%342 = OpSampledImage %315 %273 %275 +%343 = OpImageSampleImplicitLod %23 %342 %341 Bias|ConstOffset %282 %30 +%344 = OpLoad %23 %284 +%345 = OpFAdd %23 %344 %343 +OpStore %284 %345 +%346 = OpConvertSToF %7 %283 +%347 = OpCompositeConstruct %279 %278 %346 +%348 = OpSampledImage %315 %273 %275 +%349 = OpImageSampleImplicitLod %23 %348 %347 +%350 = OpLoad %23 %284 +%351 = OpFAdd %23 %350 %349 +OpStore %284 %351 +%352 = OpConvertSToF %7 %283 +%353 = OpCompositeConstruct %279 %278 %352 +%354 = OpSampledImage %315 %273 %275 +%355 = OpImageSampleImplicitLod %23 %354 %353 ConstOffset %30 +%356 = OpLoad %23 %284 +%357 = OpFAdd %23 %356 %355 +OpStore %284 %357 +%358 = OpConvertSToF %7 %283 +%359 = OpCompositeConstruct %279 %278 %358 +%360 = OpSampledImage %315 %273 %275 +%361 = OpImageSampleExplicitLod %23 %360 %359 Lod %281 +%362 = OpLoad %23 %284 +%363 = OpFAdd %23 %362 %361 +OpStore %284 %363 +%364 = OpConvertSToF %7 %283 +%365 = OpCompositeConstruct %279 %278 %364 +%366 = OpSampledImage %315 %273 %275 +%367 = OpImageSampleExplicitLod %23 %366 %365 Lod|ConstOffset %281 %30 +%368 = OpLoad %23 %284 +%369 = OpFAdd %23 %368 %367 +OpStore %284 %369 +%370 = OpConvertSToF %7 %283 +%371 = OpCompositeConstruct %279 %278 %370 +%372 = OpSampledImage %315 %273 %275 +%373 = OpImageSampleImplicitLod %23 %372 %371 Bias|ConstOffset %282 %30 +%374 = OpLoad %23 %284 +%375 = OpFAdd %23 %374 %373 +OpStore %284 %375 +%377 = OpConvertUToF %7 %198 +%378 = OpCompositeConstruct %23 %280 %377 +%379 = OpSampledImage %376 %274 %275 +%380 = OpImageSampleImplicitLod %23 %379 %378 +%381 = OpLoad %23 %284 +%382 = OpFAdd %23 %381 %380 +OpStore %284 %382 +%383 = OpConvertUToF %7 %198 +%384 = OpCompositeConstruct %23 %280 %383 +%385 = OpSampledImage %376 %274 %275 +%386 = OpImageSampleExplicitLod %23 %385 %384 Lod %281 +%387 = OpLoad %23 %284 +%388 = OpFAdd %23 %387 %386 +OpStore %284 %388 +%389 = OpConvertUToF %7 %198 +%390 = OpCompositeConstruct %23 %280 %389 +%391 = OpSampledImage %376 %274 %275 +%392 = OpImageSampleImplicitLod %23 %391 %390 Bias %282 +%393 = OpLoad %23 %284 +%394 = OpFAdd %23 %393 %392 +OpStore %284 %394 +%395 = OpConvertSToF %7 %283 +%396 = OpCompositeConstruct %23 %280 %395 +%397 = OpSampledImage %376 %274 %275 +%398 = OpImageSampleImplicitLod %23 %397 %396 +%399 = OpLoad %23 %284 +%400 = OpFAdd %23 %399 %398 +OpStore %284 %400 +%401 = OpConvertSToF %7 %283 +%402 = OpCompositeConstruct %23 %280 %401 +%403 = OpSampledImage %376 %274 %275 +%404 = OpImageSampleExplicitLod %23 %403 %402 Lod %281 +%405 = OpLoad %23 %284 +%406 = OpFAdd %23 %405 %404 +OpStore %284 %406 +%407 = OpConvertSToF %7 %283 +%408 = OpCompositeConstruct %23 %280 %407 +%409 = OpSampledImage %376 %274 %275 +%410 = OpImageSampleImplicitLod %23 %409 %408 Bias %282 +%411 = OpLoad %23 %284 +%412 = OpFAdd %23 %411 %410 +OpStore %284 %412 +%413 = OpLoad %23 %284 +OpStore %269 %413 OpReturn OpFunctionEnd -%416 = OpFunction %2 None %79 -%413 = OpLabel -%421 = OpVariable %422 Function %423 -%417 = OpLoad %24 %66 -%418 = OpLoad %25 %68 -%419 = OpLoad %26 %70 -%420 = OpLoad %27 %72 -OpBranch %424 -%424 = OpLabel -%426 = OpSampledImage %425 %418 %417 -%427 = OpImageSampleDrefImplicitLod %7 %426 %278 %276 -%428 = OpLoad %7 %421 -%429 = OpFAdd %7 %428 %427 -OpStore %421 %429 -%431 = OpConvertUToF %7 %198 -%432 = OpCompositeConstruct %279 %278 %431 -%433 = OpSampledImage %430 %419 %417 -%434 = OpImageSampleDrefImplicitLod %7 %433 %432 %276 -%435 = OpLoad %7 %421 -%436 = OpFAdd %7 %435 %434 -OpStore %421 %436 -%437 = OpConvertSToF %7 %283 -%438 = OpCompositeConstruct %279 %278 %437 -%439 = OpSampledImage %430 %419 %417 -%440 = OpImageSampleDrefImplicitLod %7 %439 %438 %276 -%441 = OpLoad %7 %421 -%442 = OpFAdd %7 %441 %440 -OpStore %421 %442 -%444 = OpSampledImage %443 %420 %417 -%445 = OpImageSampleDrefImplicitLod %7 %444 %280 %276 -%446 = OpLoad %7 %421 -%447 = OpFAdd %7 %446 %445 -OpStore %421 %447 -%448 = OpSampledImage %425 %418 %417 -%449 = OpImageSampleDrefExplicitLod %7 %448 %278 %276 Lod %450 -%451 = OpLoad %7 %421 -%452 = OpFAdd %7 %451 %449 -OpStore %421 %452 -%453 = OpConvertUToF %7 %198 -%454 = OpCompositeConstruct %279 %278 %453 -%455 = OpSampledImage %430 %419 %417 -%456 = OpImageSampleDrefExplicitLod %7 %455 %454 %276 Lod %450 -%457 = OpLoad %7 %421 -%458 = OpFAdd %7 %457 %456 -OpStore %421 %458 -%459 = OpConvertSToF %7 %283 -%460 = OpCompositeConstruct %279 %278 %459 -%461 = OpSampledImage %430 %419 %417 -%462 = OpImageSampleDrefExplicitLod %7 %461 %460 %276 Lod %450 -%463 = OpLoad %7 %421 -%464 = OpFAdd %7 %463 %462 -OpStore %421 %464 -%465 = OpSampledImage %443 %420 %417 -%466 = OpImageSampleDrefExplicitLod %7 %465 %280 %276 Lod %450 -%467 = OpLoad %7 %421 -%468 = OpFAdd %7 %467 %466 -OpStore %421 %468 -%469 = OpLoad %7 %421 -OpStore %414 %469 +%417 = OpFunction %2 None %79 +%414 = OpLabel +%422 = OpVariable %423 Function %424 +%418 = OpLoad %24 %66 +%419 = OpLoad %25 %68 +%420 = OpLoad %26 %70 +%421 = OpLoad %27 %72 +OpBranch %425 +%425 = OpLabel +%427 = OpSampledImage %426 %419 %418 +%428 = OpImageSampleDrefImplicitLod %7 %427 %278 %276 +%429 = OpLoad %7 %422 +%430 = OpFAdd %7 %429 %428 +OpStore %422 %430 +%432 = OpConvertUToF %7 %198 +%433 = OpCompositeConstruct %279 %278 %432 +%434 = OpSampledImage %431 %420 %418 +%435 = OpImageSampleDrefImplicitLod %7 %434 %433 %276 +%436 = OpLoad %7 %422 +%437 = OpFAdd %7 %436 %435 +OpStore %422 %437 +%438 = OpConvertSToF %7 %283 +%439 = OpCompositeConstruct %279 %278 %438 +%440 = OpSampledImage %431 %420 %418 +%441 = OpImageSampleDrefImplicitLod %7 %440 %439 %276 +%442 = OpLoad %7 %422 +%443 = OpFAdd %7 %442 %441 +OpStore %422 %443 +%445 = OpSampledImage %444 %421 %418 +%446 = OpImageSampleDrefImplicitLod %7 %445 %280 %276 +%447 = OpLoad %7 %422 +%448 = OpFAdd %7 %447 %446 +OpStore %422 %448 +%449 = OpSampledImage %426 %419 %418 +%450 = OpImageSampleDrefExplicitLod %7 %449 %278 %276 Lod %451 +%452 = OpLoad %7 %422 +%453 = OpFAdd %7 %452 %450 +OpStore %422 %453 +%454 = OpConvertUToF %7 %198 +%455 = OpCompositeConstruct %279 %278 %454 +%456 = OpSampledImage %431 %420 %418 +%457 = OpImageSampleDrefExplicitLod %7 %456 %455 %276 Lod %451 +%458 = OpLoad %7 %422 +%459 = OpFAdd %7 %458 %457 +OpStore %422 %459 +%460 = OpConvertSToF %7 %283 +%461 = OpCompositeConstruct %279 %278 %460 +%462 = OpSampledImage %431 %420 %418 +%463 = OpImageSampleDrefExplicitLod %7 %462 %461 %276 Lod %451 +%464 = OpLoad %7 %422 +%465 = OpFAdd %7 %464 %463 +OpStore %422 %465 +%466 = OpSampledImage %444 %421 %418 +%467 = OpImageSampleDrefExplicitLod %7 %466 %280 %276 Lod %451 +%468 = OpLoad %7 %422 +%469 = OpFAdd %7 %468 %467 +OpStore %422 %469 +%470 = OpLoad %7 %422 +OpStore %415 %470 OpReturn OpFunctionEnd -%472 = OpFunction %2 None %79 -%470 = OpLabel -%473 = OpLoad %16 %49 -%474 = OpLoad %3 %51 -%475 = OpLoad %17 %52 -%476 = OpLoad %24 %64 -%477 = OpLoad %24 %66 -%478 = OpLoad %25 %68 -OpBranch %479 -%479 = OpLabel -%480 = OpSampledImage %293 %473 %476 -%481 = OpImageGather %23 %480 %278 %482 -%483 = OpSampledImage %293 %473 %476 -%484 = OpImageGather %23 %483 %278 %485 ConstOffset %30 -%486 = OpSampledImage %425 %478 %477 -%487 = OpImageDrefGather %23 %486 %278 %276 -%488 = OpSampledImage %425 %478 %477 -%489 = OpImageDrefGather %23 %488 %278 %276 ConstOffset %30 -%491 = OpSampledImage %490 %474 %476 -%492 = OpImageGather %98 %491 %278 %198 -%495 = OpSampledImage %494 %475 %476 -%496 = OpImageGather %493 %495 %278 %198 -%497 = OpConvertUToF %23 %492 -%498 = OpConvertSToF %23 %496 -%499 = OpFAdd %23 %497 %498 -%500 = OpFAdd %23 %481 %484 -%501 = OpFAdd %23 %500 %487 -%502 = OpFAdd %23 %501 %489 -%503 = OpFAdd %23 %502 %499 -OpStore %471 %503 +%473 = OpFunction %2 None %79 +%471 = OpLabel +%474 = OpLoad %16 %49 +%475 = OpLoad %3 %51 +%476 = OpLoad %17 %52 +%477 = OpLoad %24 %64 +%478 = OpLoad %24 %66 +%479 = OpLoad %25 %68 +OpBranch %480 +%480 = OpLabel +%481 = OpSampledImage %294 %474 %477 +%482 = OpImageGather %23 %481 %278 %483 +%484 = OpSampledImage %294 %474 %477 +%485 = OpImageGather %23 %484 %278 %486 ConstOffset %30 +%487 = OpSampledImage %426 %479 %478 +%488 = OpImageDrefGather %23 %487 %278 %276 +%489 = OpSampledImage %426 %479 %478 +%490 = OpImageDrefGather %23 %489 %278 %276 ConstOffset %30 +%492 = OpSampledImage %491 %475 %477 +%493 = OpImageGather %98 %492 %278 %198 +%496 = OpSampledImage %495 %476 %477 +%497 = OpImageGather %494 %496 %278 %198 +%498 = OpConvertUToF %23 %493 +%499 = OpConvertSToF %23 %497 +%500 = OpFAdd %23 %498 %499 +%501 = OpFAdd %23 %482 %485 +%502 = OpFAdd %23 %501 %488 +%503 = OpFAdd %23 %502 %490 +%504 = OpFAdd %23 %503 %500 +OpStore %472 %504 OpReturn OpFunctionEnd -%506 = OpFunction %2 None %79 -%504 = OpLabel -%507 = OpLoad %24 %64 -%508 = OpLoad %25 %68 -OpBranch %509 -%509 = OpLabel -%510 = OpSampledImage %425 %508 %507 -%511 = OpImageSampleImplicitLod %23 %510 %278 -%512 = OpCompositeExtract %7 %511 0 -%513 = OpSampledImage %425 %508 %507 -%514 = OpImageGather %23 %513 %278 %198 -%515 = OpCompositeConstruct %23 %512 %512 %512 %512 -%516 = OpFAdd %23 %515 %514 -OpStore %505 %516 +%507 = OpFunction %2 None %79 +%505 = OpLabel +%508 = OpLoad %24 %64 +%509 = OpLoad %25 %68 +OpBranch %510 +%510 = OpLabel +%511 = OpSampledImage %426 %509 %508 +%512 = OpImageSampleImplicitLod %23 %511 %278 +%513 = OpCompositeExtract %7 %512 0 +%514 = OpSampledImage %426 %509 %508 +%515 = OpImageGather %23 %514 %278 %198 +%516 = OpCompositeConstruct %23 %513 %513 %513 %513 +%517 = OpFAdd %23 %516 %515 +OpStore %506 %517 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index ba268dca96..de98638874 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -138,7 +138,7 @@ fn foo_vert(@builtin(vertex_index) vi: u32) -> @builtin(position) vec4 { test_matrix_within_array_within_struct_accesses(); let _matrix = bar._matrix; let arr_1 = bar.arr; - let b = bar._matrix[3][0]; + let b = bar._matrix[3u][0]; let a_1 = bar.data[(arrayLength((&bar.data)) - 2u)].value; let c = qux; let data_pointer = (&bar.data[0].value); diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 57f3ba6a4e..2ddc903aad 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -9,17 +9,13 @@ var out: vec4; var out2_: i32; fn swizzle_of_compose() { - let a = vec2(1, 2); - let b = vec2(3, 4); out = vec4(4, 3, 2, 1); return; } fn index_of_compose() { - let a_1 = vec2(1, 2); - let b_1 = vec2(3, 4); - let _e7 = out2_; - out2_ = (_e7 + 2); + let _e2 = out2_; + out2_ = (_e2 + 2); return; } diff --git a/tests/out/wgsl/image.wgsl b/tests/out/wgsl/image.wgsl index 6dfa0dbac7..062d377139 100644 --- a/tests/out/wgsl/image.wgsl +++ b/tests/out/wgsl/image.wgsl @@ -112,74 +112,74 @@ fn texture_sample() -> @location(0) vec4 { let tc = vec2(0.5); let tc3_ = vec3(0.5); - let _e8 = textureSample(image_1d, sampler_reg, 0.5); - let _e9 = a; - a = (_e9 + _e8); - let _e13 = textureSample(image_2d, sampler_reg, tc); - let _e14 = a; - a = (_e14 + _e13); - let _e18 = textureSample(image_2d, sampler_reg, tc, vec2(3, 1)); - let _e19 = a; - a = (_e19 + _e18); - let _e23 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3); - let _e24 = a; - a = (_e24 + _e23); - let _e28 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3, vec2(3, 1)); - let _e29 = a; - a = (_e29 + _e28); - let _e34 = textureSampleBias(image_2d, sampler_reg, tc, 2.0, vec2(3, 1)); - let _e35 = a; - a = (_e35 + _e34); - let _e40 = textureSample(image_2d_array, sampler_reg, tc, 0u); - let _e41 = a; - a = (_e41 + _e40); - let _e46 = textureSample(image_2d_array, sampler_reg, tc, 0u, vec2(3, 1)); - let _e47 = a; - a = (_e47 + _e46); - let _e52 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3); - let _e53 = a; - a = (_e53 + _e52); - let _e58 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3, vec2(3, 1)); - let _e59 = a; - a = (_e59 + _e58); - let _e65 = textureSampleBias(image_2d_array, sampler_reg, tc, 0u, 2.0, vec2(3, 1)); - let _e66 = a; - a = (_e66 + _e65); - let _e71 = textureSample(image_2d_array, sampler_reg, tc, 0); - let _e72 = a; - a = (_e72 + _e71); - let _e77 = textureSample(image_2d_array, sampler_reg, tc, 0, vec2(3, 1)); - let _e78 = a; - a = (_e78 + _e77); - let _e83 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3); - let _e84 = a; - a = (_e84 + _e83); - let _e89 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3, vec2(3, 1)); - let _e90 = a; - a = (_e90 + _e89); - let _e96 = textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, vec2(3, 1)); - let _e97 = a; - a = (_e97 + _e96); - let _e102 = textureSample(image_cube_array, sampler_reg, tc3_, 0u); - let _e103 = a; - a = (_e103 + _e102); - let _e108 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0u, 2.3); - let _e109 = a; - a = (_e109 + _e108); - let _e115 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0u, 2.0); - let _e116 = a; - a = (_e116 + _e115); - let _e121 = textureSample(image_cube_array, sampler_reg, tc3_, 0); - let _e122 = a; - a = (_e122 + _e121); - let _e127 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0, 2.3); - let _e128 = a; - a = (_e128 + _e127); - let _e134 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0, 2.0); - let _e135 = a; - a = (_e135 + _e134); - let _e137 = a; - return _e137; + let _e9 = textureSample(image_1d, sampler_reg, tc.x); + let _e10 = a; + a = (_e10 + _e9); + let _e14 = textureSample(image_2d, sampler_reg, tc); + let _e15 = a; + a = (_e15 + _e14); + let _e19 = textureSample(image_2d, sampler_reg, tc, vec2(3, 1)); + let _e20 = a; + a = (_e20 + _e19); + let _e24 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3); + let _e25 = a; + a = (_e25 + _e24); + let _e29 = textureSampleLevel(image_2d, sampler_reg, tc, 2.3, vec2(3, 1)); + let _e30 = a; + a = (_e30 + _e29); + let _e35 = textureSampleBias(image_2d, sampler_reg, tc, 2.0, vec2(3, 1)); + let _e36 = a; + a = (_e36 + _e35); + let _e41 = textureSample(image_2d_array, sampler_reg, tc, 0u); + let _e42 = a; + a = (_e42 + _e41); + let _e47 = textureSample(image_2d_array, sampler_reg, tc, 0u, vec2(3, 1)); + let _e48 = a; + a = (_e48 + _e47); + let _e53 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3); + let _e54 = a; + a = (_e54 + _e53); + let _e59 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0u, 2.3, vec2(3, 1)); + let _e60 = a; + a = (_e60 + _e59); + let _e66 = textureSampleBias(image_2d_array, sampler_reg, tc, 0u, 2.0, vec2(3, 1)); + let _e67 = a; + a = (_e67 + _e66); + let _e72 = textureSample(image_2d_array, sampler_reg, tc, 0); + let _e73 = a; + a = (_e73 + _e72); + let _e78 = textureSample(image_2d_array, sampler_reg, tc, 0, vec2(3, 1)); + let _e79 = a; + a = (_e79 + _e78); + let _e84 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3); + let _e85 = a; + a = (_e85 + _e84); + let _e90 = textureSampleLevel(image_2d_array, sampler_reg, tc, 0, 2.3, vec2(3, 1)); + let _e91 = a; + a = (_e91 + _e90); + let _e97 = textureSampleBias(image_2d_array, sampler_reg, tc, 0, 2.0, vec2(3, 1)); + let _e98 = a; + a = (_e98 + _e97); + let _e103 = textureSample(image_cube_array, sampler_reg, tc3_, 0u); + let _e104 = a; + a = (_e104 + _e103); + let _e109 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0u, 2.3); + let _e110 = a; + a = (_e110 + _e109); + let _e116 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0u, 2.0); + let _e117 = a; + a = (_e117 + _e116); + let _e122 = textureSample(image_cube_array, sampler_reg, tc3_, 0); + let _e123 = a; + a = (_e123 + _e122); + let _e128 = textureSampleLevel(image_cube_array, sampler_reg, tc3_, 0, 2.3); + let _e129 = a; + a = (_e129 + _e128); + let _e135 = textureSampleBias(image_cube_array, sampler_reg, tc3_, 0, 2.0); + let _e136 = a; + a = (_e136 + _e135); + let _e138 = a; + return _e138; } @fragment diff --git a/tests/out/wgsl/type-alias.wgsl b/tests/out/wgsl/type-alias.wgsl index a4a9438eb0..fea2dec108 100644 --- a/tests/out/wgsl/type-alias.wgsl +++ b/tests/out/wgsl/type-alias.wgsl @@ -3,7 +3,7 @@ fn main() { let c = vec3(0.0); let b = vec3(vec2(0.0), 0.0); let d = vec3(vec2(0.0), 0.0); - let e = vec3(vec2(0, 0), 0); + let e = vec3(d); let f = mat2x2(vec2(1.0, 2.0), vec2(3.0, 4.0)); let g = mat3x3(a, a, a); } diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index 637b5372f9..9e5eecccce 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -1759,47 +1759,47 @@ fn assign_to_let() { "###, ); - // check( - // " - // fn f() { - // let a = array(1, 2); - // a[0] = 1; - // } - // ", - // r###"error: invalid left-hand side of assignment - // ┌─ wgsl:3:17 - // │ - // 3 │ let a = array(1, 2); - // │ ^ this is an immutable binding - // 4 │ a[0] = 1; - // │ ^^^^ cannot assign to this expression - // │ - // = note: consider declaring 'a' with `var` instead of `let` - - // "###, - // ); - - // check( - // " - // struct S { a: i32 } - - // fn f() { - // let a = S(10); - // a.a = 20; - // } - // ", - // r###"error: invalid left-hand side of assignment - // ┌─ wgsl:5:17 - // │ - // 5 │ let a = S(10); - // │ ^ this is an immutable binding - // 6 │ a.a = 20; - // │ ^^^ cannot assign to this expression - // │ - // = note: consider declaring 'a' with `var` instead of `let` - - // "###, - // ); + check( + " + fn f() { + let a = array(1, 2); + a[0] = 1; + } + ", + r###"error: invalid left-hand side of assignment + ┌─ wgsl:3:17 + │ +3 │ let a = array(1, 2); + │ ^ this is an immutable binding +4 │ a[0] = 1; + │ ^^^^ cannot assign to this expression + │ + = note: consider declaring 'a' with `var` instead of `let` + +"###, + ); + + check( + " + struct S { a: i32 } + + fn f() { + let a = S(10); + a.a = 20; + } + ", + r###"error: invalid left-hand side of assignment + ┌─ wgsl:5:17 + │ +5 │ let a = S(10); + │ ^ this is an immutable binding +6 │ a.a = 20; + │ ^^^ cannot assign to this expression + │ + = note: consider declaring 'a' with `var` instead of `let` + +"###, + ); } #[test] From f06eee93736c1fa9e83020fe56fb6f25a8f80295 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 20:09:59 +0200 Subject: [PATCH 20/37] [wgsl] test `@workgroup_size` attribute with constants --- tests/in/const-exprs.wgsl | 5 +- tests/out/glsl/const-exprs.main.Compute.glsl | 4 +- tests/out/hlsl/const-exprs.hlsl | 4 +- tests/out/msl/const-exprs.msl | 2 + tests/out/spv/const-exprs.spvasm | 195 ++++++++++--------- tests/out/wgsl/const-exprs.wgsl | 4 +- 6 files changed, 113 insertions(+), 101 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index 49e95a275f..11fee4a41c 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -1,7 +1,10 @@ @group(0) @binding(0) var out: vec4; @group(0) @binding(1) var out2: i32; -@compute @workgroup_size(1) +const TWO: u32 = 2u; +const THREE: i32 = 3i; + +@compute @workgroup_size(TWO, THREE, TWO - 1u) fn main() { swizzle_of_compose(); index_of_compose(); diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index e75ffa6506..8a1c3d45c7 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -3,8 +3,10 @@ precision highp float; precision highp int; -layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +layout(local_size_x = 2, local_size_y = 3, local_size_z = 1) in; +const uint TWO = 2u; +const int THREE = 3; const int FOUR = 4; const int FOUR_ALIAS = 4; const int TEST_CONSTANT_ADDITION = 8; diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 91b82ec56d..08cf89091e 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -1,3 +1,5 @@ +static const uint TWO = 2u; +static const int THREE = 3; static const int FOUR = 4; static const int FOUR_ALIAS = 4; static const int TEST_CONSTANT_ADDITION = 8; @@ -58,7 +60,7 @@ void compose_of_constant() return; } -[numthreads(1, 1, 1)] +[numthreads(2, 3, 1)] void main() { swizzle_of_compose(); diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 5cbc23a006..4e6d67f801 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -4,6 +4,8 @@ using metal::uint; +constant uint TWO = 2u; +constant int THREE = 3; constant int FOUR = 4; constant int FOUR_ALIAS = 4; constant int TEST_CONSTANT_ADDITION = 8; diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index 1f7bf5c8ce..c8d41c59fa 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,127 +1,128 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 82 +; Bound: 83 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %72 "main" -OpExecutionMode %72 LocalSize 1 1 1 -OpDecorate %7 DescriptorSet 0 -OpDecorate %7 Binding 0 -OpDecorate %8 Block -OpMemberDecorate %8 0 Offset 0 +OpEntryPoint GLCompute %73 "main" +OpExecutionMode %73 LocalSize 2 3 1 OpDecorate %10 DescriptorSet 0 -OpDecorate %10 Binding 1 +OpDecorate %10 Binding 0 OpDecorate %11 Block OpMemberDecorate %11 0 Offset 0 +OpDecorate %13 DescriptorSet 0 +OpDecorate %13 Binding 1 +OpDecorate %14 Block +OpMemberDecorate %14 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 -%5 = OpConstant %4 4 -%6 = OpConstant %4 8 -%8 = OpTypeStruct %3 -%9 = OpTypePointer StorageBuffer %8 -%7 = OpVariable %9 StorageBuffer -%11 = OpTypeStruct %4 +%5 = OpTypeInt 32 0 +%6 = OpConstant %5 2 +%7 = OpConstant %4 3 +%8 = OpConstant %4 4 +%9 = OpConstant %4 8 +%11 = OpTypeStruct %3 %12 = OpTypePointer StorageBuffer %11 %10 = OpVariable %12 StorageBuffer -%15 = OpTypeFunction %2 -%16 = OpTypePointer StorageBuffer %3 -%18 = OpTypeInt 32 0 -%17 = OpConstant %18 0 -%20 = OpConstant %4 1 -%21 = OpConstant %4 2 -%22 = OpConstant %4 3 -%23 = OpConstantComposite %3 %5 %22 %21 %20 -%27 = OpTypePointer StorageBuffer %4 -%35 = OpConstant %4 6 -%42 = OpConstant %4 30 -%43 = OpConstant %4 70 -%45 = OpTypePointer Function %4 -%47 = OpConstantNull %4 -%49 = OpConstantNull %4 -%64 = OpConstant %4 -4 -%65 = OpConstantComposite %3 %64 %64 %64 %64 -%14 = OpFunction %2 None %15 -%13 = OpLabel -%19 = OpAccessChain %16 %7 %17 -OpBranch %24 -%24 = OpLabel -OpStore %19 %23 -OpReturn -OpFunctionEnd -%26 = OpFunction %2 None %15 +%14 = OpTypeStruct %4 +%15 = OpTypePointer StorageBuffer %14 +%13 = OpVariable %15 StorageBuffer +%18 = OpTypeFunction %2 +%19 = OpTypePointer StorageBuffer %3 +%20 = OpConstant %5 0 +%22 = OpConstant %4 1 +%23 = OpConstant %4 2 +%24 = OpConstantComposite %3 %8 %7 %23 %22 +%28 = OpTypePointer StorageBuffer %4 +%36 = OpConstant %4 6 +%43 = OpConstant %4 30 +%44 = OpConstant %4 70 +%46 = OpTypePointer Function %4 +%48 = OpConstantNull %4 +%50 = OpConstantNull %4 +%65 = OpConstant %4 -4 +%66 = OpConstantComposite %3 %65 %65 %65 %65 +%17 = OpFunction %2 None %18 +%16 = OpLabel +%21 = OpAccessChain %19 %10 %20 +OpBranch %25 %25 = OpLabel -%28 = OpAccessChain %27 %10 %17 -OpBranch %29 -%29 = OpLabel -%30 = OpLoad %4 %28 -%31 = OpIAdd %4 %30 %21 -OpStore %28 %31 +OpStore %21 %24 OpReturn OpFunctionEnd -%33 = OpFunction %2 None %15 -%32 = OpLabel -%34 = OpAccessChain %27 %10 %17 -OpBranch %36 -%36 = OpLabel -%37 = OpLoad %4 %34 -%38 = OpIAdd %4 %37 %35 -OpStore %34 %38 +%27 = OpFunction %2 None %18 +%26 = OpLabel +%29 = OpAccessChain %28 %13 %20 +OpBranch %30 +%30 = OpLabel +%31 = OpLoad %4 %29 +%32 = OpIAdd %4 %31 %23 +OpStore %29 %32 OpReturn OpFunctionEnd -%40 = OpFunction %2 None %15 -%39 = OpLabel -%46 = OpVariable %45 Function %47 -%50 = OpVariable %45 Function %43 -%44 = OpVariable %45 Function %42 -%48 = OpVariable %45 Function %49 -%41 = OpAccessChain %16 %7 %17 -OpBranch %51 -%51 = OpLabel -%52 = OpLoad %4 %44 -OpStore %46 %52 -%53 = OpLoad %4 %46 -OpStore %48 %53 -%54 = OpLoad %4 %44 -%55 = OpLoad %4 %46 -%56 = OpLoad %4 %48 -%57 = OpLoad %4 %50 -%58 = OpCompositeConstruct %3 %54 %55 %56 %57 -%59 = OpLoad %3 %41 -%60 = OpIAdd %3 %59 %58 -OpStore %41 %60 +%34 = OpFunction %2 None %18 +%33 = OpLabel +%35 = OpAccessChain %28 %13 %20 +OpBranch %37 +%37 = OpLabel +%38 = OpLoad %4 %35 +%39 = OpIAdd %4 %38 %36 +OpStore %35 %39 OpReturn OpFunctionEnd -%62 = OpFunction %2 None %15 -%61 = OpLabel -%63 = OpAccessChain %16 %7 %17 -OpBranch %66 -%66 = OpLabel -OpStore %63 %65 +%41 = OpFunction %2 None %18 +%40 = OpLabel +%47 = OpVariable %46 Function %48 +%51 = OpVariable %46 Function %44 +%45 = OpVariable %46 Function %43 +%49 = OpVariable %46 Function %50 +%42 = OpAccessChain %19 %10 %20 +OpBranch %52 +%52 = OpLabel +%53 = OpLoad %4 %45 +OpStore %47 %53 +%54 = OpLoad %4 %47 +OpStore %49 %54 +%55 = OpLoad %4 %45 +%56 = OpLoad %4 %47 +%57 = OpLoad %4 %49 +%58 = OpLoad %4 %51 +%59 = OpCompositeConstruct %3 %55 %56 %57 %58 +%60 = OpLoad %3 %42 +%61 = OpIAdd %3 %60 %59 +OpStore %42 %61 OpReturn OpFunctionEnd -%68 = OpFunction %2 None %15 +%63 = OpFunction %2 None %18 +%62 = OpLabel +%64 = OpAccessChain %19 %10 %20 +OpBranch %67 %67 = OpLabel -%69 = OpAccessChain %16 %7 %17 -OpBranch %70 -%70 = OpLabel -OpStore %69 %65 +OpStore %64 %66 OpReturn OpFunctionEnd -%72 = OpFunction %2 None %15 +%69 = OpFunction %2 None %18 +%68 = OpLabel +%70 = OpAccessChain %19 %10 %20 +OpBranch %71 %71 = OpLabel -%73 = OpAccessChain %16 %7 %17 -%74 = OpAccessChain %27 %10 %17 -OpBranch %75 -%75 = OpLabel -%76 = OpFunctionCall %2 %14 -%77 = OpFunctionCall %2 %26 -%78 = OpFunctionCall %2 %33 -%79 = OpFunctionCall %2 %40 -%80 = OpFunctionCall %2 %62 -%81 = OpFunctionCall %2 %68 +OpStore %70 %66 +OpReturn +OpFunctionEnd +%73 = OpFunction %2 None %18 +%72 = OpLabel +%74 = OpAccessChain %19 %10 %20 +%75 = OpAccessChain %28 %13 %20 +OpBranch %76 +%76 = OpLabel +%77 = OpFunctionCall %2 %17 +%78 = OpFunctionCall %2 %27 +%79 = OpFunctionCall %2 %34 +%80 = OpFunctionCall %2 %41 +%81 = OpFunctionCall %2 %63 +%82 = OpFunctionCall %2 %69 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 2ddc903aad..df675a8962 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -1,3 +1,5 @@ +const TWO: u32 = 2u; +const THREE: i32 = 3; const FOUR: i32 = 4; const FOUR_ALIAS: i32 = 4; const TEST_CONSTANT_ADDITION: i32 = 8; @@ -54,7 +56,7 @@ fn compose_of_constant() { return; } -@compute @workgroup_size(1, 1, 1) +@compute @workgroup_size(2, 3, 1) fn main() { swizzle_of_compose(); index_of_compose(); From 303a3cd30c75697f338b871b0da8d924784a4111 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 20:11:31 +0200 Subject: [PATCH 21/37] [wgsl] test const evaluation of division and multiplication --- tests/in/const-exprs.wgsl | 5 + tests/out/glsl/const-exprs.main.Compute.glsl | 3 + tests/out/hlsl/const-exprs.hlsl | 3 + tests/out/msl/const-exprs.msl | 3 + tests/out/spv/const-exprs.spvasm | 209 ++++++++++--------- tests/out/wgsl/const-exprs.wgsl | 3 + 6 files changed, 125 insertions(+), 101 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index 11fee4a41c..580eda1848 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -64,3 +64,8 @@ fn splat_of_constant() { fn compose_of_constant() { out = -vec4(FOUR, FOUR, FOUR, FOUR); } + +const PI: f32 = 3.141; +const phi_sun: f32 = PI * 2.0; + +const DIV: vec4f = vec4(4.0 / 9.0, 0.0, 0.0, 0.0); diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 8a1c3d45c7..a9fbb3b77e 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -11,6 +11,9 @@ const int FOUR = 4; const int FOUR_ALIAS = 4; const int TEST_CONSTANT_ADDITION = 8; const int TEST_CONSTANT_ALIAS_ADDITION = 8; +const float PI = 3.141; +const float phi_sun = 6.282; +const vec4 DIV = vec4(0.44444445, 0.0, 0.0, 0.0); layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index 08cf89091e..ed1b864152 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -4,6 +4,9 @@ static const int FOUR = 4; static const int FOUR_ALIAS = 4; static const int TEST_CONSTANT_ADDITION = 8; static const int TEST_CONSTANT_ALIAS_ADDITION = 8; +static const float PI = 3.141; +static const float phi_sun = 6.282; +static const float4 DIV = float4(0.44444445, 0.0, 0.0, 0.0); RWByteAddressBuffer out_ : register(u0); RWByteAddressBuffer out2_ : register(u1); diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 4e6d67f801..1707df1e8e 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -10,6 +10,9 @@ constant int FOUR = 4; constant int FOUR_ALIAS = 4; constant int TEST_CONSTANT_ADDITION = 8; constant int TEST_CONSTANT_ALIAS_ADDITION = 8; +constant float PI = 3.141; +constant float phi_sun = 6.282; +constant metal::float4 DIV = metal::float4(0.44444445, 0.0, 0.0, 0.0); void swizzle_of_compose( device metal::int4& out diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index c8d41c59fa..f4103b8682 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,128 +1,135 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 83 +; Bound: 90 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %73 "main" -OpExecutionMode %73 LocalSize 2 3 1 -OpDecorate %10 DescriptorSet 0 -OpDecorate %10 Binding 0 -OpDecorate %11 Block -OpMemberDecorate %11 0 Offset 0 -OpDecorate %13 DescriptorSet 0 -OpDecorate %13 Binding 1 -OpDecorate %14 Block -OpMemberDecorate %14 0 Offset 0 +OpEntryPoint GLCompute %80 "main" +OpExecutionMode %80 LocalSize 2 3 1 +OpDecorate %17 DescriptorSet 0 +OpDecorate %17 Binding 0 +OpDecorate %18 Block +OpMemberDecorate %18 0 Offset 0 +OpDecorate %20 DescriptorSet 0 +OpDecorate %20 Binding 1 +OpDecorate %21 Block +OpMemberDecorate %21 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 %5 = OpTypeInt 32 0 -%6 = OpConstant %5 2 -%7 = OpConstant %4 3 -%8 = OpConstant %4 4 -%9 = OpConstant %4 8 -%11 = OpTypeStruct %3 -%12 = OpTypePointer StorageBuffer %11 -%10 = OpVariable %12 StorageBuffer -%14 = OpTypeStruct %4 -%15 = OpTypePointer StorageBuffer %14 -%13 = OpVariable %15 StorageBuffer -%18 = OpTypeFunction %2 -%19 = OpTypePointer StorageBuffer %3 -%20 = OpConstant %5 0 -%22 = OpConstant %4 1 -%23 = OpConstant %4 2 -%24 = OpConstantComposite %3 %8 %7 %23 %22 -%28 = OpTypePointer StorageBuffer %4 -%36 = OpConstant %4 6 -%43 = OpConstant %4 30 -%44 = OpConstant %4 70 -%46 = OpTypePointer Function %4 -%48 = OpConstantNull %4 -%50 = OpConstantNull %4 -%65 = OpConstant %4 -4 -%66 = OpConstantComposite %3 %65 %65 %65 %65 -%17 = OpFunction %2 None %18 -%16 = OpLabel -%21 = OpAccessChain %19 %10 %20 -OpBranch %25 -%25 = OpLabel -OpStore %21 %24 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpConstant %5 2 +%9 = OpConstant %4 3 +%10 = OpConstant %4 4 +%11 = OpConstant %4 8 +%12 = OpConstant %6 3.141 +%13 = OpConstant %6 6.282 +%14 = OpConstant %6 0.44444445 +%15 = OpConstant %6 0.0 +%16 = OpConstantComposite %7 %14 %15 %15 %15 +%18 = OpTypeStruct %3 +%19 = OpTypePointer StorageBuffer %18 +%17 = OpVariable %19 StorageBuffer +%21 = OpTypeStruct %4 +%22 = OpTypePointer StorageBuffer %21 +%20 = OpVariable %22 StorageBuffer +%25 = OpTypeFunction %2 +%26 = OpTypePointer StorageBuffer %3 +%27 = OpConstant %5 0 +%29 = OpConstant %4 1 +%30 = OpConstant %4 2 +%31 = OpConstantComposite %3 %10 %9 %30 %29 +%35 = OpTypePointer StorageBuffer %4 +%43 = OpConstant %4 6 +%50 = OpConstant %4 30 +%51 = OpConstant %4 70 +%53 = OpTypePointer Function %4 +%55 = OpConstantNull %4 +%57 = OpConstantNull %4 +%72 = OpConstant %4 -4 +%73 = OpConstantComposite %3 %72 %72 %72 %72 +%24 = OpFunction %2 None %25 +%23 = OpLabel +%28 = OpAccessChain %26 %17 %27 +OpBranch %32 +%32 = OpLabel +OpStore %28 %31 OpReturn OpFunctionEnd -%27 = OpFunction %2 None %18 -%26 = OpLabel -%29 = OpAccessChain %28 %13 %20 -OpBranch %30 -%30 = OpLabel -%31 = OpLoad %4 %29 -%32 = OpIAdd %4 %31 %23 -OpStore %29 %32 -OpReturn -OpFunctionEnd -%34 = OpFunction %2 None %18 +%34 = OpFunction %2 None %25 %33 = OpLabel -%35 = OpAccessChain %28 %13 %20 +%36 = OpAccessChain %35 %20 %27 OpBranch %37 %37 = OpLabel -%38 = OpLoad %4 %35 -%39 = OpIAdd %4 %38 %36 -OpStore %35 %39 +%38 = OpLoad %4 %36 +%39 = OpIAdd %4 %38 %30 +OpStore %36 %39 OpReturn OpFunctionEnd -%41 = OpFunction %2 None %18 +%41 = OpFunction %2 None %25 %40 = OpLabel -%47 = OpVariable %46 Function %48 -%51 = OpVariable %46 Function %44 -%45 = OpVariable %46 Function %43 -%49 = OpVariable %46 Function %50 -%42 = OpAccessChain %19 %10 %20 -OpBranch %52 -%52 = OpLabel -%53 = OpLoad %4 %45 -OpStore %47 %53 -%54 = OpLoad %4 %47 -OpStore %49 %54 -%55 = OpLoad %4 %45 -%56 = OpLoad %4 %47 -%57 = OpLoad %4 %49 -%58 = OpLoad %4 %51 -%59 = OpCompositeConstruct %3 %55 %56 %57 %58 -%60 = OpLoad %3 %42 -%61 = OpIAdd %3 %60 %59 -OpStore %42 %61 +%42 = OpAccessChain %35 %20 %27 +OpBranch %44 +%44 = OpLabel +%45 = OpLoad %4 %42 +%46 = OpIAdd %4 %45 %43 +OpStore %42 %46 +OpReturn +OpFunctionEnd +%48 = OpFunction %2 None %25 +%47 = OpLabel +%54 = OpVariable %53 Function %55 +%58 = OpVariable %53 Function %51 +%52 = OpVariable %53 Function %50 +%56 = OpVariable %53 Function %57 +%49 = OpAccessChain %26 %17 %27 +OpBranch %59 +%59 = OpLabel +%60 = OpLoad %4 %52 +OpStore %54 %60 +%61 = OpLoad %4 %54 +OpStore %56 %61 +%62 = OpLoad %4 %52 +%63 = OpLoad %4 %54 +%64 = OpLoad %4 %56 +%65 = OpLoad %4 %58 +%66 = OpCompositeConstruct %3 %62 %63 %64 %65 +%67 = OpLoad %3 %49 +%68 = OpIAdd %3 %67 %66 +OpStore %49 %68 OpReturn OpFunctionEnd -%63 = OpFunction %2 None %18 -%62 = OpLabel -%64 = OpAccessChain %19 %10 %20 -OpBranch %67 -%67 = OpLabel -OpStore %64 %66 +%70 = OpFunction %2 None %25 +%69 = OpLabel +%71 = OpAccessChain %26 %17 %27 +OpBranch %74 +%74 = OpLabel +OpStore %71 %73 OpReturn OpFunctionEnd -%69 = OpFunction %2 None %18 -%68 = OpLabel -%70 = OpAccessChain %19 %10 %20 -OpBranch %71 -%71 = OpLabel -OpStore %70 %66 +%76 = OpFunction %2 None %25 +%75 = OpLabel +%77 = OpAccessChain %26 %17 %27 +OpBranch %78 +%78 = OpLabel +OpStore %77 %73 OpReturn OpFunctionEnd -%73 = OpFunction %2 None %18 -%72 = OpLabel -%74 = OpAccessChain %19 %10 %20 -%75 = OpAccessChain %28 %13 %20 -OpBranch %76 -%76 = OpLabel -%77 = OpFunctionCall %2 %17 -%78 = OpFunctionCall %2 %27 -%79 = OpFunctionCall %2 %34 -%80 = OpFunctionCall %2 %41 -%81 = OpFunctionCall %2 %63 -%82 = OpFunctionCall %2 %69 +%80 = OpFunction %2 None %25 +%79 = OpLabel +%81 = OpAccessChain %26 %17 %27 +%82 = OpAccessChain %35 %20 %27 +OpBranch %83 +%83 = OpLabel +%84 = OpFunctionCall %2 %24 +%85 = OpFunctionCall %2 %34 +%86 = OpFunctionCall %2 %41 +%87 = OpFunctionCall %2 %48 +%88 = OpFunctionCall %2 %70 +%89 = OpFunctionCall %2 %76 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index df675a8962..532883d9b1 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -4,6 +4,9 @@ const FOUR: i32 = 4; const FOUR_ALIAS: i32 = 4; const TEST_CONSTANT_ADDITION: i32 = 8; const TEST_CONSTANT_ALIAS_ADDITION: i32 = 8; +const PI: f32 = 3.141; +const phi_sun: f32 = 6.282; +const DIV: vec4 = vec4(0.44444445, 0.0, 0.0, 0.0); @group(0) @binding(0) var out: vec4; From 82a36133b80bb745d81040334ac56516f85006cb Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 29 Sep 2023 20:12:14 +0200 Subject: [PATCH 22/37] [wgsl] test usage of constants in switch cases --- tests/in/const-exprs.wgsl | 13 ++ tests/out/glsl/const-exprs.main.Compute.glsl | 20 ++ tests/out/hlsl/const-exprs.hlsl | 21 ++ tests/out/msl/const-exprs.msl | 22 ++ tests/out/spv/const-exprs.spvasm | 210 +++++++++++-------- tests/out/wgsl/const-exprs.wgsl | 20 ++ 6 files changed, 213 insertions(+), 93 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index 580eda1848..e388c378ad 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -69,3 +69,16 @@ const PI: f32 = 3.141; const phi_sun: f32 = PI * 2.0; const DIV: vec4f = vec4(4.0 / 9.0, 0.0, 0.0, 0.0); + +const TEXTURE_KIND_REGULAR: i32 = 0; +const TEXTURE_KIND_WARP: i32 = 1; +const TEXTURE_KIND_SKY: i32 = 2; + +fn map_texture_kind(texture_kind: i32) -> u32 { + switch (texture_kind) { + case TEXTURE_KIND_REGULAR: { return 10u; } + case TEXTURE_KIND_WARP: { return 20u; } + case TEXTURE_KIND_SKY: { return 30u; } + default: { return 0u; } + } +} diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index a9fbb3b77e..738d0d7ef5 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -14,6 +14,9 @@ const int TEST_CONSTANT_ALIAS_ADDITION = 8; const float PI = 3.141; const float phi_sun = 6.282; const vec4 DIV = vec4(0.44444445, 0.0, 0.0, 0.0); +const int TEXTURE_KIND_REGULAR = 0; +const int TEXTURE_KIND_WARP = 1; +const int TEXTURE_KIND_SKY = 2; layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; @@ -65,6 +68,23 @@ void compose_of_constant() { return; } +uint map_texture_kind(int texture_kind) { + switch(texture_kind) { + case 0: { + return 10u; + } + case 1: { + return 20u; + } + case 2: { + return 30u; + } + default: { + return 0u; + } + } +} + void main() { swizzle_of_compose(); index_of_compose(); diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index ed1b864152..f3f59a5840 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -7,6 +7,9 @@ static const int TEST_CONSTANT_ALIAS_ADDITION = 8; static const float PI = 3.141; static const float phi_sun = 6.282; static const float4 DIV = float4(0.44444445, 0.0, 0.0, 0.0); +static const int TEXTURE_KIND_REGULAR = 0; +static const int TEXTURE_KIND_WARP = 1; +static const int TEXTURE_KIND_SKY = 2; RWByteAddressBuffer out_ : register(u0); RWByteAddressBuffer out2_ : register(u1); @@ -63,6 +66,24 @@ void compose_of_constant() return; } +uint map_texture_kind(int texture_kind) +{ + switch(texture_kind) { + case 0: { + return 10u; + } + case 1: { + return 20u; + } + case 2: { + return 30u; + } + default: { + return 0u; + } + } +} + [numthreads(2, 3, 1)] void main() { diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 1707df1e8e..48299e767b 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -13,6 +13,9 @@ constant int TEST_CONSTANT_ALIAS_ADDITION = 8; constant float PI = 3.141; constant float phi_sun = 6.282; constant metal::float4 DIV = metal::float4(0.44444445, 0.0, 0.0, 0.0); +constant int TEXTURE_KIND_REGULAR = 0; +constant int TEXTURE_KIND_WARP = 1; +constant int TEXTURE_KIND_SKY = 2; void swizzle_of_compose( device metal::int4& out @@ -71,6 +74,25 @@ void compose_of_constant( return; } +uint map_texture_kind( + int texture_kind +) { + switch(texture_kind) { + case 0: { + return 10u; + } + case 1: { + return 20u; + } + case 2: { + return 30u; + } + default: { + return 0u; + } + } +} + kernel void main_( device metal::int4& out [[user(fake0)]] , device int& out2_ [[user(fake0)]] diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index f4103b8682..b05f0f7df9 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,21 +1,21 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 90 +; Bound: 105 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %80 "main" -OpExecutionMode %80 LocalSize 2 3 1 -OpDecorate %17 DescriptorSet 0 -OpDecorate %17 Binding 0 -OpDecorate %18 Block -OpMemberDecorate %18 0 Offset 0 +OpEntryPoint GLCompute %95 "main" +OpExecutionMode %95 LocalSize 2 3 1 OpDecorate %20 DescriptorSet 0 -OpDecorate %20 Binding 1 +OpDecorate %20 Binding 0 OpDecorate %21 Block OpMemberDecorate %21 0 Offset 0 +OpDecorate %23 DescriptorSet 0 +OpDecorate %23 Binding 1 +OpDecorate %24 Block +OpMemberDecorate %24 0 Offset 0 %2 = OpTypeVoid %4 = OpTypeInt 32 1 %3 = OpTypeVector %4 4 @@ -31,105 +31,129 @@ OpMemberDecorate %21 0 Offset 0 %14 = OpConstant %6 0.44444445 %15 = OpConstant %6 0.0 %16 = OpConstantComposite %7 %14 %15 %15 %15 -%18 = OpTypeStruct %3 -%19 = OpTypePointer StorageBuffer %18 -%17 = OpVariable %19 StorageBuffer -%21 = OpTypeStruct %4 +%17 = OpConstant %4 0 +%18 = OpConstant %4 1 +%19 = OpConstant %4 2 +%21 = OpTypeStruct %3 %22 = OpTypePointer StorageBuffer %21 %20 = OpVariable %22 StorageBuffer -%25 = OpTypeFunction %2 -%26 = OpTypePointer StorageBuffer %3 -%27 = OpConstant %5 0 -%29 = OpConstant %4 1 -%30 = OpConstant %4 2 -%31 = OpConstantComposite %3 %10 %9 %30 %29 -%35 = OpTypePointer StorageBuffer %4 -%43 = OpConstant %4 6 -%50 = OpConstant %4 30 -%51 = OpConstant %4 70 -%53 = OpTypePointer Function %4 -%55 = OpConstantNull %4 -%57 = OpConstantNull %4 -%72 = OpConstant %4 -4 -%73 = OpConstantComposite %3 %72 %72 %72 %72 -%24 = OpFunction %2 None %25 -%23 = OpLabel -%28 = OpAccessChain %26 %17 %27 -OpBranch %32 -%32 = OpLabel -OpStore %28 %31 -OpReturn -OpFunctionEnd -%34 = OpFunction %2 None %25 +%24 = OpTypeStruct %4 +%25 = OpTypePointer StorageBuffer %24 +%23 = OpVariable %25 StorageBuffer +%28 = OpTypeFunction %2 +%29 = OpTypePointer StorageBuffer %3 +%30 = OpConstant %5 0 +%32 = OpConstantComposite %3 %10 %9 %19 %18 +%36 = OpTypePointer StorageBuffer %4 +%44 = OpConstant %4 6 +%51 = OpConstant %4 30 +%52 = OpConstant %4 70 +%54 = OpTypePointer Function %4 +%56 = OpConstantNull %4 +%58 = OpConstantNull %4 +%73 = OpConstant %4 -4 +%74 = OpConstantComposite %3 %73 %73 %73 %73 +%83 = OpTypeFunction %5 %4 +%84 = OpConstant %5 10 +%85 = OpConstant %5 20 +%86 = OpConstant %5 30 +%93 = OpConstantNull %5 +%27 = OpFunction %2 None %28 +%26 = OpLabel +%31 = OpAccessChain %29 %20 %30 +OpBranch %33 %33 = OpLabel -%36 = OpAccessChain %35 %20 %27 -OpBranch %37 -%37 = OpLabel -%38 = OpLoad %4 %36 -%39 = OpIAdd %4 %38 %30 -OpStore %36 %39 +OpStore %31 %32 OpReturn OpFunctionEnd -%41 = OpFunction %2 None %25 -%40 = OpLabel -%42 = OpAccessChain %35 %20 %27 -OpBranch %44 -%44 = OpLabel -%45 = OpLoad %4 %42 -%46 = OpIAdd %4 %45 %43 -OpStore %42 %46 +%35 = OpFunction %2 None %28 +%34 = OpLabel +%37 = OpAccessChain %36 %23 %30 +OpBranch %38 +%38 = OpLabel +%39 = OpLoad %4 %37 +%40 = OpIAdd %4 %39 %19 +OpStore %37 %40 OpReturn OpFunctionEnd -%48 = OpFunction %2 None %25 -%47 = OpLabel -%54 = OpVariable %53 Function %55 -%58 = OpVariable %53 Function %51 -%52 = OpVariable %53 Function %50 -%56 = OpVariable %53 Function %57 -%49 = OpAccessChain %26 %17 %27 -OpBranch %59 -%59 = OpLabel -%60 = OpLoad %4 %52 -OpStore %54 %60 -%61 = OpLoad %4 %54 -OpStore %56 %61 -%62 = OpLoad %4 %52 -%63 = OpLoad %4 %54 -%64 = OpLoad %4 %56 -%65 = OpLoad %4 %58 -%66 = OpCompositeConstruct %3 %62 %63 %64 %65 -%67 = OpLoad %3 %49 -%68 = OpIAdd %3 %67 %66 -OpStore %49 %68 +%42 = OpFunction %2 None %28 +%41 = OpLabel +%43 = OpAccessChain %36 %23 %30 +OpBranch %45 +%45 = OpLabel +%46 = OpLoad %4 %43 +%47 = OpIAdd %4 %46 %44 +OpStore %43 %47 OpReturn OpFunctionEnd -%70 = OpFunction %2 None %25 -%69 = OpLabel -%71 = OpAccessChain %26 %17 %27 -OpBranch %74 -%74 = OpLabel -OpStore %71 %73 +%49 = OpFunction %2 None %28 +%48 = OpLabel +%55 = OpVariable %54 Function %56 +%59 = OpVariable %54 Function %52 +%53 = OpVariable %54 Function %51 +%57 = OpVariable %54 Function %58 +%50 = OpAccessChain %29 %20 %30 +OpBranch %60 +%60 = OpLabel +%61 = OpLoad %4 %53 +OpStore %55 %61 +%62 = OpLoad %4 %55 +OpStore %57 %62 +%63 = OpLoad %4 %53 +%64 = OpLoad %4 %55 +%65 = OpLoad %4 %57 +%66 = OpLoad %4 %59 +%67 = OpCompositeConstruct %3 %63 %64 %65 %66 +%68 = OpLoad %3 %50 +%69 = OpIAdd %3 %68 %67 +OpStore %50 %69 OpReturn OpFunctionEnd -%76 = OpFunction %2 None %25 +%71 = OpFunction %2 None %28 +%70 = OpLabel +%72 = OpAccessChain %29 %20 %30 +OpBranch %75 %75 = OpLabel -%77 = OpAccessChain %26 %17 %27 -OpBranch %78 -%78 = OpLabel -OpStore %77 %73 +OpStore %72 %74 OpReturn OpFunctionEnd -%80 = OpFunction %2 None %25 +%77 = OpFunction %2 None %28 +%76 = OpLabel +%78 = OpAccessChain %29 %20 %30 +OpBranch %79 %79 = OpLabel -%81 = OpAccessChain %26 %17 %27 -%82 = OpAccessChain %35 %20 %27 -OpBranch %83 -%83 = OpLabel -%84 = OpFunctionCall %2 %24 -%85 = OpFunctionCall %2 %34 -%86 = OpFunctionCall %2 %41 -%87 = OpFunctionCall %2 %48 -%88 = OpFunctionCall %2 %70 -%89 = OpFunctionCall %2 %76 +OpStore %78 %74 +OpReturn +OpFunctionEnd +%82 = OpFunction %5 None %83 +%81 = OpFunctionParameter %4 +%80 = OpLabel +OpBranch %87 +%87 = OpLabel +OpSelectionMerge %88 None +OpSwitch %81 %92 0 %89 1 %90 2 %91 +%89 = OpLabel +OpReturnValue %84 +%90 = OpLabel +OpReturnValue %85 +%91 = OpLabel +OpReturnValue %86 +%92 = OpLabel +OpReturnValue %30 +%88 = OpLabel +OpReturnValue %93 +OpFunctionEnd +%95 = OpFunction %2 None %28 +%94 = OpLabel +%96 = OpAccessChain %29 %20 %30 +%97 = OpAccessChain %36 %23 %30 +OpBranch %98 +%98 = OpLabel +%99 = OpFunctionCall %2 %27 +%100 = OpFunctionCall %2 %35 +%101 = OpFunctionCall %2 %42 +%102 = OpFunctionCall %2 %49 +%103 = OpFunctionCall %2 %71 +%104 = OpFunctionCall %2 %77 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 532883d9b1..569d082641 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -7,6 +7,9 @@ const TEST_CONSTANT_ALIAS_ADDITION: i32 = 8; const PI: f32 = 3.141; const phi_sun: f32 = 6.282; const DIV: vec4 = vec4(0.44444445, 0.0, 0.0, 0.0); +const TEXTURE_KIND_REGULAR: i32 = 0; +const TEXTURE_KIND_WARP: i32 = 1; +const TEXTURE_KIND_SKY: i32 = 2; @group(0) @binding(0) var out: vec4; @@ -59,6 +62,23 @@ fn compose_of_constant() { return; } +fn map_texture_kind(texture_kind: i32) -> u32 { + switch texture_kind { + case 0: { + return 10u; + } + case 1: { + return 20u; + } + case 2: { + return 30u; + } + default: { + return 0u; + } + } +} + @compute @workgroup_size(2, 3, 1) fn main() { swizzle_of_compose(); From b46ea491b7d35ce72ed2c5c8ce1552739107de7f Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:31:02 +0200 Subject: [PATCH 23/37] [const-eval] add wgsl/glsl behavior switch to evaluator --- src/front/glsl/context.rs | 4 +- src/front/wgsl/lower/mod.rs | 4 +- src/proc/constant_evaluator.rs | 120 +++++++++++++++++++++++++-------- 3 files changed, 97 insertions(+), 31 deletions(-) diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 871d110c76..0eceb24e4d 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -249,9 +249,9 @@ impl<'a> Context<'a> { pub fn add_expression(&mut self, expr: Expression, meta: Span) -> Result> { let mut eval = if self.is_const { - crate::proc::ConstantEvaluator::for_module(self.module) + crate::proc::ConstantEvaluator::for_glsl_module(self.module) } else { - crate::proc::ConstantEvaluator::for_function( + crate::proc::ConstantEvaluator::for_glsl_function( self.module, &mut self.expressions, &mut self.expression_constness, diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index fe0c4f92d6..94118e65ef 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -340,7 +340,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { ) -> Result, Error<'source>> { match self.expr_type { ExpressionContextType::Runtime(ref mut rctx) => { - let mut eval = ConstantEvaluator::for_function( + let mut eval = ConstantEvaluator::for_wgsl_function( self.module, rctx.naga_expressions, rctx.expression_constness, @@ -354,7 +354,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } ExpressionContextType::Constant => { - let mut eval = ConstantEvaluator::for_module(self.module); + let mut eval = ConstantEvaluator::for_wgsl_module(self.module); eval.try_eval_and_append(&expr, span) .map_err(|e| Error::ConstantEvaluatorError(e, span)) } diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 6453989b38..05d657cd9e 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -4,8 +4,15 @@ use crate::{ UnaryOperator, }; +#[derive(Debug)] +enum Behavior { + Wgsl, + Glsl, +} + #[derive(Debug)] pub struct ConstantEvaluator<'a> { + behavior: Behavior, types: &'a mut UniqueArena, constants: &'a Arena, expressions: &'a mut Arena, @@ -109,6 +116,8 @@ pub enum ConstantEvaluatorError { InvalidAccessIndexTy, #[error("Constants don't support bitcasts")] Bitcast, + #[error("Constants don't support array length expressions")] + ArrayLength, #[error("Cannot cast type")] InvalidCastArg, #[error("Cannot apply the unary op to the argument")] @@ -131,20 +140,18 @@ pub enum ConstantEvaluatorError { NotImplemented(String), } -// Access -// AccessIndex -// Splat -// Swizzle -// Unary -// Binary -// Select -// Relational -// Math -// As - impl<'a> ConstantEvaluator<'a> { - pub fn for_module(module: &'a mut crate::Module) -> Self { + pub fn for_wgsl_module(module: &'a mut crate::Module) -> Self { + Self::for_module(Behavior::Wgsl, module) + } + + pub fn for_glsl_module(module: &'a mut crate::Module) -> Self { + Self::for_module(Behavior::Glsl, module) + } + + fn for_module(behavior: Behavior, module: &'a mut crate::Module) -> Self { Self { + behavior, types: &mut module.types, constants: &module.constants, expressions: &mut module.const_expressions, @@ -152,7 +159,42 @@ impl<'a> ConstantEvaluator<'a> { } } - pub fn for_function( + pub fn for_wgsl_function( + module: &'a mut crate::Module, + expressions: &'a mut Arena, + expression_constness: &'a mut ExpressionConstnessTracker, + emitter: &'a mut super::Emitter, + block: &'a mut crate::Block, + ) -> Self { + Self::for_function( + Behavior::Wgsl, + module, + expressions, + expression_constness, + emitter, + block, + ) + } + + pub fn for_glsl_function( + module: &'a mut crate::Module, + expressions: &'a mut Arena, + expression_constness: &'a mut ExpressionConstnessTracker, + emitter: &'a mut super::Emitter, + block: &'a mut crate::Block, + ) -> Self { + Self::for_function( + Behavior::Glsl, + module, + expressions, + expression_constness, + emitter, + block, + ) + } + + fn for_function( + behavior: Behavior, module: &'a mut crate::Module, expressions: &'a mut Arena, expression_constness: &'a mut ExpressionConstnessTracker, @@ -160,6 +202,7 @@ impl<'a> ConstantEvaluator<'a> { block: &'a mut crate::Block, ) -> Self { Self { + behavior, types: &mut module.types, constants: &module.constants, expressions, @@ -288,20 +331,36 @@ impl<'a> ConstantEvaluator<'a> { match convert { Some(width) => self.cast(expr, kind, width, span), - None => Err(ConstantEvaluatorError::Bitcast), + None => match self.behavior { + Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented( + "bitcast built-in function".into(), + )), + Behavior::Glsl => Err(ConstantEvaluatorError::Bitcast), + }, } } - Expression::ArrayLength(expr) => { - let expr = self.check_and_get(expr)?; - - self.array_length(expr, span) - } - + Expression::Select { .. } => match self.behavior { + Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented( + "select built-in function".into(), + )), + Behavior::Glsl => Err(ConstantEvaluatorError::Select), + }, + Expression::Relational { fun, .. } => match self.behavior { + Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented(format!( + "{fun:?} built-in function" + ))), + Behavior::Glsl => Err(ConstantEvaluatorError::Relational), + }, + Expression::ArrayLength(expr) => match self.behavior { + Behavior::Wgsl => Err(ConstantEvaluatorError::ArrayLength), + Behavior::Glsl => { + let expr = self.check_and_get(expr)?; + self.array_length(expr, span) + } + }, Expression::Load { .. } => Err(ConstantEvaluatorError::Load), - Expression::Select { .. } => Err(ConstantEvaluatorError::Select), Expression::LocalVariable(_) => Err(ConstantEvaluatorError::LocalVariable), Expression::Derivative { .. } => Err(ConstantEvaluatorError::Derivative), - Expression::Relational { .. } => Err(ConstantEvaluatorError::Relational), Expression::CallResult { .. } => Err(ConstantEvaluatorError::Call), Expression::WorkGroupUniformLoadResult { .. } => { Err(ConstantEvaluatorError::WorkGroupUniformLoadResult) @@ -468,16 +527,18 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidMathArg), }, _ => { - return Err(ConstantEvaluatorError::NotImplemented(format!( - "{fun:?} applied to vector values" - ))) + return Err(ConstantEvaluatorError::NotImplemented( + "clamp built-in function with vector values".into(), + )) } }; let expr = Expression::Literal(literal); Ok(self.register_evaluated_expr(expr, span)) } - _ => Err(ConstantEvaluatorError::NotImplemented(format!("{fun:?}"))), + fun => Err(ConstantEvaluatorError::NotImplemented(format!( + "{fun:?} built-in function" + ))), } } @@ -999,7 +1060,7 @@ mod tests { UniqueArena, VectorSize, }; - use super::ConstantEvaluator; + use super::{Behavior, ConstantEvaluator}; #[test] fn nan_handling() { @@ -1100,6 +1161,7 @@ mod tests { }; let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, types: &mut types, constants: &constants, expressions: &mut const_expressions, @@ -1186,6 +1248,7 @@ mod tests { }; let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, types: &mut types, constants: &constants, expressions: &mut const_expressions, @@ -1304,6 +1367,7 @@ mod tests { let base = const_expressions.append(Expression::Constant(h), Default::default()); let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, types: &mut types, constants: &constants, expressions: &mut const_expressions, @@ -1398,6 +1462,7 @@ mod tests { let h_expr = const_expressions.append(Expression::Constant(h), Default::default()); let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, types: &mut types, constants: &constants, expressions: &mut const_expressions, @@ -1481,6 +1546,7 @@ mod tests { let h_expr = const_expressions.append(Expression::Constant(h), Default::default()); let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, types: &mut types, constants: &constants, expressions: &mut const_expressions, From d87231bcea0c6b84255fa08a619985a8cd760145 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:56:37 +0200 Subject: [PATCH 24/37] [const-eval] check number of arguments for math functions --- src/proc/constant_evaluator.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 05d657cd9e..43aae48d2b 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -126,6 +126,8 @@ pub enum ConstantEvaluatorError { InvalidBinaryOpArgs, #[error("Cannot apply math function to type")] InvalidMathArg, + #[error("{0:?} built-in function expects {1:?} arguments but {2:?} were supplied")] + InvalidMathArgCount(crate::MathFunction, usize, usize), #[error("Splat is defined only on scalar values")] SplatScalarOnly, #[error("Can only swizzle vector constants")] @@ -486,6 +488,19 @@ impl<'a> ConstantEvaluator<'a> { fun: crate::MathFunction, span: Span, ) -> Result, ConstantEvaluatorError> { + let expected = fun.argument_count(); + let given = Some(arg) + .into_iter() + .chain(arg1) + .chain(arg2) + .chain(arg3) + .count(); + if expected != given { + return Err(ConstantEvaluatorError::InvalidMathArgCount( + fun, expected, given, + )); + } + let const0 = &self.expressions[arg]; let const1 = arg1.map(|arg| &self.expressions[arg]); let const2 = arg2.map(|arg| &self.expressions[arg]); From c24ab867211411ca98b7c0e8a420d6995f777d45 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:29:06 +0200 Subject: [PATCH 25/37] [const-eval] account for `ZeroValue` index for `AccessIndex` expression --- src/proc/constant_evaluator.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 43aae48d2b..3b0fd78602 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -632,6 +632,17 @@ impl<'a> ConstantEvaluator<'a> { fn constant_index(&self, expr: Handle) -> Result { match self.expressions[expr] { + Expression::ZeroValue(ty) + if matches!( + self.types[ty].inner, + crate::TypeInner::Scalar { + kind: crate::ScalarKind::Uint, + .. + } + ) => + { + Ok(0) + } Expression::Literal(Literal::U32(index)) => Ok(index as usize), _ => Err(ConstantEvaluatorError::InvalidAccessIndexTy), } From f219e9323cc7b1e81c79bd71a12e15cc228cef11 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:34:13 +0200 Subject: [PATCH 26/37] [const-eval] implement `pow` & `clamp` built-in functions properly --- src/proc/constant_evaluator.rs | 275 ++++++++++++++++++++------------- 1 file changed, 168 insertions(+), 107 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 3b0fd78602..9ed068be7e 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -128,6 +128,8 @@ pub enum ConstantEvaluatorError { InvalidMathArg, #[error("{0:?} built-in function expects {1:?} arguments but {2:?} were supplied")] InvalidMathArgCount(crate::MathFunction, usize, usize), + #[error("value of `low` is greater than `high` for clamp built-in function")] + InvalidClamp, #[error("Splat is defined only on scalar values")] SplatScalarOnly, #[error("Can only swizzle vector constants")] @@ -501,60 +503,181 @@ impl<'a> ConstantEvaluator<'a> { )); } - let const0 = &self.expressions[arg]; - let const1 = arg1.map(|arg| &self.expressions[arg]); - let const2 = arg2.map(|arg| &self.expressions[arg]); - let _const3 = arg3.map(|arg| &self.expressions[arg]); - match fun { - crate::MathFunction::Pow => { - let literal = match (const0, const1.unwrap()) { - (&Expression::Literal(value0), &Expression::Literal(value1)) => { - match (value0, value1) { - (Literal::I32(a), Literal::I32(b)) => Literal::I32(a.pow(b as u32)), - (Literal::U32(a), Literal::U32(b)) => Literal::U32(a.pow(b)), - (Literal::F32(a), Literal::F32(b)) => Literal::F32(a.powf(b)), - _ => return Err(ConstantEvaluatorError::InvalidMathArg), - } + crate::MathFunction::Pow => self.math_pow(arg, arg1.unwrap(), span), + crate::MathFunction::Clamp => self.math_clamp(arg, arg1.unwrap(), arg2.unwrap(), span), + fun => Err(ConstantEvaluatorError::NotImplemented(format!( + "{fun:?} built-in function" + ))), + } + } + + fn math_pow( + &mut self, + e1: Handle, + e2: Handle, + span: Span, + ) -> Result, ConstantEvaluatorError> { + let e1 = self.eval_zero_value_and_splat(e1, span)?; + let e2 = self.eval_zero_value_and_splat(e2, span)?; + + let expr = match (&self.expressions[e1], &self.expressions[e2]) { + (&Expression::Literal(Literal::F32(a)), &Expression::Literal(Literal::F32(b))) => { + Expression::Literal(Literal::F32(a.powf(b))) + } + ( + &Expression::Compose { + components: ref src_components0, + ty: ty0, + }, + &Expression::Compose { + components: ref src_components1, + ty: ty1, + }, + ) if ty0 == ty1 + && matches!( + self.types[ty0].inner, + crate::TypeInner::Vector { + kind: crate::ScalarKind::Float, + .. } - _ => return Err(ConstantEvaluatorError::InvalidMathArg), - }; + ) => + { + let mut components: Vec<_> = crate::proc::flatten_compose( + ty0, + src_components0, + self.expressions, + self.types, + ) + .chain(crate::proc::flatten_compose( + ty1, + src_components1, + self.expressions, + self.types, + )) + .collect(); + + let mid = components.len() / 2; + let (first, last) = components.split_at_mut(mid); + for (a, b) in first.iter_mut().zip(&*last) { + *a = self.math_pow(*a, *b, span)?; + } + components.truncate(mid); - let expr = Expression::Literal(literal); - Ok(self.register_evaluated_expr(expr, span)) + Expression::Compose { + ty: ty0, + components, + } } - crate::MathFunction::Clamp => { - let literal = match (const0, const1.unwrap(), const2.unwrap()) { - ( - &Expression::Literal(value0), - &Expression::Literal(value1), - &Expression::Literal(value2), - ) => match (value0, value1, value2) { - (Literal::I32(a), Literal::I32(b), Literal::I32(c)) => { - Literal::I32(a.clamp(b, c)) + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }; + + Ok(self.register_evaluated_expr(expr, span)) + } + + fn math_clamp( + &mut self, + e: Handle, + low: Handle, + high: Handle, + span: Span, + ) -> Result, ConstantEvaluatorError> { + let e = self.eval_zero_value_and_splat(e, span)?; + let low = self.eval_zero_value_and_splat(low, span)?; + let high = self.eval_zero_value_and_splat(high, span)?; + + let expr = match ( + &self.expressions[e], + &self.expressions[low], + &self.expressions[high], + ) { + (&Expression::Literal(e), &Expression::Literal(low), &Expression::Literal(high)) => { + let literal = match (e, low, high) { + (Literal::I32(e), Literal::I32(low), Literal::I32(high)) => { + if low > high { + return Err(ConstantEvaluatorError::InvalidClamp); + } else { + Literal::I32(e.clamp(low, high)) } - (Literal::U32(a), Literal::U32(b), Literal::U32(c)) => { - Literal::U32(a.clamp(b, c)) + } + (Literal::U32(e), Literal::U32(low), Literal::U32(high)) => { + if low > high { + return Err(ConstantEvaluatorError::InvalidClamp); + } else { + Literal::U32(e.clamp(low, high)) } - (Literal::F32(a), Literal::F32(b), Literal::F32(c)) => { - Literal::F32(glsl_float_clamp(a, b, c)) + } + (Literal::F32(e), Literal::F32(low), Literal::F32(high)) => { + if low > high { + return Err(ConstantEvaluatorError::InvalidClamp); + } else { + Literal::F32(e.clamp(low, high)) } - _ => return Err(ConstantEvaluatorError::InvalidMathArg), - }, - _ => { - return Err(ConstantEvaluatorError::NotImplemented( - "clamp built-in function with vector values".into(), - )) } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), }; + Expression::Literal(literal) + } + ( + &Expression::Compose { + components: ref src_components0, + ty: ty0, + }, + &Expression::Compose { + components: ref src_components1, + ty: ty1, + }, + &Expression::Compose { + components: ref src_components2, + ty: ty2, + }, + ) if ty0 == ty1 + && ty0 == ty2 + && matches!( + self.types[ty0].inner, + crate::TypeInner::Vector { + kind: crate::ScalarKind::Float, + .. + } + ) => + { + let mut components: Vec<_> = crate::proc::flatten_compose( + ty0, + src_components0, + self.expressions, + self.types, + ) + .chain(crate::proc::flatten_compose( + ty1, + src_components1, + self.expressions, + self.types, + )) + .chain(crate::proc::flatten_compose( + ty2, + src_components2, + self.expressions, + self.types, + )) + .collect(); + + let chunk_size = components.len() / 3; + let (es, rem) = components.split_at_mut(chunk_size); + let (lows, highs) = rem.split_at(chunk_size); + for ((e, low), high) in es.iter_mut().zip(lows).zip(highs) { + *e = self.math_clamp(*e, *low, *high, span)?; + } + components.truncate(chunk_size); - let expr = Expression::Literal(literal); - Ok(self.register_evaluated_expr(expr, span)) + Expression::Compose { + ty: ty0, + components, + } } - fun => Err(ConstantEvaluatorError::NotImplemented(format!( - "{fun:?} built-in function" - ))), - } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }; + + Ok(self.register_evaluated_expr(expr, span)) } fn array_length( @@ -1000,6 +1123,8 @@ impl<'a> ConstantEvaluator<'a> { } fn register_evaluated_expr(&mut self, expr: Expression, span: Span) -> Handle { + // TODO: use the validate_literal function from https://github.com/gfx-rs/naga/pull/2508 here + if let Some(FunctionLocalData { ref mut emitter, ref mut block, @@ -1026,57 +1151,6 @@ impl<'a> ConstantEvaluator<'a> { } } -/// Helper function to implement the GLSL `max` function for floats. -/// -/// While Rust does provide a `f64::max` method, it has a different behavior than the -/// GLSL `max` for NaNs. In Rust, if any of the arguments is a NaN, then the other -/// is returned. -/// -/// This leads to different results in the following example -/// ``` -/// use std::cmp::max; -/// std::f64::NAN.max(1.0); -/// ``` -/// -/// Rust will return `1.0` while GLSL should return NaN. -fn glsl_float_max(x: f32, y: f32) -> f32 { - if x < y { - y - } else { - x - } -} - -/// Helper function to implement the GLSL `min` function for floats. -/// -/// While Rust does provide a `f64::min` method, it has a different behavior than the -/// GLSL `min` for NaNs. In Rust, if any of the arguments is a NaN, then the other -/// is returned. -/// -/// This leads to different results in the following example -/// ``` -/// use std::cmp::min; -/// std::f64::NAN.min(1.0); -/// ``` -/// -/// Rust will return `1.0` while GLSL should return NaN. -fn glsl_float_min(x: f32, y: f32) -> f32 { - if y < x { - y - } else { - x - } -} - -/// Helper function to implement the GLSL `clamp` function for floats. -/// -/// While Rust does provide a `f64::clamp` method, it panics if either -/// `min` or `max` are `NaN`s which is not the behavior specified by -/// the glsl specification. -fn glsl_float_clamp(value: f32, min: f32, max: f32) -> f32 { - glsl_float_min(glsl_float_max(value, min), max) -} - #[cfg(test)] mod tests { use std::vec; @@ -1088,19 +1162,6 @@ mod tests { use super::{Behavior, ConstantEvaluator}; - #[test] - fn nan_handling() { - assert!(super::glsl_float_max(f32::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_max(2.0, f32::NAN).is_nan()); - - assert!(super::glsl_float_min(f32::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_min(2.0, f32::NAN).is_nan()); - - assert!(super::glsl_float_clamp(f32::NAN, 1.0, 2.0).is_nan()); - assert!(!super::glsl_float_clamp(1.0, f32::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_clamp(1.0, 2.0, f32::NAN).is_nan()); - } - #[test] fn unary_op() { let mut types = UniqueArena::new(); From da1765065efc5fe466079e25ff1fe77de10cafd6 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 01:54:52 +0200 Subject: [PATCH 27/37] [const-eval] allow bitcast, select and relational functions for GLSL since they should be supported --- src/proc/constant_evaluator.rs | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 9ed068be7e..d4e4acd8df 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -96,12 +96,8 @@ pub enum ConstantEvaluatorError { WorkGroupUniformLoadResult, #[error("Constants don't support atomic functions")] Atomic, - #[error("Constants don't support relational functions")] - Relational, #[error("Constants don't support derivative functions")] Derivative, - #[error("Constants don't support select expressions")] - Select, #[error("Constants don't support load expressions")] Load, #[error("Constants don't support image expressions")] @@ -114,8 +110,6 @@ pub enum ConstantEvaluatorError { InvalidAccessIndex, #[error("Cannot access with index of type")] InvalidAccessIndexTy, - #[error("Constants don't support bitcasts")] - Bitcast, #[error("Constants don't support array length expressions")] ArrayLength, #[error("Cannot cast type")] @@ -335,26 +329,17 @@ impl<'a> ConstantEvaluator<'a> { match convert { Some(width) => self.cast(expr, kind, width, span), - None => match self.behavior { - Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented( - "bitcast built-in function".into(), - )), - Behavior::Glsl => Err(ConstantEvaluatorError::Bitcast), - }, + None => Err(ConstantEvaluatorError::NotImplemented( + "bitcast built-in function".into(), + )), } } - Expression::Select { .. } => match self.behavior { - Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented( - "select built-in function".into(), - )), - Behavior::Glsl => Err(ConstantEvaluatorError::Select), - }, - Expression::Relational { fun, .. } => match self.behavior { - Behavior::Wgsl => Err(ConstantEvaluatorError::NotImplemented(format!( - "{fun:?} built-in function" - ))), - Behavior::Glsl => Err(ConstantEvaluatorError::Relational), - }, + Expression::Select { .. } => Err(ConstantEvaluatorError::NotImplemented( + "select built-in function".into(), + )), + Expression::Relational { fun, .. } => Err(ConstantEvaluatorError::NotImplemented( + format!("{fun:?} built-in function"), + )), Expression::ArrayLength(expr) => match self.behavior { Behavior::Wgsl => Err(ConstantEvaluatorError::ArrayLength), Behavior::Glsl => { From 18f4de766f562efc34489bb125c346614a5513aa Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 03:05:52 +0200 Subject: [PATCH 28/37] [const-eval] evaluate `BinaryOperator::Modulo` correctly (use the truncated version instead of floored) --- src/proc/constant_evaluator.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index d4e4acd8df..b3c63e8e48 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -1027,7 +1027,7 @@ impl<'a> ConstantEvaluator<'a> { BinaryOperator::Subtract => a - b, BinaryOperator::Multiply => a * b, BinaryOperator::Divide => a / b, - BinaryOperator::Modulo => a - b * (a / b).floor(), + BinaryOperator::Modulo => a % b, _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::Bool(a), Literal::Bool(b)) => Literal::Bool(match op { From b737d3e094855f38b2df9d9783a463a5bf4c5a89 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 03:47:15 +0200 Subject: [PATCH 29/37] [const-eval] error on invalid binary operations --- src/proc/constant_evaluator.rs | 72 +++++++++++++++++++++++++++------- 1 file changed, 58 insertions(+), 14 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index b3c63e8e48..eb45179b71 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -136,6 +136,14 @@ pub enum ConstantEvaluatorError { SubexpressionsAreNotConstant, #[error("Not implemented as constant expression: {0}")] NotImplemented(String), + #[error("{0} operation overflowed")] + Overflow(String), + #[error("Division by zero")] + DivisionByZero, + #[error("Remainder by zero")] + RemainderByZero, + #[error("RHS of shift operation is greater than or equal to 32")] + ShiftedMoreThan32Bits, } impl<'a> ConstantEvaluator<'a> { @@ -994,32 +1002,68 @@ impl<'a> ConstantEvaluator<'a> { _ => match (left_value, right_value) { (Literal::I32(a), Literal::I32(b)) => Literal::I32(match op { - BinaryOperator::Add => a.wrapping_add(b), - BinaryOperator::Subtract => a.wrapping_sub(b), - BinaryOperator::Multiply => a.wrapping_mul(b), - BinaryOperator::Divide => a.checked_div(b).unwrap_or(0), - BinaryOperator::Modulo => a.checked_rem(b).unwrap_or(0), + BinaryOperator::Add => a.checked_add(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("addition".into()) + })?, + BinaryOperator::Subtract => a.checked_sub(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("subtraction".into()) + })?, + BinaryOperator::Multiply => a.checked_mul(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("multiplication".into()) + })?, + BinaryOperator::Divide => a.checked_div(b).ok_or_else(|| { + if b == 0 { + ConstantEvaluatorError::DivisionByZero + } else { + ConstantEvaluatorError::Overflow("division".into()) + } + })?, + BinaryOperator::Modulo => a.checked_rem(b).ok_or_else(|| { + if b == 0 { + ConstantEvaluatorError::RemainderByZero + } else { + ConstantEvaluatorError::Overflow("remainder".into()) + } + })?, BinaryOperator::And => a & b, BinaryOperator::ExclusiveOr => a ^ b, BinaryOperator::InclusiveOr => a | b, _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::I32(a), Literal::U32(b)) => Literal::I32(match op { - BinaryOperator::ShiftLeft => a.wrapping_shl(b), - BinaryOperator::ShiftRight => a.wrapping_shr(b), + BinaryOperator::ShiftLeft => a + .checked_shl(b) + .ok_or(ConstantEvaluatorError::ShiftedMoreThan32Bits)?, + BinaryOperator::ShiftRight => a + .checked_shr(b) + .ok_or(ConstantEvaluatorError::ShiftedMoreThan32Bits)?, _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::U32(a), Literal::U32(b)) => Literal::U32(match op { - BinaryOperator::Add => a.wrapping_add(b), - BinaryOperator::Subtract => a.wrapping_sub(b), - BinaryOperator::Multiply => a.wrapping_mul(b), - BinaryOperator::Divide => a.checked_div(b).unwrap_or(0), - BinaryOperator::Modulo => a.checked_rem(b).unwrap_or(0), + BinaryOperator::Add => a.checked_add(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("addition".into()) + })?, + BinaryOperator::Subtract => a.checked_sub(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("subtraction".into()) + })?, + BinaryOperator::Multiply => a.checked_mul(b).ok_or_else(|| { + ConstantEvaluatorError::Overflow("multiplication".into()) + })?, + BinaryOperator::Divide => a + .checked_div(b) + .ok_or(ConstantEvaluatorError::DivisionByZero)?, + BinaryOperator::Modulo => a + .checked_rem(b) + .ok_or(ConstantEvaluatorError::RemainderByZero)?, BinaryOperator::And => a & b, BinaryOperator::ExclusiveOr => a ^ b, BinaryOperator::InclusiveOr => a | b, - BinaryOperator::ShiftLeft => a.wrapping_shl(b), - BinaryOperator::ShiftRight => a.wrapping_shr(b), + BinaryOperator::ShiftLeft => a + .checked_shl(b) + .ok_or(ConstantEvaluatorError::ShiftedMoreThan32Bits)?, + BinaryOperator::ShiftRight => a + .checked_shr(b) + .ok_or(ConstantEvaluatorError::ShiftedMoreThan32Bits)?, _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }), (Literal::F32(a), Literal::F32(b)) => Literal::F32(match op { From 233c6c66167ae762986a0a3ebf71192d5382533c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Thu, 5 Oct 2023 14:03:07 -0700 Subject: [PATCH 30/37] Properly recognize `Literal` expressions as non-dynamic indices. (#2537) Restore `negative_index` test in `tests/wgsl-errors.rs`, as part of the `invalid_arrays` test function. --- src/proc/mod.rs | 12 +++++++----- tests/wgsl-errors.rs | 39 ++++++++++++++++++++------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/proc/mod.rs b/src/proc/mod.rs index 481ea89021..d50f165a56 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -466,11 +466,13 @@ impl crate::Expression { /// [`Access`]: crate::Expression::Access /// [`ResolveContext`]: crate::proc::ResolveContext pub fn is_dynamic_index(&self, module: &crate::Module) -> bool { - if let Self::Constant(handle) = *self { - let constant = &module.constants[handle]; - !matches!(constant.r#override, crate::Override::None) - } else { - true + match *self { + Self::Literal(_) | Self::ZeroValue(_) => false, + Self::Constant(handle) => { + let constant = &module.constants[handle]; + !matches!(constant.r#override, crate::Override::None) + } + _ => true, } } } diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index 9e5eecccce..90785d4f23 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -107,25 +107,6 @@ fn unknown_identifier() { ); } -// #[test] -// fn negative_index() { -// check( -// r#" -// fn main() -> f32 { -// let a = array(0., 1., 2.); -// return a[-1]; -// } -// "#, -// r#"error: expected unsigned integer constant expression, found `-1` -// ┌─ wgsl:4:26 -// │ -// 4 │ return a[-1]; -// │ ^^ expected unsigned integer - -// "#, -// ); -// } - #[test] fn bad_texture() { check( @@ -921,6 +902,26 @@ fn invalid_arrays() { }) } + check_validation! { + r#" + fn main() -> f32 { + let a = array(0., 1., 2.); + return a[-1]; + } + "#: + Err( + naga::valid::ValidationError::Function { + name, + source: naga::valid::FunctionError::Expression { + source: naga::valid::ExpressionError::NegativeIndex(_), + .. + }, + .. + } + ) + if name == "main" + } + check( "alias Bad = array;", r###"error: must be a const-expression that resolves to a concrete integer scalar (u32 or i32) From c216a132b1c53b297b341f3d86e0e7fbdd392cf3 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:46:02 +0200 Subject: [PATCH 31/37] Avoid FXC's error X3694: race condition writing to shared resource detected --- tests/in/const-exprs.wgsl | 35 ++- tests/out/glsl/const-exprs.main.Compute.glsl | 33 +-- tests/out/hlsl/const-exprs.hlsl | 37 ++-- tests/out/msl/const-exprs.msl | 49 ++--- tests/out/spv/const-exprs.spvasm | 214 ++++++++----------- tests/out/wgsl/const-exprs.wgsl | 39 ++-- 6 files changed, 169 insertions(+), 238 deletions(-) diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl index e388c378ad..24d48665e6 100644 --- a/tests/in/const-exprs.wgsl +++ b/tests/in/const-exprs.wgsl @@ -1,32 +1,29 @@ -@group(0) @binding(0) var out: vec4; -@group(0) @binding(1) var out2: i32; - const TWO: u32 = 2u; const THREE: i32 = 3i; @compute @workgroup_size(TWO, THREE, TWO - 1u) fn main() { - swizzle_of_compose(); - index_of_compose(); - compose_three_deep(); - non_constant_initializers(); - splat_of_constant(); - compose_of_constant(); + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); + non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); } // Swizzle the value of nested Compose expressions. fn swizzle_of_compose() { - out = vec4(vec2(1, 2), vec2(3, 4)).wzyx; // should assign vec4(4, 3, 2, 1); + var out = vec4(vec2(1, 2), vec2(3, 4)).wzyx; // should assign vec4(4, 3, 2, 1); } // Index the value of nested Compose expressions. fn index_of_compose() { - out2 += vec4(vec2(1, 2), vec2(3, 4))[1]; // should assign 2 + var out = vec4(vec2(1, 2), vec2(3, 4))[1]; // should assign 2 } // Index the value of Compose expressions nested three deep fn compose_three_deep() { - out2 += vec4(vec3(vec2(6, 7), 8), 9)[0]; // should assign 6 + var out = vec4(vec3(vec2(6, 7), 8), 9)[0]; // should assign 6 } // While WGSL allows local variables to be declared anywhere in the function, @@ -40,12 +37,12 @@ fn compose_three_deep() { // initializers that are constants as Naga locals with initializers. This test // checks that Naga local variable initializers are only used when safe. fn non_constant_initializers() { - var w = 10 + 20; - var x = w; - var y = x; - var z = 30 + 40; + var w = 10 + 20; + var x = w; + var y = x; + var z = 30 + 40; - out += vec4(w, x, y, z); + var out = vec4(w, x, y, z); } // Constant evaluation should be able to see through constants to @@ -58,11 +55,11 @@ const TEST_CONSTANT_ADDITION: i32 = FOUR + FOUR; const TEST_CONSTANT_ALIAS_ADDITION: i32 = FOUR_ALIAS + FOUR_ALIAS; fn splat_of_constant() { - out = -vec4(FOUR); + var out = -vec4(FOUR); } fn compose_of_constant() { - out = -vec4(FOUR, FOUR, FOUR, FOUR); + var out = -vec4(FOUR, FOUR, FOUR, FOUR); } const PI: f32 = 3.141; diff --git a/tests/out/glsl/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl index 738d0d7ef5..b6bbe5daa7 100644 --- a/tests/out/glsl/const-exprs.main.Compute.glsl +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -18,26 +18,17 @@ const int TEXTURE_KIND_REGULAR = 0; const int TEXTURE_KIND_WARP = 1; const int TEXTURE_KIND_SKY = 2; -layout(std430) buffer type_block_0Compute { ivec4 _group_0_binding_0_cs; }; - -layout(std430) buffer type_1_block_1Compute { int _group_0_binding_1_cs; }; - void swizzle_of_compose() { - _group_0_binding_0_cs = ivec4(4, 3, 2, 1); - return; + ivec4 out_ = ivec4(4, 3, 2, 1); } void index_of_compose() { - int _e2 = _group_0_binding_1_cs; - _group_0_binding_1_cs = (_e2 + 2); - return; + int out_1 = 2; } void compose_three_deep() { - int _e2 = _group_0_binding_1_cs; - _group_0_binding_1_cs = (_e2 + 6); - return; + int out_2 = 6; } void non_constant_initializers() { @@ -45,27 +36,25 @@ void non_constant_initializers() { int x = 0; int y = 0; int z = 70; + ivec4 out_3 = ivec4(0); int _e2 = w; x = _e2; int _e4 = x; y = _e4; - int _e9 = w; - int _e10 = x; - int _e11 = y; - int _e12 = z; - ivec4 _e14 = _group_0_binding_0_cs; - _group_0_binding_0_cs = (_e14 + ivec4(_e9, _e10, _e11, _e12)); + int _e8 = w; + int _e9 = x; + int _e10 = y; + int _e11 = z; + out_3 = ivec4(_e8, _e9, _e10, _e11); return; } void splat_of_constant() { - _group_0_binding_0_cs = ivec4(-4, -4, -4, -4); - return; + ivec4 out_4 = ivec4(-4, -4, -4, -4); } void compose_of_constant() { - _group_0_binding_0_cs = ivec4(-4, -4, -4, -4); - return; + ivec4 out_5 = ivec4(-4, -4, -4, -4); } uint map_texture_kind(int texture_kind) { diff --git a/tests/out/hlsl/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl index f3f59a5840..fc52a1129e 100644 --- a/tests/out/hlsl/const-exprs.hlsl +++ b/tests/out/hlsl/const-exprs.hlsl @@ -11,27 +11,22 @@ static const int TEXTURE_KIND_REGULAR = 0; static const int TEXTURE_KIND_WARP = 1; static const int TEXTURE_KIND_SKY = 2; -RWByteAddressBuffer out_ : register(u0); -RWByteAddressBuffer out2_ : register(u1); - void swizzle_of_compose() { - out_.Store4(0, asuint(int4(4, 3, 2, 1))); - return; + int4 out_ = int4(4, 3, 2, 1); + } void index_of_compose() { - int _expr2 = asint(out2_.Load(0)); - out2_.Store(0, asuint((_expr2 + 2))); - return; + int out_1 = 2; + } void compose_three_deep() { - int _expr2 = asint(out2_.Load(0)); - out2_.Store(0, asuint((_expr2 + 6))); - return; + int out_2 = 6; + } void non_constant_initializers() @@ -40,30 +35,30 @@ void non_constant_initializers() int x = (int)0; int y = (int)0; int z = 70; + int4 out_3 = (int4)0; int _expr2 = w; x = _expr2; int _expr4 = x; y = _expr4; - int _expr9 = w; - int _expr10 = x; - int _expr11 = y; - int _expr12 = z; - int4 _expr14 = asint(out_.Load4(0)); - out_.Store4(0, asuint((_expr14 + int4(_expr9, _expr10, _expr11, _expr12)))); + int _expr8 = w; + int _expr9 = x; + int _expr10 = y; + int _expr11 = z; + out_3 = int4(_expr8, _expr9, _expr10, _expr11); return; } void splat_of_constant() { - out_.Store4(0, asuint(int4(-4, -4, -4, -4))); - return; + int4 out_4 = int4(-4, -4, -4, -4); + } void compose_of_constant() { - out_.Store4(0, asuint(int4(-4, -4, -4, -4))); - return; + int4 out_5 = int4(-4, -4, -4, -4); + } uint map_texture_kind(int texture_kind) diff --git a/tests/out/msl/const-exprs.msl b/tests/out/msl/const-exprs.msl index 48299e767b..47b3615e13 100644 --- a/tests/out/msl/const-exprs.msl +++ b/tests/out/msl/const-exprs.msl @@ -18,60 +18,47 @@ constant int TEXTURE_KIND_WARP = 1; constant int TEXTURE_KIND_SKY = 2; void swizzle_of_compose( - device metal::int4& out ) { - out = metal::int4(4, 3, 2, 1); - return; + metal::int4 out = metal::int4(4, 3, 2, 1); } void index_of_compose( - device int& out2_ ) { - int _e2 = out2_; - out2_ = _e2 + 2; - return; + int out_1 = 2; } void compose_three_deep( - device int& out2_ ) { - int _e2 = out2_; - out2_ = _e2 + 6; - return; + int out_2 = 6; } void non_constant_initializers( - device metal::int4& out ) { int w = 30; int x = {}; int y = {}; int z = 70; + metal::int4 out_3 = {}; int _e2 = w; x = _e2; int _e4 = x; y = _e4; - int _e9 = w; - int _e10 = x; - int _e11 = y; - int _e12 = z; - metal::int4 _e14 = out; - out = _e14 + metal::int4(_e9, _e10, _e11, _e12); + int _e8 = w; + int _e9 = x; + int _e10 = y; + int _e11 = z; + out_3 = metal::int4(_e8, _e9, _e10, _e11); return; } void splat_of_constant( - device metal::int4& out ) { - out = metal::int4(-4, -4, -4, -4); - return; + metal::int4 out_4 = metal::int4(-4, -4, -4, -4); } void compose_of_constant( - device metal::int4& out ) { - out = metal::int4(-4, -4, -4, -4); - return; + metal::int4 out_5 = metal::int4(-4, -4, -4, -4); } uint map_texture_kind( @@ -94,14 +81,12 @@ uint map_texture_kind( } kernel void main_( - device metal::int4& out [[user(fake0)]] -, device int& out2_ [[user(fake0)]] ) { - swizzle_of_compose(out); - index_of_compose(out2_); - compose_three_deep(out2_); - non_constant_initializers(out); - splat_of_constant(out); - compose_of_constant(out); + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); + non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); return; } diff --git a/tests/out/spv/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm index b05f0f7df9..e6aff5079a 100644 --- a/tests/out/spv/const-exprs.spvasm +++ b/tests/out/spv/const-exprs.spvasm @@ -1,28 +1,19 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 105 +; Bound: 91 OpCapability Shader -OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %95 "main" -OpExecutionMode %95 LocalSize 2 3 1 -OpDecorate %20 DescriptorSet 0 -OpDecorate %20 Binding 0 -OpDecorate %21 Block -OpMemberDecorate %21 0 Offset 0 -OpDecorate %23 DescriptorSet 0 -OpDecorate %23 Binding 1 -OpDecorate %24 Block -OpMemberDecorate %24 0 Offset 0 +OpEntryPoint GLCompute %83 "main" +OpExecutionMode %83 LocalSize 2 3 1 %2 = OpTypeVoid +%3 = OpTypeInt 32 0 %4 = OpTypeInt 32 1 -%3 = OpTypeVector %4 4 -%5 = OpTypeInt 32 0 +%5 = OpTypeVector %4 4 %6 = OpTypeFloat 32 %7 = OpTypeVector %6 4 -%8 = OpConstant %5 2 +%8 = OpConstant %3 2 %9 = OpConstant %4 3 %10 = OpConstant %4 4 %11 = OpConstant %4 8 @@ -34,126 +25,107 @@ OpMemberDecorate %24 0 Offset 0 %17 = OpConstant %4 0 %18 = OpConstant %4 1 %19 = OpConstant %4 2 -%21 = OpTypeStruct %3 -%22 = OpTypePointer StorageBuffer %21 -%20 = OpVariable %22 StorageBuffer -%24 = OpTypeStruct %4 -%25 = OpTypePointer StorageBuffer %24 -%23 = OpVariable %25 StorageBuffer -%28 = OpTypeFunction %2 -%29 = OpTypePointer StorageBuffer %3 -%30 = OpConstant %5 0 -%32 = OpConstantComposite %3 %10 %9 %19 %18 -%36 = OpTypePointer StorageBuffer %4 -%44 = OpConstant %4 6 -%51 = OpConstant %4 30 -%52 = OpConstant %4 70 -%54 = OpTypePointer Function %4 -%56 = OpConstantNull %4 -%58 = OpConstantNull %4 -%73 = OpConstant %4 -4 -%74 = OpConstantComposite %3 %73 %73 %73 %73 -%83 = OpTypeFunction %5 %4 -%84 = OpConstant %5 10 -%85 = OpConstant %5 20 -%86 = OpConstant %5 30 -%93 = OpConstantNull %5 -%27 = OpFunction %2 None %28 +%22 = OpTypeFunction %2 +%23 = OpConstantComposite %5 %10 %9 %19 %18 +%25 = OpTypePointer Function %5 +%30 = OpTypePointer Function %4 +%34 = OpConstant %4 6 +%39 = OpConstant %4 30 +%40 = OpConstant %4 70 +%43 = OpConstantNull %4 +%45 = OpConstantNull %4 +%48 = OpConstantNull %5 +%59 = OpConstant %4 -4 +%60 = OpConstantComposite %5 %59 %59 %59 %59 +%70 = OpTypeFunction %3 %4 +%71 = OpConstant %3 10 +%72 = OpConstant %3 20 +%73 = OpConstant %3 30 +%74 = OpConstant %3 0 +%81 = OpConstantNull %3 +%21 = OpFunction %2 None %22 +%20 = OpLabel +%24 = OpVariable %25 Function %23 +OpBranch %26 %26 = OpLabel -%31 = OpAccessChain %29 %20 %30 -OpBranch %33 -%33 = OpLabel -OpStore %31 %32 OpReturn OpFunctionEnd -%35 = OpFunction %2 None %28 -%34 = OpLabel -%37 = OpAccessChain %36 %23 %30 -OpBranch %38 -%38 = OpLabel -%39 = OpLoad %4 %37 -%40 = OpIAdd %4 %39 %19 -OpStore %37 %40 +%28 = OpFunction %2 None %22 +%27 = OpLabel +%29 = OpVariable %30 Function %19 +OpBranch %31 +%31 = OpLabel OpReturn OpFunctionEnd -%42 = OpFunction %2 None %28 -%41 = OpLabel -%43 = OpAccessChain %36 %23 %30 -OpBranch %45 -%45 = OpLabel -%46 = OpLoad %4 %43 -%47 = OpIAdd %4 %46 %44 -OpStore %43 %47 +%33 = OpFunction %2 None %22 +%32 = OpLabel +%35 = OpVariable %30 Function %34 +OpBranch %36 +%36 = OpLabel OpReturn OpFunctionEnd -%49 = OpFunction %2 None %28 -%48 = OpLabel -%55 = OpVariable %54 Function %56 -%59 = OpVariable %54 Function %52 -%53 = OpVariable %54 Function %51 -%57 = OpVariable %54 Function %58 -%50 = OpAccessChain %29 %20 %30 -OpBranch %60 -%60 = OpLabel -%61 = OpLoad %4 %53 -OpStore %55 %61 -%62 = OpLoad %4 %55 -OpStore %57 %62 -%63 = OpLoad %4 %53 -%64 = OpLoad %4 %55 -%65 = OpLoad %4 %57 -%66 = OpLoad %4 %59 -%67 = OpCompositeConstruct %3 %63 %64 %65 %66 -%68 = OpLoad %3 %50 -%69 = OpIAdd %3 %68 %67 -OpStore %50 %69 +%38 = OpFunction %2 None %22 +%37 = OpLabel +%47 = OpVariable %25 Function %48 +%42 = OpVariable %30 Function %43 +%46 = OpVariable %30 Function %40 +%41 = OpVariable %30 Function %39 +%44 = OpVariable %30 Function %45 +OpBranch %49 +%49 = OpLabel +%50 = OpLoad %4 %41 +OpStore %42 %50 +%51 = OpLoad %4 %42 +OpStore %44 %51 +%52 = OpLoad %4 %41 +%53 = OpLoad %4 %42 +%54 = OpLoad %4 %44 +%55 = OpLoad %4 %46 +%56 = OpCompositeConstruct %5 %52 %53 %54 %55 +OpStore %47 %56 OpReturn OpFunctionEnd -%71 = OpFunction %2 None %28 -%70 = OpLabel -%72 = OpAccessChain %29 %20 %30 -OpBranch %75 -%75 = OpLabel -OpStore %72 %74 +%58 = OpFunction %2 None %22 +%57 = OpLabel +%61 = OpVariable %25 Function %60 +OpBranch %62 +%62 = OpLabel OpReturn OpFunctionEnd -%77 = OpFunction %2 None %28 -%76 = OpLabel -%78 = OpAccessChain %29 %20 %30 -OpBranch %79 -%79 = OpLabel -OpStore %78 %74 +%64 = OpFunction %2 None %22 +%63 = OpLabel +%65 = OpVariable %25 Function %60 +OpBranch %66 +%66 = OpLabel OpReturn OpFunctionEnd -%82 = OpFunction %5 None %83 -%81 = OpFunctionParameter %4 +%69 = OpFunction %3 None %70 +%68 = OpFunctionParameter %4 +%67 = OpLabel +OpBranch %75 +%75 = OpLabel +OpSelectionMerge %76 None +OpSwitch %68 %80 0 %77 1 %78 2 %79 +%77 = OpLabel +OpReturnValue %71 +%78 = OpLabel +OpReturnValue %72 +%79 = OpLabel +OpReturnValue %73 %80 = OpLabel -OpBranch %87 -%87 = OpLabel -OpSelectionMerge %88 None -OpSwitch %81 %92 0 %89 1 %90 2 %91 -%89 = OpLabel -OpReturnValue %84 -%90 = OpLabel -OpReturnValue %85 -%91 = OpLabel -OpReturnValue %86 -%92 = OpLabel -OpReturnValue %30 -%88 = OpLabel -OpReturnValue %93 +OpReturnValue %74 +%76 = OpLabel +OpReturnValue %81 OpFunctionEnd -%95 = OpFunction %2 None %28 -%94 = OpLabel -%96 = OpAccessChain %29 %20 %30 -%97 = OpAccessChain %36 %23 %30 -OpBranch %98 -%98 = OpLabel -%99 = OpFunctionCall %2 %27 -%100 = OpFunctionCall %2 %35 -%101 = OpFunctionCall %2 %42 -%102 = OpFunctionCall %2 %49 -%103 = OpFunctionCall %2 %71 -%104 = OpFunctionCall %2 %77 +%83 = OpFunction %2 None %22 +%82 = OpLabel +OpBranch %84 +%84 = OpLabel +%85 = OpFunctionCall %2 %21 +%86 = OpFunctionCall %2 %28 +%87 = OpFunctionCall %2 %33 +%88 = OpFunctionCall %2 %38 +%89 = OpFunctionCall %2 %58 +%90 = OpFunctionCall %2 %64 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl index 569d082641..fffc11f34f 100644 --- a/tests/out/wgsl/const-exprs.wgsl +++ b/tests/out/wgsl/const-exprs.wgsl @@ -11,26 +11,19 @@ const TEXTURE_KIND_REGULAR: i32 = 0; const TEXTURE_KIND_WARP: i32 = 1; const TEXTURE_KIND_SKY: i32 = 2; -@group(0) @binding(0) -var out: vec4; -@group(0) @binding(1) -var out2_: i32; - fn swizzle_of_compose() { - out = vec4(4, 3, 2, 1); - return; + var out: vec4 = vec4(4, 3, 2, 1); + } fn index_of_compose() { - let _e2 = out2_; - out2_ = (_e2 + 2); - return; + var out_1: i32 = 2; + } fn compose_three_deep() { - let _e2 = out2_; - out2_ = (_e2 + 6); - return; + var out_2: i32 = 6; + } fn non_constant_initializers() { @@ -38,28 +31,28 @@ fn non_constant_initializers() { var x: i32; var y: i32; var z: i32 = 70; + var out_3: vec4; let _e2 = w; x = _e2; let _e4 = x; y = _e4; - let _e9 = w; - let _e10 = x; - let _e11 = y; - let _e12 = z; - let _e14 = out; - out = (_e14 + vec4(_e9, _e10, _e11, _e12)); + let _e8 = w; + let _e9 = x; + let _e10 = y; + let _e11 = z; + out_3 = vec4(_e8, _e9, _e10, _e11); return; } fn splat_of_constant() { - out = vec4(-4, -4, -4, -4); - return; + var out_4: vec4 = vec4(-4, -4, -4, -4); + } fn compose_of_constant() { - out = vec4(-4, -4, -4, -4); - return; + var out_5: vec4 = vec4(-4, -4, -4, -4); + } fn map_texture_kind(texture_kind: i32) -> u32 { From 91718842d354bfcadd8ae485ccce5e96d060323a Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 5 Oct 2023 23:55:47 +0200 Subject: [PATCH 32/37] [const-eval] error on NaN and infinite floats --- src/proc/constant_evaluator.rs | 69 ++++++++++++++++++++-------------- src/valid/expression.rs | 2 +- src/valid/mod.rs | 1 + 3 files changed, 42 insertions(+), 30 deletions(-) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index eb45179b71..61adf0fdd5 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -78,7 +78,7 @@ impl ExpressionConstnessTracker { } } -#[derive(Clone, Debug, PartialEq, thiserror::Error)] +#[derive(Clone, Debug, thiserror::Error)] pub enum ConstantEvaluatorError { #[error("Constants cannot access function arguments")] FunctionArg, @@ -144,6 +144,8 @@ pub enum ConstantEvaluatorError { RemainderByZero, #[error("RHS of shift operation is greater than or equal to 32")] ShiftedMoreThan32Bits, + #[error(transparent)] + Literal(#[from] crate::valid::LiteralError), } impl<'a> ConstantEvaluator<'a> { @@ -270,18 +272,18 @@ impl<'a> ConstantEvaluator<'a> { Ok(self.constants[c].init) } Expression::Literal(_) | Expression::ZeroValue(_) | Expression::Constant(_) => { - Ok(self.register_evaluated_expr(expr.clone(), span)) + self.register_evaluated_expr(expr.clone(), span) } Expression::Compose { ty, ref components } => { let components = components .iter() .map(|component| self.check_and_get(*component)) .collect::, _>>()?; - Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) + self.register_evaluated_expr(Expression::Compose { ty, components }, span) } Expression::Splat { size, value } => { let value = self.check_and_get(value)?; - Ok(self.register_evaluated_expr(Expression::Splat { size, value }, span)) + self.register_evaluated_expr(Expression::Splat { size, value }, span) } Expression::AccessIndex { base, index } => { let base = self.check_and_get(base)?; @@ -395,7 +397,7 @@ impl<'a> ConstantEvaluator<'a> { ty, components: vec![value; size as usize], }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } Expression::ZeroValue(ty) => { let inner = match self.types[ty].inner { @@ -404,7 +406,7 @@ impl<'a> ConstantEvaluator<'a> { }; let res_ty = self.types.insert(Type { name: None, inner }, span); let expr = Expression::ZeroValue(res_ty); - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } _ => Err(ConstantEvaluatorError::SplatScalarOnly), } @@ -436,11 +438,11 @@ impl<'a> ConstantEvaluator<'a> { Expression::ZeroValue(ty) => { let dst_ty = get_dst_ty(ty)?; let expr = Expression::ZeroValue(dst_ty); - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } Expression::Splat { value, .. } => { let expr = Expression::Splat { size, value }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } Expression::Compose { ty, ref components } => { let dst_ty = get_dst_ty(ty)?; @@ -468,7 +470,7 @@ impl<'a> ConstantEvaluator<'a> { ty: dst_ty, components: swizzled_components, }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } _ => Err(ConstantEvaluatorError::SwizzleVectorOnly), } @@ -565,7 +567,7 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidMathArg), }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } fn math_clamp( @@ -670,7 +672,7 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidMathArg), }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } fn array_length( @@ -684,7 +686,7 @@ impl<'a> ConstantEvaluator<'a> { TypeInner::Array { size, .. } => match size { crate::ArraySize::Constant(len) => { let expr = Expression::Literal(Literal::U32(len.get())); - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } crate::ArraySize::Dynamic => { Err(ConstantEvaluatorError::ArrayLengthDynamic) @@ -722,7 +724,7 @@ impl<'a> ConstantEvaluator<'a> { self.types.insert(Type { name: None, inner }, span) } }; - Ok(self.register_evaluated_expr(Expression::ZeroValue(ty), span)) + self.register_evaluated_expr(Expression::ZeroValue(ty), span) } } Expression::Splat { size, value } => { @@ -788,7 +790,7 @@ impl<'a> ConstantEvaluator<'a> { Literal::zero(kind, width) .ok_or(ConstantEvaluatorError::TypeNotConstructible)?, ); - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } TypeInner::Vector { size, kind, width } => { let scalar_ty = self.types.insert( @@ -803,7 +805,7 @@ impl<'a> ConstantEvaluator<'a> { ty, components: vec![el; size as usize], }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } TypeInner::Matrix { columns, @@ -826,7 +828,7 @@ impl<'a> ConstantEvaluator<'a> { ty, components: vec![el; columns as usize], }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } TypeInner::Array { base, @@ -838,7 +840,7 @@ impl<'a> ConstantEvaluator<'a> { ty, components: vec![el; size.get() as usize], }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } TypeInner::Struct { ref members, .. } => { let types: Vec<_> = members.iter().map(|m| m.ty).collect(); @@ -847,7 +849,7 @@ impl<'a> ConstantEvaluator<'a> { components.push(self.eval_zero_value_impl(ty, span)?); } let expr = Expression::Compose { ty, components }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } _ => Err(ConstantEvaluatorError::TypeNotConstructible), } @@ -933,7 +935,7 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidCastArg), }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } fn unary_op( @@ -977,7 +979,7 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } fn binary_op( @@ -1113,7 +1115,7 @@ impl<'a> ConstantEvaluator<'a> { _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), }; - Ok(self.register_evaluated_expr(expr, span)) + self.register_evaluated_expr(expr, span) } /// Deep copy `expr` from `expressions` into `self.expressions`. @@ -1132,17 +1134,17 @@ impl<'a> ConstantEvaluator<'a> { match expressions[expr] { ref expr @ (Expression::Literal(_) | Expression::Constant(_) - | Expression::ZeroValue(_)) => Ok(self.register_evaluated_expr(expr.clone(), span)), + | Expression::ZeroValue(_)) => self.register_evaluated_expr(expr.clone(), span), Expression::Compose { ty, ref components } => { let mut components = components.clone(); for component in &mut components { *component = self.copy_from(*component, expressions)?; } - Ok(self.register_evaluated_expr(Expression::Compose { ty, components }, span)) + self.register_evaluated_expr(Expression::Compose { ty, components }, span) } Expression::Splat { size, value } => { let value = self.copy_from(value, expressions)?; - Ok(self.register_evaluated_expr(Expression::Splat { size, value }, span)) + self.register_evaluated_expr(Expression::Splat { size, value }, span) } _ => { log::debug!("copy_from: SubexpressionsAreNotConstant"); @@ -1151,8 +1153,17 @@ impl<'a> ConstantEvaluator<'a> { } } - fn register_evaluated_expr(&mut self, expr: Expression, span: Span) -> Handle { - // TODO: use the validate_literal function from https://github.com/gfx-rs/naga/pull/2508 here + fn register_evaluated_expr( + &mut self, + expr: Expression, + span: Span, + ) -> Result, ConstantEvaluatorError> { + // It suffices to only check literals, since we only register one + // expression at a time, `Compose` expressions can only refer to other + // expressions, and `ZeroValue` expressions are always okay. + if let Expression::Literal(literal) = expr { + crate::valid::validate_literal(literal)?; + } if let Some(FunctionLocalData { ref mut emitter, @@ -1168,14 +1179,14 @@ impl<'a> ConstantEvaluator<'a> { let h = self.expressions.append(expr, span); emitter.start(self.expressions); expression_constness.insert(h); - h + Ok(h) } else { let h = self.expressions.append(expr, span); expression_constness.insert(h); - h + Ok(h) } } else { - self.expressions.append(expr, span) + Ok(self.expressions.append(expr, span)) } } } diff --git a/src/valid/expression.rs b/src/valid/expression.rs index af4b774f12..95225a3926 100644 --- a/src/valid/expression.rs +++ b/src/valid/expression.rs @@ -1566,7 +1566,7 @@ impl super::Validator { } } -fn validate_literal(literal: crate::Literal) -> Result<(), LiteralError> { +pub fn validate_literal(literal: crate::Literal) -> Result<(), LiteralError> { let is_nan = match literal { crate::Literal::F64(v) => v.is_nan(), crate::Literal::F32(v) => v.is_nan(), diff --git a/src/valid/mod.rs b/src/valid/mod.rs index 6175aa0945..8c065bb159 100644 --- a/src/valid/mod.rs +++ b/src/valid/mod.rs @@ -24,6 +24,7 @@ use std::ops; use crate::span::{AddSpan as _, WithSpan}; pub use analyzer::{ExpressionInfo, FunctionInfo, GlobalUse, Uniformity, UniformityRequirements}; pub use compose::ComposeError; +pub use expression::{validate_literal, LiteralError}; pub use expression::{ConstExpressionError, ExpressionError}; pub use function::{CallError, FunctionError, LocalVariableError}; pub use interface::{EntryPointError, GlobalVariableError, VaryingError}; From 260effbf42160b41547cadec8399ae0682977620 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Mon, 9 Oct 2023 16:24:55 +0200 Subject: [PATCH 33/37] avoid const-evaluating the `operators.wgsl` snapshot --- tests/in/operators.wgsl | 362 +++++----- tests/out/glsl/operators.main.Compute.glsl | 161 +++-- tests/out/hlsl/operators.hlsl | 161 +++-- tests/out/msl/operators.msl | 161 +++-- tests/out/spv/operators.spvasm | 732 +++++++++++---------- tests/out/wgsl/operators.wgsl | 161 +++-- 6 files changed, 1032 insertions(+), 706 deletions(-) diff --git a/tests/in/operators.wgsl b/tests/in/operators.wgsl index eaf16ab8ff..40d1ce8ead 100644 --- a/tests/in/operators.wgsl +++ b/tests/in/operators.wgsl @@ -41,215 +41,242 @@ fn bool_cast(x: vec3) -> vec3 { } fn logical() { + let t = true; + let f = false; + // unary - let neg0 = !true; - let neg1 = !vec2(true); + let neg0 = !t; + let neg1 = !vec2(t); // binary - let or = true || false; - let and = true && false; - let bitwise_or0 = true | false; - let bitwise_or1 = vec3(true) | vec3(false); - let bitwise_and0 = true & false; - let bitwise_and1 = vec4(true) & vec4(false); + let or = t || f; + let and = t && f; + let bitwise_or0 = t | f; + let bitwise_or1 = vec3(t) | vec3(f); + let bitwise_and0 = t & f; + let bitwise_and1 = vec4(t) & vec4(f); } fn arithmetic() { + let one_i = 1i; + let one_u = 1u; + let one_f = 1.0; + let two_i = 2i; + let two_u = 2u; + let two_f = 2.0; + // unary - let neg0 = -1.0; - let neg1 = -vec2(1); - let neg2 = -vec2(1.0); + let neg0 = -one_f; + let neg1 = -vec2(one_i); + let neg2 = -vec2(one_f); // binary // Addition - let add0 = 2 + 1; - let add1 = 2u + 1u; - let add2 = 2.0 + 1.0; - let add3 = vec2(2) + vec2(1); - let add4 = vec3(2u) + vec3(1u); - let add5 = vec4(2.0) + vec4(1.0); + let add0 = two_i + one_i; + let add1 = two_u + one_u; + let add2 = two_f + one_f; + let add3 = vec2(two_i) + vec2(one_i); + let add4 = vec3(two_u) + vec3(one_u); + let add5 = vec4(two_f) + vec4(one_f); // Subtraction - let sub0 = 2 - 1; - let sub1 = 2u - 1u; - let sub2 = 2.0 - 1.0; - let sub3 = vec2(2) - vec2(1); - let sub4 = vec3(2u) - vec3(1u); - let sub5 = vec4(2.0) - vec4(1.0); + let sub0 = two_i - one_i; + let sub1 = two_u - one_u; + let sub2 = two_f - one_f; + let sub3 = vec2(two_i) - vec2(one_i); + let sub4 = vec3(two_u) - vec3(one_u); + let sub5 = vec4(two_f) - vec4(one_f); // Multiplication - let mul0 = 2 * 1; - let mul1 = 2u * 1u; - let mul2 = 2.0 * 1.0; - let mul3 = vec2(2) * vec2(1); - let mul4 = vec3(2u) * vec3(1u); - let mul5 = vec4(2.0) * vec4(1.0); + let mul0 = two_i * one_i; + let mul1 = two_u * one_u; + let mul2 = two_f * one_f; + let mul3 = vec2(two_i) * vec2(one_i); + let mul4 = vec3(two_u) * vec3(one_u); + let mul5 = vec4(two_f) * vec4(one_f); // Division - let div0 = 2 / 1; - let div1 = 2u / 1u; - let div2 = 2.0 / 1.0; - let div3 = vec2(2) / vec2(1); - let div4 = vec3(2u) / vec3(1u); - let div5 = vec4(2.0) / vec4(1.0); + let div0 = two_i / one_i; + let div1 = two_u / one_u; + let div2 = two_f / one_f; + let div3 = vec2(two_i) / vec2(one_i); + let div4 = vec3(two_u) / vec3(one_u); + let div5 = vec4(two_f) / vec4(one_f); // Remainder - let rem0 = 2 % 1; - let rem1 = 2u % 1u; - let rem2 = 2.0 % 1.0; - let rem3 = vec2(2) % vec2(1); - let rem4 = vec3(2u) % vec3(1u); - let rem5 = vec4(2.0) % vec4(1.0); + let rem0 = two_i % one_i; + let rem1 = two_u % one_u; + let rem2 = two_f % one_f; + let rem3 = vec2(two_i) % vec2(one_i); + let rem4 = vec3(two_u) % vec3(one_u); + let rem5 = vec4(two_f) % vec4(one_f); // Binary arithmetic expressions with mixed scalar and vector operands { - let add0 = vec2(2) + 1; - let add1 = 2 + vec2(1); - let add2 = vec2(2u) + 1u; - let add3 = 2u + vec2(1u); - let add4 = vec2(2.0) + 1.0; - let add5 = 2.0 + vec2(1.0); - - let sub0 = vec2(2) - 1; - let sub1 = 2 - vec2(1); - let sub2 = vec2(2u) - 1u; - let sub3 = 2u - vec2(1u); - let sub4 = vec2(2.0) - 1.0; - let sub5 = 2.0 - vec2(1.0); - - let mul0 = vec2(2) * 1; - let mul1 = 2 * vec2(1); - let mul2 = vec2(2u) * 1u; - let mul3 = 2u * vec2(1u); - let mul4 = vec2(2.0) * 1.0; - let mul5 = 2.0 * vec2(1.0); - - let div0 = vec2(2) / 1; - let div1 = 2 / vec2(1); - let div2 = vec2(2u) / 1u; - let div3 = 2u / vec2(1u); - let div4 = vec2(2.0) / 1.0; - let div5 = 2.0 / vec2(1.0); - - let rem0 = vec2(2) % 1; - let rem1 = 2 % vec2(1); - let rem2 = vec2(2u) % 1u; - let rem3 = 2u % vec2(1u); - let rem4 = vec2(2.0) % 1.0; - let rem5 = 2.0 % vec2(1.0); + let add0 = vec2(two_i) + one_i; + let add1 = two_i + vec2(one_i); + let add2 = vec2(two_u) + one_u; + let add3 = two_u + vec2(one_u); + let add4 = vec2(two_f) + one_f; + let add5 = two_f + vec2(one_f); + + let sub0 = vec2(two_i) - one_i; + let sub1 = two_i - vec2(one_i); + let sub2 = vec2(two_u) - one_u; + let sub3 = two_u - vec2(one_u); + let sub4 = vec2(two_f) - one_f; + let sub5 = two_f - vec2(one_f); + + let mul0 = vec2(two_i) * one_i; + let mul1 = two_i * vec2(one_i); + let mul2 = vec2(two_u) * one_u; + let mul3 = two_u * vec2(one_u); + let mul4 = vec2(two_f) * one_f; + let mul5 = two_f * vec2(one_f); + + let div0 = vec2(two_i) / one_i; + let div1 = two_i / vec2(one_i); + let div2 = vec2(two_u) / one_u; + let div3 = two_u / vec2(one_u); + let div4 = vec2(two_f) / one_f; + let div5 = two_f / vec2(one_f); + + let rem0 = vec2(two_i) % one_i; + let rem1 = two_i % vec2(one_i); + let rem2 = vec2(two_u) % one_u; + let rem3 = two_u % vec2(one_u); + let rem4 = vec2(two_f) % one_f; + let rem5 = two_f % vec2(one_f); } // Matrix arithmetic let add = mat3x3() + mat3x3(); let sub = mat3x3() - mat3x3(); - let mul_scalar0 = mat3x3() * 1.0; - let mul_scalar1 = 2.0 * mat3x3(); + let mul_scalar0 = mat3x3() * one_f; + let mul_scalar1 = two_f * mat3x3(); - let mul_vector0 = mat4x3() * vec4(1.0); - let mul_vector1 = vec3f(2.0) * mat4x3f(); + let mul_vector0 = mat4x3() * vec4(one_f); + let mul_vector1 = vec3f(two_f) * mat4x3f(); let mul = mat4x3() * mat3x4(); } fn bit() { + let one_i = 1i; + let one_u = 1u; + let two_i = 2i; + let two_u = 2u; + // unary - let flip0 = ~1; - let flip1 = ~1u; - let flip2 = ~vec2(1); - let flip3 = ~vec3(1u); + let flip0 = ~one_i; + let flip1 = ~one_u; + let flip2 = ~vec2(one_i); + let flip3 = ~vec3(one_u); // binary - let or0 = 2 | 1; - let or1 = 2u | 1u; - let or2 = vec2(2) | vec2(1); - let or3 = vec3(2u) | vec3(1u); - - let and0 = 2 & 1; - let and1 = 2u & 1u; - let and2 = vec2(2) & vec2(1); - let and3 = vec3(2u) & vec3(1u); - - let xor0 = 2 ^ 1; - let xor1 = 2u ^ 1u; - let xor2 = vec2(2) ^ vec2(1); - let xor3 = vec3(2u) ^ vec3(1u); - - let shl0 = 2 << 1u; - let shl1 = 2u << 1u; - let shl2 = vec2(2) << vec2(1u); - let shl3 = vec3(2u) << vec3(1u); - - let shr0 = 2 >> 1u; - let shr1 = 2u >> 1u; - let shr2 = vec2(2) >> vec2(1u); - let shr3 = vec3(2u) >> vec3(1u); + let or0 = two_i | one_i; + let or1 = two_u | one_u; + let or2 = vec2(two_i) | vec2(one_i); + let or3 = vec3(two_u) | vec3(one_u); + + let and0 = two_i & one_i; + let and1 = two_u & one_u; + let and2 = vec2(two_i) & vec2(one_i); + let and3 = vec3(two_u) & vec3(one_u); + + let xor0 = two_i ^ one_i; + let xor1 = two_u ^ one_u; + let xor2 = vec2(two_i) ^ vec2(one_i); + let xor3 = vec3(two_u) ^ vec3(one_u); + + let shl0 = two_i << one_u; + let shl1 = two_u << one_u; + let shl2 = vec2(two_i) << vec2(one_u); + let shl3 = vec3(two_u) << vec3(one_u); + + let shr0 = two_i >> one_u; + let shr1 = two_u >> one_u; + let shr2 = vec2(two_i) >> vec2(one_u); + let shr3 = vec3(two_u) >> vec3(one_u); } fn comparison() { - let eq0 = 2 == 1; - let eq1 = 2u == 1u; - let eq2 = 2.0 == 1.0; - let eq3 = vec2(2) == vec2(1); - let eq4 = vec3(2u) == vec3(1u); - let eq5 = vec4(2.0) == vec4(1.0); - - let neq0 = 2 != 1; - let neq1 = 2u != 1u; - let neq2 = 2.0 != 1.0; - let neq3 = vec2(2) != vec2(1); - let neq4 = vec3(2u) != vec3(1u); - let neq5 = vec4(2.0) != vec4(1.0); - - let lt0 = 2 < 1; - let lt1 = 2u < 1u; - let lt2 = 2.0 < 1.0; - let lt3 = vec2(2) < vec2(1); - let lt4 = vec3(2u) < vec3(1u); - let lt5 = vec4(2.0) < vec4(1.0); - - let lte0 = 2 <= 1; - let lte1 = 2u <= 1u; - let lte2 = 2.0 <= 1.0; - let lte3 = vec2(2) <= vec2(1); - let lte4 = vec3(2u) <= vec3(1u); - let lte5 = vec4(2.0) <= vec4(1.0); - - let gt0 = 2 > 1; - let gt1 = 2u > 1u; - let gt2 = 2.0 > 1.0; - let gt3 = vec2(2) > vec2(1); - let gt4 = vec3(2u) > vec3(1u); - let gt5 = vec4(2.0) > vec4(1.0); - - let gte0 = 2 >= 1; - let gte1 = 2u >= 1u; - let gte2 = 2.0 >= 1.0; - let gte3 = vec2(2) >= vec2(1); - let gte4 = vec3(2u) >= vec3(1u); - let gte5 = vec4(2.0) >= vec4(1.0); + let one_i = 1i; + let one_u = 1u; + let one_f = 1.0; + let two_i = 2i; + let two_u = 2u; + let two_f = 2.0; + + let eq0 = two_i == one_i; + let eq1 = two_u == one_u; + let eq2 = two_f == one_f; + let eq3 = vec2(two_i) == vec2(one_i); + let eq4 = vec3(two_u) == vec3(one_u); + let eq5 = vec4(two_f) == vec4(one_f); + + let neq0 = two_i != one_i; + let neq1 = two_u != one_u; + let neq2 = two_f != one_f; + let neq3 = vec2(two_i) != vec2(one_i); + let neq4 = vec3(two_u) != vec3(one_u); + let neq5 = vec4(two_f) != vec4(one_f); + + let lt0 = two_i < one_i; + let lt1 = two_u < one_u; + let lt2 = two_f < one_f; + let lt3 = vec2(two_i) < vec2(one_i); + let lt4 = vec3(two_u) < vec3(one_u); + let lt5 = vec4(two_f) < vec4(one_f); + + let lte0 = two_i <= one_i; + let lte1 = two_u <= one_u; + let lte2 = two_f <= one_f; + let lte3 = vec2(two_i) <= vec2(one_i); + let lte4 = vec3(two_u) <= vec3(one_u); + let lte5 = vec4(two_f) <= vec4(one_f); + + let gt0 = two_i > one_i; + let gt1 = two_u > one_u; + let gt2 = two_f > one_f; + let gt3 = vec2(two_i) > vec2(one_i); + let gt4 = vec3(two_u) > vec3(one_u); + let gt5 = vec4(two_f) > vec4(one_f); + + let gte0 = two_i >= one_i; + let gte1 = two_u >= one_u; + let gte2 = two_f >= one_f; + let gte3 = vec2(two_i) >= vec2(one_i); + let gte4 = vec3(two_u) >= vec3(one_u); + let gte5 = vec4(two_f) >= vec4(one_f); } fn assignment() { - var a = 1; + let zero_i = 0i; + let one_i = 1i; + let one_u = 1u; + let two_u = 2u; + + var a = one_i; - a += 1; - a -= 1; + a += one_i; + a -= one_i; a *= a; a /= a; - a %= 1; - a &= 0; - a |= 0; - a ^= 0; - a <<= 2u; - a >>= 1u; + a %= one_i; + a &= zero_i; + a |= zero_i; + a ^= zero_i; + a <<= two_u; + a >>= one_u; a++; a--; var vec0: vec3 = vec3(); - vec0[1]++; - vec0[1]--; + vec0[one_i]++; + vec0[one_i]--; } @compute @workgroup_size(1) @@ -266,12 +293,13 @@ fn main() { } fn negation_avoids_prefix_decrement() { - let p0 = -1; - let p1 = - -2; - let p2 = -(-3); - let p3 = -(- 4); - let p4 = - - -5; - let p5 = - - - - 6; - let p6 = - - -(- -7); - let p7 = (- - - - -8); + let x = 1; + let p0 = -x; + let p1 = - -x; + let p2 = -(-x); + let p3 = -(- x); + let p4 = - - -x; + let p5 = - - - - x; + let p6 = - - -(- -x); + let p7 = (- - - - -x); } diff --git a/tests/out/glsl/operators.main.Compute.glsl b/tests/out/glsl/operators.main.Compute.glsl index a1a7131e99..83dd56f8a4 100644 --- a/tests/out/glsl/operators.main.Compute.glsl +++ b/tests/out/glsl/operators.main.Compute.glsl @@ -47,7 +47,10 @@ vec3 bool_cast(vec3 x) { } void logical() { - bvec2 neg1_ = bvec2(false, false); + bool neg0_ = !(true); + bvec2 neg1_ = not(bvec2(true)); + bool or = (true || false); + bool and = (true && false); bool bitwise_or0_ = (true || false); bvec3 bitwise_or1_ = bvec3(bvec3(true).x || bvec3(false).x, bvec3(true).y || bvec3(false).y, bvec3(true).z || bvec3(false).z); bool bitwise_and0_ = (true && false); @@ -55,138 +58,192 @@ void logical() { } void arithmetic() { - ivec2 neg1_1 = ivec2(-1, -1); - vec2 neg2_ = vec2(-1.0, -1.0); + float neg0_1 = -(1.0); + ivec2 neg1_1 = -(ivec2(1)); + vec2 neg2_ = -(vec2(1.0)); + int add0_ = (2 + 1); + uint add1_ = (2u + 1u); + float add2_ = (2.0 + 1.0); ivec2 add3_ = (ivec2(2) + ivec2(1)); uvec3 add4_ = (uvec3(2u) + uvec3(1u)); vec4 add5_ = (vec4(2.0) + vec4(1.0)); + int sub0_ = (2 - 1); + uint sub1_ = (2u - 1u); + float sub2_ = (2.0 - 1.0); ivec2 sub3_ = (ivec2(2) - ivec2(1)); uvec3 sub4_ = (uvec3(2u) - uvec3(1u)); vec4 sub5_ = (vec4(2.0) - vec4(1.0)); + int mul0_ = (2 * 1); + uint mul1_ = (2u * 1u); + float mul2_ = (2.0 * 1.0); ivec2 mul3_ = (ivec2(2) * ivec2(1)); uvec3 mul4_ = (uvec3(2u) * uvec3(1u)); vec4 mul5_ = (vec4(2.0) * vec4(1.0)); + int div0_ = (2 / 1); + uint div1_ = (2u / 1u); + float div2_ = (2.0 / 1.0); ivec2 div3_ = (ivec2(2) / ivec2(1)); uvec3 div4_ = (uvec3(2u) / uvec3(1u)); vec4 div5_ = (vec4(2.0) / vec4(1.0)); + int rem0_ = (2 % 1); + uint rem1_ = (2u % 1u); + float rem2_ = (2.0 - 1.0 * trunc(2.0 / 1.0)); ivec2 rem3_ = (ivec2(2) % ivec2(1)); uvec3 rem4_ = (uvec3(2u) % uvec3(1u)); vec4 rem5_ = (vec4(2.0) - vec4(1.0) * trunc(vec4(2.0) / vec4(1.0))); { - ivec2 add0_ = (ivec2(2) + ivec2(1)); - ivec2 add1_ = (ivec2(2) + ivec2(1)); - uvec2 add2_ = (uvec2(2u) + uvec2(1u)); + ivec2 add0_1 = (ivec2(2) + ivec2(1)); + ivec2 add1_1 = (ivec2(2) + ivec2(1)); + uvec2 add2_1 = (uvec2(2u) + uvec2(1u)); uvec2 add3_1 = (uvec2(2u) + uvec2(1u)); vec2 add4_1 = (vec2(2.0) + vec2(1.0)); vec2 add5_1 = (vec2(2.0) + vec2(1.0)); - ivec2 sub0_ = (ivec2(2) - ivec2(1)); - ivec2 sub1_ = (ivec2(2) - ivec2(1)); - uvec2 sub2_ = (uvec2(2u) - uvec2(1u)); + ivec2 sub0_1 = (ivec2(2) - ivec2(1)); + ivec2 sub1_1 = (ivec2(2) - ivec2(1)); + uvec2 sub2_1 = (uvec2(2u) - uvec2(1u)); uvec2 sub3_1 = (uvec2(2u) - uvec2(1u)); vec2 sub4_1 = (vec2(2.0) - vec2(1.0)); vec2 sub5_1 = (vec2(2.0) - vec2(1.0)); - ivec2 mul0_ = ivec2(2, 2); - ivec2 mul1_ = ivec2(2, 2); - uvec2 mul2_ = uvec2(2u, 2u); - uvec2 mul3_1 = uvec2(2u, 2u); - vec2 mul4_1 = vec2(2.0, 2.0); - vec2 mul5_1 = vec2(2.0, 2.0); - ivec2 div0_ = (ivec2(2) / ivec2(1)); - ivec2 div1_ = (ivec2(2) / ivec2(1)); - uvec2 div2_ = (uvec2(2u) / uvec2(1u)); + ivec2 mul0_1 = (ivec2(2) * 1); + ivec2 mul1_1 = (2 * ivec2(1)); + uvec2 mul2_1 = (uvec2(2u) * 1u); + uvec2 mul3_1 = (2u * uvec2(1u)); + vec2 mul4_1 = (vec2(2.0) * 1.0); + vec2 mul5_1 = (2.0 * vec2(1.0)); + ivec2 div0_1 = (ivec2(2) / ivec2(1)); + ivec2 div1_1 = (ivec2(2) / ivec2(1)); + uvec2 div2_1 = (uvec2(2u) / uvec2(1u)); uvec2 div3_1 = (uvec2(2u) / uvec2(1u)); vec2 div4_1 = (vec2(2.0) / vec2(1.0)); vec2 div5_1 = (vec2(2.0) / vec2(1.0)); - ivec2 rem0_ = (ivec2(2) % ivec2(1)); - ivec2 rem1_ = (ivec2(2) % ivec2(1)); - uvec2 rem2_ = (uvec2(2u) % uvec2(1u)); + ivec2 rem0_1 = (ivec2(2) % ivec2(1)); + ivec2 rem1_1 = (ivec2(2) % ivec2(1)); + uvec2 rem2_1 = (uvec2(2u) % uvec2(1u)); uvec2 rem3_1 = (uvec2(2u) % uvec2(1u)); vec2 rem4_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0))); vec2 rem5_1 = (vec2(2.0) - vec2(1.0) * trunc(vec2(2.0) / vec2(1.0))); } mat3x3 add = (mat3x3(0.0) + mat3x3(0.0)); mat3x3 sub = (mat3x3(0.0) - mat3x3(0.0)); - mat3x3 mul_scalar0_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); - mat3x3 mul_scalar1_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); + mat3x3 mul_scalar0_ = (mat3x3(0.0) * 1.0); + mat3x3 mul_scalar1_ = (2.0 * mat3x3(0.0)); vec3 mul_vector0_ = (mat4x3(0.0) * vec4(1.0)); vec4 mul_vector1_ = (vec3(2.0) * mat4x3(0.0)); mat3x3 mul = (mat4x3(0.0) * mat3x4(0.0)); } void bit() { - ivec2 flip2_ = ivec2(-2, -2); - uvec3 flip3_ = uvec3(4294967294u, 4294967294u, 4294967294u); + int flip0_ = ~(1); + uint flip1_ = ~(1u); + ivec2 flip2_ = ~(ivec2(1)); + uvec3 flip3_ = ~(uvec3(1u)); + int or0_ = (2 | 1); + uint or1_ = (2u | 1u); ivec2 or2_ = (ivec2(2) | ivec2(1)); uvec3 or3_ = (uvec3(2u) | uvec3(1u)); + int and0_ = (2 & 1); + uint and1_ = (2u & 1u); ivec2 and2_ = (ivec2(2) & ivec2(1)); uvec3 and3_ = (uvec3(2u) & uvec3(1u)); + int xor0_ = (2 ^ 1); + uint xor1_ = (2u ^ 1u); ivec2 xor2_ = (ivec2(2) ^ ivec2(1)); uvec3 xor3_ = (uvec3(2u) ^ uvec3(1u)); + int shl0_ = (2 << 1u); + uint shl1_ = (2u << 1u); ivec2 shl2_ = (ivec2(2) << uvec2(1u)); uvec3 shl3_ = (uvec3(2u) << uvec3(1u)); + int shr0_ = (2 >> 1u); + uint shr1_ = (2u >> 1u); ivec2 shr2_ = (ivec2(2) >> uvec2(1u)); uvec3 shr3_ = (uvec3(2u) >> uvec3(1u)); } void comparison() { + bool eq0_ = (2 == 1); + bool eq1_ = (2u == 1u); + bool eq2_ = (2.0 == 1.0); bvec2 eq3_ = equal(ivec2(2), ivec2(1)); bvec3 eq4_ = equal(uvec3(2u), uvec3(1u)); bvec4 eq5_ = equal(vec4(2.0), vec4(1.0)); + bool neq0_ = (2 != 1); + bool neq1_ = (2u != 1u); + bool neq2_ = (2.0 != 1.0); bvec2 neq3_ = notEqual(ivec2(2), ivec2(1)); bvec3 neq4_ = notEqual(uvec3(2u), uvec3(1u)); bvec4 neq5_ = notEqual(vec4(2.0), vec4(1.0)); + bool lt0_ = (2 < 1); + bool lt1_ = (2u < 1u); + bool lt2_ = (2.0 < 1.0); bvec2 lt3_ = lessThan(ivec2(2), ivec2(1)); bvec3 lt4_ = lessThan(uvec3(2u), uvec3(1u)); bvec4 lt5_ = lessThan(vec4(2.0), vec4(1.0)); + bool lte0_ = (2 <= 1); + bool lte1_ = (2u <= 1u); + bool lte2_ = (2.0 <= 1.0); bvec2 lte3_ = lessThanEqual(ivec2(2), ivec2(1)); bvec3 lte4_ = lessThanEqual(uvec3(2u), uvec3(1u)); bvec4 lte5_ = lessThanEqual(vec4(2.0), vec4(1.0)); + bool gt0_ = (2 > 1); + bool gt1_ = (2u > 1u); + bool gt2_ = (2.0 > 1.0); bvec2 gt3_ = greaterThan(ivec2(2), ivec2(1)); bvec3 gt4_ = greaterThan(uvec3(2u), uvec3(1u)); bvec4 gt5_ = greaterThan(vec4(2.0), vec4(1.0)); + bool gte0_ = (2 >= 1); + bool gte1_ = (2u >= 1u); + bool gte2_ = (2.0 >= 1.0); bvec2 gte3_ = greaterThanEqual(ivec2(2), ivec2(1)); bvec3 gte4_ = greaterThanEqual(uvec3(2u), uvec3(1u)); bvec4 gte5_ = greaterThanEqual(vec4(2.0), vec4(1.0)); } void assignment() { - int a_1 = 1; + int a_1 = 0; ivec3 vec0_ = ivec3(0); - int _e3 = a_1; - a_1 = (_e3 + 1); - int _e6 = a_1; - a_1 = (_e6 - 1); - int _e8 = a_1; + a_1 = 1; + int _e5 = a_1; + a_1 = (_e5 + 1); + int _e7 = a_1; + a_1 = (_e7 - 1); int _e9 = a_1; - a_1 = (_e9 * _e8); - int _e11 = a_1; + int _e10 = a_1; + a_1 = (_e10 * _e9); int _e12 = a_1; - a_1 = (_e12 / _e11); + int _e13 = a_1; + a_1 = (_e13 / _e12); int _e15 = a_1; a_1 = (_e15 % 1); - int _e18 = a_1; - a_1 = (_e18 & 0); + int _e17 = a_1; + a_1 = (_e17 & 0); + int _e19 = a_1; + a_1 = (_e19 | 0); int _e21 = a_1; - a_1 = (_e21 | 0); - int _e24 = a_1; - a_1 = (_e24 ^ 0); - int _e27 = a_1; - a_1 = (_e27 << 2u); - int _e30 = a_1; - a_1 = (_e30 >> 1u); - int _e33 = a_1; - a_1 = (_e33 + 1); - int _e36 = a_1; - a_1 = (_e36 - 1); - int _e42 = vec0_.y; - vec0_.y = (_e42 + 1); - int _e46 = vec0_.y; - vec0_.y = (_e46 - 1); + a_1 = (_e21 ^ 0); + int _e23 = a_1; + a_1 = (_e23 << 2u); + int _e25 = a_1; + a_1 = (_e25 >> 1u); + int _e28 = a_1; + a_1 = (_e28 + 1); + int _e31 = a_1; + a_1 = (_e31 - 1); + int _e37 = vec0_[1]; + vec0_[1] = (_e37 + 1); + int _e41 = vec0_[1]; + vec0_[1] = (_e41 - 1); return; } void negation_avoids_prefix_decrement() { - return; + int p0_ = -(1); + int p1_ = -(-(1)); + int p2_ = -(-(1)); + int p3_ = -(-(1)); + int p4_ = -(-(-(1))); + int p5_ = -(-(-(-(1)))); + int p6_ = -(-(-(-(-(1))))); + int p7_ = -(-(-(-(-(1))))); } void main() { diff --git a/tests/out/hlsl/operators.hlsl b/tests/out/hlsl/operators.hlsl index 7074d1d562..6d18d07ed6 100644 --- a/tests/out/hlsl/operators.hlsl +++ b/tests/out/hlsl/operators.hlsl @@ -45,7 +45,10 @@ float3 bool_cast(float3 x) void logical() { - bool2 neg1_ = bool2(false, false); + bool neg0_ = !(true); + bool2 neg1_ = !((true).xx); + bool or_ = (true || false); + bool and_ = (true && false); bool bitwise_or0_ = (true | false); bool3 bitwise_or1_ = ((true).xxx | (false).xxx); bool bitwise_and0_ = (true & false); @@ -54,59 +57,75 @@ void logical() void arithmetic() { - int2 neg1_1 = int2(-1, -1); - float2 neg2_ = float2(-1.0, -1.0); + float neg0_1 = -(1.0); + int2 neg1_1 = -((1).xx); + float2 neg2_ = -((1.0).xx); + int add0_ = (2 + 1); + uint add1_ = (2u + 1u); + float add2_ = (2.0 + 1.0); int2 add3_ = ((2).xx + (1).xx); uint3 add4_ = ((2u).xxx + (1u).xxx); float4 add5_ = ((2.0).xxxx + (1.0).xxxx); + int sub0_ = (2 - 1); + uint sub1_ = (2u - 1u); + float sub2_ = (2.0 - 1.0); int2 sub3_ = ((2).xx - (1).xx); uint3 sub4_ = ((2u).xxx - (1u).xxx); float4 sub5_ = ((2.0).xxxx - (1.0).xxxx); + int mul0_ = (2 * 1); + uint mul1_ = (2u * 1u); + float mul2_ = (2.0 * 1.0); int2 mul3_ = ((2).xx * (1).xx); uint3 mul4_ = ((2u).xxx * (1u).xxx); float4 mul5_ = ((2.0).xxxx * (1.0).xxxx); + int div0_ = (2 / 1); + uint div1_ = (2u / 1u); + float div2_ = (2.0 / 1.0); int2 div3_ = ((2).xx / (1).xx); uint3 div4_ = ((2u).xxx / (1u).xxx); float4 div5_ = ((2.0).xxxx / (1.0).xxxx); + int rem0_ = (2 % 1); + uint rem1_ = (2u % 1u); + float rem2_ = fmod(2.0, 1.0); int2 rem3_ = ((2).xx % (1).xx); uint3 rem4_ = ((2u).xxx % (1u).xxx); float4 rem5_ = fmod((2.0).xxxx, (1.0).xxxx); { - int2 add0_ = ((2).xx + (1).xx); - int2 add1_ = ((2).xx + (1).xx); - uint2 add2_ = ((2u).xx + (1u).xx); + int2 add0_1 = ((2).xx + (1).xx); + int2 add1_1 = ((2).xx + (1).xx); + uint2 add2_1 = ((2u).xx + (1u).xx); uint2 add3_1 = ((2u).xx + (1u).xx); float2 add4_1 = ((2.0).xx + (1.0).xx); float2 add5_1 = ((2.0).xx + (1.0).xx); - int2 sub0_ = ((2).xx - (1).xx); - int2 sub1_ = ((2).xx - (1).xx); - uint2 sub2_ = ((2u).xx - (1u).xx); + int2 sub0_1 = ((2).xx - (1).xx); + int2 sub1_1 = ((2).xx - (1).xx); + uint2 sub2_1 = ((2u).xx - (1u).xx); uint2 sub3_1 = ((2u).xx - (1u).xx); float2 sub4_1 = ((2.0).xx - (1.0).xx); float2 sub5_1 = ((2.0).xx - (1.0).xx); - int2 mul0_ = int2(2, 2); - int2 mul1_ = int2(2, 2); - uint2 mul2_ = uint2(2u, 2u); - uint2 mul3_1 = uint2(2u, 2u); - float2 mul4_1 = float2(2.0, 2.0); - float2 mul5_1 = float2(2.0, 2.0); - int2 div0_ = ((2).xx / (1).xx); - int2 div1_ = ((2).xx / (1).xx); - uint2 div2_ = ((2u).xx / (1u).xx); + int2 mul0_1 = ((2).xx * 1); + int2 mul1_1 = (2 * (1).xx); + uint2 mul2_1 = ((2u).xx * 1u); + uint2 mul3_1 = (2u * (1u).xx); + float2 mul4_1 = ((2.0).xx * 1.0); + float2 mul5_1 = (2.0 * (1.0).xx); + int2 div0_1 = ((2).xx / (1).xx); + int2 div1_1 = ((2).xx / (1).xx); + uint2 div2_1 = ((2u).xx / (1u).xx); uint2 div3_1 = ((2u).xx / (1u).xx); float2 div4_1 = ((2.0).xx / (1.0).xx); float2 div5_1 = ((2.0).xx / (1.0).xx); - int2 rem0_ = ((2).xx % (1).xx); - int2 rem1_ = ((2).xx % (1).xx); - uint2 rem2_ = ((2u).xx % (1u).xx); + int2 rem0_1 = ((2).xx % (1).xx); + int2 rem1_1 = ((2).xx % (1).xx); + uint2 rem2_1 = ((2u).xx % (1u).xx); uint2 rem3_1 = ((2u).xx % (1u).xx); float2 rem4_1 = fmod((2.0).xx, (1.0).xx); float2 rem5_1 = fmod((2.0).xx, (1.0).xx); } float3x3 add = ((float3x3)0 + (float3x3)0); float3x3 sub = ((float3x3)0 - (float3x3)0); - float3x3 mul_scalar0_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)); - float3x3 mul_scalar1_ = float3x3(float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0), float3(0.0, 0.0, 0.0)); + float3x3 mul_scalar0_ = mul(1.0, (float3x3)0); + float3x3 mul_scalar1_ = mul((float3x3)0, 2.0); float3 mul_vector0_ = mul((1.0).xxxx, (float4x3)0); float4 mul_vector1_ = mul((float4x3)0, (2.0).xxx); float3x3 mul_ = mul((float3x4)0, (float4x3)0); @@ -114,37 +133,67 @@ void arithmetic() void bit() { - int2 flip2_ = int2(-2, -2); - uint3 flip3_ = uint3(4294967294u, 4294967294u, 4294967294u); + int flip0_ = ~(1); + uint flip1_ = ~(1u); + int2 flip2_ = ~((1).xx); + uint3 flip3_ = ~((1u).xxx); + int or0_ = (2 | 1); + uint or1_ = (2u | 1u); int2 or2_ = ((2).xx | (1).xx); uint3 or3_ = ((2u).xxx | (1u).xxx); + int and0_ = (2 & 1); + uint and1_ = (2u & 1u); int2 and2_ = ((2).xx & (1).xx); uint3 and3_ = ((2u).xxx & (1u).xxx); + int xor0_ = (2 ^ 1); + uint xor1_ = (2u ^ 1u); int2 xor2_ = ((2).xx ^ (1).xx); uint3 xor3_ = ((2u).xxx ^ (1u).xxx); + int shl0_ = (2 << 1u); + uint shl1_ = (2u << 1u); int2 shl2_ = ((2).xx << (1u).xx); uint3 shl3_ = ((2u).xxx << (1u).xxx); + int shr0_ = (2 >> 1u); + uint shr1_ = (2u >> 1u); int2 shr2_ = ((2).xx >> (1u).xx); uint3 shr3_ = ((2u).xxx >> (1u).xxx); } void comparison() { + bool eq0_ = (2 == 1); + bool eq1_ = (2u == 1u); + bool eq2_ = (2.0 == 1.0); bool2 eq3_ = ((2).xx == (1).xx); bool3 eq4_ = ((2u).xxx == (1u).xxx); bool4 eq5_ = ((2.0).xxxx == (1.0).xxxx); + bool neq0_ = (2 != 1); + bool neq1_ = (2u != 1u); + bool neq2_ = (2.0 != 1.0); bool2 neq3_ = ((2).xx != (1).xx); bool3 neq4_ = ((2u).xxx != (1u).xxx); bool4 neq5_ = ((2.0).xxxx != (1.0).xxxx); + bool lt0_ = (2 < 1); + bool lt1_ = (2u < 1u); + bool lt2_ = (2.0 < 1.0); bool2 lt3_ = ((2).xx < (1).xx); bool3 lt4_ = ((2u).xxx < (1u).xxx); bool4 lt5_ = ((2.0).xxxx < (1.0).xxxx); + bool lte0_ = (2 <= 1); + bool lte1_ = (2u <= 1u); + bool lte2_ = (2.0 <= 1.0); bool2 lte3_ = ((2).xx <= (1).xx); bool3 lte4_ = ((2u).xxx <= (1u).xxx); bool4 lte5_ = ((2.0).xxxx <= (1.0).xxxx); + bool gt0_ = (2 > 1); + bool gt1_ = (2u > 1u); + bool gt2_ = (2.0 > 1.0); bool2 gt3_ = ((2).xx > (1).xx); bool3 gt4_ = ((2u).xxx > (1u).xxx); bool4 gt5_ = ((2.0).xxxx > (1.0).xxxx); + bool gte0_ = (2 >= 1); + bool gte1_ = (2u >= 1u); + bool gte2_ = (2.0 >= 1.0); bool2 gte3_ = ((2).xx >= (1).xx); bool3 gte4_ = ((2u).xxx >= (1u).xxx); bool4 gte5_ = ((2.0).xxxx >= (1.0).xxxx); @@ -152,45 +201,53 @@ void comparison() void assignment() { - int a_1 = 1; + int a_1 = (int)0; int3 vec0_ = (int3)0; - int _expr3 = a_1; - a_1 = (_expr3 + 1); - int _expr6 = a_1; - a_1 = (_expr6 - 1); - int _expr8 = a_1; + a_1 = 1; + int _expr5 = a_1; + a_1 = (_expr5 + 1); + int _expr7 = a_1; + a_1 = (_expr7 - 1); int _expr9 = a_1; - a_1 = (_expr9 * _expr8); - int _expr11 = a_1; + int _expr10 = a_1; + a_1 = (_expr10 * _expr9); int _expr12 = a_1; - a_1 = (_expr12 / _expr11); + int _expr13 = a_1; + a_1 = (_expr13 / _expr12); int _expr15 = a_1; a_1 = (_expr15 % 1); - int _expr18 = a_1; - a_1 = (_expr18 & 0); + int _expr17 = a_1; + a_1 = (_expr17 & 0); + int _expr19 = a_1; + a_1 = (_expr19 | 0); int _expr21 = a_1; - a_1 = (_expr21 | 0); - int _expr24 = a_1; - a_1 = (_expr24 ^ 0); - int _expr27 = a_1; - a_1 = (_expr27 << 2u); - int _expr30 = a_1; - a_1 = (_expr30 >> 1u); - int _expr33 = a_1; - a_1 = (_expr33 + 1); - int _expr36 = a_1; - a_1 = (_expr36 - 1); - int _expr42 = vec0_.y; - vec0_.y = (_expr42 + 1); - int _expr46 = vec0_.y; - vec0_.y = (_expr46 - 1); + a_1 = (_expr21 ^ 0); + int _expr23 = a_1; + a_1 = (_expr23 << 2u); + int _expr25 = a_1; + a_1 = (_expr25 >> 1u); + int _expr28 = a_1; + a_1 = (_expr28 + 1); + int _expr31 = a_1; + a_1 = (_expr31 - 1); + int _expr37 = vec0_[1]; + vec0_[1] = (_expr37 + 1); + int _expr41 = vec0_[1]; + vec0_[1] = (_expr41 - 1); return; } void negation_avoids_prefix_decrement() { - return; + int p0_ = -(1); + int p1_ = -(-(1)); + int p2_ = -(-(1)); + int p3_ = -(-(1)); + int p4_ = -(-(-(1))); + int p5_ = -(-(-(-(1)))); + int p6_ = -(-(-(-(-(1))))); + int p7_ = -(-(-(-(-(1))))); } [numthreads(1, 1, 1)] diff --git a/tests/out/msl/operators.msl b/tests/out/msl/operators.msl index 2a7463646f..114865451a 100644 --- a/tests/out/msl/operators.msl +++ b/tests/out/msl/operators.msl @@ -51,7 +51,10 @@ metal::float3 bool_cast( void logical( ) { - metal::bool2 neg1_ = metal::bool2(false, false); + bool neg0_ = !(true); + metal::bool2 neg1_ = !(metal::bool2(true)); + bool or_ = true || false; + bool and_ = true && false; bool bitwise_or0_ = true | false; metal::bool3 bitwise_or1_ = metal::bool3(true) | metal::bool3(false); bool bitwise_and0_ = true & false; @@ -60,59 +63,75 @@ void logical( void arithmetic( ) { - metal::int2 neg1_1 = metal::int2(-1, -1); - metal::float2 neg2_ = metal::float2(-1.0, -1.0); + float neg0_1 = -(1.0); + metal::int2 neg1_1 = -(metal::int2(1)); + metal::float2 neg2_ = -(metal::float2(1.0)); + int add0_ = 2 + 1; + uint add1_ = 2u + 1u; + float add2_ = 2.0 + 1.0; metal::int2 add3_ = metal::int2(2) + metal::int2(1); metal::uint3 add4_ = metal::uint3(2u) + metal::uint3(1u); metal::float4 add5_ = metal::float4(2.0) + metal::float4(1.0); + int sub0_ = 2 - 1; + uint sub1_ = 2u - 1u; + float sub2_ = 2.0 - 1.0; metal::int2 sub3_ = metal::int2(2) - metal::int2(1); metal::uint3 sub4_ = metal::uint3(2u) - metal::uint3(1u); metal::float4 sub5_ = metal::float4(2.0) - metal::float4(1.0); + int mul0_ = 2 * 1; + uint mul1_ = 2u * 1u; + float mul2_ = 2.0 * 1.0; metal::int2 mul3_ = metal::int2(2) * metal::int2(1); metal::uint3 mul4_ = metal::uint3(2u) * metal::uint3(1u); metal::float4 mul5_ = metal::float4(2.0) * metal::float4(1.0); + int div0_ = 2 / 1; + uint div1_ = 2u / 1u; + float div2_ = 2.0 / 1.0; metal::int2 div3_ = metal::int2(2) / metal::int2(1); metal::uint3 div4_ = metal::uint3(2u) / metal::uint3(1u); metal::float4 div5_ = metal::float4(2.0) / metal::float4(1.0); + int rem0_ = 2 % 1; + uint rem1_ = 2u % 1u; + float rem2_ = metal::fmod(2.0, 1.0); metal::int2 rem3_ = metal::int2(2) % metal::int2(1); metal::uint3 rem4_ = metal::uint3(2u) % metal::uint3(1u); metal::float4 rem5_ = metal::fmod(metal::float4(2.0), metal::float4(1.0)); { - metal::int2 add0_ = metal::int2(2) + metal::int2(1); - metal::int2 add1_ = metal::int2(2) + metal::int2(1); - metal::uint2 add2_ = metal::uint2(2u) + metal::uint2(1u); + metal::int2 add0_1 = metal::int2(2) + metal::int2(1); + metal::int2 add1_1 = metal::int2(2) + metal::int2(1); + metal::uint2 add2_1 = metal::uint2(2u) + metal::uint2(1u); metal::uint2 add3_1 = metal::uint2(2u) + metal::uint2(1u); metal::float2 add4_1 = metal::float2(2.0) + metal::float2(1.0); metal::float2 add5_1 = metal::float2(2.0) + metal::float2(1.0); - metal::int2 sub0_ = metal::int2(2) - metal::int2(1); - metal::int2 sub1_ = metal::int2(2) - metal::int2(1); - metal::uint2 sub2_ = metal::uint2(2u) - metal::uint2(1u); + metal::int2 sub0_1 = metal::int2(2) - metal::int2(1); + metal::int2 sub1_1 = metal::int2(2) - metal::int2(1); + metal::uint2 sub2_1 = metal::uint2(2u) - metal::uint2(1u); metal::uint2 sub3_1 = metal::uint2(2u) - metal::uint2(1u); metal::float2 sub4_1 = metal::float2(2.0) - metal::float2(1.0); metal::float2 sub5_1 = metal::float2(2.0) - metal::float2(1.0); - metal::int2 mul0_ = metal::int2(2, 2); - metal::int2 mul1_ = metal::int2(2, 2); - metal::uint2 mul2_ = metal::uint2(2u, 2u); - metal::uint2 mul3_1 = metal::uint2(2u, 2u); - metal::float2 mul4_1 = metal::float2(2.0, 2.0); - metal::float2 mul5_1 = metal::float2(2.0, 2.0); - metal::int2 div0_ = metal::int2(2) / metal::int2(1); - metal::int2 div1_ = metal::int2(2) / metal::int2(1); - metal::uint2 div2_ = metal::uint2(2u) / metal::uint2(1u); + metal::int2 mul0_1 = metal::int2(2) * 1; + metal::int2 mul1_1 = 2 * metal::int2(1); + metal::uint2 mul2_1 = metal::uint2(2u) * 1u; + metal::uint2 mul3_1 = 2u * metal::uint2(1u); + metal::float2 mul4_1 = metal::float2(2.0) * 1.0; + metal::float2 mul5_1 = 2.0 * metal::float2(1.0); + metal::int2 div0_1 = metal::int2(2) / metal::int2(1); + metal::int2 div1_1 = metal::int2(2) / metal::int2(1); + metal::uint2 div2_1 = metal::uint2(2u) / metal::uint2(1u); metal::uint2 div3_1 = metal::uint2(2u) / metal::uint2(1u); metal::float2 div4_1 = metal::float2(2.0) / metal::float2(1.0); metal::float2 div5_1 = metal::float2(2.0) / metal::float2(1.0); - metal::int2 rem0_ = metal::int2(2) % metal::int2(1); - metal::int2 rem1_ = metal::int2(2) % metal::int2(1); - metal::uint2 rem2_ = metal::uint2(2u) % metal::uint2(1u); + metal::int2 rem0_1 = metal::int2(2) % metal::int2(1); + metal::int2 rem1_1 = metal::int2(2) % metal::int2(1); + metal::uint2 rem2_1 = metal::uint2(2u) % metal::uint2(1u); metal::uint2 rem3_1 = metal::uint2(2u) % metal::uint2(1u); metal::float2 rem4_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0)); metal::float2 rem5_1 = metal::fmod(metal::float2(2.0), metal::float2(1.0)); } metal::float3x3 add = metal::float3x3 {} + metal::float3x3 {}; metal::float3x3 sub = metal::float3x3 {} - metal::float3x3 {}; - metal::float3x3 mul_scalar0_ = metal::float3x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); - metal::float3x3 mul_scalar1_ = metal::float3x3(metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0), metal::float3(0.0, 0.0, 0.0)); + metal::float3x3 mul_scalar0_ = metal::float3x3 {} * 1.0; + metal::float3x3 mul_scalar1_ = 2.0 * metal::float3x3 {}; metal::float3 mul_vector0_ = metal::float4x3 {} * metal::float4(1.0); metal::float4 mul_vector1_ = metal::float3(2.0) * metal::float4x3 {}; metal::float3x3 mul = metal::float4x3 {} * metal::float3x4 {}; @@ -120,37 +139,67 @@ void arithmetic( void bit( ) { - metal::int2 flip2_ = metal::int2(-2, -2); - metal::uint3 flip3_ = metal::uint3(4294967294u, 4294967294u, 4294967294u); + int flip0_ = ~(1); + uint flip1_ = ~(1u); + metal::int2 flip2_ = ~(metal::int2(1)); + metal::uint3 flip3_ = ~(metal::uint3(1u)); + int or0_ = 2 | 1; + uint or1_ = 2u | 1u; metal::int2 or2_ = metal::int2(2) | metal::int2(1); metal::uint3 or3_ = metal::uint3(2u) | metal::uint3(1u); + int and0_ = 2 & 1; + uint and1_ = 2u & 1u; metal::int2 and2_ = metal::int2(2) & metal::int2(1); metal::uint3 and3_ = metal::uint3(2u) & metal::uint3(1u); + int xor0_ = 2 ^ 1; + uint xor1_ = 2u ^ 1u; metal::int2 xor2_ = metal::int2(2) ^ metal::int2(1); metal::uint3 xor3_ = metal::uint3(2u) ^ metal::uint3(1u); + int shl0_ = 2 << 1u; + uint shl1_ = 2u << 1u; metal::int2 shl2_ = metal::int2(2) << metal::uint2(1u); metal::uint3 shl3_ = metal::uint3(2u) << metal::uint3(1u); + int shr0_ = 2 >> 1u; + uint shr1_ = 2u >> 1u; metal::int2 shr2_ = metal::int2(2) >> metal::uint2(1u); metal::uint3 shr3_ = metal::uint3(2u) >> metal::uint3(1u); } void comparison( ) { + bool eq0_ = 2 == 1; + bool eq1_ = 2u == 1u; + bool eq2_ = 2.0 == 1.0; metal::bool2 eq3_ = metal::int2(2) == metal::int2(1); metal::bool3 eq4_ = metal::uint3(2u) == metal::uint3(1u); metal::bool4 eq5_ = metal::float4(2.0) == metal::float4(1.0); + bool neq0_ = 2 != 1; + bool neq1_ = 2u != 1u; + bool neq2_ = 2.0 != 1.0; metal::bool2 neq3_ = metal::int2(2) != metal::int2(1); metal::bool3 neq4_ = metal::uint3(2u) != metal::uint3(1u); metal::bool4 neq5_ = metal::float4(2.0) != metal::float4(1.0); + bool lt0_ = 2 < 1; + bool lt1_ = 2u < 1u; + bool lt2_ = 2.0 < 1.0; metal::bool2 lt3_ = metal::int2(2) < metal::int2(1); metal::bool3 lt4_ = metal::uint3(2u) < metal::uint3(1u); metal::bool4 lt5_ = metal::float4(2.0) < metal::float4(1.0); + bool lte0_ = 2 <= 1; + bool lte1_ = 2u <= 1u; + bool lte2_ = 2.0 <= 1.0; metal::bool2 lte3_ = metal::int2(2) <= metal::int2(1); metal::bool3 lte4_ = metal::uint3(2u) <= metal::uint3(1u); metal::bool4 lte5_ = metal::float4(2.0) <= metal::float4(1.0); + bool gt0_ = 2 > 1; + bool gt1_ = 2u > 1u; + bool gt2_ = 2.0 > 1.0; metal::bool2 gt3_ = metal::int2(2) > metal::int2(1); metal::bool3 gt4_ = metal::uint3(2u) > metal::uint3(1u); metal::bool4 gt5_ = metal::float4(2.0) > metal::float4(1.0); + bool gte0_ = 2 >= 1; + bool gte1_ = 2u >= 1u; + bool gte2_ = 2.0 >= 1.0; metal::bool2 gte3_ = metal::int2(2) >= metal::int2(1); metal::bool3 gte4_ = metal::uint3(2u) >= metal::uint3(1u); metal::bool4 gte5_ = metal::float4(2.0) >= metal::float4(1.0); @@ -158,44 +207,52 @@ void comparison( void assignment( ) { - int a_1 = 1; + int a_1 = {}; metal::int3 vec0_ = metal::int3 {}; - int _e3 = a_1; - a_1 = _e3 + 1; - int _e6 = a_1; - a_1 = _e6 - 1; - int _e8 = a_1; + a_1 = 1; + int _e5 = a_1; + a_1 = _e5 + 1; + int _e7 = a_1; + a_1 = _e7 - 1; int _e9 = a_1; - a_1 = _e9 * _e8; - int _e11 = a_1; + int _e10 = a_1; + a_1 = _e10 * _e9; int _e12 = a_1; - a_1 = _e12 / _e11; + int _e13 = a_1; + a_1 = _e13 / _e12; int _e15 = a_1; a_1 = _e15 % 1; - int _e18 = a_1; - a_1 = _e18 & 0; + int _e17 = a_1; + a_1 = _e17 & 0; + int _e19 = a_1; + a_1 = _e19 | 0; int _e21 = a_1; - a_1 = _e21 | 0; - int _e24 = a_1; - a_1 = _e24 ^ 0; - int _e27 = a_1; - a_1 = _e27 << 2u; - int _e30 = a_1; - a_1 = _e30 >> 1u; - int _e33 = a_1; - a_1 = _e33 + 1; - int _e36 = a_1; - a_1 = _e36 - 1; - int _e42 = vec0_.y; - vec0_.y = _e42 + 1; - int _e46 = vec0_.y; - vec0_.y = _e46 - 1; + a_1 = _e21 ^ 0; + int _e23 = a_1; + a_1 = _e23 << 2u; + int _e25 = a_1; + a_1 = _e25 >> 1u; + int _e28 = a_1; + a_1 = _e28 + 1; + int _e31 = a_1; + a_1 = _e31 - 1; + int _e37 = vec0_[1]; + vec0_[1] = _e37 + 1; + int _e41 = vec0_[1]; + vec0_[1] = _e41 - 1; return; } void negation_avoids_prefix_decrement( ) { - return; + int p0_ = -(1); + int p1_ = -(-(1)); + int p2_ = -(-(1)); + int p3_ = -(-(1)); + int p4_ = -(-(-(1))); + int p5_ = -(-(-(-(1)))); + int p6_ = -(-(-(-(-(1))))); + int p7_ = -(-(-(-(-(1))))); } kernel void main_( diff --git a/tests/out/spv/operators.spvasm b/tests/out/spv/operators.spvasm index 538c080e36..89bc4ccf28 100644 --- a/tests/out/spv/operators.spvasm +++ b/tests/out/spv/operators.spvasm @@ -1,12 +1,12 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 308 +; Bound: 377 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %297 "main" -OpExecutionMode %297 LocalSize 1 1 1 +OpEntryPoint GLCompute %366 "main" +OpExecutionMode %366 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -16,352 +16,422 @@ OpExecutionMode %297 LocalSize 1 1 1 %7 = OpTypeVector %8 4 %9 = OpTypeVector %4 2 %10 = OpTypeVector %4 3 -%11 = OpTypeVector %8 2 -%12 = OpTypeVector %6 2 -%14 = OpTypeInt 32 0 -%13 = OpTypeVector %14 3 -%15 = OpTypeVector %14 2 -%16 = OpTypeMatrix %10 3 -%17 = OpTypeMatrix %10 4 -%18 = OpTypeMatrix %3 3 -%19 = OpTypeVector %6 3 -%20 = OpConstant %4 1.0 -%21 = OpConstantComposite %3 %20 %20 %20 %20 -%22 = OpConstant %4 0.0 -%23 = OpConstantComposite %3 %22 %22 %22 %22 -%24 = OpConstant %4 0.5 -%25 = OpConstantComposite %3 %24 %24 %24 %24 -%26 = OpConstant %6 1 -%27 = OpConstantComposite %5 %26 %26 %26 %26 -%30 = OpTypeFunction %3 -%31 = OpConstantTrue %8 -%32 = OpConstant %6 0 -%33 = OpConstantFalse %8 -%34 = OpConstantComposite %7 %33 %33 %33 %33 -%35 = OpConstant %4 0.1 -%36 = OpConstantComposite %5 %32 %32 %32 %32 -%58 = OpConstant %4 2.0 +%11 = OpTypeMatrix %10 3 +%12 = OpTypeMatrix %10 4 +%13 = OpTypeMatrix %3 3 +%14 = OpTypeVector %6 3 +%15 = OpConstant %4 1.0 +%16 = OpConstantComposite %3 %15 %15 %15 %15 +%17 = OpConstant %4 0.0 +%18 = OpConstantComposite %3 %17 %17 %17 %17 +%19 = OpConstant %4 0.5 +%20 = OpConstantComposite %3 %19 %19 %19 %19 +%21 = OpConstant %6 1 +%22 = OpConstantComposite %5 %21 %21 %21 %21 +%25 = OpTypeFunction %3 +%26 = OpConstantTrue %8 +%27 = OpConstant %6 0 +%28 = OpConstantFalse %8 +%29 = OpConstantComposite %7 %28 %28 %28 %28 +%30 = OpConstant %4 0.1 +%31 = OpConstantComposite %5 %27 %27 %27 %27 +%53 = OpConstant %4 2.0 +%54 = OpConstantComposite %9 %53 %53 +%55 = OpConstantComposite %9 %15 %15 +%56 = OpConstant %4 3.0 +%57 = OpConstantComposite %9 %56 %56 +%58 = OpConstant %4 4.0 %59 = OpConstantComposite %9 %58 %58 -%60 = OpConstantComposite %9 %20 %20 -%61 = OpConstant %4 3.0 -%62 = OpConstantComposite %9 %61 %61 -%63 = OpConstant %4 4.0 -%64 = OpConstantComposite %9 %63 %63 -%65 = OpConstant %6 5 -%66 = OpConstantComposite %5 %65 %65 %65 %65 -%67 = OpConstant %6 2 -%68 = OpConstantComposite %5 %67 %67 %67 %67 -%79 = OpTypeFunction %9 -%81 = OpTypePointer Function %9 -%93 = OpTypeFunction %10 %10 -%95 = OpTypeVector %8 3 -%96 = OpConstantComposite %10 %22 %22 %22 -%98 = OpConstantComposite %10 %20 %20 %20 -%102 = OpTypeFunction %2 -%103 = OpConstantComposite %11 %33 %33 -%104 = OpConstantComposite %95 %31 %31 %31 -%105 = OpConstantComposite %95 %33 %33 %33 -%106 = OpConstantComposite %7 %31 %31 %31 %31 -%107 = OpConstantComposite %7 %33 %33 %33 %33 -%115 = OpConstant %4 -1.0 -%116 = OpConstant %6 -1 -%117 = OpConstantComposite %12 %116 %116 -%118 = OpConstantComposite %9 %115 %115 -%119 = OpConstant %6 3 -%120 = OpConstant %14 3 -%121 = OpConstantComposite %12 %67 %67 -%122 = OpConstantComposite %12 %26 %26 -%123 = OpConstant %14 2 -%124 = OpConstantComposite %13 %123 %123 %123 -%125 = OpConstant %14 1 -%126 = OpConstantComposite %13 %125 %125 %125 -%127 = OpConstantComposite %3 %58 %58 %58 %58 -%128 = OpConstantComposite %3 %20 %20 %20 %20 -%129 = OpConstant %14 0 -%130 = OpConstantComposite %15 %123 %123 -%131 = OpConstantComposite %15 %125 %125 -%132 = OpConstantComposite %12 %67 %67 -%133 = OpConstantComposite %15 %123 %123 -%134 = OpConstantComposite %9 %58 %58 -%135 = OpConstantNull %16 -%136 = OpConstantComposite %10 %22 %22 %22 -%137 = OpConstantComposite %16 %136 %136 %136 -%138 = OpConstantNull %17 -%139 = OpConstantComposite %10 %58 %58 %58 -%140 = OpConstantNull %18 -%208 = OpConstant %6 -2 -%209 = OpConstant %14 4294967294 -%210 = OpConstantComposite %12 %208 %208 -%211 = OpConstantComposite %13 %209 %209 %209 -%212 = OpConstant %6 4 -%213 = OpConstant %14 4 -%248 = OpConstantNull %19 -%250 = OpTypePointer Function %6 -%252 = OpTypePointer Function %19 -%280 = OpTypePointer Function %6 -%291 = OpConstant %6 -5 -%292 = OpConstant %6 6 -%293 = OpConstant %6 -7 -%294 = OpConstant %6 -8 -%298 = OpConstantComposite %10 %20 %20 %20 -%29 = OpFunction %3 None %30 -%28 = OpLabel -OpBranch %37 -%37 = OpLabel -%38 = OpSelect %6 %31 %26 %32 -%40 = OpCompositeConstruct %7 %31 %31 %31 %31 -%39 = OpSelect %3 %40 %21 %23 -%41 = OpSelect %3 %34 %23 %21 -%42 = OpExtInst %3 %1 FMix %23 %21 %25 -%44 = OpCompositeConstruct %3 %35 %35 %35 %35 -%43 = OpExtInst %3 %1 FMix %23 %21 %44 -%45 = OpBitcast %4 %26 -%46 = OpBitcast %3 %27 -%47 = OpCompositeConstruct %5 %38 %38 %38 %38 -%48 = OpIAdd %5 %47 %36 -%49 = OpConvertSToF %3 %48 -%50 = OpFAdd %3 %49 %39 -%51 = OpFAdd %3 %50 %42 -%52 = OpFAdd %3 %51 %43 -%53 = OpCompositeConstruct %3 %45 %45 %45 %45 -%54 = OpFAdd %3 %52 %53 -%55 = OpFAdd %3 %54 %46 -OpReturnValue %55 +%60 = OpConstant %6 5 +%61 = OpConstantComposite %5 %60 %60 %60 %60 +%62 = OpConstant %6 2 +%63 = OpConstantComposite %5 %62 %62 %62 %62 +%74 = OpTypeFunction %9 +%76 = OpTypePointer Function %9 +%88 = OpTypeFunction %10 %10 +%90 = OpTypeVector %8 3 +%91 = OpConstantComposite %10 %17 %17 %17 +%93 = OpConstantComposite %10 %15 %15 %15 +%97 = OpTypeFunction %2 +%98 = OpTypeVector %8 2 +%99 = OpConstantComposite %98 %26 %26 +%100 = OpConstantComposite %90 %26 %26 %26 +%101 = OpConstantComposite %90 %28 %28 %28 +%102 = OpConstantComposite %7 %26 %26 %26 %26 +%103 = OpConstantComposite %7 %28 %28 %28 %28 +%115 = OpTypeInt 32 0 +%116 = OpConstant %115 1 +%117 = OpConstant %115 2 +%118 = OpTypeVector %6 2 +%119 = OpConstantComposite %118 %21 %21 +%120 = OpConstantComposite %118 %62 %62 +%121 = OpTypeVector %115 3 +%122 = OpConstantComposite %121 %117 %117 %117 +%123 = OpConstantComposite %121 %116 %116 %116 +%124 = OpConstantComposite %3 %53 %53 %53 %53 +%125 = OpConstantComposite %3 %15 %15 %15 %15 +%126 = OpTypeVector %115 2 +%127 = OpConstantComposite %126 %117 %117 +%128 = OpConstantComposite %126 %116 %116 +%129 = OpConstantNull %11 +%130 = OpConstantNull %12 +%131 = OpConstantComposite %10 %53 %53 %53 +%132 = OpConstantNull %13 +%296 = OpConstantNull %14 +%298 = OpTypePointer Function %6 +%299 = OpConstantNull %6 +%301 = OpTypePointer Function %14 +%329 = OpTypePointer Function %6 +%367 = OpConstantComposite %10 %15 %15 %15 +%24 = OpFunction %3 None %25 +%23 = OpLabel +OpBranch %32 +%32 = OpLabel +%33 = OpSelect %6 %26 %21 %27 +%35 = OpCompositeConstruct %7 %26 %26 %26 %26 +%34 = OpSelect %3 %35 %16 %18 +%36 = OpSelect %3 %29 %18 %16 +%37 = OpExtInst %3 %1 FMix %18 %16 %20 +%39 = OpCompositeConstruct %3 %30 %30 %30 %30 +%38 = OpExtInst %3 %1 FMix %18 %16 %39 +%40 = OpBitcast %4 %21 +%41 = OpBitcast %3 %22 +%42 = OpCompositeConstruct %5 %33 %33 %33 %33 +%43 = OpIAdd %5 %42 %31 +%44 = OpConvertSToF %3 %43 +%45 = OpFAdd %3 %44 %34 +%46 = OpFAdd %3 %45 %37 +%47 = OpFAdd %3 %46 %38 +%48 = OpCompositeConstruct %3 %40 %40 %40 %40 +%49 = OpFAdd %3 %47 %48 +%50 = OpFAdd %3 %49 %41 +OpReturnValue %50 OpFunctionEnd -%57 = OpFunction %3 None %30 -%56 = OpLabel -OpBranch %69 -%69 = OpLabel -%70 = OpFAdd %9 %60 %59 -%71 = OpFSub %9 %70 %62 -%72 = OpFDiv %9 %71 %64 -%73 = OpSRem %5 %66 %68 -%74 = OpVectorShuffle %3 %72 %72 0 1 0 1 -%75 = OpConvertSToF %3 %73 -%76 = OpFAdd %3 %74 %75 -OpReturnValue %76 +%52 = OpFunction %3 None %25 +%51 = OpLabel +OpBranch %64 +%64 = OpLabel +%65 = OpFAdd %9 %55 %54 +%66 = OpFSub %9 %65 %57 +%67 = OpFDiv %9 %66 %59 +%68 = OpSRem %5 %61 %63 +%69 = OpVectorShuffle %3 %67 %67 0 1 0 1 +%70 = OpConvertSToF %3 %68 +%71 = OpFAdd %3 %69 %70 +OpReturnValue %71 OpFunctionEnd -%78 = OpFunction %9 None %79 +%73 = OpFunction %9 None %74 +%72 = OpLabel +%75 = OpVariable %76 Function %54 +OpBranch %77 %77 = OpLabel -%80 = OpVariable %81 Function %59 -OpBranch %82 -%82 = OpLabel -%83 = OpLoad %9 %80 -%84 = OpFAdd %9 %83 %60 -OpStore %80 %84 -%85 = OpLoad %9 %80 -%86 = OpFSub %9 %85 %62 -OpStore %80 %86 -%87 = OpLoad %9 %80 -%88 = OpFDiv %9 %87 %64 -OpStore %80 %88 -%89 = OpLoad %9 %80 -OpReturnValue %89 +%78 = OpLoad %9 %75 +%79 = OpFAdd %9 %78 %55 +OpStore %75 %79 +%80 = OpLoad %9 %75 +%81 = OpFSub %9 %80 %57 +OpStore %75 %81 +%82 = OpLoad %9 %75 +%83 = OpFDiv %9 %82 %59 +OpStore %75 %83 +%84 = OpLoad %9 %75 +OpReturnValue %84 OpFunctionEnd -%92 = OpFunction %10 None %93 -%91 = OpFunctionParameter %10 -%90 = OpLabel -OpBranch %94 -%94 = OpLabel -%97 = OpFUnordNotEqual %95 %91 %96 -%99 = OpSelect %10 %97 %98 %96 -OpReturnValue %99 +%87 = OpFunction %10 None %88 +%86 = OpFunctionParameter %10 +%85 = OpLabel +OpBranch %89 +%89 = OpLabel +%92 = OpFUnordNotEqual %90 %86 %91 +%94 = OpSelect %10 %92 %93 %91 +OpReturnValue %94 OpFunctionEnd -%101 = OpFunction %2 None %102 -%100 = OpLabel -OpBranch %108 -%108 = OpLabel -%109 = OpLogicalOr %8 %31 %33 -%110 = OpLogicalOr %95 %104 %105 -%111 = OpLogicalAnd %8 %31 %33 -%112 = OpLogicalAnd %7 %106 %107 +%96 = OpFunction %2 None %97 +%95 = OpLabel +OpBranch %104 +%104 = OpLabel +%105 = OpLogicalNot %8 %26 +%106 = OpLogicalNot %98 %99 +%107 = OpLogicalOr %8 %26 %28 +%108 = OpLogicalAnd %8 %26 %28 +%109 = OpLogicalOr %8 %26 %28 +%110 = OpLogicalOr %90 %100 %101 +%111 = OpLogicalAnd %8 %26 %28 +%112 = OpLogicalAnd %7 %102 %103 OpReturn OpFunctionEnd -%114 = OpFunction %2 None %102 +%114 = OpFunction %2 None %97 %113 = OpLabel -OpBranch %141 -%141 = OpLabel -%142 = OpIAdd %12 %121 %122 -%143 = OpIAdd %13 %124 %126 -%144 = OpFAdd %3 %127 %128 -%145 = OpISub %12 %121 %122 -%146 = OpISub %13 %124 %126 -%147 = OpFSub %3 %127 %128 -%148 = OpIMul %12 %121 %122 -%149 = OpIMul %13 %124 %126 -%150 = OpFMul %3 %127 %128 -%151 = OpSDiv %12 %121 %122 -%152 = OpUDiv %13 %124 %126 -%153 = OpFDiv %3 %127 %128 -%154 = OpSRem %12 %121 %122 -%155 = OpUMod %13 %124 %126 -%156 = OpFRem %3 %127 %128 -OpBranch %157 -%157 = OpLabel -%159 = OpIAdd %12 %121 %122 -%160 = OpIAdd %12 %121 %122 -%161 = OpIAdd %15 %130 %131 -%162 = OpIAdd %15 %130 %131 -%163 = OpFAdd %9 %59 %60 -%164 = OpFAdd %9 %59 %60 -%165 = OpISub %12 %121 %122 -%166 = OpISub %12 %121 %122 -%167 = OpISub %15 %130 %131 -%168 = OpISub %15 %130 %131 -%169 = OpFSub %9 %59 %60 -%170 = OpFSub %9 %59 %60 -%171 = OpSDiv %12 %121 %122 -%172 = OpSDiv %12 %121 %122 -%173 = OpUDiv %15 %130 %131 -%174 = OpUDiv %15 %130 %131 -%175 = OpFDiv %9 %59 %60 -%176 = OpFDiv %9 %59 %60 -%177 = OpSRem %12 %121 %122 -%178 = OpSRem %12 %121 %122 -%179 = OpUMod %15 %130 %131 -%180 = OpUMod %15 %130 %131 -%181 = OpFRem %9 %59 %60 -%182 = OpFRem %9 %59 %60 -OpBranch %158 -%158 = OpLabel -%184 = OpCompositeExtract %10 %135 0 -%185 = OpCompositeExtract %10 %135 0 -%186 = OpFAdd %10 %184 %185 -%187 = OpCompositeExtract %10 %135 1 -%188 = OpCompositeExtract %10 %135 1 -%189 = OpFAdd %10 %187 %188 -%190 = OpCompositeExtract %10 %135 2 -%191 = OpCompositeExtract %10 %135 2 -%192 = OpFAdd %10 %190 %191 -%183 = OpCompositeConstruct %16 %186 %189 %192 -%194 = OpCompositeExtract %10 %135 0 -%195 = OpCompositeExtract %10 %135 0 -%196 = OpFSub %10 %194 %195 -%197 = OpCompositeExtract %10 %135 1 -%198 = OpCompositeExtract %10 %135 1 -%199 = OpFSub %10 %197 %198 -%200 = OpCompositeExtract %10 %135 2 -%201 = OpCompositeExtract %10 %135 2 -%202 = OpFSub %10 %200 %201 -%193 = OpCompositeConstruct %16 %196 %199 %202 -%203 = OpMatrixTimesVector %10 %138 %128 -%204 = OpVectorTimesMatrix %3 %139 %138 -%205 = OpMatrixTimesMatrix %16 %138 %140 +OpBranch %133 +%133 = OpLabel +%134 = OpFNegate %4 %15 +%135 = OpSNegate %118 %119 +%136 = OpFNegate %9 %55 +%137 = OpIAdd %6 %62 %21 +%138 = OpIAdd %115 %117 %116 +%139 = OpFAdd %4 %53 %15 +%140 = OpIAdd %118 %120 %119 +%141 = OpIAdd %121 %122 %123 +%142 = OpFAdd %3 %124 %125 +%143 = OpISub %6 %62 %21 +%144 = OpISub %115 %117 %116 +%145 = OpFSub %4 %53 %15 +%146 = OpISub %118 %120 %119 +%147 = OpISub %121 %122 %123 +%148 = OpFSub %3 %124 %125 +%149 = OpIMul %6 %62 %21 +%150 = OpIMul %115 %117 %116 +%151 = OpFMul %4 %53 %15 +%152 = OpIMul %118 %120 %119 +%153 = OpIMul %121 %122 %123 +%154 = OpFMul %3 %124 %125 +%155 = OpSDiv %6 %62 %21 +%156 = OpUDiv %115 %117 %116 +%157 = OpFDiv %4 %53 %15 +%158 = OpSDiv %118 %120 %119 +%159 = OpUDiv %121 %122 %123 +%160 = OpFDiv %3 %124 %125 +%161 = OpSRem %6 %62 %21 +%162 = OpUMod %115 %117 %116 +%163 = OpFRem %4 %53 %15 +%164 = OpSRem %118 %120 %119 +%165 = OpUMod %121 %122 %123 +%166 = OpFRem %3 %124 %125 +OpBranch %167 +%167 = OpLabel +%169 = OpIAdd %118 %120 %119 +%170 = OpIAdd %118 %120 %119 +%171 = OpIAdd %126 %127 %128 +%172 = OpIAdd %126 %127 %128 +%173 = OpFAdd %9 %54 %55 +%174 = OpFAdd %9 %54 %55 +%175 = OpISub %118 %120 %119 +%176 = OpISub %118 %120 %119 +%177 = OpISub %126 %127 %128 +%178 = OpISub %126 %127 %128 +%179 = OpFSub %9 %54 %55 +%180 = OpFSub %9 %54 %55 +%182 = OpCompositeConstruct %118 %21 %21 +%181 = OpIMul %118 %120 %182 +%184 = OpCompositeConstruct %118 %62 %62 +%183 = OpIMul %118 %119 %184 +%186 = OpCompositeConstruct %126 %116 %116 +%185 = OpIMul %126 %127 %186 +%188 = OpCompositeConstruct %126 %117 %117 +%187 = OpIMul %126 %128 %188 +%189 = OpVectorTimesScalar %9 %54 %15 +%190 = OpVectorTimesScalar %9 %55 %53 +%191 = OpSDiv %118 %120 %119 +%192 = OpSDiv %118 %120 %119 +%193 = OpUDiv %126 %127 %128 +%194 = OpUDiv %126 %127 %128 +%195 = OpFDiv %9 %54 %55 +%196 = OpFDiv %9 %54 %55 +%197 = OpSRem %118 %120 %119 +%198 = OpSRem %118 %120 %119 +%199 = OpUMod %126 %127 %128 +%200 = OpUMod %126 %127 %128 +%201 = OpFRem %9 %54 %55 +%202 = OpFRem %9 %54 %55 +OpBranch %168 +%168 = OpLabel +%204 = OpCompositeExtract %10 %129 0 +%205 = OpCompositeExtract %10 %129 0 +%206 = OpFAdd %10 %204 %205 +%207 = OpCompositeExtract %10 %129 1 +%208 = OpCompositeExtract %10 %129 1 +%209 = OpFAdd %10 %207 %208 +%210 = OpCompositeExtract %10 %129 2 +%211 = OpCompositeExtract %10 %129 2 +%212 = OpFAdd %10 %210 %211 +%203 = OpCompositeConstruct %11 %206 %209 %212 +%214 = OpCompositeExtract %10 %129 0 +%215 = OpCompositeExtract %10 %129 0 +%216 = OpFSub %10 %214 %215 +%217 = OpCompositeExtract %10 %129 1 +%218 = OpCompositeExtract %10 %129 1 +%219 = OpFSub %10 %217 %218 +%220 = OpCompositeExtract %10 %129 2 +%221 = OpCompositeExtract %10 %129 2 +%222 = OpFSub %10 %220 %221 +%213 = OpCompositeConstruct %11 %216 %219 %222 +%223 = OpMatrixTimesScalar %11 %129 %15 +%224 = OpMatrixTimesScalar %11 %129 %53 +%225 = OpMatrixTimesVector %10 %130 %125 +%226 = OpVectorTimesMatrix %3 %131 %130 +%227 = OpMatrixTimesMatrix %11 %130 %132 OpReturn OpFunctionEnd -%207 = OpFunction %2 None %102 -%206 = OpLabel -OpBranch %214 -%214 = OpLabel -%215 = OpBitwiseOr %12 %121 %122 -%216 = OpBitwiseOr %13 %124 %126 -%217 = OpBitwiseAnd %12 %121 %122 -%218 = OpBitwiseAnd %13 %124 %126 -%219 = OpBitwiseXor %12 %121 %122 -%220 = OpBitwiseXor %13 %124 %126 -%221 = OpShiftLeftLogical %12 %121 %131 -%222 = OpShiftLeftLogical %13 %124 %126 -%223 = OpShiftRightArithmetic %12 %121 %131 -%224 = OpShiftRightLogical %13 %124 %126 +%229 = OpFunction %2 None %97 +%228 = OpLabel +OpBranch %230 +%230 = OpLabel +%231 = OpNot %6 %21 +%232 = OpNot %115 %116 +%233 = OpNot %118 %119 +%234 = OpNot %121 %123 +%235 = OpBitwiseOr %6 %62 %21 +%236 = OpBitwiseOr %115 %117 %116 +%237 = OpBitwiseOr %118 %120 %119 +%238 = OpBitwiseOr %121 %122 %123 +%239 = OpBitwiseAnd %6 %62 %21 +%240 = OpBitwiseAnd %115 %117 %116 +%241 = OpBitwiseAnd %118 %120 %119 +%242 = OpBitwiseAnd %121 %122 %123 +%243 = OpBitwiseXor %6 %62 %21 +%244 = OpBitwiseXor %115 %117 %116 +%245 = OpBitwiseXor %118 %120 %119 +%246 = OpBitwiseXor %121 %122 %123 +%247 = OpShiftLeftLogical %6 %62 %116 +%248 = OpShiftLeftLogical %115 %117 %116 +%249 = OpShiftLeftLogical %118 %120 %128 +%250 = OpShiftLeftLogical %121 %122 %123 +%251 = OpShiftRightArithmetic %6 %62 %116 +%252 = OpShiftRightLogical %115 %117 %116 +%253 = OpShiftRightArithmetic %118 %120 %128 +%254 = OpShiftRightLogical %121 %122 %123 OpReturn OpFunctionEnd -%226 = OpFunction %2 None %102 -%225 = OpLabel -OpBranch %227 -%227 = OpLabel -%228 = OpIEqual %11 %121 %122 -%229 = OpIEqual %95 %124 %126 -%230 = OpFOrdEqual %7 %127 %128 -%231 = OpINotEqual %11 %121 %122 -%232 = OpINotEqual %95 %124 %126 -%233 = OpFOrdNotEqual %7 %127 %128 -%234 = OpSLessThan %11 %121 %122 -%235 = OpULessThan %95 %124 %126 -%236 = OpFOrdLessThan %7 %127 %128 -%237 = OpSLessThanEqual %11 %121 %122 -%238 = OpULessThanEqual %95 %124 %126 -%239 = OpFOrdLessThanEqual %7 %127 %128 -%240 = OpSGreaterThan %11 %121 %122 -%241 = OpUGreaterThan %95 %124 %126 -%242 = OpFOrdGreaterThan %7 %127 %128 -%243 = OpSGreaterThanEqual %11 %121 %122 -%244 = OpUGreaterThanEqual %95 %124 %126 -%245 = OpFOrdGreaterThanEqual %7 %127 %128 +%256 = OpFunction %2 None %97 +%255 = OpLabel +OpBranch %257 +%257 = OpLabel +%258 = OpIEqual %8 %62 %21 +%259 = OpIEqual %8 %117 %116 +%260 = OpFOrdEqual %8 %53 %15 +%261 = OpIEqual %98 %120 %119 +%262 = OpIEqual %90 %122 %123 +%263 = OpFOrdEqual %7 %124 %125 +%264 = OpINotEqual %8 %62 %21 +%265 = OpINotEqual %8 %117 %116 +%266 = OpFOrdNotEqual %8 %53 %15 +%267 = OpINotEqual %98 %120 %119 +%268 = OpINotEqual %90 %122 %123 +%269 = OpFOrdNotEqual %7 %124 %125 +%270 = OpSLessThan %8 %62 %21 +%271 = OpULessThan %8 %117 %116 +%272 = OpFOrdLessThan %8 %53 %15 +%273 = OpSLessThan %98 %120 %119 +%274 = OpULessThan %90 %122 %123 +%275 = OpFOrdLessThan %7 %124 %125 +%276 = OpSLessThanEqual %8 %62 %21 +%277 = OpULessThanEqual %8 %117 %116 +%278 = OpFOrdLessThanEqual %8 %53 %15 +%279 = OpSLessThanEqual %98 %120 %119 +%280 = OpULessThanEqual %90 %122 %123 +%281 = OpFOrdLessThanEqual %7 %124 %125 +%282 = OpSGreaterThan %8 %62 %21 +%283 = OpUGreaterThan %8 %117 %116 +%284 = OpFOrdGreaterThan %8 %53 %15 +%285 = OpSGreaterThan %98 %120 %119 +%286 = OpUGreaterThan %90 %122 %123 +%287 = OpFOrdGreaterThan %7 %124 %125 +%288 = OpSGreaterThanEqual %8 %62 %21 +%289 = OpUGreaterThanEqual %8 %117 %116 +%290 = OpFOrdGreaterThanEqual %8 %53 %15 +%291 = OpSGreaterThanEqual %98 %120 %119 +%292 = OpUGreaterThanEqual %90 %122 %123 +%293 = OpFOrdGreaterThanEqual %7 %124 %125 OpReturn OpFunctionEnd -%247 = OpFunction %2 None %102 -%246 = OpLabel -%249 = OpVariable %250 Function %26 -%251 = OpVariable %252 Function %248 -OpBranch %253 -%253 = OpLabel -%254 = OpLoad %6 %249 -%255 = OpIAdd %6 %254 %26 -OpStore %249 %255 -%256 = OpLoad %6 %249 -%257 = OpISub %6 %256 %26 -OpStore %249 %257 -%258 = OpLoad %6 %249 -%259 = OpLoad %6 %249 -%260 = OpIMul %6 %259 %258 -OpStore %249 %260 -%261 = OpLoad %6 %249 -%262 = OpLoad %6 %249 -%263 = OpSDiv %6 %262 %261 -OpStore %249 %263 -%264 = OpLoad %6 %249 -%265 = OpSRem %6 %264 %26 -OpStore %249 %265 -%266 = OpLoad %6 %249 -%267 = OpBitwiseAnd %6 %266 %32 -OpStore %249 %267 -%268 = OpLoad %6 %249 -%269 = OpBitwiseOr %6 %268 %32 -OpStore %249 %269 -%270 = OpLoad %6 %249 -%271 = OpBitwiseXor %6 %270 %32 -OpStore %249 %271 -%272 = OpLoad %6 %249 -%273 = OpShiftLeftLogical %6 %272 %123 -OpStore %249 %273 -%274 = OpLoad %6 %249 -%275 = OpShiftRightArithmetic %6 %274 %125 -OpStore %249 %275 -%276 = OpLoad %6 %249 -%277 = OpIAdd %6 %276 %26 -OpStore %249 %277 -%278 = OpLoad %6 %249 -%279 = OpISub %6 %278 %26 -OpStore %249 %279 -%281 = OpAccessChain %280 %251 %125 -%282 = OpLoad %6 %281 -%283 = OpIAdd %6 %282 %26 -%284 = OpAccessChain %280 %251 %125 -OpStore %284 %283 -%285 = OpAccessChain %280 %251 %125 -%286 = OpLoad %6 %285 -%287 = OpISub %6 %286 %26 -%288 = OpAccessChain %280 %251 %125 -OpStore %288 %287 +%295 = OpFunction %2 None %97 +%294 = OpLabel +%297 = OpVariable %298 Function %299 +%300 = OpVariable %301 Function %296 +OpBranch %302 +%302 = OpLabel +OpStore %297 %21 +%303 = OpLoad %6 %297 +%304 = OpIAdd %6 %303 %21 +OpStore %297 %304 +%305 = OpLoad %6 %297 +%306 = OpISub %6 %305 %21 +OpStore %297 %306 +%307 = OpLoad %6 %297 +%308 = OpLoad %6 %297 +%309 = OpIMul %6 %308 %307 +OpStore %297 %309 +%310 = OpLoad %6 %297 +%311 = OpLoad %6 %297 +%312 = OpSDiv %6 %311 %310 +OpStore %297 %312 +%313 = OpLoad %6 %297 +%314 = OpSRem %6 %313 %21 +OpStore %297 %314 +%315 = OpLoad %6 %297 +%316 = OpBitwiseAnd %6 %315 %27 +OpStore %297 %316 +%317 = OpLoad %6 %297 +%318 = OpBitwiseOr %6 %317 %27 +OpStore %297 %318 +%319 = OpLoad %6 %297 +%320 = OpBitwiseXor %6 %319 %27 +OpStore %297 %320 +%321 = OpLoad %6 %297 +%322 = OpShiftLeftLogical %6 %321 %117 +OpStore %297 %322 +%323 = OpLoad %6 %297 +%324 = OpShiftRightArithmetic %6 %323 %116 +OpStore %297 %324 +%325 = OpLoad %6 %297 +%326 = OpIAdd %6 %325 %21 +OpStore %297 %326 +%327 = OpLoad %6 %297 +%328 = OpISub %6 %327 %21 +OpStore %297 %328 +%330 = OpAccessChain %329 %300 %21 +%331 = OpLoad %6 %330 +%332 = OpIAdd %6 %331 %21 +%333 = OpAccessChain %329 %300 %21 +OpStore %333 %332 +%334 = OpAccessChain %329 %300 %21 +%335 = OpLoad %6 %334 +%336 = OpISub %6 %335 %21 +%337 = OpAccessChain %329 %300 %21 +OpStore %337 %336 OpReturn OpFunctionEnd -%290 = OpFunction %2 None %102 -%289 = OpLabel -OpBranch %295 -%295 = OpLabel +%339 = OpFunction %2 None %97 +%338 = OpLabel +OpBranch %340 +%340 = OpLabel +%341 = OpSNegate %6 %21 +%342 = OpSNegate %6 %21 +%343 = OpSNegate %6 %342 +%344 = OpSNegate %6 %21 +%345 = OpSNegate %6 %344 +%346 = OpSNegate %6 %21 +%347 = OpSNegate %6 %346 +%348 = OpSNegate %6 %21 +%349 = OpSNegate %6 %348 +%350 = OpSNegate %6 %349 +%351 = OpSNegate %6 %21 +%352 = OpSNegate %6 %351 +%353 = OpSNegate %6 %352 +%354 = OpSNegate %6 %353 +%355 = OpSNegate %6 %21 +%356 = OpSNegate %6 %355 +%357 = OpSNegate %6 %356 +%358 = OpSNegate %6 %357 +%359 = OpSNegate %6 %358 +%360 = OpSNegate %6 %21 +%361 = OpSNegate %6 %360 +%362 = OpSNegate %6 %361 +%363 = OpSNegate %6 %362 +%364 = OpSNegate %6 %363 OpReturn OpFunctionEnd -%297 = OpFunction %2 None %102 -%296 = OpLabel -OpBranch %299 -%299 = OpLabel -%300 = OpFunctionCall %3 %29 -%301 = OpFunctionCall %3 %57 -%302 = OpFunctionCall %10 %92 %298 -%303 = OpFunctionCall %2 %101 -%304 = OpFunctionCall %2 %114 -%305 = OpFunctionCall %2 %207 -%306 = OpFunctionCall %2 %226 -%307 = OpFunctionCall %2 %247 +%366 = OpFunction %2 None %97 +%365 = OpLabel +OpBranch %368 +%368 = OpLabel +%369 = OpFunctionCall %3 %24 +%370 = OpFunctionCall %3 %52 +%371 = OpFunctionCall %10 %87 %367 +%372 = OpFunctionCall %2 %96 +%373 = OpFunctionCall %2 %114 +%374 = OpFunctionCall %2 %229 +%375 = OpFunctionCall %2 %256 +%376 = OpFunctionCall %2 %295 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index 9c07526d39..5038bdc853 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -40,7 +40,10 @@ fn bool_cast(x: vec3) -> vec3 { } fn logical() { - let neg1_ = vec2(false, false); + let neg0_ = !(true); + let neg1_ = !(vec2(true)); + let or = (true || false); + let and = (true && false); let bitwise_or0_ = (true | false); let bitwise_or1_ = (vec3(true) | vec3(false)); let bitwise_and0_ = (true & false); @@ -48,139 +51,193 @@ fn logical() { } fn arithmetic() { - let neg1_1 = vec2(-1, -1); - let neg2_ = vec2(-1.0, -1.0); + let neg0_1 = -(1.0); + let neg1_1 = -(vec2(1)); + let neg2_ = -(vec2(1.0)); + let add0_ = (2 + 1); + let add1_ = (2u + 1u); + let add2_ = (2.0 + 1.0); let add3_ = (vec2(2) + vec2(1)); let add4_ = (vec3(2u) + vec3(1u)); let add5_ = (vec4(2.0) + vec4(1.0)); + let sub0_ = (2 - 1); + let sub1_ = (2u - 1u); + let sub2_ = (2.0 - 1.0); let sub3_ = (vec2(2) - vec2(1)); let sub4_ = (vec3(2u) - vec3(1u)); let sub5_ = (vec4(2.0) - vec4(1.0)); + let mul0_ = (2 * 1); + let mul1_ = (2u * 1u); + let mul2_ = (2.0 * 1.0); let mul3_ = (vec2(2) * vec2(1)); let mul4_ = (vec3(2u) * vec3(1u)); let mul5_ = (vec4(2.0) * vec4(1.0)); + let div0_ = (2 / 1); + let div1_ = (2u / 1u); + let div2_ = (2.0 / 1.0); let div3_ = (vec2(2) / vec2(1)); let div4_ = (vec3(2u) / vec3(1u)); let div5_ = (vec4(2.0) / vec4(1.0)); + let rem0_ = (2 % 1); + let rem1_ = (2u % 1u); + let rem2_ = (2.0 % 1.0); let rem3_ = (vec2(2) % vec2(1)); let rem4_ = (vec3(2u) % vec3(1u)); let rem5_ = (vec4(2.0) % vec4(1.0)); { - let add0_ = (vec2(2) + vec2(1)); - let add1_ = (vec2(2) + vec2(1)); - let add2_ = (vec2(2u) + vec2(1u)); + let add0_1 = (vec2(2) + vec2(1)); + let add1_1 = (vec2(2) + vec2(1)); + let add2_1 = (vec2(2u) + vec2(1u)); let add3_1 = (vec2(2u) + vec2(1u)); let add4_1 = (vec2(2.0) + vec2(1.0)); let add5_1 = (vec2(2.0) + vec2(1.0)); - let sub0_ = (vec2(2) - vec2(1)); - let sub1_ = (vec2(2) - vec2(1)); - let sub2_ = (vec2(2u) - vec2(1u)); + let sub0_1 = (vec2(2) - vec2(1)); + let sub1_1 = (vec2(2) - vec2(1)); + let sub2_1 = (vec2(2u) - vec2(1u)); let sub3_1 = (vec2(2u) - vec2(1u)); let sub4_1 = (vec2(2.0) - vec2(1.0)); let sub5_1 = (vec2(2.0) - vec2(1.0)); - let mul0_ = vec2(2, 2); - let mul1_ = vec2(2, 2); - let mul2_ = vec2(2u, 2u); - let mul3_1 = vec2(2u, 2u); - let mul4_1 = vec2(2.0, 2.0); - let mul5_1 = vec2(2.0, 2.0); - let div0_ = (vec2(2) / vec2(1)); - let div1_ = (vec2(2) / vec2(1)); - let div2_ = (vec2(2u) / vec2(1u)); + let mul0_1 = (vec2(2) * 1); + let mul1_1 = (2 * vec2(1)); + let mul2_1 = (vec2(2u) * 1u); + let mul3_1 = (2u * vec2(1u)); + let mul4_1 = (vec2(2.0) * 1.0); + let mul5_1 = (2.0 * vec2(1.0)); + let div0_1 = (vec2(2) / vec2(1)); + let div1_1 = (vec2(2) / vec2(1)); + let div2_1 = (vec2(2u) / vec2(1u)); let div3_1 = (vec2(2u) / vec2(1u)); let div4_1 = (vec2(2.0) / vec2(1.0)); let div5_1 = (vec2(2.0) / vec2(1.0)); - let rem0_ = (vec2(2) % vec2(1)); - let rem1_ = (vec2(2) % vec2(1)); - let rem2_ = (vec2(2u) % vec2(1u)); + let rem0_1 = (vec2(2) % vec2(1)); + let rem1_1 = (vec2(2) % vec2(1)); + let rem2_1 = (vec2(2u) % vec2(1u)); let rem3_1 = (vec2(2u) % vec2(1u)); let rem4_1 = (vec2(2.0) % vec2(1.0)); let rem5_1 = (vec2(2.0) % vec2(1.0)); } let add = (mat3x3() + mat3x3()); let sub = (mat3x3() - mat3x3()); - let mul_scalar0_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); - let mul_scalar1_ = mat3x3(vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0), vec3(0.0, 0.0, 0.0)); + let mul_scalar0_ = (mat3x3() * 1.0); + let mul_scalar1_ = (2.0 * mat3x3()); let mul_vector0_ = (mat4x3() * vec4(1.0)); let mul_vector1_ = (vec3(2.0) * mat4x3()); let mul = (mat4x3() * mat3x4()); } fn bit() { - let flip2_ = vec2(-2, -2); - let flip3_ = vec3(4294967294u, 4294967294u, 4294967294u); + let flip0_ = ~(1); + let flip1_ = ~(1u); + let flip2_ = !(vec2(1)); + let flip3_ = !(vec3(1u)); + let or0_ = (2 | 1); + let or1_ = (2u | 1u); let or2_ = (vec2(2) | vec2(1)); let or3_ = (vec3(2u) | vec3(1u)); + let and0_ = (2 & 1); + let and1_ = (2u & 1u); let and2_ = (vec2(2) & vec2(1)); let and3_ = (vec3(2u) & vec3(1u)); + let xor0_ = (2 ^ 1); + let xor1_ = (2u ^ 1u); let xor2_ = (vec2(2) ^ vec2(1)); let xor3_ = (vec3(2u) ^ vec3(1u)); + let shl0_ = (2 << 1u); + let shl1_ = (2u << 1u); let shl2_ = (vec2(2) << vec2(1u)); let shl3_ = (vec3(2u) << vec3(1u)); + let shr0_ = (2 >> 1u); + let shr1_ = (2u >> 1u); let shr2_ = (vec2(2) >> vec2(1u)); let shr3_ = (vec3(2u) >> vec3(1u)); } fn comparison() { + let eq0_ = (2 == 1); + let eq1_ = (2u == 1u); + let eq2_ = (2.0 == 1.0); let eq3_ = (vec2(2) == vec2(1)); let eq4_ = (vec3(2u) == vec3(1u)); let eq5_ = (vec4(2.0) == vec4(1.0)); + let neq0_ = (2 != 1); + let neq1_ = (2u != 1u); + let neq2_ = (2.0 != 1.0); let neq3_ = (vec2(2) != vec2(1)); let neq4_ = (vec3(2u) != vec3(1u)); let neq5_ = (vec4(2.0) != vec4(1.0)); + let lt0_ = (2 < 1); + let lt1_ = (2u < 1u); + let lt2_ = (2.0 < 1.0); let lt3_ = (vec2(2) < vec2(1)); let lt4_ = (vec3(2u) < vec3(1u)); let lt5_ = (vec4(2.0) < vec4(1.0)); + let lte0_ = (2 <= 1); + let lte1_ = (2u <= 1u); + let lte2_ = (2.0 <= 1.0); let lte3_ = (vec2(2) <= vec2(1)); let lte4_ = (vec3(2u) <= vec3(1u)); let lte5_ = (vec4(2.0) <= vec4(1.0)); + let gt0_ = (2 > 1); + let gt1_ = (2u > 1u); + let gt2_ = (2.0 > 1.0); let gt3_ = (vec2(2) > vec2(1)); let gt4_ = (vec3(2u) > vec3(1u)); let gt5_ = (vec4(2.0) > vec4(1.0)); + let gte0_ = (2 >= 1); + let gte1_ = (2u >= 1u); + let gte2_ = (2.0 >= 1.0); let gte3_ = (vec2(2) >= vec2(1)); let gte4_ = (vec3(2u) >= vec3(1u)); let gte5_ = (vec4(2.0) >= vec4(1.0)); } fn assignment() { - var a_1: i32 = 1; + var a_1: i32; var vec0_: vec3 = vec3(); - let _e3 = a_1; - a_1 = (_e3 + 1); - let _e6 = a_1; - a_1 = (_e6 - 1); - let _e8 = a_1; + a_1 = 1; + let _e5 = a_1; + a_1 = (_e5 + 1); + let _e7 = a_1; + a_1 = (_e7 - 1); let _e9 = a_1; - a_1 = (_e9 * _e8); - let _e11 = a_1; + let _e10 = a_1; + a_1 = (_e10 * _e9); let _e12 = a_1; - a_1 = (_e12 / _e11); + let _e13 = a_1; + a_1 = (_e13 / _e12); let _e15 = a_1; a_1 = (_e15 % 1); - let _e18 = a_1; - a_1 = (_e18 & 0); + let _e17 = a_1; + a_1 = (_e17 & 0); + let _e19 = a_1; + a_1 = (_e19 | 0); let _e21 = a_1; - a_1 = (_e21 | 0); - let _e24 = a_1; - a_1 = (_e24 ^ 0); - let _e27 = a_1; - a_1 = (_e27 << 2u); - let _e30 = a_1; - a_1 = (_e30 >> 1u); - let _e33 = a_1; - a_1 = (_e33 + 1); - let _e36 = a_1; - a_1 = (_e36 - 1); - let _e42 = vec0_.y; - vec0_.y = (_e42 + 1); - let _e46 = vec0_.y; - vec0_.y = (_e46 - 1); + a_1 = (_e21 ^ 0); + let _e23 = a_1; + a_1 = (_e23 << 2u); + let _e25 = a_1; + a_1 = (_e25 >> 1u); + let _e28 = a_1; + a_1 = (_e28 + 1); + let _e31 = a_1; + a_1 = (_e31 - 1); + let _e37 = vec0_[1]; + vec0_[1] = (_e37 + 1); + let _e41 = vec0_[1]; + vec0_[1] = (_e41 - 1); return; } fn negation_avoids_prefix_decrement() { - return; + let p0_ = -(1); + let p1_ = -(-(1)); + let p2_ = -(-(1)); + let p3_ = -(-(1)); + let p4_ = -(-(-(1))); + let p5_ = -(-(-(-(1)))); + let p6_ = -(-(-(-(-(1))))); + let p7_ = -(-(-(-(-(1))))); } @compute @workgroup_size(1, 1, 1) From ca46c6d5dc298fa3aebfefc3c2e6d66200ae973f Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 9 Oct 2023 10:35:46 -0700 Subject: [PATCH 34/37] [wgsl-in] Document necessity of `force_non_const`. --- src/front/wgsl/lower/mod.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 94118e65ef..6bbd8d919e 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -106,7 +106,16 @@ pub struct StatementContext<'source, 'temp, 'out> { named_expressions: &'out mut FastIndexMap, (String, Span)>, arguments: &'out [crate::FunctionArgument], module: &'out mut crate::Module, - /// Tracks the constness of `Expression`s residing in `self.naga_expressions` + + /// Which `Expression`s in `self.naga_expressions` are const expressions, in + /// the WGSL sense. + /// + /// According to the WGSL spec, a const expression must not refer to any + /// `let` declarations, even if those declarations' initializers are + /// themselves const expressions. So this tracker is not simply concerned + /// with the form of the expressions; it is also tracking whether WGSL says + /// we should consider them to be const. See the use of `force_non_const` in + /// the code for lowering `let` bindings. expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker, } @@ -192,7 +201,11 @@ pub struct RuntimeExpressionContext<'temp, 'out> { block: &'temp mut crate::Block, emitter: &'temp mut Emitter, typifier: &'temp mut Typifier, - /// Tracks the constness of `Expression`s residing in `self.naga_expressions` + + /// Which `Expression`s in `self.naga_expressions` are const expressions, in + /// the WGSL sense. + /// + /// See [`StatementContext::expression_constness`] for details. expression_constness: &'temp mut crate::proc::ExpressionConstnessTracker, } @@ -1087,6 +1100,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { emitter.start(ctx.naga_expressions); let value = self.expression(l.init, ctx.as_expression(block, &mut emitter))?; + + // 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.expression_constness.force_non_const(value); let explicit_ty = From a0e02423700796f723e85fe0262ca155a2b0dba4 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 9 Oct 2023 20:03:11 -0700 Subject: [PATCH 35/37] Some documentation for ConstantEvaluator. --- src/proc/constant_evaluator.rs | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/src/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs index 61adf0fdd5..70a46114a9 100644 --- a/src/proc/constant_evaluator.rs +++ b/src/proc/constant_evaluator.rs @@ -10,11 +10,40 @@ enum Behavior { Glsl, } +/// A context for evaluating constant expressions. +/// +/// A `ConstantEvaluator` points at an expression arena to which it can append +/// newly evaluated expressions: you pass [`try_eval_and_append`] whatever kind +/// of Naga [`Expression`] you like, and if its value can be computed at compile +/// time, `try_eval_and_append` appends an expression representing the computed +/// value - a tree of [`Literal`], [`Compose`], [`ZeroValue`], and [`Swizzle`] +/// expressions - to the arena. See the [`try_eval_and_append`] method for details. +/// +/// A `ConstantEvaluator` also holds whatever information we need to carry out +/// that evaluation: types, other constants, and so on. +/// +/// [`try_eval_and_append`]: ConstantEvaluator::try_eval_and_append +/// [`Compose`]: Expression::Compose +/// [`ZeroValue`]: Expression::ZeroValue +/// [`Literal`]: Expression::Literal +/// [`Swizzle`]: Expression::Swizzle #[derive(Debug)] pub struct ConstantEvaluator<'a> { + /// Which language's evaluation rules we should follow. behavior: Behavior, + + /// The module's type arena. + /// + /// Because expressions like [`Splat`] contain type handles, we need to be + /// able to add new types to produce those expressions. + /// + /// [`Splat`]: Expression::Splat types: &'a mut UniqueArena, + + /// The module's constant arena. constants: &'a Arena, + + /// The arena to which we are contributing expressions. expressions: &'a mut Arena, /// When `self.expressions` refers to a function's local expression @@ -149,10 +178,18 @@ pub enum ConstantEvaluatorError { } impl<'a> ConstantEvaluator<'a> { + /// Return a [`ConstantEvaluator`] that will add expressions to `module`'s + /// constant expression arena. + /// + /// Report errors according to WGSL's rules for constant evaluation. pub fn for_wgsl_module(module: &'a mut crate::Module) -> Self { Self::for_module(Behavior::Wgsl, module) } + /// Return a [`ConstantEvaluator`] that will add expressions to `module`'s + /// constant expression arena. + /// + /// Report errors according to GLSL's rules for constant evaluation. pub fn for_glsl_module(module: &'a mut crate::Module) -> Self { Self::for_module(Behavior::Glsl, module) } @@ -167,6 +204,10 @@ impl<'a> ConstantEvaluator<'a> { } } + /// Return a [`ConstantEvaluator`] that will add expressions to `function`'s + /// expression arena. + /// + /// Report errors according to WGSL's rules for constant evaluation. pub fn for_wgsl_function( module: &'a mut crate::Module, expressions: &'a mut Arena, @@ -184,6 +225,10 @@ impl<'a> ConstantEvaluator<'a> { ) } + /// Return a [`ConstantEvaluator`] that will add expressions to `function`'s + /// expression arena. + /// + /// Report errors according to GLSL's rules for constant evaluation. pub fn for_glsl_function( module: &'a mut crate::Module, expressions: &'a mut Arena, @@ -259,6 +304,27 @@ impl<'a> ConstantEvaluator<'a> { } } + /// Try to evaluate `expr` at compile time. + /// + /// The `expr` argument can be any sort of Naga [`Expression`] you like. If + /// we can determine its value at compile time, we append an expression + /// representing its value - a tree of [`Literal`], [`Compose`], + /// [`ZeroValue`], and [`Swizzle`] expressions - to the expression arena + /// `self` contributes to. + /// + /// If `expr`'s value cannot be determined at compile time, return a an + /// error. If it's acceptable to evaluate `expr` at runtime, this error can + /// be ignored, and the caller can append `expr` to the arena itself. + /// + /// We only consider `expr` itself, without recursing into its operands. Its + /// operands must all have been produced by prior calls to + /// `try_eval_and_append`, to ensure that they have already been reduced to + /// an evaluated form if possible. + /// + /// [`Literal`]: Expression::Literal + /// [`Compose`]: Expression::Compose + /// [`ZeroValue`]: Expression::ZeroValue + /// [`Swizzle`]: Expression::Swizzle pub fn try_eval_and_append( &mut self, expr: &Expression, From 61d91ebee1ac3dafa8a25ed7e156197e860e6d70 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Wed, 11 Oct 2023 14:07:20 +0200 Subject: [PATCH 36/37] [valid] check local variable initializer is const --- src/lib.rs | 8 +++++++- src/valid/function.rs | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 80461e16ff..9d70190421 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -978,7 +978,13 @@ pub struct LocalVariable { pub name: Option, /// The type of this variable. pub ty: Handle, - /// Initial value for this variable. Must be a const-expression. + /// Initial value for this variable. + /// + /// This handle refers to this `LocalVariable`'s function's + /// [`expressions`] arena, but it is required to be an evaluated + /// constant expression. + /// + /// [`expressions`]: Function::expressions pub init: Option>, } diff --git a/src/valid/function.rs b/src/valid/function.rs index a056a1d1f6..ca5877ba1e 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -58,6 +58,8 @@ pub enum LocalVariableError { InvalidType(Handle), #[error("Initializer doesn't match the variable type")] InitializerType, + #[error("Initializer is not const")] + NonConstInitializer, } #[derive(Clone, Debug, thiserror::Error)] @@ -942,6 +944,7 @@ impl super::Validator { var: &crate::LocalVariable, gctx: crate::proc::GlobalCtx, fun_info: &FunctionInfo, + expression_constness: &crate::proc::ExpressionConstnessTracker, ) -> Result<(), LocalVariableError> { log::debug!("var {:?}", var); let type_info = self @@ -958,6 +961,10 @@ impl super::Validator { if !decl_ty.equivalent(init_ty, gctx.types) { return Err(LocalVariableError::InitializerType); } + + if !expression_constness.is_const(init) { + return Err(LocalVariableError::NonConstInitializer); + } } Ok(()) @@ -973,9 +980,13 @@ impl super::Validator { #[cfg_attr(not(feature = "validate"), allow(unused_mut))] let mut info = mod_info.process_function(fun, module, self.flags, self.capabilities)?; + #[cfg(feature = "validate")] + let expression_constness = + crate::proc::ExpressionConstnessTracker::from_arena(&fun.expressions); + #[cfg(feature = "validate")] for (var_handle, var) in fun.local_variables.iter() { - self.validate_local_var(var, module.to_ctx(), &info) + self.validate_local_var(var, module.to_ctx(), &info, &expression_constness) .map_err(|source| { FunctionError::LocalVariable { handle: var_handle, From f53151d92cc3db6a878a25c98d724b871d0970a7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Wed, 11 Oct 2023 17:17:01 -0700 Subject: [PATCH 37/37] [wgsl-in] Don't double-initialize variables local to loops. --- src/front/wgsl/lower/mod.rs | 16 +- tests/out/spv/atomicCompareExchange.spvasm | 254 +++++++++++---------- tests/out/wgsl/atomicCompareExchange.wgsl | 4 +- 3 files changed, 143 insertions(+), 131 deletions(-) diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 6bbd8d919e..c883732e8b 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -1181,10 +1181,20 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let (const_initializer, initializer) = { match initializer { - Some(init) if ctx.expression_constness.is_const(init) => { - (Some(init), is_inside_loop.then_some(init)) + Some(init) => { + // It's not correct to hoist the initializer up + // to the top of the function if: + // - the initialization is inside a loop, and should + // take place on every iteration, or + // - the initialization is not a constant + // expression, so its value depends on the + // state at the point of initialization. + if is_inside_loop || !ctx.expression_constness.is_const(init) { + (None, Some(init)) + } else { + (Some(init), None) + } } - Some(init) => (None, Some(init)), None => (None, None), } }; diff --git a/tests/out/spv/atomicCompareExchange.spvasm b/tests/out/spv/atomicCompareExchange.spvasm index d08e3656fd..bfd4591d49 100644 --- a/tests/out/spv/atomicCompareExchange.spvasm +++ b/tests/out/spv/atomicCompareExchange.spvasm @@ -1,15 +1,15 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 122 +; Bound: 124 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %18 "test_atomic_compare_exchange_i32" -OpEntryPoint GLCompute %76 "test_atomic_compare_exchange_u32" +OpEntryPoint GLCompute %77 "test_atomic_compare_exchange_u32" OpExecutionMode %18 LocalSize 1 1 1 -OpExecutionMode %76 LocalSize 1 1 1 +OpExecutionMode %77 LocalSize 1 1 1 OpDecorate %5 ArrayStride 4 OpDecorate %7 ArrayStride 4 OpMemberDecorate %9 0 Offset 0 @@ -50,153 +50,155 @@ OpMemberDecorate %15 0 Offset 0 %30 = OpTypePointer Function %4 %31 = OpConstantNull %4 %33 = OpTypePointer Function %8 -%46 = OpTypePointer StorageBuffer %4 -%49 = OpConstant %4 1 -%50 = OpConstant %3 64 -%77 = OpTypePointer StorageBuffer %7 -%81 = OpConstantNull %3 -%95 = OpTypePointer StorageBuffer %3 +%34 = OpConstantNull %8 +%47 = OpTypePointer StorageBuffer %4 +%50 = OpConstant %4 1 +%51 = OpConstant %3 64 +%78 = OpTypePointer StorageBuffer %7 +%82 = OpConstantNull %3 +%84 = OpConstantNull %8 +%97 = OpTypePointer StorageBuffer %3 %18 = OpFunction %2 None %19 %17 = OpLabel %27 = OpVariable %28 Function %21 %29 = OpVariable %30 Function %31 -%32 = OpVariable %33 Function %23 +%32 = OpVariable %33 Function %34 %22 = OpAccessChain %20 %11 %21 -OpBranch %34 -%34 = OpLabel OpBranch %35 %35 = OpLabel -OpLoopMerge %36 %38 None -OpBranch %37 -%37 = OpLabel -%39 = OpLoad %3 %27 -%40 = OpULessThan %8 %39 %6 -OpSelectionMerge %41 None -OpBranchConditional %40 %41 %42 -%42 = OpLabel OpBranch %36 -%41 = OpLabel -OpBranch %43 +%36 = OpLabel +OpLoopMerge %37 %39 None +OpBranch %38 +%38 = OpLabel +%40 = OpLoad %3 %27 +%41 = OpULessThan %8 %40 %6 +OpSelectionMerge %42 None +OpBranchConditional %41 %42 %43 %43 = OpLabel -%45 = OpLoad %3 %27 -%47 = OpAccessChain %46 %22 %45 -%48 = OpAtomicLoad %4 %47 %49 %50 -OpStore %29 %48 +OpBranch %37 +%42 = OpLabel +OpBranch %44 +%44 = OpLabel +%46 = OpLoad %3 %27 +%48 = OpAccessChain %47 %22 %46 +%49 = OpAtomicLoad %4 %48 %50 %51 +OpStore %29 %49 OpStore %32 %23 -OpBranch %51 -%51 = OpLabel -OpLoopMerge %52 %54 None -OpBranch %53 -%53 = OpLabel -%55 = OpLoad %8 %32 -%56 = OpLogicalNot %8 %55 -OpSelectionMerge %57 None -OpBranchConditional %56 %57 %58 -%58 = OpLabel OpBranch %52 -%57 = OpLabel -OpBranch %59 +%52 = OpLabel +OpLoopMerge %53 %55 None +OpBranch %54 +%54 = OpLabel +%56 = OpLoad %8 %32 +%57 = OpLogicalNot %8 %56 +OpSelectionMerge %58 None +OpBranchConditional %57 %58 %59 %59 = OpLabel -%61 = OpLoad %4 %29 -%62 = OpBitcast %24 %61 -%63 = OpFAdd %24 %62 %25 -%64 = OpBitcast %4 %63 -%65 = OpLoad %3 %27 -%66 = OpLoad %4 %29 -%68 = OpAccessChain %46 %22 %65 -%69 = OpAtomicCompareExchange %4 %68 %49 %50 %50 %64 %66 -%70 = OpIEqual %8 %69 %66 -%67 = OpCompositeConstruct %9 %69 %70 -%71 = OpCompositeExtract %4 %67 0 -OpStore %29 %71 -%72 = OpCompositeExtract %8 %67 1 -OpStore %32 %72 +OpBranch %53 +%58 = OpLabel OpBranch %60 %60 = OpLabel -OpBranch %54 -%54 = OpLabel -OpBranch %51 -%52 = OpLabel -OpBranch %44 -%44 = OpLabel -OpBranch %38 -%38 = OpLabel -%73 = OpLoad %3 %27 -%74 = OpIAdd %3 %73 %26 -OpStore %27 %74 -OpBranch %35 -%36 = OpLabel +%62 = OpLoad %4 %29 +%63 = OpBitcast %24 %62 +%64 = OpFAdd %24 %63 %25 +%65 = OpBitcast %4 %64 +%66 = OpLoad %3 %27 +%67 = OpLoad %4 %29 +%69 = OpAccessChain %47 %22 %66 +%70 = OpAtomicCompareExchange %4 %69 %50 %51 %51 %65 %67 +%71 = OpIEqual %8 %70 %67 +%68 = OpCompositeConstruct %9 %70 %71 +%72 = OpCompositeExtract %4 %68 0 +OpStore %29 %72 +%73 = OpCompositeExtract %8 %68 1 +OpStore %32 %73 +OpBranch %61 +%61 = OpLabel +OpBranch %55 +%55 = OpLabel +OpBranch %52 +%53 = OpLabel +OpBranch %45 +%45 = OpLabel +OpBranch %39 +%39 = OpLabel +%74 = OpLoad %3 %27 +%75 = OpIAdd %3 %74 %26 +OpStore %27 %75 +OpBranch %36 +%37 = OpLabel OpReturn OpFunctionEnd -%76 = OpFunction %2 None %19 -%75 = OpLabel -%79 = OpVariable %28 Function %21 -%80 = OpVariable %28 Function %81 -%82 = OpVariable %33 Function %23 -%78 = OpAccessChain %77 %14 %21 -OpBranch %83 -%83 = OpLabel -OpBranch %84 -%84 = OpLabel -OpLoopMerge %85 %87 None +%77 = OpFunction %2 None %19 +%76 = OpLabel +%80 = OpVariable %28 Function %21 +%81 = OpVariable %28 Function %82 +%83 = OpVariable %33 Function %84 +%79 = OpAccessChain %78 %14 %21 +OpBranch %85 +%85 = OpLabel OpBranch %86 %86 = OpLabel -%88 = OpLoad %3 %79 -%89 = OpULessThan %8 %88 %6 -OpSelectionMerge %90 None -OpBranchConditional %89 %90 %91 -%91 = OpLabel -OpBranch %85 -%90 = OpLabel -OpBranch %92 +OpLoopMerge %87 %89 None +OpBranch %88 +%88 = OpLabel +%90 = OpLoad %3 %80 +%91 = OpULessThan %8 %90 %6 +OpSelectionMerge %92 None +OpBranchConditional %91 %92 %93 +%93 = OpLabel +OpBranch %87 %92 = OpLabel -%94 = OpLoad %3 %79 -%96 = OpAccessChain %95 %78 %94 -%97 = OpAtomicLoad %3 %96 %49 %50 -OpStore %80 %97 -OpStore %82 %23 -OpBranch %98 -%98 = OpLabel -OpLoopMerge %99 %101 None +OpBranch %94 +%94 = OpLabel +%96 = OpLoad %3 %80 +%98 = OpAccessChain %97 %79 %96 +%99 = OpAtomicLoad %3 %98 %50 %51 +OpStore %81 %99 +OpStore %83 %23 OpBranch %100 %100 = OpLabel -%102 = OpLoad %8 %82 -%103 = OpLogicalNot %8 %102 -OpSelectionMerge %104 None -OpBranchConditional %103 %104 %105 -%105 = OpLabel -OpBranch %99 -%104 = OpLabel -OpBranch %106 -%106 = OpLabel -%108 = OpLoad %3 %80 -%109 = OpBitcast %24 %108 -%110 = OpFAdd %24 %109 %25 -%111 = OpBitcast %3 %110 -%112 = OpLoad %3 %79 -%113 = OpLoad %3 %80 -%115 = OpAccessChain %95 %78 %112 -%116 = OpAtomicCompareExchange %3 %115 %49 %50 %50 %111 %113 -%117 = OpIEqual %8 %116 %113 -%114 = OpCompositeConstruct %10 %116 %117 -%118 = OpCompositeExtract %3 %114 0 -OpStore %80 %118 -%119 = OpCompositeExtract %8 %114 1 -OpStore %82 %119 -OpBranch %107 +OpLoopMerge %101 %103 None +OpBranch %102 +%102 = OpLabel +%104 = OpLoad %8 %83 +%105 = OpLogicalNot %8 %104 +OpSelectionMerge %106 None +OpBranchConditional %105 %106 %107 %107 = OpLabel OpBranch %101 +%106 = OpLabel +OpBranch %108 +%108 = OpLabel +%110 = OpLoad %3 %81 +%111 = OpBitcast %24 %110 +%112 = OpFAdd %24 %111 %25 +%113 = OpBitcast %3 %112 +%114 = OpLoad %3 %80 +%115 = OpLoad %3 %81 +%117 = OpAccessChain %97 %79 %114 +%118 = OpAtomicCompareExchange %3 %117 %50 %51 %51 %113 %115 +%119 = OpIEqual %8 %118 %115 +%116 = OpCompositeConstruct %10 %118 %119 +%120 = OpCompositeExtract %3 %116 0 +OpStore %81 %120 +%121 = OpCompositeExtract %8 %116 1 +OpStore %83 %121 +OpBranch %109 +%109 = OpLabel +OpBranch %103 +%103 = OpLabel +OpBranch %100 %101 = OpLabel -OpBranch %98 -%99 = OpLabel -OpBranch %93 -%93 = OpLabel -OpBranch %87 +OpBranch %95 +%95 = OpLabel +OpBranch %89 +%89 = OpLabel +%122 = OpLoad %3 %80 +%123 = OpIAdd %3 %122 %26 +OpStore %80 %123 +OpBranch %86 %87 = OpLabel -%120 = OpLoad %3 %79 -%121 = OpIAdd %3 %120 %26 -OpStore %79 %121 -OpBranch %84 -%85 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/atomicCompareExchange.wgsl b/tests/out/wgsl/atomicCompareExchange.wgsl index f68017028f..5f98c61969 100644 --- a/tests/out/wgsl/atomicCompareExchange.wgsl +++ b/tests/out/wgsl/atomicCompareExchange.wgsl @@ -9,7 +9,7 @@ var arr_u32_: array, 128>; fn test_atomic_compare_exchange_i32_() { var i: u32 = 0u; var old: i32; - var exchanged: bool = false; + var exchanged: bool; loop { let _e2 = i; @@ -51,7 +51,7 @@ fn test_atomic_compare_exchange_i32_() { fn test_atomic_compare_exchange_u32_() { var i_1: u32 = 0u; var old_1: u32; - var exchanged_1: bool = false; + var exchanged_1: bool; loop { let _e2 = i_1;