diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index 86b1aecd06..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)?; @@ -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..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)?; @@ -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..d0f5413136 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, ";")?; } @@ -3535,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, @@ -3549,7 +3588,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_expression(value, &context.expression, true)?; } None => { write!(self.out, " = {{}}")?; @@ -3558,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, - pipeline_options, - }, - mod_info, - 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)?; @@ -3958,7 +3981,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 +4037,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 => { @@ -4090,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() { @@ -4106,7 +4146,7 @@ impl Writer { match local.init { Some(value) => { write!(self.out, " = ")?; - self.put_const_expression(value, module)?; + self.put_expression(value, &context.expression, true)?; } None => { write!(self.out, " = {{}}")?; @@ -4115,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, - pipeline_options, - }, - mod_info, - 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..4dba7ea0ca 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -243,22 +243,51 @@ 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.expression_constness.is_const(expr_handle) { + 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, + id, + &self.temp_list, + )); + id } + } + crate::Expression::Splat { size, value } => { + let value_id = self.cached[value]; + let components = &[value_id; 4][..size as usize]; - let id = self.gen_id(); - block.body.push(Instruction::composite_construct( - result_type_id, - id, - &self.temp_list, - )); - id + if self.expression_constness.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 +434,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 +1776,10 @@ impl<'w> BlockContext<'w> { match *statement { crate::Statement::Emit(ref range) => { for handle in range.clone() { - self.cache_expression_value(handle, &mut block)?; + // omit const expressions as we've already cached those + if !self.expression_constness.is_const(handle) { + self.cache_expression_value(handle, &mut block)?; + } } } crate::Statement::Block(ref block_statements) => { 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 8cad9c4d27..2e133985af 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) } @@ -334,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 { @@ -647,12 +620,57 @@ 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() { + if (expr.needs_pre_emit() && !matches!(*expr, crate::Expression::LocalVariable(_))) + || context.expression_constness.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 }); + } + + // cache local variable expressions + for (handle, expr) in ir_function.expressions.iter() { + if matches!(*expr, crate::Expression::LocalVariable(_)) { context.cache_expression_value(handle, &mut prelude)?; } } @@ -1242,6 +1260,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), @@ -1254,12 +1273,24 @@ 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 } => { + 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 +1909,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/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/builtins.rs b/src/front/glsl/builtins.rs index 811be65cce..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.solve_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/constants.rs b/src/front/glsl/constants.rs deleted file mode 100644 index 81ec6f3a8c..0000000000 --- a/src/front/glsl/constants.rs +++ /dev/null @@ -1,1131 +0,0 @@ -use crate::{ - arena::{Arena, Handle, UniqueArena}, - ArraySize, BinaryOperator, Constant, Expression, Literal, ScalarKind, Type, TypeInner, - UnaryOperator, -}; - -#[derive(Debug)] -pub struct ConstantSolver<'a> { - pub types: &'a mut UniqueArena, - pub expressions: &'a Arena, - pub constants: &'a mut Arena, - pub const_expressions: &'a mut Arena, -} - -#[derive(Clone, Debug, PartialEq, thiserror::Error)] -pub enum ConstantSolvingError { - #[error("Constants cannot access function arguments")] - FunctionArg, - #[error("Constants cannot access global variables")] - GlobalVariable, - #[error("Constants cannot access local variables")] - LocalVariable, - #[error("Cannot get the array length of a non array type")] - InvalidArrayLengthArg, - #[error("Constants cannot get the array length of a dynamically sized array")] - ArrayLengthDynamic, - #[error("Constants cannot call functions")] - Call, - #[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")] - ImageExpression, - #[error("Constants don't support ray query expressions")] - RayQueryExpression, - #[error("Cannot access the type")] - InvalidAccessBase, - #[error("Cannot access at the index")] - InvalidAccessIndex, - #[error("Cannot access with index of type")] - InvalidAccessIndexTy, - #[error("Constants don't support bitcasts")] - Bitcast, - #[error("Cannot cast type")] - InvalidCastArg, - #[error("Cannot apply the unary op to the argument")] - InvalidUnaryOpArg, - #[error("Cannot apply the binary op to the arguments")] - InvalidBinaryOpArgs, - #[error("Cannot apply math function to type")] - InvalidMathArg, - #[error("Splat is defined only on scalar values")] - SplatScalarOnly, - #[error("Can only swizzle vector constants")] - SwizzleVectorOnly, - #[error("Type is not constructible")] - TypeNotConstructible, - #[error("Not implemented as constant expression: {0}")] - NotImplemented(String), -} - -#[derive(Clone, Copy)] -pub enum ExprType { - Regular, - Constant, -} - -impl<'a> ConstantSolver<'a> { - pub fn solve( - &mut self, - expr: Handle, - ) -> Result, ConstantSolvingError> { - self.solve_impl(expr, ExprType::Regular, true) - } - - pub fn solve_impl( - &mut self, - expr: Handle, - expr_type: ExprType, - top_level: bool, - ) -> Result, ConstantSolvingError> { - let expressions = match expr_type { - ExprType::Regular => self.expressions, - ExprType::Constant => self.const_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::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)?; - } - Ok(self.register_constant(Expression::Compose { ty, components }, span)) - } - ExprType::Constant => Ok(expr), - }, - Expression::Constant(constant) => { - if top_level { - match expr_type { - ExprType::Regular => { - Ok(self.register_constant(Expression::Constant(constant), span)) - } - ExprType::Constant => Ok(expr), - } - } else { - self.solve_impl(self.constants[constant].init, ExprType::Constant, false) - } - } - Expression::AccessIndex { base, index } => { - let base = self.solve_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)?; - - 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); - } - }; - - let expr = Expression::Compose { - ty, - components: vec![value_constant; size as usize], - }; - Ok(self.register_constant(expr, 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), - }; - - 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), - } - } - Expression::Unary { expr, op } => { - let expr_constant = self.solve_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)?; - - self.binary_op(op, left_constant, right_constant, span) - } - Expression::Math { - fun, - arg, - arg1, - arg2, - arg3, - } => { - let arg = self.solve_impl(arg, expr_type, false)?; - let arg1 = arg1 - .map(|arg| self.solve_impl(arg, expr_type, false)) - .transpose()?; - let arg2 = arg2 - .map(|arg| self.solve_impl(arg, expr_type, false)) - .transpose()?; - let arg3 = arg3 - .map(|arg| self.solve_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:?}"))), - } - } - Expression::As { - convert, - expr, - kind, - } => { - let expr_constant = self.solve_impl(expr, expr_type, false)?; - - match convert { - Some(width) => self.cast(expr_constant, kind, width, span), - None => Err(ConstantSolvingError::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), - } - } - - 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::WorkGroupUniformLoadResult { .. } => unreachable!(), - Expression::AtomicResult { .. } => Err(ConstantSolvingError::Atomic), - Expression::FunctionArgument(_) => Err(ConstantSolvingError::FunctionArg), - Expression::GlobalVariable(_) => Err(ConstantSolvingError::GlobalVariable), - Expression::ImageSample { .. } - | Expression::ImageLoad { .. } - | Expression::ImageQuery { .. } => Err(ConstantSolvingError::ImageExpression), - Expression::RayQueryProceedResult | Expression::RayQueryGetIntersection { .. } => { - Err(ConstantSolvingError::RayQueryExpression) - } - } - } - - fn access( - &mut self, - base: Handle, - index: usize, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - match self.const_expressions[base] { - Expression::ZeroValue(ty) => { - let ty_inner = &self.types[ty].inner; - let components = ty_inner - .components() - .ok_or(ConstantSolvingError::InvalidAccessBase)?; - - if index >= components as usize { - Err(ConstantSolvingError::InvalidAccessBase) - } else { - let ty_res = ty_inner - .component_type(index) - .ok_or(ConstantSolvingError::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)) - } - } - Expression::Compose { ty, ref components } => { - let _ = self.types[ty] - .inner - .components() - .ok_or(ConstantSolvingError::InvalidAccessBase)?; - - components - .get(index) - .copied() - .ok_or(ConstantSolvingError::InvalidAccessIndex) - } - _ => Err(ConstantSolvingError::InvalidAccessBase), - } - } - - fn constant_index(&self, expr: Handle) -> Result { - match self.const_expressions[expr] { - Expression::Literal(Literal::U32(index)) => Ok(index as usize), - _ => Err(ConstantSolvingError::InvalidAccessIndexTy), - } - } - - /// Transforms a `Expression::ZeroValue` into either `Expression::Literal` or `Expression::Compose` - fn eval_zero_value( - &mut self, - expr: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - match self.const_expressions[expr] { - Expression::ZeroValue(ty) => self.eval_zero_value_impl(ty, span), - _ => Ok(expr), - } - } - - fn eval_zero_value_impl( - &mut self, - ty: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - match self.types[ty].inner { - TypeInner::Scalar { kind, width } => { - let expr = Expression::Literal( - Literal::zero(kind, width).ok_or(ConstantSolvingError::TypeNotConstructible)?, - ); - Ok(self.register_constant(expr, span)) - } - TypeInner::Vector { size, kind, width } => { - let scalar_ty = self.types.insert( - Type { - name: None, - inner: TypeInner::Scalar { kind, width }, - }, - span, - ); - let el = self.eval_zero_value_impl(scalar_ty, span)?; - let expr = Expression::Compose { - ty, - components: vec![el; size as usize], - }; - Ok(self.register_constant(expr, span)) - } - TypeInner::Matrix { - columns, - rows, - width, - } => { - let vec_ty = self.types.insert( - Type { - name: None, - inner: TypeInner::Vector { - size: rows, - kind: ScalarKind::Float, - width, - }, - }, - span, - ); - let el = self.eval_zero_value_impl(vec_ty, span)?; - let expr = Expression::Compose { - ty, - components: vec![el; columns as usize], - }; - Ok(self.register_constant(expr, span)) - } - TypeInner::Array { - base, - size: ArraySize::Constant(size), - .. - } => { - let el = self.eval_zero_value_impl(base, span)?; - let expr = Expression::Compose { - ty, - components: vec![el; size.get() as usize], - }; - Ok(self.register_constant(expr, span)) - } - TypeInner::Struct { ref members, .. } => { - let types: Vec<_> = members.iter().map(|m| m.ty).collect(); - let mut components = Vec::with_capacity(members.len()); - for ty in types { - components.push(self.eval_zero_value_impl(ty, span)?); - } - let expr = Expression::Compose { ty, components }; - Ok(self.register_constant(expr, span)) - } - _ => Err(ConstantSolvingError::TypeNotConstructible), - } - } - - fn cast( - &mut self, - expr: Handle, - kind: ScalarKind, - target_width: crate::Bytes, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let expr = self.eval_zero_value(expr, span)?; - - let expr = match self.const_expressions[expr] { - Expression::Literal(literal) => { - let literal = match (kind, target_width) { - (ScalarKind::Sint, 4) => Literal::I32(match literal { - Literal::I32(v) => v, - Literal::U32(v) => v as i32, - Literal::F32(v) => v as i32, - Literal::Bool(v) => v as i32, - Literal::F64(_) => return Err(ConstantSolvingError::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), - }), - (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), - }), - (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), - }), - _ => return Err(ConstantSolvingError::InvalidCastArg), - }; - Expression::Literal(literal) - } - Expression::Compose { - ty, - components: ref src_components, - } => { - match self.types[ty].inner { - TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), - _ => return Err(ConstantSolvingError::InvalidCastArg), - } - - let mut components = src_components.clone(); - for component in &mut components { - *component = self.cast(*component, kind, target_width, span)?; - } - - Expression::Compose { ty, components } - } - _ => return Err(ConstantSolvingError::InvalidCastArg), - }; - - Ok(self.register_constant(expr, span)) - } - - fn unary_op( - &mut self, - op: UnaryOperator, - expr: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let expr = self.eval_zero_value(expr, span)?; - - let expr = match self.const_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), - }, - 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), - }, - }), - Expression::Compose { - ty, - components: ref src_components, - } => { - match self.types[ty].inner { - TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), - } - - let mut components = src_components.clone(); - for component in &mut components { - *component = self.unary_op(op, *component, span)?; - } - - Expression::Compose { ty, components } - } - _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), - }; - - Ok(self.register_constant(expr, span)) - } - - fn binary_op( - &mut self, - 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], - ) { - (&Expression::Literal(left_value), &Expression::Literal(right_value)) => { - let literal = match op { - BinaryOperator::Equal => Literal::Bool(left_value == right_value), - BinaryOperator::NotEqual => Literal::Bool(left_value != right_value), - BinaryOperator::Less => Literal::Bool(left_value < right_value), - BinaryOperator::LessEqual => Literal::Bool(left_value <= right_value), - BinaryOperator::Greater => Literal::Bool(left_value > right_value), - BinaryOperator::GreaterEqual => Literal::Bool(left_value >= right_value), - - _ => 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::And => a & b, - BinaryOperator::ExclusiveOr => a ^ b, - BinaryOperator::InclusiveOr => a | b, - _ => return Err(ConstantSolvingError::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), - }), - (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::And => a & b, - BinaryOperator::ExclusiveOr => a ^ b, - BinaryOperator::InclusiveOr => a | b, - BinaryOperator::ShiftLeft => a.wrapping_shl(b), - BinaryOperator::ShiftRight => a.wrapping_shr(b), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), - }), - (Literal::F32(a), Literal::F32(b)) => Literal::F32(match op { - BinaryOperator::Add => a + b, - BinaryOperator::Subtract => a - b, - BinaryOperator::Multiply => a * b, - BinaryOperator::Divide => a / b, - BinaryOperator::Modulo => a - b * (a / b).floor(), - _ => return Err(ConstantSolvingError::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(ConstantSolvingError::InvalidBinaryOpArgs), - }, - }; - Expression::Literal(literal) - } - ( - &Expression::Compose { - components: ref src_components, - ty, - }, - &Expression::Literal(_), - ) => { - let mut components = src_components.clone(); - for component in &mut components { - *component = self.binary_op(op, *component, right, span)?; - } - Expression::Compose { ty, components } - } - ( - &Expression::Literal(_), - &Expression::Compose { - components: ref src_components, - ty, - }, - ) => { - let mut components = src_components.clone(); - for component in &mut components { - *component = self.binary_op(op, left, *component, span)?; - } - Expression::Compose { ty, components } - } - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), - }; - - Ok(self.register_constant(expr, span)) - } - - fn register_constant(&mut self, expr: Expression, span: crate::Span) -> Handle { - self.const_expressions.append(expr, span) - } -} - -/// 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; - - use crate::{ - Arena, Constant, Expression, Literal, ScalarKind, Type, TypeInner, UnaryOperator, - UniqueArena, VectorSize, - }; - - use super::ConstantSolver; - - #[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(); - let mut expressions = Arena::new(); - let mut constants = Arena::new(); - let mut const_expressions = Arena::new(); - - let scalar_ty = types.insert( - Type { - name: None, - inner: TypeInner::Scalar { - kind: ScalarKind::Sint, - width: 4, - }, - }, - Default::default(), - ); - - let vec_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: scalar_ty, - init: const_expressions - .append(Expression::Literal(Literal::I32(4)), Default::default()), - }, - Default::default(), - ); - - let h1 = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: scalar_ty, - init: const_expressions - .append(Expression::Literal(Literal::I32(8)), Default::default()), - }, - Default::default(), - ); - - let vec_h = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: vec_ty, - init: const_expressions.append( - Expression::Compose { - ty: vec_ty, - components: vec![constants[h].init, constants[h1].init], - }, - Default::default(), - ), - }, - Default::default(), - ); - - let expr = expressions.append(Expression::Constant(h), Default::default()); - let expr1 = expressions.append(Expression::Constant(vec_h), Default::default()); - - let root1 = expressions.append( - Expression::Unary { - op: UnaryOperator::Negate, - expr, - }, - Default::default(), - ); - - let root2 = expressions.append( - Expression::Unary { - op: UnaryOperator::Not, - expr, - }, - Default::default(), - ); - - let root3 = expressions.append( - Expression::Unary { - op: UnaryOperator::Not, - expr: expr1, - }, - Default::default(), - ); - - let mut solver = ConstantSolver { - types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, - }; - - let res1 = solver.solve(root1).unwrap(); - let res2 = solver.solve(root2).unwrap(); - let res3 = solver.solve(root3).unwrap(); - - assert_eq!( - const_expressions[res1], - Expression::Literal(Literal::I32(-4)) - ); - - assert_eq!( - const_expressions[res2], - Expression::Literal(Literal::I32(!4)) - ); - - let res3_inner = &const_expressions[res3]; - - match *res3_inner { - Expression::Compose { - ref ty, - ref components, - } => { - assert_eq!(*ty, vec_ty); - let mut components_iter = components.iter().copied(); - assert_eq!( - const_expressions[components_iter.next().unwrap()], - Expression::Literal(Literal::I32(!4)) - ); - assert_eq!( - const_expressions[components_iter.next().unwrap()], - Expression::Literal(Literal::I32(!8)) - ); - assert!(components_iter.next().is_none()); - } - _ => panic!("Expected vector"), - } - } - - #[test] - fn cast() { - let mut types = UniqueArena::new(); - let mut expressions = Arena::new(); - let mut constants = Arena::new(); - let mut const_expressions = Arena::new(); - - let scalar_ty = types.insert( - Type { - name: None, - inner: TypeInner::Scalar { - kind: ScalarKind::Sint, - width: 4, - }, - }, - Default::default(), - ); - - let h = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: scalar_ty, - init: const_expressions - .append(Expression::Literal(Literal::I32(4)), Default::default()), - }, - Default::default(), - ); - - let expr = 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 mut solver = ConstantSolver { - types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, - }; - - let res = solver.solve(root).unwrap(); - - assert_eq!( - const_expressions[res], - Expression::Literal(Literal::Bool(true)) - ); - } - - #[test] - fn access() { - let mut types = UniqueArena::new(); - let mut expressions = Arena::new(); - let mut constants = Arena::new(); - let mut const_expressions = Arena::new(); - - let matrix_ty = types.insert( - Type { - name: None, - inner: TypeInner::Matrix { - columns: VectorSize::Bi, - rows: VectorSize::Tri, - width: 4, - }, - }, - Default::default(), - ); - - let vec_ty = types.insert( - Type { - name: None, - inner: TypeInner::Vector { - size: VectorSize::Tri, - kind: ScalarKind::Float, - width: 4, - }, - }, - Default::default(), - ); - - let mut vec1_components = Vec::with_capacity(3); - let mut vec2_components = Vec::with_capacity(3); - - for i in 0..3 { - let h = const_expressions.append( - Expression::Literal(Literal::F32(i as f32)), - Default::default(), - ); - - vec1_components.push(h) - } - - for i in 3..6 { - let h = const_expressions.append( - Expression::Literal(Literal::F32(i as f32)), - Default::default(), - ); - - vec2_components.push(h) - } - - let vec1 = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: vec_ty, - init: const_expressions.append( - Expression::Compose { - ty: vec_ty, - components: vec1_components, - }, - Default::default(), - ), - }, - Default::default(), - ); - - let vec2 = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: vec_ty, - init: const_expressions.append( - Expression::Compose { - ty: vec_ty, - components: vec2_components, - }, - Default::default(), - ), - }, - Default::default(), - ); - - let h = constants.append( - Constant { - name: None, - r#override: crate::Override::None, - ty: matrix_ty, - init: const_expressions.append( - Expression::Compose { - ty: matrix_ty, - components: vec![constants[vec1].init, constants[vec2].init], - }, - Default::default(), - ), - }, - 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 mut solver = ConstantSolver { - types: &mut types, - expressions: &expressions, - constants: &mut constants, - const_expressions: &mut const_expressions, - }; - - let res1 = solver.solve(root1).unwrap(); - let res2 = solver.solve(root2).unwrap(); - - match const_expressions[res1] { - Expression::Compose { - ref ty, - ref components, - } => { - assert_eq!(*ty, vec_ty); - let mut components_iter = components.iter().copied(); - assert_eq!( - const_expressions[components_iter.next().unwrap()], - Expression::Literal(Literal::F32(3.)) - ); - assert_eq!( - const_expressions[components_iter.next().unwrap()], - Expression::Literal(Literal::F32(4.)) - ); - assert_eq!( - const_expressions[components_iter.next().unwrap()], - Expression::Literal(Literal::F32(5.)) - ); - assert!(components_iter.next().is_none()); - } - _ => panic!("Expected vector"), - } - - assert_eq!( - const_expressions[res2], - Expression::Literal(Literal::F32(5.)) - ); - } -} diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 407619c3d2..0eceb24e4d 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; @@ -71,15 +70,19 @@ 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, + /// Tracks the constness of `Expression`s residing in `self.expressions` + pub expression_constness: crate::proc::ExpressionConstnessTracker, } 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 +94,14 @@ 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, + expression_constness: crate::proc::ExpressionConstnessTracker::new(), }; this.emit_start(); @@ -103,6 +109,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 +248,41 @@ 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 eval = if self.is_const { + crate::proc::ConstantEvaluator::for_glsl_module(self.module) + } else { + crate::proc::ConstantEvaluator::for_glsl_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 { + kind: e.into(), + meta, + }); + + match res { + Ok(expr) => Ok(expr), + 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(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.solve_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) { ( @@ -988,18 +1016,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 { @@ -1012,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/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/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/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..851d2e1d79 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.solve_constant(root, meta)?, meta)) + Ok((root, meta)) } } @@ -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 2abd67672b..02ee2bedea 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)?; @@ -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,39 @@ 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.solve_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, - } + let decl_initializer; + let late_initializer; + if is_global_const { + decl_initializer = init; + late_initializer = None; + } else if ctx.external { + decl_initializer = + init.and_then(|expr| ctx.ctx.lift_up_const_expression(expr).ok()); + 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 { - None + decl_initializer = Some(init); + late_initializer = None; } } else { - None + decl_initializer = None; + late_initializer = None; }; - 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 +300,7 @@ impl<'source> ParsingContext<'source> { frontend: &mut Frontend, ctx: &mut Context, external: bool, + is_inside_loop: bool, ) -> Result> { //declaration: // function_prototype SEMICOLON @@ -317,7 +331,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)?; @@ -343,6 +357,7 @@ impl<'source> ParsingContext<'source> { frontend, &mut context, &mut None, + false, )?; frontend.add_function(context, name, result, meta); @@ -385,6 +400,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 200afc78fd..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); } } @@ -187,11 +192,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 { @@ -255,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, + )?; } } } @@ -350,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(()) @@ -372,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(); @@ -428,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)?; @@ -511,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(()) @@ -536,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(()) })?; @@ -571,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(); @@ -583,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/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/front/glsl/types.rs b/src/front/glsl/types.rs index a91a0a9f28..ffa879506e 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, @@ -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,21 +340,36 @@ impl Context<'_> { }) } - pub(crate) fn solve_constant( + pub(crate) fn lift_up_const_expression( &mut self, - root: Handle, - meta: Span, + expr: Handle, ) -> Result> { - let mut solver = ConstantSolver { - types: &mut self.module.types, - expressions: &self.expressions, - constants: &mut self.module.constants, - const_expressions: &mut self.module.const_expressions, - }; - - solver.solve(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/front/mod.rs b/src/front/mod.rs index 1f16ff6378..634c809fb9 100644 --- a/src/front/mod.rs +++ b/src/front/mod.rs @@ -19,42 +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()); - } - #[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 5fd54b023f..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. @@ -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 { @@ -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/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..59d7b17435 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) } @@ -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.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 56d8709708..c883732e8b 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -4,8 +4,11 @@ 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::proc::{ensure_block_returns, Alignment, Layouter, ResolveContext, TypeResolution}; +use crate::front::Typifier; +use crate::proc::{ + ensure_block_returns, Alignment, ConstantEvaluator, Emitter, Layouter, ResolveContext, + TypeResolution, +}; use crate::{Arena, FastHashMap, FastIndexMap, Handle, Span}; mod construction; @@ -103,6 +106,17 @@ pub struct StatementContext<'source, 'temp, 'out> { named_expressions: &'out mut FastIndexMap, (String, Span)>, arguments: &'out [crate::FunctionArgument], module: &'out mut crate::Module, + + /// 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, } impl<'a, 'temp> StatementContext<'a, 'temp, '_> { @@ -119,6 +133,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { named_expressions: self.named_expressions, arguments: self.arguments, module: self.module, + expression_constness: self.expression_constness, } } @@ -144,6 +159,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { typifier: self.typifier, block, emitter, + expression_constness: self.expression_constness, }), } } @@ -185,6 +201,12 @@ pub struct RuntimeExpressionContext<'temp, 'out> { block: &'temp mut crate::Block, emitter: &'temp mut Emitter, typifier: &'temp mut Typifier, + + /// 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, } impl RuntimeExpressionContext<'_, '_> { @@ -197,6 +219,7 @@ impl RuntimeExpressionContext<'_, '_> { block: self.block, emitter: self.emitter, typifier: self.typifier, + expression_constness: self.expression_constness, } } } @@ -327,17 +350,43 @@ 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::for_wgsl_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), + Err(_) => Ok(rctx.naga_expressions.append(expr, span)), + } + } + ExpressionContextType::Constant => { + let mut eval = ConstantEvaluator::for_wgsl_module(self.module); + 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) => { + 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(), } } @@ -365,39 +414,36 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { } } - fn array_length( - &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)) - } - fn gather_component( - &self, + &mut self, expr: Handle, + component_span: Span, 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) => { + if !rctx.expression_constness.is_const(expr) { + return Err(Error::ExpectedConstExprConcreteIntegerScalar( + component_span, + )); + } + 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(component_span) + } + crate::proc::U32EvalError::Negative => { + 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. @@ -543,13 +589,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 +612,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 +634,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 +645,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 +880,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 +988,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,17 +997,18 @@ 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()?; let mut typifier = Typifier::default(); let mut body = self.block( &f.body, + false, StatementContext { local_table: &mut local_table, globals: ctx.globals, @@ -962,6 +1021,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); @@ -980,11 +1040,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) @@ -997,12 +1070,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) @@ -1012,11 +1086,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 { @@ -1026,6 +1101,13 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { 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 = l.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_global())) .transpose()?; @@ -1097,18 +1179,39 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; + let (const_initializer, initializer) = { + match initializer { + 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) + } + } + 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, ); - 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, @@ -1139,8 +1242,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, @@ -1168,21 +1271,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 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 => { + crate::SwitchValue::I32(value) + } + Some(crate::Literal::U32(value)) if uint => { + crate::SwitchValue::U32(value) + } + _ => { + return Err(Error::InvalidSwitchValue { uint, span }); + } + } } ast::SwitchValue::Default => crate::SwitchValue::Default, - _ => { - return Err(Error::InvalidSwitchValue { - uint, - span: case.value_span, - }); - } }, - body: self.block(&case.body, ctx.reborrow())?, + body: self.block(&case.body, is_inside_loop, ctx.reborrow())?, fall_through: case.fall_through, }) }) @@ -1195,8 +1301,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); @@ -1261,7 +1367,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 +1376,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { right: value, }, stmt.span, - ) + )? } None => value, }; @@ -1319,7 +1425,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 +1464,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 +1486,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 +1509,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 +1589,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 +1669,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let vector = ctx.apply_load_rule(TypedExpression { handle, is_reference, - }); + })?; ( crate::Expression::Swizzle { @@ -1625,7 +1722,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 +2018,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 +2070,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 +2223,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 +2260,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 +2313,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { comparison: false, }, span, - ); + )?; let rctx = ctx.runtime_expression_ctx(span)?; rctx.block.push( crate::Statement::Atomic { @@ -2251,6 +2350,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())?; @@ -2260,20 +2360,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, + )?), ) } } @@ -2367,7 +2468,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 +2479,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 +2494,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 +2525,54 @@ 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 span = ctx.ast_expressions.get_span(expr); + let expr = self.expression(expr, ctx.reborrow())?; + 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)) + } + + 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, @@ -2449,19 +2600,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, @@ -2477,17 +2621,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()); @@ -2507,18 +2642,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/lib.rs b/src/lib.rs index 93ecaa1ab3..9d70190421 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -980,7 +980,11 @@ pub struct LocalVariable { pub ty: Handle, /// Initial value for this variable. /// - /// Expression handle lives in const_expressions + /// 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/proc/constant_evaluator.rs b/src/proc/constant_evaluator.rs new file mode 100644 index 0000000000..70a46114a9 --- /dev/null +++ b/src/proc/constant_evaluator.rs @@ -0,0 +1,1782 @@ +use crate::{ + arena::{Arena, Handle, UniqueArena}, + ArraySize, BinaryOperator, Constant, Expression, Literal, ScalarKind, Span, Type, TypeInner, + UnaryOperator, +}; + +#[derive(Debug)] +enum Behavior { + Wgsl, + 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 + /// 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 ExpressionConstnessTracker { + inner: bit_set::BitSet, +} + +impl ExpressionConstnessTracker { + pub fn new() -> Self { + Self { + inner: bit_set::BitSet::new(), + } + } + + /// 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()); + } + + 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, thiserror::Error)] +pub enum ConstantEvaluatorError { + #[error("Constants cannot access function arguments")] + FunctionArg, + #[error("Constants cannot access global variables")] + GlobalVariable, + #[error("Constants cannot access local variables")] + LocalVariable, + #[error("Cannot get the array length of a non array type")] + InvalidArrayLengthArg, + #[error("Constants cannot get the array length of a dynamically sized array")] + 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 derivative functions")] + Derivative, + #[error("Constants don't support load expressions")] + Load, + #[error("Constants don't support image expressions")] + ImageExpression, + #[error("Constants don't support ray query expressions")] + RayQueryExpression, + #[error("Cannot access the type")] + InvalidAccessBase, + #[error("Cannot access at the index")] + InvalidAccessIndex, + #[error("Cannot access with index of type")] + InvalidAccessIndexTy, + #[error("Constants don't support array length expressions")] + ArrayLength, + #[error("Cannot cast type")] + InvalidCastArg, + #[error("Cannot apply the unary op to the argument")] + InvalidUnaryOpArg, + #[error("Cannot apply the binary op to the arguments")] + 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("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")] + SwizzleVectorOnly, + #[error("swizzle component not present in source expression")] + SwizzleOutOfBounds, + #[error("Type is not constructible")] + TypeNotConstructible, + #[error("Subexpression(s) are not constant")] + 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, + #[error(transparent)] + Literal(#[from] crate::valid::LiteralError), +} + +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) + } + + 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, + function_local_data: None, + } + } + + /// 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, + 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, + ) + } + + /// 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, + 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, + emitter: &'a mut super::Emitter, + block: &'a mut crate::Block, + ) -> Self { + Self { + behavior, + 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); + } + } + Ok(()) + } + + fn check_and_get( + &mut self, + expr: Handle, + ) -> Result, ConstantEvaluatorError> { + match self.expressions[expr] { + Expression::Constant(c) => { + // Are we working in a function's expression arena, or the + // module's constant expression arena? + 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, + function_local_data.const_expressions, + ) + } else { + // "See through" the constant and use its initializer. + Ok(self.constants[c].init) + } + } + _ => { + self.check(expr)?; + Ok(expr) + } + } + } + + /// 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, + span: Span, + ) -> 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(_) => { + self.register_evaluated_expr(expr.clone(), span) + } + Expression::Compose { ty, ref components } => { + let components = components + .iter() + .map(|component| self.check_and_get(*component)) + .collect::, _>>()?; + self.register_evaluated_expr(Expression::Compose { ty, components }, span) + } + Expression::Splat { size, value } => { + let value = self.check_and_get(value)?; + self.register_evaluated_expr(Expression::Splat { size, value }, 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::NotImplemented( + "bitcast built-in function".into(), + )), + } + } + 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 => { + let expr = self.check_and_get(expr)?; + self.array_length(expr, span) + } + }, + Expression::Load { .. } => Err(ConstantEvaluatorError::Load), + Expression::LocalVariable(_) => Err(ConstantEvaluatorError::LocalVariable), + Expression::Derivative { .. } => Err(ConstantEvaluatorError::Derivative), + 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) + } + } + } + + 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], + }; + 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); + 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); + self.register_evaluated_expr(expr, span) + } + Expression::Splat { value, .. } => { + let expr = Expression::Splat { size, value }; + self.register_evaluated_expr(expr, span) + } + Expression::Compose { ty, ref components } => { + let dst_ty = get_dst_ty(ty)?; + + 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() + .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: swizzled_components, + }; + 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 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, + )); + } + + match fun { + 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, + .. + } + ) => + { + 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); + + Expression::Compose { + ty: ty0, + components, + } + } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }; + + 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(e), Literal::U32(low), Literal::U32(high)) => { + if low > high { + return Err(ConstantEvaluatorError::InvalidClamp); + } else { + Literal::U32(e.clamp(low, high)) + } + } + (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), + }; + 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); + + Expression::Compose { + ty: ty0, + components, + } + } + _ => return Err(ConstantEvaluatorError::InvalidMathArg), + }; + + self.register_evaluated_expr(expr, span) + } + + 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())); + self.register_evaluated_expr(expr, span) + } + crate::ArraySize::Dynamic => { + Err(ConstantEvaluatorError::ArrayLengthDynamic) + } + }, + _ => Err(ConstantEvaluatorError::InvalidArrayLengthArg), + } + } + _ => Err(ConstantEvaluatorError::InvalidArrayLengthArg), + } + } + + fn access( + &mut self, + base: Handle, + index: usize, + 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(ConstantEvaluatorError::InvalidAccessBase)?; + + if index >= components as usize { + Err(ConstantEvaluatorError::InvalidAccessBase) + } else { + let ty_res = ty_inner + .component_type(index) + .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) + } + }; + 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(ConstantEvaluatorError::InvalidAccessBase)?; + + crate::proc::flatten_compose(ty, components, self.expressions, self.types) + .nth(index) + .ok_or(ConstantEvaluatorError::InvalidAccessIndex) + } + _ => Err(ConstantEvaluatorError::InvalidAccessBase), + } + } + + 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), + } + } + + /// Transforms `Expression::ZeroValue` and `Expression::Splat` into either `Expression::Literal` or `Expression::Compose` + fn eval_zero_value_and_splat( + &mut self, + expr: Handle, + 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), + } + } + + fn eval_zero_value_impl( + &mut self, + ty: Handle, + span: Span, + ) -> Result, ConstantEvaluatorError> { + match self.types[ty].inner { + TypeInner::Scalar { kind, width } => { + let expr = Expression::Literal( + Literal::zero(kind, width) + .ok_or(ConstantEvaluatorError::TypeNotConstructible)?, + ); + self.register_evaluated_expr(expr, span) + } + TypeInner::Vector { size, kind, width } => { + let scalar_ty = self.types.insert( + Type { + name: None, + inner: TypeInner::Scalar { kind, width }, + }, + span, + ); + let el = self.eval_zero_value_impl(scalar_ty, span)?; + let expr = Expression::Compose { + ty, + components: vec![el; size as usize], + }; + self.register_evaluated_expr(expr, span) + } + TypeInner::Matrix { + columns, + rows, + width, + } => { + let vec_ty = self.types.insert( + Type { + name: None, + inner: TypeInner::Vector { + size: rows, + kind: ScalarKind::Float, + width, + }, + }, + span, + ); + let el = self.eval_zero_value_impl(vec_ty, span)?; + let expr = Expression::Compose { + ty, + components: vec![el; columns as usize], + }; + self.register_evaluated_expr(expr, span) + } + TypeInner::Array { + base, + size: ArraySize::Constant(size), + .. + } => { + let el = self.eval_zero_value_impl(base, span)?; + let expr = Expression::Compose { + ty, + components: vec![el; size.get() as usize], + }; + self.register_evaluated_expr(expr, span) + } + TypeInner::Struct { ref members, .. } => { + let types: Vec<_> = members.iter().map(|m| m.ty).collect(); + let mut components = Vec::with_capacity(members.len()); + for ty in types { + components.push(self.eval_zero_value_impl(ty, span)?); + } + let expr = Expression::Compose { ty, components }; + self.register_evaluated_expr(expr, span) + } + _ => Err(ConstantEvaluatorError::TypeNotConstructible), + } + } + + fn cast( + &mut self, + expr: Handle, + kind: ScalarKind, + target_width: crate::Bytes, + span: Span, + ) -> Result, ConstantEvaluatorError> { + let expr = self.eval_zero_value_and_splat(expr, span)?; + + let expr = match self.expressions[expr] { + Expression::Literal(literal) => { + let literal = match (kind, target_width) { + (ScalarKind::Sint, 4) => Literal::I32(match literal { + Literal::I32(v) => v, + Literal::U32(v) => v as i32, + Literal::F32(v) => v as i32, + Literal::Bool(v) => v as i32, + 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(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(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(ConstantEvaluatorError::InvalidCastArg), + }), + _ => return Err(ConstantEvaluatorError::InvalidCastArg), + }; + Expression::Literal(literal) + } + Expression::Compose { + ty, + components: ref src_components, + } => { + 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(ConstantEvaluatorError::InvalidCastArg), + }; + + self.register_evaluated_expr(expr, span) + } + + fn unary_op( + &mut self, + op: UnaryOperator, + expr: Handle, + span: Span, + ) -> Result, ConstantEvaluatorError> { + let expr = self.eval_zero_value_and_splat(expr, span)?; + + 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(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(ConstantEvaluatorError::InvalidUnaryOpArg), + }, + }), + Expression::Compose { + ty, + components: ref src_components, + } => { + match self.types[ty].inner { + TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), + } + + let mut components = src_components.clone(); + for component in &mut components { + *component = self.unary_op(op, *component, span)?; + } + + Expression::Compose { ty, components } + } + _ => return Err(ConstantEvaluatorError::InvalidUnaryOpArg), + }; + + self.register_evaluated_expr(expr, span) + } + + fn binary_op( + &mut self, + op: BinaryOperator, + left: Handle, + right: Handle, + 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), + BinaryOperator::NotEqual => Literal::Bool(left_value != right_value), + BinaryOperator::Less => Literal::Bool(left_value < right_value), + BinaryOperator::LessEqual => Literal::Bool(left_value <= right_value), + BinaryOperator::Greater => Literal::Bool(left_value > right_value), + BinaryOperator::GreaterEqual => Literal::Bool(left_value >= right_value), + + _ => match (left_value, right_value) { + (Literal::I32(a), Literal::I32(b)) => Literal::I32(match op { + 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 + .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.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 + .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 { + BinaryOperator::Add => a + b, + BinaryOperator::Subtract => a - b, + BinaryOperator::Multiply => a * b, + BinaryOperator::Divide => a / b, + BinaryOperator::Modulo => a % b, + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }), + (Literal::Bool(a), Literal::Bool(b)) => Literal::Bool(match op { + BinaryOperator::LogicalAnd => a && b, + BinaryOperator::LogicalOr => a || b, + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }), + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }, + }; + Expression::Literal(literal) + } + ( + &Expression::Compose { + components: ref src_components, + ty, + }, + &Expression::Literal(_), + ) => { + let mut components = src_components.clone(); + for component in &mut components { + *component = self.binary_op(op, *component, right, span)?; + } + Expression::Compose { ty, components } + } + ( + &Expression::Literal(_), + &Expression::Compose { + components: ref src_components, + ty, + }, + ) => { + let mut components = src_components.clone(); + for component in &mut components { + *component = self.binary_op(op, left, *component, span)?; + } + Expression::Compose { ty, components } + } + _ => return Err(ConstantEvaluatorError::InvalidBinaryOpArgs), + }; + + 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, + expr: Handle, + expressions: &Arena, + ) -> Result, ConstantEvaluatorError> { + let span = expressions.get_span(expr); + match expressions[expr] { + ref expr @ (Expression::Literal(_) + | Expression::Constant(_) + | 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)?; + } + self.register_evaluated_expr(Expression::Compose { ty, components }, span) + } + Expression::Splat { size, value } => { + let value = self.copy_from(value, expressions)?; + self.register_evaluated_expr(Expression::Splat { size, value }, span) + } + _ => { + log::debug!("copy_from: SubexpressionsAreNotConstant"); + Err(ConstantEvaluatorError::SubexpressionsAreNotConstant) + } + } + } + + 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, + 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 { + block.extend(emitter.finish(self.expressions)); + let h = self.expressions.append(expr, span); + emitter.start(self.expressions); + expression_constness.insert(h); + Ok(h) + } else { + let h = self.expressions.append(expr, span); + expression_constness.insert(h); + Ok(h) + } + } else { + Ok(self.expressions.append(expr, span)) + } + } +} + +#[cfg(test)] +mod tests { + use std::vec; + + use crate::{ + Arena, Constant, Expression, Literal, ScalarKind, Type, TypeInner, UnaryOperator, + UniqueArena, VectorSize, + }; + + use super::{Behavior, ConstantEvaluator}; + + #[test] + fn unary_op() { + let mut types = UniqueArena::new(); + let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); + + let scalar_ty = types.insert( + Type { + name: None, + inner: TypeInner::Scalar { + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let vec_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: scalar_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(4)), Default::default()), + }, + Default::default(), + ); + + let h1 = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: scalar_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(8)), Default::default()), + }, + Default::default(), + ); + + let vec_h = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: vec_ty, + init: const_expressions.append( + Expression::Compose { + ty: vec_ty, + components: vec![constants[h].init, constants[h1].init], + }, + Default::default(), + ), + }, + Default::default(), + ); + + let expr = const_expressions.append(Expression::Constant(h), Default::default()); + let expr1 = const_expressions.append(Expression::Constant(vec_h), Default::default()); + + let expr2 = Expression::Unary { + op: UnaryOperator::Negate, + expr, + }; + + let expr3 = Expression::Unary { + op: UnaryOperator::Not, + expr, + }; + + let expr4 = Expression::Unary { + op: UnaryOperator::Not, + expr: expr1, + }; + + let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, + types: &mut types, + constants: &constants, + expressions: &mut const_expressions, + function_local_data: None, + }; + + 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], + Expression::Literal(Literal::I32(-4)) + ); + + assert_eq!( + const_expressions[res2], + Expression::Literal(Literal::I32(!4)) + ); + + let res3_inner = &const_expressions[res3]; + + match *res3_inner { + Expression::Compose { + ref ty, + ref components, + } => { + assert_eq!(*ty, vec_ty); + let mut components_iter = components.iter().copied(); + assert_eq!( + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::I32(!4)) + ); + assert_eq!( + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::I32(!8)) + ); + assert!(components_iter.next().is_none()); + } + _ => panic!("Expected vector"), + } + } + + #[test] + fn cast() { + let mut types = UniqueArena::new(); + let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); + + let scalar_ty = types.insert( + Type { + name: None, + inner: TypeInner::Scalar { + kind: ScalarKind::Sint, + width: 4, + }, + }, + Default::default(), + ); + + let h = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: scalar_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(4)), Default::default()), + }, + Default::default(), + ); + + let expr = const_expressions.append(Expression::Constant(h), Default::default()); + + let root = Expression::As { + expr, + kind: ScalarKind::Bool, + convert: Some(crate::BOOL_WIDTH), + }; + + let mut solver = ConstantEvaluator { + behavior: Behavior::Wgsl, + types: &mut types, + constants: &constants, + expressions: &mut const_expressions, + function_local_data: None, + }; + + let res = solver + .try_eval_and_append(&root, Default::default()) + .unwrap(); + + assert_eq!( + const_expressions[res], + Expression::Literal(Literal::Bool(true)) + ); + } + + #[test] + fn access() { + let mut types = UniqueArena::new(); + let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); + + let matrix_ty = types.insert( + Type { + name: None, + inner: TypeInner::Matrix { + columns: VectorSize::Bi, + rows: VectorSize::Tri, + width: 4, + }, + }, + Default::default(), + ); + + let vec_ty = types.insert( + Type { + name: None, + inner: TypeInner::Vector { + size: VectorSize::Tri, + kind: ScalarKind::Float, + width: 4, + }, + }, + Default::default(), + ); + + let mut vec1_components = Vec::with_capacity(3); + let mut vec2_components = Vec::with_capacity(3); + + for i in 0..3 { + let h = const_expressions.append( + Expression::Literal(Literal::F32(i as f32)), + Default::default(), + ); + + vec1_components.push(h) + } + + for i in 3..6 { + let h = const_expressions.append( + Expression::Literal(Literal::F32(i as f32)), + Default::default(), + ); + + vec2_components.push(h) + } + + let vec1 = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: vec_ty, + init: const_expressions.append( + Expression::Compose { + ty: vec_ty, + components: vec1_components, + }, + Default::default(), + ), + }, + Default::default(), + ); + + let vec2 = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: vec_ty, + init: const_expressions.append( + Expression::Compose { + ty: vec_ty, + components: vec2_components, + }, + Default::default(), + ), + }, + Default::default(), + ); + + let h = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: matrix_ty, + init: const_expressions.append( + Expression::Compose { + ty: matrix_ty, + components: vec![constants[vec1].init, constants[vec2].init], + }, + Default::default(), + ), + }, + Default::default(), + ); + + 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, + function_local_data: None, + }; + + 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 res2 = solver + .try_eval_and_append(&root2, Default::default()) + .unwrap(); + + match const_expressions[res1] { + Expression::Compose { + ref ty, + ref components, + } => { + assert_eq!(*ty, vec_ty); + let mut components_iter = components.iter().copied(); + assert_eq!( + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(3.)) + ); + assert_eq!( + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(4.)) + ); + assert_eq!( + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(5.)) + ); + assert!(components_iter.next().is_none()); + } + _ => panic!("Expected vector"), + } + + assert_eq!( + const_expressions[res2], + 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 { + behavior: Behavior::Wgsl, + 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") + } + } + + #[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 { + behavior: Behavior::Wgsl, + 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/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 0d12126acb..d50f165a56 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -2,12 +2,18 @@ [`Module`](super::Module) processing functionality. */ +mod constant_evaluator; +mod emitter; pub mod index; mod layouter; mod namer; mod terminator; mod typifier; +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}; pub use namer::{EntryPointIndex, NameKey, Namer}; @@ -460,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, } } } @@ -590,28 +598,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) + } + + 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] { @@ -623,6 +642,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/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/expression.rs b/src/valid/expression.rs index 0b61253682..95225a3926 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), } @@ -1560,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/function.rs b/src/valid/function.rs index 998f873c08..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)] @@ -941,7 +943,8 @@ impl super::Validator { &self, var: &crate::LocalVariable, gctx: crate::proc::GlobalCtx, - mod_info: &ModuleInfo, + fun_info: &FunctionInfo, + expression_constness: &crate::proc::ExpressionConstnessTracker, ) -> Result<(), LocalVariableError> { log::debug!("var {:?}", var); let type_info = self @@ -954,10 +957,14 @@ 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); } + + 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(), mod_info) + self.validate_local_var(var, module.to_ctx(), &info, &expression_constness) .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/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}; diff --git a/tests/in/const-exprs.wgsl b/tests/in/const-exprs.wgsl new file mode 100644 index 0000000000..24d48665e6 --- /dev/null +++ b/tests/in/const-exprs.wgsl @@ -0,0 +1,81 @@ +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 the value of nested Compose expressions. +fn swizzle_of_compose() { + 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() { + 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() { + 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, +// 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; + + var out = vec4(w, x, y, z); +} + +// Constant evaluation should be able to see through constants to +// 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() { + var out = -vec4(FOUR); +} + +fn compose_of_constant() { + var 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); + +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/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/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/analysis/access.info.ron b/tests/out/analysis/access.info.ron index 4a020e48c4..80a2cb1621 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, @@ -2774,7 +2774,7 @@ non_uniform_result: None, requirements: (""), ), - ref_count: 0, + ref_count: 1, assignable_global: None, ty: Value(Scalar( kind: Uint, @@ -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..edc7ce1e6b 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,14 +126,13 @@ 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(); 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/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/const-exprs.main.Compute.glsl b/tests/out/glsl/const-exprs.main.Compute.glsl new file mode 100644 index 0000000000..b6bbe5daa7 --- /dev/null +++ b/tests/out/glsl/const-exprs.main.Compute.glsl @@ -0,0 +1,86 @@ +#version 310 es + +precision highp float; +precision highp int; + +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; +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; + + +void swizzle_of_compose() { + ivec4 out_ = ivec4(4, 3, 2, 1); +} + +void index_of_compose() { + int out_1 = 2; +} + +void compose_three_deep() { + int out_2 = 6; +} + +void non_constant_initializers() { + int w = 30; + 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 _e8 = w; + int _e9 = x; + int _e10 = y; + int _e11 = z; + out_3 = ivec4(_e8, _e9, _e10, _e11); + return; +} + +void splat_of_constant() { + ivec4 out_4 = ivec4(-4, -4, -4, -4); +} + +void compose_of_constant() { + ivec4 out_5 = ivec4(-4, -4, -4, -4); +} + +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(); + compose_three_deep(); + non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); + return; +} + 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/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 ba3734be18..83dd56f8a4 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_); } @@ -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; @@ -59,6 +58,7 @@ void logical() { } void arithmetic() { + float neg0_1 = -(1.0); ivec2 neg1_1 = -(ivec2(1)); vec2 neg2_ = -(vec2(1.0)); int add0_ = (2 + 1); @@ -202,54 +202,54 @@ void assignment() { int a_1 = 0; ivec3 vec0_ = ivec3(0); a_1 = 1; - int _e3 = a_1; - a_1 = (_e3 + 1); - int _e6 = a_1; - a_1 = (_e6 - 1); - int _e8 = a_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); - vec0_ = ivec3(0); - 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() { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + 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() { 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/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..a4c739d74b 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,17 +247,16 @@ 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(); 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); @@ -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/const-exprs.hlsl b/tests/out/hlsl/const-exprs.hlsl new file mode 100644 index 0000000000..fc52a1129e --- /dev/null +++ b/tests/out/hlsl/const-exprs.hlsl @@ -0,0 +1,92 @@ +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; +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; + +void swizzle_of_compose() +{ + int4 out_ = int4(4, 3, 2, 1); + +} + +void index_of_compose() +{ + int out_1 = 2; + +} + +void compose_three_deep() +{ + int out_2 = 6; + +} + +void non_constant_initializers() +{ + int w = 30; + 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 _expr8 = w; + int _expr9 = x; + int _expr10 = y; + int _expr11 = z; + out_3 = int4(_expr8, _expr9, _expr10, _expr11); + return; +} + +void splat_of_constant() +{ + int4 out_4 = int4(-4, -4, -4, -4); + +} + +void compose_of_constant() +{ + int4 out_5 = int4(-4, -4, -4, -4); + +} + +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() +{ + 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.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/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/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/image.hlsl b/tests/out/hlsl/image.hlsl index e284813a1b..7fbd68b105 100644 --- a/tests/out/hlsl/image.hlsl +++ b/tests/out/hlsl/image.hlsl @@ -252,46 +252,46 @@ float4 texture_sample() : SV_Target0 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 _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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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(3, 1)); + 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)); @@ -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/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 846f567f96..6d18d07ed6 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_); } @@ -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; @@ -58,6 +57,7 @@ void logical() void arithmetic() { + float neg0_1 = -(1.0); int2 neg1_1 = -((1).xx); float2 neg2_ = -((1.0).xx); int add0_ = (2 + 1); @@ -205,49 +205,49 @@ void assignment() int3 vec0_ = (int3)0; a_1 = 1; - int _expr3 = a_1; - a_1 = (_expr3 + 1); - int _expr6 = a_1; - a_1 = (_expr6 - 1); - int _expr8 = a_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); - vec0_ = (int3)0; - 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() { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + 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)] @@ -255,7 +255,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/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..f24f830af8 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"), @@ -1713,9 +1697,9 @@ base: 13, index: 0, ), - AccessIndex( + Access( base: 14, - index: 3, + index: 12, ), AccessIndex( base: 15, @@ -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 a200e75a91..9a1820fc8d 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: [ ( @@ -444,12 +455,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 16, - init: None, + init: Some(54), ), ], expressions: [ @@ -755,10 +766,6 @@ 46: "l6", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -827,10 +834,6 @@ start: 51, end: 54, )), - Store( - pointer: 55, - value: 54, - ), Emit(( start: 56, end: 58, @@ -948,12 +951,12 @@ ( name: Some("idx"), ty: 3, - init: None, + init: Some(1), ), ( name: Some("t"), ty: 21, - init: None, + init: Some(65), ), ], expressions: [ @@ -1327,10 +1330,6 @@ 63: "l7", }, body: [ - Store( - pointer: 2, - value: 1, - ), Emit(( start: 3, end: 5, @@ -1423,10 +1422,6 @@ start: 64, end: 65, )), - Store( - pointer: 66, - value: 65, - ), Emit(( start: 67, end: 69, @@ -1759,7 +1754,7 @@ ( name: Some("foo"), ty: 22, - init: None, + init: Some(2), ), ( name: Some("c2"), @@ -1797,9 +1792,9 @@ base: 13, index: 0, ), - AccessIndex( + Access( base: 14, - index: 3, + index: 12, ), AccessIndex( base: 15, @@ -1931,10 +1926,6 @@ 47: "value", }, body: [ - Store( - pointer: 3, - value: 2, - ), Emit(( start: 3, end: 4, @@ -2247,7 +2238,7 @@ ( name: Some("arr"), ty: 32, - init: None, + init: Some(5), ), ], expressions: [ @@ -2281,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 fb8ff825e1..8146909c1e 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"), @@ -82,7 +86,7 @@ ( name: Some("i"), ty: 1, - init: None, + init: Some(3), ), ], expressions: [ @@ -159,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..7c901c35a4 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,16 +172,15 @@ 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); 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); @@ -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/const-exprs.msl b/tests/out/msl/const-exprs.msl new file mode 100644 index 0000000000..47b3615e13 --- /dev/null +++ b/tests/out/msl/const-exprs.msl @@ -0,0 +1,92 @@ +// language: metal2.0 +#include +#include + +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; +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( +) { + metal::int4 out = metal::int4(4, 3, 2, 1); +} + +void index_of_compose( +) { + int out_1 = 2; +} + +void compose_three_deep( +) { + int out_2 = 6; +} + +void non_constant_initializers( +) { + 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 _e8 = w; + int _e9 = x; + int _e10 = y; + int _e11 = z; + out_3 = metal::int4(_e8, _e9, _e10, _e11); + return; +} + +void splat_of_constant( +) { + metal::int4 out_4 = metal::int4(-4, -4, -4, -4); +} + +void compose_of_constant( +) { + metal::int4 out_5 = metal::int4(-4, -4, -4, -4); +} + +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_( +) { + swizzle_of_compose(); + index_of_compose(); + compose_three_deep(); + non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); + return; +} 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/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 a80c71bef9..114865451a 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_; } @@ -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; @@ -64,6 +63,7 @@ void logical( void arithmetic( ) { + float neg0_1 = -(1.0); metal::int2 neg1_1 = -(metal::int2(1)); metal::float2 neg2_ = -(metal::float2(1.0)); int add0_ = 2 + 1; @@ -208,58 +208,58 @@ void comparison( void assignment( ) { int a_1 = {}; - metal::int3 vec0_ = {}; + metal::int3 vec0_ = metal::int3 {}; a_1 = 1; - int _e3 = a_1; - a_1 = _e3 + 1; - int _e6 = a_1; - a_1 = _e6 - 1; - int _e8 = a_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; - vec0_ = metal::int3 {}; - 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( ) { - int p1_ = -(-2); - int p2_ = -(-3); - int p3_ = -(-(4)); - int p4_ = -(-(-5)); - int p5_ = -(-(-(-(6)))); - int p6_ = -(-(-(-(-7)))); - int p7_ = -(-(-(-(-8)))); + 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_( ) { 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/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..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: 123 +; Bound: 124 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 %77 "test_atomic_compare_exchange_u32" +OpExecutionMode %18 LocalSize 1 1 1 +OpExecutionMode %77 LocalSize 1 1 1 OpDecorate %5 ArrayStride 4 OpDecorate %7 ArrayStride 4 OpMemberDecorate %9 0 Offset 0 @@ -39,167 +39,166 @@ 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 +%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 +%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 %34 +%22 = OpAccessChain %20 %11 %21 +OpBranch %35 +%35 = OpLabel OpBranch %36 %36 = OpLabel -OpStore %17 %30 -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 +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 -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 -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 -%60 = OpLabel +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 %52 +%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 +OpBranch %53 +%58 = OpLabel +OpBranch %60 +%60 = 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 -%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 -%38 = 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 -%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 -OpBranch %84 -%84 = OpLabel -OpStore %77 %30 +%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 -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 OpBranch %86 -%91 = OpLabel -OpBranch %93 +%86 = OpLabel +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 -%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 %87 +%92 = OpLabel +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 -%105 = OpLabel -OpBranch %107 +%100 = OpLabel +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 -%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 %101 +%106 = OpLabel 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 +%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 %95 +%95 = OpLabel +OpBranch %89 +%89 = OpLabel +%122 = OpLoad %3 %80 +%123 = OpIAdd %3 %122 %26 +OpStore %80 %123 +OpBranch %86 +%87 = 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/const-exprs.spvasm b/tests/out/spv/const-exprs.spvasm new file mode 100644 index 0000000000..e6aff5079a --- /dev/null +++ b/tests/out/spv/const-exprs.spvasm @@ -0,0 +1,131 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 91 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %83 "main" +OpExecutionMode %83 LocalSize 2 3 1 +%2 = OpTypeVoid +%3 = OpTypeInt 32 0 +%4 = OpTypeInt 32 1 +%5 = OpTypeVector %4 4 +%6 = OpTypeFloat 32 +%7 = OpTypeVector %6 4 +%8 = OpConstant %3 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 +%17 = OpConstant %4 0 +%18 = OpConstant %4 1 +%19 = OpConstant %4 2 +%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 +OpReturn +OpFunctionEnd +%28 = OpFunction %2 None %22 +%27 = OpLabel +%29 = OpVariable %30 Function %19 +OpBranch %31 +%31 = OpLabel +OpReturn +OpFunctionEnd +%33 = OpFunction %2 None %22 +%32 = OpLabel +%35 = OpVariable %30 Function %34 +OpBranch %36 +%36 = OpLabel +OpReturn +OpFunctionEnd +%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 +%58 = OpFunction %2 None %22 +%57 = OpLabel +%61 = OpVariable %25 Function %60 +OpBranch %62 +%62 = OpLabel +OpReturn +OpFunctionEnd +%64 = OpFunction %2 None %22 +%63 = OpLabel +%65 = OpVariable %25 Function %60 +OpBranch %66 +%66 = OpLabel +OpReturn +OpFunctionEnd +%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 +OpReturnValue %74 +%76 = OpLabel +OpReturnValue %81 +OpFunctionEnd +%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/spv/constructors.spvasm b/tests/out/spv/constructors.spvasm index ec54d6d1bb..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: 74 +; 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,32 +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 -%71 = OpCopyObject %20 %49 -%73 = 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 8c27f3ab9e..36fae9d60a 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: 644 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 %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 // ============================ @@ -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 %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 %66 "v" +OpName %67 "snoise2" +OpName %86 "i" +OpName %89 "i1" +OpName %91 "x12" +OpName %94 "m" +OpName %203 "p" +OpName %204 "fbm" +OpName %209 "x" +OpName %211 "v" +OpName %213 "a" +OpName %214 "i" +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 %470 "gen_terrain_fragment" -OpName %552 "position" +OpName %549 "position" +OpName %552 "normal" +OpName %554 "clip_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 %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 %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 %552 Location 0 -OpDecorate %555 Location 1 -OpDecorate %557 BuiltIn Position -OpDecorate %558 Location 0 -OpDecorate %560 Location 1 -OpDecorate %580 BuiltIn FragCoord +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 %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 -OpDecorate %584 Location 1 -OpDecorate %586 Location 0 %2 = OpTypeVoid %5 = OpTypeFloat 32 %4 = OpTypeVector %5 3 @@ -538,927 +538,914 @@ OpDecorate %586 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 -%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 -%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 -%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 +%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 = 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 +%208 = OpConstantComposite %6 %207 %207 +%210 = OpConstantNull %6 +%212 = OpTypePointer Function %5 +%215 = OpTypePointer Function %8 +%258 = OpTypeFunction %4 %6 %6 +%271 = OpTypeFunction %14 %6 %6 +%272 = OpConstant %5 0.1 +%273 = OpConstantComposite %6 %272 %74 +%274 = OpConstantComposite %6 %74 %272 +%275 = OpConstant %5 -0.1 +%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 +%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 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 %78 %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 -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 +%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 -%90 = OpCompositeConstruct %7 %79 %80 %81 %82 OpLine %3 14 24 -%91 = OpVectorShuffle %6 %90 %90 1 1 -%92 = OpDot %5 %76 %91 -%93 = OpCompositeConstruct %6 %92 %92 -%94 = OpFAdd %6 %76 %93 -%95 = OpExtInst %6 %1 Floor %94 +%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 %65 %95 +OpStore %86 %102 OpLine %3 15 14 -%96 = OpLoad %6 %65 -%97 = OpFSub %6 %76 %96 -%98 = OpLoad %6 %65 -%99 = OpVectorShuffle %6 %90 %90 0 0 -%100 = OpDot %5 %98 %99 -%101 = OpCompositeConstruct %6 %100 %100 -%102 = OpFAdd %6 %97 %101 +%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 -%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 +%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 %68 %109 +OpStore %89 %114 OpLine %3 18 26 -%112 = OpVectorShuffle %7 %102 %102 0 1 0 1 -%113 = OpVectorShuffle %7 %90 %90 0 0 2 2 -%114 = OpFAdd %7 %112 %113 -%115 = OpLoad %6 %68 +%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 -%116 = OpCompositeConstruct %7 %115 %83 %83 -%117 = OpFSub %7 %114 %116 +%121 = OpCompositeConstruct %7 %120 %74 %74 +%122 = OpFSub %7 %119 %121 OpLine %3 18 5 -OpStore %69 %117 +OpStore %91 %122 OpLine %3 1 1 -%118 = OpLoad %6 %65 +%123 = OpLoad %6 %86 OpLine %3 19 9 -%119 = OpCompositeConstruct %6 %57 %57 -%120 = OpFRem %6 %118 %119 +%124 = OpFRem %6 %123 %77 OpLine %3 19 5 -OpStore %65 %120 +OpStore %86 %124 OpLine %3 20 31 -%123 = OpAccessChain %121 %65 %122 -%124 = OpLoad %5 %123 +%127 = OpAccessChain %125 %86 %126 +%128 = OpLoad %5 %127 OpLine %3 20 51 -%125 = OpAccessChain %121 %68 %122 -%126 = OpLoad %5 %125 +%129 = OpAccessChain %125 %89 %126 +%130 = OpLoad %5 %129 OpLine %3 20 31 -%127 = OpCompositeConstruct %4 %83 %126 %56 -%128 = OpCompositeConstruct %4 %124 %124 %124 -%129 = OpFAdd %4 %128 %127 +%131 = OpCompositeConstruct %4 %74 %130 %56 +%132 = OpCompositeConstruct %4 %128 %128 %128 +%133 = OpFAdd %4 %132 %131 OpLine %3 20 22 -%130 = OpFunctionCall %4 %53 %129 +%134 = OpFunctionCall %4 %53 %133 OpLine %3 20 22 -%132 = OpAccessChain %121 %65 %131 -%133 = OpLoad %5 %132 -%134 = OpCompositeConstruct %4 %133 %133 %133 -%135 = OpFAdd %4 %130 %134 -OpLine %3 20 84 -%136 = OpAccessChain %121 %68 %131 +%136 = OpAccessChain %125 %86 %135 %137 = OpLoad %5 %136 +%138 = OpCompositeConstruct %4 %137 %137 %137 +%139 = OpFAdd %4 %134 %138 +OpLine %3 20 84 +%140 = OpAccessChain %125 %89 %135 +%141 = OpLoad %5 %140 OpLine %3 20 22 -%138 = OpCompositeConstruct %4 %83 %137 %56 -%139 = OpFAdd %4 %135 %138 +%142 = OpCompositeConstruct %4 %74 %141 %56 +%143 = OpFAdd %4 %139 %142 OpLine %3 20 13 -%140 = OpFunctionCall %4 %53 %139 +%144 = OpFunctionCall %4 %53 %143 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 -%151 = OpDot %5 %148 %150 -%152 = OpCompositeConstruct %4 %141 %146 %151 -%153 = OpCompositeConstruct %4 %84 %84 %84 -%154 = OpFSub %4 %153 %152 +%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 -%155 = OpCompositeConstruct %4 %83 %83 %83 -%156 = OpExtInst %4 %1 FMax %154 %155 +%158 = OpExtInst %4 %1 FMax %157 %80 OpLine %3 21 5 -OpStore %72 %156 +OpStore %94 %158 OpLine %3 22 9 -%157 = OpLoad %4 %72 -%158 = OpLoad %4 %72 -%159 = OpFMul %4 %157 %158 +%159 = OpLoad %4 %94 +%160 = OpLoad %4 %94 +%161 = OpFMul %4 %159 %160 OpLine %3 22 5 -OpStore %72 %159 +OpStore %94 %161 OpLine %3 23 9 -%160 = OpLoad %4 %72 -%161 = OpLoad %4 %72 -%162 = OpFMul %4 %160 %161 +%162 = OpLoad %4 %94 +%163 = OpLoad %4 %94 +%164 = OpFMul %4 %162 %163 OpLine %3 23 5 -OpStore %72 %162 +OpStore %94 %164 OpLine %3 24 13 -%163 = OpVectorShuffle %4 %90 %90 3 3 3 -%164 = OpFMul %4 %140 %163 -%165 = OpExtInst %4 %1 Fract %164 -%166 = OpVectorTimesScalar %4 %165 %85 +%165 = OpVectorShuffle %4 %73 %73 3 3 3 +%166 = OpFMul %4 %144 %165 +%167 = OpExtInst %4 %1 Fract %166 +%168 = OpVectorTimesScalar %4 %167 %81 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 %79 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 %79 +%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 %94 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 %83 +%180 = OpFSub %4 %84 %179 +%181 = OpFMul %4 %175 %180 OpLine %3 28 5 -OpStore %72 %183 +OpStore %94 %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 %109 0 +%184 = OpFMul %5 %182 %183 +%185 = OpCompositeExtract %5 %171 0 +%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 %91 +%191 = OpVectorShuffle %6 %190 %190 0 2 +%192 = OpFMul %6 %189 %191 +%193 = OpVectorShuffle %6 %171 %171 1 2 +%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 -%201 = OpLoad %4 %72 -%202 = OpDot %5 %201 %200 -%203 = OpFMul %5 %88 %202 -OpReturnValue %203 +%199 = OpLoad %4 %94 +%200 = OpDot %5 %199 %198 +%201 = OpFMul %5 %85 %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 %74 +%214 = OpVariable %215 Function %135 +%209 = OpVariable %87 Function %210 +%213 = OpVariable %212 Function %78 +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 %78 OpLine %3 40 14 -%222 = OpExtInst %5 %1 Sin %84 -%223 = OpCompositeConstruct %6 %221 %222 +%219 = OpExtInst %5 %1 Sin %78 +%220 = OpCompositeConstruct %6 %218 %219 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 -OpLine %3 43 10 -OpStore %209 %131 -OpBranch %232 -%232 = 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 %233 %235 None -OpBranch %234 -%234 = OpLabel +OpLoopMerge %230 %232 None +OpBranch %231 +%231 = OpLabel OpLine %3 43 22 -%236 = OpLoad %8 %209 -%237 = OpULessThan %107 %236 %215 +%233 = OpLoad %8 %214 +%234 = OpULessThan %112 %233 %205 OpLine %3 43 21 -OpSelectionMerge %238 None -OpBranchConditional %237 %238 %239 -%239 = OpLabel -OpBranch %233 -%238 = OpLabel -OpBranch %240 -%240 = OpLabel +OpSelectionMerge %235 None +OpBranchConditional %234 %235 %236 +%236 = OpLabel +OpBranch %230 +%235 = OpLabel +OpBranch %237 +%237 = OpLabel OpLine %3 1 1 -%242 = OpLoad %5 %205 -%243 = OpLoad %5 %208 -%244 = OpLoad %6 %204 +%239 = OpLoad %5 %211 +%240 = OpLoad %5 %213 +%241 = OpLoad %6 %209 OpLine %3 44 21 -%245 = OpFunctionCall %5 %77 %244 +%242 = OpFunctionCall %5 %67 %241 OpLine %3 44 13 -%246 = OpFMul %5 %243 %245 -%247 = OpFAdd %5 %242 %246 +%243 = OpFMul %5 %240 %242 +%244 = OpFAdd %5 %239 %243 OpLine %3 44 9 -OpStore %205 %247 +OpStore %211 %244 OpLine %3 45 13 -%248 = OpLoad %6 %204 -%249 = OpMatrixTimesVector %6 %231 %248 +%245 = OpLoad %6 %209 +%246 = OpMatrixTimesVector %6 %228 %245 OpLine %3 45 13 -%250 = OpVectorTimesScalar %6 %249 %85 -%251 = OpFAdd %6 %250 %220 +%247 = OpVectorTimesScalar %6 %246 %81 +%248 = OpFAdd %6 %247 %208 OpLine %3 45 9 -OpStore %204 %251 +OpStore %209 %248 OpLine %3 1 1 -%252 = OpLoad %5 %208 +%249 = OpLoad %5 %213 OpLine %3 46 13 -%253 = OpFMul %5 %252 %84 +%250 = OpFMul %5 %249 %78 OpLine %3 46 9 -OpStore %208 %253 -OpBranch %241 -%241 = OpLabel -OpBranch %235 -%235 = OpLabel +OpStore %213 %250 +OpBranch %238 +%238 = OpLabel +OpBranch %232 +%232 = OpLabel OpLine %3 1 1 -%254 = OpLoad %8 %209 +%251 = OpLoad %8 %214 OpLine %3 43 43 -%255 = OpIAdd %8 %254 %122 +%252 = OpIAdd %8 %251 %126 OpLine %3 43 39 -OpStore %209 %255 -OpBranch %232 -%233 = OpLabel +OpStore %214 %252 +OpBranch %229 +%230 = OpLabel OpLine %3 1 1 -%256 = OpLoad %5 %205 -OpReturnValue %256 +%253 = OpLoad %5 %211 +OpReturnValue %253 OpFunctionEnd -%260 = OpFunction %4 None %261 -%258 = OpFunctionParameter %6 -%259 = OpFunctionParameter %6 -%257 = OpLabel -OpBranch %262 -%262 = OpLabel +%257 = OpFunction %4 None %258 +%255 = OpFunctionParameter %6 +%256 = OpFunctionParameter %6 +%254 = OpLabel +OpBranch %259 +%259 = OpLabel OpLine %3 77 9 -%263 = OpCompositeExtract %5 %258 0 -%264 = OpCompositeExtract %5 %259 0 -%265 = OpCompositeExtract %5 %259 1 +%260 = OpCompositeExtract %5 %255 0 +%261 = OpCompositeExtract %5 %256 0 +%262 = OpCompositeExtract %5 %256 1 OpLine %3 78 49 -%266 = OpFunctionCall %5 %214 %258 +%263 = OpFunctionCall %5 %204 %255 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 +%264 = OpExtInst %5 %1 FMix %261 %262 %263 +%265 = OpCompositeExtract %5 %255 1 +%266 = OpCompositeConstruct %4 %260 %264 %265 +OpReturnValue %266 OpFunctionEnd -%273 = OpFunction %14 None %274 -%271 = OpFunctionParameter %6 -%272 = OpFunctionParameter %6 -%270 = OpLabel -OpBranch %277 -%277 = OpLabel +%270 = OpFunction %14 None %271 +%268 = OpFunctionParameter %6 +%269 = OpFunctionParameter %6 +%267 = OpLabel +OpBranch %278 +%278 = OpLabel OpLine %3 84 13 -%278 = OpFunctionCall %4 %260 %271 %272 +%279 = OpFunctionCall %4 %257 %268 %269 OpLine %3 86 29 -%279 = OpCompositeConstruct %6 %275 %83 -%280 = OpFAdd %6 %271 %279 +%280 = OpFAdd %6 %268 %273 OpLine %3 86 15 -%281 = OpFunctionCall %4 %260 %280 %272 +%281 = OpFunctionCall %4 %257 %280 %269 OpLine %3 86 15 -%282 = OpFSub %4 %281 %278 +%282 = OpFSub %4 %281 %279 OpLine %3 87 29 -%283 = OpCompositeConstruct %6 %83 %275 -%284 = OpFAdd %6 %271 %283 +%283 = OpFAdd %6 %268 %274 OpLine %3 87 15 -%285 = OpFunctionCall %4 %260 %284 %272 +%284 = OpFunctionCall %4 %257 %283 %269 OpLine %3 87 15 -%286 = OpFSub %4 %285 %278 +%285 = OpFSub %4 %284 %279 OpLine %3 88 29 -%287 = OpCompositeConstruct %6 %276 %83 -%288 = OpFAdd %6 %271 %287 +%286 = OpFAdd %6 %268 %276 OpLine %3 88 15 -%289 = OpFunctionCall %4 %260 %288 %272 +%287 = OpFunctionCall %4 %257 %286 %269 OpLine %3 88 15 -%290 = OpFSub %4 %289 %278 +%288 = OpFSub %4 %287 %279 OpLine %3 89 29 -%291 = OpCompositeConstruct %6 %83 %276 -%292 = OpFAdd %6 %271 %291 +%289 = OpFAdd %6 %268 %277 OpLine %3 89 15 -%293 = OpFunctionCall %4 %260 %292 %272 +%290 = OpFunctionCall %4 %257 %289 %269 OpLine %3 89 15 -%294 = OpFSub %4 %293 %278 +%291 = OpFSub %4 %290 %279 OpLine %3 91 14 -%295 = OpExtInst %4 %1 Cross %286 %282 -%296 = OpExtInst %4 %1 Normalize %295 +%292 = OpExtInst %4 %1 Cross %285 %282 +%293 = OpExtInst %4 %1 Normalize %292 OpLine %3 92 14 -%297 = OpExtInst %4 %1 Cross %294 %290 -%298 = OpExtInst %4 %1 Normalize %297 +%294 = OpExtInst %4 %1 Cross %291 %288 +%295 = OpExtInst %4 %1 Normalize %294 OpLine %3 94 14 -%299 = OpFAdd %4 %296 %298 +%296 = OpFAdd %4 %293 %295 OpLine %3 94 13 -%300 = OpVectorTimesScalar %4 %299 %84 +%297 = OpVectorTimesScalar %4 %296 %78 OpLine %3 96 12 -%301 = OpCompositeConstruct %14 %278 %300 -OpReturnValue %301 +%298 = OpCompositeConstruct %14 %279 %297 +OpReturnValue %298 OpFunctionEnd -%306 = OpFunction %6 None %307 -%303 = OpFunctionParameter %8 -%304 = OpFunctionParameter %10 -%305 = OpFunctionParameter %11 -%302 = OpLabel -OpBranch %308 -%308 = 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 -%309 = OpConvertUToF %5 %303 -%310 = OpCompositeExtract %8 %304 0 +%306 = OpConvertUToF %5 %300 +%307 = OpCompositeExtract %8 %301 0 OpLine %3 101 9 -%311 = OpIAdd %8 %310 %122 -%312 = OpConvertUToF %5 %311 -%313 = OpFRem %5 %309 %312 -%314 = OpCompositeExtract %8 %304 0 +%308 = OpIAdd %8 %307 %126 +%309 = OpConvertUToF %5 %308 +%310 = OpFRem %5 %306 %309 +%311 = OpCompositeExtract %8 %301 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 +%312 = OpIAdd %8 %311 %126 +%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 -%323 = OpFunction %4 None %324 -%322 = OpFunctionParameter %6 -%321 = OpLabel -OpBranch %329 -%329 = OpLabel +%320 = OpFunction %4 None %321 +%319 = OpFunctionParameter %6 +%318 = OpLabel +OpBranch %328 +%328 = OpLabel OpLine %3 270 9 -%330 = OpFunctionCall %5 %77 %322 +%329 = OpFunctionCall %5 %67 %319 OpLine %3 270 9 -%331 = OpFMul %5 %330 %84 +%330 = OpFMul %5 %329 %78 OpLine %3 270 9 -%332 = OpFAdd %5 %331 %84 +%331 = OpFAdd %5 %330 %78 OpLine %3 271 17 -%333 = OpCompositeConstruct %6 %325 %326 -%334 = OpFAdd %6 %322 %333 +%332 = OpFAdd %6 %319 %324 OpLine %3 271 9 -%335 = OpFunctionCall %5 %77 %334 +%333 = OpFunctionCall %5 %67 %332 OpLine %3 271 9 -%336 = OpFMul %5 %335 %84 +%334 = OpFMul %5 %333 %78 OpLine %3 271 9 -%337 = OpFAdd %5 %336 %84 +%335 = OpFAdd %5 %334 %78 OpLine %3 272 17 -%338 = OpCompositeConstruct %6 %327 %328 -%339 = OpFAdd %6 %322 %338 +%336 = OpFAdd %6 %319 %327 OpLine %3 272 9 -%340 = OpFunctionCall %5 %77 %339 +%337 = OpFunctionCall %5 %67 %336 OpLine %3 272 9 -%341 = OpFMul %5 %340 %84 +%338 = OpFMul %5 %337 %78 OpLine %3 269 12 -%342 = OpFAdd %5 %341 %84 -%343 = OpCompositeConstruct %4 %332 %337 %342 -OpReturnValue %343 +%339 = OpFAdd %5 %338 %78 +%340 = OpCompositeConstruct %4 %331 %335 %339 +OpReturnValue %340 OpFunctionEnd -%348 = OpFunction %2 None %349 -%344 = OpLabel -%347 = OpLoad %19 %345 -%351 = OpAccessChain %350 %29 %131 -OpBranch %356 -%356 = OpLabel +%345 = OpFunction %2 None %346 +%341 = OpLabel +%344 = OpLoad %19 %342 +%348 = OpAccessChain %347 %29 %135 +OpBranch %353 +%353 = OpLabel OpLine %3 111 22 -%357 = OpCompositeExtract %8 %347 0 +%354 = OpCompositeExtract %8 %344 0 OpLine %3 113 36 -%359 = OpAccessChain %358 %351 %131 -%360 = OpLoad %10 %359 +%356 = OpAccessChain %355 %348 %135 +%357 = OpLoad %10 %356 OpLine %3 113 59 -%362 = OpAccessChain %361 %351 %122 -%363 = OpLoad %11 %362 +%359 = OpAccessChain %358 %348 %126 +%360 = OpLoad %11 %359 OpLine %3 113 13 -%364 = OpFunctionCall %6 %306 %357 %360 %363 +%361 = OpFunctionCall %6 %303 %354 %357 %360 OpLine %3 115 5 OpLine %3 115 51 -%368 = OpAccessChain %367 %351 %353 -%369 = OpLoad %6 %368 +%365 = OpAccessChain %364 %348 %350 +%366 = OpLoad %6 %365 OpLine %3 115 33 -%370 = OpFunctionCall %14 %273 %364 %369 +%367 = OpFunctionCall %14 %270 %361 %366 OpLine %3 115 5 -%371 = OpAccessChain %366 %32 %131 %357 -OpStore %371 %370 +%368 = OpAccessChain %363 %32 %135 %354 +OpStore %368 %367 OpLine %3 118 23 -%372 = OpCompositeExtract %8 %347 0 +%369 = OpCompositeExtract %8 %344 0 OpLine %3 118 23 -%373 = OpIMul %8 %372 %352 +%370 = OpIMul %8 %369 %349 OpLine %3 120 25 -%375 = OpAccessChain %374 %351 %131 %131 -%376 = OpLoad %8 %375 +%372 = OpAccessChain %371 %348 %135 %135 +%373 = OpLoad %8 %372 OpLine %3 120 25 -%377 = OpAccessChain %374 %351 %131 %122 -%378 = OpLoad %8 %377 -%379 = OpIMul %8 %376 %378 +%374 = OpAccessChain %371 %348 %135 %126 +%375 = OpLoad %8 %374 +%376 = OpIMul %8 %373 %375 OpLine %3 120 9 -%380 = OpIMul %8 %379 %352 -%381 = OpUGreaterThanEqual %107 %373 %380 +%377 = OpIMul %8 %376 %349 +%378 = OpUGreaterThanEqual %112 %370 %377 OpLine %3 120 5 -OpSelectionMerge %382 None -OpBranchConditional %381 %383 %382 -%383 = OpLabel +OpSelectionMerge %379 None +OpBranchConditional %378 %380 %379 +%380 = OpLabel OpReturn -%382 = OpLabel +%379 = OpLabel OpLine %3 122 28 -%384 = OpCompositeExtract %8 %347 0 +%381 = OpCompositeExtract %8 %344 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 +%382 = OpAccessChain %371 %348 %135 %135 +%383 = OpLoad %8 %382 +%384 = OpUDiv %8 %381 %383 +%385 = OpIAdd %8 %354 %384 OpLine %3 123 15 -%389 = OpIAdd %8 %388 %122 +%386 = OpIAdd %8 %385 %126 OpLine %3 124 15 -%390 = OpAccessChain %374 %351 %131 %131 -%391 = OpLoad %8 %390 -%392 = OpIAdd %8 %388 %391 +%387 = OpAccessChain %371 %348 %135 %135 +%388 = OpLoad %8 %387 +%389 = OpIAdd %8 %385 %388 OpLine %3 124 15 -%393 = OpIAdd %8 %392 %122 +%390 = OpIAdd %8 %389 %126 OpLine %3 125 15 -%394 = OpIAdd %8 %393 %122 +%391 = OpIAdd %8 %390 %126 OpLine %3 127 5 OpLine %3 127 5 -%397 = OpAccessChain %396 %34 %131 %373 -OpStore %397 %388 +%394 = OpAccessChain %393 %34 %135 %370 +OpStore %394 %385 OpLine %3 128 5 OpLine %3 128 5 -%398 = OpIAdd %8 %373 %122 +%395 = OpIAdd %8 %370 %126 OpLine %3 128 5 -%399 = OpAccessChain %396 %34 %131 %398 -OpStore %399 %393 +%396 = OpAccessChain %393 %34 %135 %395 +OpStore %396 %390 OpLine %3 129 5 OpLine %3 129 5 -%400 = OpIAdd %8 %373 %353 +%397 = OpIAdd %8 %370 %350 OpLine %3 129 5 -%401 = OpAccessChain %396 %34 %131 %400 -OpStore %401 %394 +%398 = OpAccessChain %393 %34 %135 %397 +OpStore %398 %391 OpLine %3 130 5 OpLine %3 130 5 -%402 = OpIAdd %8 %373 %354 +%399 = OpIAdd %8 %370 %351 OpLine %3 130 5 -%403 = OpAccessChain %396 %34 %131 %402 -OpStore %403 %388 +%400 = OpAccessChain %393 %34 %135 %399 +OpStore %400 %385 OpLine %3 131 5 OpLine %3 131 5 -%404 = OpIAdd %8 %373 %355 +%401 = OpIAdd %8 %370 %352 OpLine %3 131 5 -%405 = OpAccessChain %396 %34 %131 %404 -OpStore %405 %394 +%402 = OpAccessChain %393 %34 %135 %401 +OpStore %402 %391 OpLine %3 132 5 OpLine %3 132 5 -%406 = OpIAdd %8 %373 %215 +%403 = OpIAdd %8 %370 %205 OpLine %3 132 5 -%407 = OpAccessChain %396 %34 %131 %406 -OpStore %407 %389 +%404 = OpAccessChain %393 %34 %135 %403 +OpStore %404 %386 OpReturn OpFunctionEnd -%418 = OpFunction %2 None %349 -%408 = OpLabel -%411 = OpLoad %8 %409 -%420 = OpAccessChain %419 %36 %131 -OpBranch %422 -%422 = OpLabel +%415 = OpFunction %2 None %346 +%405 = OpLabel +%408 = OpLoad %8 %406 +%417 = OpAccessChain %416 %36 %135 +OpBranch %420 +%420 = OpLabel OpLine %3 161 19 -%423 = OpIAdd %8 %411 %353 +%421 = OpIAdd %8 %408 %350 OpLine %3 161 18 -%424 = OpUDiv %8 %423 %354 +%422 = OpUDiv %8 %421 %351 OpLine %3 161 13 -%425 = OpUMod %8 %424 %353 -%426 = OpConvertUToF %5 %425 +%423 = OpUMod %8 %422 %350 +%424 = OpConvertUToF %5 %423 OpLine %3 162 19 -%427 = OpIAdd %8 %411 %122 +%425 = OpIAdd %8 %408 %126 OpLine %3 162 18 -%428 = OpUDiv %8 %427 %354 +%426 = OpUDiv %8 %425 %351 OpLine %3 162 13 -%429 = OpUMod %8 %428 %353 -%430 = OpConvertUToF %5 %429 +%427 = OpUMod %8 %426 %350 +%428 = OpConvertUToF %5 %427 OpLine %3 163 14 -%431 = OpCompositeConstruct %6 %426 %430 +%429 = OpCompositeConstruct %6 %424 %428 OpLine %3 165 30 -%432 = OpVectorTimesScalar %6 %431 %85 -%433 = OpCompositeConstruct %6 %421 %421 -%434 = OpFAdd %6 %433 %432 +%430 = OpVectorTimesScalar %6 %429 %81 +%431 = OpFAdd %6 %419 %430 OpLine %3 165 20 -%435 = OpCompositeConstruct %7 %434 %83 %56 +%432 = OpCompositeConstruct %7 %431 %74 %56 OpLine %3 168 21 -%436 = OpCompositeExtract %5 %431 0 +%433 = OpCompositeExtract %5 %429 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 +%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 -%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 +%440 = OpAccessChain %434 %417 %351 +%441 = OpLoad %8 %440 +%442 = OpConvertUToF %5 %441 +%443 = OpFMul %5 %439 %442 +%444 = OpFAdd %5 %438 %443 +%445 = OpConvertFToU %8 %444 OpLine %3 168 17 -%449 = OpAccessChain %437 %420 %355 -%450 = OpLoad %8 %449 -%451 = OpIAdd %8 %448 %450 +%446 = OpAccessChain %434 %417 %352 +%447 = OpLoad %8 %446 +%448 = OpIAdd %8 %445 %447 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 +%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 -%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 +%465 = OpFunction %2 None %346 +%453 = OpLabel +%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 %135 +OpBranch %470 +%470 = OpLabel OpLine %3 181 17 -%474 = OpCompositeExtract %6 %459 2 -%475 = OpCompositeExtract %5 %474 0 +%471 = OpCompositeExtract %6 %454 2 +%472 = OpCompositeExtract %5 %471 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 +%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 -%482 = OpAccessChain %437 %471 %354 -%483 = OpLoad %8 %482 +%479 = OpAccessChain %434 %466 %351 +%480 = OpLoad %8 %479 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 +%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 -%491 = OpAccessChain %437 %471 %355 -%492 = OpLoad %8 %491 -%493 = OpIAdd %8 %490 %492 +%488 = OpAccessChain %434 %466 %352 +%489 = OpLoad %8 %488 +%490 = OpIAdd %8 %487 %489 OpLine %3 182 32 -%494 = OpConvertUToF %5 %493 +%491 = OpConvertUToF %5 %490 OpLine %3 182 22 -%495 = OpFDiv %5 %494 %472 -%496 = OpExtInst %5 %1 Floor %495 -%497 = OpConvertFToU %8 %496 +%492 = OpFDiv %5 %491 %467 +%493 = OpExtInst %5 %1 Floor %492 +%494 = OpConvertFToU %8 %493 OpLine %3 183 22 -%498 = OpUMod %8 %493 %352 +%495 = OpUMod %8 %490 %349 OpLine %3 185 36 -%499 = OpAccessChain %358 %471 %131 -%500 = OpLoad %10 %499 +%496 = OpAccessChain %355 %466 %135 +%497 = OpLoad %10 %496 OpLine %3 185 57 -%501 = OpAccessChain %361 %471 %122 -%502 = OpLoad %11 %501 +%498 = OpAccessChain %358 %466 %126 +%499 = OpLoad %11 %498 OpLine %3 185 13 -%503 = OpFunctionCall %6 %306 %497 %500 %502 +%500 = OpFunctionCall %6 %303 %494 %497 %499 OpLine %3 186 31 -%504 = OpAccessChain %367 %471 %353 -%505 = OpLoad %6 %504 +%501 = OpAccessChain %364 %466 %350 +%502 = OpLoad %6 %501 OpLine %3 186 13 -%506 = OpFunctionCall %14 %273 %503 %505 -OpLine %3 188 5 -OpStore %456 %83 +%503 = OpFunctionCall %14 %270 %500 %502 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 %504 None +OpSwitch %495 %511 0 %505 1 %506 2 %507 3 %508 4 %509 5 %510 +%505 = OpLabel OpLine %3 191 37 -%515 = OpCompositeExtract %4 %506 0 -%516 = OpCompositeExtract %5 %515 0 +%512 = OpCompositeExtract %4 %503 0 +%513 = OpCompositeExtract %5 %512 0 OpLine %3 191 20 -OpStore %456 %516 -OpBranch %507 -%509 = OpLabel +OpStore %468 %513 +OpBranch %504 +%506 = OpLabel OpLine %3 192 37 -%517 = OpCompositeExtract %4 %506 0 -%518 = OpCompositeExtract %5 %517 1 +%514 = OpCompositeExtract %4 %503 0 +%515 = OpCompositeExtract %5 %514 1 OpLine %3 192 20 -OpStore %456 %518 -OpBranch %507 -%510 = OpLabel +OpStore %468 %515 +OpBranch %504 +%507 = OpLabel OpLine %3 193 37 -%519 = OpCompositeExtract %4 %506 0 -%520 = OpCompositeExtract %5 %519 2 +%516 = OpCompositeExtract %4 %503 0 +%517 = OpCompositeExtract %5 %516 2 OpLine %3 193 20 -OpStore %456 %520 -OpBranch %507 -%511 = OpLabel +OpStore %468 %517 +OpBranch %504 +%508 = OpLabel OpLine %3 194 37 -%521 = OpCompositeExtract %4 %506 1 -%522 = OpCompositeExtract %5 %521 0 +%518 = OpCompositeExtract %4 %503 1 +%519 = OpCompositeExtract %5 %518 0 OpLine %3 194 20 -OpStore %456 %522 -OpBranch %507 -%512 = OpLabel +OpStore %468 %519 +OpBranch %504 +%509 = OpLabel OpLine %3 195 37 -%523 = OpCompositeExtract %4 %506 1 -%524 = OpCompositeExtract %5 %523 1 +%520 = OpCompositeExtract %4 %503 1 +%521 = OpCompositeExtract %5 %520 1 OpLine %3 195 20 -OpStore %456 %524 -OpBranch %507 -%513 = OpLabel +OpStore %468 %521 +OpBranch %504 +%510 = OpLabel OpLine %3 196 37 -%525 = OpCompositeExtract %4 %506 1 -%526 = OpCompositeExtract %5 %525 2 +%522 = OpCompositeExtract %4 %503 1 +%523 = OpCompositeExtract %5 %522 2 OpLine %3 196 20 -OpStore %456 %526 -OpBranch %507 -%514 = OpLabel -OpBranch %507 -%507 = OpLabel +OpStore %468 %523 +OpBranch %504 +%511 = OpLabel +OpBranch %504 +%504 = 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 +%524 = OpAccessChain %371 %466 %135 %135 +%525 = OpLoad %8 %524 +%526 = OpUDiv %8 %494 %525 +%527 = OpIAdd %8 %494 %526 OpLine %3 201 15 -%531 = OpIAdd %8 %530 %122 +%528 = OpIAdd %8 %527 %126 OpLine %3 202 15 -%532 = OpAccessChain %374 %471 %131 %131 -%533 = OpLoad %8 %532 -%534 = OpIAdd %8 %530 %533 +%529 = OpAccessChain %371 %466 %135 %135 +%530 = OpLoad %8 %529 +%531 = OpIAdd %8 %527 %530 OpLine %3 202 15 -%535 = OpIAdd %8 %534 %122 +%532 = OpIAdd %8 %531 %126 OpLine %3 203 15 -%536 = OpIAdd %8 %535 %122 -OpLine %3 205 5 -OpStore %457 %131 +%533 = OpIAdd %8 %532 %126 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 %534 None +OpSwitch %495 %539 0 %535 3 %535 2 %536 4 %536 1 %537 5 %538 +%535 = OpLabel OpLine %3 207 24 -OpStore %457 %530 -OpBranch %537 -%539 = OpLabel +OpStore %469 %527 +OpBranch %534 +%536 = OpLabel OpLine %3 208 24 -OpStore %457 %536 -OpBranch %537 -%540 = OpLabel +OpStore %469 %533 +OpBranch %534 +%537 = OpLabel OpLine %3 209 20 -OpStore %457 %535 -OpBranch %537 -%541 = OpLabel +OpStore %469 %532 +OpBranch %534 +%538 = OpLabel OpLine %3 210 20 -OpStore %457 %531 -OpBranch %537 -%542 = OpLabel -OpBranch %537 -%537 = OpLabel +OpStore %469 %528 +OpBranch %534 +%539 = OpLabel +OpBranch %534 +%534 = OpLabel OpLine %3 213 13 -%543 = OpCompositeExtract %8 %459 0 +%540 = OpCompositeExtract %8 %454 0 OpLine %3 213 5 -OpStore %457 %543 +OpStore %469 %540 OpLine %3 222 27 -%544 = OpLoad %5 %456 -%545 = OpBitcast %8 %544 +%541 = OpLoad %5 %468 +%542 = OpBitcast %8 %541 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 +%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 -%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 +%558 = OpFunction %2 None %346 +%547 = OpLabel +%551 = OpLoad %4 %549 +%553 = OpLoad %4 %552 +%548 = OpCompositeConstruct %14 %551 %553 +%560 = OpAccessChain %559 %39 %135 +OpBranch %561 +%561 = OpLabel OpLine %3 254 25 -%566 = OpAccessChain %565 %563 %122 -%567 = OpLoad %23 %566 -%568 = OpCompositeExtract %4 %551 0 +%563 = OpAccessChain %562 %560 %126 +%564 = OpLoad %23 %563 +%565 = OpCompositeExtract %4 %548 0 OpLine %3 254 25 -%569 = OpCompositeConstruct %7 %568 %56 -%570 = OpMatrixTimesVector %7 %567 %569 +%566 = OpCompositeConstruct %7 %565 %56 +%567 = OpMatrixTimesVector %7 %564 %566 OpLine %3 255 18 -%571 = OpCompositeExtract %4 %551 1 +%568 = OpCompositeExtract %4 %548 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 +%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 -%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 +%583 = OpFunction %2 None %346 +%574 = OpLabel +%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 %135 +%586 = OpAccessChain %585 %42 %135 +OpBranch %594 +%594 = OpLabel OpLine %3 278 28 -%594 = 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 +%595 = OpCompositeExtract %4 %575 2 +%596 = OpExtInst %4 %1 Fract %595 +%597 = OpExtInst %4 %1 SmoothStep %80 %587 %596 OpLine %3 278 5 -OpStore %577 %598 +OpStore %592 %597 OpLine %3 279 17 -%599 = OpCompositeConstruct %4 %84 %275 %591 OpLine %3 279 13 -%600 = OpCompositeConstruct %4 %592 %592 %592 -%601 = OpAccessChain %121 %577 %131 -%602 = OpLoad %5 %601 -%603 = OpAccessChain %121 %577 %122 +%598 = OpAccessChain %125 %592 %135 +%599 = OpLoad %5 %598 +%600 = OpAccessChain %125 %592 %126 +%601 = OpLoad %5 %600 +%602 = OpFMul %5 %599 %601 +%603 = OpAccessChain %125 %592 %350 %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 +%606 = OpCompositeConstruct %4 %605 %605 %605 +%607 = OpExtInst %4 %1 FMix %589 %591 %606 OpLine %3 279 5 -OpStore %577 %610 +OpStore %592 %607 OpLine %3 282 25 -%612 = OpAccessChain %611 %590 %122 -%613 = OpLoad %4 %612 -%614 = OpVectorTimesScalar %4 %613 %275 +%609 = OpAccessChain %608 %586 %126 +%610 = OpLoad %4 %609 +%611 = OpVectorTimesScalar %4 %610 %272 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 +%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 -%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 +%618 = OpAccessChain %617 %584 %135 +%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 -%627 = OpFAdd %4 %626 %619 -%628 = OpExtInst %4 %1 Normalize %627 +%624 = OpFAdd %4 %623 %616 +%625 = OpExtInst %4 %1 Normalize %624 OpLine %3 288 32 -%629 = OpCompositeExtract %4 %579 1 -%630 = OpDot %5 %629 %619 +%626 = OpCompositeExtract %4 %575 1 +%627 = OpDot %5 %626 %616 OpLine %3 288 28 -%631 = OpExtInst %5 %1 FMax %630 %83 +%628 = OpExtInst %5 %1 FMax %627 %74 OpLine %3 289 25 -%632 = OpAccessChain %611 %590 %122 -%633 = OpLoad %4 %632 -%634 = OpVectorTimesScalar %4 %633 %631 +%629 = OpAccessChain %608 %586 %126 +%630 = OpLoad %4 %629 +%631 = OpVectorTimesScalar %4 %630 %628 OpLine %3 291 37 -%635 = OpCompositeExtract %4 %579 1 -%636 = OpDot %5 %635 %628 +%632 = OpCompositeExtract %4 %575 1 +%633 = OpDot %5 %632 %625 OpLine %3 291 33 -%637 = OpExtInst %5 %1 FMax %636 %83 +%634 = OpExtInst %5 %1 FMax %633 %74 OpLine %3 291 29 -%638 = OpExtInst %5 %1 Pow %637 %326 +%635 = OpExtInst %5 %1 Pow %634 %323 OpLine %3 292 26 -%639 = OpAccessChain %611 %590 %122 -%640 = OpLoad %4 %639 -%641 = OpVectorTimesScalar %4 %640 %638 +%636 = OpAccessChain %608 %586 %126 +%637 = OpLoad %4 %636 +%638 = OpVectorTimesScalar %4 %637 %635 OpLine %3 294 18 -%642 = OpFAdd %4 %614 %634 -%643 = OpFAdd %4 %642 %641 -%644 = OpLoad %4 %577 -%645 = OpFMul %4 %643 %644 +%639 = OpFAdd %4 %611 %631 +%640 = OpFAdd %4 %639 %638 +%641 = OpLoad %4 %592 +%642 = OpFMul %4 %640 %641 OpLine %3 296 12 -%646 = OpCompositeConstruct %7 %645 %56 -OpStore %586 %646 +%643 = OpCompositeConstruct %7 %642 %56 +OpStore %582 %643 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 1b6ef28879..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: 523 +; Bound: 518 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 %421 "texture_sample_comparison" %419 -OpEntryPoint Fragment %476 "gather" %475 -OpEntryPoint Fragment %511 "depth_no_comparison" %510 +OpEntryPoint Vertex %189 "queries" %187 +OpEntryPoint Vertex %241 "levels_queries" %240 +OpEntryPoint Fragment %270 "texture_sample" %269 +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 %274 OriginUpperLeft -OpExecutionMode %421 OriginUpperLeft -OpExecutionMode %476 OriginUpperLeft -OpExecutionMode %511 OriginUpperLeft +OpExecutionMode %270 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" @@ -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 %415 "a" -OpName %421 "texture_sample_comparison" -OpName %476 "gather" -OpName %511 "depth_no_comparison" +OpName %189 "queries" +OpName %241 "levels_queries" +OpName %270 "texture_sample" +OpName %284 "a" +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 @@ -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 %419 Location 0 -OpDecorate %475 Location 0 -OpDecorate %510 Location 0 +OpDecorate %187 BuiltIn Position +OpDecorate %240 BuiltIn Position +OpDecorate %269 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 @@ -189,42 +189,45 @@ OpDecorate %510 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 -%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 +%285 = OpTypePointer Function %23 +%286 = OpConstantNull %23 +%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 @@ -234,14 +237,13 @@ OpDecorate %510 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,377 +323,370 @@ 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 -%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 +%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 +%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 -%414 = OpLoad %23 %269 -OpStore %273 %414 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 +%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 -%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 +%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 -%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 +%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/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 71bd913f7a..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: 522 +; Bound: 377 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %511 "main" -OpExecutionMode %511 LocalSize 1 1 1 +OpEntryPoint GLCompute %366 "main" +OpExecutionMode %366 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 %3 = OpTypeVector %4 4 @@ -32,553 +32,406 @@ OpExecutionMode %511 LocalSize 1 1 1 %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 +%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 = 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 %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 +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 = 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 -%51 = OpFAdd %3 %50 %41 -OpReturnValue %51 +%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 -%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 +%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 -%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 +%73 = OpFunction %9 None %74 +%72 = OpLabel +%75 = OpVariable %76 Function %54 +OpBranch %77 +%77 = OpLabel +%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 -%93 = OpFunction %10 None %94 -%92 = OpFunctionParameter %10 -%91 = OpLabel -OpBranch %95 -%95 = OpLabel -%98 = OpFUnordNotEqual %96 %92 %97 -%100 = OpSelect %10 %98 %99 %97 -OpReturnValue %100 +%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 -%102 = OpFunction %2 None %103 -%101 = OpLabel +%96 = OpFunction %2 None %97 +%95 = OpLabel OpBranch %104 %104 = OpLabel %105 = OpLogicalNot %8 %26 -%107 = OpCompositeConstruct %106 %26 %26 -%108 = OpLogicalNot %106 %107 +%106 = OpLogicalNot %98 %99 +%107 = OpLogicalOr %8 %26 %28 +%108 = OpLogicalAnd %8 %26 %28 %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 +%110 = OpLogicalOr %90 %100 %101 +%111 = OpLogicalAnd %8 %26 %28 +%112 = OpLogicalAnd %7 %102 %103 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 +%114 = OpFunction %2 None %97 +%113 = OpLabel +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 -%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 +%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 -%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 +%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 -%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 +%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 -%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 +%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 -%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 +%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/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/246-collatz.comp.wgsl b/tests/out/wgsl/246-collatz.comp.wgsl index e92cf8127c..5d1ea64833 100644 --- a/tests/out/wgsl/246-collatz.comp.wgsl +++ b/tests/out/wgsl/246-collatz.comp.wgsl @@ -8,28 +8,26 @@ 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 = u32(0); 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..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 = f32(1); return; } diff --git a/tests/out/wgsl/280-matrix-cast.frag.wgsl b/tests/out/wgsl/280-matrix-cast.frag.wgsl index 316d936518..7d432ee496 100644 --- a/tests/out/wgsl/280-matrix-cast.frag.wgsl +++ b/tests/out/wgsl/280-matrix-cast.frag.wgsl @@ -1,9 +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)); - 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)); - return; } @fragment 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/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/access.wgsl b/tests/out/wgsl/access.wgsl index c01c4247c5..de98638874 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,17 +129,16 @@ 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(); 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); @@ -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..5f98c61969 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; - 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; - i_1 = 0u; loop { let _e2 = i_1; if (_e2 < SIZE) { diff --git a/tests/out/wgsl/bevy-pbr.frag.wgsl b/tests/out/wgsl/bevy-pbr.frag.wgsl index 85bbafd042..c40b6dd73d 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,15 +321,15 @@ 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 { 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_; @@ -353,10 +351,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; @@ -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; @@ -934,6 +928,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/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/bits_glsl.frag.wgsl b/tests/out/wgsl/bits_glsl.frag.wgsl index d81c3319d7..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 = u32(0); - u2_ = vec2(u32(0)); - u3_ = vec3(u32(0)); - u4_ = vec4(u32(0)); - f2_ = vec2(0.0); - f4_ = vec4(0.0); let _e33 = f4_; u = pack4x8snorm(_e33); let _e36 = f4_; @@ -42,44 +32,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/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/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/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/const-exprs.wgsl b/tests/out/wgsl/const-exprs.wgsl new file mode 100644 index 0000000000..fffc11f34f --- /dev/null +++ b/tests/out/wgsl/const-exprs.wgsl @@ -0,0 +1,84 @@ +const TWO: u32 = 2u; +const THREE: i32 = 3; +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); +const TEXTURE_KIND_REGULAR: i32 = 0; +const TEXTURE_KIND_WARP: i32 = 1; +const TEXTURE_KIND_SKY: i32 = 2; + +fn swizzle_of_compose() { + var out: vec4 = vec4(4, 3, 2, 1); + +} + +fn index_of_compose() { + var out_1: i32 = 2; + +} + +fn compose_three_deep() { + var out_2: i32 = 6; + +} + +fn non_constant_initializers() { + var w: i32 = 30; + 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 _e8 = w; + let _e9 = x; + let _e10 = y; + let _e11 = z; + out_3 = vec4(_e8, _e9, _e10, _e11); + return; +} + +fn splat_of_constant() { + var out_4: vec4 = vec4(-4, -4, -4, -4); + +} + +fn compose_of_constant() { + var out_5: vec4 = vec4(-4, -4, -4, -4); + +} + +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(); + index_of_compose(); + compose_three_deep(); + non_constant_initializers(); + splat_of_constant(); + compose_of_constant(); + return; +} diff --git a/tests/out/wgsl/constant-array-size.frag.wgsl b/tests/out/wgsl/constant-array-size.frag.wgsl index 1aff03c79c..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(f32(0)); - i = 0; loop { let _e9 = i; if !((_e9 < NUM_VECS)) { 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/declarations.frag.wgsl b/tests/out/wgsl/declarations.frag.wgsl index 1720296896..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(f32(1), f32(2)); let _e35 = in_array_2[1]; from_input_array = _e35; let _e41 = array_2d[0][0]; 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..c3817d8d78 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) @@ -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 = f32(mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0))[0].x); - 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 = u32(1); let _e3 = a_18; b_16 = vec4(i32(_e3)); return; @@ -332,7 +325,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 +335,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 +347,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 +357,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; @@ -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 = i32(4u); - return; } fn indexConstantNonConstantIndex(i: i32) { @@ -407,8 +398,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; } @@ -417,18 +408,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 +431,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/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/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/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/local-var-init-in-loop.comp.wgsl b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl new file mode 100644 index 0000000000..7675a54cef --- /dev/null +++ b/tests/out/wgsl/local-var-init-in-loop.comp.wgsl @@ -0,0 +1,29 @@ +fn main_1() { + var sum: vec4 = vec4(0.0); + var i: i32 = 0; + var a: vec4; + + loop { + let _e6 = i; + if !((_e6 < 4)) { + break; + } + { + a = vec4(1.0); + 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 f335452e1f..cadfe936c4 100644 --- a/tests/out/wgsl/long-form-matrix.frag.wgsl +++ b/tests/out/wgsl/long-form-matrix.frag.wgsl @@ -1,37 +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)); - 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)); - 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/module-scope.wgsl b/tests/out/wgsl/module-scope.wgsl index 3276a0a10a..b746ff37ca 100644 --- a/tests/out/wgsl/module-scope.wgsl +++ b/tests/out/wgsl/module-scope.wgsl @@ -14,13 +14,12 @@ fn statement() { } fn returns() -> S { - return S(Value); + return S(1); } 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..5038bdc853 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_); } @@ -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; @@ -52,6 +51,7 @@ fn logical() { } fn arithmetic() { + let neg0_1 = -(1.0); let neg1_1 = -(vec2(1)); let neg2_ = -(vec2(1.0)); let add0_ = (2 + 1); @@ -193,58 +193,58 @@ fn comparison() { fn assignment() { var a_1: i32; - var vec0_: vec3; + var vec0_: vec3 = vec3(); a_1 = 1; - let _e3 = a_1; - a_1 = (_e3 + 1); - let _e6 = a_1; - a_1 = (_e6 - 1); - let _e8 = a_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); - vec0_ = vec3(); - 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() { - let p1_ = -(-2); - let p2_ = -(-3); - let p3_ = -(-(4)); - let p4_ = -(-(-5)); - let p5_ = -(-(-(-(6)))); - let p6_ = -(-(-(-(-7)))); - let p7_ = -(-(-(-(-8)))); + 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) 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/prepostfix.frag.wgsl b/tests/out/wgsl/prepostfix.frag.wgsl index 296a8151eb..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(u32(1)); let _e14 = vec; vec = (_e14 - vec2(1u)); vec_target = _e14; @@ -22,8 +20,6 @@ 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)); 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..39e51e93de 100644 --- a/tests/out/wgsl/sampler-functions.frag.wgsl +++ b/tests/out/wgsl/sampler-functions.frag.wgsl @@ -1,15 +1,14 @@ 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; 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..11565d1f5a 100644 --- a/tests/out/wgsl/samplers.frag.wgsl +++ b/tests/out/wgsl/samplers.frag.wgsl @@ -218,19 +218,19 @@ 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; @@ -265,12 +265,12 @@ fn testTex2D(coord_4: vec2) { 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, (_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 _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, (_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; @@ -285,32 +285,32 @@ fn testTex2D(coord_4: vec2) { 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, (_e313.xy / vec2(_e313.z)), 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, (_e336.xyz / vec3(_e336.w)).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, (_e357.xy / vec2(_e357.z)), 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, (_e378.xyz / vec3(_e378.w)).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, (_e399.xy / vec2(_e399.z)), 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, (_e422.xyz / vec3(_e422.w)).xy, 2.0, vec2(5)); c_2 = _e431; let _e432 = coord_5; let _e435 = coord_5; @@ -344,7 +344,7 @@ fn testTex2DShadow(coord_6: vec2) { 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)); + let _e82 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e73.xy, _e73.z, vec2(5)); d = _e82; let _e83 = coord_7; let _e89 = coord_7; @@ -354,12 +354,12 @@ fn testTex2DShadow(coord_6: vec2) { 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)); + 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, 5)); + let _e133 = textureSampleCompare(tex2DShadow, sampShadow, _e128.xy, _e128.z, vec2(5)); d = _e133; let _e134 = coord_7; let _e140 = coord_7; @@ -377,7 +377,7 @@ fn testTex2DShadow(coord_6: vec2) { 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)); + let _e210 = textureSampleCompareLevel(tex2DShadow, sampShadow, _e207.xy, _e207.z, vec2(5)); d = _e210; let _e211 = coord_7; let _e218 = coord_7; @@ -389,13 +389,13 @@ fn testTex2DShadow(coord_6: vec2) { 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)); + 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, 5)); + let _e279 = textureSampleCompare(tex2DShadow, sampShadow, _e276.xy, _e276.z, vec2(5)); d = _e279; return; } @@ -419,19 +419,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; @@ -468,12 +468,12 @@ fn testTex2DArrayShadow(coord_10: vec3) { 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)); + 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, 5)); + let _e119 = textureSampleCompare(tex2DArrayShadow, sampShadow, _e112.xy, i32(_e112.z), _e112.w, vec2(5)); d_1 = _e119; return; } @@ -588,12 +588,12 @@ fn testTex3D(coord_20: vec3) { 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, (_e81.xyz / vec3(_e81.w)), 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, (_e103.xyz / vec3(_e103.w)), 2.0, vec3(5)); c_6 = _e111; let _e112 = coord_21; let _e119 = coord_21; @@ -603,7 +603,7 @@ fn testTex3D(coord_20: vec3) { 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, (_e145.xyz / vec3(_e145.w)), 3.0, vec3(5)); c_6 = _e153; let _e154 = coord_21; let _e164 = coord_21; @@ -613,25 +613,25 @@ fn testTex3D(coord_20: vec3) { 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, (_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)); 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; 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; 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() { diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index cbab660269..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,13 +902,33 @@ 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: 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 +938,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 "###, );