diff --git a/src/back/dot/mod.rs b/src/back/dot/mod.rs index 85f382d26e..d92fe39e4a 100644 --- a/src/back/dot/mod.rs +++ b/src/back/dot/mod.rs @@ -405,6 +405,10 @@ fn write_function_expressions( E::Literal(_) => ("Literal".into(), 2), E::Constant(_) => ("Constant".into(), 2), E::ZeroValue(_) => ("ZeroValue".into(), 2), + E::Compose { ref components, .. } => { + payload = Some(Payload::Arguments(components)); + ("Compose".into(), 3) + } E::Access { base, index } => { edges.insert("base", base); edges.insert("index", index); @@ -426,10 +430,6 @@ fn write_function_expressions( edges.insert("vector", vector); (format!("Swizzle{:?}", &pattern[..size as usize]).into(), 3) } - E::Compose { ref components, .. } => { - payload = Some(Payload::Arguments(components)); - ("Compose".into(), 3) - } E::FunctionArgument(index) => (format!("Argument[{index}]").into(), 1), E::GlobalVariable(h) => { payload = Some(Payload::Global(h)); diff --git a/src/back/glsl/mod.rs b/src/back/glsl/mod.rs index b7384af737..83cf544c15 100644 --- a/src/back/glsl/mod.rs +++ b/src/back/glsl/mod.rs @@ -604,8 +604,6 @@ impl<'a, W: Write> Writer<'a, W> { } } - let ep_info = self.info.get_entry_point(self.entry_point_idx as usize); - // Write struct types. // // This are always ordered because the IR is structured in a way that @@ -627,6 +625,23 @@ impl<'a, W: Write> Writer<'a, W> { } } + // Write all named constants + let mut constants = self + .module + .constants + .iter() + .filter(|&(_, c)| c.name.is_some()) + .peekable(); + while let Some((handle, _)) = constants.next() { + self.write_global_constant(handle)?; + // Add extra newline for readability on last iteration + if constants.peek().is_none() { + writeln!(self.out)?; + } + } + + let ep_info = self.info.get_entry_point(self.entry_point_idx as usize); + // Write the globals // // Unless explicitly disabled with WriterFlags::INCLUDE_UNUSED_ITEMS, @@ -722,31 +737,6 @@ impl<'a, W: Write> Writer<'a, W> { } } - if include_unused { - // write named constants - for (handle, constant) in self.module.constants.iter() { - if let Some(name) = constant.name.as_ref() { - write!(self.out, "const ")?; - match constant.inner { - crate::ConstantInner::Scalar { width, value } => { - // create a TypeInner to write - let inner = TypeInner::Scalar { - width, - kind: value.scalar_kind(), - }; - self.write_value_type(&inner)?; - } - crate::ConstantInner::Composite { ty, .. } => { - self.write_type(ty)?; - } - }; - write!(self.out, " {name} = ")?; - self.write_constant(handle)?; - writeln!(self.out, ";")?; - } - } - } - for arg in self.entry_point.function.arguments.iter() { self.write_varying(arg.binding.as_ref(), arg.ty, false)?; } @@ -818,12 +808,6 @@ impl<'a, W: Write> Writer<'a, W> { /// /// # Notes /// Adds no trailing or leading whitespace - /// - /// # Panics - /// - If type is either a image, a sampler, a pointer, or a struct - /// - If it's an Array with a [`ArraySize::Constant`](crate::ArraySize::Constant) with a - /// constant that isn't a [`Scalar`](crate::ConstantInner::Scalar) or if the - /// scalar value isn't an [`Sint`](crate::ScalarValue::Sint) or [`Uint`](crate::ScalarValue::Uint) fn write_value_type(&mut self, inner: &TypeInner) -> BackendResult { match *inner { // Scalars are simple we just get the full name from `glsl_scalar` @@ -865,11 +849,9 @@ impl<'a, W: Write> Writer<'a, W> { rows as u8 )?, // GLSL arrays are written as `type name[size]` - // Current code is written arrays only as `[size]` + // Here we only write the size of the array i.e. `[size]` // Base `type` and `name` should be written outside TypeInner::Array { base, size, .. } => self.write_array_size(base, size)?, - // Panic if either Image, Sampler, Pointer, or a Struct is being written - // // Write all variants instead of `_` so that if new variants are added a // no exhaustiveness error is thrown TypeInner::Pointer { .. } @@ -890,12 +872,6 @@ impl<'a, W: Write> Writer<'a, W> { /// /// # Notes /// Adds no trailing or leading whitespace - /// - /// # Panics - /// - If type is either a image or sampler - /// - If it's an Array with a [`ArraySize::Constant`](crate::ArraySize::Constant) with a - /// constant that isn't a [`Scalar`](crate::ConstantInner::Scalar) or if the - /// scalar value isn't an [`Sint`](crate::ScalarValue::Sint) or [`Uint`](crate::ScalarValue::Uint) fn write_type(&mut self, ty: Handle) -> BackendResult { match self.module.types[ty].inner { // glsl has no pointer types so just write types as normal and loads are skipped @@ -1050,7 +1026,7 @@ impl<'a, W: Write> Writer<'a, W> { if global.space.initializable() && is_value_init_supported(self.module, global.ty) { write!(self.out, " = ")?; if let Some(init) = global.init { - self.write_constant(init)?; + self.write_const_expr(init)?; } else { self.write_zero_init_value(global.ty)?; } @@ -1550,7 +1526,7 @@ impl<'a, W: Write> Writer<'a, W> { // Write the constant // `write_constant` adds no trailing or leading space/newline - self.write_constant(init)?; + self.write_const_expr(init)?; } else if is_value_init_supported(self.module, local.ty) { write!(self.out, " = ")?; self.write_zero_init_value(local.ty)?; @@ -1605,7 +1581,7 @@ impl<'a, W: Write> Writer<'a, W> { Ok(()) } - /// Helper method that writes a list of comma separated `T` with a writer function `F` + /// Write a list of comma separated `T` values using a writer function `F`. /// /// The writer function `F` receives a mutable reference to `self` that if needed won't cause /// borrow checker issues (using for example a closure with `self` will cause issues), the @@ -1620,61 +1596,30 @@ impl<'a, W: Write> Writer<'a, W> { data: &[T], mut f: F, ) -> BackendResult { - // Loop trough `data` invoking `f` for each element - for (i, item) in data.iter().enumerate() { - f(self, i as u32, item)?; - - // Only write a comma if isn't the last element - if i != data.len().saturating_sub(1) { - // The leading space is for readability only + // Loop through `data` invoking `f` for each element + for (index, item) in data.iter().enumerate() { + if index != 0 { write!(self.out, ", ")?; } + f(self, index as u32, item)?; } Ok(()) } - /// Helper method used to write constants - /// - /// # Notes - /// Adds no newlines or leading/trailing whitespace - fn write_constant(&mut self, handle: Handle) -> BackendResult { - use crate::ScalarValue as Sv; - - match self.module.constants[handle].inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } => match *value { - // Signed integers don't need anything special - Sv::Sint(int) => write!(self.out, "{int}")?, - // Unsigned integers need a `u` at the end - // - // While `core` doesn't necessarily need it, it's allowed and since `es` needs it we - // always write it as the extra branch wouldn't have any benefit in readability - Sv::Uint(int) => write!(self.out, "{int}u")?, - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero which is needed for a valid glsl float constant - Sv::Float(float) => write!(self.out, "{float:?}")?, - // Booleans are either `true` or `false` so nothing special needs to be done - Sv::Bool(boolean) => write!(self.out, "{boolean}")?, - }, - // Composite constant are created using the same syntax as compose - // `type(components)` where `components` is a comma separated list of constants - crate::ConstantInner::Composite { ty, ref components } => { - self.write_type(ty)?; - if let TypeInner::Array { base, size, .. } = self.module.types[ty].inner { - self.write_array_size(base, size)?; - } - write!(self.out, "(")?; - - // Write the comma separated constants - self.write_slice(components, |this, _, arg| this.write_constant(*arg))?; - - write!(self.out, ")")? - } + /// Helper method used to write global constants + fn write_global_constant(&mut self, handle: Handle) -> BackendResult { + write!(self.out, "const ")?; + let constant = &self.module.constants[handle]; + self.write_type(constant.ty)?; + let name = &self.names[&NameKey::Constant(handle)]; + write!(self.out, " {name}")?; + if let TypeInner::Array { base, size, .. } = self.module.types[constant.ty].inner { + self.write_array_size(base, size)?; } - + write!(self.out, " = ")?; + self.write_const_expr(constant.init)?; + writeln!(self.out, ";")?; Ok(()) } @@ -2219,6 +2164,100 @@ impl<'a, W: Write> Writer<'a, W> { Ok(()) } + /// Write a const expression. + /// + /// Write `expr`, a handle to an [`Expression`] in the current [`Module`]'s + /// constant expression arena, as GLSL expression. + /// + /// # Notes + /// Adds no newlines or leading/trailing whitespace + /// + /// [`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) + }) + } + + /// Write [`Expression`] variants that can occur in both runtime and const expressions. + /// + /// Write `expr`, a handle to an [`Expression`] in the arena `expressions`, + /// as as GLSL expression. This must be one of the [`Expression`] variants + /// that is allowed to occur in constant expressions. + /// + /// Use `write_expression` to write subexpressions. + /// + /// This is the common code for `write_expr`, which handles arbitrary + /// runtime expressions, and `write_const_expr`, which only handles + /// const-expressions. Each of those callers passes itself (essentially) as + /// the `write_expression` callback, so that subexpressions are restricted + /// to the appropriate variants. + /// + /// # Notes + /// Adds no newlines or leading/trailing whitespace + /// + /// [`Expression`]: crate::Expression + fn write_possibly_const_expr( + &mut self, + expr: Handle, + expressions: &crate::Arena, + write_expression: E, + ) -> BackendResult + where + E: Fn(&mut Self, Handle) -> BackendResult, + { + use crate::Expression; + + match expressions[expr] { + Expression::Literal(literal) => { + match literal { + // Floats are written using `Debug` instead of `Display` because it always appends the + // decimal part even it's zero which is needed for a valid glsl float constant + crate::Literal::F64(value) => write!(self.out, "{:?}LF", value)?, + crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, + // Unsigned integers need a `u` at the end + // + // While `core` doesn't necessarily need it, it's allowed and since `es` needs it we + // always write it as the extra branch wouldn't have any benefit in readability + crate::Literal::U32(value) => write!(self.out, "{}u", value)?, + crate::Literal::I32(value) => write!(self.out, "{}", value)?, + crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + } + } + Expression::Constant(handle) => { + let constant = &self.module.constants[handle]; + if constant.name.is_some() { + write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; + } else { + self.write_const_expr(constant.init)?; + } + } + Expression::ZeroValue(ty) => { + self.write_zero_init_value(ty)?; + } + Expression::Compose { ty, ref components } => { + self.write_type(ty)?; + + if let TypeInner::Array { base, size, .. } = self.module.types[ty].inner { + self.write_array_size(base, size)?; + } + + write!(self.out, "(")?; + for (index, component) in components.iter().enumerate() { + if index != 0 { + write!(self.out, ", ")?; + } + write_expression(self, *component)?; + } + write!(self.out, ")")? + } + _ => unreachable!(), + } + + Ok(()) + } + /// Helper method to write expressions /// /// # Notes @@ -2236,6 +2275,14 @@ impl<'a, W: Write> Writer<'a, W> { } match ctx.expressions[expr] { + Expression::Literal(_) + | Expression::Constant(_) + | Expression::ZeroValue(_) + | Expression::Compose { .. } => { + self.write_possibly_const_expr(expr, ctx.expressions, |writer, expr| { + writer.write_expr(expr, ctx) + })?; + } // `Access` is applied to arrays, vectors and matrices and is written as indexing Expression::Access { base, index } => { self.write_expr(base, ctx)?; @@ -2281,26 +2328,6 @@ impl<'a, W: Write> Writer<'a, W> { ref other => return Err(Error::Custom(format!("Cannot index {other:?}"))), } } - // Constants are delegated to `write_constant` - Expression::Constant(constant) => self.write_constant(constant)?, - Expression::ZeroValue(ty) => { - self.write_zero_init_value(ty)?; - } - Expression::Literal(literal) => { - match literal { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero which is needed for a valid glsl float constant - crate::Literal::F64(value) => write!(self.out, "{:?}LF", value)?, - crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, - // Unsigned integers need a `u` at the end - // - // While `core` doesn't necessarily need it, it's allowed and since `es` needs it we - // always write it as the extra branch wouldn't have any benefit in readability - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, - } - } // `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); @@ -2321,20 +2348,6 @@ impl<'a, W: Write> Writer<'a, W> { self.out.write_char(back::COMPONENTS[sc as usize])?; } } - // `Compose` is pretty simple we just write `type(components)` where `components` is a - // comma separated list of expressions - Expression::Compose { ty, ref components } => { - self.write_type(ty)?; - - let resolved = ctx.info[expr].ty.inner_with(&self.module.types); - if let TypeInner::Array { base, size, .. } = *resolved { - self.write_array_size(base, size)?; - } - - write!(self.out, "(")?; - self.write_slice(components, |this, _, arg| this.write_expr(*arg, ctx))?; - write!(self.out, ")")? - } // Function arguments are written as the argument name Expression::FunctionArgument(pos) => { write!(self.out, "{}", &self.names[&ctx.argument_key(pos)])? @@ -2524,7 +2537,7 @@ impl<'a, W: Write> Writer<'a, W> { if tex_1d_hack { write!(self.out, "ivec2(")?; } - self.write_constant(constant)?; + self.write_const_expr(constant)?; if tex_1d_hack { write!(self.out, ", 0)")?; } @@ -3829,11 +3842,11 @@ impl<'a, W: Write> Writer<'a, W> { TypeInner::Struct { ref members, .. } => { let name = &self.names[&NameKey::Type(ty)]; write!(self.out, "{name}(")?; - for (i, member) in members.iter().enumerate() { - self.write_zero_init_value(member.ty)?; - if i != members.len().saturating_sub(1) { + for (index, member) in members.iter().enumerate() { + if index != 0 { write!(self.out, ", ")?; } + self.write_zero_init_value(member.ty)?; } write!(self.out, ")")?; } diff --git a/src/back/hlsl/help.rs b/src/back/hlsl/help.rs index c59816550c..7ad4631315 100644 --- a/src/back/hlsl/help.rs +++ b/src/back/hlsl/help.rs @@ -159,10 +159,7 @@ impl<'a, W: Write> super::Writer<'a, W> { /// pub(super) fn write_wrapped_array_length_function( &mut self, - module: &crate::Module, wal: WrappedArrayLength, - expr_handle: Handle, - func_ctx: &FunctionCtx, ) -> BackendResult { use crate::back::INDENT; @@ -170,9 +167,7 @@ impl<'a, W: Write> super::Writer<'a, W> { const RETURN_VARIABLE_NAME: &str = "ret"; // Write function return type and name - let ret_ty = func_ctx.info[expr_handle].ty.inner_with(&module.types); - self.write_value_type(module, ret_ty)?; - write!(self.out, " ")?; + write!(self.out, "uint ")?; self.write_wrapped_array_length_function_name(wal)?; // Write function parameters @@ -786,14 +781,36 @@ impl<'a, W: Write> super::Writer<'a, W> { Ok(()) } - /// Helper function that write wrapped function for `Expression::ImageQuery` and `Expression::ArrayLength` - /// - /// + /// Helper function that writes compose wrapped functions + pub(super) fn write_wrapped_compose_functions( + &mut self, + module: &crate::Module, + expressions: &crate::Arena, + ) -> BackendResult { + for (handle, _) in expressions.iter() { + if let crate::Expression::Compose { ty, .. } = expressions[handle] { + match module.types[ty].inner { + crate::TypeInner::Struct { .. } | crate::TypeInner::Array { .. } => { + let constructor = WrappedConstructor { ty }; + if self.wrapped.constructors.insert(constructor) { + self.write_wrapped_constructor_function(module, constructor)?; + } + } + _ => {} + }; + } + } + Ok(()) + } + + /// Helper function that writes various wrapped functions pub(super) fn write_wrapped_functions( &mut self, module: &crate::Module, func_ctx: &FunctionCtx, ) -> BackendResult { + self.write_wrapped_compose_functions(module, func_ctx.expressions)?; + for (handle, _) in func_ctx.expressions.iter() { match func_ctx.expressions[handle] { crate::Expression::ArrayLength(expr) => { @@ -816,9 +833,8 @@ impl<'a, W: Write> super::Writer<'a, W> { writable: storage_access.contains(crate::StorageAccess::STORE), }; - if !self.wrapped.array_lengths.contains(&wal) { - self.write_wrapped_array_length_function(module, wal, handle, func_ctx)?; - self.wrapped.array_lengths.insert(wal); + if self.wrapped.array_lengths.insert(wal) { + self.write_wrapped_array_length_function(wal)?; } } crate::Expression::ImageQuery { image, query } => { @@ -836,9 +852,8 @@ impl<'a, W: Write> super::Writer<'a, W> { _ => unreachable!("we only query images"), }; - if !self.wrapped.image_queries.contains(&wiq) { + if self.wrapped.image_queries.insert(wiq) { self.write_wrapped_image_query_function(module, wiq, handle, func_ctx)?; - self.wrapped.image_queries.insert(wiq); } } // Write `WrappedConstructor` for structs that are loaded from `AddressSpace::Storage` @@ -867,19 +882,18 @@ impl<'a, W: Write> super::Writer<'a, W> { } let constructor = WrappedConstructor { ty }; - if !writer.wrapped.constructors.contains(&constructor) { + if writer.wrapped.constructors.insert(constructor) { writer .write_wrapped_constructor_function(module, constructor)?; - writer.wrapped.constructors.insert(constructor); } } crate::TypeInner::Array { base, .. } => { write_wrapped_constructor(writer, base, module)?; + let constructor = WrappedConstructor { ty }; - if !writer.wrapped.constructors.contains(&constructor) { + if writer.wrapped.constructors.insert(constructor) { writer .write_wrapped_constructor_function(module, constructor)?; - writer.wrapped.constructors.insert(constructor); } } _ => {} @@ -888,18 +902,6 @@ impl<'a, W: Write> super::Writer<'a, W> { Ok(()) } } - crate::Expression::Compose { ty, components: _ } => { - let constructor = match module.types[ty].inner { - crate::TypeInner::Struct { .. } | crate::TypeInner::Array { .. } => { - WrappedConstructor { ty } - } - _ => continue, - }; - if !self.wrapped.constructors.contains(&constructor) { - self.write_wrapped_constructor_function(module, constructor)?; - self.wrapped.constructors.insert(constructor); - } - } // We treat matrices of the form `matCx2` as a sequence of C `vec2`s // (see top level module docs for details). // @@ -925,7 +927,7 @@ impl<'a, W: Write> super::Writer<'a, W> { let ty = base_ty_handle.unwrap(); let access = WrappedStructMatrixAccess { ty, index }; - if !self.wrapped.struct_matrix_access.contains(&access) { + if self.wrapped.struct_matrix_access.insert(access) { self.write_wrapped_struct_matrix_get_function(module, access)?; self.write_wrapped_struct_matrix_set_function(module, access)?; self.write_wrapped_struct_matrix_set_vec_function( @@ -934,7 +936,6 @@ impl<'a, W: Write> super::Writer<'a, W> { self.write_wrapped_struct_matrix_set_scalar_function( module, access, )?; - self.wrapped.struct_matrix_access.insert(access); } } _ => {} @@ -948,33 +949,6 @@ impl<'a, W: Write> super::Writer<'a, W> { Ok(()) } - pub(super) fn write_wrapped_constructor_function_for_constant( - &mut self, - module: &crate::Module, - constant: &crate::Constant, - ) -> BackendResult { - if let crate::ConstantInner::Composite { ty, ref components } = constant.inner { - match module.types[ty].inner { - crate::TypeInner::Struct { .. } | crate::TypeInner::Array { .. } => { - let constructor = WrappedConstructor { ty }; - if !self.wrapped.constructors.contains(&constructor) { - self.write_wrapped_constructor_function(module, constructor)?; - self.wrapped.constructors.insert(constructor); - } - } - _ => {} - } - for constant in components { - self.write_wrapped_constructor_function_for_constant( - module, - &module.constants[*constant], - )?; - } - } - - Ok(()) - } - pub(super) fn write_texture_coordinates( &mut self, kind: &str, @@ -1085,9 +1059,8 @@ impl<'a, W: Write> super::Writer<'a, W> { }) = super::writer::get_inner_matrix_data(module, global.ty) { let entry = WrappedMatCx2 { columns }; - if !self.wrapped.mat_cx2s.contains(&entry) { + if self.wrapped.mat_cx2s.insert(entry) { self.write_mat_cx2_typedef_and_functions(entry)?; - self.wrapped.mat_cx2s.insert(entry); } } } @@ -1104,9 +1077,8 @@ impl<'a, W: Write> super::Writer<'a, W> { }) = super::writer::get_inner_matrix_data(module, member.ty) { let entry = WrappedMatCx2 { columns }; - if !self.wrapped.mat_cx2s.contains(&entry) { + if self.wrapped.mat_cx2s.insert(entry) { self.write_mat_cx2_typedef_and_functions(entry)?; - self.wrapped.mat_cx2s.insert(entry); } } } diff --git a/src/back/hlsl/writer.rs b/src/back/hlsl/writer.rs index ec99c97448..4f19126388 100644 --- a/src/back/hlsl/writer.rs +++ b/src/back/hlsl/writer.rs @@ -199,31 +199,11 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { write!(self.out, ", space{}", bt.space)?; } writeln!(self.out, ");")?; - } - // Write all constants - // For example, input wgsl shader: - // ```wgsl - // let c_scale: f32 = 1.2; - // return VertexOutput(uv, vec4(c_scale * pos, 0.0, 1.0)); - // ``` - // - // Output shader: - // ```hlsl - // static const float c_scale = 1.2; - // const VertexOutput vertexoutput1 = { vertexinput.uv3, float4((c_scale * vertexinput.pos1), 0.0, 1.0) }; - // ``` - // - // If we remove `write_global_constant` `c_scale` will be inlined. - for (handle, constant) in module.constants.iter() { - if constant.name.is_some() { - self.write_global_constant(module, &constant.inner, handle)?; - } + // Extra newline for readability + writeln!(self.out)?; } - // Extra newline for readability - writeln!(self.out)?; - // Save all entry point output types let ep_results = module .entry_points @@ -264,9 +244,20 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { } } - // Write wrapped constructor functions used in constants - for (_, constant) in module.constants.iter() { - self.write_wrapped_constructor_function_for_constant(module, constant)?; + self.write_wrapped_compose_functions(module, &module.const_expressions)?; + + // Write all named constants + let mut constants = module + .constants + .iter() + .filter(|&(_, c)| c.name.is_some()) + .peekable(); + while let Some((handle, _)) = constants.next() { + self.write_global_constant(module, handle)?; + // Add extra newline for readability on last iteration + if constants.peek().is_none() { + writeln!(self.out)?; + } } // Write all globals @@ -321,8 +312,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { }; let name = self.names[&NameKey::Function(handle)].clone(); - // Write wrapped function for `Expression::ImageQuery` and `Expressions::ArrayLength` - // before writing all statements and expressions. self.write_wrapped_functions(module, &ctx)?; self.write_function(module, name.as_str(), function, &ctx, info)?; @@ -362,8 +351,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { named_expressions: &ep.function.named_expressions, }; - // Write wrapped function for `Expression::ImageQuery` and `Expressions::ArrayLength` - // before writing all statements and expressions. self.write_wrapped_functions(module, &ctx)?; if ep.stage == ShaderStage::Compute { @@ -769,7 +756,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if global.space == crate::AddressSpace::Private { write!(self.out, " = ")?; if let Some(init) = global.init { - self.write_constant(module, init)?; + self.write_const_expression(module, init)?; } else { self.write_default_init(module, global.ty)?; } @@ -807,44 +794,19 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { fn write_global_constant( &mut self, module: &Module, - inner: &crate::ConstantInner, handle: Handle, ) -> BackendResult { write!(self.out, "static const ")?; - match *inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } => { - // Write type - let ty_str = match *value { - crate::ScalarValue::Sint(_) => "int", - crate::ScalarValue::Uint(_) => "uint", - crate::ScalarValue::Float(_) => "float", - crate::ScalarValue::Bool(_) => "bool", - }; - let name = &self.names[&NameKey::Constant(handle)]; - write!(self.out, "{ty_str} {name} = ")?; - - // Second match required to avoid heap allocation by `format!()` - match *value { - crate::ScalarValue::Sint(value) => write!(self.out, "{value}")?, - crate::ScalarValue::Uint(value) => write!(self.out, "{value}")?, - crate::ScalarValue::Float(value) => { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - write!(self.out, "{value:?}")? - } - crate::ScalarValue::Bool(value) => write!(self.out, "{value}")?, - }; - } - crate::ConstantInner::Composite { ty, ref components } => { - self.write_type(module, ty)?; - let name = &self.names[&NameKey::Constant(handle)]; - write!(self.out, " {name} = ")?; - self.write_composite_constant(module, ty, components)?; - } + let constant = &module.constants[handle]; + self.write_type(module, constant.ty)?; + let name = &self.names[&NameKey::Constant(handle)]; + write!(self.out, " {}", name)?; + // Write size for array type + if let TypeInner::Array { base, size, .. } = module.types[constant.ty].inner { + self.write_array_size(module, base, size)?; } + write!(self.out, " = ")?; + self.write_const_expression(module, constant.init)?; writeln!(self.out, ";")?; Ok(()) } @@ -1261,12 +1223,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 { - // Put the equal signal only if there's a initializer - // The leading and trailing spaces aren't needed but help with readability - - // Write the constant - // `write_constant` adds no trailing or leading space/newline - self.write_constant(module, init)?; + self.write_const_expression(module, init)?; } else { // Zero initialize local variables self.write_default_init(module, local.ty)?; @@ -1859,12 +1816,10 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { let func_name = &self.names[&NameKey::Function(function)]; write!(self.out, "{func_name}(")?; for (index, argument) in arguments.iter().enumerate() { - self.write_expr(module, *argument, func_ctx)?; - // Only write a comma if isn't the last element - if index != arguments.len().saturating_sub(1) { - // The leading space is for readability only + if index != 0 { write!(self.out, ", ")?; } + self.write_expr(module, *argument, func_ctx)?; } writeln!(self.out, ");")? } @@ -2043,6 +1998,77 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { Ok(()) } + fn write_const_expression( + &mut self, + module: &Module, + expr: Handle, + ) -> BackendResult { + self.write_possibly_const_expression( + module, + expr, + &module.const_expressions, + |writer, expr| writer.write_const_expression(module, expr), + ) + } + + fn write_possibly_const_expression( + &mut self, + module: &Module, + expr: Handle, + expressions: &crate::Arena, + write_expression: E, + ) -> BackendResult + where + E: Fn(&mut Self, Handle) -> BackendResult, + { + use crate::Expression; + + match expressions[expr] { + Expression::Literal(literal) => match literal { + // Floats are written using `Debug` instead of `Display` because it always appends the + // decimal part even it's zero + crate::Literal::F64(value) => write!(self.out, "{value:?}L")?, + crate::Literal::F32(value) => write!(self.out, "{value:?}")?, + crate::Literal::U32(value) => write!(self.out, "{}u", value)?, + crate::Literal::I32(value) => write!(self.out, "{}", value)?, + crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + }, + Expression::Constant(handle) => { + let constant = &module.constants[handle]; + if constant.name.is_some() { + write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; + } else { + self.write_const_expression(module, constant.init)?; + } + } + Expression::ZeroValue(ty) => self.write_default_init(module, ty)?, + Expression::Compose { ty, ref components } => { + match module.types[ty].inner { + TypeInner::Struct { .. } | TypeInner::Array { .. } => { + self.write_wrapped_constructor_function_name( + module, + WrappedConstructor { ty }, + )?; + } + _ => { + self.write_type(module, ty)?; + } + }; + write!(self.out, "(")?; + for (index, component) in components.iter().enumerate() { + if index != 0 { + write!(self.out, ", ")?; + } + write_expression(self, *component)?; + } + write!(self.out, ")")?; + } + _ => unreachable!(), + } + + Ok(()) + } + /// Helper method to write expressions /// /// # Notes @@ -2091,41 +2117,16 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { let expression = &func_ctx.expressions[expr]; match *expression { - Expression::Constant(constant) => self.write_constant(module, constant)?, - Expression::ZeroValue(ty) => self.write_default_init(module, ty)?, - Expression::Literal(literal) => match literal { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - crate::Literal::F64(value) => write!(self.out, "{value:?}L")?, - crate::Literal::F32(value) => write!(self.out, "{value:?}")?, - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, - }, - Expression::Compose { ty, ref components } => { - match module.types[ty].inner { - TypeInner::Struct { .. } | TypeInner::Array { .. } => { - self.write_wrapped_constructor_function_name( - module, - WrappedConstructor { ty }, - )?; - } - _ => { - self.write_type(module, ty)?; - } - }; - - write!(self.out, "(")?; - - for (index, &component) in components.iter().enumerate() { - if index != 0 { - // The leading space is for readability only - write!(self.out, ", ")?; - } - self.write_expr(module, component, func_ctx)?; - } - - write!(self.out, ")")?; + Expression::Literal(_) + | Expression::Constant(_) + | Expression::ZeroValue(_) + | Expression::Compose { .. } => { + self.write_possibly_const_expression( + module, + expr, + func_ctx.expressions, + |writer, expr| writer.write_expr(module, expr, func_ctx), + )?; } // All of the multiplication can be expressed as `mul`, // except vector * vector, which needs to use the "*" operator. @@ -2412,7 +2413,7 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { if let Some(offset) = offset { write!(self.out, ", ")?; - self.write_constant(module, offset)?; + self.write_const_expression(module, offset)?; } write!(self.out, ")")?; @@ -3184,82 +3185,6 @@ impl<'a, W: fmt::Write> super::Writer<'a, W> { Ok(()) } - /// Helper method used to write constants - /// - /// # Notes - /// Doesn't add any newlines or leading/trailing spaces - fn write_constant( - &mut self, - module: &Module, - handle: Handle, - ) -> BackendResult { - let constant = &module.constants[handle]; - match constant.inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } => { - if constant.name.is_some() { - write!(self.out, "{}", &self.names[&NameKey::Constant(handle)])?; - } else { - self.write_scalar_value(*value)?; - } - } - crate::ConstantInner::Composite { ty, ref components } => { - self.write_composite_constant(module, ty, components)?; - } - } - - Ok(()) - } - - fn write_composite_constant( - &mut self, - module: &Module, - ty: Handle, - components: &[Handle], - ) -> BackendResult { - match module.types[ty].inner { - TypeInner::Struct { .. } | TypeInner::Array { .. } => { - self.write_wrapped_constructor_function_name(module, WrappedConstructor { ty })?; - } - _ => { - self.write_type(module, ty)?; - } - }; - write!(self.out, "(")?; - for (index, constant) in components.iter().enumerate() { - self.write_constant(module, *constant)?; - // Only write a comma if isn't the last element - if index != components.len().saturating_sub(1) { - // The leading space is for readability only - write!(self.out, ", ")?; - } - } - write!(self.out, ")")?; - - Ok(()) - } - - /// Helper method used to write [`ScalarValue`](crate::ScalarValue) - /// - /// # Notes - /// Adds no trailing or leading whitespace - fn write_scalar_value(&mut self, value: crate::ScalarValue) -> BackendResult { - use crate::ScalarValue as Sv; - - match value { - Sv::Sint(value) => write!(self.out, "{value}")?, - Sv::Uint(value) => write!(self.out, "{value}u")?, - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - Sv::Float(value) => write!(self.out, "{value:?}")?, - Sv::Bool(value) => write!(self.out, "{value}")?, - } - - Ok(()) - } - fn write_named_expr( &mut self, module: &Module, diff --git a/src/back/mod.rs b/src/back/mod.rs index 76fbaf7644..875b04d69a 100644 --- a/src/back/mod.rs +++ b/src/back/mod.rs @@ -71,6 +71,14 @@ struct FunctionCtx<'a> { } impl FunctionCtx<'_> { + fn resolve_type<'a>( + &'a self, + handle: crate::Handle, + types: &'a crate::UniqueArena, + ) -> &'a crate::TypeInner { + self.info[handle].ty.inner_with(types) + } + /// Helper method that generates a [`NameKey`](crate::proc::NameKey) for a local in the current function const fn name_key(&self, local: crate::Handle) -> crate::proc::NameKey { match self.ty { diff --git a/src/back/msl/writer.rs b/src/back/msl/writer.rs index a9551dc715..200b4f0231 100644 --- a/src/back/msl/writer.rs +++ b/src/back/msl/writer.rs @@ -300,50 +300,6 @@ impl<'a> TypedGlobalVariable<'a> { } } -struct ConstantContext<'a> { - handle: Handle, - arena: &'a crate::Arena, - names: &'a FastHashMap, - first_time: bool, -} - -impl<'a> Display for ConstantContext<'a> { - fn fmt(&self, out: &mut Formatter<'_>) -> Result<(), FmtError> { - let con = &self.arena[self.handle]; - if con.needs_alias() && !self.first_time { - let name = &self.names[&NameKey::Constant(self.handle)]; - return write!(out, "{name}"); - } - - match con.inner { - crate::ConstantInner::Scalar { value, width: _ } => match value { - crate::ScalarValue::Sint(value) => { - write!(out, "{value}") - } - crate::ScalarValue::Uint(value) => { - write!(out, "{value}u") - } - crate::ScalarValue::Float(value) => { - if value.is_infinite() { - let sign = if value.is_sign_negative() { "-" } else { "" }; - write!(out, "{sign}INFINITY") - } else if value.is_nan() { - write!(out, "NAN") - } else { - let suffix = if value.fract() == 0.0 { ".0" } else { "" }; - - write!(out, "{value}{suffix}") - } - } - crate::ScalarValue::Bool(value) => { - write!(out, "{value}") - } - }, - crate::ConstantInner::Composite { .. } => unreachable!("should be aliased"), - } - } -} - pub struct Writer { out: W, names: FastHashMap, @@ -501,16 +457,6 @@ impl crate::Type { } } -impl crate::Constant { - // Returns `true` if we need to emit an alias for this constant. - const fn needs_alias(&self) -> bool { - match self.inner { - crate::ConstantInner::Scalar { .. } => self.name.is_some(), - crate::ConstantInner::Composite { .. } => true, - } - } -} - enum FunctionOrigin { Handle(Handle), EntryPoint(proc::EntryPointIndex), @@ -655,12 +601,25 @@ impl Writer { parameters: impl Iterator>, context: &ExpressionContext, ) -> BackendResult { + self.put_call_parameters_impl(parameters, |writer, expr| { + writer.put_expression(expr, context, true) + }) + } + + fn put_call_parameters_impl( + &mut self, + parameters: impl Iterator>, + put_expression: E, + ) -> BackendResult + where + E: Fn(&mut Self, Handle) -> BackendResult, + { write!(self.out, "(")?; for (i, handle) in parameters.enumerate() { if i != 0 { write!(self.out, ", ")?; } - self.put_expression(handle, context, true)?; + put_expression(self, handle)?; } write!(self.out, ")")?; Ok(()) @@ -1077,44 +1036,6 @@ impl Writer { Ok(()) } - fn put_compose( - &mut self, - ty: Handle, - components: &[Handle], - context: &ExpressionContext, - ) -> BackendResult { - match context.module.types[ty].inner { - crate::TypeInner::Scalar { width: 4, kind } if components.len() == 1 => { - write!(self.out, "{}", kind.to_msl_name())?; - self.put_call_parameters(components.iter().cloned(), context)?; - } - crate::TypeInner::Vector { size, kind, .. } => { - put_numeric_type(&mut self.out, kind, &[size])?; - self.put_call_parameters(components.iter().cloned(), context)?; - } - crate::TypeInner::Matrix { columns, rows, .. } => { - put_numeric_type(&mut self.out, crate::ScalarKind::Float, &[rows, columns])?; - self.put_call_parameters(components.iter().cloned(), context)?; - } - crate::TypeInner::Array { .. } | crate::TypeInner::Struct { .. } => { - write!(self.out, "{} {{", &self.names[&NameKey::Type(ty)])?; - for (index, &component) in components.iter().enumerate() { - if index != 0 { - write!(self.out, ", ")?; - } - // insert padding initialization, if needed - if self.struct_member_pads.contains(&(ty, index as u32)) { - write!(self.out, "{{}}, ")?; - } - self.put_expression(component, context, true)?; - } - write!(self.out, "}}")?; - } - _ => return Err(Error::UnsupportedCompose(ty)), - } - Ok(()) - } - /// Write the maximum valid index of the dynamically sized array at the end of `handle`. /// /// The 'maximum valid index' is simply one less than the array's length. @@ -1260,6 +1181,113 @@ impl Writer { Ok(()) } + fn put_const_expression( + &mut self, + expr_handle: Handle, + module: &crate::Module, + ) -> BackendResult { + self.put_possibly_const_expression( + expr_handle, + &module.const_expressions, + module, + |writer, expr| writer.put_const_expression(expr, module), + ) + } + + fn put_possibly_const_expression( + &mut self, + expr_handle: Handle, + expressions: &crate::Arena, + module: &crate::Module, + put_expression: E, + ) -> BackendResult + where + E: Fn(&mut Self, Handle) -> BackendResult, + { + match expressions[expr_handle] { + crate::Expression::Literal(literal) => match literal { + crate::Literal::F64(_) => { + return Err(Error::CapabilityNotSupported(valid::Capabilities::FLOAT64)) + } + crate::Literal::F32(value) => { + if value.is_infinite() { + let sign = if value.is_sign_negative() { "-" } else { "" }; + write!(self.out, "{sign}INFINITY")?; + } else if value.is_nan() { + write!(self.out, "NAN")?; + } else { + let suffix = if value.fract() == 0.0 { ".0" } else { "" }; + write!(self.out, "{value}{suffix}")?; + } + } + crate::Literal::U32(value) => { + write!(self.out, "{value}u")?; + } + crate::Literal::I32(value) => { + write!(self.out, "{value}")?; + } + crate::Literal::Bool(value) => { + write!(self.out, "{value}")?; + } + }, + crate::Expression::Constant(handle) => { + let constant = &module.constants[handle]; + if constant.name.is_some() { + write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; + } else { + self.put_const_expression(constant.init, module)?; + } + } + crate::Expression::ZeroValue(ty) => { + let ty_name = TypeContext { + handle: ty, + gctx: module.to_ctx(), + names: &self.names, + access: crate::StorageAccess::empty(), + binding: None, + first_time: false, + }; + write!(self.out, "{ty_name} {{}}")?; + } + crate::Expression::Compose { ty, ref components } => { + let ty_name = TypeContext { + handle: ty, + gctx: module.to_ctx(), + names: &self.names, + access: crate::StorageAccess::empty(), + binding: None, + first_time: false, + }; + write!(self.out, "{ty_name}")?; + match module.types[ty].inner { + crate::TypeInner::Scalar { .. } + | crate::TypeInner::Vector { .. } + | crate::TypeInner::Matrix { .. } => { + self.put_call_parameters_impl(components.iter().copied(), put_expression)?; + } + crate::TypeInner::Array { .. } | crate::TypeInner::Struct { .. } => { + write!(self.out, " {{")?; + for (index, &component) in components.iter().enumerate() { + if index != 0 { + write!(self.out, ", ")?; + } + // insert padding initialization, if needed + if self.struct_member_pads.contains(&(ty, index as u32)) { + write!(self.out, "{{}}, ")?; + } + put_expression(self, component)?; + } + write!(self.out, "}}")?; + } + _ => return Err(Error::UnsupportedCompose(ty)), + } + } + _ => unreachable!(), + } + + Ok(()) + } + /// Emit code for the expression `expr_handle`. /// /// The `is_scoped` argument is true if the surrounding operators have the @@ -1291,6 +1319,17 @@ impl Writer { let expression = &context.function.expressions[expr_handle]; log::trace!("expression {:?} = {:?}", expr_handle, expression); match *expression { + crate::Expression::Literal(_) + | crate::Expression::Constant(_) + | crate::Expression::ZeroValue(_) + | crate::Expression::Compose { .. } => { + self.put_possibly_const_expression( + expr_handle, + &context.function.expressions, + context.module, + |writer, expr| writer.put_expression(expr, context, true), + )?; + } crate::Expression::Access { base, .. } | crate::Expression::AccessIndex { base, .. } => { // This is an acceptable place to generate a `ReadZeroSkipWrite` check. @@ -1318,51 +1357,6 @@ impl Writer { self.put_access_chain(expr_handle, policy, context)?; } } - crate::Expression::Constant(handle) => { - let coco = ConstantContext { - handle, - arena: &context.module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, "{coco}")?; - } - crate::Expression::ZeroValue(ty) => { - let ty_name = TypeContext { - handle: ty, - gctx: context.module.to_ctx(), - names: &self.names, - access: crate::StorageAccess::empty(), - binding: None, - first_time: false, - }; - write!(self.out, "{ty_name} {{}}")?; - } - crate::Expression::Literal(literal) => match literal { - crate::Literal::F64(_) => { - return Err(Error::CapabilityNotSupported(valid::Capabilities::FLOAT64)) - } - crate::Literal::F32(value) => { - if value.is_infinite() { - let sign = if value.is_sign_negative() { "-" } else { "" }; - write!(self.out, "{sign}INFINITY")?; - } else if value.is_nan() { - write!(self.out, "NAN")?; - } else { - let suffix = if value.fract() == 0.0 { ".0" } else { "" }; - write!(self.out, "{value}{suffix}")?; - } - } - crate::Literal::U32(value) => { - write!(self.out, "{value}u")?; - } - crate::Literal::I32(value) => { - write!(self.out, "{value}")?; - } - crate::Literal::Bool(value) => { - write!(self.out, "{value}")?; - } - }, crate::Expression::Splat { size, value } => { let scalar_kind = match *context.resolve_type(value) { crate::TypeInner::Scalar { kind, .. } => kind, @@ -1384,9 +1378,6 @@ impl Writer { write!(self.out, "{}", back::COMPONENTS[sc as usize])?; } } - crate::Expression::Compose { ty, ref components } => { - self.put_compose(ty, components, context)?; - } crate::Expression::FunctionArgument(index) => { let name_key = match context.origin { FunctionOrigin::Handle(handle) => NameKey::FunctionArgument(handle, index), @@ -1448,15 +1439,11 @@ impl Writer { self.put_image_sample_level(image, level, context)?; - if let Some(constant) = offset { - let coco = ConstantContext { - handle: constant, - arena: &context.module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, ", {coco}")?; + if let Some(offset) = offset { + write!(self.out, ", ")?; + self.put_const_expression(offset, context.module)?; } + match gather { None | Some(crate::SwizzleComponent::X) => {} Some(component) => { @@ -2270,15 +2257,11 @@ impl Writer { policy: index::BoundsCheckPolicy, context: &ExpressionContext, ) -> BackendResult { - let is_atomic = match *context.resolve_type(pointer) { - crate::TypeInner::Pointer { base, .. } => match context.module.types[base].inner { - crate::TypeInner::Atomic { .. } => true, - _ => false, - }, - _ => false, - }; + let is_atomic_pointer = context + .resolve_type(pointer) + .is_atomic_pointer(&context.module.types); - if is_atomic { + if is_atomic_pointer { write!( self.out, "{NAMESPACE}::atomic_load_explicit({ATOMIC_REFERENCE}" @@ -2420,9 +2403,8 @@ impl Writer { // check what kind of product this is depending // on the resolve type of the Dot function itself - if let crate::TypeInner::Scalar { kind, .. } = - *context.resolve_type(expr_handle) - { + let inner = context.resolve_type(expr_handle); + if let crate::TypeInner::Scalar { kind, .. } = *inner { match kind { crate::ScalarKind::Sint | crate::ScalarKind::Uint => { self.need_bake_expressions.insert(arg); @@ -2991,18 +2973,12 @@ impl Writer { level: back::Level, context: &StatementContext, ) -> BackendResult { - let pointer_inner = context.expression.resolve_type(pointer); - let is_atomic = match *pointer_inner { - crate::TypeInner::Pointer { base, .. } => { - match context.expression.module.types[base].inner { - crate::TypeInner::Atomic { .. } => true, - _ => false, - } - } - _ => false, - }; + let is_atomic_pointer = context + .expression + .resolve_type(pointer) + .is_atomic_pointer(&context.expression.module.types); - if is_atomic { + if is_atomic_pointer { write!( self.out, "{level}{NAMESPACE}::atomic_store_explicit({ATOMIC_REFERENCE}" @@ -3107,9 +3083,8 @@ impl Writer { } }; - self.write_scalar_constants(module)?; self.write_type_defs(module)?; - self.write_composite_constants(module)?; + self.write_global_constants(module)?; self.write_functions(module, info, options, pipeline_options) } @@ -3264,78 +3239,25 @@ impl Writer { Ok(()) } - fn write_scalar_constants(&mut self, module: &crate::Module) -> BackendResult { - for (handle, constant) in module.constants.iter() { - match constant.inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } if constant.name.is_some() => { - debug_assert!(constant.needs_alias()); - write!(self.out, "constexpr constant ")?; - match *value { - crate::ScalarValue::Sint(_) => { - write!(self.out, "int")?; - } - crate::ScalarValue::Uint(_) => { - write!(self.out, "unsigned")?; - } - crate::ScalarValue::Float(_) => { - write!(self.out, "float")?; - } - crate::ScalarValue::Bool(_) => { - write!(self.out, "bool")?; - } - } - let name = &self.names[&NameKey::Constant(handle)]; - let coco = ConstantContext { - handle, - arena: &module.constants, - names: &self.names, - first_time: true, - }; - writeln!(self.out, " {name} = {coco};")?; - } - _ => {} - } + /// Writes all named constants + fn write_global_constants(&mut self, module: &crate::Module) -> BackendResult { + let constants = module.constants.iter().filter(|&(_, c)| c.name.is_some()); + + for (handle, constant) in constants { + let ty_name = TypeContext { + handle: constant.ty, + gctx: module.to_ctx(), + names: &self.names, + access: crate::StorageAccess::empty(), + binding: None, + first_time: false, + }; + let name = &self.names[&NameKey::Constant(handle)]; + write!(self.out, "constant {ty_name} {name} = ")?; + self.put_const_expression(constant.init, module)?; + writeln!(self.out, ";")?; } - Ok(()) - } - fn write_composite_constants(&mut self, module: &crate::Module) -> BackendResult { - for (handle, constant) in module.constants.iter() { - match constant.inner { - crate::ConstantInner::Scalar { .. } => {} - crate::ConstantInner::Composite { ty, ref components } => { - debug_assert!(constant.needs_alias()); - let name = &self.names[&NameKey::Constant(handle)]; - let ty_name = TypeContext { - handle: ty, - gctx: module.to_ctx(), - names: &self.names, - access: crate::StorageAccess::empty(), - binding: None, - first_time: false, - }; - write!(self.out, "constant {ty_name} {name} = {{",)?; - for (i, &sub_handle) in components.iter().enumerate() { - // insert padding initialization, if needed - if self.struct_member_pads.contains(&(ty, i as u32)) { - write!(self.out, ", {{}}")?; - } - let separator = if i != 0 { ", " } else { "" }; - let coco = ConstantContext { - handle: sub_handle, - arena: &module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, "{separator}{coco}")?; - } - writeln!(self.out, "}};")?; - } - } - } Ok(()) } @@ -3528,13 +3450,8 @@ impl Writer { write!(self.out, "{}{} {}", back::INDENT, ty_name, local_name)?; match local.init { Some(value) => { - let coco = ConstantContext { - handle: value, - arena: &module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, " = {coco}")?; + write!(self.out, " = ")?; + self.put_const_expression(value, module)?; } None => { write!(self.out, " = {{}}")?; @@ -3935,13 +3852,8 @@ impl Writer { resolved.try_fmt(&mut self.out)?; } if let Some(value) = var.init { - let coco = ConstantContext { - handle: value, - arena: &module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, " = {coco}")?; + write!(self.out, " = ")?; + self.put_const_expression(value, module)?; } writeln!(self.out)?; } @@ -3996,13 +3908,9 @@ impl Writer { tyvar.try_fmt(&mut self.out)?; match var.init { Some(value) => { - let coco = ConstantContext { - handle: value, - arena: &module.constants, - names: &self.names, - first_time: false, - }; - writeln!(self.out, " = {coco};")?; + write!(self.out, " = ")?; + self.put_const_expression(value, module)?; + writeln!(self.out, ";")?; } None => { writeln!(self.out, " = {{}};")?; @@ -4100,13 +4008,8 @@ impl Writer { write!(self.out, "{}{} {}", back::INDENT, ty_name, name)?; match local.init { Some(value) => { - let coco = ConstantContext { - handle: value, - arena: &module.constants, - names: &self.names, - first_time: false, - }; - write!(self.out, " = {coco}")?; + write!(self.out, " = ")?; + self.put_const_expression(value, module)?; } None => { write!(self.out, " = {{}}")?; @@ -4373,21 +4276,11 @@ fn test_stack_size() { use crate::valid::{Capabilities, ValidationFlags}; // create a module with at least one expression nested let mut module = crate::Module::default(); - let constant = module.constants.append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Scalar { - value: crate::ScalarValue::Float(1.0), - width: 4, - }, - }, + let mut fun = crate::Function::default(); + let const_expr = fun.expressions.append( + crate::Expression::Literal(crate::Literal::F32(1.0)), Default::default(), ); - let mut fun = crate::Function::default(); - let const_expr = fun - .expressions - .append(crate::Expression::Constant(constant), Default::default()); let nested_expr = fun.expressions.append( crate::Expression::Unary { op: crate::UnaryOperator::Negate, diff --git a/src/back/spv/block.rs b/src/back/spv/block.rs index 84910e6999..ec3531ede1 100644 --- a/src/back/spv/block.rs +++ b/src/back/spv/block.rs @@ -237,6 +237,29 @@ impl<'w> BlockContext<'w> { let result_type_id = self.get_expression_type_id(&self.fun_info[expr_handle].ty); let id = match self.ir_function.expressions[expr_handle] { + crate::Expression::Literal(literal) => self.writer.get_constant_scalar(literal), + crate::Expression::Constant(handle) => { + let init = self.ir_module.constants[handle].init; + self.writer.constant_ids[init.index()] + } + crate::Expression::ZeroValue(_) => self.writer.write_constant_null(result_type_id), + crate::Expression::Compose { + ty: _, + ref components, + } => { + self.temp_list.clear(); + for &component in components { + self.temp_list.push(self.cached[component]); + } + + let id = self.gen_id(); + block.body.push(Instruction::composite_construct( + result_type_id, + id, + &self.temp_list, + )); + id + } crate::Expression::Access { base, index: _ } if self.is_intermediate(base) => { // See `is_intermediate`; we'll handle this later in // `write_expression_pointer`. @@ -372,9 +395,6 @@ impl<'w> BlockContext<'w> { crate::Expression::GlobalVariable(handle) => { self.writer.global_variables[handle.index()].access_id } - crate::Expression::Constant(handle) => self.writer.constant_ids[handle.index()], - crate::Expression::ZeroValue(_) => self.writer.write_constant_null(result_type_id), - crate::Expression::Literal(literal) => self.writer.get_constant_scalar(literal), crate::Expression::Splat { size, value } => { let value_id = self.cached[value]; let components = [value_id; 4]; @@ -406,23 +426,6 @@ impl<'w> BlockContext<'w> { )); id } - crate::Expression::Compose { - ty: _, - ref components, - } => { - self.temp_list.clear(); - for &component in components { - self.temp_list.push(self.cached[component]); - } - - let id = self.gen_id(); - block.body.push(Instruction::composite_construct( - result_type_id, - id, - &self.temp_list, - )); - id - } crate::Expression::Unary { op, expr } => { let id = self.gen_id(); let expr_id = self.cached[expr]; diff --git a/src/back/spv/image.rs b/src/back/spv/image.rs index 81c9de3755..2c92fa9cee 100644 --- a/src/back/spv/image.rs +++ b/src/back/spv/image.rs @@ -823,7 +823,7 @@ impl<'w> BlockContext<'w> { gather: Option, coordinate: Handle, array_index: Option>, - offset: Option>, + offset: Option>, level: crate::SampleLevel, depth_ref: Option>, block: &mut Block, diff --git a/src/back/spv/index.rs b/src/back/spv/index.rs index d2cbdf4d6d..19cc4a896f 100644 --- a/src/back/spv/index.rs +++ b/src/back/spv/index.rs @@ -176,17 +176,19 @@ impl<'w> BlockContext<'w> { // done the bounds check. let max_index_id = match self.write_sequence_max_index(sequence, block)? { MaybeKnown::Known(known_max_index) => { - if let crate::Expression::Constant(index_k) = self.ir_function.expressions[index] { - if let Some(known_index) = self.ir_module.constants[index_k].to_array_length() { - // Both the index and length are known at compile time. - // - // In strict WGSL compliance mode, out-of-bounds indices cannot be - // reported at shader translation time, and must be replaced with - // in-bounds indices at run time. So we cannot assume that - // validation ensured the index was in bounds. Restrict now. - let restricted = std::cmp::min(known_index, known_max_index); - return Ok(BoundsCheckResult::KnownInBounds(restricted)); - } + if let Ok(known_index) = self + .ir_module + .to_ctx() + .eval_expr_to_u32_from(index, &self.ir_function.expressions) + { + // Both the index and length are known at compile time. + // + // In strict WGSL compliance mode, out-of-bounds indices cannot be + // reported at shader translation time, and must be replaced with + // in-bounds indices at run time. So we cannot assume that + // validation ensured the index was in bounds. Restrict now. + let restricted = std::cmp::min(known_index, known_max_index); + return Ok(BoundsCheckResult::KnownInBounds(restricted)); } self.get_index_constant(known_max_index) @@ -236,31 +238,33 @@ impl<'w> BlockContext<'w> { // bounds check. let length_id = match self.write_sequence_length(sequence, block)? { MaybeKnown::Known(known_length) => { - if let crate::Expression::Constant(index_k) = self.ir_function.expressions[index] { - if let Some(known_index) = self.ir_module.constants[index_k].to_array_length() { - // Both the index and length are known at compile time. - // - // It would be nice to assume that, since we are using the - // `ReadZeroSkipWrite` policy, we are not in strict WGSL - // compliance mode, and thus we can count on the validator to have - // rejected any programs with known out-of-bounds indices, and - // thus just return `KnownInBounds` here without actually - // checking. - // - // But it's also reasonable to expect that bounds check policies - // and error reporting policies should be able to vary - // independently without introducing security holes. So, we should - // support the case where bad indices do not cause validation - // errors, and are handled via `ReadZeroSkipWrite`. - // - // In theory, when `known_index` is bad, we could return a new - // `KnownOutOfBounds` variant here. But it's simpler just to fall - // through and let the bounds check take place. The shader is - // broken anyway, so it doesn't make sense to invest in emitting - // the ideal code for it. - if known_index < known_length { - return Ok(BoundsCheckResult::KnownInBounds(known_index)); - } + if let Ok(known_index) = self + .ir_module + .to_ctx() + .eval_expr_to_u32_from(index, &self.ir_function.expressions) + { + // Both the index and length are known at compile time. + // + // It would be nice to assume that, since we are using the + // `ReadZeroSkipWrite` policy, we are not in strict WGSL + // compliance mode, and thus we can count on the validator to have + // rejected any programs with known out-of-bounds indices, and + // thus just return `KnownInBounds` here without actually + // checking. + // + // But it's also reasonable to expect that bounds check policies + // and error reporting policies should be able to vary + // independently without introducing security holes. So, we should + // support the case where bad indices do not cause validation + // errors, and are handled via `ReadZeroSkipWrite`. + // + // In theory, when `known_index` is bad, we could return a new + // `KnownOutOfBounds` variant here. But it's simpler just to fall + // through and let the bounds check take place. The shader is + // broken anyway, so it doesn't make sense to invest in emitting + // the ideal code for it. + if known_index < known_length { + return Ok(BoundsCheckResult::KnownInBounds(known_index)); } } diff --git a/src/back/spv/mod.rs b/src/back/spv/mod.rs index 8554c6226c..2d395effa0 100644 --- a/src/back/spv/mod.rs +++ b/src/back/spv/mod.rs @@ -616,6 +616,7 @@ pub struct Writer { lookup_type: crate::FastHashMap, lookup_function: crate::FastHashMap, Word>, lookup_function_type: crate::FastHashMap, + /// Indexed by const-expression handle indexes constant_ids: Vec, cached_constants: crate::FastHashMap, global_variables: Vec, diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index 554db6d8a2..e402400b3a 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -1213,6 +1213,36 @@ impl Writer { null_id } + fn write_constant_expr( + &mut self, + handle: Handle, + ir_module: &crate::Module, + ) -> Result { + let id = match ir_module.const_expressions[handle] { + crate::Expression::Literal(literal) => self.get_constant_scalar(literal), + crate::Expression::Constant(constant) => { + let constant = &ir_module.constants[constant]; + self.constant_ids[constant.init.index()] + } + crate::Expression::ZeroValue(ty) => { + let type_id = self.get_type_id(LookupType::Handle(ty)); + self.write_constant_null(type_id) + } + crate::Expression::Compose { ty, ref components } => { + let component_ids: Vec<_> = components + .iter() + .map(|component| self.constant_ids[component.index()]) + .collect(); + self.get_constant_composite(LookupType::Handle(ty), component_ids.as_slice()) + } + _ => unreachable!(), + }; + + self.constant_ids[handle.index()] = id; + + Ok(id) + } + pub(super) fn write_barrier(&mut self, flags: crate::Barrier, block: &mut Block) { let memory_scope = if flags.contains(crate::Barrier::STORAGE) { spirv::Scope::Device @@ -1796,59 +1826,30 @@ impl Writer { } } - self.constant_ids.resize(ir_module.constants.len(), 0); - // first, output all the scalar constants - for (handle, constant) in ir_module.constants.iter() { - match constant.inner { - crate::ConstantInner::Composite { .. } => continue, - crate::ConstantInner::Scalar { width, ref value } => { - let literal = crate::Literal::from_scalar(*value, width).ok_or( - Error::Validation("Unexpected kind and/or width for Literal"), - )?; - self.constant_ids[handle.index()] = match constant.name { - Some(ref name) => { - let id = self.id_gen.next(); - self.write_constant_scalar(id, &literal, Some(name)); - id - } - None => self.get_constant_scalar(literal), - }; - } - } - } - - // then all types, some of them may rely on constants and struct type set + // write all types for (handle, _) in ir_module.types.iter() { self.write_type_declaration_arena(&ir_module.types, handle)?; } - // then all the composite constants, they rely on types - for (handle, constant) in ir_module.constants.iter() { - match constant.inner { - crate::ConstantInner::Scalar { .. } => continue, - crate::ConstantInner::Composite { ty, ref components } => { - let ty = LookupType::Handle(ty); - - let mut constituent_ids = Vec::with_capacity(components.len()); - for constituent in components.iter() { - let constituent_id = self.constant_ids[constituent.index()]; - constituent_ids.push(constituent_id); - } + // write all const-expressions as constants + 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)?; + } + debug_assert!(self.constant_ids.iter().all(|&id| id != 0)); - self.constant_ids[handle.index()] = match constant.name { - Some(ref name) => { - let id = self.id_gen.next(); - self.write_constant_composite(id, ty, &constituent_ids, Some(name)); - id - } - None => self.get_constant_composite(ty, &constituent_ids), - }; + // write the name of constants on their respective const-expression initializer + if self.flags.contains(WriterFlags::DEBUG) { + for (_, constant) in ir_module.constants.iter() { + if let Some(ref name) = constant.name { + let id = self.constant_ids[constant.init.index()]; + self.debugs.push(Instruction::name(id, name)); } } } - debug_assert_eq!(self.constant_ids.iter().position(|&id| id == 0), None); - // now write all globals + // write all global variables for (handle, var) in ir_module.global_variables.iter() { // If a single entry point was specified, only write `OpVariable` instructions // for the globals it actually uses. Emit dummies for the others, @@ -1865,7 +1866,7 @@ impl Writer { self.global_variables.push(gvar); } - // all functions + // write all functions for (handle, ir_function) in ir_module.functions.iter() { let info = &mod_info[handle]; if let Some(index) = ep_index { @@ -1882,7 +1883,7 @@ impl Writer { self.lookup_function.insert(handle, id); } - // and entry points + // write all or one entry points for (index, ir_ep) in ir_module.entry_points.iter().enumerate() { if ep_index.is_some() && ep_index != Some(index) { continue; diff --git a/src/back/wgsl/writer.rs b/src/back/wgsl/writer.rs index 225df0b898..44dd2a97c0 100644 --- a/src/back/wgsl/writer.rs +++ b/src/back/wgsl/writer.rs @@ -118,10 +118,17 @@ impl Writer { } } - // Write all constants - for (handle, constant) in module.constants.iter() { - if constant.name.is_some() { - self.write_global_constant(module, &constant.inner, handle)?; + // Write all named constants + let mut constants = module + .constants + .iter() + .filter(|&(_, c)| c.name.is_some()) + .peekable(); + while let Some((handle, _)) = constants.next() { + self.write_global_constant(module, handle)?; + // Add extra newline for readability on last iteration + if constants.peek().is_none() { + writeln!(self.out)?; } } @@ -182,25 +189,6 @@ impl Writer { Ok(()) } - /// Helper method used to write [`ScalarValue`](crate::ScalarValue) - /// - /// # Notes - /// Adds no trailing or leading whitespace - fn write_scalar_value(&mut self, value: crate::ScalarValue) -> BackendResult { - use crate::ScalarValue as Sv; - - match value { - Sv::Sint(value) => write!(self.out, "{value}")?, - Sv::Uint(value) => write!(self.out, "{value}u")?, - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - Sv::Float(value) => write!(self.out, "{value:?}")?, - Sv::Bool(value) => write!(self.out, "{value}")?, - } - - Ok(()) - } - /// Helper method used to write struct name /// /// # Notes @@ -302,7 +290,7 @@ impl Writer { // Write the constant // `write_constant` adds no trailing or leading space/newline - self.write_constant(module, init)?; + self.write_const_expression(module, init)?; } // Finish the local with `;` and add a newline (only for readability) @@ -708,14 +696,11 @@ impl Writer { Statement::Store { pointer, value } => { write!(self.out, "{level}")?; - let is_atomic = match *func_ctx.info[pointer].ty.inner_with(&module.types) { - crate::TypeInner::Pointer { base, .. } => match module.types[base].inner { - crate::TypeInner::Atomic { .. } => true, - _ => false, - }, - _ => false, - }; - if is_atomic { + let is_atomic_pointer = func_ctx + .resolve_type(pointer, &module.types) + .is_atomic_pointer(&module.types); + + if is_atomic_pointer { write!(self.out, "atomicStore(")?; self.write_expr(module, pointer, func_ctx)?; write!(self.out, ", ")?; @@ -747,12 +732,10 @@ impl Writer { let func_name = &self.names[&NameKey::Function(function)]; write!(self.out, "{func_name}(")?; for (index, &argument) in arguments.iter().enumerate() { - self.write_expr(module, argument, func_ctx)?; - // Only write a comma if isn't the last element - if index != arguments.len().saturating_sub(1) { - // The leading space is for readability only + if index != 0 { write!(self.out, ", ")?; } + self.write_expr(module, argument, func_ctx)?; } writeln!(self.out, ");")? } @@ -987,7 +970,7 @@ impl Writer { } } Ex::Access { base, .. } | Ex::AccessIndex { base, .. } => { - let base_ty = func_ctx.info[base].ty.inner_with(&module.types); + let base_ty = func_ctx.resolve_type(base, &module.types); match *base_ty { crate::TypeInner::Pointer { .. } | crate::TypeInner::ValuePointer { .. } => { Indirection::Reference @@ -1077,6 +1060,74 @@ impl Writer { Ok(()) } + fn write_const_expression( + &mut self, + module: &Module, + expr: Handle, + ) -> BackendResult { + self.write_possibly_const_expression( + module, + expr, + &module.const_expressions, + |writer, expr| writer.write_const_expression(module, expr), + ) + } + + fn write_possibly_const_expression( + &mut self, + module: &Module, + expr: Handle, + expressions: &crate::Arena, + write_expression: E, + ) -> BackendResult + where + E: Fn(&mut Self, Handle) -> BackendResult, + { + use crate::Expression; + + match expressions[expr] { + Expression::Literal(literal) => { + match literal { + // Floats are written using `Debug` instead of `Display` because it always appends the + // decimal part even it's zero + crate::Literal::F64(_) => { + return Err(Error::Custom("unsupported f64 literal".to_string())); + } + crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, + crate::Literal::U32(value) => write!(self.out, "{}u", value)?, + crate::Literal::I32(value) => write!(self.out, "{}", value)?, + crate::Literal::Bool(value) => write!(self.out, "{}", value)?, + } + } + Expression::Constant(handle) => { + let constant = &module.constants[handle]; + if constant.name.is_some() { + write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; + } else { + self.write_const_expression(module, constant.init)?; + } + } + Expression::ZeroValue(ty) => { + self.write_type(module, ty)?; + write!(self.out, "()")?; + } + Expression::Compose { ty, ref components } => { + self.write_type(module, ty)?; + write!(self.out, "(")?; + for (index, component) in components.iter().enumerate() { + if index != 0 { + write!(self.out, ", ")?; + } + write_expression(self, *component)?; + } + write!(self.out, ")")? + } + _ => unreachable!(), + } + + Ok(()) + } + /// Write the 'plain form' of `expr`. /// /// An expression's 'plain form' is the most general rendition of that @@ -1109,36 +1160,16 @@ impl Writer { // `postfix_expression` forms for member/component access and // subscripting. match *expression { - Expression::Literal(literal) => { - match literal { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - crate::Literal::F64(_) => { - return Err(Error::Custom("unsupported f64 literal".to_string())); - } - crate::Literal::F32(value) => write!(self.out, "{:?}", value)?, - crate::Literal::U32(value) => write!(self.out, "{}u", value)?, - crate::Literal::I32(value) => write!(self.out, "{}", value)?, - crate::Literal::Bool(value) => write!(self.out, "{}", value)?, - } - } - Expression::Constant(constant) => self.write_constant(module, constant)?, - Expression::ZeroValue(ty) => { - self.write_type(module, ty)?; - write!(self.out, "()")?; - } - Expression::Compose { ty, ref components } => { - self.write_type(module, ty)?; - write!(self.out, "(")?; - for (index, component) in components.iter().enumerate() { - self.write_expr(module, *component, func_ctx)?; - // Only write a comma if isn't the last element - if index != components.len().saturating_sub(1) { - // The leading space is for readability only - write!(self.out, ", ")?; - } - } - write!(self.out, ")")? + Expression::Literal(_) + | Expression::Constant(_) + | Expression::ZeroValue(_) + | Expression::Compose { .. } => { + self.write_possibly_const_expression( + module, + expr, + func_ctx.expressions, + |writer, expr| writer.write_expr(module, expr, func_ctx), + )?; } Expression::FunctionArgument(pos) => { let name_key = func_ctx.argument_key(pos); @@ -1261,11 +1292,12 @@ impl Writer { if let Some(offset) = offset { write!(self.out, ", ")?; - self.write_constant(module, offset)?; + self.write_const_expression(module, offset)?; } write!(self.out, ")")?; } + Expression::ImageSample { image, sampler, @@ -1282,7 +1314,7 @@ impl Writer { }; write!(self.out, "textureGather{suffix_cmp}(")?; - match *func_ctx.info[image].ty.inner_with(&module.types) { + match *func_ctx.resolve_type(image, &module.types) { TypeInner::Image { class: crate::ImageClass::Depth { multi: _ }, .. @@ -1309,7 +1341,7 @@ impl Writer { if let Some(offset) = offset { write!(self.out, ", ")?; - self.write_constant(module, offset)?; + self.write_const_expression(module, offset)?; } write!(self.out, ")")?; @@ -1332,6 +1364,7 @@ impl Writer { }; write!(self.out, ")")?; } + Expression::ImageLoad { image, coordinate, @@ -1357,12 +1390,13 @@ impl Writer { let name = &self.names[&NameKey::GlobalVariable(handle)]; write!(self.out, "{name}")?; } + Expression::As { expr, kind, convert, } => { - let inner = func_ctx.info[expr].ty.inner_with(&module.types); + let inner = func_ctx.resolve_type(expr, &module.types); match *inner { TypeInner::Matrix { columns, @@ -1407,7 +1441,7 @@ impl Writer { write!(self.out, ")")?; } Expression::Splat { size, value } => { - let inner = func_ctx.info[value].ty.inner_with(&module.types); + let inner = func_ctx.resolve_type(value, &module.types); let (scalar_kind, scalar_width) = match *inner { crate::TypeInner::Scalar { kind, width } => (kind, width), _ => { @@ -1424,15 +1458,11 @@ impl Writer { write!(self.out, ")")?; } Expression::Load { pointer } => { - let is_atomic = match *func_ctx.info[pointer].ty.inner_with(&module.types) { - crate::TypeInner::Pointer { base, .. } => match module.types[base].inner { - crate::TypeInner::Atomic { .. } => true, - _ => false, - }, - _ => false, - }; + let is_atomic_pointer = func_ctx + .resolve_type(pointer, &module.types) + .is_atomic_pointer(&module.types); - if is_atomic { + if is_atomic_pointer { write!(self.out, "atomicLoad(")?; self.write_expr(module, pointer, func_ctx)?; write!(self.out, ")")?; @@ -1453,6 +1483,7 @@ impl Writer { self.write_expr(module, expr, func_ctx)?; write!(self.out, ")")?; } + Expression::Math { fun, arg, @@ -1561,6 +1592,7 @@ impl Writer { } } } + Expression::Swizzle { size, vector, @@ -1576,7 +1608,7 @@ impl Writer { let unary = match op { crate::UnaryOperator::Negate => "-", crate::UnaryOperator::Not => { - match *func_ctx.info[expr].ty.inner_with(&module.types) { + match *func_ctx.resolve_type(expr, &module.types) { TypeInner::Scalar { kind: crate::ScalarKind::Bool, .. @@ -1592,6 +1624,7 @@ impl Writer { write!(self.out, ")")? } + Expression::Select { condition, accept, @@ -1688,7 +1721,7 @@ impl Writer { // Write initializer if let Some(init) = global.init { write!(self.out, " = ")?; - self.write_constant(module, init)?; + self.write_const_expression(module, init)?; } // End with semicolon @@ -1697,47 +1730,6 @@ impl Writer { Ok(()) } - /// Helper method used to write constants - /// - /// # Notes - /// Doesn't add any newlines or leading/trailing spaces - fn write_constant( - &mut self, - module: &Module, - handle: Handle, - ) -> BackendResult { - let constant = &module.constants[handle]; - match constant.inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } => { - if constant.name.is_some() { - write!(self.out, "{}", self.names[&NameKey::Constant(handle)])?; - } else { - self.write_scalar_value(*value)?; - } - } - crate::ConstantInner::Composite { ty, ref components } => { - self.write_type(module, ty)?; - write!(self.out, "(")?; - - // Write the comma separated constants - for (index, constant) in components.iter().enumerate() { - self.write_constant(module, *constant)?; - // Only write a comma if isn't the last element - if index != components.len().saturating_sub(1) { - // The leading space is for readability only - write!(self.out, ", ")?; - } - } - write!(self.out, ")")? - } - } - - Ok(()) - } - /// Helper method used to write global constants /// /// # Notes @@ -1745,61 +1737,17 @@ impl Writer { fn write_global_constant( &mut self, module: &Module, - inner: &crate::ConstantInner, handle: Handle, ) -> BackendResult { - match *inner { - crate::ConstantInner::Scalar { - width: _, - ref value, - } => { - let name = &self.names[&NameKey::Constant(handle)]; - // First write only constant name - write!(self.out, "const {name}: ")?; - // Next write constant type and value - match *value { - crate::ScalarValue::Sint(value) => { - write!(self.out, "i32 = {value}")?; - } - crate::ScalarValue::Uint(value) => { - write!(self.out, "u32 = {value}u")?; - } - crate::ScalarValue::Float(value) => { - // Floats are written using `Debug` instead of `Display` because it always appends the - // decimal part even it's zero - write!(self.out, "f32 = {value:?}")?; - } - crate::ScalarValue::Bool(value) => { - write!(self.out, "bool = {value}")?; - } - }; - // End with semicolon - writeln!(self.out, ";")?; - } - crate::ConstantInner::Composite { ty, ref components } => { - let name = &self.names[&NameKey::Constant(handle)]; - // First write only constant name - write!(self.out, "const {name}: ")?; - // Next write constant type - self.write_type(module, ty)?; - - write!(self.out, " = ")?; - self.write_type(module, ty)?; + let name = &self.names[&NameKey::Constant(handle)]; + // First write only constant name + write!(self.out, "const {name}: ")?; + self.write_type(module, module.constants[handle].ty)?; + write!(self.out, " = ")?; + let init = module.constants[handle].init; + self.write_const_expression(module, init)?; + writeln!(self.out, ";")?; - write!(self.out, "(")?; - for (index, constant) in components.iter().enumerate() { - self.write_constant(module, *constant)?; - // Only write a comma if isn't the last element - if index != components.len().saturating_sub(1) { - // The leading space is for readability only - write!(self.out, ", ")?; - } - } - write!(self.out, ");")?; - } - } - // End with extra newline for readability - writeln!(self.out)?; Ok(()) } diff --git a/src/front/glsl/builtins.rs b/src/front/glsl/builtins.rs index 14e223d6a4..5a5acf4321 100644 --- a/src/front/glsl/builtins.rs +++ b/src/front/glsl/builtins.rs @@ -7,10 +7,9 @@ use super::{ Error, ErrorKind, Frontend, Result, }; use crate::{ - BinaryOperator, Block, Constant, DerivativeAxis as Axis, DerivativeControl as Ctrl, Expression, - Handle, ImageClass, ImageDimension as Dim, ImageQuery, MathFunction, Module, - RelationalFunction, SampleLevel, ScalarKind as Sk, Span, Type, TypeInner, UnaryOperator, - VectorSize, + BinaryOperator, Block, DerivativeAxis as Axis, DerivativeControl as Ctrl, Expression, Handle, + ImageClass, ImageDimension as Dim, ImageQuery, MathFunction, Module, RelationalFunction, + SampleLevel, ScalarKind as Sk, Span, Type, TypeInner, UnaryOperator, VectorSize, }; impl crate::ScalarKind { @@ -2183,7 +2182,7 @@ fn texture_call( image: Handle, level: SampleLevel, comps: CoordComponents, - offset: Option>, + offset: Option>, body: &mut Block, meta: Span, ) -> Result> { diff --git a/src/front/glsl/constants.rs b/src/front/glsl/constants.rs index 35569926ce..81ec6f3a8c 100644 --- a/src/front/glsl/constants.rs +++ b/src/front/glsl/constants.rs @@ -1,6 +1,6 @@ use crate::{ arena::{Arena, Handle, UniqueArena}, - BinaryOperator, Constant, ConstantInner, Expression, ScalarKind, ScalarValue, Type, TypeInner, + ArraySize, BinaryOperator, Constant, Expression, Literal, ScalarKind, Type, TypeInner, UnaryOperator, }; @@ -9,6 +9,7 @@ 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)] @@ -59,34 +60,84 @@ pub enum ConstantSolvingError { 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> { - let span = self.expressions.get_span(expr); - match self.expressions[expr] { - Expression::Constant(constant) => Ok(constant), - Expression::ZeroValue(ty) => self.register_zero_constant(ty, span), - Expression::Literal(literal) => Ok(self.register_literal(literal, span)), - Expression::AccessIndex { base, index } => self.access(base, index as usize), + ) -> 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 index = self.solve(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)?) + self.access(base, self.constant_index(index)?, span) } Expression::Splat { size, value: splat_value, } => { - let value_constant = self.solve(splat_value)?; - let ty = match self.constants[value_constant].inner { - ConstantInner::Scalar { ref value, width } => { - let kind = value.scalar_kind(); + 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, @@ -95,76 +146,83 @@ impl<'a> ConstantSolver<'a> { span, ) } - ConstantInner::Composite { .. } => { + 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 inner = ConstantInner::Composite { + let expr = Expression::Compose { ty, components: vec![value_constant; size as usize], }; - Ok(self.register_constant(inner, span)) + Ok(self.register_constant(expr, span)) } Expression::Swizzle { size, vector: src_vector, pattern, } => { - let src_constant = self.solve(src_vector)?; - let (ty, src_components) = match self.constants[src_constant].inner { - ConstantInner::Scalar { .. } => { - return Err(ConstantSolvingError::SwizzleVectorOnly); + 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)) } - ConstantInner::Composite { + Expression::Compose { ty, components: ref src_components, - } => match self.types[ty].inner { - crate::TypeInner::Vector { - size: _, - kind, - width, - } => { - let dst_ty = self.types.insert( - Type { - name: None, - inner: crate::TypeInner::Vector { size, kind, width }, - }, - span, - ); - (dst_ty, &src_components[..]) - } - _ => { - return Err(ConstantSolvingError::SwizzleVectorOnly); - } - }, - }; - - let components = pattern - .iter() - .map(|&sc| src_components[sc as usize]) - .collect(); - let inner = ConstantInner::Composite { ty, components }; - - Ok(self.register_constant(inner, span)) - } - Expression::Compose { ty, ref components } => { - let components = components - .iter() - .map(|c| self.solve(*c)) - .collect::>()?; - let inner = ConstantInner::Composite { ty, components }; - - Ok(self.register_constant(inner, span)) + } => { + 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(expr)?; + 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(left)?; - let right_constant = self.solve(right)?; + 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) } @@ -173,76 +231,61 @@ impl<'a> ConstantSolver<'a> { arg, arg1, arg2, - .. + arg3, } => { - let arg = self.solve(arg)?; - let arg1 = arg1.map(|arg| self.solve(arg)).transpose()?; - let arg2 = arg2.map(|arg| self.solve(arg)).transpose()?; - - let const0 = &self.constants[arg].inner; - let const1 = arg1.map(|arg| &self.constants[arg].inner); - let const2 = arg2.map(|arg| &self.constants[arg].inner); + 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 (value, width) = match (const0, const1.unwrap()) { - ( - &ConstantInner::Scalar { - width, - value: value0, - }, - &ConstantInner::Scalar { value: value1, .. }, - ) => ( + let literal = match (const0, const1.unwrap()) { + (&Expression::Literal(value0), &Expression::Literal(value1)) => { match (value0, value1) { - (ScalarValue::Sint(a), ScalarValue::Sint(b)) => { - ScalarValue::Sint(a.pow(b as u32)) - } - (ScalarValue::Uint(a), ScalarValue::Uint(b)) => { - ScalarValue::Uint(a.pow(b as u32)) - } - (ScalarValue::Float(a), ScalarValue::Float(b)) => { - ScalarValue::Float(a.powf(b)) + (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), - }, - width, - ), + } + } _ => return Err(ConstantSolvingError::InvalidMathArg), }; - let inner = ConstantInner::Scalar { width, value }; - Ok(self.register_constant(inner, span)) + let expr = Expression::Literal(literal); + Ok(self.register_constant(expr, span)) } crate::MathFunction::Clamp => { - let (value, width) = match (const0, const1.unwrap(), const2.unwrap()) { + let literal = match (const0, const1.unwrap(), const2.unwrap()) { ( - &ConstantInner::Scalar { - width, - value: value0, - }, - &ConstantInner::Scalar { value: value1, .. }, - &ConstantInner::Scalar { value: value2, .. }, - ) => ( - match (value0, value1, value2) { - ( - ScalarValue::Sint(a), - ScalarValue::Sint(b), - ScalarValue::Sint(c), - ) => ScalarValue::Sint(a.clamp(b, c)), - ( - ScalarValue::Uint(a), - ScalarValue::Uint(b), - ScalarValue::Uint(c), - ) => ScalarValue::Uint(a.clamp(b, c)), - ( - ScalarValue::Float(a), - ScalarValue::Float(b), - ScalarValue::Float(c), - ) => ScalarValue::Float(glsl_float_clamp(a, b, c)), - _ => return Err(ConstantSolvingError::InvalidMathArg), - }, - width, - ), + &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" @@ -250,8 +293,8 @@ impl<'a> ConstantSolver<'a> { } }; - let inner = ConstantInner::Scalar { width, value }; - Ok(self.register_constant(inner, span)) + let expr = Expression::Literal(literal); + Ok(self.register_constant(expr, span)) } _ => Err(ConstantSolvingError::NotImplemented(format!("{fun:?}"))), } @@ -261,7 +304,7 @@ impl<'a> ConstantSolver<'a> { expr, kind, } => { - let expr_constant = self.solve(expr)?; + let expr_constant = self.solve_impl(expr, expr_type, false)?; match convert { Some(width) => self.cast(expr_constant, kind, width, span), @@ -269,27 +312,24 @@ impl<'a> ConstantSolver<'a> { } } Expression::ArrayLength(expr) => { - let array = self.solve(expr)?; - - match self.constants[array].inner { - ConstantInner::Scalar { .. } => { - Err(ConstantSolvingError::InvalidArrayLengthArg) + 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), + } } - ConstantInner::Composite { ty, .. } => match self.types[ty].inner { - TypeInner::Array { size, .. } => match size { - crate::ArraySize::Constant(size) => Ok(self.register_constant( - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Uint(size.get() as u64), - }, - span, - )), - crate::ArraySize::Dynamic => { - Err(ConstantSolvingError::ArrayLengthDynamic) - } - }, - _ => Err(ConstantSolvingError::InvalidArrayLengthArg), - }, + _ => Err(ConstantSolvingError::InvalidArrayLengthArg), } } @@ -316,350 +356,354 @@ impl<'a> ConstantSolver<'a> { &mut self, base: Handle, index: usize, - ) -> Result, ConstantSolvingError> { - let base = self.solve(base)?; - - match self.constants[base].inner { - ConstantInner::Scalar { .. } => Err(ConstantSolvingError::InvalidAccessBase), - ConstantInner::Composite { ty, ref components } => { - match self.types[ty].inner { - TypeInner::Vector { .. } - | TypeInner::Matrix { .. } - | TypeInner::Array { .. } - | TypeInner::Struct { .. } => (), - _ => return Err(ConstantSolvingError::InvalidAccessBase), + 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, constant: Handle) -> Result { - match self.constants[constant].inner { - ConstantInner::Scalar { - value: ScalarValue::Uint(index), - .. - } => Ok(index as usize), + 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, - constant: Handle, + expr: Handle, kind: ScalarKind, target_width: crate::Bytes, span: crate::Span, - ) -> Result, ConstantSolvingError> { - let mut inner = self.constants[constant].inner.clone(); - - match inner { - ConstantInner::Scalar { - ref mut value, - ref mut width, - } => { - *width = target_width; - *value = match kind { - ScalarKind::Sint => ScalarValue::Sint(match *value { - ScalarValue::Sint(v) => v, - ScalarValue::Uint(v) => v as i64, - ScalarValue::Float(v) => v as i64, - ScalarValue::Bool(v) => v as i64, + ) -> 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 => ScalarValue::Uint(match *value { - ScalarValue::Sint(v) => v as u64, - ScalarValue::Uint(v) => v, - ScalarValue::Float(v) => v as u64, - ScalarValue::Bool(v) => v as u64, + (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 => ScalarValue::Float(match *value { - ScalarValue::Sint(v) => v as f64, - ScalarValue::Uint(v) => v as f64, - ScalarValue::Float(v) => v, - ScalarValue::Bool(v) => v as u64 as f64, + (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 => ScalarValue::Bool(match *value { - ScalarValue::Sint(v) => v != 0, - ScalarValue::Uint(v) => v != 0, - ScalarValue::Float(v) => v != 0.0, - ScalarValue::Bool(v) => v, + (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) } - ConstantInner::Composite { + Expression::Compose { ty, - ref mut components, + components: ref src_components, } => { match self.types[ty].inner { TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), _ => return Err(ConstantSolvingError::InvalidCastArg), } - for component in components { + 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(inner, span)) + Ok(self.register_constant(expr, span)) } fn unary_op( &mut self, op: UnaryOperator, - constant: Handle, + expr: Handle, span: crate::Span, - ) -> Result, ConstantSolvingError> { - let mut inner = self.constants[constant].inner.clone(); - - match inner { - ConstantInner::Scalar { ref mut value, .. } => match op { - UnaryOperator::Negate => match *value { - ScalarValue::Sint(ref mut v) => *v = -*v, - ScalarValue::Float(ref mut v) => *v = -*v, + ) -> 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 { - ScalarValue::Sint(ref mut v) => *v = !*v, - ScalarValue::Uint(ref mut v) => *v = !*v, - ScalarValue::Bool(ref mut v) => *v = !*v, - ScalarValue::Float(_) => 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), }, - }, - ConstantInner::Composite { + }), + Expression::Compose { ty, - ref mut components, + components: ref src_components, } => { match self.types[ty].inner { TypeInner::Vector { .. } | TypeInner::Matrix { .. } => (), - _ => return Err(ConstantSolvingError::InvalidCastArg), + _ => return Err(ConstantSolvingError::InvalidUnaryOpArg), } - for component in components { - *component = self.unary_op(op, *component, span)? + 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(inner, span)) + Ok(self.register_constant(expr, span)) } fn binary_op( &mut self, op: BinaryOperator, - left: Handle, - right: Handle, + left: Handle, + right: Handle, span: crate::Span, - ) -> Result, ConstantSolvingError> { - let left_inner = &self.constants[left].inner; - let right_inner = &self.constants[right].inner; - - let inner = match (left_inner, right_inner) { - ( - &ConstantInner::Scalar { - value: left_value, - width, - }, - &ConstantInner::Scalar { - value: right_value, - width: _, - }, - ) => { - let value = match op { - BinaryOperator::Equal => ScalarValue::Bool(left_value == right_value), - BinaryOperator::NotEqual => ScalarValue::Bool(left_value != right_value), - BinaryOperator::Less => ScalarValue::Bool(left_value < right_value), - BinaryOperator::LessEqual => ScalarValue::Bool(left_value <= right_value), - BinaryOperator::Greater => ScalarValue::Bool(left_value > right_value), - BinaryOperator::GreaterEqual => ScalarValue::Bool(left_value >= right_value), + ) -> 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) { - (ScalarValue::Sint(a), ScalarValue::Sint(b)) => { - ScalarValue::Sint(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), - }) - } - (ScalarValue::Sint(a), ScalarValue::Uint(b)) => { - ScalarValue::Sint(match op { - BinaryOperator::ShiftLeft => a.wrapping_shl(b as u32), - BinaryOperator::ShiftRight => a.wrapping_shr(b as u32), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), - }) - } - (ScalarValue::Uint(a), ScalarValue::Uint(b)) => { - ScalarValue::Uint(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 as u32), - BinaryOperator::ShiftRight => a.wrapping_shr(b as u32), - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), - }) - } - (ScalarValue::Float(a), ScalarValue::Float(b)) => { - ScalarValue::Float(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), - }) - } - (ScalarValue::Bool(a), ScalarValue::Bool(b)) => { - ScalarValue::Bool(match op { - BinaryOperator::LogicalAnd => a && b, - BinaryOperator::LogicalOr => a || b, - _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), - }) - } + (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), }, }; - - ConstantInner::Scalar { value, width } + Expression::Literal(literal) } - (&ConstantInner::Composite { ref components, ty }, &ConstantInner::Scalar { .. }) => { - let mut components = components.clone(); - for comp in components.iter_mut() { - *comp = self.binary_op(op, *comp, right, span)?; + ( + &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)?; } - ConstantInner::Composite { ty, components } + Expression::Compose { ty, components } } - (&ConstantInner::Scalar { .. }, &ConstantInner::Composite { ref components, ty }) => { - let mut components = components.clone(); - for comp in components.iter_mut() { - *comp = self.binary_op(op, left, *comp, span)?; + ( + &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)?; } - ConstantInner::Composite { ty, components } + Expression::Compose { ty, components } } _ => return Err(ConstantSolvingError::InvalidBinaryOpArgs), }; - Ok(self.register_constant(inner, span)) + Ok(self.register_constant(expr, span)) } - fn register_zero_constant( - &mut self, - ty: Handle, - span: crate::Span, - ) -> Result, ConstantSolvingError> { - let inner = match self.types[ty].inner { - TypeInner::Scalar { kind, width } => { - let value = match kind { - ScalarKind::Sint => ScalarValue::Sint(0), - ScalarKind::Uint => ScalarValue::Uint(0), - ScalarKind::Float => ScalarValue::Float(1.0), - ScalarKind::Bool => ScalarValue::Bool(false), - }; - ConstantInner::Scalar { width, value } - } - TypeInner::Vector { size, kind, width } => { - let element_type = self.types.insert( - Type { - name: None, - inner: TypeInner::Scalar { kind, width }, - }, - span, - ); - let element = self.register_zero_constant(element_type, span)?; - let components = std::iter::repeat(element) - .take(size as u8 as usize) - .collect(); - ConstantInner::Composite { ty, components } - } - TypeInner::Matrix { - columns, - rows, - width, - } => { - let column_type = self.types.insert( - Type { - name: None, - inner: TypeInner::Vector { - size: rows, - kind: ScalarKind::Float, - width, - }, - }, - span, - ); - let column = self.register_zero_constant(column_type, span)?; - let components = std::iter::repeat(column) - .take(columns as u8 as usize) - .collect(); - ConstantInner::Composite { ty, components } - } - TypeInner::Array { base, size, .. } => { - let length = match size { - crate::ArraySize::Constant(size) => size.get(), - crate::ArraySize::Dynamic => { - return Err(ConstantSolvingError::ArrayLengthDynamic) - } - }; - let element = self.register_zero_constant(base, span)?; - let components = std::iter::repeat(element).take(length as usize).collect(); - ConstantInner::Composite { ty, components } - } - TypeInner::Struct { ref members, .. } => { - // Make a copy of the member types, for the borrow checker. - let types: Vec> = members.iter().map(|member| member.ty).collect(); - let mut components = vec![]; - for member_ty in types { - let value = self.register_zero_constant(member_ty, span)?; - components.push(value); - } - ConstantInner::Composite { ty, components } - } - ref inner => { - return Err(ConstantSolvingError::NotImplemented(format!( - "zero-value construction for types: {:?}", - inner - ))); - } - }; - - Ok(self.register_constant(inner, span)) - } - - fn register_literal(&mut self, literal: crate::Literal, span: crate::Span) -> Handle { - let (width, value) = match literal { - crate::Literal::F64(n) => (8, ScalarValue::Float(n)), - crate::Literal::F32(n) => (4, ScalarValue::Float(n as f64)), - crate::Literal::U32(n) => (4, ScalarValue::Uint(n as u64)), - crate::Literal::I32(n) => (4, ScalarValue::Sint(n as i64)), - crate::Literal::Bool(b) => (1, ScalarValue::Bool(b)), - }; - - self.register_constant(ConstantInner::Scalar { width, value }, span) - } - - fn register_constant(&mut self, inner: ConstantInner, span: crate::Span) -> Handle { - self.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner, - }, - span, - ) + fn register_constant(&mut self, expr: Expression, span: crate::Span) -> Handle { + self.const_expressions.append(expr, span) } } @@ -676,7 +720,7 @@ impl<'a> ConstantSolver<'a> { /// ``` /// /// Rust will return `1.0` while GLSL should return NaN. -fn glsl_float_max(x: f64, y: f64) -> f64 { +fn glsl_float_max(x: f32, y: f32) -> f32 { if x < y { y } else { @@ -697,7 +741,7 @@ fn glsl_float_max(x: f64, y: f64) -> f64 { /// ``` /// /// Rust will return `1.0` while GLSL should return NaN. -fn glsl_float_min(x: f64, y: f64) -> f64 { +fn glsl_float_min(x: f32, y: f32) -> f32 { if y < x { y } else { @@ -710,7 +754,7 @@ fn glsl_float_min(x: f64, y: f64) -> f64 { /// 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: f64, min: f64, max: f64) -> f64 { +fn glsl_float_clamp(value: f32, min: f32, max: f32) -> f32 { glsl_float_min(glsl_float_max(value, min), max) } @@ -719,23 +763,23 @@ mod tests { use std::vec; use crate::{ - Arena, Constant, ConstantInner, Expression, ScalarKind, ScalarValue, Type, TypeInner, - UnaryOperator, UniqueArena, VectorSize, + Arena, Constant, Expression, Literal, ScalarKind, Type, TypeInner, UnaryOperator, + UniqueArena, VectorSize, }; use super::ConstantSolver; #[test] fn nan_handling() { - assert!(super::glsl_float_max(f64::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_max(2.0, f64::NAN).is_nan()); + 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(f64::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_min(2.0, f64::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(f64::NAN, 1.0, 2.0).is_nan()); - assert!(!super::glsl_float_clamp(1.0, f64::NAN, 2.0).is_nan()); - assert!(!super::glsl_float_clamp(1.0, 2.0, f64::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] @@ -743,6 +787,18 @@ mod tests { 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 { @@ -759,11 +815,10 @@ mod tests { let h = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(4), - }, + r#override: crate::Override::None, + ty: scalar_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(4)), Default::default()), }, Default::default(), ); @@ -771,11 +826,10 @@ mod tests { let h1 = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(8), - }, + r#override: crate::Override::None, + ty: scalar_ty, + init: const_expressions + .append(Expression::Literal(Literal::I32(8)), Default::default()), }, Default::default(), ); @@ -783,11 +837,15 @@ mod tests { let vec_h = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Composite { - ty: vec_ty, - components: vec![h, h1], - }, + 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(), ); @@ -823,6 +881,7 @@ mod tests { types: &mut types, expressions: &expressions, constants: &mut constants, + const_expressions: &mut const_expressions, }; let res1 = solver.solve(root1).unwrap(); @@ -830,43 +889,31 @@ mod tests { let res3 = solver.solve(root3).unwrap(); assert_eq!( - constants[res1].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(-4), - }, + const_expressions[res1], + Expression::Literal(Literal::I32(-4)) ); assert_eq!( - constants[res2].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(!4), - }, + const_expressions[res2], + Expression::Literal(Literal::I32(!4)) ); - let res3_inner = &constants[res3].inner; + let res3_inner = &const_expressions[res3]; match *res3_inner { - ConstantInner::Composite { + Expression::Compose { ref ty, ref components, } => { assert_eq!(*ty, vec_ty); let mut components_iter = components.iter().copied(); assert_eq!( - constants[components_iter.next().unwrap()].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(!4), - }, + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::I32(!4)) ); assert_eq!( - constants[components_iter.next().unwrap()].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Sint(!8), - }, + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::I32(!8)) ); assert!(components_iter.next().is_none()); } @@ -876,21 +923,33 @@ mod tests { #[test] fn cast() { + let mut types = UniqueArena::new(); let mut expressions = Arena::new(); let mut constants = Arena::new(); + let mut const_expressions = Arena::new(); - let h = constants.append( - Constant { + let scalar_ty = types.insert( + Type { name: None, - specialization: None, - inner: ConstantInner::Scalar { + inner: TypeInner::Scalar { + kind: ScalarKind::Sint, width: 4, - value: ScalarValue::Sint(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( @@ -903,19 +962,17 @@ mod tests { ); let mut solver = ConstantSolver { - types: &mut UniqueArena::new(), + types: &mut types, expressions: &expressions, constants: &mut constants, + const_expressions: &mut const_expressions, }; let res = solver.solve(root).unwrap(); assert_eq!( - constants[res].inner, - ConstantInner::Scalar { - width: crate::BOOL_WIDTH, - value: ScalarValue::Bool(true), - }, + const_expressions[res], + Expression::Literal(Literal::Bool(true)) ); } @@ -924,6 +981,7 @@ mod tests { 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 { @@ -953,15 +1011,8 @@ mod tests { let mut vec2_components = Vec::with_capacity(3); for i in 0..3 { - let h = constants.append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(i as f64), - }, - }, + let h = const_expressions.append( + Expression::Literal(Literal::F32(i as f32)), Default::default(), ); @@ -969,15 +1020,8 @@ mod tests { } for i in 3..6 { - let h = constants.append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(i as f64), - }, - }, + let h = const_expressions.append( + Expression::Literal(Literal::F32(i as f32)), Default::default(), ); @@ -987,11 +1031,15 @@ mod tests { let vec1 = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Composite { - ty: vec_ty, - components: vec1_components, - }, + r#override: crate::Override::None, + ty: vec_ty, + init: const_expressions.append( + Expression::Compose { + ty: vec_ty, + components: vec1_components, + }, + Default::default(), + ), }, Default::default(), ); @@ -999,11 +1047,15 @@ mod tests { let vec2 = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Composite { - ty: vec_ty, - components: vec2_components, - }, + r#override: crate::Override::None, + ty: vec_ty, + init: const_expressions.append( + Expression::Compose { + ty: vec_ty, + components: vec2_components, + }, + Default::default(), + ), }, Default::default(), ); @@ -1011,11 +1063,15 @@ mod tests { let h = constants.append( Constant { name: None, - specialization: None, - inner: ConstantInner::Composite { - ty: matrix_ty, - components: vec![vec1, vec2], - }, + 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(), ); @@ -1037,40 +1093,30 @@ mod tests { 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 res1_inner = &constants[res1].inner; - - match *res1_inner { - ConstantInner::Composite { + match const_expressions[res1] { + Expression::Compose { ref ty, ref components, } => { assert_eq!(*ty, vec_ty); let mut components_iter = components.iter().copied(); assert_eq!( - constants[components_iter.next().unwrap()].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(3.), - }, + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(3.)) ); assert_eq!( - constants[components_iter.next().unwrap()].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(4.), - }, + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(4.)) ); assert_eq!( - constants[components_iter.next().unwrap()].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(5.), - }, + const_expressions[components_iter.next().unwrap()], + Expression::Literal(Literal::F32(5.)) ); assert!(components_iter.next().is_none()); } @@ -1078,11 +1124,8 @@ mod tests { } assert_eq!( - constants[res2].inner, - ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(5.), - }, + const_expressions[res2], + Expression::Literal(Literal::F32(5.)) ); } } diff --git a/src/front/glsl/context.rs b/src/front/glsl/context.rs index 93b7e03b64..e16dc125e7 100644 --- a/src/front/glsl/context.rs +++ b/src/front/glsl/context.rs @@ -10,10 +10,10 @@ use super::{ use crate::{ front::{Emitter, Typifier}, AddressSpace, Arena, BinaryOperator, Block, Expression, FastHashMap, FunctionArgument, Handle, - Literal, LocalVariable, RelationalFunction, ScalarKind, ScalarValue, Span, Statement, Type, - TypeInner, VectorSize, + Literal, LocalVariable, RelationalFunction, ScalarKind, Span, Statement, Type, TypeInner, + VectorSize, }; -use std::{convert::TryFrom, ops::Index}; +use std::ops::Index; /// The position at which an expression is, used while lowering #[derive(Clone, Copy, PartialEq, Eq, Debug)] @@ -519,21 +519,12 @@ impl Context { .0; let pointer = maybe_constant_index - .and_then(|constant| { + .and_then(|const_expr| { Some(self.add_expression( Expression::AccessIndex { base, - index: match frontend.module.constants[constant].inner { - crate::ConstantInner::Scalar { - value: ScalarValue::Uint(i), - .. - } => u32::try_from(i).ok()?, - crate::ConstantInner::Scalar { - value: ScalarValue::Sint(i), - .. - } => u32::try_from(i).ok()?, - _ => return None, - }, + index: + frontend.module.to_ctx().eval_expr_to_u32(const_expr).ok()?, }, meta, body, @@ -1039,14 +1030,18 @@ impl Context { // 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(constant), - }, - Span::default(), - ); + let local = + self.locals.append( + LocalVariable { + name: None, + ty, + init: Some(frontend.module.const_expressions.append( + Expression::Constant(constant), + Span::default(), + )), + }, + Span::default(), + ); self.add_expression( Expression::LocalVariable(local), diff --git a/src/front/glsl/functions.rs b/src/front/glsl/functions.rs index b7b4be8a61..f448272583 100644 --- a/src/front/glsl/functions.rs +++ b/src/front/glsl/functions.rs @@ -8,8 +8,8 @@ use super::{ }; use crate::{ front::glsl::types::type_power, proc::ensure_block_returns, AddressSpace, Arena, Block, - Constant, ConstantInner, EntryPoint, Expression, Function, FunctionArgument, FunctionResult, - Handle, LocalVariable, ScalarKind, ScalarValue, Span, Statement, StructMember, Type, TypeInner, + EntryPoint, Expression, Function, FunctionArgument, FunctionResult, Handle, Literal, + LocalVariable, ScalarKind, Span, Statement, StructMember, Type, TypeInner, }; use std::iter; @@ -24,29 +24,6 @@ struct ProxyWrite { } impl Frontend { - fn add_constant_value( - &mut self, - scalar_kind: ScalarKind, - value: u64, - meta: Span, - ) -> Handle { - let value = match scalar_kind { - ScalarKind::Uint => ScalarValue::Uint(value), - ScalarKind::Sint => ScalarValue::Sint(value as i64), - ScalarKind::Float => ScalarValue::Float(value as f64), - ScalarKind::Bool => unreachable!(), - }; - - self.module.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { width: 4, value }, - }, - meta, - ) - } - pub(crate) fn function_or_constructor_call( &mut self, ctx: &mut Context, @@ -97,10 +74,10 @@ impl Frontend { if expr_type.scalar_kind() == Some(ScalarKind::Bool) && result_scalar_kind != ScalarKind::Bool => { - let c0 = self.add_constant_value(result_scalar_kind, 0u64, meta); - let c1 = self.add_constant_value(result_scalar_kind, 1u64, meta); - let mut reject = ctx.add_expression(Expression::Constant(c0), expr_meta, body); - let mut accept = ctx.add_expression(Expression::Constant(c1), expr_meta, body); + let l0 = Literal::zero(result_scalar_kind, 4).unwrap(); + let l1 = Literal::one(result_scalar_kind, 4).unwrap(); + let mut reject = ctx.add_expression(Expression::Literal(l0), expr_meta, body); + let mut accept = ctx.add_expression(Expression::Literal(l1), expr_meta, body); ctx.implicit_splat(self, &mut reject, meta, vector_size)?; ctx.implicit_splat(self, &mut accept, meta, vector_size)?; @@ -282,18 +259,9 @@ impl Frontend { }, meta, ); - let zero_constant = self.module.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { - width, - value: ScalarValue::Float(0.0), - }, - }, - meta, - ); - let zero = ctx.add_expression(Expression::Constant(zero_constant), meta, body); + + let zero_literal = Literal::zero(ScalarKind::Float, width).unwrap(); + let zero = ctx.add_expression(Expression::Literal(zero_literal), meta, body); for i in 0..columns as u32 { components.push( @@ -323,30 +291,12 @@ impl Frontend { // (column i, row j) in the argument will be initialized from there. All // other components will be initialized to the identity matrix. - let zero_constant = self.module.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { - width, - value: ScalarValue::Float(0.0), - }, - }, - meta, - ); - let zero = ctx.add_expression(Expression::Constant(zero_constant), meta, body); - let one_constant = self.module.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Scalar { - width, - value: ScalarValue::Float(1.0), - }, - }, - meta, - ); - let one = ctx.add_expression(Expression::Constant(one_constant), meta, body); + let zero_literal = Literal::zero(ScalarKind::Float, width).unwrap(); + let one_literal = Literal::one(ScalarKind::Float, width).unwrap(); + + let zero = ctx.add_expression(Expression::Literal(zero_literal), meta, body); + let one = ctx.add_expression(Expression::Literal(one_literal), meta, body); + let vector_ty = self.module.types.insert( Type { name: None, @@ -406,24 +356,17 @@ impl Frontend { Ordering::Greater => ctx.vector_resize(rows, vector, meta, body), }) } else { - let vec_constant = self.module.constants.fetch_or_append( - Constant { - name: None, - specialization: None, - inner: ConstantInner::Composite { - ty: vector_ty, - components: (0..rows as u32) - .map(|r| match r == i { - true => one_constant, - false => zero_constant, - }) - .collect(), - }, - }, - meta, - ); - let vec = - ctx.add_expression(Expression::Constant(vec_constant), meta, body); + let compose_expr = Expression::Compose { + ty: vector_ty, + components: (0..rows as u32) + .map(|r| match r == i { + true => one, + false => zero, + }) + .collect(), + }; + + let vec = ctx.add_expression(compose_expr, meta, body); components.push(vec) } diff --git a/src/front/glsl/parser.rs b/src/front/glsl/parser.rs index ed139e799d..7db30ea80f 100644 --- a/src/front/glsl/parser.rs +++ b/src/front/glsl/parser.rs @@ -9,8 +9,7 @@ use super::{ variables::{GlobalOrConstant, VarDeclaration}, Frontend, Result, }; -use crate::{arena::Handle, Block, Constant, ConstantInner, Expression, ScalarValue, Span, Type}; -use core::convert::TryFrom; +use crate::{arena::Handle, proc::U32EvalError, Block, Expression, Span, Type}; use pp_rs::token::{PreprocessorError, Token as PPToken, TokenValue as PPTokenValue}; use std::iter::Peekable; @@ -192,30 +191,21 @@ impl<'source> ParsingContext<'source> { } fn parse_uint_constant(&mut self, frontend: &mut Frontend) -> Result<(u32, Span)> { - let (value, meta) = self.parse_constant_expression(frontend)?; + let (const_expr, meta) = self.parse_constant_expression(frontend)?; - let int = match frontend.module.constants[value].inner { - ConstantInner::Scalar { - value: ScalarValue::Uint(int), - .. - } => u32::try_from(int).map_err(|_| Error { + let res = frontend.module.to_ctx().eval_expr_to_u32(const_expr); + + let int = match res { + Ok(value) => Ok(value), + Err(U32EvalError::Negative) => Err(Error { kind: ErrorKind::SemanticError("int constant overflows".into()), meta, - })?, - ConstantInner::Scalar { - value: ScalarValue::Sint(int), - .. - } => u32::try_from(int).map_err(|_| Error { - kind: ErrorKind::SemanticError("int constant overflows".into()), + }), + Err(U32EvalError::NonConst) => Err(Error { + kind: ErrorKind::SemanticError("Expected a uint constant".into()), meta, - })?, - _ => { - return Err(Error { - kind: ErrorKind::SemanticError("Expected a uint constant".into()), - meta, - }) - } - }; + }), + }?; Ok((int, meta)) } @@ -223,7 +213,7 @@ impl<'source> ParsingContext<'source> { fn parse_constant_expression( &mut self, frontend: &mut Frontend, - ) -> Result<(Handle, Span)> { + ) -> Result<(Handle, Span)> { let mut block = Block::new(); let mut ctx = Context::new(frontend, &mut block); @@ -412,7 +402,7 @@ impl<'ctx, 'qualifiers> DeclarationContext<'ctx, 'qualifiers> { frontend: &mut Frontend, ty: Handle, name: String, - init: Option>, + init: Option>, meta: Span, ) -> Result> { let decl = VarDeclaration { diff --git a/src/front/glsl/parser/declarations.rs b/src/front/glsl/parser/declarations.rs index 79bf1bc8cb..1062630180 100644 --- a/src/front/glsl/parser/declarations.rs +++ b/src/front/glsl/parser/declarations.rs @@ -244,7 +244,7 @@ impl<'source> ParsingContext<'source> { .transpose()?; let is_const = ctx.qualifiers.storage.0 == StorageQualifier::Const; - let maybe_constant = if ctx.external { + let maybe_const_expr = if ctx.external { if let Some((root, meta)) = init { match frontend.solve_constant(ctx.ctx, root, meta) { Ok(res) => Some(res), @@ -260,9 +260,9 @@ impl<'source> ParsingContext<'source> { None }; - let pointer = ctx.add_var(frontend, ty, name, maybe_constant, meta)?; + let pointer = ctx.add_var(frontend, ty, name, maybe_const_expr, meta)?; - if let Some((value, _)) = init.filter(|_| maybe_constant.is_none()) { + if let Some((value, _)) = init.filter(|_| maybe_const_expr.is_none()) { ctx.flush_expressions(); ctx.body.push(Statement::Store { pointer, value }, meta); } diff --git a/src/front/glsl/parser/functions.rs b/src/front/glsl/parser/functions.rs index 781f4cffed..c05d060ea1 100644 --- a/src/front/glsl/parser/functions.rs +++ b/src/front/glsl/parser/functions.rs @@ -1,5 +1,6 @@ use crate::front::glsl::context::ExprPos; use crate::front::glsl::Span; +use crate::Literal; use crate::{ front::glsl::{ ast::ParameterQualifier, @@ -9,7 +10,7 @@ use crate::{ variables::VarDeclaration, Error, ErrorKind, Frontend, Result, }, - Block, ConstantInner, Expression, ScalarValue, Statement, SwitchCase, UnaryOperator, + Block, Expression, Statement, SwitchCase, UnaryOperator, }; impl<'source> ParsingContext<'source> { @@ -194,20 +195,16 @@ impl<'source> ParsingContext<'source> { let expr = self.parse_expression(frontend, ctx, &mut stmt, body)?; let (root, meta) = ctx.lower_expect(stmt, frontend, expr, ExprPos::Rhs, body)?; - let constant = frontend.solve_constant(ctx, root, meta)?; - - match frontend.module.constants[constant].inner { - ConstantInner::Scalar { - value: ScalarValue::Sint(int), - .. - } => match uint { - true => crate::SwitchValue::U32(int as u32), - false => crate::SwitchValue::I32(int as i32), + let const_expr = frontend.solve_constant(ctx, root, meta)?; + + match frontend.module.const_expressions[const_expr] { + Expression::Literal(Literal::I32(value)) => match uint { + true => crate::SwitchValue::U32(value as u32), + false => crate::SwitchValue::I32(value), }, - ConstantInner::Scalar { - value: ScalarValue::Uint(int), - .. - } => crate::SwitchValue::U32(int as u32), + Expression::Literal(Literal::U32(value)) => { + crate::SwitchValue::U32(value) + } _ => { frontend.errors.push(Error { kind: ErrorKind::SemanticError( diff --git a/src/front/glsl/parser_tests.rs b/src/front/glsl/parser_tests.rs index ae529a6fbe..dd5880068c 100644 --- a/src/front/glsl/parser_tests.rs +++ b/src/front/glsl/parser_tests.rs @@ -509,7 +509,8 @@ fn functions() { #[test] fn constants() { - use crate::{Constant, ConstantInner, ScalarValue}; + use crate::{Constant, Expression, ScalarKind, Type, TypeInner}; + let mut frontend = Frontend::default(); let module = frontend @@ -526,28 +527,49 @@ fn constants() { ) .unwrap(); + let mut types = module.types.iter(); let mut constants = module.constants.iter(); + let mut const_expressions = module.const_expressions.iter(); + let (ty_handle, ty) = types.next().unwrap(); assert_eq!( - constants.next().unwrap().1, + ty, + &Type { + name: None, + inner: TypeInner::Scalar { + kind: ScalarKind::Float, + width: 4 + } + } + ); + + let (init_a_handle, init_a) = const_expressions.next().unwrap(); + assert_eq!(init_a, &Expression::Literal(crate::Literal::F32(1.0))); + + let (constant_a_handle, constant_a) = constants.next().unwrap(); + assert_eq!( + constant_a, &Constant { name: Some("a".to_owned()), - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(1.0) - } + r#override: crate::Override::None, + ty: ty_handle, + init: init_a_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()), - specialization: None, - inner: ConstantInner::Scalar { - width: 4, - value: ScalarValue::Float(1.0) - } + r#override: crate::Override::None, + ty: ty_handle, + init: init_b_handle } ); diff --git a/src/front/glsl/types.rs b/src/front/glsl/types.rs index a7967848d5..513bc22754 100644 --- a/src/front/glsl/types.rs +++ b/src/front/glsl/types.rs @@ -2,8 +2,8 @@ use super::{ constants::ConstantSolver, context::Context, Error, ErrorKind, Frontend, Result, Span, }; use crate::{ - proc::ResolveContext, Bytes, Constant, Expression, Handle, ImageClass, ImageDimension, - ScalarKind, Type, TypeInner, VectorSize, + proc::ResolveContext, Bytes, Expression, Handle, ImageClass, ImageDimension, ScalarKind, Type, + TypeInner, VectorSize, }; pub fn parse_type(type_name: &str) -> Option { @@ -320,11 +320,12 @@ impl Frontend { ctx: &Context, root: Handle, meta: Span, - ) -> Result> { + ) -> Result> { let mut solver = ConstantSolver { types: &mut self.module.types, expressions: &ctx.expressions, constants: &mut self.module.constants, + const_expressions: &mut self.module.const_expressions, }; solver.solve(root).map_err(|e| Error { diff --git a/src/front/glsl/variables.rs b/src/front/glsl/variables.rs index 4c0e0a927d..a9a403e402 100644 --- a/src/front/glsl/variables.rs +++ b/src/front/glsl/variables.rs @@ -14,7 +14,7 @@ pub struct VarDeclaration<'a, 'key> { pub qualifiers: &'a mut TypeQualifiers<'key>, pub ty: Handle, pub name: Option, - pub init: Option>, + pub init: Option>, pub meta: Span, } @@ -494,29 +494,21 @@ impl Frontend { meta, })?; + let constant = Constant { + name: name.clone(), + r#override: crate::Override::None, + ty, + init, + }; + let handle = self.module.constants.fetch_or_append(constant, meta); + let lookup = GlobalLookup { - kind: GlobalLookupKind::Constant(init, ty), + kind: GlobalLookupKind::Constant(handle, ty), entry_arg: None, mutable: false, }; - if let Some(name) = name.as_ref() { - let constant = self.module.constants.get_mut(init); - if constant.name.is_none() { - // set the name of the constant - constant.name = Some(name.clone()) - } else { - // add a copy of the constant with the new name - let new_const = Constant { - name: Some(name.clone()), - specialization: constant.specialization, - inner: constant.inner.clone(), - }; - self.module.constants.fetch_or_append(new_const, meta); - } - } - - (GlobalOrConstant::Constant(init), lookup) + (GlobalOrConstant::Constant(handle), lookup) } StorageQualifier::AddressSpace(mut space) => { match space { diff --git a/src/front/mod.rs b/src/front/mod.rs index d6f38671ea..1f16ff6378 100644 --- a/src/front/mod.rs +++ b/src/front/mod.rs @@ -55,16 +55,6 @@ impl Emitter { } } -#[allow(dead_code)] -impl super::ConstantInner { - const fn boolean(value: bool) -> Self { - Self::Scalar { - width: super::BOOL_WIDTH, - value: super::ScalarValue::Bool(value), - } - } -} - /// 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 97a1974974..7a874ae4e0 100644 --- a/src/front/spv/function.rs +++ b/src/front/spv/function.rs @@ -128,6 +128,7 @@ impl> super::Frontend { expressions: &mut fun.expressions, local_arena: &mut fun.local_variables, const_arena: &mut module.constants, + const_expressions: &mut module.const_expressions, type_arena: &module.types, global_arena: &module.global_variables, arguments: &fun.arguments, @@ -572,6 +573,7 @@ impl<'function> BlockContext<'function> { crate::proc::GlobalCtx { types: self.type_arena, constants: self.const_arena, + const_expressions: self.const_expressions, } } diff --git a/src/front/spv/image.rs b/src/front/spv/image.rs index ddbc8c19b7..ac0129059a 100644 --- a/src/front/spv/image.rs +++ b/src/front/spv/image.rs @@ -503,6 +503,10 @@ impl> super::Frontend { spirv::ImageOperands::CONST_OFFSET => { let offset_constant = self.next()?; let offset_handle = self.lookup_constant.lookup(offset_constant)?.handle; + let offset_handle = ctx.const_expressions.append( + crate::Expression::Constant(offset_handle), + Default::default(), + ); offset = Some(offset_handle); words_left -= 1; } diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index a2124bfa87..6ddd1d70c8 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -221,6 +221,11 @@ impl Decoration { } } + fn specialization(&self) -> crate::Override { + self.specialization + .map_or(crate::Override::None, crate::Override::ByNameOrId) + } + const fn resource_binding(&self) -> Option { match *self { Decoration { @@ -536,6 +541,7 @@ struct BlockContext<'function> { local_arena: &'function mut Arena, /// Constants arena of the module being processed const_arena: &'function mut Arena, + const_expressions: &'function mut Arena, /// Type arena of the module being processed type_arena: &'function UniqueArena, /// Global arena of the module being processed @@ -584,8 +590,6 @@ pub struct Frontend { // so that in the IR any called function is already known. function_call_graph: GraphMap, options: Options, - index_constants: Vec>, - index_constant_expressions: Vec>, /// Maps for a switch from a case target to the respective body and associated literals that /// use that target block id. @@ -636,8 +640,6 @@ impl> Frontend { dummy_functions: Arena::new(), function_call_graph: GraphMap::new(), options: options.clone(), - index_constants: Vec::new(), - index_constant_expressions: Vec::new(), switch_cases: indexmap::IndexMap::default(), gl_per_vertex_builtin_access: FastHashSet::default(), } @@ -1395,7 +1397,10 @@ impl> Frontend { inst.expect(5)?; let init_id = self.next()?; let lconst = self.lookup_constant.lookup(init_id)?; - Some(lconst.handle) + Some( + ctx.const_expressions + .append(crate::Expression::Constant(lconst.handle), span), + ) } else { None }; @@ -1531,11 +1536,15 @@ impl> Frontend { let index_expr_handle = get_expr_handle!(access_id, &index_expr); let index_expr_data = &ctx.expressions[index_expr.handle]; let index_maybe = match *index_expr_data { - crate::Expression::Constant(const_handle) => { - Some(ctx.const_arena[const_handle].to_array_length().ok_or( - Error::InvalidAccess(crate::Expression::Constant(const_handle)), - )?) - } + crate::Expression::Constant(const_handle) => Some( + ctx.gctx() + .eval_expr_to_u32(ctx.const_arena[const_handle].init) + .map_err(|_| { + Error::InvalidAccess(crate::Expression::Constant( + const_handle, + )) + })?, + ), _ => None, }; @@ -3731,13 +3740,6 @@ impl> Frontend { }, ); } - // register special constants - self.index_constant_expressions.clear(); - for &con_handle in self.index_constants.iter() { - let span = constants.get_span(con_handle); - let handle = expressions.append(crate::Expression::Constant(con_handle), span); - self.index_constant_expressions.push(handle); - } // register constants for (&id, con) in self.lookup_constant.iter() { let span = constants.get_span(con.handle); @@ -3902,23 +3904,6 @@ impl> Frontend { crate::Module::default() }; - // register indexing constants - self.index_constants.clear(); - for i in 0..4 { - let handle = module.constants.append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Scalar { - width: 4, - value: crate::ScalarValue::Sint(i), - }, - }, - Default::default(), - ); - self.index_constants.push(handle); - } - self.layouter.clear(); self.dummy_functions = Arena::new(); self.lookup_function.clear(); @@ -3965,9 +3950,7 @@ impl> Frontend { Op::TypeSampler => self.parse_type_sampler(inst, &mut module), Op::Constant | Op::SpecConstant => self.parse_constant(inst, &mut module), Op::ConstantComposite => self.parse_composite_constant(inst, &mut module), - Op::ConstantNull | Op::Undef => self - .parse_null_constant(inst, &module.types, &mut module.constants) - .map(|_| ()), + Op::ConstantNull | Op::Undef => self.parse_null_constant(inst, &mut module), Op::ConstantTrue => self.parse_bool_constant(inst, true, &mut module), Op::ConstantFalse => self.parse_bool_constant(inst, false, &mut module), Op::Variable => self.parse_global_variable(inst, &mut module), @@ -4892,21 +4875,15 @@ impl> Frontend { let type_lookup = self.lookup_type.lookup(type_id)?; let ty = type_lookup.handle; - let inner = match module.types[ty].inner { + let literal = match module.types[ty].inner { crate::TypeInner::Scalar { kind: crate::ScalarKind::Uint, width, } => { let low = self.next()?; - let high = if width > 4 { - inst.expect(5)?; - self.next()? - } else { - 0 - }; - crate::ConstantInner::Scalar { - width, - value: crate::ScalarValue::Uint((u64::from(high) << 32) | u64::from(low)), + match width { + 4 => crate::Literal::U32(low), + _ => return Err(Error::InvalidTypeWidth(width as u32)), } } crate::TypeInner::Scalar { @@ -4914,17 +4891,9 @@ impl> Frontend { width, } => { let low = self.next()?; - let high = if width > 4 { - inst.expect(5)?; - self.next()? - } else { - 0 - }; - crate::ConstantInner::Scalar { - width, - value: crate::ScalarValue::Sint( - (i64::from(high as i32) << 32) | ((i64::from(low as i32) << 32) >> 32), - ), + match width { + 4 => crate::Literal::I32(low as i32), + _ => return Err(Error::InvalidTypeWidth(width as u32)), } } crate::TypeInner::Scalar { @@ -4932,18 +4901,16 @@ impl> Frontend { width, } => { let low = self.next()?; - let extended = match width { - 4 => f64::from(f32::from_bits(low)), + match width { + 4 => crate::Literal::F32(f32::from_bits(low)), 8 => { inst.expect(5)?; let high = self.next()?; - f64::from_bits((u64::from(high) << 32) | u64::from(low)) + crate::Literal::F64(f64::from_bits( + (u64::from(high) << 32) | u64::from(low), + )) } _ => return Err(Error::InvalidTypeWidth(width as u32)), - }; - crate::ConstantInner::Scalar { - width, - value: crate::ScalarValue::Float(extended), } } _ => return Err(Error::UnsupportedType(type_lookup.handle)), @@ -4951,16 +4918,22 @@ impl> Frontend { let decor = self.future_decor.remove(&id).unwrap_or_default(); + let span = self.span_from_with_op(start); + + let init = module + .const_expressions + .append(crate::Expression::Literal(literal), span); self.lookup_constant.insert( id, LookupConstant { handle: module.constants.append( crate::Constant { - specialization: decor.specialization, + r#override: decor.specialization(), name: decor.name, - inner, + ty, + init, }, - self.span_from_with_op(start), + span, ), type_id, }, @@ -4977,27 +4950,41 @@ impl> Frontend { self.switch(ModuleState::Type, inst.op)?; inst.expect_at_least(3)?; let type_id = self.next()?; + let id = self.next()?; + let type_lookup = self.lookup_type.lookup(type_id)?; let ty = type_lookup.handle; - let id = self.next()?; let mut components = Vec::with_capacity(inst.wc as usize - 3); for _ in 0..components.capacity() { + let start = self.data_offset; let component_id = self.next()?; + let span = self.span_from_with_op(start); let constant = self.lookup_constant.lookup(component_id)?; - components.push(constant.handle); + let expr = module + .const_expressions + .append(crate::Expression::Constant(constant.handle), span); + components.push(expr); } + let decor = self.future_decor.remove(&id).unwrap_or_default(); + + let span = self.span_from_with_op(start); + + let init = module + .const_expressions + .append(crate::Expression::Compose { ty, components }, span); self.lookup_constant.insert( id, LookupConstant { handle: module.constants.append( crate::Constant { - name: self.future_decor.remove(&id).and_then(|dec| dec.name), - specialization: None, - inner: crate::ConstantInner::Composite { ty, components }, + r#override: decor.specialization(), + name: decor.name, + ty, + init, }, - self.span_from_with_op(start), + span, ), type_id, }, @@ -5008,30 +4995,35 @@ impl> Frontend { fn parse_null_constant( &mut self, inst: Instruction, - types: &UniqueArena, - constants: &mut Arena, - ) -> Result<(u32, u32, Handle), Error> { + module: &mut crate::Module, + ) -> Result<(), Error> { let start = self.data_offset; self.switch(ModuleState::Type, inst.op)?; inst.expect(3)?; let type_id = self.next()?; let id = self.next()?; let span = self.span_from_with_op(start); + let type_lookup = self.lookup_type.lookup(type_id)?; let ty = type_lookup.handle; - let inner = null::generate_null_constant(ty, types, constants, span)?; - let handle = constants.append( + let decor = self.future_decor.remove(&id).unwrap_or_default(); + + let init = module + .const_expressions + .append(crate::Expression::ZeroValue(ty), span); + let handle = module.constants.append( crate::Constant { - name: self.future_decor.remove(&id).and_then(|dec| dec.name), - specialization: None, //TODO - inner, + r#override: decor.specialization(), + name: decor.name, + ty, + init, }, span, ); self.lookup_constant .insert(id, LookupConstant { handle, type_id }); - Ok((type_id, id, handle)) + Ok(()) } fn parse_bool_constant( @@ -5045,17 +5037,28 @@ impl> Frontend { inst.expect(3)?; let type_id = self.next()?; let id = self.next()?; + let span = self.span_from_with_op(start); + + let type_lookup = self.lookup_type.lookup(type_id)?; + let ty = type_lookup.handle; + let decor = self.future_decor.remove(&id).unwrap_or_default(); + + let init = module.const_expressions.append( + crate::Expression::Literal(crate::Literal::Bool(value)), + span, + ); self.lookup_constant.insert( id, LookupConstant { handle: module.constants.append( crate::Constant { - name: self.future_decor.remove(&id).and_then(|dec| dec.name), - specialization: None, //TODO - inner: crate::ConstantInner::boolean(value), + r#override: decor.specialization(), + name: decor.name, + ty, + init, }, - self.span_from_with_op(start), + span, ), type_id, }, @@ -5076,9 +5079,14 @@ impl> Frontend { let storage_class = self.next()?; let init = if inst.wc > 4 { inst.expect(5)?; + let start = self.data_offset; let init_id = self.next()?; + let span = self.span_from_with_op(start); let lconst = self.lookup_constant.lookup(init_id)?; - Some(lconst.handle) + let expr = module + .const_expressions + .append(crate::Expression::Constant(lconst.handle), span); + Some(expr) } else { None }; @@ -5211,8 +5219,7 @@ impl> Frontend { match null::generate_default_built_in( Some(built_in), ty, - &module.types, - &mut module.constants, + &mut module.const_expressions, span, ) { Ok(handle) => Some(handle), @@ -5225,37 +5232,25 @@ impl> Frontend { Some(crate::Binding::Location { .. }) => None, None => match module.types[ty].inner { crate::TypeInner::Struct { ref members, .. } => { - // A temporary to avoid borrowing `module.types` - let pairs = members - .iter() - .map(|member| { - let built_in = match member.binding { - Some(crate::Binding::BuiltIn(built_in)) => Some(built_in), - _ => None, - }; - (built_in, member.ty) - }) - .collect::>(); - let mut components = Vec::with_capacity(members.len()); - for (built_in, member_ty) in pairs { + for member in members.iter() { + let built_in = match member.binding { + Some(crate::Binding::BuiltIn(built_in)) => Some(built_in), + _ => None, + }; let handle = null::generate_default_built_in( built_in, - member_ty, - &module.types, - &mut module.constants, + member.ty, + &mut module.const_expressions, span, )?; components.push(handle); } - Some(module.constants.append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Composite { ty, components }, - }, - span, - )) + Some( + module + .const_expressions + .append(crate::Expression::Compose { ty, components }, span), + ) } _ => None, }, @@ -5322,7 +5317,11 @@ fn resolve_constant( gctx: crate::proc::GlobalCtx, constant: Handle, ) -> Option { - gctx.constants[constant].to_array_length() + match gctx.const_expressions[gctx.constants[constant].init] { + crate::Expression::Literal(crate::Literal::U32(id)) => Some(id), + crate::Expression::Literal(crate::Literal::I32(id)) => Some(id as u32), + _ => None, + } } pub fn parse_u8_slice(data: &[u8], options: &Options) -> Result { diff --git a/src/front/spv/null.rs b/src/front/spv/null.rs index eb0b418aaa..42cccca80a 100644 --- a/src/front/spv/null.rs +++ b/src/front/spv/null.rs @@ -1,172 +1,31 @@ use super::Error; -use crate::arena::{Arena, Handle, UniqueArena}; - -const fn make_scalar_inner(kind: crate::ScalarKind, width: crate::Bytes) -> crate::ConstantInner { - crate::ConstantInner::Scalar { - width, - value: match kind { - crate::ScalarKind::Uint => crate::ScalarValue::Uint(0), - crate::ScalarKind::Sint => crate::ScalarValue::Sint(0), - crate::ScalarKind::Float => crate::ScalarValue::Float(0.0), - crate::ScalarKind::Bool => crate::ScalarValue::Bool(false), - }, - } -} - -pub fn generate_null_constant( - ty: Handle, - type_arena: &UniqueArena, - constant_arena: &mut Arena, - span: crate::Span, -) -> Result { - let inner = match type_arena[ty].inner { - crate::TypeInner::Scalar { kind, width } => make_scalar_inner(kind, width), - crate::TypeInner::Vector { size, kind, width } => { - let mut components = Vec::with_capacity(size as usize); - for _ in 0..size as usize { - components.push(constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner: make_scalar_inner(kind, width), - }, - span, - )); - } - crate::ConstantInner::Composite { ty, components } - } - crate::TypeInner::Matrix { - columns, - rows, - width, - } => { - // If we successfully declared a matrix type, we have declared a vector type for it too. - let vector_ty = type_arena - .get(&crate::Type { - name: None, - inner: crate::TypeInner::Vector { - kind: crate::ScalarKind::Float, - size: rows, - width, - }, - }) - .unwrap(); - let vector_inner = generate_null_constant(vector_ty, type_arena, constant_arena, span)?; - let vector_handle = constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner: vector_inner, - }, - span, - ); - crate::ConstantInner::Composite { - ty, - components: vec![vector_handle; columns as usize], - } - } - crate::TypeInner::Struct { ref members, .. } => { - let mut components = Vec::with_capacity(members.len()); - // copy out the types to avoid borrowing `members` - let member_tys = members.iter().map(|member| member.ty).collect::>(); - for member_ty in member_tys { - let inner = generate_null_constant(member_ty, type_arena, constant_arena, span)?; - components.push(constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner, - }, - span, - )); - } - crate::ConstantInner::Composite { ty, components } - } - crate::TypeInner::Array { - base, - size: crate::ArraySize::Constant(size), - .. - } => { - let inner = generate_null_constant(base, type_arena, constant_arena, span)?; - let value = constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner, - }, - span, - ); - crate::ConstantInner::Composite { - ty, - components: vec![value; size.get() as usize], - } - } - ref other => { - log::warn!("null constant type {:?}", other); - return Err(Error::UnsupportedType(ty)); - } - }; - Ok(inner) -} +use crate::arena::{Arena, Handle}; /// Create a default value for an output built-in. pub fn generate_default_built_in( built_in: Option, ty: Handle, - type_arena: &UniqueArena, - constant_arena: &mut Arena, + const_expressions: &mut Arena, span: crate::Span, -) -> Result, Error> { - let inner = match built_in { +) -> Result, Error> { + let expr = match built_in { Some(crate::BuiltIn::Position { .. }) => { - let zero = constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Scalar { - value: crate::ScalarValue::Float(0.0), - width: 4, - }, - }, - span, - ); - let one = constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Scalar { - value: crate::ScalarValue::Float(1.0), - width: 4, - }, - }, - span, - ); - crate::ConstantInner::Composite { + let zero = const_expressions + .append(crate::Expression::Literal(crate::Literal::F32(0.0)), span); + let one = const_expressions + .append(crate::Expression::Literal(crate::Literal::F32(1.0)), span); + crate::Expression::Compose { ty, components: vec![zero, zero, zero, one], } } - Some(crate::BuiltIn::PointSize) => crate::ConstantInner::Scalar { - value: crate::ScalarValue::Float(1.0), - width: 4, - }, - Some(crate::BuiltIn::FragDepth) => crate::ConstantInner::Scalar { - value: crate::ScalarValue::Float(0.0), - width: 4, - }, - Some(crate::BuiltIn::SampleMask) => crate::ConstantInner::Scalar { - value: crate::ScalarValue::Uint(u64::MAX), - width: 4, - }, - //Note: `crate::BuiltIn::ClipDistance` is intentionally left for the default path - _ => generate_null_constant(ty, type_arena, constant_arena, span)?, + Some(crate::BuiltIn::PointSize) => crate::Expression::Literal(crate::Literal::F32(1.0)), + Some(crate::BuiltIn::FragDepth) => crate::Expression::Literal(crate::Literal::F32(0.0)), + Some(crate::BuiltIn::SampleMask) => { + crate::Expression::Literal(crate::Literal::U32(u32::MAX)) + } + // Note: `crate::BuiltIn::ClipDistance` is intentionally left for the default path + _ => crate::Expression::ZeroValue(ty), }; - Ok(constant_arena.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner, - }, - span, - )) + Ok(const_expressions.append(expr, span)) } diff --git a/src/front/wgsl/error.rs b/src/front/wgsl/error.rs index dc9a3b178d..701eca992b 100644 --- a/src/front/wgsl/error.rs +++ b/src/front/wgsl/error.rs @@ -100,8 +100,6 @@ pub enum ExpectedToken<'a> { Identifier, Number, Integer, - /// A compile-time constant expression. - Constant, /// Expected: constant, parenthesized expression, identifier PrimaryExpression, /// Expected: assignment, increment/decrement expression @@ -141,6 +139,7 @@ pub enum InvalidAssignmentType { pub enum Error<'a> { Unexpected(Span, ExpectedToken<'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. @@ -227,7 +226,6 @@ pub enum Error<'a> { /// the same identifier as `ident`, above. path: Vec<(Span, Span)>, }, - ConstExprUnsupported(Span), InvalidSwitchValue { uint: bool, span: Span, @@ -273,7 +271,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::Constant => "compile-time constant".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(), @@ -297,6 +294,11 @@ impl<'a> Error<'a> { labels: vec![(bad_span, "unexpected components".into())], notes: vec![], }, + Error::UnexpectedOperationInConstContext(span) => ParseError { + message: "this operation is not supported in a const context".to_string(), + labels: vec![(span, "operation not supported here".into())], + notes: vec![], + }, Error::BadNumber(bad_span, ref err) => ParseError { message: format!("{}: `{}`", err, &source[bad_span],), labels: vec![(bad_span, err.to_string().into())], @@ -625,14 +627,6 @@ impl<'a> Error<'a> { .collect(), notes: vec![], }, - Error::ConstExprUnsupported(span) => ParseError { - message: "this constant expression is not supported".to_string(), - labels: vec![(span, "expression is not supported".into())], - notes: vec![ - "this should be fixed in a future version of Naga".into(), - "https://github.com/gfx-rs/naga/issues/1829".into(), - ], - }, Error::InvalidSwitchValue { uint, span } => ParseError { message: "invalid switch value".to_string(), labels: vec![( @@ -701,7 +695,7 @@ impl<'a> Error<'a> { }, Error::NonPositiveArrayLength(span) => ParseError { message: "array element count must be greater than zero".to_string(), - labels: vec![(span, "must be positive".into())], + labels: vec![(span, "must be greater than zero".into())], notes: vec![], }, } diff --git a/src/front/wgsl/lower/construction.rs b/src/front/wgsl/lower/construction.rs index 8d7a5cdc2e..3b4830b058 100644 --- a/src/front/wgsl/lower/construction.rs +++ b/src/front/wgsl/lower/construction.rs @@ -4,7 +4,7 @@ use crate::front::wgsl::parse::ast; use crate::{Handle, Span}; use crate::front::wgsl::error::Error; -use crate::front::wgsl::lower::{ExpressionContext, Lowerer, OutputContext}; +use crate::front::wgsl::lower::{ExpressionContext, Lowerer}; use crate::proc::TypeResolution; enum ConcreteConstructorHandle { @@ -145,7 +145,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { components: &[Handle>], mut ctx: ExpressionContext<'source, '_, '_>, ) -> Result, Error<'source>> { - let constructor_h = self.constructor(constructor, ctx.as_output())?; + let constructor_h = self.constructor(constructor, ctx.reborrow())?; let components_h = match *components { [] => ComponentsHandle::None, @@ -153,7 +153,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let span = ctx.ast_expressions.get_span(component); let component = self.expression(component, ctx.reborrow())?; ctx.grow_types(component)?; - let ty = &ctx.typifier[component]; + let ty = &ctx.typifier()[component]; ComponentsHandle::One { component, @@ -179,7 +179,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .collect(); ctx.grow_types(component)?; - let ty = &ctx.typifier[component]; + let ty = &ctx.typifier()[component]; ComponentsHandle::Many { components, @@ -195,14 +195,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ); let expr = match (components, constructor) { // Empty constructor - (Components::None, dst_ty) => { - let ty = match dst_ty { - ConcreteConstructor::Type(ty, _) => ty, - _ => return Err(Error::TypeNotInferrable(ty_span)), - }; - - return Ok(ctx.interrupt_emitter(crate::Expression::ZeroValue(ty), span)); - } + (Components::None, dst_ty) => match dst_ty { + ConcreteConstructor::Type(ty, _) => { + return Ok(ctx.interrupt_emitter(crate::Expression::ZeroValue(ty), span)) + } + _ => return Err(Error::TypeNotInferrable(ty_span)), + }, // Scalar constructor & conversion (scalar -> scalar) ( @@ -402,7 +400,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let components = components .chunks(rows as usize) .map(|vec_components| { - ctx.naga_expressions.append( + ctx.append_expression( crate::Expression::Compose { ty: vec_ty, components: Vec::from(vec_components), @@ -525,55 +523,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { _ => return Err(Error::TypeNotConstructible(ty_span)), }; - let expr = ctx.naga_expressions.append(expr, span); + let expr = ctx.append_expression(expr, span); Ok(expr) } - /// Build a Naga IR [`ConstantInner`] given a WGSL construction expression. - /// - /// Given `constructor`, representing the head of a WGSL [`type constructor - /// expression`], and a slice of [`ast::Expression`] handles representing - /// the constructor's arguments, build a Naga [`ConstantInner`] value - /// representing the given value. - /// - /// If `constructor` is for a composite type, this may entail adding new - /// [`Type`]s and [`Constant`]s to [`ctx.module`], if it doesn't already - /// have what we need. - /// - /// If the arguments cannot be evaluated at compile time, return an error. - /// - /// [`ConstantInner`]: crate::ConstantInner - /// [`type constructor expression`]: https://gpuweb.github.io/gpuweb/wgsl/#type-constructor-expr - /// [`Function::expressions`]: ast::Function::expressions - /// [`TranslationUnit::global_expressions`]: ast::TranslationUnit::global_expressions - /// [`Type`]: crate::Type - /// [`Constant`]: crate::Constant - /// [`ctx.module`]: OutputContext::module - pub fn const_construct( - &mut self, - span: Span, - constructor: &ast::ConstructorType<'source>, - components: &[Handle>], - mut ctx: OutputContext<'source, '_, '_>, - ) -> Result> { - // TODO: Support zero values, splatting and inference. - - let constructor = self.constructor(constructor, ctx.reborrow())?; - - let c = match constructor { - ConcreteConstructorHandle::Type(ty) => { - let components = components - .iter() - .map(|&expr| self.constant(expr, ctx.reborrow())) - .collect::>()?; - - crate::ConstantInner::Composite { ty, components } - } - _ => return Err(Error::ConstExprUnsupported(span)), - }; - Ok(c) - } - /// Build a Naga IR [`Type`] for `constructor` if there is enough /// information to do so. /// @@ -591,13 +544,13 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { /// array's length. /// /// [`Type`]: crate::Type - /// [`ctx.module`]: OutputContext::module + /// [`ctx.module`]: ExpressionContext::module /// [`Array`]: crate::TypeInner::Array /// [`Constant`]: crate::Constant fn constructor<'out>( &mut self, constructor: &ast::ConstructorType<'source>, - mut ctx: OutputContext<'source, '_, 'out>, + mut ctx: ExpressionContext<'source, '_, 'out>, ) -> Result> { let c = match *constructor { ast::ConstructorType::Scalar { width, kind } => { @@ -628,17 +581,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } ast::ConstructorType::PartialArray => ConcreteConstructorHandle::PartialArray, ast::ConstructorType::Array { base, size } => { - let base = self.resolve_ast_type(base, ctx.reborrow())?; + let base = self.resolve_ast_type(base, ctx.as_global())?; let size = match size { ast::ArraySize::Constant(expr) => { - let span = ctx.ast_expressions.get_span(expr); - let constant = self.constant(expr, ctx.reborrow())?; - let size = ctx.module.constants[constant] - .to_array_length() - .ok_or(Error::ExpectedArraySize(span))?; - let size = - NonZeroU32::new(size).ok_or(Error::NonPositiveArrayLength(span))?; - crate::ArraySize::Constant(size) + let const_expr = self.expression(expr, ctx.as_const())?; + crate::ArraySize::Constant(ctx.array_length(const_expr)?) } ast::ArraySize::Dynamic => crate::ArraySize::Dynamic, }; diff --git a/src/front/wgsl/lower/mod.rs b/src/front/wgsl/lower/mod.rs index 0de078353b..cf52d6ce80 100644 --- a/src/front/wgsl/lower/mod.rs +++ b/src/front/wgsl/lower/mod.rs @@ -12,7 +12,7 @@ use indexmap::IndexMap; mod construction; /// State for constructing a `crate::Module`. -pub struct OutputContext<'source, 'temp, 'out> { +pub struct GlobalContext<'source, 'temp, 'out> { /// The `TranslationUnit`'s expressions arena. ast_expressions: &'temp Arena>, @@ -26,15 +26,29 @@ pub struct OutputContext<'source, 'temp, 'out> { /// The module we're constructing. module: &'out mut crate::Module, + + const_typifier: &'temp mut Typifier, } -impl<'source> OutputContext<'source, '_, '_> { - fn reborrow(&mut self) -> OutputContext<'source, '_, '_> { - OutputContext { +impl<'source> GlobalContext<'source, '_, '_> { + fn reborrow(&mut self) -> GlobalContext<'source, '_, '_> { + GlobalContext { ast_expressions: self.ast_expressions, globals: self.globals, types: self.types, module: self.module, + const_typifier: self.const_typifier, + } + } + + fn as_const(&mut self) -> ExpressionContext<'source, '_, '_> { + ExpressionContext { + ast_expressions: self.ast_expressions, + globals: self.globals, + types: self.types, + module: self.module, + const_typifier: self.const_typifier, + expr_type: ExpressionContextType::Constant, } } @@ -74,6 +88,7 @@ pub struct StatementContext<'source, 'temp, 'out> { /// [`FunctionArgument`]: crate::Expression::FunctionArgument local_table: &'temp mut FastHashMap, TypedExpression>, + const_typifier: &'temp mut Typifier, typifier: &'temp mut Typifier, variables: &'out mut Arena, naga_expressions: &'out mut Arena, @@ -91,6 +106,7 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { globals: self.globals, types: self.types, ast_expressions: self.ast_expressions, + const_typifier: self.const_typifier, typifier: self.typifier, variables: self.variables, naga_expressions: self.naga_expressions, @@ -109,26 +125,30 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { 'temp: 't, { ExpressionContext { - local_table: self.local_table, globals: self.globals, types: self.types, ast_expressions: self.ast_expressions, - typifier: self.typifier, - naga_expressions: self.naga_expressions, + const_typifier: self.const_typifier, module: self.module, - local_vars: self.variables, - arguments: self.arguments, - block, - emitter, + expr_type: ExpressionContextType::Runtime(RuntimeExpressionContext { + local_table: self.local_table, + naga_expressions: self.naga_expressions, + local_vars: self.variables, + arguments: self.arguments, + typifier: self.typifier, + block, + emitter, + }), } } - fn as_output(&mut self) -> OutputContext<'a, '_, '_> { - OutputContext { + fn as_global(&mut self) -> GlobalContext<'a, '_, '_> { + GlobalContext { ast_expressions: self.ast_expressions, globals: self.globals, types: self.types, module: self.module, + const_typifier: self.const_typifier, } } @@ -146,12 +166,92 @@ impl<'a, 'temp> StatementContext<'a, 'temp, '_> { } } -/// State for lowering an `ast::Expression` to Naga IR. +pub struct RuntimeExpressionContext<'temp, 'out> { + local_table: &'temp mut FastHashMap, TypedExpression>, + + naga_expressions: &'out mut Arena, + local_vars: &'out Arena, + arguments: &'out [crate::FunctionArgument], + block: &'temp mut crate::Block, + emitter: &'temp mut Emitter, + typifier: &'temp mut Typifier, +} + +impl RuntimeExpressionContext<'_, '_> { + fn reborrow(&mut self) -> RuntimeExpressionContext<'_, '_> { + RuntimeExpressionContext { + local_table: self.local_table, + naga_expressions: self.naga_expressions, + local_vars: self.local_vars, + arguments: self.arguments, + block: self.block, + emitter: self.emitter, + typifier: self.typifier, + } + } +} + +/// The type of Naga IR expression we are lowering an [`ast::Expression`] to. +pub enum ExpressionContextType<'temp, 'out> { + /// We are lowering to an arbitrary runtime expression, to be + /// included in a function's body. + /// + /// The given [`RuntimeExpressionContext`] holds information about local + /// variables, arguments, and other definitions available only to runtime + /// expressions, not constant or override expressions. + Runtime(RuntimeExpressionContext<'temp, 'out>), + + /// We are lowering to a constant expression, to be included in the module's + /// constant expression arena. + /// + /// Everything constant expressions are allowed to refer to is + /// available in the [`ExpressionContext`], so this variant + /// carries no further information. + Constant, +} + +/// State for lowering an [`ast::Expression`] to Naga IR. +/// +/// [`ExpressionContext`]s come in two kinds, distinguished by +/// the value of the [`expr_type`] field: +/// +/// - A [`Runtime`] context contributes [`naga::Expression`]s to a [`naga::Function`]'s +/// runtime expression arena. +/// +/// - A [`Constant`] context contributes [`naga::Expression`]s to a [`naga::Module`]'s +/// constant expression arena. +/// +/// [`ExpressionContext`]s are constructed in restricted ways: +/// +/// - To get a [`Runtime`] [`ExpressionContext`], call +/// [`StatementContext::as_expression`]. /// -/// Not to be confused with `parser::ExpressionContext`. +/// - To get a [`Constant`] [`ExpressionContext`], call +/// [`GlobalContext::as_const`]. +/// +/// - You can demote a [`Runtime`] context to a [`Constant`] context +/// by calling [`as_const`], but there's no way to go in the other +/// direction, producing a runtime context from a constant one. This +/// is because runtime expressions can refer to constant +/// expressions, via [`Expression::Constant`], but constant +/// expressions can't refer to a function's expressions. +/// +/// - You can always call [`ExpressionContext::reborrow`] to get a fresh context +/// for a recursive call. The reborrowed context is equivalent to the original. +/// +/// Not to be confused with `wgsl::parse::ExpressionContext`, which is +/// for parsing the `ast::Expression` in the first place. +/// +/// [`expr_type`]: ExpressionContext::expr_type +/// [`Runtime`]: ExpressionContextType::Runtime +/// [`naga::Expression`]: crate::Expression +/// [`naga::Function`]: crate::Function +/// [`Constant`]: ExpressionContextType::Constant +/// [`naga::Module`]: crate::Module +/// [`as_const`]: ExpressionContext::as_const +/// [`Expression::Constant`]: crate::Expression::Constant pub struct ExpressionContext<'source, 'temp, 'out> { // WGSL AST values. - local_table: &'temp mut FastHashMap, TypedExpression>, ast_expressions: &'temp Arena>, types: &'temp Arena>, @@ -160,38 +260,140 @@ pub struct ExpressionContext<'source, 'temp, 'out> { /// `Handle`s we have built for them, owned by `Lowerer::lower`. globals: &'temp mut FastHashMap<&'source str, LoweredGlobalDecl>, - typifier: &'temp mut Typifier, - naga_expressions: &'out mut Arena, - local_vars: &'out Arena, - arguments: &'out [crate::FunctionArgument], + /// The IR [`Module`] we're constructing. + /// + /// [`Module`]: crate::Module module: &'out mut crate::Module, - block: &'temp mut crate::Block, - emitter: &'temp mut Emitter, + + /// Type judgments for [`module::const_expressions`]. + /// + /// [`module::const_expressions`]: crate::Module::const_expressions + const_typifier: &'temp mut Typifier, + + /// Whether we are lowering a constant expression or a general + /// runtime expression, and the data needed in each case. + expr_type: ExpressionContextType<'temp, 'out>, } -impl<'a> ExpressionContext<'a, '_, '_> { - fn reborrow(&mut self) -> ExpressionContext<'a, '_, '_> { +impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> { + fn reborrow(&mut self) -> ExpressionContext<'source, '_, '_> { ExpressionContext { - local_table: self.local_table, globals: self.globals, types: self.types, ast_expressions: self.ast_expressions, - typifier: self.typifier, - naga_expressions: self.naga_expressions, + const_typifier: self.const_typifier, module: self.module, - local_vars: self.local_vars, - arguments: self.arguments, - block: self.block, - emitter: self.emitter, + expr_type: match self.expr_type { + ExpressionContextType::Runtime(ref mut c) => { + ExpressionContextType::Runtime(c.reborrow()) + } + ExpressionContextType::Constant => ExpressionContextType::Constant, + }, + } + } + + fn as_const(&mut self) -> ExpressionContext<'source, '_, '_> { + ExpressionContext { + globals: self.globals, + types: self.types, + ast_expressions: self.ast_expressions, + const_typifier: self.const_typifier, + module: self.module, + expr_type: ExpressionContextType::Constant, } } - fn as_output(&mut self) -> OutputContext<'a, '_, '_> { - OutputContext { + fn as_global(&mut self) -> GlobalContext<'source, '_, '_> { + GlobalContext { ast_expressions: self.ast_expressions, globals: self.globals, types: self.types, module: self.module, + const_typifier: self.const_typifier, + } + } + + fn append_expression( + &mut self, + expr: crate::Expression, + span: Span, + ) -> Handle { + match self.expr_type { + ExpressionContextType::Runtime(ref mut ctx) => ctx.naga_expressions.append(expr, span), + ExpressionContextType::Constant => self.module.const_expressions.append(expr, span), + } + } + + fn get_expression(&self, handle: Handle) -> &crate::Expression { + match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => &ctx.naga_expressions[handle], + ExpressionContextType::Constant => &self.module.const_expressions[handle], + } + } + + fn get_expression_span(&self, handle: Handle) -> Span { + match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => ctx.naga_expressions.get_span(handle), + ExpressionContextType::Constant => self.module.const_expressions.get_span(handle), + } + } + + fn typifier(&self) -> &Typifier { + match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => ctx.typifier, + ExpressionContextType::Constant => self.const_typifier, + } + } + + fn runtime_expression_ctx( + &mut self, + span: Span, + ) -> Result, Error<'source>> { + match self.expr_type { + ExpressionContextType::Runtime(ref mut ctx) => Ok(ctx.reborrow()), + ExpressionContextType::Constant => Err(Error::UnexpectedOperationInConstContext(span)), + } + } + + 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, + expr: Handle, + gather_span: Span, + ) -> Result> { + match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => { + let expr_span = ctx.naga_expressions.get_span(expr); + let index = self + .module + .to_ctx() + .eval_expr_to_u32_from(expr, ctx.naga_expressions) + .map_err(|_| Error::InvalidGatherComponent(expr_span))?; + crate::SwizzleComponent::XYZW + .get(index as usize) + .copied() + .ok_or(Error::InvalidGatherComponent(expr_span)) + } + // This means a `gather` operation appeared in a constant expression. + // This error refers to the `gather` itself, not its "component" argument. + ExpressionContextType::Constant => { + Err(Error::UnexpectedOperationInConstContext(gather_span)) + } } } @@ -210,9 +412,16 @@ impl<'a> ExpressionContext<'a, '_, '_> { fn register_type( &mut self, handle: Handle, - ) -> Result, Error<'a>> { + ) -> Result, Error<'source>> { self.grow_types(handle)?; - Ok(self.typifier.register_type(handle, &mut self.module.types)) + // This is equivalent to calling ExpressionContext::typifier(), + // except that this lets the borrow checker see that it's okay + // to also borrow self.module.types mutably below. + let typifier = match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => ctx.typifier, + ExpressionContextType::Constant => &*self.const_typifier, + }; + Ok(typifier.register_type(handle, &mut self.module.types)) } /// Resolve the types of all expressions up through `handle`. @@ -235,23 +444,43 @@ impl<'a> ExpressionContext<'a, '_, '_> { /// [`self.typifier`]: ExpressionContext::typifier /// [`self.resolved_inner(handle)`]: ExpressionContext::resolved_inner /// [`Typifier`]: Typifier - fn grow_types(&mut self, handle: Handle) -> Result<&mut Self, Error<'a>> { - let resolve_ctx = ResolveContext::with_locals(self.module, self.local_vars, self.arguments); - self.typifier - .grow(handle, self.naga_expressions, &resolve_ctx) + fn grow_types( + &mut self, + handle: Handle, + ) -> Result<&mut Self, Error<'source>> { + let empty_arena = Arena::new(); + let resolve_ctx = match self.expr_type { + ExpressionContextType::Runtime(ref ctx) => { + ResolveContext::with_locals(self.module, ctx.local_vars, ctx.arguments) + } + ExpressionContextType::Constant => { + ResolveContext::with_locals(self.module, &empty_arena, &[]) + } + }; + let (typifier, expressions) = match self.expr_type { + ExpressionContextType::Runtime(ref mut ctx) => { + (&mut *ctx.typifier, &*ctx.naga_expressions) + } + ExpressionContextType::Constant => { + (&mut *self.const_typifier, &self.module.const_expressions) + } + }; + typifier + .grow(handle, expressions, &resolve_ctx) .map_err(Error::InvalidResolve)?; + Ok(self) } fn resolved_inner(&self, handle: Handle) -> &crate::TypeInner { - self.typifier[handle].inner_with(&self.module.types) + self.typifier()[handle].inner_with(&self.module.types) } fn image_data( &mut self, image: Handle, span: Span, - ) -> Result<(crate::ImageClass, bool), Error<'a>> { + ) -> Result<(crate::ImageClass, bool), Error<'source>> { self.grow_types(image)?; match *self.resolved_inner(image) { crate::TypeInner::Image { class, arrayed, .. } => Ok((class, arrayed)), @@ -261,10 +490,10 @@ impl<'a> ExpressionContext<'a, '_, '_> { fn prepare_args<'b>( &mut self, - args: &'b [Handle>], + args: &'b [Handle>], min_args: u32, span: Span, - ) -> ArgumentContext<'b, 'a> { + ) -> ArgumentContext<'b, 'source> { ArgumentContext { args: args.iter(), min_args, @@ -280,7 +509,7 @@ impl<'a> ExpressionContext<'a, '_, '_> { op: crate::BinaryOperator, left: &mut Handle, right: &mut Handle, - ) -> Result<(), Error<'a>> { + ) -> Result<(), Error<'source>> { if op != crate::BinaryOperator::Multiply { self.grow_types(*left)?.grow_types(*right)?; @@ -291,18 +520,18 @@ impl<'a> ExpressionContext<'a, '_, '_> { match (left_size, self.resolved_inner(*right)) { (Some(size), &crate::TypeInner::Scalar { .. }) => { - *right = self.naga_expressions.append( + *right = self.append_expression( crate::Expression::Splat { size, value: *right, }, - self.naga_expressions.get_span(*right), + self.get_expression_span(*right), ); } (None, &crate::TypeInner::Vector { size, .. }) => { - *left = self.naga_expressions.append( + *left = self.append_expression( crate::Expression::Splat { size, value: *left }, - self.naga_expressions.get_span(*left), + self.get_expression_span(*left), ); } _ => {} @@ -321,10 +550,20 @@ impl<'a> ExpressionContext<'a, '_, '_> { expression: crate::Expression, span: Span, ) -> Handle { - self.block - .extend(self.emitter.finish(self.naga_expressions)); - let result = self.naga_expressions.append(expression, span); - self.emitter.start(self.naga_expressions); + match self.expr_type { + ExpressionContextType::Runtime(ref mut rctx) => { + rctx.block + .extend(rctx.emitter.finish(rctx.naga_expressions)); + } + ExpressionContextType::Constant => {} + } + let result = self.append_expression(expression, span); + match self.expr_type { + ExpressionContextType::Runtime(ref mut rctx) => { + rctx.emitter.start(rctx.naga_expressions); + } + ExpressionContextType::Constant => {} + } result } @@ -337,8 +576,8 @@ impl<'a> ExpressionContext<'a, '_, '_> { let load = crate::Expression::Load { pointer: expr.handle, }; - let span = self.naga_expressions.get_span(expr.handle); - self.naga_expressions.append(load, span) + let span = self.get_expression_span(expr.handle); + self.append_expression(load, span) } else { expr.handle } @@ -364,7 +603,7 @@ impl<'a> ExpressionContext<'a, '_, '_> { } fn ensure_type_exists(&mut self, inner: crate::TypeInner) -> Handle { - self.as_output().ensure_type_exists(inner) + self.as_global().ensure_type_exists(inner) } } @@ -485,11 +724,6 @@ enum LoweredGlobalDecl { EntryPoint, } -enum ConstantOrInner { - Constant(Handle), - Inner(crate::ConstantInner), -} - enum Texture { Gather, GatherCompare, @@ -555,11 +789,12 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ) -> Result> { let mut module = crate::Module::default(); - let mut ctx = OutputContext { + let mut ctx = GlobalContext { ast_expressions: &tu.expressions, globals: &mut FastHashMap::default(), types: &tu.types, module: &mut module, + const_typifier: &mut Typifier::new(), }; for decl_handle in self.index.visit_ordered() { @@ -576,7 +811,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let init = v .init - .map(|init| self.constant(init, ctx.reborrow())) + .map(|init| self.expression(init, ctx.as_const())) .transpose()?; let handle = ctx.module.global_variables.append( @@ -594,30 +829,9 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .insert(v.name.name, LoweredGlobalDecl::Var(handle)); } ast::GlobalDeclKind::Const(ref c) => { - let inner = self.constant_inner(c.init, ctx.reborrow())?; - let inner = match inner { - ConstantOrInner::Constant(c) => ctx.module.constants[c].inner.clone(), - ConstantOrInner::Inner(inner) => inner, - }; - - let inferred_type = match inner { - crate::ConstantInner::Scalar { width, value } => { - ctx.ensure_type_exists(crate::TypeInner::Scalar { - width, - kind: value.scalar_kind(), - }) - } - crate::ConstantInner::Composite { ty, .. } => ty, - }; - - let handle = ctx.module.constants.append( - crate::Constant { - name: Some(c.name.name.to_string()), - specialization: None, - inner, - }, - span, - ); + let mut ectx = ctx.as_const(); + let init = self.expression(c.init, ectx.reborrow())?; + let inferred_type = ectx.register_type(init)?; let explicit_ty = c.ty.map(|ty| self.resolve_ast_type(ty, ctx.reborrow())) @@ -645,6 +859,16 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } } + let handle = ctx.module.constants.append( + crate::Constant { + name: Some(c.name.name.to_string()), + r#override: crate::Override::None, + ty: inferred_type, + init, + }, + span, + ); + ctx.globals .insert(c.name.name, LoweredGlobalDecl::Const(handle)); } @@ -668,7 +892,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { &mut self, f: &ast::Function<'source>, span: Span, - mut ctx: OutputContext<'source, '_, '_>, + mut ctx: GlobalContext<'source, '_, '_>, ) -> Result> { let mut local_table = FastHashMap::default(); let mut local_variables = Arena::new(); @@ -713,6 +937,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { local_table: &mut local_table, globals: ctx.globals, ast_expressions: ctx.ast_expressions, + const_typifier: ctx.const_typifier, typifier: &mut typifier, variables: &mut local_variables, naga_expressions: &mut expressions, @@ -785,7 +1010,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let value = self.expression(l.init, ctx.as_expression(block, &mut emitter))?; let explicit_ty = - l.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_output())) + l.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_global())) .transpose()?; if let Some(ty) = explicit_ty { @@ -827,7 +1052,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }; let explicit_ty = - v.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_output())) + v.ty.map(|ty| self.resolve_ast_type(ty, ctx.as_global())) .transpose()?; let ty = match (explicit_ty, initializer) { @@ -1021,7 +1246,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let mut ctx = ctx.as_expression(block, &mut emitter); let mut left = ctx.apply_load_rule(expr); ctx.binary_op_splat(op, &mut left, &mut value)?; - ctx.naga_expressions.append( + ctx.append_expression( crate::Expression::Binary { op, left, @@ -1068,32 +1293,24 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }, _ => return Err(Error::BadIncrDecrReferenceType(value_span)), }; - let constant_inner = crate::ConstantInner::Scalar { - width, - value: match kind { - crate::ScalarKind::Sint => crate::ScalarValue::Sint(1), - crate::ScalarKind::Uint => crate::ScalarValue::Uint(1), - _ => return Err(Error::BadIncrDecrReferenceType(value_span)), - }, + let literal = match kind { + crate::ScalarKind::Sint | crate::ScalarKind::Uint => { + crate::Literal::one(kind, width) + .ok_or(Error::BadIncrDecrReferenceType(value_span))? + } + _ => return Err(Error::BadIncrDecrReferenceType(value_span)), }; - let constant = ectx.module.constants.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner: constant_inner, - }, - Span::UNDEFINED, - ); - let left = ectx.naga_expressions.append( + let right = + 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 { pointer: reference.handle, }, value_span, ); - let right = - ectx.interrupt_emitter(crate::Expression::Constant(constant), Span::UNDEFINED); - let value = ectx + let value = rctx .naga_expressions .append(crate::Expression::Binary { op, left, right }, stmt.span); @@ -1150,7 +1367,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { return Ok(TypedExpression::non_reference(handle)); } ast::Expression::Ident(ast::IdentExpr::Local(local)) => { - return Ok(ctx.local_table[&local]) + let rctx = ctx.runtime_expression_ctx(span)?; + return Ok(rctx.local_table[&local]); } ast::Expression::Ident(ast::IdentExpr::Unresolved(name)) => { return if let Some(global) = ctx.globals.get(name) { @@ -1248,54 +1466,31 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { )); } - match ctx.naga_expressions[index] { - crate::Expression::Constant(constant) => { - let span = ctx.naga_expressions.get_span(index); - let index = match ctx.module.constants[constant].inner { - crate::ConstantInner::Scalar { - value: crate::ScalarValue::Uint(int), - .. - } => u32::try_from(int).map_err(|_| Error::BadU32Constant(span)), - crate::ConstantInner::Scalar { - value: crate::ScalarValue::Sint(int), - .. - } => u32::try_from(int).map_err(|_| Error::BadU32Constant(span)), - _ => Err(Error::BadU32Constant(span)), - }?; - - ( - crate::Expression::AccessIndex { - base: expr.handle, - index, - }, - expr.is_reference, - ) - } - crate::Expression::Literal(literal) => { - let span = ctx.naga_expressions.get_span(index); - let index = match literal { - crate::Literal::U32(n) => n, - crate::Literal::I32(n) => { - u32::try_from(n).map_err(|_| Error::BadU32Constant(span))? - } - _ => return Err(Error::BadU32Constant(span)), - }; + 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)), + }?; - ( - crate::Expression::AccessIndex { - base: expr.handle, - index, - }, - expr.is_reference, - ) - } - _ => ( + ( + crate::Expression::AccessIndex { + base: expr.handle, + index, + }, + expr.is_reference, + ) + } else { + ( crate::Expression::Access { base: expr.handle, index, }, expr.is_reference, - ), + ) } } ast::Expression::Member { base, ref field } => { @@ -1387,13 +1582,13 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } ast::Expression::Bitcast { expr, to, ty_span } => { let expr = self.expression(expr, ctx.reborrow())?; - let to_resolved = self.resolve_ast_type(to, ctx.as_output())?; + let to_resolved = self.resolve_ast_type(to, ctx.as_global())?; let kind = match ctx.module.types[to_resolved].inner { crate::TypeInner::Scalar { kind, .. } => kind, crate::TypeInner::Vector { kind, .. } => kind, _ => { - let ty = &ctx.typifier[expr]; + let ty = &ctx.typifier()[expr]; return Err(Error::BadTypeCast { from_type: ctx.format_type_resolution(ty), span: ty_span, @@ -1413,7 +1608,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; - let handle = ctx.naga_expressions.append(expr, span); + let handle = ctx.append_expression(expr, span); Ok(TypedExpression { handle, is_reference, @@ -1466,13 +1661,17 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { .map(|&arg| self.expression(arg, ctx.reborrow())) .collect::, _>>()?; - ctx.block.extend(ctx.emitter.finish(ctx.naga_expressions)); - let result = ctx.module.functions[function].result.is_some().then(|| { - ctx.naga_expressions + let has_result = ctx.module.functions[function].result.is_some(); + let rctx = ctx.runtime_expression_ctx(span)?; + // we need to always do this before a fn call since all arguments need to be emitted before the fn call + rctx.block + .extend(rctx.emitter.finish(rctx.naga_expressions)); + let result = has_result.then(|| { + rctx.naga_expressions .append(crate::Expression::CallResult(function), span) }); - ctx.emitter.start(ctx.naga_expressions); - ctx.block.push( + rctx.emitter.start(rctx.naga_expressions); + rctx.block.push( crate::Statement::Call { function, arguments, @@ -1566,9 +1765,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let value = self.expression(args.next()?, ctx.reborrow())?; args.finish()?; - ctx.block.extend(ctx.emitter.finish(ctx.naga_expressions)); - ctx.emitter.start(ctx.naga_expressions); - ctx.block + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block + .extend(rctx.emitter.finish(rctx.naga_expressions)); + rctx.emitter.start(rctx.naga_expressions); + rctx.block .push(crate::Statement::Store { pointer, value }, span); return Ok(None); } @@ -1664,7 +1865,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }; let result = ctx.interrupt_emitter(expression, span); - ctx.block.push( + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block.push( crate::Statement::Atomic { pointer, fun: crate::AtomicFunction::Exchange { @@ -1680,14 +1882,16 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { "storageBarrier" => { ctx.prepare_args(arguments, 0, span).finish()?; - ctx.block + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block .push(crate::Statement::Barrier(crate::Barrier::STORAGE), span); return Ok(None); } "workgroupBarrier" => { ctx.prepare_args(arguments, 0, span).finish()?; - ctx.block + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block .push(crate::Statement::Barrier(crate::Barrier::WORK_GROUP), span); return Ok(None); } @@ -1713,7 +1917,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { crate::Expression::WorkGroupUniformLoadResult { ty: result_ty }, span, ); - ctx.block.push( + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block.push( crate::Statement::WorkGroupUniformLoad { pointer, result }, span, ); @@ -1739,15 +1944,17 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { args.finish()?; - ctx.block.extend(ctx.emitter.finish(ctx.naga_expressions)); - ctx.emitter.start(ctx.naga_expressions); + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block + .extend(rctx.emitter.finish(rctx.naga_expressions)); + rctx.emitter.start(rctx.naga_expressions); let stmt = crate::Statement::ImageStore { image, coordinate, array_index, value, }; - ctx.block.push(stmt, span); + rctx.block.push(stmt, span); return Ok(None); } "textureLoad" => { @@ -1843,9 +2050,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { descriptor, }; - ctx.block.extend(ctx.emitter.finish(ctx.naga_expressions)); - ctx.emitter.start(ctx.naga_expressions); - ctx.block + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block + .extend(rctx.emitter.finish(rctx.naga_expressions)); + rctx.emitter.start(rctx.naga_expressions); + rctx.block .push(crate::Statement::RayQuery { query, fun }, span); return Ok(None); } @@ -1854,14 +2063,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let query = self.ray_query_pointer(args.next()?, ctx.reborrow())?; args.finish()?; - ctx.block.extend(ctx.emitter.finish(ctx.naga_expressions)); let result = ctx - .naga_expressions - .append(crate::Expression::RayQueryProceedResult, span); + .interrupt_emitter(crate::Expression::RayQueryProceedResult, span); let fun = crate::RayQueryFunction::Proceed { result }; - - ctx.emitter.start(ctx.naga_expressions); - ctx.block + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block .push(crate::Statement::RayQuery { query, fun }, span); return Ok(Some(result)); } @@ -1892,7 +2098,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { } }; - let expr = ctx.naga_expressions.append(expr, span); + let expr = ctx.append_expression(expr, span); Ok(Some(expr)) } } @@ -1946,7 +2152,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }, span, ); - ctx.block.push( + let rctx = ctx.runtime_expression_ctx(span)?; + rctx.block.push( crate::Statement::Atomic { pointer, fun, @@ -1967,31 +2174,58 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { ) -> Result> { let mut args = ctx.prepare_args(args, fun.min_argument_count(), span); - let (image, gather) = match fun { + fn get_image_and_span<'source>( + lowerer: &mut Lowerer<'source, '_>, + args: &mut ArgumentContext<'_, 'source>, + ctx: &mut ExpressionContext<'source, '_, '_>, + ) -> Result<(Handle, Span), Error<'source>> { + let image = args.next()?; + let image_span = ctx.ast_expressions.get_span(image); + let image = lowerer.expression(image, ctx.reborrow())?; + Ok((image, image_span)) + } + + let (image, image_span, gather) = match fun { Texture::Gather => { let image_or_component = args.next()?; - match self.gather_component(image_or_component, ctx.reborrow())? { - Some(component) => { - let image = args.next()?; - (image, Some(component)) + // Gathers from depth textures don't take an initial `component` argument. + let lowered_image_or_component = + self.expression(image_or_component, ctx.reborrow())?; + + ctx.grow_types(lowered_image_or_component)?; + match *ctx.resolved_inner(lowered_image_or_component) { + 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), + ) + } + _ => { + 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)?), + ) } - None => (image_or_component, Some(crate::SwizzleComponent::X)), } } Texture::GatherCompare => { - let image = args.next()?; - (image, Some(crate::SwizzleComponent::X)) + let (image, image_span) = get_image_and_span(self, &mut args, &mut ctx)?; + (image, image_span, Some(crate::SwizzleComponent::X)) } _ => { - let image = args.next()?; - (image, None) + let (image, image_span) = get_image_and_span(self, &mut args, &mut ctx)?; + (image, image_span, None) } }; - let image_span = ctx.ast_expressions.get_span(image); - let image = self.expression(image, ctx.reborrow())?; - let sampler = self.expression(args.next()?, ctx.reborrow())?; let coordinate = self.expression(args.next()?, ctx.reborrow())?; @@ -2034,7 +2268,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { let offset = args .next() - .map(|arg| self.constant(arg, ctx.as_output())) + .map(|arg| self.expression(arg, ctx.as_const())) .ok() .transpose()?; @@ -2052,45 +2286,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { }) } - fn gather_component( - &mut self, - expr: Handle>, - mut ctx: ExpressionContext<'source, '_, '_>, - ) -> Result, Error<'source>> { - let span = ctx.ast_expressions.get_span(expr); - - let constant = match self.constant_inner(expr, ctx.as_output()).ok() { - Some(ConstantOrInner::Constant(c)) => ctx.module.constants[c].inner.clone(), - Some(ConstantOrInner::Inner(inner)) => inner, - None => return Ok(None), - }; - - let int = match constant { - crate::ConstantInner::Scalar { - value: crate::ScalarValue::Sint(i), - .. - } if i >= 0 => i as u64, - crate::ConstantInner::Scalar { - value: crate::ScalarValue::Uint(i), - .. - } => i, - _ => { - return Err(Error::InvalidGatherComponent(span)); - } - }; - - crate::SwizzleComponent::XYZW - .get(int as usize) - .copied() - .map(Some) - .ok_or(Error::InvalidGatherComponent(span)) - } - fn r#struct( &mut self, s: &ast::Struct<'source>, span: Span, - mut ctx: OutputContext<'source, '_, '_>, + mut ctx: GlobalContext<'source, '_, '_>, ) -> Result, Error<'source>> { let mut offset = 0; let mut struct_alignment = Alignment::ONE; @@ -2163,7 +2363,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { fn resolve_ast_type( &mut self, handle: Handle>, - mut ctx: OutputContext<'source, '_, '_>, + mut ctx: GlobalContext<'source, '_, '_>, ) -> Result, Error<'source>> { let inner = match ctx.types[handle] { ast::Type::Scalar { kind, width } => crate::TypeInner::Scalar { kind, width }, @@ -2192,14 +2392,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { base, size: match size { ast::ArraySize::Constant(constant) => { - let span = ctx.ast_expressions.get_span(constant); - let constant = self.constant(constant, ctx.reborrow())?; - let size = ctx.module.constants[constant] - .to_array_length() - .ok_or(Error::ExpectedArraySize(span))?; - let size = - NonZeroU32::new(size).ok_or(Error::NonPositiveArrayLength(span))?; - crate::ArraySize::Constant(size) + 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, }, @@ -2225,14 +2419,8 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { base, size: match size { ast::ArraySize::Constant(constant) => { - let span = ctx.ast_expressions.get_span(constant); - let constant = self.constant(constant, ctx.reborrow())?; - let size = ctx.module.constants[constant] - .to_array_length() - .ok_or(Error::ExpectedArraySize(span))?; - let size = - NonZeroU32::new(size).ok_or(Error::NonPositiveArrayLength(span))?; - crate::ArraySize::Constant(size) + 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, }, @@ -2256,105 +2444,11 @@ impl<'source, 'temp> Lowerer<'source, 'temp> { Ok(ctx.ensure_type_exists(inner)) } - /// Find or construct a Naga [`Constant`] whose value is `expr`. - /// - /// The `ctx` indicates the Naga [`Module`] to which we should add - /// new `Constant`s or [`Type`]s as needed. - /// - /// [`Module`]: crate::Module - /// [`Constant`]: crate::Constant - /// [`Type`]: crate::Type - fn constant( - &mut self, - expr: Handle>, - mut ctx: OutputContext<'source, '_, '_>, - ) -> Result, Error<'source>> { - let inner = match self.constant_inner(expr, ctx.reborrow())? { - ConstantOrInner::Constant(c) => return Ok(c), - ConstantOrInner::Inner(inner) => inner, - }; - - let c = ctx.module.constants.fetch_or_append( - crate::Constant { - name: None, - specialization: None, - inner, - }, - Span::UNDEFINED, - ); - Ok(c) - } - - fn constant_inner( - &mut self, - expr: Handle>, - mut ctx: OutputContext<'source, '_, '_>, - ) -> Result> { - let span = ctx.ast_expressions.get_span(expr); - let inner = match ctx.ast_expressions[expr] { - ast::Expression::Literal(literal) => match literal { - ast::Literal::Number(Number::F32(f)) => crate::ConstantInner::Scalar { - width: 4, - value: crate::ScalarValue::Float(f as _), - }, - ast::Literal::Number(Number::I32(i)) => crate::ConstantInner::Scalar { - width: 4, - value: crate::ScalarValue::Sint(i as _), - }, - ast::Literal::Number(Number::U32(u)) => crate::ConstantInner::Scalar { - width: 4, - value: crate::ScalarValue::Uint(u as _), - }, - ast::Literal::Number(_) => { - unreachable!("got abstract numeric type when not expected"); - } - ast::Literal::Bool(b) => crate::ConstantInner::Scalar { - width: 1, - value: crate::ScalarValue::Bool(b), - }, - }, - ast::Expression::Ident(ast::IdentExpr::Local(_)) => { - return Err(Error::Unexpected(span, ExpectedToken::Constant)) - } - ast::Expression::Ident(ast::IdentExpr::Unresolved(name)) => { - return if let Some(global) = ctx.globals.get(name) { - match *global { - LoweredGlobalDecl::Const(handle) => Ok(ConstantOrInner::Constant(handle)), - _ => Err(Error::Unexpected(span, ExpectedToken::Constant)), - } - } else { - Err(Error::UnknownIdent(span, name)) - } - } - ast::Expression::Construct { - ref ty, - ref components, - .. - } => self.const_construct(span, ty, components, ctx.reborrow())?, - ast::Expression::Call { - ref function, - ref arguments, - } => match ctx.globals.get(function.name) { - Some(&LoweredGlobalDecl::Type(ty)) => self.const_construct( - span, - &ast::ConstructorType::Type(ty), - arguments, - ctx.reborrow(), - )?, - Some(_) => return Err(Error::ConstExprUnsupported(span)), - None => return Err(Error::UnknownIdent(function.span, function.name)), - }, - _ => return Err(Error::ConstExprUnsupported(span)), - }; - - Ok(ConstantOrInner::Inner(inner)) - } - fn interpolate_default( &mut self, binding: &Option, ty: Handle, - ctx: OutputContext<'source, '_, '_>, + ctx: GlobalContext<'source, '_, '_>, ) -> Option { let mut binding = binding.clone(); if let Some(ref mut binding) = binding { diff --git a/src/front/wgsl/mod.rs b/src/front/wgsl/mod.rs index b60f6fe655..2b471a8a93 100644 --- a/src/front/wgsl/mod.rs +++ b/src/front/wgsl/mod.rs @@ -198,6 +198,7 @@ impl crate::TypeInner { } mod type_inner_tests { + #[test] fn to_wgsl() { use std::num::NonZeroU32; @@ -228,6 +229,7 @@ mod type_inner_tests { let gctx = crate::proc::GlobalCtx { types: &types, constants: &crate::Arena::new(), + const_expressions: &crate::Arena::new(), }; let array = crate::TypeInner::Array { base: mytype1, diff --git a/src/front/wgsl/parse/ast.rs b/src/front/wgsl/parse/ast.rs index 2a56ac6f80..9b7670e4a2 100644 --- a/src/front/wgsl/parse/ast.rs +++ b/src/front/wgsl/parse/ast.rs @@ -107,7 +107,7 @@ pub struct EntryPoint { } #[cfg(doc)] -use crate::front::wgsl::lower::{ExpressionContext, StatementContext}; +use crate::front::wgsl::lower::{RuntimeExpressionContext, StatementContext}; #[derive(Debug)] pub struct Function<'a> { @@ -132,14 +132,14 @@ pub struct Function<'a> { /// During lowering, [`LocalDecl`] statements add entries to a per-function /// table that maps `Handle` values to their Naga representations, /// accessed via [`StatementContext::local_table`] and - /// [`ExpressionContext::local_table`]. This table is then consulted when + /// [`RuntimeExpressionContext::local_table`]. This table is then consulted when /// lowering subsequent [`Ident`] expressions. /// /// [`LocalDecl`]: StatementKind::LocalDecl /// [`arguments`]: Function::arguments /// [`Ident`]: Expression::Ident /// [`StatementContext::local_table`]: StatementContext::local_table - /// [`ExpressionContext::local_table`]: ExpressionContext::local_table + /// [`RuntimeExpressionContext::local_table`]: RuntimeExpressionContext::local_table pub locals: Arena, pub body: Block<'a>, diff --git a/src/front/wgsl/parse/mod.rs b/src/front/wgsl/parse/mod.rs index 8e7abed704..c13ee52775 100644 --- a/src/front/wgsl/parse/mod.rs +++ b/src/front/wgsl/parse/mod.rs @@ -11,7 +11,10 @@ pub mod number; /// State for constructing an AST expression. /// -/// Not to be confused with `lower::ExpressionContext`. +/// Not to be confused with [`lower::ExpressionContext`], which is for producing +/// Naga IR from the AST we produce here. +/// +/// [`lower::ExpressionContext`]: super::lower::ExpressionContext struct ExpressionContext<'input, 'temp, 'out> { /// The [`TranslationUnit::expressions`] arena to which we should contribute /// expressions. diff --git a/src/lib.rs b/src/lib.rs index 1148379c09..a835fec32d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -170,6 +170,35 @@ nested `Block` is not available in the `Block`'s parents. Such a value would need to be stored in a local variable to be carried upwards in the statement tree. +## Constant expressions + +A Naga *constant expression* is one of the following [`Expression`] +variants, whose operands (if any) are also constant expressions: +- [`Literal`] +- [`Constant`], for [`Constant`s][const_type] whose [`override`] is [`None`] +- [`ZeroValue`], for fixed-size types +- [`Compose`] +- [`Access`] +- [`AccessIndex`] +- [`Splat`] +- [`Swizzle`] +- [`Unary`] +- [`Binary`] +- [`Select`] +- [`Relational`] +- [`Math`] +- [`As`] + +A constant expression can be evaluated at module translation time. + +## Override expressions + +A Naga *override expression* is the same as a [constant expression], +except that it is also allowed to refer to [`Constant`s][const_type] +whose [`override`] is something other than [`None`]. + +An override expression can be evaluated at pipeline creation time. + [`AtomicResult`]: Expression::AtomicResult [`RayQueryProceedResult`]: Expression::RayQueryProceedResult [`CallResult`]: Expression::CallResult @@ -194,6 +223,26 @@ tree. [`Validator::validate`]: valid::Validator::validate [`ModuleInfo`]: valid::ModuleInfo + +[`Literal`]: Expression::Literal +[`ZeroValue`]: Expression::ZeroValue +[`Compose`]: Expression::Compose +[`Access`]: Expression::Access +[`AccessIndex`]: Expression::AccessIndex +[`Splat`]: Expression::Splat +[`Swizzle`]: Expression::Swizzle +[`Unary`]: Expression::Unary +[`Binary`]: Expression::Binary +[`Select`]: Expression::Select +[`Relational`]: Expression::Relational +[`Math`]: Expression::Math +[`As`]: Expression::As + +[const_type]: Constant +[`override`]: Constant::override +[`None`]: Override::None + +[constant expression]: index.html#constant-expressions */ #![allow( @@ -796,18 +845,6 @@ pub enum TypeInner { BindingArray { base: Handle, size: ArraySize }, } -/// Constant value. -#[derive(Debug, PartialEq)] -#[cfg_attr(feature = "clone", derive(Clone))] -#[cfg_attr(feature = "serialize", derive(Serialize))] -#[cfg_attr(feature = "deserialize", derive(Deserialize))] -#[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub struct Constant { - pub name: Option, - pub specialization: Option, - pub inner: ConstantInner, -} - #[derive(Debug, Clone, Copy, PartialOrd)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] @@ -820,32 +857,42 @@ pub enum Literal { Bool(bool), } -/// A literal scalar value, used in constants. -#[derive(Debug, Clone, Copy, PartialOrd)] +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "clone", derive(Clone))] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ScalarValue { - Sint(i64), - Uint(u64), - Float(f64), - Bool(bool), +pub enum Override { + None, + ByName, + ByNameOrId(u32), } -/// Additional information, dependent on the kind of constant. -#[derive(Clone, Debug, PartialEq)] +/// Constant value. +#[derive(Debug, PartialEq)] +#[cfg_attr(feature = "clone", derive(Clone))] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] #[cfg_attr(feature = "arbitrary", derive(Arbitrary))] -pub enum ConstantInner { - Scalar { - width: Bytes, - value: ScalarValue, - }, - Composite { - ty: Handle, - components: Vec>, - }, +pub struct Constant { + pub name: Option, + pub r#override: Override, + pub ty: Handle, + + /// The value of the constant. + /// + /// This [`Handle`] refers to [`Module::const_expressions`], not + /// any [`Function::expressions`] arena. + /// + /// If [`override`] is [`None`], then this must be a Naga + /// [constant expression]. Otherwise, this may be a Naga + /// [override expression] or [constant expression]. + /// + /// [`override`]: Constant::override + /// [`None`]: Override::None + /// [constant expression]: index.html#constant-expressions + /// [override expression]: index.html#override-expressions + pub init: Handle, } /// Describes how an input/output variable is to be bound. @@ -907,7 +954,9 @@ pub struct GlobalVariable { /// The type of this variable. pub ty: Handle, /// Initial value for this variable. - pub init: Option>, + /// + /// Expression handle lives in const_expressions + pub init: Option>, } /// Variable defined at function level. @@ -921,7 +970,9 @@ pub struct LocalVariable { /// The type of this variable. pub ty: Handle, /// Initial value for this variable. - pub init: Option>, + /// + /// Expression handle lives in const_expressions + pub init: Option>, } /// Operation that can be applied on a single value. @@ -1224,6 +1275,11 @@ pub enum Expression { Constant(Handle), /// Zero value of a type. ZeroValue(Handle), + /// Composite expression. + Compose { + ty: Handle, + components: Vec>, + }, /// Array access with a computed index. /// @@ -1294,11 +1350,6 @@ pub enum Expression { vector: Handle, pattern: [SwizzleComponent; 4], }, - /// Composite expression. - Compose { - ty: Handle, - components: Vec>, - }, /// Reference a function parameter, by its index. /// @@ -1347,7 +1398,8 @@ pub enum Expression { gather: Option, coordinate: Handle, array_index: Option>, - offset: Option>, + /// Expression handle lives in const_expressions + offset: Option>, level: SampleLevel, depth_ref: Option>, }, @@ -1448,7 +1500,6 @@ pub enum Expression { Derivative { axis: DerivativeAxis, ctrl: DerivativeControl, - //modifier, expr: Handle, }, /// Call a relational function. @@ -1510,7 +1561,6 @@ pub enum Expression { pub use block::Block; /// The value of the switch case. -// Clone is used only for error reporting and is not intended for end users #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[cfg_attr(feature = "serialize", derive(Serialize))] #[cfg_attr(feature = "deserialize", derive(Deserialize))] @@ -1619,7 +1669,7 @@ pub enum Statement { /// [`body`]: SwitchCase::body /// [`Default`]: SwitchValue::Default Switch { - selector: Handle, //int + selector: Handle, cases: Vec, }, @@ -1939,6 +1989,14 @@ pub struct Module { pub constants: Arena, /// Arena for the global variables defined in this module. pub global_variables: Arena, + /// [Constant expressions] and [override expressions] used by this module. + /// + /// Each `Expression` must occur in the arena before any + /// `Expression` that uses its value. + /// + /// [Constant expressions]: index.html#constant-expressions + /// [override expressions]: index.html#override-expressions + pub const_expressions: Arena, /// Arena for the functions defined in this module. /// /// Each function must appear in this arena strictly before all its callers. diff --git a/src/proc/index.rs b/src/proc/index.rs index 0ccdfdca54..9a723b66dc 100644 --- a/src/proc/index.rs +++ b/src/proc/index.rs @@ -327,22 +327,16 @@ pub fn access_needs_check( } impl GuardedIndex { - /// Make A `GuardedIndex::Known` from a `GuardedIndex::Expression` if possible. - /// - /// If the expression is a [`Constant`] whose value is a non-specialized, scalar - /// integer constant that can be converted to a `u32`, do so and return a - /// `GuardedIndex::Known`. Otherwise, return the `GuardedIndex::Expression` - /// unchanged. + /// Make a `GuardedIndex::Known` from a `GuardedIndex::Expression` if possible. /// /// Return values that are already `Known` unchanged. - /// - /// [`Constant`]: crate::Expression::Constant fn try_resolve_to_constant(&mut self, function: &crate::Function, module: &crate::Module) { if let GuardedIndex::Expression(expr) = *self { - if let crate::Expression::Constant(handle) = function.expressions[expr] { - if let Some(value) = module.constants[handle].to_array_length() { - *self = GuardedIndex::Known(value); - } + if let Ok(value) = module + .to_ctx() + .eval_expr_to_u32_from(expr, &function.expressions) + { + *self = GuardedIndex::Known(value); } } } @@ -353,7 +347,7 @@ pub enum IndexableLengthError { #[error("Type is not indexable, and has no length (validation error)")] TypeNotIndexable, #[error("Array length constant {0:?} is invalid")] - InvalidArrayLength(Handle), + InvalidArrayLength(Handle), } impl crate::TypeInner { diff --git a/src/proc/mod.rs b/src/proc/mod.rs index c61fbdd932..582c887034 100644 --- a/src/proc/mod.rs +++ b/src/proc/mod.rs @@ -8,8 +8,6 @@ mod namer; mod terminator; mod typifier; -use std::cmp::PartialEq; - pub use index::{BoundsCheckPolicies, BoundsCheckPolicy, IndexableLength, IndexableLengthError}; pub use layouter::{Alignment, LayoutError, LayoutErrorInner, Layouter, TypeLayout}; pub use namer::{EntryPointIndex, NameKey, Namer}; @@ -62,17 +60,6 @@ impl From for super::ScalarKind { } } -impl super::ScalarValue { - pub const fn scalar_kind(&self) -> super::ScalarKind { - match *self { - Self::Uint(_) => super::ScalarKind::Uint, - Self::Sint(_) => super::ScalarKind::Sint, - Self::Float(_) => super::ScalarKind::Float, - Self::Bool(_) => super::ScalarKind::Bool, - } - } -} - impl super::ScalarKind { pub const fn is_numeric(self) -> bool { match self { @@ -135,17 +122,6 @@ impl crate::Literal { } } - pub const fn from_scalar(scalar: crate::ScalarValue, width: crate::Bytes) -> Option { - match (scalar, width) { - (crate::ScalarValue::Sint(n), 4) => Some(Self::I32(n as _)), - (crate::ScalarValue::Uint(n), 4) => Some(Self::U32(n as _)), - (crate::ScalarValue::Float(n), 4) => Some(Self::F32(n as _)), - (crate::ScalarValue::Float(n), 8) => Some(Self::F64(n)), - (crate::ScalarValue::Bool(b), _) => Some(Self::Bool(b)), - _ => None, - } - } - pub const fn zero(kind: crate::ScalarKind, width: crate::Bytes) -> Option { Self::new(0, kind, width) } @@ -209,6 +185,16 @@ impl super::TypeInner { } } + pub fn is_atomic_pointer(&self, types: &crate::UniqueArena) -> bool { + match *self { + crate::TypeInner::Pointer { base, .. } => match types[base].inner { + crate::TypeInner::Atomic { .. } => true, + _ => false, + }, + _ => false, + } + } + /// Get the size of this type. pub fn size(&self, _gctx: GlobalCtx) -> u32 { match *self { @@ -308,6 +294,39 @@ impl super::TypeInner { _ => false, } } + + pub fn components(&self) -> Option { + Some(match *self { + Self::Vector { size, .. } => size as u32, + Self::Matrix { columns, .. } => columns as u32, + Self::Array { + size: crate::ArraySize::Constant(len), + .. + } => len.get(), + Self::Struct { ref members, .. } => members.len() as u32, + _ => return None, + }) + } + + pub fn component_type(&self, index: usize) -> Option { + Some(match *self { + Self::Vector { kind, width, .. } => { + TypeResolution::Value(crate::TypeInner::Scalar { kind, width }) + } + Self::Matrix { rows, width, .. } => TypeResolution::Value(crate::TypeInner::Vector { + size: rows, + kind: crate::ScalarKind::Float, + width, + }), + Self::Array { + base, + size: crate::ArraySize::Constant(_), + .. + } => TypeResolution::Handle(base), + Self::Struct { ref members, .. } => TypeResolution::Handle(members[index].ty), + _ => return None, + }) + } } impl super::AddressSpace { @@ -441,7 +460,7 @@ impl crate::Expression { pub fn is_dynamic_index(&self, module: &crate::Module) -> bool { if let Self::Constant(handle) = *self { let constant = &module.constants[handle]; - constant.specialization.is_some() + !matches!(constant.r#override, crate::Override::None) } else { true } @@ -484,36 +503,6 @@ impl crate::SampleLevel { } } -impl crate::Constant { - /// Interpret this constant as an array length, and return it as a `u32`. - /// - /// Ignore any specialization available for this constant; return its - /// unspecialized value. - /// - /// If the constant has an inappropriate kind (non-scalar or non-integer) or - /// value (negative, out of range for u32), return `None`. This usually - /// indicates an error, but only the caller has enough information to report - /// the error helpfully: in back ends, it's a validation error, but in front - /// ends, it may indicate ill-formed input (for example, a SPIR-V - /// `OpArrayType` referring to an inappropriate `OpConstant`). So we return - /// `Option` and let the caller sort things out. - pub(crate) fn to_array_length(&self) -> Option { - match self.inner { - crate::ConstantInner::Scalar { value, width: _ } => match value { - crate::ScalarValue::Uint(value) => value.try_into().ok(), - // Accept a signed integer size to avoid - // requiring an explicit uint - // literal. Type inference should make - // this unnecessary. - crate::ScalarValue::Sint(value) => value.try_into().ok(), - _ => None, - }, - // caught by type validation - crate::ConstantInner::Composite { .. } => None, - } - } -} - impl crate::Binding { pub const fn to_built_in(&self) -> Option { match *self { @@ -523,30 +512,6 @@ impl crate::Binding { } } -//TODO: should we use an existing crate for hashable floats? -impl PartialEq for crate::ScalarValue { - fn eq(&self, other: &Self) -> bool { - match (*self, *other) { - (Self::Uint(a), Self::Uint(b)) => a == b, - (Self::Sint(a), Self::Sint(b)) => a == b, - (Self::Float(a), Self::Float(b)) => a.to_bits() == b.to_bits(), - (Self::Bool(a), Self::Bool(b)) => a == b, - _ => false, - } - } -} -impl Eq for crate::ScalarValue {} -impl std::hash::Hash for crate::ScalarValue { - fn hash(&self, hasher: &mut H) { - match *self { - Self::Sint(v) => v.hash(hasher), - Self::Uint(v) => v.hash(hasher), - Self::Float(v) => v.to_bits().hash(hasher), - Self::Bool(v) => v.hash(hasher), - } - } -} - impl super::SwizzleComponent { pub const XYZW: [Self; 4] = [Self::X, Self::Y, Self::Z, Self::W]; @@ -589,14 +554,71 @@ impl crate::Module { GlobalCtx { types: &self.types, constants: &self.constants, + const_expressions: &self.const_expressions, } } } +#[derive(Debug)] +pub(super) enum U32EvalError { + NonConst, + Negative, +} + #[derive(Clone, Copy)] pub struct GlobalCtx<'a> { pub types: &'a crate::UniqueArena, pub constants: &'a crate::Arena, + pub const_expressions: &'a crate::Arena, +} + +impl GlobalCtx<'_> { + /// Try to evaluate the expression in `self.const_expressions` using its `handle` and return it as a `u32`. + #[allow(dead_code)] + pub(super) fn eval_expr_to_u32( + &self, + handle: crate::Handle, + ) -> Result { + self.eval_expr_to_u32_from(handle, self.const_expressions) + } + + /// Try to evaluate the expression in the `arena` using its `handle` and return it as a `u32`. + pub(super) fn eval_expr_to_u32_from( + &self, + handle: crate::Handle, + arena: &crate::Arena, + ) -> Result { + fn get( + gctx: GlobalCtx, + handle: crate::Handle, + arena: &crate::Arena, + ) -> Result { + 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), + } + } + match arena[handle] { + crate::Expression::Constant(c) => { + get(*self, self.constants[c].init, self.const_expressions) + } + _ => get(*self, handle, arena), + } + } } #[test] diff --git a/src/proc/namer.rs b/src/proc/namer.rs index de98f601cc..2f262d7d5f 100644 --- a/src/proc/namer.rs +++ b/src/proc/namer.rs @@ -225,43 +225,7 @@ impl Namer { use std::fmt::Write; // Try to be more descriptive about the constant values temp.clear(); - match constant.inner { - crate::ConstantInner::Scalar { - width: _, - value: crate::ScalarValue::Sint(v), - } => write!(temp, "const_{v}i"), - crate::ConstantInner::Scalar { - width: _, - value: crate::ScalarValue::Uint(v), - } => write!(temp, "const_{v}u"), - crate::ConstantInner::Scalar { - width: _, - value: crate::ScalarValue::Float(v), - } => { - let abs = v.abs(); - write!( - temp, - "const_{}{}", - if v < 0.0 { "n" } else { "" }, - abs.trunc(), - ) - .unwrap(); - let fract = abs.fract(); - if fract == 0.0 { - write!(temp, "f") - } else { - write!(temp, "_{:02}f", (fract * 100.0) as i8) - } - } - crate::ConstantInner::Scalar { - width: _, - value: crate::ScalarValue::Bool(v), - } => write!(temp, "const_{v}"), - crate::ConstantInner::Composite { ty, components: _ } => { - write!(temp, "const_{}", output[&NameKey::Type(ty)]) - } - } - .unwrap(); + write!(temp, "const_{}", output[&NameKey::Type(constant.ty)]).unwrap(); &temp } }; diff --git a/src/proc/typifier.rs b/src/proc/typifier.rs index f0030f340f..6b79e0ead2 100644 --- a/src/proc/typifier.rs +++ b/src/proc/typifier.rs @@ -148,18 +148,6 @@ impl Clone for TypeResolution { } } -impl crate::ConstantInner { - pub const fn resolve_type(&self) -> TypeResolution { - match *self { - Self::Scalar { width, ref value } => TypeResolution::Value(crate::TypeInner::Scalar { - kind: value.scalar_kind(), - width, - }), - Self::Composite { ty, components: _ } => TypeResolution::Handle(ty), - } - } -} - #[derive(Clone, Debug, Error, PartialEq)] pub enum ResolveError { #[error("Index {index} is out of bounds for expression {expr:?}")] @@ -421,17 +409,6 @@ impl<'a> ResolveContext<'a> { } } } - crate::Expression::Literal(lit) => TypeResolution::Value(lit.ty_inner()), - crate::Expression::Constant(h) => match self.constants[h].inner { - crate::ConstantInner::Scalar { width, ref value } => { - TypeResolution::Value(Ti::Scalar { - kind: value.scalar_kind(), - width, - }) - } - crate::ConstantInner::Composite { ty, components: _ } => TypeResolution::Handle(ty), - }, - crate::Expression::ZeroValue(ty) => TypeResolution::Handle(ty), crate::Expression::Splat { size, value } => match *past(value)?.inner_with(types) { Ti::Scalar { kind, width } => { TypeResolution::Value(Ti::Vector { size, kind, width }) @@ -456,6 +433,9 @@ impl<'a> ResolveContext<'a> { return Err(ResolveError::InvalidVector(vector)); } }, + crate::Expression::Literal(lit) => TypeResolution::Value(lit.ty_inner()), + crate::Expression::Constant(h) => TypeResolution::Handle(self.constants[h].ty), + crate::Expression::ZeroValue(ty) => TypeResolution::Handle(ty), crate::Expression::Compose { ty, .. } => TypeResolution::Handle(ty), crate::Expression::FunctionArgument(index) => { let arg = self diff --git a/src/valid/analyzer.rs b/src/valid/analyzer.rs index 8ce63eaf3a..1e75c5af6c 100644 --- a/src/valid/analyzer.rs +++ b/src/valid/analyzer.rs @@ -495,7 +495,6 @@ impl FunctionInfo { requirements: UniformityRequirements::empty(), }, // always uniform - E::Literal(_) | E::Constant(_) | E::ZeroValue(_) => Uniformity::new(), E::Splat { size: _, value } => Uniformity { non_uniform_result: self.add_ref(value), requirements: UniformityRequirements::empty(), @@ -504,6 +503,7 @@ impl FunctionInfo { non_uniform_result: self.add_ref(vector), requirements: UniformityRequirements::empty(), }, + E::Literal(_) | E::Constant(_) | E::ZeroValue(_) => Uniformity::new(), E::Compose { ref components, .. } => { let non_uniform_result = components .iter() @@ -969,6 +969,18 @@ impl FunctionInfo { } impl ModuleInfo { + /// Populates `self.const_expression_types` + pub(super) fn process_const_expression( + &mut self, + handle: Handle, + resolve_context: &ResolveContext, + gctx: crate::proc::GlobalCtx, + ) -> Result<(), super::ConstExpressionError> { + self.const_expression_types[handle.index()] = + resolve_context.resolve(&gctx.const_expressions[handle], |h| Ok(&self[h]))?; + Ok(()) + } + /// Builds the `FunctionInfo` based on the function, and validates the /// uniform control flow if required by the expressions of this function. pub(super) fn process_function( @@ -1022,18 +1034,6 @@ impl ModuleInfo { fn uniform_control_flow() { use crate::{Expression as E, Statement as S}; - let mut constant_arena = Arena::new(); - let constant = constant_arena.append( - crate::Constant { - name: None, - specialization: None, - inner: crate::ConstantInner::Scalar { - width: 4, - value: crate::ScalarValue::Uint(0), - }, - }, - Default::default(), - ); let mut type_arena = crate::UniqueArena::new(); let ty = type_arena.insert( crate::Type { @@ -1070,7 +1070,7 @@ fn uniform_control_flow() { let mut expressions = Arena::new(); // checks the uniform control flow - let constant_expr = expressions.append(E::Constant(constant), Default::default()); + let constant_expr = expressions.append(E::Literal(crate::Literal::U32(0)), Default::default()); // checks the non-uniform control flow let derivative_expr = expressions.append( E::Derivative { @@ -1110,7 +1110,7 @@ fn uniform_control_flow() { sampling: crate::FastHashSet::default(), }; let resolve_context = ResolveContext { - constants: &constant_arena, + constants: &Arena::new(), types: &type_arena, special_types: &crate::SpecialTypes::default(), global_vars: &global_var_arena, diff --git a/src/valid/expression.rs b/src/valid/expression.rs index 071c1a4995..1703d213e1 100644 --- a/src/valid/expression.rs +++ b/src/valid/expression.rs @@ -1,7 +1,7 @@ #[cfg(feature = "validate")] use super::{ - compose::validate_compose, validate_atomic_compare_exchange_struct, FunctionInfo, ShaderStages, - TypeFlags, + compose::validate_compose, validate_atomic_compare_exchange_struct, FunctionInfo, ModuleInfo, + ShaderStages, TypeFlags, }; #[cfg(feature = "validate")] use crate::arena::UniqueArena; @@ -22,8 +22,10 @@ pub enum ExpressionError { InvalidBaseType(Handle), #[error("Accessing with index {0:?} can't be done")] InvalidIndexType(Handle), - #[error("Accessing index {1:?} is out of {0:?} bounds")] - IndexOutOfBounds(Handle, crate::ScalarValue), + #[error("Accessing {0:?} via a negative index is invalid")] + NegativeIndex(Handle), + #[error("Accessing index {1} is out of {0:?} bounds")] + IndexOutOfBounds(Handle, u32), #[error("The expression {0:?} may only be indexed by a constant")] IndexMustBeConstant(Handle), #[error("Function argument {0:?} doesn't exist")] @@ -91,7 +93,7 @@ pub enum ExpressionError { has_ref: bool, }, #[error("Sample offset constant {1:?} doesn't match the image dimension {0:?}")] - InvalidSampleOffset(crate::ImageDimension, Handle), + InvalidSampleOffset(crate::ImageDimension, Handle), #[error("Depth reference {0:?} is not a scalar float")] InvalidDepthReference(Handle), #[error("Depth sample level can only be Auto or Zero")] @@ -151,6 +153,29 @@ impl<'a> std::ops::Index> for ExpressionTypeResolver<' #[cfg(feature = "validate")] impl super::Validator { + pub(super) fn validate_const_expression( + &self, + handle: Handle, + gctx: crate::proc::GlobalCtx, + mod_info: &mut ModuleInfo, + ) -> Result<(), super::ConstExpressionError> { + use crate::Expression as E; + + match gctx.const_expressions[handle] { + E::Literal(_) | E::Constant(_) | E::ZeroValue(_) => {} + E::Compose { ref components, ty } => { + validate_compose( + ty, + gctx, + components.iter().map(|&handle| mod_info[handle].clone()), + )?; + } + _ => return Err(super::ConstExpressionError::NonConst), + } + + Ok(()) + } + pub(super) fn validate_expression( &self, root: Handle, @@ -158,7 +183,7 @@ impl super::Validator { function: &crate::Function, module: &crate::Module, info: &FunctionInfo, - other_infos: &[FunctionInfo], + mod_info: &ModuleInfo, ) -> Result { use crate::{Expression as E, ScalarKind as Sk, TypeInner as Ti}; @@ -205,27 +230,19 @@ impl super::Validator { if let crate::proc::IndexableLength::Known(known_length) = base_type.indexable_length(module)? { - if let E::Constant(k) = function.expressions[index] { - if let crate::Constant { - // We must treat specializable constants as unknown. - specialization: None, - // Non-scalar indices should have been caught above. - inner: crate::ConstantInner::Scalar { value, .. }, - .. - } = module.constants[k] - { - match value { - crate::ScalarValue::Uint(u) if u >= known_length as u64 => { - return Err(ExpressionError::IndexOutOfBounds(base, value)); - } - crate::ScalarValue::Sint(s) - if s < 0 || s >= known_length as i64 => - { - return Err(ExpressionError::IndexOutOfBounds(base, value)); - } - _ => (), + match module + .to_ctx() + .eval_expr_to_u32_from(index, &function.expressions) + { + Ok(value) => { + if value >= known_length { + return Err(ExpressionError::IndexOutOfBounds(base, value)); } } + Err(crate::proc::U32EvalError::Negative) => { + return Err(ExpressionError::NegativeIndex(base)) + } + Err(crate::proc::U32EvalError::NonConst) => {} } } @@ -263,16 +280,10 @@ impl super::Validator { let limit = resolve_index_limit(module, base, &resolver[base], true)?; if index >= limit { - return Err(ExpressionError::IndexOutOfBounds( - base, - crate::ScalarValue::Uint(limit as _), - )); + return Err(ExpressionError::IndexOutOfBounds(base, limit)); } ShaderStages::all() } - E::Literal(_value) => ShaderStages::all(), - E::Constant(_handle) => ShaderStages::all(), - E::ZeroValue(_type) => ShaderStages::all(), E::Splat { size: _, value } => match resolver[value] { Ti::Scalar { .. } => ShaderStages::all(), ref other => { @@ -299,6 +310,7 @@ impl super::Validator { } ShaderStages::all() } + E::Literal(_) | E::Constant(_) | E::ZeroValue(_) => ShaderStages::all(), E::Compose { ref components, ty } => { validate_compose( ty, @@ -412,26 +424,17 @@ impl super::Validator { } // check constant offset - if let Some(const_handle) = offset { - let good = match module.constants[const_handle].inner { - crate::ConstantInner::Scalar { - width: _, - value: crate::ScalarValue::Sint(_), - } => num_components == 1, - crate::ConstantInner::Scalar { .. } => false, - crate::ConstantInner::Composite { ty, .. } => { - match module.types[ty].inner { - Ti::Vector { - size, - kind: Sk::Sint, - .. - } => size as u32 == num_components, - _ => false, - } + if let Some(const_expr) = offset { + match *mod_info[const_expr].inner_with(&module.types) { + Ti::Scalar { kind: Sk::Sint, .. } if num_components == 1 => {} + Ti::Vector { + size, + kind: Sk::Sint, + .. + } if size as u32 == num_components => {} + _ => { + return Err(ExpressionError::InvalidSampleOffset(dim, const_expr)); } - }; - if !good { - return Err(ExpressionError::InvalidSampleOffset(dim, const_handle)); } } @@ -1388,7 +1391,7 @@ impl super::Validator { } ShaderStages::all() } - E::CallResult(function) => other_infos[function.index()].available_stages, + E::CallResult(function) => mod_info.functions[function.index()].available_stages, E::AtomicResult { ty, comparison } => { let scalar_predicate = |ty: &crate::TypeInner| match ty { &crate::TypeInner::Scalar { diff --git a/src/valid/function.rs b/src/valid/function.rs index 41f31b5658..06aa27c84b 100644 --- a/src/valid/function.rs +++ b/src/valid/function.rs @@ -941,6 +941,7 @@ impl super::Validator { &self, var: &crate::LocalVariable, gctx: crate::proc::GlobalCtx, + mod_info: &ModuleInfo, ) -> Result<(), LocalVariableError> { log::debug!("var {:?}", var); let type_info = self @@ -954,24 +955,14 @@ impl super::Validator { return Err(LocalVariableError::InvalidType(var.ty)); } - if let Some(const_handle) = var.init { - match gctx.constants[const_handle].inner { - crate::ConstantInner::Scalar { width, ref value } => { - let ty_inner = crate::TypeInner::Scalar { - width, - kind: value.scalar_kind(), - }; - if gctx.types[var.ty].inner != ty_inner { - return Err(LocalVariableError::InitializerType); - } - } - crate::ConstantInner::Composite { ty, components: _ } => { - if ty != var.ty { - return Err(LocalVariableError::InitializerType); - } - } + if let Some(init) = var.init { + let decl_ty = &gctx.types[var.ty].inner; + let init_ty = mod_info[init].inner_with(gctx.types); + if !decl_ty.equivalent(init_ty, gctx.types) { + return Err(LocalVariableError::InitializerType); } } + Ok(()) } @@ -987,7 +978,7 @@ impl super::Validator { #[cfg(feature = "validate")] for (var_handle, var) in fun.local_variables.iter() { - self.validate_local_var(var, module.to_ctx()) + self.validate_local_var(var, module.to_ctx(), mod_info) .map_err(|source| { FunctionError::LocalVariable { handle: var_handle, @@ -1061,14 +1052,7 @@ impl super::Validator { } #[cfg(feature = "validate")] if self.flags.contains(super::ValidationFlags::EXPRESSIONS) { - match self.validate_expression( - handle, - expr, - fun, - module, - &info, - &mod_info.functions, - ) { + match self.validate_expression(handle, expr, fun, module, &info, mod_info) { Ok(stages) => info.available_stages &= stages, Err(source) => { return Err(FunctionError::Expression { handle, source } diff --git a/src/valid/handles.rs b/src/valid/handles.rs index 2b0d107626..da95f60842 100644 --- a/src/valid/handles.rs +++ b/src/valid/handles.rs @@ -40,6 +40,7 @@ impl super::Validator { ref global_variables, ref types, ref special_types, + ref const_expressions, } = module; // NOTE: Types being first is important. All other forms of validation depend on this. @@ -70,25 +71,25 @@ impl super::Validator { } } + for handle_and_expr in const_expressions.iter() { + Self::validate_const_expression_handles(handle_and_expr, constants, types)?; + } + let validate_type = |handle| Self::validate_type_handle(handle, types); + let validate_const_expr = + |handle| Self::validate_expression_handle(handle, const_expressions); - for (this_handle, constant) in constants.iter() { + for (_handle, constant) in constants.iter() { let &crate::Constant { name: _, - specialization: _, - ref inner, + r#override: _, + ty, + init, } = constant; - match *inner { - crate::ConstantInner::Scalar { .. } => (), - crate::ConstantInner::Composite { ty, ref components } => { - validate_type(ty)?; - this_handle.check_dep_iter(components.iter().copied())?; - } - } + validate_type(ty)?; + validate_const_expr(init)?; } - let validate_constant = |handle| Self::validate_constant_handle(handle, constants); - for (_handle, global_variable) in global_variables.iter() { let &crate::GlobalVariable { name: _, @@ -99,7 +100,7 @@ impl super::Validator { } = global_variable; validate_type(ty)?; if let Some(init_expr) = init { - validate_constant(init_expr)?; + validate_const_expr(init_expr)?; } } @@ -131,7 +132,7 @@ impl super::Validator { let &crate::LocalVariable { name: _, ty, init } = local_variable; validate_type(ty)?; if let Some(init_constant) = init { - validate_constant(init_constant)?; + validate_const_expr(init_constant)?; } } @@ -143,6 +144,7 @@ impl super::Validator { Self::validate_expression_handles( handle_and_expr, constants, + const_expressions, types, local_variables, global_variables, @@ -202,9 +204,37 @@ impl super::Validator { handle.check_valid_for(functions).map(|_| ()) } + fn validate_const_expression_handles( + (handle, expression): (Handle, &crate::Expression), + constants: &Arena, + types: &UniqueArena, + ) -> Result<(), InvalidHandleError> { + let validate_constant = |handle| Self::validate_constant_handle(handle, constants); + let validate_type = |handle| Self::validate_type_handle(handle, types); + + match *expression { + crate::Expression::Literal(_) => {} + crate::Expression::Constant(constant) => { + validate_constant(constant)?; + handle.check_dep(constants[constant].init)?; + } + crate::Expression::ZeroValue(ty) => { + validate_type(ty)?; + } + crate::Expression::Compose { ty, ref components } => { + validate_type(ty)?; + handle.check_dep_iter(components.iter().copied())?; + } + _ => {} + } + Ok(()) + } + + #[allow(clippy::too_many_arguments)] fn validate_expression_handles( (handle, expression): (Handle, &crate::Expression), constants: &Arena, + const_expressions: &Arena, types: &UniqueArena, local_variables: &Arena, global_variables: &Arena, @@ -213,6 +243,8 @@ impl super::Validator { current_function: Option>, ) -> Result<(), InvalidHandleError> { let validate_constant = |handle| Self::validate_constant_handle(handle, constants); + let validate_const_expr = + |handle| Self::validate_expression_handle(handle, const_expressions); let validate_type = |handle| Self::validate_type_handle(handle, types); match *expression { @@ -222,19 +254,19 @@ impl super::Validator { crate::Expression::AccessIndex { base, .. } => { handle.check_dep(base)?; } - crate::Expression::Literal(_value) => {} - crate::Expression::Constant(constant) => { - validate_constant(constant)?; - } - crate::Expression::ZeroValue(ty) => { - validate_type(ty)?; - } crate::Expression::Splat { value, .. } => { handle.check_dep(value)?; } crate::Expression::Swizzle { vector, .. } => { handle.check_dep(vector)?; } + crate::Expression::Literal(_) => {} + crate::Expression::Constant(constant) => { + validate_constant(constant)?; + } + crate::Expression::ZeroValue(ty) => { + validate_type(ty)?; + } crate::Expression::Compose { ty, ref components } => { validate_type(ty)?; handle.check_dep_iter(components.iter().copied())?; @@ -260,7 +292,7 @@ impl super::Validator { depth_ref, } => { if let Some(offset) = offset { - validate_constant(offset)?; + validate_const_expr(offset)?; } handle @@ -630,3 +662,51 @@ impl crate::arena::Range { arena.check_contains_range(self) } } + +#[test] +#[cfg(feature = "validate")] +fn constant_deps() { + use crate::{Constant, Expression, Literal, Span, Type, TypeInner}; + + let nowhere = Span::default(); + + let mut types = UniqueArena::new(); + let mut const_exprs = Arena::new(); + let mut fun_exprs = Arena::new(); + let mut constants = Arena::new(); + + let i32_handle = types.insert( + Type { + name: None, + inner: TypeInner::Scalar { + kind: crate::ScalarKind::Sint, + width: 4, + }, + }, + nowhere, + ); + + // Construct a self-referential constant by misusing a handle to + // fun_exprs as a constant initializer. + let fun_expr = fun_exprs.append(Expression::Literal(Literal::I32(42)), nowhere); + let self_referential_const = constants.append( + Constant { + name: None, + r#override: crate::Override::None, + ty: i32_handle, + init: fun_expr, + }, + nowhere, + ); + let _self_referential_expr = + const_exprs.append(Expression::Constant(self_referential_const), nowhere); + + for handle_and_expr in const_exprs.iter() { + assert!(super::Validator::validate_const_expression_handles( + handle_and_expr, + &constants, + &types, + ) + .is_err()); + } +} diff --git a/src/valid/interface.rs b/src/valid/interface.rs index 47e2f201c8..f1f9548a72 100644 --- a/src/valid/interface.rs +++ b/src/valid/interface.rs @@ -31,6 +31,8 @@ pub enum GlobalVariableError { Handle, #[source] Disalignment, ), + #[error("Initializer doesn't match the variable type")] + InitializerType, } #[derive(Clone, Debug, thiserror::Error)] @@ -396,6 +398,7 @@ impl super::Validator { &self, var: &crate::GlobalVariable, gctx: crate::proc::GlobalCtx, + mod_info: &ModuleInfo, ) -> Result<(), GlobalVariableError> { use super::TypeFlags; @@ -509,6 +512,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); + if !decl_ty.equivalent(init_ty, gctx.types) { + return Err(GlobalVariableError::InitializerType); + } + } + Ok(()) } diff --git a/src/valid/mod.rs b/src/valid/mod.rs index 2c83e1a8d7..b04d69b5b4 100644 --- a/src/valid/mod.rs +++ b/src/valid/mod.rs @@ -10,12 +10,9 @@ mod handles; mod interface; mod r#type; -#[cfg(feature = "validate")] -use crate::arena::UniqueArena; - use crate::{ arena::Handle, - proc::{LayoutError, Layouter}, + proc::{LayoutError, Layouter, TypeResolution}, FastHashSet, }; use bit_set::BitSet; @@ -143,6 +140,7 @@ pub struct ModuleInfo { type_flags: Vec, functions: Vec, entry_points: Vec, + const_expression_types: Box<[TypeResolution]>, } impl ops::Index> for ModuleInfo { @@ -159,6 +157,13 @@ impl ops::Index> for ModuleInfo { } } +impl ops::Index> for ModuleInfo { + type Output = TypeResolution; + fn index(&self, handle: Handle) -> &Self::Output { + &self.const_expression_types[handle.index()] + } +} + #[derive(Debug)] pub struct Validator { flags: ValidationFlags, @@ -173,12 +178,22 @@ pub struct Validator { valid_expression_set: BitSet, } +#[derive(Clone, Debug, thiserror::Error)] +pub enum ConstExpressionError { + #[error("The expression is not a constant expression")] + NonConst, + #[error(transparent)] + Compose(#[from] ComposeError), + #[error("Type resolution failed")] + Type(#[from] crate::proc::ResolveError), +} + #[derive(Clone, Debug, thiserror::Error)] pub enum ConstantError { #[error("The type doesn't match the constant")] InvalidType, - #[error(transparent)] - Compose(#[from] ComposeError), + #[error("The type is not constructible")] + NonConstructibleType, } #[derive(Clone, Debug, thiserror::Error)] @@ -193,6 +208,11 @@ pub enum ValidationError { name: String, source: TypeError, }, + #[error("Constant expression {handle:?} is invalid")] + ConstExpression { + handle: Handle, + source: ConstExpressionError, + }, #[error("Constant {handle:?} '{name}' is invalid")] Constant { handle: Handle, @@ -300,24 +320,21 @@ impl Validator { &self, handle: Handle, gctx: crate::proc::GlobalCtx, + mod_info: &ModuleInfo, ) -> Result<(), ConstantError> { let con = &gctx.constants[handle]; - match con.inner { - crate::ConstantInner::Scalar { width, ref value } => { - if self.check_width(value.scalar_kind(), width).is_err() { - return Err(ConstantError::InvalidType); - } - } - crate::ConstantInner::Composite { ty, ref components } => { - compose::validate_compose( - ty, - gctx, - components - .iter() - .map(|&component| gctx.constants[component].inner.resolve_type()), - )?; - } + + let type_info = &self.types[con.ty.index()]; + if !type_info.flags.contains(TypeFlags::CONSTRUCTIBLE) { + return Err(ConstantError::NonConstructibleType); } + + let decl_ty = &gctx.types[con.ty].inner; + let init_ty = mod_info[con.init].inner_with(gctx.types); + if !decl_ty.equivalent(init_ty, gctx.types) { + return Err(ConstantError::InvalidType); + } + Ok(()) } @@ -337,25 +354,17 @@ impl Validator { ValidationError::from(e).with_span_handle(handle, &module.types) })?; - #[cfg(feature = "validate")] - if self.flags.contains(ValidationFlags::CONSTANTS) { - for (handle, constant) in module.constants.iter() { - self.validate_constant(handle, module.to_ctx()) - .map_err(|source| { - ValidationError::Constant { - handle, - name: constant.name.clone().unwrap_or_default(), - source, - } - .with_span_handle(handle, &module.constants) - })? - } - } + let placeholder = TypeResolution::Value(crate::TypeInner::Scalar { + kind: crate::ScalarKind::Bool, + width: 0, + }); let mut mod_info = ModuleInfo { type_flags: Vec::with_capacity(module.types.len()), functions: Vec::with_capacity(module.functions.len()), entry_points: Vec::with_capacity(module.entry_points.len()), + const_expression_types: vec![placeholder; module.const_expressions.len()] + .into_boxed_slice(), }; for (handle, ty) in module.types.iter() { @@ -373,9 +382,45 @@ impl Validator { self.types[handle.index()] = ty_info; } + { + let t = crate::Arena::new(); + let resolve_context = crate::proc::ResolveContext::with_locals(module, &t, &[]); + for (handle, _) in module.const_expressions.iter() { + mod_info + .process_const_expression(handle, &resolve_context, module.to_ctx()) + .map_err(|source| { + ValidationError::ConstExpression { handle, source } + .with_span_handle(handle, &module.const_expressions) + })? + } + } + + #[cfg(feature = "validate")] + if self.flags.contains(ValidationFlags::CONSTANTS) { + for (handle, _) in module.const_expressions.iter() { + self.validate_const_expression(handle, module.to_ctx(), &mut mod_info) + .map_err(|source| { + ValidationError::ConstExpression { handle, source } + .with_span_handle(handle, &module.const_expressions) + })? + } + + for (handle, constant) in module.constants.iter() { + self.validate_constant(handle, module.to_ctx(), &mod_info) + .map_err(|source| { + ValidationError::Constant { + handle, + name: constant.name.clone().unwrap_or_default(), + source, + } + .with_span_handle(handle, &module.constants) + })? + } + } + #[cfg(feature = "validate")] for (var_handle, var) in module.global_variables.iter() { - self.validate_global_var(var, module.to_ctx()) + self.validate_global_var(var, module.to_ctx(), &mod_info) .map_err(|source| { ValidationError::GlobalVariable { handle: var_handle, @@ -434,7 +479,7 @@ impl Validator { #[cfg(feature = "validate")] fn validate_atomic_compare_exchange_struct( - types: &UniqueArena, + types: &crate::UniqueArena, members: &[crate::StructMember], scalar_predicate: impl FnOnce(&crate::TypeInner) -> bool, ) -> bool { diff --git a/tests/in/constructors.param.ron b/tests/in/constructors.param.ron new file mode 100644 index 0000000000..72873dd667 --- /dev/null +++ b/tests/in/constructors.param.ron @@ -0,0 +1,2 @@ +( +) diff --git a/tests/in/constructors.wgsl b/tests/in/constructors.wgsl new file mode 100644 index 0000000000..d221dc80de --- /dev/null +++ b/tests/in/constructors.wgsl @@ -0,0 +1,67 @@ +struct Foo { + a: vec4, + b: i32, +} + +// const const1 = vec3(0.0); // TODO: this is now a splat and we need to const eval it +const const2 = vec3(0.0, 1.0, 2.0); +const const3 = mat2x2(0.0, 1.0, 2.0, 3.0); +const const4 = array, 1>(mat2x2(0.0, 1.0, 2.0, 3.0)); + +// zero value constructors +const cz0 = bool(); +const cz1 = i32(); +const cz2 = u32(); +const cz3 = f32(); +const cz4 = vec2(); +const cz5 = mat2x2(); +const cz6 = array(); +const cz7 = Foo(); + +// constructors that infer their type from their parameters +// TODO: these also contain splats +// const cp1 = vec2(0u); +// const cp2 = mat2x2(vec2(0.), vec2(0.)); +const cp3 = array(0, 1, 2, 3); + +@compute @workgroup_size(1) +fn main() { + var foo: Foo; + foo = Foo(vec4(1.0), 1); + + let m0 = mat2x2( + 1.0, 0.0, + 0.0, 1.0, + ); + let m1 = mat4x4( + 1.0, 0.0, 0.0, 0.0, + 0.0, 1.0, 0.0, 0.0, + 0.0, 0.0, 1.0, 0.0, + 0.0, 0.0, 0.0, 1.0, + ); + + // zero value constructors + let zvc0 = bool(); + let zvc1 = i32(); + let zvc2 = u32(); + let zvc3 = f32(); + let zvc4 = vec2(); + let zvc5 = mat2x2(); + let zvc6 = array(); + let zvc7 = Foo(); + + // constructors that infer their type from their parameters + let cit0 = vec2(0u); + let cit1 = mat2x2(vec2(0.), vec2(0.)); + let cit2 = array(0, 1, 2, 3); + + // identity constructors + 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 ic6 = vec2(vec2()); + let ic7 = mat2x3(mat2x3()); +} diff --git a/tests/in/operators.wgsl b/tests/in/operators.wgsl index 365a039921..eaf16ab8ff 100644 --- a/tests/in/operators.wgsl +++ b/tests/in/operators.wgsl @@ -1,4 +1,3 @@ -//TODO: support splatting constructors for globals? const v_f32_one = vec4(1.0, 1.0, 1.0, 1.0); const v_f32_zero = vec4(0.0, 0.0, 0.0, 0.0); const v_f32_half = vec4(0.5, 0.5, 0.5, 0.5); @@ -41,54 +40,6 @@ fn bool_cast(x: vec3) -> vec3 { return vec3(y); } -struct Foo { - a: vec4, - b: i32, -} - -fn constructors() -> f32 { - var foo: Foo; - foo = Foo(vec4(1.0), 1); - - let m0 = mat2x2( - 1.0, 0.0, - 0.0, 1.0, - ); - let m1 = mat4x4( - 1.0, 0.0, 0.0, 0.0, - 0.0, 1.0, 0.0, 0.0, - 0.0, 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, 1.0, - ); - - // zero value constructors - let zvc0 = bool(); - let zvc1 = i32(); - let zvc2 = u32(); - let zvc3 = f32(); - let zvc4 = vec2(); - let zvc5 = mat2x2(); - let zvc6 = array(); - let zvc7 = Foo(); - - // constructors that infer their type from their parameters - let cit0 = vec2(0u); - let cit1 = mat2x2(vec2(0.), vec2(0.)); - let cit2 = array(0, 1, 2, 3); - - // identity constructors - 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 ic6 = vec2(vec2()); - let ic7 = mat2x3(mat2x3()); - - return foo.a.x; -} - fn logical() { // unary let neg0 = !true; @@ -306,7 +257,6 @@ fn main() { builtins(); splat(); bool_cast(v_f32_one.xyz); - constructors(); logical(); arithmetic(); diff --git a/tests/out/analysis/access.info.ron b/tests/out/analysis/access.info.ron index 66b38e35a2..62e898d3c0 100644 --- a/tests/out/analysis/access.info.ron +++ b/tests/out/analysis/access.info.ron @@ -79,24 +79,24 @@ ), ( uniformity: ( - non_uniform_result: Some(2), + non_uniform_result: None, requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Handle(3), + ty: Value(Scalar( + kind: Sint, + width: 4, + )), ), ( uniformity: ( - non_uniform_result: None, + non_uniform_result: Some(2), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -710,24 +710,24 @@ ), ( uniformity: ( - non_uniform_result: Some(2), + non_uniform_result: None, requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Handle(3), + ty: Value(Scalar( + kind: Sint, + width: 4, + )), ), ( uniformity: ( - non_uniform_result: None, + non_uniform_result: Some(2), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -1296,24 +1296,24 @@ ), ( uniformity: ( - non_uniform_result: Some(2), + non_uniform_result: None, requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Handle(3), + ty: Value(Scalar( + kind: Sint, + width: 4, + )), ), ( uniformity: ( - non_uniform_result: None, + non_uniform_result: Some(2), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -2053,24 +2053,24 @@ ), ( uniformity: ( - non_uniform_result: Some(2), + non_uniform_result: None, requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Handle(3), + ty: Value(Scalar( + kind: Sint, + width: 4, + )), ), ( uniformity: ( - non_uniform_result: None, + non_uniform_result: Some(2), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -4290,4 +4290,88 @@ sampling: [], ), ], + const_expression_types: [ + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Uint, + width: 4, + )), + Handle(2), + Value(Scalar( + kind: Sint, + width: 4, + )), + Handle(4), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + ], ) \ No newline at end of file diff --git a/tests/out/analysis/collatz.info.ron b/tests/out/analysis/collatz.info.ron index f060e3b3fe..c0c222ba48 100644 --- a/tests/out/analysis/collatz.info.ron +++ b/tests/out/analysis/collatz.info.ron @@ -428,4 +428,5 @@ sampling: [], ), ], + const_expression_types: [], ) \ No newline at end of file diff --git a/tests/out/analysis/shadow.info.ron b/tests/out/analysis/shadow.info.ron index fdafe51070..8af61bff53 100644 --- a/tests/out/analysis/shadow.info.ron +++ b/tests/out/analysis/shadow.info.ron @@ -143,58 +143,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -203,10 +152,7 @@ ), ref_count: 2, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -215,10 +161,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -227,10 +170,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -239,10 +179,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -251,10 +188,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -263,10 +197,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -275,10 +206,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -287,10 +215,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -299,10 +224,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -311,10 +233,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -323,10 +242,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -335,10 +251,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -347,10 +260,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -359,10 +269,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -371,10 +278,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -383,10 +287,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -395,10 +296,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -407,10 +305,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -419,10 +314,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -431,10 +323,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -443,10 +332,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -455,10 +341,7 @@ ), ref_count: 3, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -467,10 +350,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -479,10 +359,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -491,10 +368,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -503,10 +377,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -515,10 +386,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -527,10 +395,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -539,10 +404,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -551,10 +413,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -563,10 +422,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -575,10 +431,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -596,14 +449,11 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -612,7 +462,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 6, @@ -621,7 +471,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -633,7 +483,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -645,7 +495,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -657,7 +507,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -669,7 +519,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -687,7 +537,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -696,7 +546,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -708,19 +558,16 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -742,7 +589,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 2, @@ -751,7 +598,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -763,7 +610,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -775,7 +622,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -787,7 +634,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -799,7 +646,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 3, @@ -808,7 +655,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -820,7 +667,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -832,31 +679,25 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -868,7 +709,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -880,7 +721,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -889,7 +730,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -901,7 +742,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1037,46 +878,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1085,22 +887,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), - ), - ( - uniformity: ( - non_uniform_result: None, - requirements: (""), - ), - ref_count: 0, - assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -1109,10 +896,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1121,10 +905,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1133,10 +914,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1145,10 +923,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1157,10 +932,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1169,10 +941,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1181,10 +950,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -1193,10 +959,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1205,10 +968,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -1217,10 +977,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1229,10 +986,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1241,10 +995,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -1253,10 +1004,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1265,10 +1013,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1277,10 +1022,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1289,10 +1031,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1301,10 +1040,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1313,10 +1049,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -1325,10 +1058,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Uint, - width: 4, - )), + ty: Handle(3), ), ( uniformity: ( @@ -1337,10 +1067,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -1349,10 +1076,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -1361,10 +1085,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1373,10 +1094,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1385,10 +1103,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1397,10 +1112,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1409,10 +1121,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1421,10 +1130,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1433,10 +1139,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1445,10 +1148,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1457,10 +1157,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1469,10 +1166,7 @@ ), ref_count: 0, assignable_global: None, - ty: Value(Scalar( - kind: Sint, - width: 4, - )), + ty: Handle(9), ), ( uniformity: ( @@ -1490,14 +1184,11 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 3, @@ -1509,7 +1200,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 11, @@ -1521,7 +1212,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1580,7 +1271,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1592,7 +1283,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -1601,7 +1292,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1624,7 +1315,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1633,7 +1324,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1647,7 +1338,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1661,7 +1352,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1679,7 +1370,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1733,7 +1424,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1742,7 +1433,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1756,7 +1447,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1770,7 +1461,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1786,7 +1477,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1812,7 +1503,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1821,7 +1512,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1835,7 +1526,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1849,7 +1540,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1865,7 +1556,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1891,7 +1582,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1900,7 +1591,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1914,7 +1605,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1928,7 +1619,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1944,7 +1635,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -1956,7 +1647,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2052,7 +1743,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2061,7 +1752,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2087,10 +1778,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -2099,10 +1787,7 @@ ), ref_count: 1, assignable_global: None, - ty: Value(Scalar( - kind: Float, - width: 4, - )), + ty: Handle(1), ), ( uniformity: ( @@ -2120,7 +1805,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2129,7 +1814,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2143,7 +1828,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2157,7 +1842,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2173,7 +1858,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2199,7 +1884,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2208,7 +1893,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2222,7 +1907,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2236,7 +1921,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2252,7 +1937,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2278,7 +1963,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2287,7 +1972,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2301,7 +1986,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2315,7 +2000,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2331,7 +2016,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2343,7 +2028,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2352,7 +2037,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2361,7 +2046,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -2370,7 +2055,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2379,7 +2064,7 @@ ), ( uniformity: ( - non_uniform_result: Some(48), + non_uniform_result: Some(44), requirements: (""), ), ref_count: 1, @@ -2388,7 +2073,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -2397,7 +2082,7 @@ ), ( uniformity: ( - non_uniform_result: Some(47), + non_uniform_result: Some(43), requirements: (""), ), ref_count: 1, @@ -2500,4 +2185,148 @@ sampling: [], ), ], + const_expression_types: [ + Value(Scalar( + kind: Float, + width: 4, + )), + Value(Scalar( + kind: Float, + width: 4, + )), + Value(Scalar( + kind: Float, + width: 4, + )), + Value(Scalar( + kind: Float, + width: 4, + )), + Value(Scalar( + kind: Float, + width: 4, + )), + Handle(1), + Handle(1), + Handle(1), + Handle(2), + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Uint, + width: 4, + )), + Value(Scalar( + kind: Float, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Value(Scalar( + kind: Sint, + width: 4, + )), + Handle(2), + Handle(3), + ], ) \ No newline at end of file diff --git a/tests/out/glsl/access.foo_vert.Vertex.glsl b/tests/out/glsl/access.foo_vert.Vertex.glsl index 2a5e038821..a25eda03bb 100644 --- a/tests/out/glsl/access.foo_vert.Vertex.glsl +++ b/tests/out/glsl/access.foo_vert.Vertex.glsl @@ -37,8 +37,8 @@ void test_matrix_within_struct_accesses() { int idx = 0; Baz t = Baz(mat3x2(0.0)); idx = 1; - int _e2 = idx; - idx = (_e2 - 1); + int _e3 = idx; + idx = (_e3 - 1); mat3x2 l0_ = _group_0_binding_1_vs.m; vec2 l1_ = _group_0_binding_1_vs.m[0]; int _e15 = idx; @@ -52,8 +52,8 @@ void test_matrix_within_struct_accesses() { int _e43 = idx; float l6_ = _group_0_binding_1_vs.m[_e41][_e43]; t = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); - int _e55 = idx; - idx = (_e55 + 1); + int _e56 = idx; + idx = (_e56 + 1); t.m = mat3x2(vec2(6.0), vec2(5.0), vec2(4.0)); t.m[0] = vec2(9.0); int _e72 = idx; @@ -73,8 +73,8 @@ void test_matrix_within_array_within_struct_accesses() { int idx_1 = 0; MatCx2InArray t_1 = MatCx2InArray(mat4x2[2](mat4x2(0.0), mat4x2(0.0))); idx_1 = 1; - int _e2 = idx_1; - idx_1 = (_e2 - 1); + int _e3 = idx_1; + idx_1 = (_e3 - 1); mat4x2 l0_1[2] = _group_0_binding_3_vs.am; mat4x2 l1_1 = _group_0_binding_3_vs.am[0]; vec2 l2_1 = _group_0_binding_3_vs.am[0][0]; @@ -89,8 +89,8 @@ void test_matrix_within_array_within_struct_accesses() { int _e60 = idx_1; float l7_ = _group_0_binding_3_vs.am[0][_e58][_e60]; t_1 = MatCx2InArray(mat4x2[2](mat4x2(0.0), mat4x2(0.0))); - int _e66 = idx_1; - idx_1 = (_e66 + 1); + int _e67 = idx_1; + idx_1 = (_e67 + 1); t_1.am = mat4x2[2](mat4x2(0.0), mat4x2(0.0)); t_1.am[0] = mat4x2(vec2(8.0), vec2(7.0), vec2(6.0), vec2(5.0)); t_1.am[0][0] = vec2(9.0); diff --git a/tests/out/glsl/boids.main.Compute.glsl b/tests/out/glsl/boids.main.Compute.glsl index 0f64853619..8d6067aeed 100644 --- a/tests/out/glsl/boids.main.Compute.glsl +++ b/tests/out/glsl/boids.main.Compute.glsl @@ -18,6 +18,8 @@ struct SimParams { float rule2Scale; float rule3Scale; }; +const uint NUM_PARTICLES = 1500u; + uniform SimParams_block_0Compute { SimParams _group_0_binding_0_cs; }; layout(std430) readonly buffer Particles_block_1Compute { @@ -42,7 +44,7 @@ void main() { vec2 vel = vec2(0.0); uint i = 0u; uint index = global_invocation_id.x; - if ((index >= 1500u)) { + if ((index >= NUM_PARTICLES)) { return; } vec2 _e8 = _group_0_binding_1_cs.particles[index].pos; @@ -63,7 +65,7 @@ void main() { } loop_init = false; uint _e36 = i; - if ((_e36 >= 1500u)) { + if ((_e36 >= NUM_PARTICLES)) { break; } uint _e39 = i; diff --git a/tests/out/glsl/constructors.main.Compute.glsl b/tests/out/glsl/constructors.main.Compute.glsl new file mode 100644 index 0000000000..112795eda1 --- /dev/null +++ b/tests/out/glsl/constructors.main.Compute.glsl @@ -0,0 +1,43 @@ +#version 310 es + +precision highp float; +precision highp int; + +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; + +struct Foo { + vec4 a; + int b; +}; +const vec3 const2_ = vec3(0.0, 1.0, 2.0); +const mat2x2 const3_ = mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0)); +const mat2x2 const4_[1] = mat2x2[1](mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0))); +const bool cz0_ = false; +const int cz1_ = 0; +const uint cz2_ = 0u; +const float cz3_ = 0.0; +const uvec2 cz4_ = uvec2(0u); +const mat2x2 cz5_ = mat2x2(0.0); +const Foo cz6_[3] = Foo[3](Foo(vec4(0.0), 0), Foo(vec4(0.0), 0), Foo(vec4(0.0), 0)); +const Foo cz7_ = Foo(vec4(0.0), 0); +const int cp3_[4] = int[4](0, 1, 2, 3); + + +void main() { + Foo foo = Foo(vec4(0.0), 0); + foo = Foo(vec4(1.0), 1); + mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); + mat4x4 m1_ = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + uvec2 cit0_ = uvec2(0u); + 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 ic6_ = uvec2(0u); + mat2x3 ic7_ = mat2x3(0.0); +} + diff --git a/tests/out/glsl/do-while.main.Fragment.glsl b/tests/out/glsl/do-while.main.Fragment.glsl index 56a69123cf..50e9a48971 100644 --- a/tests/out/glsl/do-while.main.Fragment.glsl +++ b/tests/out/glsl/do-while.main.Fragment.glsl @@ -8,8 +8,8 @@ void fb1_(inout bool cond) { bool loop_init = true; while(true) { if (!loop_init) { - bool _e6 = cond; - if (!(_e6)) { + bool _e2 = cond; + if (!(_e2)) { break; } } diff --git a/tests/out/glsl/globals.main.Compute.glsl b/tests/out/glsl/globals.main.Compute.glsl index 5c194d5326..d1b2347345 100644 --- a/tests/out/glsl/globals.main.Compute.glsl +++ b/tests/out/glsl/globals.main.Compute.glsl @@ -9,6 +9,8 @@ struct FooStruct { vec3 v3_; float v1_; }; +const bool Foo_1 = true; + shared float wg[10]; shared uint at_1; diff --git a/tests/out/glsl/operators.main.Compute.glsl b/tests/out/glsl/operators.main.Compute.glsl index d3859ef63b..5adfec2f8a 100644 --- a/tests/out/glsl/operators.main.Compute.glsl +++ b/tests/out/glsl/operators.main.Compute.glsl @@ -5,20 +5,21 @@ precision highp int; layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; -struct Foo { - vec4 a; - int b; -}; +const vec4 v_f32_one = vec4(1.0, 1.0, 1.0, 1.0); +const vec4 v_f32_zero = vec4(0.0, 0.0, 0.0, 0.0); +const vec4 v_f32_half = vec4(0.5, 0.5, 0.5, 0.5); +const ivec4 v_i32_one = ivec4(1, 1, 1, 1); + vec4 builtins() { int s1_ = (true ? 1 : 0); - vec4 s2_ = (true ? vec4(1.0, 1.0, 1.0, 1.0) : vec4(0.0, 0.0, 0.0, 0.0)); - vec4 s3_ = mix(vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), bvec4(false, false, false, false)); - vec4 m1_ = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(0.5, 0.5, 0.5, 0.5)); - vec4 m2_ = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0), 0.1); - float b1_ = intBitsToFloat(ivec4(1, 1, 1, 1).x); - vec4 b2_ = intBitsToFloat(ivec4(1, 1, 1, 1)); - ivec4 v_i32_zero = ivec4(vec4(0.0, 0.0, 0.0, 0.0)); + vec4 s2_ = (true ? v_f32_one : v_f32_zero); + 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); + vec4 b2_ = intBitsToFloat(v_i32_one); + ivec4 v_i32_zero = ivec4(v_f32_zero); return (((((vec4((ivec4(s1_) + v_i32_zero)) + s2_) + m1_) + m2_) + vec4(b1_)) + b2_); } @@ -46,26 +47,6 @@ vec3 bool_cast(vec3 x) { return vec3(y); } -float constructors() { - Foo foo = Foo(vec4(0.0), 0); - foo = Foo(vec4(1.0), 1); - mat2x2 m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); - mat4x4 m1_1 = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); - uvec2 cit0_ = uvec2(0u); - 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 ic6_ = uvec2(0u); - mat2x3 ic7_ = mat2x3(0.0); - float _e71 = foo.a.x; - return _e71; -} - void logical() { bool neg0_ = !(true); bvec2 neg1_ = not(bvec2(true)); @@ -243,15 +224,15 @@ void assignment() { a_1 = (_e27 << 2u); int _e30 = a_1; a_1 = (_e30 >> 1u); - int _e32 = a_1; - a_1 = (_e32 + 1); - int _e35 = a_1; - a_1 = (_e35 - 1); + 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 _e47 = vec0_.y; - vec0_.y = (_e47 - 1); + int _e43 = vec0_.y; + vec0_.y = (_e43 + 1); + int _e48 = vec0_.y; + vec0_.y = (_e48 - 1); return; } @@ -268,8 +249,7 @@ void negation_avoids_prefix_decrement() { void main() { vec4 _e0 = builtins(); vec4 _e1 = splat(); - vec3 _e4 = bool_cast(vec4(1.0, 1.0, 1.0, 1.0).xyz); - float _e5 = constructors(); + vec3 _e4 = bool_cast(v_f32_one.xyz); logical(); arithmetic(); bit(); diff --git a/tests/out/glsl/quad-vert.main.Vertex.glsl b/tests/out/glsl/quad-vert.main.Vertex.glsl index 082196af51..eec208cdc6 100644 --- a/tests/out/glsl/quad-vert.main.Vertex.glsl +++ b/tests/out/glsl/quad-vert.main.Vertex.glsl @@ -26,10 +26,10 @@ layout(location = 0) in vec2 _p2vs_location0; layout(location = 0) smooth out vec2 _vs2fs_location0; void main_1() { - vec2 _e12 = a_uv_1; - v_uv = _e12; - vec2 _e13 = a_pos_1; - perVertexStruct.gen_gl_Position = vec4(_e13.x, _e13.y, 0.0, 1.0); + vec2 _e8 = a_uv_1; + v_uv = _e8; + vec2 _e9 = a_pos_1; + perVertexStruct.gen_gl_Position = vec4(_e9.x, _e9.y, 0.0, 1.0); return; } diff --git a/tests/out/glsl/quad.frag_main.Fragment.glsl b/tests/out/glsl/quad.frag_main.Fragment.glsl index e1902d9e36..c69b9eb5fe 100644 --- a/tests/out/glsl/quad.frag_main.Fragment.glsl +++ b/tests/out/glsl/quad.frag_main.Fragment.glsl @@ -7,6 +7,8 @@ struct VertexOutput { vec2 uv; vec4 position; }; +const float c_scale = 1.2; + uniform highp sampler2D _group_0_binding_0_fs; smooth in vec2 _vs2fs_location0; diff --git a/tests/out/glsl/quad.fs_extra.Fragment.glsl b/tests/out/glsl/quad.fs_extra.Fragment.glsl index 932fa76ba0..31674b12d6 100644 --- a/tests/out/glsl/quad.fs_extra.Fragment.glsl +++ b/tests/out/glsl/quad.fs_extra.Fragment.glsl @@ -7,6 +7,8 @@ struct VertexOutput { vec2 uv; vec4 position; }; +const float c_scale = 1.2; + layout(location = 0) out vec4 _fs2p_location0; void main() { diff --git a/tests/out/glsl/quad.vert_main.Vertex.glsl b/tests/out/glsl/quad.vert_main.Vertex.glsl index 5a1f432b28..c5bca7f666 100644 --- a/tests/out/glsl/quad.vert_main.Vertex.glsl +++ b/tests/out/glsl/quad.vert_main.Vertex.glsl @@ -7,6 +7,8 @@ struct VertexOutput { vec2 uv; vec4 position; }; +const float c_scale = 1.2; + layout(location = 0) in vec2 _p2vs_location0; layout(location = 1) in vec2 _p2vs_location1; smooth out vec2 _vs2fs_location0; @@ -14,7 +16,7 @@ smooth out vec2 _vs2fs_location0; void main() { vec2 pos = _p2vs_location0; vec2 uv = _p2vs_location1; - VertexOutput _tmp_return = VertexOutput(uv, vec4((1.2000000476837158 * pos), 0.0, 1.0)); + VertexOutput _tmp_return = VertexOutput(uv, vec4((c_scale * pos), 0.0, 1.0)); _vs2fs_location0 = _tmp_return.uv; gl_Position = _tmp_return.position; return; diff --git a/tests/out/glsl/shadow.fs_main.Fragment.glsl b/tests/out/glsl/shadow.fs_main.Fragment.glsl index b34e39e5c4..0910850814 100644 --- a/tests/out/glsl/shadow.fs_main.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main.Fragment.glsl @@ -21,6 +21,9 @@ struct Light { vec4 pos; vec4 color; }; +const vec3 c_ambient = vec3(0.05, 0.05, 0.05); +const uint c_max_lights = 10u; + uniform Globals_block_0Fragment { Globals _group_0_binding_0_fs; }; uniform Entity_block_1Fragment { Entity _group_1_binding_0_fs; }; @@ -49,18 +52,18 @@ void main() { vec3 color = vec3(0.0); uint i = 0u; vec3 normal_1 = normalize(in_.world_normal); - color = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color = c_ambient; i = 0u; bool loop_init = true; while(true) { if (!loop_init) { - uint _e39 = i; - i = (_e39 + 1u); + uint _e40 = i; + i = (_e40 + 1u); } loop_init = false; uint _e7 = i; uint _e11 = _group_0_binding_0_fs.num_lights.x; - if ((_e7 < min(_e11, 10u))) { + if ((_e7 < min(_e11, c_max_lights))) { } else { break; } 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 ae3dd1c861..c85a89eb96 100644 --- a/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl +++ b/tests/out/glsl/shadow.fs_main_without_storage.Fragment.glsl @@ -21,6 +21,9 @@ struct Light { vec4 pos; vec4 color; }; +const vec3 c_ambient = vec3(0.05, 0.05, 0.05); +const uint c_max_lights = 10u; + uniform Globals_block_0Fragment { Globals _group_0_binding_0_fs; }; uniform Entity_block_1Fragment { Entity _group_1_binding_0_fs; }; @@ -49,18 +52,18 @@ void main() { vec3 color_1 = vec3(0.0); uint i_1 = 0u; vec3 normal_1 = normalize(in_1.world_normal); - color_1 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color_1 = c_ambient; i_1 = 0u; bool loop_init = true; while(true) { if (!loop_init) { - uint _e39 = i_1; - i_1 = (_e39 + 1u); + uint _e40 = i_1; + i_1 = (_e40 + 1u); } loop_init = false; uint _e7 = i_1; uint _e11 = _group_0_binding_0_fs.num_lights.x; - if ((_e7 < min(_e11, 10u))) { + if ((_e7 < min(_e11, c_max_lights))) { } else { break; } diff --git a/tests/out/glsl/shadow.vs_main.Vertex.glsl b/tests/out/glsl/shadow.vs_main.Vertex.glsl index eced93ae71..631c412f2a 100644 --- a/tests/out/glsl/shadow.vs_main.Vertex.glsl +++ b/tests/out/glsl/shadow.vs_main.Vertex.glsl @@ -21,6 +21,9 @@ struct Light { vec4 pos; vec4 color; }; +const vec3 c_ambient = vec3(0.05, 0.05, 0.05); +const uint c_max_lights = 10u; + uniform Globals_block_0Vertex { Globals _group_0_binding_0_vs; }; uniform Entity_block_1Vertex { Entity _group_1_binding_0_vs; }; diff --git a/tests/out/glsl/workgroup-uniform-load.test_workgroupUniformLoad.Compute.glsl b/tests/out/glsl/workgroup-uniform-load.test_workgroupUniformLoad.Compute.glsl index 03857ec797..6315309c99 100644 --- a/tests/out/glsl/workgroup-uniform-load.test_workgroupUniformLoad.Compute.glsl +++ b/tests/out/glsl/workgroup-uniform-load.test_workgroupUniformLoad.Compute.glsl @@ -5,6 +5,8 @@ precision highp int; layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in; +const uint SIZE = 128u; + shared int arr_i32_[128]; diff --git a/tests/out/hlsl/access.hlsl b/tests/out/hlsl/access.hlsl index 2af083b721..5fdd97fbcd 100644 --- a/tests/out/hlsl/access.hlsl +++ b/tests/out/hlsl/access.hlsl @@ -1,4 +1,3 @@ - typedef struct { float2 _0; float2 _1; } __mat2x2; float2 __get_col_of_mat2x2(__mat2x2 mat, uint idx) { switch(idx) { @@ -84,6 +83,14 @@ RWByteAddressBuffer qux : register(u2); cbuffer nested_mat_cx2_ : register(b3) { MatCx2InArray nested_mat_cx2_; } groupshared uint val; +Baz ConstructBaz(float3x2 arg0) { + Baz ret = (Baz)0; + ret.m_0 = arg0[0]; + ret.m_1 = arg0[1]; + ret.m_2 = arg0[2]; + return ret; +} + float3x2 GetMatmOnBaz(Baz obj) { return float3x2(obj.m_0, obj.m_1, obj.m_2); } @@ -110,22 +117,14 @@ void SetMatScalarmOnBaz(Baz obj, float scalar, uint mat_idx, uint vec_idx) { } } -Baz ConstructBaz(float3x2 arg0) { - Baz ret = (Baz)0; - ret.m_0 = arg0[0]; - ret.m_1 = arg0[1]; - ret.m_2 = arg0[2]; - return ret; -} - void test_matrix_within_struct_accesses() { int idx = (int)0; Baz t = (Baz)0; idx = 1; - int _expr2 = idx; - idx = (_expr2 - 1); + int _expr3 = idx; + idx = (_expr3 - 1); float3x2 l0_ = GetMatmOnBaz(baz); float2 l1_ = GetMatmOnBaz(baz)[0]; int _expr15 = idx; @@ -139,8 +138,8 @@ void test_matrix_within_struct_accesses() int _expr43 = idx; float l6_ = GetMatmOnBaz(baz)[_expr41][_expr43]; t = ConstructBaz(float3x2((1.0).xx, (2.0).xx, (3.0).xx)); - int _expr55 = idx; - idx = (_expr55 + 1); + int _expr56 = idx; + idx = (_expr56 + 1); SetMatmOnBaz(t, float3x2((6.0).xx, (5.0).xx, (4.0).xx)); t.m_0 = (9.0).xx; int _expr72 = idx; @@ -168,8 +167,8 @@ void test_matrix_within_array_within_struct_accesses() MatCx2InArray t_1 = (MatCx2InArray)0; idx_1 = 1; - int _expr2 = idx_1; - idx_1 = (_expr2 - 1); + int _expr3 = idx_1; + idx_1 = (_expr3 - 1); float4x2 l0_1[2] = ((float4x2[2])nested_mat_cx2_.am); float4x2 l1_1 = ((float4x2)nested_mat_cx2_.am[0]); float2 l2_1 = nested_mat_cx2_.am[0]._0; @@ -184,8 +183,8 @@ void test_matrix_within_array_within_struct_accesses() int _expr60 = idx_1; float l7_ = __get_col_of_mat4x2(nested_mat_cx2_.am[0], _expr58)[_expr60]; t_1 = ConstructMatCx2InArray((float4x2[2])0); - int _expr66 = idx_1; - idx_1 = (_expr66 + 1); + int _expr67 = idx_1; + idx_1 = (_expr67 + 1); t_1.am = (__mat4x2[2])(float4x2[2])0; t_1.am[0] = (__mat4x2)float4x2((8.0).xx, (7.0).xx, (6.0).xx, (5.0).xx); t_1.am[0]._0 = (9.0).xx; @@ -231,6 +230,12 @@ void assign_array_through_ptr_fn(inout float4 foo_2[2]) return; } +typedef int ret_Constructarray5_int_[5]; +ret_Constructarray5_int_ Constructarray5_int_(int arg0, int arg1, int arg2, int arg3, int arg4) { + int ret[5] = { arg0, arg1, arg2, arg3, arg4 }; + return ret; +} + typedef uint2 ret_Constructarray2_uint2_[2]; ret_Constructarray2_uint2_ Constructarray2_uint2_(uint2 arg0, uint2 arg1) { uint2 ret[2] = { arg0, arg1 }; @@ -244,12 +249,6 @@ uint NagaBufferLengthRW(RWByteAddressBuffer buffer) return ret; } -typedef int ret_Constructarray5_int_[5]; -ret_Constructarray5_int_ Constructarray5_int_(int arg0, int arg1, int arg2, int arg3, int arg4) { - int ret[5] = { arg0, arg1, arg2, arg3, arg4 }; - return ret; -} - float4 foo_vert(uint vi : SV_VertexID) : SV_Position { float foo = (float)0; diff --git a/tests/out/hlsl/array-in-ctor.hlsl b/tests/out/hlsl/array-in-ctor.hlsl index e184339e99..1079262a01 100644 --- a/tests/out/hlsl/array-in-ctor.hlsl +++ b/tests/out/hlsl/array-in-ctor.hlsl @@ -1,4 +1,3 @@ - struct Ah { float inner[2]; }; diff --git a/tests/out/hlsl/atomicOps.hlsl b/tests/out/hlsl/atomicOps.hlsl index a45afb1a88..0363920b31 100644 --- a/tests/out/hlsl/atomicOps.hlsl +++ b/tests/out/hlsl/atomicOps.hlsl @@ -1,4 +1,3 @@ - struct Struct { uint atomic_scalar; int atomic_arr[2]; diff --git a/tests/out/hlsl/binding-arrays.hlsl b/tests/out/hlsl/binding-arrays.hlsl index 7784f2425b..13d93c43c5 100644 --- a/tests/out/hlsl/binding-arrays.hlsl +++ b/tests/out/hlsl/binding-arrays.hlsl @@ -1,4 +1,3 @@ - struct UniformIndex { uint index; }; @@ -71,115 +70,115 @@ float4 main(FragmentInput_main fragmentinput_main) : SV_Target0 u2_ = (_expr28 + NagaDimensions2D(texture_array_unbounded[uniform_index])); uint2 _expr33 = u2_; u2_ = (_expr33 + NagaDimensions2D(texture_array_unbounded[NonUniformResourceIndex(non_uniform_index)])); - float4 _expr41 = texture_array_bounded[0].Gather(samp[0], uv); - float4 _expr42 = v4_; - v4_ = (_expr42 + _expr41); - float4 _expr48 = texture_array_bounded[uniform_index].Gather(samp[uniform_index], uv); - float4 _expr49 = v4_; - v4_ = (_expr49 + _expr48); - float4 _expr55 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].Gather(samp[NonUniformResourceIndex(non_uniform_index)], uv); - float4 _expr56 = v4_; - v4_ = (_expr56 + _expr55); - float4 _expr65 = texture_array_depth[0].GatherCmp(samp_comp[0], uv, 0.0); - float4 _expr66 = v4_; - v4_ = (_expr66 + _expr65); - float4 _expr73 = texture_array_depth[uniform_index].GatherCmp(samp_comp[uniform_index], uv, 0.0); - float4 _expr74 = v4_; - v4_ = (_expr74 + _expr73); - float4 _expr81 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].GatherCmp(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); - float4 _expr82 = v4_; - v4_ = (_expr82 + _expr81); - float4 _expr88 = texture_array_unbounded[0].Load(int3(pix, 0)); - float4 _expr89 = v4_; - v4_ = (_expr89 + _expr88); - float4 _expr94 = texture_array_unbounded[uniform_index].Load(int3(pix, 0)); - float4 _expr95 = v4_; - v4_ = (_expr95 + _expr94); - float4 _expr100 = texture_array_unbounded[NonUniformResourceIndex(non_uniform_index)].Load(int3(pix, 0)); - float4 _expr101 = v4_; - v4_ = (_expr101 + _expr100); - uint _expr107 = u1_; - u1_ = (_expr107 + NagaNumLayers2DArray(texture_array_2darray[0])); - uint _expr112 = u1_; - u1_ = (_expr112 + NagaNumLayers2DArray(texture_array_2darray[uniform_index])); - uint _expr117 = u1_; - u1_ = (_expr117 + NagaNumLayers2DArray(texture_array_2darray[NonUniformResourceIndex(non_uniform_index)])); - uint _expr123 = u1_; - u1_ = (_expr123 + NagaNumLevels2D(texture_array_bounded[0])); - uint _expr128 = u1_; - u1_ = (_expr128 + NagaNumLevels2D(texture_array_bounded[uniform_index])); - uint _expr133 = u1_; - u1_ = (_expr133 + NagaNumLevels2D(texture_array_bounded[NonUniformResourceIndex(non_uniform_index)])); - uint _expr139 = u1_; - u1_ = (_expr139 + NagaMSNumSamples2D(texture_array_multisampled[0])); - uint _expr144 = u1_; - u1_ = (_expr144 + NagaMSNumSamples2D(texture_array_multisampled[uniform_index])); - uint _expr149 = u1_; - u1_ = (_expr149 + NagaMSNumSamples2D(texture_array_multisampled[NonUniformResourceIndex(non_uniform_index)])); - float4 _expr157 = texture_array_bounded[0].Sample(samp[0], uv); - float4 _expr158 = v4_; - v4_ = (_expr158 + _expr157); - float4 _expr164 = texture_array_bounded[uniform_index].Sample(samp[uniform_index], uv); - float4 _expr165 = v4_; - v4_ = (_expr165 + _expr164); - float4 _expr171 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].Sample(samp[NonUniformResourceIndex(non_uniform_index)], uv); - float4 _expr172 = v4_; - v4_ = (_expr172 + _expr171); - float4 _expr181 = texture_array_bounded[0].SampleBias(samp[0], uv, 0.0); - float4 _expr182 = v4_; - v4_ = (_expr182 + _expr181); - float4 _expr189 = texture_array_bounded[uniform_index].SampleBias(samp[uniform_index], uv, 0.0); - float4 _expr190 = v4_; - v4_ = (_expr190 + _expr189); - float4 _expr197 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleBias(samp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); - float4 _expr198 = v4_; - v4_ = (_expr198 + _expr197); - float _expr207 = texture_array_depth[0].SampleCmp(samp_comp[0], uv, 0.0); - float _expr208 = v1_; - v1_ = (_expr208 + _expr207); - float _expr215 = texture_array_depth[uniform_index].SampleCmp(samp_comp[uniform_index], uv, 0.0); - float _expr216 = v1_; - v1_ = (_expr216 + _expr215); - float _expr223 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].SampleCmp(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); - float _expr224 = v1_; - v1_ = (_expr224 + _expr223); - float _expr233 = texture_array_depth[0].SampleCmpLevelZero(samp_comp[0], uv, 0.0); - float _expr234 = v1_; - v1_ = (_expr234 + _expr233); - float _expr241 = texture_array_depth[uniform_index].SampleCmpLevelZero(samp_comp[uniform_index], uv, 0.0); - float _expr242 = v1_; - v1_ = (_expr242 + _expr241); - float _expr249 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].SampleCmpLevelZero(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); - float _expr250 = v1_; - v1_ = (_expr250 + _expr249); - float4 _expr258 = texture_array_bounded[0].SampleGrad(samp[0], uv, uv, uv); - float4 _expr259 = v4_; - v4_ = (_expr259 + _expr258); - float4 _expr265 = texture_array_bounded[uniform_index].SampleGrad(samp[uniform_index], uv, uv, uv); - float4 _expr266 = v4_; - v4_ = (_expr266 + _expr265); - float4 _expr272 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleGrad(samp[NonUniformResourceIndex(non_uniform_index)], uv, uv, uv); - float4 _expr273 = v4_; - v4_ = (_expr273 + _expr272); - float4 _expr282 = texture_array_bounded[0].SampleLevel(samp[0], uv, 0.0); - float4 _expr283 = v4_; - v4_ = (_expr283 + _expr282); - float4 _expr290 = texture_array_bounded[uniform_index].SampleLevel(samp[uniform_index], uv, 0.0); - float4 _expr291 = v4_; - v4_ = (_expr291 + _expr290); - float4 _expr298 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleLevel(samp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); - float4 _expr299 = v4_; - v4_ = (_expr299 + _expr298); - float4 _expr304 = v4_; - texture_array_storage[0][pix] = _expr304; + float4 _expr42 = texture_array_bounded[0].Gather(samp[0], uv); + float4 _expr43 = v4_; + v4_ = (_expr43 + _expr42); + float4 _expr50 = texture_array_bounded[uniform_index].Gather(samp[uniform_index], uv); + float4 _expr51 = v4_; + v4_ = (_expr51 + _expr50); + float4 _expr58 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].Gather(samp[NonUniformResourceIndex(non_uniform_index)], uv); + float4 _expr59 = v4_; + v4_ = (_expr59 + _expr58); + float4 _expr68 = texture_array_depth[0].GatherCmp(samp_comp[0], uv, 0.0); + float4 _expr69 = v4_; + v4_ = (_expr69 + _expr68); + float4 _expr76 = texture_array_depth[uniform_index].GatherCmp(samp_comp[uniform_index], uv, 0.0); + float4 _expr77 = v4_; + v4_ = (_expr77 + _expr76); + float4 _expr84 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].GatherCmp(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); + float4 _expr85 = v4_; + v4_ = (_expr85 + _expr84); + float4 _expr91 = texture_array_unbounded[0].Load(int3(pix, 0)); + float4 _expr92 = v4_; + v4_ = (_expr92 + _expr91); + float4 _expr97 = texture_array_unbounded[uniform_index].Load(int3(pix, 0)); + float4 _expr98 = v4_; + v4_ = (_expr98 + _expr97); + float4 _expr103 = texture_array_unbounded[NonUniformResourceIndex(non_uniform_index)].Load(int3(pix, 0)); + float4 _expr104 = v4_; + v4_ = (_expr104 + _expr103); + uint _expr110 = u1_; + u1_ = (_expr110 + NagaNumLayers2DArray(texture_array_2darray[0])); + uint _expr115 = u1_; + u1_ = (_expr115 + NagaNumLayers2DArray(texture_array_2darray[uniform_index])); + uint _expr120 = u1_; + u1_ = (_expr120 + NagaNumLayers2DArray(texture_array_2darray[NonUniformResourceIndex(non_uniform_index)])); + uint _expr126 = u1_; + u1_ = (_expr126 + NagaNumLevels2D(texture_array_bounded[0])); + uint _expr131 = u1_; + u1_ = (_expr131 + NagaNumLevels2D(texture_array_bounded[uniform_index])); + uint _expr136 = u1_; + u1_ = (_expr136 + NagaNumLevels2D(texture_array_bounded[NonUniformResourceIndex(non_uniform_index)])); + uint _expr142 = u1_; + u1_ = (_expr142 + NagaMSNumSamples2D(texture_array_multisampled[0])); + uint _expr147 = u1_; + u1_ = (_expr147 + NagaMSNumSamples2D(texture_array_multisampled[uniform_index])); + uint _expr152 = u1_; + u1_ = (_expr152 + NagaMSNumSamples2D(texture_array_multisampled[NonUniformResourceIndex(non_uniform_index)])); + float4 _expr160 = texture_array_bounded[0].Sample(samp[0], uv); + float4 _expr161 = v4_; + v4_ = (_expr161 + _expr160); + float4 _expr167 = texture_array_bounded[uniform_index].Sample(samp[uniform_index], uv); + float4 _expr168 = v4_; + v4_ = (_expr168 + _expr167); + float4 _expr174 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].Sample(samp[NonUniformResourceIndex(non_uniform_index)], uv); + float4 _expr175 = v4_; + v4_ = (_expr175 + _expr174); + float4 _expr184 = texture_array_bounded[0].SampleBias(samp[0], uv, 0.0); + float4 _expr185 = v4_; + v4_ = (_expr185 + _expr184); + float4 _expr192 = texture_array_bounded[uniform_index].SampleBias(samp[uniform_index], uv, 0.0); + float4 _expr193 = v4_; + v4_ = (_expr193 + _expr192); + float4 _expr200 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleBias(samp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); + float4 _expr201 = v4_; + v4_ = (_expr201 + _expr200); + float _expr210 = texture_array_depth[0].SampleCmp(samp_comp[0], uv, 0.0); + float _expr211 = v1_; + v1_ = (_expr211 + _expr210); + float _expr218 = texture_array_depth[uniform_index].SampleCmp(samp_comp[uniform_index], uv, 0.0); + float _expr219 = v1_; + v1_ = (_expr219 + _expr218); + float _expr226 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].SampleCmp(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); + float _expr227 = v1_; + v1_ = (_expr227 + _expr226); + float _expr236 = texture_array_depth[0].SampleCmpLevelZero(samp_comp[0], uv, 0.0); + float _expr237 = v1_; + v1_ = (_expr237 + _expr236); + float _expr244 = texture_array_depth[uniform_index].SampleCmpLevelZero(samp_comp[uniform_index], uv, 0.0); + float _expr245 = v1_; + v1_ = (_expr245 + _expr244); + float _expr252 = texture_array_depth[NonUniformResourceIndex(non_uniform_index)].SampleCmpLevelZero(samp_comp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); + float _expr253 = v1_; + v1_ = (_expr253 + _expr252); + float4 _expr261 = texture_array_bounded[0].SampleGrad(samp[0], uv, uv, uv); + float4 _expr262 = v4_; + v4_ = (_expr262 + _expr261); + float4 _expr268 = texture_array_bounded[uniform_index].SampleGrad(samp[uniform_index], uv, uv, uv); + float4 _expr269 = v4_; + v4_ = (_expr269 + _expr268); + float4 _expr275 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleGrad(samp[NonUniformResourceIndex(non_uniform_index)], uv, uv, uv); + float4 _expr276 = v4_; + v4_ = (_expr276 + _expr275); + float4 _expr285 = texture_array_bounded[0].SampleLevel(samp[0], uv, 0.0); + float4 _expr286 = v4_; + v4_ = (_expr286 + _expr285); + float4 _expr293 = texture_array_bounded[uniform_index].SampleLevel(samp[uniform_index], uv, 0.0); + float4 _expr294 = v4_; + v4_ = (_expr294 + _expr293); + float4 _expr301 = texture_array_bounded[NonUniformResourceIndex(non_uniform_index)].SampleLevel(samp[NonUniformResourceIndex(non_uniform_index)], uv, 0.0); + float4 _expr302 = v4_; + v4_ = (_expr302 + _expr301); float4 _expr307 = v4_; - texture_array_storage[uniform_index][pix] = _expr307; + texture_array_storage[0][pix] = _expr307; float4 _expr310 = v4_; - texture_array_storage[NonUniformResourceIndex(non_uniform_index)][pix] = _expr310; - uint2 _expr311 = u2_; - uint _expr312 = u1_; - float2 v2_ = float2((_expr311 + (_expr312).xx)); - float4 _expr316 = v4_; - float _expr323 = v1_; - return ((_expr316 + float4(v2_.x, v2_.y, v2_.x, v2_.y)) + (_expr323).xxxx); + texture_array_storage[uniform_index][pix] = _expr310; + float4 _expr313 = v4_; + texture_array_storage[NonUniformResourceIndex(non_uniform_index)][pix] = _expr313; + uint2 _expr314 = u2_; + uint _expr315 = u1_; + float2 v2_ = float2((_expr314 + (_expr315).xx)); + float4 _expr319 = v4_; + float _expr326 = v1_; + return ((_expr319 + float4(v2_.x, v2_.y, v2_.x, v2_.y)) + (_expr326).xxxx); } diff --git a/tests/out/hlsl/bitcast.hlsl b/tests/out/hlsl/bitcast.hlsl index eda86b0abc..00f4206a10 100644 --- a/tests/out/hlsl/bitcast.hlsl +++ b/tests/out/hlsl/bitcast.hlsl @@ -1,4 +1,3 @@ - [numthreads(1, 1, 1)] void main() { diff --git a/tests/out/hlsl/bits.hlsl b/tests/out/hlsl/bits.hlsl index 425738067c..55e1afbd80 100644 --- a/tests/out/hlsl/bits.hlsl +++ b/tests/out/hlsl/bits.hlsl @@ -1,4 +1,3 @@ - [numthreads(1, 1, 1)] void main() { diff --git a/tests/out/hlsl/boids.hlsl b/tests/out/hlsl/boids.hlsl index d6bac1cb26..5400a5e3a8 100644 --- a/tests/out/hlsl/boids.hlsl +++ b/tests/out/hlsl/boids.hlsl @@ -1,5 +1,3 @@ -static const uint NUM_PARTICLES = 1500; - struct Particle { float2 pos; float2 vel; @@ -15,6 +13,8 @@ struct SimParams { float rule3Scale; }; +static const uint NUM_PARTICLES = 1500u; + cbuffer params : register(b0) { SimParams params; } ByteAddressBuffer particlesSrc : register(t1); RWByteAddressBuffer particlesDst : register(u2); diff --git a/tests/out/hlsl/break-if.hlsl b/tests/out/hlsl/break-if.hlsl index 5a3a453e55..f1aaaac092 100644 --- a/tests/out/hlsl/break-if.hlsl +++ b/tests/out/hlsl/break-if.hlsl @@ -1,4 +1,3 @@ - void breakIfEmpty() { bool loop_init = true; diff --git a/tests/out/hlsl/collatz.hlsl b/tests/out/hlsl/collatz.hlsl index aa04129651..92539ee2f4 100644 --- a/tests/out/hlsl/collatz.hlsl +++ b/tests/out/hlsl/collatz.hlsl @@ -1,4 +1,3 @@ - RWByteAddressBuffer v_indices : register(u0); uint collatz_iterations(uint n_base) diff --git a/tests/out/hlsl/constructors.hlsl b/tests/out/hlsl/constructors.hlsl new file mode 100644 index 0000000000..3b9c06b0c1 --- /dev/null +++ b/tests/out/hlsl/constructors.hlsl @@ -0,0 +1,60 @@ +struct Foo { + float4 a; + int b; + int _end_pad_0; + int _end_pad_1; + int _end_pad_2; +}; + +typedef float2x2 ret_Constructarray1_float2x2_[1]; +ret_Constructarray1_float2x2_ Constructarray1_float2x2_(float2x2 arg0) { + float2x2 ret[1] = { arg0 }; + return ret; +} + +typedef int ret_Constructarray4_int_[4]; +ret_Constructarray4_int_ Constructarray4_int_(int arg0, int arg1, int arg2, int arg3) { + int ret[4] = { arg0, arg1, arg2, arg3 }; + return ret; +} + +static const float3 const2_ = float3(0.0, 1.0, 2.0); +static const float2x2 const3_ = float2x2(float2(0.0, 1.0), float2(2.0, 3.0)); +static const float2x2 const4_[1] = Constructarray1_float2x2_(float2x2(float2(0.0, 1.0), float2(2.0, 3.0))); +static const bool cz0_ = (bool)0; +static const int cz1_ = (int)0; +static const uint cz2_ = (uint)0; +static const float cz3_ = (float)0; +static const uint2 cz4_ = (uint2)0; +static const float2x2 cz5_ = (float2x2)0; +static const Foo cz6_[3] = (Foo[3])0; +static const Foo cz7_ = (Foo)0; +static const int cp3_[4] = Constructarray4_int_(0, 1, 2, 3); + +Foo ConstructFoo(float4 arg0, int arg1) { + Foo ret = (Foo)0; + ret.a = arg0; + ret.b = arg1; + return ret; +} + +[numthreads(1, 1, 1)] +void main() +{ + Foo foo = (Foo)0; + + foo = ConstructFoo((1.0).xxxx, 1); + float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)); + float4x4 m1_ = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0)); + uint2 cit0_ = (0u).xx; + 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 ic6_ = asuint((uint2)0); + float2x3 ic7_ = asfloat((float2x3)0); +} diff --git a/tests/out/hlsl/constructors.hlsl.config b/tests/out/hlsl/constructors.hlsl.config new file mode 100644 index 0000000000..246c485cf7 --- /dev/null +++ b/tests/out/hlsl/constructors.hlsl.config @@ -0,0 +1,3 @@ +vertex=() +fragment=() +compute=(main:cs_5_1 ) diff --git a/tests/out/hlsl/constructors.ron b/tests/out/hlsl/constructors.ron new file mode 100644 index 0000000000..a07b03300b --- /dev/null +++ b/tests/out/hlsl/constructors.ron @@ -0,0 +1,12 @@ +( + vertex:[ + ], + fragment:[ + ], + compute:[ + ( + entry_point:"main", + target_profile:"cs_5_1", + ), + ], +) diff --git a/tests/out/hlsl/control-flow.hlsl b/tests/out/hlsl/control-flow.hlsl index 7f7a4b6e5c..8d71388c43 100644 --- a/tests/out/hlsl/control-flow.hlsl +++ b/tests/out/hlsl/control-flow.hlsl @@ -1,4 +1,3 @@ - void switch_default_break(int i) { switch(i) { diff --git a/tests/out/hlsl/do-while.hlsl b/tests/out/hlsl/do-while.hlsl index 9f6a1854c9..88a3d522e8 100644 --- a/tests/out/hlsl/do-while.hlsl +++ b/tests/out/hlsl/do-while.hlsl @@ -1,11 +1,10 @@ - void fb1_(inout bool cond) { bool loop_init = true; while(true) { if (!loop_init) { - bool _expr6 = cond; - if (!(_expr6)) { + bool _expr2 = cond; + if (!(_expr2)) { break; } } diff --git a/tests/out/hlsl/empty-global-name.hlsl b/tests/out/hlsl/empty-global-name.hlsl index e958af7e9b..2ad022d6bb 100644 --- a/tests/out/hlsl/empty-global-name.hlsl +++ b/tests/out/hlsl/empty-global-name.hlsl @@ -1,4 +1,3 @@ - struct type_1 { int member; }; @@ -7,8 +6,8 @@ RWByteAddressBuffer unnamed : register(u0); void function() { - int _expr8 = asint(unnamed.Load(0)); - unnamed.Store(0, asuint((_expr8 + 1))); + int _expr4 = asint(unnamed.Load(0)); + unnamed.Store(0, asuint((_expr4 + 1))); return; } diff --git a/tests/out/hlsl/empty.hlsl b/tests/out/hlsl/empty.hlsl index 2b52438678..e79d36b9c8 100644 --- a/tests/out/hlsl/empty.hlsl +++ b/tests/out/hlsl/empty.hlsl @@ -1,4 +1,3 @@ - [numthreads(1, 1, 1)] void main() { diff --git a/tests/out/hlsl/fragment-output.hlsl b/tests/out/hlsl/fragment-output.hlsl index a4ba428a68..be425a5ef7 100644 --- a/tests/out/hlsl/fragment-output.hlsl +++ b/tests/out/hlsl/fragment-output.hlsl @@ -1,4 +1,3 @@ - struct FragmentOutputVec4Vec3_ { float4 vec4f : SV_Target0; nointerpolation int4 vec4i : SV_Target1; diff --git a/tests/out/hlsl/functions.hlsl b/tests/out/hlsl/functions.hlsl index 04a3404150..6d7e210307 100644 --- a/tests/out/hlsl/functions.hlsl +++ b/tests/out/hlsl/functions.hlsl @@ -1,4 +1,3 @@ - float2 test_fma() { float2 a = float2(2.0, 2.0); diff --git a/tests/out/hlsl/globals.hlsl b/tests/out/hlsl/globals.hlsl index b0b92f2069..f8cede1ac5 100644 --- a/tests/out/hlsl/globals.hlsl +++ b/tests/out/hlsl/globals.hlsl @@ -1,5 +1,3 @@ -static const bool Foo_1 = true; - typedef struct { float2 _0; float2 _1; float2 _2; } __mat3x2; float2 __get_col_of_mat3x2(__mat3x2 mat, uint idx) { switch(idx) { @@ -56,6 +54,8 @@ struct FooStruct { float v1_; }; +static const bool Foo_1 = true; + groupshared float wg[10]; groupshared uint at_1; RWByteAddressBuffer alignment : register(u1); diff --git a/tests/out/hlsl/hlsl-keyword.hlsl b/tests/out/hlsl/hlsl-keyword.hlsl index efdeb9960f..8602525e29 100644 --- a/tests/out/hlsl/hlsl-keyword.hlsl +++ b/tests/out/hlsl/hlsl-keyword.hlsl @@ -1,4 +1,3 @@ - float4 fs_main() : SV_Target0 { float4 Pass_ = (float4)0; diff --git a/tests/out/hlsl/image.hlsl b/tests/out/hlsl/image.hlsl index 75672b9be8..e284813a1b 100644 --- a/tests/out/hlsl/image.hlsl +++ b/tests/out/hlsl/image.hlsl @@ -1,4 +1,3 @@ - Texture2D image_mipmapped_src : register(t0); Texture2DMS image_multisampled_src : register(t3); Texture2DMS image_depth_multisampled_src : register(t4); diff --git a/tests/out/hlsl/interpolate.hlsl b/tests/out/hlsl/interpolate.hlsl index a9bd0c346b..aa1986f5d2 100644 --- a/tests/out/hlsl/interpolate.hlsl +++ b/tests/out/hlsl/interpolate.hlsl @@ -1,4 +1,3 @@ - struct FragmentInput { float4 position : SV_Position; nointerpolation uint _flat : LOC0; diff --git a/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl b/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl index 23fdc45f47..d086bf14b4 100644 --- a/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl +++ b/tests/out/hlsl/inv-hyperbolic-trig-functions.hlsl @@ -1,4 +1,3 @@ - static float a = (float)0; void main_1() @@ -7,12 +6,12 @@ void main_1() float c = (float)0; float d = (float)0; + float _expr4 = a; + b = log(_expr4 + sqrt(_expr4 * _expr4 + 1.0)); + float _expr6 = a; + c = log(_expr6 + sqrt(_expr6 * _expr6 - 1.0)); float _expr8 = a; - b = log(_expr8 + sqrt(_expr8 * _expr8 + 1.0)); - float _expr10 = a; - c = log(_expr10 + sqrt(_expr10 * _expr10 - 1.0)); - float _expr12 = a; - d = 0.5 * log((1.0 + _expr12) / (1.0 - _expr12)); + d = 0.5 * log((1.0 + _expr8) / (1.0 - _expr8)); return; } diff --git a/tests/out/hlsl/math-functions.hlsl b/tests/out/hlsl/math-functions.hlsl index e3443604f1..a1be810532 100644 --- a/tests/out/hlsl/math-functions.hlsl +++ b/tests/out/hlsl/math-functions.hlsl @@ -1,4 +1,3 @@ - void main() { float4 v = (0.0).xxxx; diff --git a/tests/out/hlsl/operators.hlsl b/tests/out/hlsl/operators.hlsl index c2a92a967d..4c57f31343 100644 --- a/tests/out/hlsl/operators.hlsl +++ b/tests/out/hlsl/operators.hlsl @@ -3,24 +3,16 @@ static const float4 v_f32_zero = float4(0.0, 0.0, 0.0, 0.0); static const float4 v_f32_half = float4(0.5, 0.5, 0.5, 0.5); static const int4 v_i32_one = int4(1, 1, 1, 1); -struct Foo { - float4 a; - int b; - int _end_pad_0; - int _end_pad_1; - int _end_pad_2; -}; - float4 builtins() { int s1_ = (true ? 1 : 0); - float4 s2_ = (true ? float4(1.0, 1.0, 1.0, 1.0) : float4(0.0, 0.0, 0.0, 0.0)); - float4 s3_ = (bool4(false, false, false, false) ? float4(0.0, 0.0, 0.0, 0.0) : float4(1.0, 1.0, 1.0, 1.0)); - float4 m1_ = lerp(float4(0.0, 0.0, 0.0, 0.0), float4(1.0, 1.0, 1.0, 1.0), float4(0.5, 0.5, 0.5, 0.5)); - float4 m2_ = lerp(float4(0.0, 0.0, 0.0, 0.0), float4(1.0, 1.0, 1.0, 1.0), 0.1); - float b1_ = asfloat(int4(1, 1, 1, 1).x); - float4 b2_ = asfloat(int4(1, 1, 1, 1)); - int4 v_i32_zero = int4(float4(0.0, 0.0, 0.0, 0.0)); + float4 s2_ = (true ? v_f32_one : v_f32_zero); + 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); + float4 b2_ = asfloat(v_i32_one); + int4 v_i32_zero = int4(v_f32_zero); return (((((float4(((s1_).xxxx + v_i32_zero)) + s2_) + m1_) + m2_) + (b1_).xxxx) + b2_); } @@ -52,41 +44,6 @@ float3 bool_cast(float3 x) return float3(y); } -Foo ConstructFoo(float4 arg0, int arg1) { - Foo ret = (Foo)0; - ret.a = arg0; - ret.b = arg1; - return ret; -} - -typedef int ret_Constructarray4_int_[4]; -ret_Constructarray4_int_ Constructarray4_int_(int arg0, int arg1, int arg2, int arg3) { - int ret[4] = { arg0, arg1, arg2, arg3 }; - return ret; -} - -float constructors() -{ - Foo foo = (Foo)0; - - foo = ConstructFoo((1.0).xxxx, 1); - float2x2 m0_ = float2x2(float2(1.0, 0.0), float2(0.0, 1.0)); - float4x4 m1_1 = float4x4(float4(1.0, 0.0, 0.0, 0.0), float4(0.0, 1.0, 0.0, 0.0), float4(0.0, 0.0, 1.0, 0.0), float4(0.0, 0.0, 0.0, 1.0)); - uint2 cit0_ = (0u).xx; - 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 ic6_ = asuint((uint2)0); - float2x3 ic7_ = asfloat((float2x3)0); - float _expr71 = foo.a.x; - return _expr71; -} - void logical() { bool neg0_ = !(true); @@ -270,15 +227,15 @@ void assignment() a_1 = (_expr27 << 2u); int _expr30 = a_1; a_1 = (_expr30 >> 1u); - int _expr32 = a_1; - a_1 = (_expr32 + 1); - int _expr35 = a_1; - a_1 = (_expr35 - 1); + 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 _expr47 = vec0_.y; - vec0_.y = (_expr47 - 1); + int _expr43 = vec0_.y; + vec0_.y = (_expr43 + 1); + int _expr48 = vec0_.y; + vec0_.y = (_expr48 - 1); return; } @@ -298,8 +255,7 @@ void main() { const float4 _e0 = builtins(); const float4 _e1 = splat(); - const float3 _e4 = bool_cast(float4(1.0, 1.0, 1.0, 1.0).xyz); - const float _e5 = constructors(); + const float3 _e4 = bool_cast(v_f32_one.xyz); logical(); arithmetic(); bit(); diff --git a/tests/out/hlsl/padding.hlsl b/tests/out/hlsl/padding.hlsl index 32e762cce8..e3271e5663 100644 --- a/tests/out/hlsl/padding.hlsl +++ b/tests/out/hlsl/padding.hlsl @@ -1,4 +1,3 @@ - struct S { float3 a; int _end_pad_0; diff --git a/tests/out/hlsl/quad-vert.hlsl b/tests/out/hlsl/quad-vert.hlsl index 1fdcc43f53..bed52d5054 100644 --- a/tests/out/hlsl/quad-vert.hlsl +++ b/tests/out/hlsl/quad-vert.hlsl @@ -1,4 +1,3 @@ - struct gl_PerVertex { float4 gl_Position : SV_Position; float gl_PointSize; @@ -12,12 +11,6 @@ struct type_9 { float4 gl_Position : SV_Position; }; -typedef float ret_Constructarray1_float_[1]; -ret_Constructarray1_float_ Constructarray1_float_(float arg0) { - float ret[1] = { arg0 }; - return ret; -} - gl_PerVertex Constructgl_PerVertex(float4 arg0, float arg1, float arg2[1], float arg3[1]) { gl_PerVertex ret = (gl_PerVertex)0; ret.gl_Position = arg0; @@ -29,7 +22,7 @@ gl_PerVertex Constructgl_PerVertex(float4 arg0, float arg1, float arg2[1], float static float2 v_uv = (float2)0; static float2 a_uv_1 = (float2)0; -static gl_PerVertex perVertexStruct = Constructgl_PerVertex(float4(0.0, 0.0, 0.0, 1.0), 1.0, Constructarray1_float_(0.0), Constructarray1_float_(0.0)); +static gl_PerVertex perVertexStruct = Constructgl_PerVertex(float4(0.0, 0.0, 0.0, 1.0), 1.0, (float[1])0, (float[1])0); static float2 a_pos_1 = (float2)0; struct VertexOutput_main { @@ -39,10 +32,10 @@ struct VertexOutput_main { void main_1() { - float2 _expr12 = a_uv_1; - v_uv = _expr12; - float2 _expr13 = a_pos_1; - perVertexStruct.gl_Position = float4(_expr13.x, _expr13.y, 0.0, 1.0); + float2 _expr8 = a_uv_1; + v_uv = _expr8; + float2 _expr9 = a_pos_1; + perVertexStruct.gl_Position = float4(_expr9.x, _expr9.y, 0.0, 1.0); return; } diff --git a/tests/out/hlsl/quad.hlsl b/tests/out/hlsl/quad.hlsl index 9a987af1ce..5bd8530c68 100644 --- a/tests/out/hlsl/quad.hlsl +++ b/tests/out/hlsl/quad.hlsl @@ -1,10 +1,10 @@ -static const float c_scale = 1.2000000476837158; - struct VertexOutput { float2 uv : LOC0; float4 position : SV_Position; }; +static const float c_scale = 1.2; + Texture2D u_texture : register(t0); SamplerState u_sampler : register(s1); diff --git a/tests/out/hlsl/shadow.hlsl b/tests/out/hlsl/shadow.hlsl index 5ea06f90c3..7116e803eb 100644 --- a/tests/out/hlsl/shadow.hlsl +++ b/tests/out/hlsl/shadow.hlsl @@ -1,6 +1,3 @@ -static const float3 c_ambient = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); -static const uint c_max_lights = 10; - struct Globals { row_major float4x4 view_proj; uint4 num_lights; @@ -23,6 +20,9 @@ struct Light { float4 color; }; +static const float3 c_ambient = float3(0.05, 0.05, 0.05); +static const uint c_max_lights = 10u; + cbuffer u_globals : register(b0) { Globals u_globals; } cbuffer u_entity : register(b0, space1) { Entity u_entity; } ByteAddressBuffer s_lights : register(t1); @@ -92,13 +92,13 @@ float4 fs_main(FragmentInput_fs_main fragmentinput_fs_main) : SV_Target0 uint i = (uint)0; float3 normal_1 = normalize(in_.world_normal); - color = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color = c_ambient; i = 0u; bool loop_init = true; while(true) { if (!loop_init) { - uint _expr39 = i; - i = (_expr39 + 1u); + uint _expr40 = i; + i = (_expr40 + 1u); } loop_init = false; uint _expr7 = i; @@ -130,13 +130,13 @@ float4 fs_main_without_storage(FragmentInput_fs_main_without_storage fragmentinp uint i_1 = (uint)0; float3 normal_2 = normalize(in_1.world_normal); - color_1 = float3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color_1 = c_ambient; i_1 = 0u; bool loop_init_1 = true; while(true) { if (!loop_init_1) { - uint _expr39 = i_1; - i_1 = (_expr39 + 1u); + uint _expr40 = i_1; + i_1 = (_expr40 + 1u); } loop_init_1 = false; uint _expr7 = i_1; diff --git a/tests/out/hlsl/standard.hlsl b/tests/out/hlsl/standard.hlsl index aacb25012a..a2bcc70ec4 100644 --- a/tests/out/hlsl/standard.hlsl +++ b/tests/out/hlsl/standard.hlsl @@ -1,4 +1,3 @@ - struct FragmentInput_derivatives { float4 foo_1 : SV_Position; }; diff --git a/tests/out/hlsl/texture-arg.hlsl b/tests/out/hlsl/texture-arg.hlsl index dd0ca1096c..b3fac887f4 100644 --- a/tests/out/hlsl/texture-arg.hlsl +++ b/tests/out/hlsl/texture-arg.hlsl @@ -1,4 +1,3 @@ - Texture2D Texture : register(t0); SamplerState Sampler : register(s1); diff --git a/tests/out/hlsl/workgroup-uniform-load.hlsl b/tests/out/hlsl/workgroup-uniform-load.hlsl index ad049461fc..663fe33649 100644 --- a/tests/out/hlsl/workgroup-uniform-load.hlsl +++ b/tests/out/hlsl/workgroup-uniform-load.hlsl @@ -1,4 +1,4 @@ -static const uint SIZE = 128; +static const uint SIZE = 128u; groupshared int arr_i32_[128]; diff --git a/tests/out/hlsl/workgroup-var-init.hlsl b/tests/out/hlsl/workgroup-var-init.hlsl index 3e70d6e095..e0bd73f8ff 100644 --- a/tests/out/hlsl/workgroup-var-init.hlsl +++ b/tests/out/hlsl/workgroup-var-init.hlsl @@ -1,4 +1,3 @@ - struct WStruct { uint arr[512]; int atom; diff --git a/tests/out/ir/access.ron b/tests/out/ir/access.ron index 6dda26d0dc..7447249127 100644 --- a/tests/out/ir/access.ron +++ b/tests/out/ir/access.ron @@ -335,87 +335,14 @@ ray_desc: None, ray_intersection: None, ), - constants: [ - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Uint(0), - ), - ), - ( - name: None, - specialization: None, - inner: Composite( - ty: 2, - components: [ - 1, - 1, - 1, - ], - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), - ), - ( - name: None, - specialization: None, - inner: Composite( - ty: 4, - components: [ - 1, - 2, - 3, - ], - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(10), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(5), - ), - ), - ], + constants: [], global_variables: [ ( name: Some("global_const"), space: Private, binding: None, ty: 4, - init: Some(4), + init: Some(7), ), ( name: Some("bar"), @@ -469,6 +396,44 @@ init: None, ), ], + const_expressions: [ + Literal(U32(0)), + Literal(U32(0)), + Literal(U32(0)), + Literal(U32(0)), + Compose( + ty: 2, + components: [ + 2, + 3, + 4, + ], + ), + Literal(I32(0)), + Compose( + ty: 4, + components: [ + 1, + 5, + 6, + ], + ), + Literal(I32(2)), + Literal(I32(10)), + Literal(I32(2)), + Literal(I32(2)), + Literal(I32(2)), + Literal(I32(2)), + Literal(I32(10)), + Literal(I32(5)), + Literal(I32(5)), + Literal(I32(10)), + Literal(I32(5)), + Literal(I32(2)), + Literal(I32(2)), + Literal(I32(2)), + Literal(I32(2)), + ], functions: [ ( name: Some("test_matrix_within_struct_accesses"), @@ -489,14 +454,14 @@ expressions: [ Literal(I32(1)), LocalVariable(1), + Literal(I32(1)), Load( pointer: 2, ), - Constant(7), Binary( op: Subtract, - left: 3, - right: 4, + left: 4, + right: 3, ), GlobalVariable(3), AccessIndex( @@ -644,14 +609,14 @@ ], ), LocalVariable(2), + Literal(I32(1)), Load( pointer: 2, ), - Constant(7), Binary( op: Add, - left: 56, - right: 57, + left: 57, + right: 56, ), AccessIndex( base: 55, @@ -794,11 +759,7 @@ value: 1, ), Emit(( - start: 2, - end: 3, - )), - Emit(( - start: 4, + start: 3, end: 5, )), Store( @@ -870,11 +831,7 @@ value: 54, ), Emit(( - start: 55, - end: 56, - )), - Emit(( - start: 57, + start: 56, end: 58, )), Store( @@ -1001,14 +958,14 @@ expressions: [ Literal(I32(1)), LocalVariable(1), + Literal(I32(1)), Load( pointer: 2, ), - Constant(7), Binary( op: Subtract, - left: 3, - right: 4, + left: 4, + right: 3, ), GlobalVariable(5), AccessIndex( @@ -1177,14 +1134,14 @@ ], ), LocalVariable(2), + Literal(I32(1)), Load( pointer: 2, ), - Constant(7), Binary( op: Add, - left: 67, - right: 68, + left: 68, + right: 67, ), AccessIndex( base: 66, @@ -1374,11 +1331,7 @@ value: 1, ), Emit(( - start: 2, - end: 3, - )), - Emit(( - start: 4, + start: 3, end: 5, )), Store( @@ -1474,11 +1427,7 @@ value: 65, ), Emit(( - start: 66, - end: 67, - )), - Emit(( - start: 68, + start: 67, end: 69, )), Store( diff --git a/tests/out/ir/collatz.ron b/tests/out/ir/collatz.ron index 1d38cc34f5..6451fc715f 100644 --- a/tests/out/ir/collatz.ron +++ b/tests/out/ir/collatz.ron @@ -57,6 +57,7 @@ init: None, ), ], + const_expressions: [], functions: [ ( name: Some("collatz_iterations"), diff --git a/tests/out/ir/shadow.ron b/tests/out/ir/shadow.ron index 103e69b5ff..246657255b 100644 --- a/tests/out/ir/shadow.ron +++ b/tests/out/ir/shadow.ron @@ -270,319 +270,213 @@ constants: [ ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 1, + init: 1, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(3), - ), + override: None, + ty: 1, + init: 2, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(0.0), - ), + override: None, + ty: 1, + init: 3, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(1.0), - ), + override: None, + ty: 1, + init: 4, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(0.5), - ), + override: None, + ty: 1, + init: 5, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(-0.5), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(0.05000000074505806), - ), + override: None, + ty: 2, + init: 9, ), ( name: None, - specialization: None, - inner: Composite( - ty: 2, - components: [ - 9, - 9, - 9, - ], - ), + override: None, + ty: 3, + init: 10, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Uint(10), - ), + override: None, + ty: 3, + init: 11, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Uint(0), - ), + override: None, + ty: 3, + init: 12, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Uint(1), - ), + override: None, + ty: 1, + init: 13, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Float(0.0), - ), + override: None, + ty: 9, + init: 14, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 15, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 16, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 17, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 18, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 19, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 20, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 21, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 22, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 23, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 24, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 25, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 26, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 9, + init: 27, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 28, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 29, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 9, + init: 30, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 31, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 9, + init: 32, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 33, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 34, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 9, + init: 35, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(1), - ), + override: None, + ty: 9, + init: 36, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(0), - ), + override: None, + ty: 9, + init: 37, ), ( name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), - ), - ( - name: None, - specialization: None, - inner: Scalar( - width: 4, - value: Sint(2), - ), + override: None, + ty: 9, + init: 38, ), ], global_variables: [ @@ -650,6 +544,55 @@ init: None, ), ], + const_expressions: [ + Literal(F32(0.0)), + Literal(F32(1.0)), + Literal(F32(0.5)), + Literal(F32(-0.5)), + Literal(F32(0.05)), + Constant(5), + Constant(5), + Constant(5), + Compose( + ty: 2, + components: [ + 6, + 7, + 8, + ], + ), + Literal(U32(10)), + Literal(U32(0)), + Literal(U32(1)), + Literal(F32(0.0)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(1)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(1)), + Literal(I32(1)), + Literal(I32(0)), + Literal(I32(1)), + Literal(I32(2)), + Literal(I32(0)), + Literal(I32(1)), + Literal(I32(2)), + Literal(I32(0)), + Literal(I32(2)), + Literal(I32(0)), + Literal(I32(0)), + Literal(I32(2)), + Literal(I32(1)), + Literal(I32(0)), + Literal(I32(2)), + Literal(I32(2)), + Constant(6), + Constant(8), + ], functions: [ ( name: None, @@ -678,171 +621,167 @@ GlobalVariable(2), GlobalVariable(4), GlobalVariable(7), - Constant(1), - Constant(2), + Constant(16), Constant(3), - Constant(4), - Constant(20), - Constant(7), - Constant(33), - Constant(31), Constant(29), Constant(27), Constant(25), - Constant(15), - Constant(12), Constant(23), + Constant(21), + Constant(11), Constant(8), - Constant(36), - Constant(34), - Constant(14), + Constant(19), + Constant(4), Constant(32), Constant(30), - Constant(17), + Constant(10), + Constant(28), Constant(26), - Constant(39), Constant(13), - Constant(11), - Constant(9), - Constant(6), - Constant(21), - Constant(35), - Constant(19), - Constant(37), - Constant(18), - Constant(28), - Constant(16), - Constant(24), - Constant(38), Constant(22), - Constant(10), + Constant(35), + Constant(9), + Constant(7), Constant(5), + Constant(2), + Constant(17), + Constant(31), + Constant(15), + Constant(33), + Constant(14), + Constant(24), + Constant(12), + Constant(20), + Constant(34), + Constant(18), + Constant(6), + Constant(1), FunctionArgument(0), FunctionArgument(1), AccessIndex( - base: 48, + base: 44, index: 3, ), Binary( op: LessEqual, - left: 49, - right: 46, + left: 45, + right: 42, ), AccessIndex( - base: 48, + base: 44, index: 0, ), AccessIndex( - base: 48, + base: 44, index: 1, ), Compose( ty: 6, components: [ - 51, - 52, + 47, + 48, ], ), Compose( ty: 6, components: [ - 13, - 22, + 9, + 18, ], ), Binary( op: Multiply, - left: 53, - right: 54, + left: 49, + right: 50, ), AccessIndex( - base: 48, + base: 44, index: 3, ), Binary( op: Divide, - left: 34, - right: 56, + left: 30, + right: 52, ), Binary( op: Multiply, - left: 55, - right: 57, + left: 51, + right: 53, ), Splat( size: Bi, - value: 13, + value: 9, ), Binary( op: Add, - left: 58, - right: 59, + left: 54, + right: 55, ), AccessIndex( - base: 60, + base: 56, index: 0, ), AccessIndex( - base: 60, + base: 56, index: 1, ), As( - expr: 47, + expr: 43, kind: Sint, convert: None, ), As( - expr: 63, + expr: 59, kind: Float, convert: Some(4), ), Compose( ty: 2, components: [ - 61, - 62, - 64, + 57, + 58, + 60, ], ), AccessIndex( - base: 48, + base: 44, index: 2, ), AccessIndex( - base: 48, + base: 44, index: 3, ), Binary( op: Divide, - left: 34, - right: 67, + left: 30, + right: 63, ), Binary( op: Multiply, - left: 66, - right: 68, + left: 62, + right: 64, ), AccessIndex( - base: 65, + base: 61, index: 0, ), AccessIndex( - base: 65, + base: 61, index: 1, ), Compose( ty: 6, components: [ - 70, - 71, + 66, + 67, ], ), AccessIndex( - base: 65, + base: 61, index: 2, ), As( - expr: 73, + expr: 69, kind: Sint, convert: Some(4), ), @@ -850,34 +789,34 @@ image: 4, sampler: 5, gather: None, - coordinate: 72, - array_index: Some(74), + coordinate: 68, + array_index: Some(70), offset: None, level: Zero, - depth_ref: Some(69), + depth_ref: Some(65), ), ], named_expressions: {}, body: [ Emit(( - start: 48, - end: 50, + start: 44, + end: 46, )), If( - condition: 50, + condition: 46, accept: [ Return( - value: Some(34), + value: Some(30), ), ], reject: [], ), Emit(( - start: 50, - end: 75, + start: 46, + end: 71, )), Return( - value: Some(75), + value: Some(71), ), ], ), @@ -889,12 +828,12 @@ ( name: Some("color"), ty: 2, - init: Some(10), + init: Some(39), ), ( name: Some("i"), ty: 3, - init: Some(12), + init: Some(40), ), ], expressions: [ @@ -905,104 +844,100 @@ GlobalVariable(2), GlobalVariable(4), GlobalVariable(7), - Constant(1), - Constant(2), + Constant(16), Constant(3), - Constant(4), - Constant(20), - Constant(7), - Constant(33), - Constant(31), Constant(29), Constant(27), Constant(25), - Constant(15), - Constant(12), Constant(23), + Constant(21), + Constant(11), Constant(8), - Constant(36), - Constant(34), - Constant(14), + Constant(19), + Constant(4), Constant(32), Constant(30), - Constant(17), + Constant(10), + Constant(28), Constant(26), - Constant(39), Constant(13), - Constant(11), - Constant(9), - Constant(6), - Constant(21), - Constant(35), - Constant(19), - Constant(37), - Constant(18), - Constant(28), - Constant(16), - Constant(24), - Constant(38), Constant(22), - Constant(10), + Constant(35), + Constant(9), + Constant(7), Constant(5), + Constant(2), + Constant(17), + Constant(31), + Constant(15), + Constant(33), + Constant(14), + Constant(24), + Constant(12), + Constant(20), + Constant(34), + Constant(18), + Constant(6), + Constant(1), LocalVariable(1), LocalVariable(2), Load( - pointer: 48, + pointer: 44, ), AccessIndex( base: 1, index: 0, ), Access( - base: 50, - index: 41, + base: 46, + index: 37, ), Load( - pointer: 51, + pointer: 47, ), Math( fun: Min, - arg: 52, - arg1: Some(32), + arg: 48, + arg1: Some(28), arg2: None, arg3: None, ), Binary( op: GreaterEqual, - left: 49, - right: 53, + left: 45, + right: 49, ), Load( - pointer: 47, + pointer: 43, ), Load( - pointer: 48, + pointer: 44, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 57, - index: 58, + base: 53, + index: 54, ), AccessIndex( - base: 59, + base: 55, index: 0, ), Load( - pointer: 60, + pointer: 56, ), Load( pointer: 3, ), Binary( op: Multiply, - left: 61, - right: 62, + left: 57, + right: 58, ), CallResult(1), Load( @@ -1010,7 +945,7 @@ ), Math( fun: Normalize, - arg: 65, + arg: 61, arg1: None, arg2: None, arg3: None, @@ -1020,235 +955,235 @@ index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 67, - index: 68, + base: 63, + index: 64, ), AccessIndex( - base: 69, + base: 65, index: 1, ), Access( - base: 70, - index: 35, + base: 66, + index: 31, ), Load( - pointer: 71, + pointer: 67, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 73, - index: 74, + base: 69, + index: 70, ), AccessIndex( - base: 75, + base: 71, index: 1, ), Access( - base: 76, - index: 42, + base: 72, + index: 38, ), Load( - pointer: 77, + pointer: 73, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 79, - index: 80, + base: 75, + index: 76, ), AccessIndex( - base: 81, + base: 77, index: 1, ), Access( - base: 82, - index: 17, + base: 78, + index: 13, ), Load( - pointer: 83, + pointer: 79, ), Compose( ty: 2, components: [ - 72, - 78, - 84, + 68, + 74, + 80, ], ), Access( base: 3, - index: 40, + index: 36, ), Load( - pointer: 86, + pointer: 82, ), Access( base: 3, - index: 16, + index: 12, ), Load( - pointer: 88, + pointer: 84, ), Access( base: 3, - index: 27, + index: 23, ), Load( - pointer: 90, + pointer: 86, ), Compose( ty: 2, components: [ + 83, + 85, 87, - 89, - 91, ], ), Binary( op: Subtract, - left: 85, - right: 92, + left: 81, + right: 88, ), Math( fun: Normalize, - arg: 93, + arg: 89, arg1: None, arg2: None, arg3: None, ), Math( fun: Dot, - arg: 66, - arg1: Some(94), + arg: 62, + arg1: Some(90), arg2: None, arg3: None, ), Math( fun: Max, - arg: 46, - arg1: Some(95), + arg: 42, + arg1: Some(91), arg2: None, arg3: None, ), Binary( op: Multiply, - left: 64, - right: 96, + left: 60, + right: 92, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 98, - index: 99, + base: 94, + index: 95, ), AccessIndex( - base: 100, + base: 96, index: 2, ), Access( - base: 101, - index: 14, + base: 97, + index: 10, ), Load( - pointer: 102, + pointer: 98, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 104, - index: 105, + base: 100, + index: 101, ), AccessIndex( - base: 106, + base: 102, index: 2, ), Access( - base: 107, - index: 23, + base: 103, + index: 19, ), Load( - pointer: 108, + pointer: 104, ), AccessIndex( base: 6, index: 0, ), Load( - pointer: 48, + pointer: 44, ), Access( - base: 110, - index: 111, + base: 106, + index: 107, ), AccessIndex( - base: 112, + base: 108, index: 2, ), Access( - base: 113, - index: 30, + base: 109, + index: 26, ), Load( - pointer: 114, + pointer: 110, ), Compose( ty: 2, components: [ - 103, - 109, - 115, + 99, + 105, + 111, ], ), Binary( op: Multiply, - left: 116, - right: 97, + left: 112, + right: 93, ), Binary( op: Add, - left: 55, - right: 117, + left: 51, + right: 113, ), Load( - pointer: 48, + pointer: 44, ), Binary( op: Add, - left: 119, - right: 31, + left: 115, + right: 27, ), Load( - pointer: 47, + pointer: 43, ), Compose( ty: 4, components: [ - 121, - 34, + 117, + 30, ], ), ], @@ -1257,57 +1192,57 @@ Loop( body: [ Emit(( - start: 48, - end: 54, + start: 44, + end: 50, )), If( - condition: 54, + condition: 50, accept: [ Break, ], reject: [], ), Emit(( - start: 54, - end: 63, + start: 50, + end: 59, )), Call( function: 1, arguments: [ - 56, - 63, + 52, + 59, ], - result: Some(64), + result: Some(60), ), Emit(( - start: 64, - end: 118, + start: 60, + end: 114, )), Store( - pointer: 47, - value: 118, + pointer: 43, + value: 114, ), Continue, ], continuing: [ Emit(( - start: 118, - end: 120, + start: 114, + end: 116, )), Store( - pointer: 48, - value: 120, + pointer: 44, + value: 116, ), ], break_if: None, ), Emit(( - start: 120, - end: 122, + start: 116, + end: 118, )), Store( pointer: 7, - value: 122, + value: 118, ), Return( value: None, diff --git a/tests/out/msl/access.msl b/tests/out/msl/access.msl index 1e83ae7c3b..e5d875dd19 100644 --- a/tests/out/msl/access.msl +++ b/tests/out/msl/access.msl @@ -57,8 +57,6 @@ struct type_22 { struct type_26 { metal::float4 inner[2]; }; -constant metal::uint3 const_type_1_ = {0u, 0u, 0u}; -constant GlobalConst const_GlobalConst = {0u, {}, const_type_1_, 0}; void test_matrix_within_struct_accesses( constant Baz& baz @@ -66,8 +64,8 @@ void test_matrix_within_struct_accesses( int idx = {}; Baz t = {}; idx = 1; - int _e2 = idx; - idx = _e2 - 1; + int _e3 = idx; + idx = _e3 - 1; metal::float3x2 l0_ = baz.m; metal::float2 l1_ = baz.m[0]; int _e15 = idx; @@ -81,8 +79,8 @@ void test_matrix_within_struct_accesses( int _e43 = idx; float l6_ = baz.m[_e41][_e43]; t = Baz {metal::float3x2(metal::float2(1.0), metal::float2(2.0), metal::float2(3.0))}; - int _e55 = idx; - idx = _e55 + 1; + int _e56 = idx; + idx = _e56 + 1; t.m = metal::float3x2(metal::float2(6.0), metal::float2(5.0), metal::float2(4.0)); t.m[0] = metal::float2(9.0); int _e72 = idx; @@ -104,8 +102,8 @@ void test_matrix_within_array_within_struct_accesses( int idx_1 = {}; MatCx2InArray t_1 = {}; idx_1 = 1; - int _e2 = idx_1; - idx_1 = _e2 - 1; + int _e3 = idx_1; + idx_1 = _e3 - 1; type_15 l0_1 = nested_mat_cx2_.am; metal::float4x2 l1_1 = nested_mat_cx2_.am.inner[0]; metal::float2 l2_1 = nested_mat_cx2_.am.inner[0][0]; @@ -120,8 +118,8 @@ void test_matrix_within_array_within_struct_accesses( int _e60 = idx_1; float l7_ = nested_mat_cx2_.am.inner[0][_e58][_e60]; t_1 = MatCx2InArray {type_15 {}}; - int _e66 = idx_1; - idx_1 = _e66 + 1; + int _e67 = idx_1; + idx_1 = _e67 + 1; t_1.am = type_15 {}; t_1.am.inner[0] = metal::float4x2(metal::float2(8.0), metal::float2(7.0), metal::float2(6.0), metal::float2(5.0)); t_1.am.inner[0][0] = metal::float2(9.0); diff --git a/tests/out/msl/binding-arrays.msl b/tests/out/msl/binding-arrays.msl index 694f79452d..10a5397910 100644 --- a/tests/out/msl/binding-arrays.msl +++ b/tests/out/msl/binding-arrays.msl @@ -54,121 +54,121 @@ fragment main_Output main_( u2_ = _e28 + metal::uint2(texture_array_unbounded[uniform_index].get_width(), texture_array_unbounded[uniform_index].get_height()); metal::uint2 _e33 = u2_; u2_ = _e33 + metal::uint2(texture_array_unbounded[non_uniform_index].get_width(), texture_array_unbounded[non_uniform_index].get_height()); - metal::float4 _e41 = texture_array_bounded[0].gather(samp[0], uv); - metal::float4 _e42 = v4_; - v4_ = _e42 + _e41; - metal::float4 _e48 = texture_array_bounded[uniform_index].gather(samp[uniform_index], uv); - metal::float4 _e49 = v4_; - v4_ = _e49 + _e48; - metal::float4 _e55 = texture_array_bounded[non_uniform_index].gather(samp[non_uniform_index], uv); - metal::float4 _e56 = v4_; - v4_ = _e56 + _e55; - metal::float4 _e65 = texture_array_depth[0].gather_compare(samp_comp[0], uv, 0.0); - metal::float4 _e66 = v4_; - v4_ = _e66 + _e65; - metal::float4 _e73 = texture_array_depth[uniform_index].gather_compare(samp_comp[uniform_index], uv, 0.0); - metal::float4 _e74 = v4_; - v4_ = _e74 + _e73; - metal::float4 _e81 = texture_array_depth[non_uniform_index].gather_compare(samp_comp[non_uniform_index], uv, 0.0); - metal::float4 _e82 = v4_; - v4_ = _e82 + _e81; - metal::float4 _e88 = (uint(0) < texture_array_unbounded[0].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[0].get_width(0), texture_array_unbounded[0].get_height(0))) ? texture_array_unbounded[0].read(metal::uint2(pix), 0): DefaultConstructible()); - metal::float4 _e89 = v4_; - v4_ = _e89 + _e88; - metal::float4 _e94 = (uint(0) < texture_array_unbounded[uniform_index].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[uniform_index].get_width(0), texture_array_unbounded[uniform_index].get_height(0))) ? texture_array_unbounded[uniform_index].read(metal::uint2(pix), 0): DefaultConstructible()); - metal::float4 _e95 = v4_; - v4_ = _e95 + _e94; - metal::float4 _e100 = (uint(0) < texture_array_unbounded[non_uniform_index].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[non_uniform_index].get_width(0), texture_array_unbounded[non_uniform_index].get_height(0))) ? texture_array_unbounded[non_uniform_index].read(metal::uint2(pix), 0): DefaultConstructible()); - metal::float4 _e101 = v4_; - v4_ = _e101 + _e100; - uint _e107 = u1_; - u1_ = _e107 + texture_array_2darray[0].get_array_size(); - uint _e112 = u1_; - u1_ = _e112 + texture_array_2darray[uniform_index].get_array_size(); - uint _e117 = u1_; - u1_ = _e117 + texture_array_2darray[non_uniform_index].get_array_size(); - uint _e123 = u1_; - u1_ = _e123 + texture_array_bounded[0].get_num_mip_levels(); - uint _e128 = u1_; - u1_ = _e128 + texture_array_bounded[uniform_index].get_num_mip_levels(); - uint _e133 = u1_; - u1_ = _e133 + texture_array_bounded[non_uniform_index].get_num_mip_levels(); - uint _e139 = u1_; - u1_ = _e139 + texture_array_multisampled[0].get_num_samples(); - uint _e144 = u1_; - u1_ = _e144 + texture_array_multisampled[uniform_index].get_num_samples(); - uint _e149 = u1_; - u1_ = _e149 + texture_array_multisampled[non_uniform_index].get_num_samples(); - metal::float4 _e157 = texture_array_bounded[0].sample(samp[0], uv); - metal::float4 _e158 = v4_; - v4_ = _e158 + _e157; - metal::float4 _e164 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv); - metal::float4 _e165 = v4_; - v4_ = _e165 + _e164; - metal::float4 _e171 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv); - metal::float4 _e172 = v4_; - v4_ = _e172 + _e171; - metal::float4 _e181 = texture_array_bounded[0].sample(samp[0], uv, metal::bias(0.0)); - metal::float4 _e182 = v4_; - v4_ = _e182 + _e181; - metal::float4 _e189 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::bias(0.0)); - metal::float4 _e190 = v4_; - v4_ = _e190 + _e189; - metal::float4 _e197 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::bias(0.0)); - metal::float4 _e198 = v4_; - v4_ = _e198 + _e197; - float _e207 = texture_array_depth[0].sample_compare(samp_comp[0], uv, 0.0); - float _e208 = v1_; - v1_ = _e208 + _e207; - float _e215 = texture_array_depth[uniform_index].sample_compare(samp_comp[uniform_index], uv, 0.0); - float _e216 = v1_; - v1_ = _e216 + _e215; - float _e223 = texture_array_depth[non_uniform_index].sample_compare(samp_comp[non_uniform_index], uv, 0.0); - float _e224 = v1_; - v1_ = _e224 + _e223; - float _e233 = texture_array_depth[0].sample_compare(samp_comp[0], uv, 0.0); - float _e234 = v1_; - v1_ = _e234 + _e233; - float _e241 = texture_array_depth[uniform_index].sample_compare(samp_comp[uniform_index], uv, 0.0); - float _e242 = v1_; - v1_ = _e242 + _e241; - float _e249 = texture_array_depth[non_uniform_index].sample_compare(samp_comp[non_uniform_index], uv, 0.0); - float _e250 = v1_; - v1_ = _e250 + _e249; - metal::float4 _e258 = texture_array_bounded[0].sample(samp[0], uv, metal::gradient2d(uv, uv)); - metal::float4 _e259 = v4_; - v4_ = _e259 + _e258; - metal::float4 _e265 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::gradient2d(uv, uv)); - metal::float4 _e266 = v4_; - v4_ = _e266 + _e265; - metal::float4 _e272 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::gradient2d(uv, uv)); - metal::float4 _e273 = v4_; - v4_ = _e273 + _e272; - metal::float4 _e282 = texture_array_bounded[0].sample(samp[0], uv, metal::level(0.0)); - metal::float4 _e283 = v4_; - v4_ = _e283 + _e282; - metal::float4 _e290 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::level(0.0)); - metal::float4 _e291 = v4_; - v4_ = _e291 + _e290; - metal::float4 _e298 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::level(0.0)); - metal::float4 _e299 = v4_; - v4_ = _e299 + _e298; - metal::float4 _e304 = v4_; + metal::float4 _e42 = texture_array_bounded[0].gather(samp[0], uv); + metal::float4 _e43 = v4_; + v4_ = _e43 + _e42; + metal::float4 _e50 = texture_array_bounded[uniform_index].gather(samp[uniform_index], uv); + metal::float4 _e51 = v4_; + v4_ = _e51 + _e50; + metal::float4 _e58 = texture_array_bounded[non_uniform_index].gather(samp[non_uniform_index], uv); + metal::float4 _e59 = v4_; + v4_ = _e59 + _e58; + metal::float4 _e68 = texture_array_depth[0].gather_compare(samp_comp[0], uv, 0.0); + metal::float4 _e69 = v4_; + v4_ = _e69 + _e68; + metal::float4 _e76 = texture_array_depth[uniform_index].gather_compare(samp_comp[uniform_index], uv, 0.0); + metal::float4 _e77 = v4_; + v4_ = _e77 + _e76; + metal::float4 _e84 = texture_array_depth[non_uniform_index].gather_compare(samp_comp[non_uniform_index], uv, 0.0); + metal::float4 _e85 = v4_; + v4_ = _e85 + _e84; + metal::float4 _e91 = (uint(0) < texture_array_unbounded[0].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[0].get_width(0), texture_array_unbounded[0].get_height(0))) ? texture_array_unbounded[0].read(metal::uint2(pix), 0): DefaultConstructible()); + metal::float4 _e92 = v4_; + v4_ = _e92 + _e91; + metal::float4 _e97 = (uint(0) < texture_array_unbounded[uniform_index].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[uniform_index].get_width(0), texture_array_unbounded[uniform_index].get_height(0))) ? texture_array_unbounded[uniform_index].read(metal::uint2(pix), 0): DefaultConstructible()); + metal::float4 _e98 = v4_; + v4_ = _e98 + _e97; + metal::float4 _e103 = (uint(0) < texture_array_unbounded[non_uniform_index].get_num_mip_levels() && metal::all(metal::uint2(pix) < metal::uint2(texture_array_unbounded[non_uniform_index].get_width(0), texture_array_unbounded[non_uniform_index].get_height(0))) ? texture_array_unbounded[non_uniform_index].read(metal::uint2(pix), 0): DefaultConstructible()); + metal::float4 _e104 = v4_; + v4_ = _e104 + _e103; + uint _e110 = u1_; + u1_ = _e110 + texture_array_2darray[0].get_array_size(); + uint _e115 = u1_; + u1_ = _e115 + texture_array_2darray[uniform_index].get_array_size(); + uint _e120 = u1_; + u1_ = _e120 + texture_array_2darray[non_uniform_index].get_array_size(); + uint _e126 = u1_; + u1_ = _e126 + texture_array_bounded[0].get_num_mip_levels(); + uint _e131 = u1_; + u1_ = _e131 + texture_array_bounded[uniform_index].get_num_mip_levels(); + uint _e136 = u1_; + u1_ = _e136 + texture_array_bounded[non_uniform_index].get_num_mip_levels(); + uint _e142 = u1_; + u1_ = _e142 + texture_array_multisampled[0].get_num_samples(); + uint _e147 = u1_; + u1_ = _e147 + texture_array_multisampled[uniform_index].get_num_samples(); + uint _e152 = u1_; + u1_ = _e152 + texture_array_multisampled[non_uniform_index].get_num_samples(); + metal::float4 _e160 = texture_array_bounded[0].sample(samp[0], uv); + metal::float4 _e161 = v4_; + v4_ = _e161 + _e160; + metal::float4 _e167 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv); + metal::float4 _e168 = v4_; + v4_ = _e168 + _e167; + metal::float4 _e174 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv); + metal::float4 _e175 = v4_; + v4_ = _e175 + _e174; + metal::float4 _e184 = texture_array_bounded[0].sample(samp[0], uv, metal::bias(0.0)); + metal::float4 _e185 = v4_; + v4_ = _e185 + _e184; + metal::float4 _e192 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::bias(0.0)); + metal::float4 _e193 = v4_; + v4_ = _e193 + _e192; + metal::float4 _e200 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::bias(0.0)); + metal::float4 _e201 = v4_; + v4_ = _e201 + _e200; + float _e210 = texture_array_depth[0].sample_compare(samp_comp[0], uv, 0.0); + float _e211 = v1_; + v1_ = _e211 + _e210; + float _e218 = texture_array_depth[uniform_index].sample_compare(samp_comp[uniform_index], uv, 0.0); + float _e219 = v1_; + v1_ = _e219 + _e218; + float _e226 = texture_array_depth[non_uniform_index].sample_compare(samp_comp[non_uniform_index], uv, 0.0); + float _e227 = v1_; + v1_ = _e227 + _e226; + float _e236 = texture_array_depth[0].sample_compare(samp_comp[0], uv, 0.0); + float _e237 = v1_; + v1_ = _e237 + _e236; + float _e244 = texture_array_depth[uniform_index].sample_compare(samp_comp[uniform_index], uv, 0.0); + float _e245 = v1_; + v1_ = _e245 + _e244; + float _e252 = texture_array_depth[non_uniform_index].sample_compare(samp_comp[non_uniform_index], uv, 0.0); + float _e253 = v1_; + v1_ = _e253 + _e252; + metal::float4 _e261 = texture_array_bounded[0].sample(samp[0], uv, metal::gradient2d(uv, uv)); + metal::float4 _e262 = v4_; + v4_ = _e262 + _e261; + metal::float4 _e268 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::gradient2d(uv, uv)); + metal::float4 _e269 = v4_; + v4_ = _e269 + _e268; + metal::float4 _e275 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::gradient2d(uv, uv)); + metal::float4 _e276 = v4_; + v4_ = _e276 + _e275; + metal::float4 _e285 = texture_array_bounded[0].sample(samp[0], uv, metal::level(0.0)); + metal::float4 _e286 = v4_; + v4_ = _e286 + _e285; + metal::float4 _e293 = texture_array_bounded[uniform_index].sample(samp[uniform_index], uv, metal::level(0.0)); + metal::float4 _e294 = v4_; + v4_ = _e294 + _e293; + metal::float4 _e301 = texture_array_bounded[non_uniform_index].sample(samp[non_uniform_index], uv, metal::level(0.0)); + metal::float4 _e302 = v4_; + v4_ = _e302 + _e301; + metal::float4 _e307 = v4_; if (metal::all(metal::uint2(pix) < metal::uint2(texture_array_storage[0].get_width(), texture_array_storage[0].get_height()))) { - texture_array_storage[0].write(_e304, metal::uint2(pix)); + texture_array_storage[0].write(_e307, metal::uint2(pix)); } - metal::float4 _e307 = v4_; + metal::float4 _e310 = v4_; if (metal::all(metal::uint2(pix) < metal::uint2(texture_array_storage[uniform_index].get_width(), texture_array_storage[uniform_index].get_height()))) { - texture_array_storage[uniform_index].write(_e307, metal::uint2(pix)); + texture_array_storage[uniform_index].write(_e310, metal::uint2(pix)); } - metal::float4 _e310 = v4_; + metal::float4 _e313 = v4_; if (metal::all(metal::uint2(pix) < metal::uint2(texture_array_storage[non_uniform_index].get_width(), texture_array_storage[non_uniform_index].get_height()))) { - texture_array_storage[non_uniform_index].write(_e310, metal::uint2(pix)); + texture_array_storage[non_uniform_index].write(_e313, metal::uint2(pix)); } - metal::uint2 _e311 = u2_; - uint _e312 = u1_; - metal::float2 v2_ = static_cast(_e311 + metal::uint2(_e312)); - metal::float4 _e316 = v4_; - float _e323 = v1_; - return main_Output { (_e316 + metal::float4(v2_.x, v2_.y, v2_.x, v2_.y)) + metal::float4(_e323) }; + metal::uint2 _e314 = u2_; + uint _e315 = u1_; + metal::float2 v2_ = static_cast(_e314 + metal::uint2(_e315)); + metal::float4 _e319 = v4_; + float _e326 = v1_; + return main_Output { (_e319 + metal::float4(v2_.x, v2_.y, v2_.x, v2_.y)) + metal::float4(_e326) }; } diff --git a/tests/out/msl/boids.msl b/tests/out/msl/boids.msl index 100a6dc1e2..1a81aaf684 100644 --- a/tests/out/msl/boids.msl +++ b/tests/out/msl/boids.msl @@ -9,7 +9,6 @@ struct _mslBufferSizes { uint size2; }; -constexpr constant unsigned NUM_PARTICLES = 1500u; struct Particle { metal::float2 pos; metal::float2 vel; @@ -27,6 +26,7 @@ typedef Particle type_3[1]; struct Particles { type_3 particles; }; +constant uint NUM_PARTICLES = 1500u; struct main_Input { }; diff --git a/tests/out/msl/constructors.msl b/tests/out/msl/constructors.msl new file mode 100644 index 0000000000..b3d3b9dd43 --- /dev/null +++ b/tests/out/msl/constructors.msl @@ -0,0 +1,50 @@ +// language: metal2.0 +#include +#include + +using metal::uint; + +struct Foo { + metal::float4 a; + int b; +}; +struct type_5 { + metal::float2x2 inner[1]; +}; +struct type_10 { + Foo inner[3]; +}; +struct type_11 { + int inner[4]; +}; +constant metal::float3 const2_ = metal::float3(0.0, 1.0, 2.0); +constant metal::float2x2 const3_ = metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0)); +constant type_5 const4_ = type_5 {metal::float2x2(metal::float2(0.0, 1.0), metal::float2(2.0, 3.0))}; +constant bool cz0_ = bool {}; +constant int cz1_ = int {}; +constant uint cz2_ = uint {}; +constant float cz3_ = float {}; +constant metal::uint2 cz4_ = metal::uint2 {}; +constant metal::float2x2 cz5_ = metal::float2x2 {}; +constant type_10 cz6_ = type_10 {}; +constant Foo cz7_ = Foo {}; +constant type_11 cp3_ = type_11 {0, 1, 2, 3}; + +kernel void main_( +) { + Foo foo = {}; + foo = Foo {metal::float4(1.0), 1}; + metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0)); + metal::float4x4 m1_ = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0)); + metal::uint2 cit0_ = metal::uint2(0u); + metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0)); + type_11 cit2_ = type_11 {0, 1, 2, 3}; + 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 ic6_ = as_type(metal::uint2 {}); + metal::float2x3 ic7_ = metal::float2x3(metal::float2x3 {}); +} diff --git a/tests/out/msl/do-while.msl b/tests/out/msl/do-while.msl index ac2393bf7f..4f928d1f3c 100644 --- a/tests/out/msl/do-while.msl +++ b/tests/out/msl/do-while.msl @@ -11,7 +11,7 @@ void fb1_( bool loop_init = true; while(true) { if (!loop_init) { - bool _e6 = cond; + bool _e2 = cond; if (!(cond)) { break; } diff --git a/tests/out/msl/empty-global-name.msl b/tests/out/msl/empty-global-name.msl index 6001dba93f..f456649bc6 100644 --- a/tests/out/msl/empty-global-name.msl +++ b/tests/out/msl/empty-global-name.msl @@ -11,8 +11,8 @@ struct type_1 { void function( device type_1& unnamed ) { - int _e8 = unnamed.member; - unnamed.member = _e8 + 1; + int _e4 = unnamed.member; + unnamed.member = _e4 + 1; return; } diff --git a/tests/out/msl/globals.msl b/tests/out/msl/globals.msl index 786e03ea5e..d9142c1990 100644 --- a/tests/out/msl/globals.msl +++ b/tests/out/msl/globals.msl @@ -8,7 +8,6 @@ struct _mslBufferSizes { uint size3; }; -constexpr constant bool Foo_1 = true; struct type_2 { float inner[10]; }; @@ -32,6 +31,7 @@ struct type_14 { struct type_15 { type_14 inner[2]; }; +constant bool Foo_1 = true; void test_msl_packed_vec3_as_arg( metal::float3 arg diff --git a/tests/out/msl/image.msl b/tests/out/msl/image.msl index 77c0a86793..e390c2e0fc 100644 --- a/tests/out/msl/image.msl +++ b/tests/out/msl/image.msl @@ -4,7 +4,6 @@ using metal::uint; -constant metal::int2 const_type_9_ = {3, 1}; struct main_Input { }; @@ -126,46 +125,46 @@ fragment texture_sampleOutput texture_sample( metal::float4 _e14 = image_2d.sample(sampler_reg, tc); metal::float4 _e15 = a; a = _e15 + _e14; - metal::float4 _e19 = image_2d.sample(sampler_reg, tc, const_type_9_); + metal::float4 _e19 = image_2d.sample(sampler_reg, tc, metal::int2(3, 1)); metal::float4 _e20 = a; a = _e20 + _e19; metal::float4 _e24 = image_2d.sample(sampler_reg, tc, metal::level(2.3)); metal::float4 _e25 = a; a = _e25 + _e24; - metal::float4 _e29 = image_2d.sample(sampler_reg, tc, metal::level(2.3), const_type_9_); + metal::float4 _e29 = image_2d.sample(sampler_reg, tc, metal::level(2.3), metal::int2(3, 1)); metal::float4 _e30 = a; a = _e30 + _e29; - metal::float4 _e35 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), const_type_9_); + metal::float4 _e35 = image_2d.sample(sampler_reg, tc, metal::bias(2.0), metal::int2(3, 1)); metal::float4 _e36 = a; a = _e36 + _e35; metal::float4 _e41 = image_2d_array.sample(sampler_reg, tc, 0u); metal::float4 _e42 = a; a = _e42 + _e41; - metal::float4 _e47 = image_2d_array.sample(sampler_reg, tc, 0u, const_type_9_); + metal::float4 _e47 = image_2d_array.sample(sampler_reg, tc, 0u, metal::int2(3, 1)); metal::float4 _e48 = a; a = _e48 + _e47; metal::float4 _e53 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3)); metal::float4 _e54 = a; a = _e54 + _e53; - metal::float4 _e59 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), const_type_9_); + metal::float4 _e59 = image_2d_array.sample(sampler_reg, tc, 0u, metal::level(2.3), metal::int2(3, 1)); metal::float4 _e60 = a; a = _e60 + _e59; - metal::float4 _e66 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), const_type_9_); + metal::float4 _e66 = image_2d_array.sample(sampler_reg, tc, 0u, metal::bias(2.0), metal::int2(3, 1)); metal::float4 _e67 = a; a = _e67 + _e66; metal::float4 _e72 = image_2d_array.sample(sampler_reg, tc, 0); metal::float4 _e73 = a; a = _e73 + _e72; - metal::float4 _e78 = image_2d_array.sample(sampler_reg, tc, 0, const_type_9_); + metal::float4 _e78 = image_2d_array.sample(sampler_reg, tc, 0, metal::int2(3, 1)); metal::float4 _e79 = a; a = _e79 + _e78; metal::float4 _e84 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3)); metal::float4 _e85 = a; a = _e85 + _e84; - metal::float4 _e90 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), const_type_9_); + metal::float4 _e90 = image_2d_array.sample(sampler_reg, tc, 0, metal::level(2.3), metal::int2(3, 1)); metal::float4 _e91 = a; a = _e91 + _e90; - metal::float4 _e97 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), const_type_9_); + metal::float4 _e97 = image_2d_array.sample(sampler_reg, tc, 0, metal::bias(2.0), metal::int2(3, 1)); metal::float4 _e98 = a; a = _e98 + _e97; metal::float4 _e103 = image_cube_array.sample(sampler_reg, tc3_, 0u); @@ -245,9 +244,9 @@ fragment gatherOutput gather( ) { metal::float2 tc_2 = metal::float2(0.5); metal::float4 s2d = image_2d.gather(sampler_reg, tc_2, metal::int2(0), metal::component::y); - metal::float4 s2d_offset = image_2d.gather(sampler_reg, tc_2, const_type_9_, metal::component::w); + metal::float4 s2d_offset = image_2d.gather(sampler_reg, tc_2, metal::int2(3, 1), metal::component::w); metal::float4 s2d_depth = image_2d_depth.gather_compare(sampler_cmp, tc_2, 0.5); - metal::float4 s2d_depth_offset = image_2d_depth.gather_compare(sampler_cmp, tc_2, 0.5, const_type_9_); + metal::float4 s2d_depth_offset = image_2d_depth.gather_compare(sampler_cmp, tc_2, 0.5, metal::int2(3, 1)); metal::uint4 u = image_2d_u32_.gather(sampler_reg, tc_2); metal::int4 i = image_2d_i32_.gather(sampler_reg, tc_2); metal::float4 f = static_cast(u) + static_cast(i); diff --git a/tests/out/msl/operators.msl b/tests/out/msl/operators.msl index 33f13e1cb9..de3e990db2 100644 --- a/tests/out/msl/operators.msl +++ b/tests/out/msl/operators.msl @@ -4,20 +4,10 @@ using metal::uint; -struct Foo { - metal::float4 a; - int b; -}; -struct type_13 { - Foo inner[3]; -}; -struct type_14 { - int inner[4]; -}; -constant metal::float4 v_f32_one = {1.0, 1.0, 1.0, 1.0}; -constant metal::float4 v_f32_zero = {0.0, 0.0, 0.0, 0.0}; -constant metal::float4 v_f32_half = {0.5, 0.5, 0.5, 0.5}; -constant metal::int4 v_i32_one = {1, 1, 1, 1}; +constant metal::float4 v_f32_one = metal::float4(1.0, 1.0, 1.0, 1.0); +constant metal::float4 v_f32_zero = metal::float4(0.0, 0.0, 0.0, 0.0); +constant metal::float4 v_f32_half = metal::float4(0.5, 0.5, 0.5, 0.5); +constant metal::int4 v_i32_one = metal::int4(1, 1, 1, 1); metal::float4 builtins( ) { @@ -60,27 +50,6 @@ metal::float3 bool_cast( return static_cast(y); } -float constructors( -) { - Foo foo = {}; - foo = Foo {metal::float4(1.0), 1}; - metal::float2x2 m0_ = metal::float2x2(metal::float2(1.0, 0.0), metal::float2(0.0, 1.0)); - metal::float4x4 m1_1 = metal::float4x4(metal::float4(1.0, 0.0, 0.0, 0.0), metal::float4(0.0, 1.0, 0.0, 0.0), metal::float4(0.0, 0.0, 1.0, 0.0), metal::float4(0.0, 0.0, 0.0, 1.0)); - metal::uint2 cit0_ = metal::uint2(0u); - metal::float2x2 cit1_ = metal::float2x2(metal::float2(0.0), metal::float2(0.0)); - type_14 cit2_ = type_14 {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 ic6_ = as_type(metal::uint2 {}); - metal::float2x3 ic7_ = metal::float2x3(metal::float2x3 {}); - float _e71 = foo.a.x; - return _e71; -} - void logical( ) { bool neg0_ = !(true); @@ -263,15 +232,15 @@ void assignment( a_1 = _e27 << 2u; int _e30 = a_1; a_1 = _e30 >> 1u; - int _e32 = a_1; - a_1 = _e32 + 1; - int _e35 = a_1; - a_1 = _e35 - 1; + 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 _e47 = vec0_.y; - vec0_.y = _e47 - 1; + int _e43 = vec0_.y; + vec0_.y = _e43 + 1; + int _e48 = vec0_.y; + vec0_.y = _e48 - 1; return; } @@ -291,7 +260,6 @@ kernel void main_( metal::float4 _e0 = builtins(); metal::float4 _e1 = splat(); metal::float3 _e4 = bool_cast(v_f32_one.xyz); - float _e5 = constructors(); logical(); arithmetic(); bit(); diff --git a/tests/out/msl/quad-vert.msl b/tests/out/msl/quad-vert.msl index d5e62774ef..d322cbcb9b 100644 --- a/tests/out/msl/quad-vert.msl +++ b/tests/out/msl/quad-vert.msl @@ -17,9 +17,6 @@ struct type_9 { metal::float2 member; metal::float4 gl_Position; }; -constant metal::float4 const_type_3_ = {0.0, 0.0, 0.0, 1.0}; -constant type_5 const_type_5_ = {0.0}; -constant gl_PerVertex const_gl_PerVertex = {const_type_3_, 1.0, const_type_5_, const_type_5_}; void main_1( thread metal::float2& v_uv, @@ -27,10 +24,10 @@ void main_1( thread gl_PerVertex& perVertexStruct, thread metal::float2& a_pos_1 ) { - metal::float2 _e12 = a_uv_1; - v_uv = _e12; - metal::float2 _e13 = a_pos_1; - perVertexStruct.gl_Position = metal::float4(_e13.x, _e13.y, 0.0, 1.0); + metal::float2 _e8 = a_uv_1; + v_uv = _e8; + metal::float2 _e9 = a_pos_1; + perVertexStruct.gl_Position = metal::float4(_e9.x, _e9.y, 0.0, 1.0); return; } @@ -47,7 +44,7 @@ vertex main_Output main_( ) { metal::float2 v_uv = {}; metal::float2 a_uv_1 = {}; - gl_PerVertex perVertexStruct = const_gl_PerVertex; + gl_PerVertex perVertexStruct = gl_PerVertex {metal::float4(0.0, 0.0, 0.0, 1.0), 1.0, type_5 {}, type_5 {}}; metal::float2 a_pos_1 = {}; const auto a_uv = varyings.a_uv; const auto a_pos = varyings.a_pos; diff --git a/tests/out/msl/quad.msl b/tests/out/msl/quad.msl index a6beb30b8c..5fa5788aac 100644 --- a/tests/out/msl/quad.msl +++ b/tests/out/msl/quad.msl @@ -4,11 +4,11 @@ using metal::uint; -constexpr constant float c_scale = 1.2000000476837158; struct VertexOutput { metal::float2 uv; metal::float4 position; }; +constant float c_scale = 1.2; struct vert_mainInput { metal::float2 pos [[attribute(0)]]; diff --git a/tests/out/msl/shadow.msl b/tests/out/msl/shadow.msl index fa1b284c6b..53f320344a 100644 --- a/tests/out/msl/shadow.msl +++ b/tests/out/msl/shadow.msl @@ -8,7 +8,6 @@ struct _mslBufferSizes { uint size2; }; -constexpr constant unsigned c_max_lights = 10u; struct Globals { metal::float4x4 view_proj; metal::uint4 num_lights; @@ -31,7 +30,8 @@ typedef Light type_6[1]; struct type_7 { Light inner[10]; }; -constant metal::float3 c_ambient = {0.05000000074505806, 0.05000000074505806, 0.05000000074505806}; +constant metal::float3 c_ambient = metal::float3(0.05, 0.05, 0.05); +constant uint c_max_lights = 10u; float fetch_shadow( uint light_id, @@ -105,8 +105,8 @@ fragment fs_mainOutput fs_main( bool loop_init = true; while(true) { if (!loop_init) { - uint _e39 = i; - i = _e39 + 1u; + uint _e40 = i; + i = _e40 + 1u; } loop_init = false; uint _e7 = i; @@ -157,8 +157,8 @@ fragment fs_main_without_storageOutput fs_main_without_storage( bool loop_init_1 = true; while(true) { if (!loop_init_1) { - uint _e39 = i_1; - i_1 = _e39 + 1u; + uint _e40 = i_1; + i_1 = _e40 + 1u; } loop_init_1 = false; uint _e7 = i_1; diff --git a/tests/out/msl/workgroup-uniform-load.msl b/tests/out/msl/workgroup-uniform-load.msl index cd85811d96..37a8781739 100644 --- a/tests/out/msl/workgroup-uniform-load.msl +++ b/tests/out/msl/workgroup-uniform-load.msl @@ -4,10 +4,10 @@ using metal::uint; -constexpr constant unsigned SIZE = 128u; struct type_2 { int inner[128]; }; +constant uint SIZE = 128u; struct test_workgroupUniformLoadInput { }; diff --git a/tests/out/spv/access.spvasm b/tests/out/spv/access.spvasm index 12d2ceef26..8687ddb6a2 100644 --- a/tests/out/spv/access.spvasm +++ b/tests/out/spv/access.spvasm @@ -11,32 +11,32 @@ OpEntryPoint Fragment %286 "foo_frag" %285 OpEntryPoint GLCompute %306 "assign_through_ptr" %309 OpExecutionMode %286 OriginUpperLeft OpExecutionMode %306 LocalSize 1 1 1 -OpMemberName %12 0 "a" -OpMemberName %12 1 "b" -OpMemberName %12 2 "c" -OpName %12 "GlobalConst" -OpMemberName %13 0 "value" -OpName %13 "AlignedWrapper" -OpMemberName %26 0 "_matrix" -OpMemberName %26 1 "matrix_array" -OpMemberName %26 2 "atom" -OpMemberName %26 3 "atom_arr" -OpMemberName %26 4 "arr" -OpMemberName %26 5 "data" -OpName %26 "Bar" -OpMemberName %28 0 "m" -OpName %28 "Baz" -OpMemberName %32 0 "am" -OpName %32 "MatCx2InArray" -OpName %46 "global_const" -OpName %48 "bar" -OpName %50 "baz" -OpName %53 "qux" -OpName %56 "nested_mat_cx2" -OpName %59 "val" -OpName %60 "idx" -OpName %63 "t" -OpName %67 "test_matrix_within_struct_accesses" +OpMemberName %6 0 "a" +OpMemberName %6 1 "b" +OpMemberName %6 2 "c" +OpName %6 "GlobalConst" +OpMemberName %7 0 "value" +OpName %7 "AlignedWrapper" +OpMemberName %20 0 "_matrix" +OpMemberName %20 1 "matrix_array" +OpMemberName %20 2 "atom" +OpMemberName %20 3 "atom_arr" +OpMemberName %20 4 "arr" +OpMemberName %20 5 "data" +OpName %20 "Bar" +OpMemberName %22 0 "m" +OpName %22 "Baz" +OpMemberName %26 0 "am" +OpName %26 "MatCx2InArray" +OpName %45 "global_const" +OpName %47 "bar" +OpName %49 "baz" +OpName %52 "qux" +OpName %55 "nested_mat_cx2" +OpName %58 "val" +OpName %59 "idx" +OpName %62 "t" +OpName %66 "test_matrix_within_struct_accesses" OpName %137 "idx" OpName %139 "t" OpName %143 "test_matrix_within_array_within_struct_accesses" @@ -55,337 +55,337 @@ OpName %239 "foo_vert" OpName %286 "foo_frag" OpName %303 "arr" OpName %306 "assign_through_ptr" -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 16 -OpMemberDecorate %12 2 Offset 28 -OpMemberDecorate %13 0 Offset 0 -OpDecorate %19 ArrayStride 16 -OpDecorate %21 ArrayStride 4 -OpDecorate %24 ArrayStride 8 -OpDecorate %25 ArrayStride 8 +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 +OpMemberDecorate %6 2 Offset 28 +OpMemberDecorate %7 0 Offset 0 +OpDecorate %13 ArrayStride 16 +OpDecorate %15 ArrayStride 4 +OpDecorate %18 ArrayStride 8 +OpDecorate %19 ArrayStride 8 +OpMemberDecorate %20 0 Offset 0 +OpMemberDecorate %20 0 ColMajor +OpMemberDecorate %20 0 MatrixStride 16 +OpMemberDecorate %20 1 Offset 64 +OpMemberDecorate %20 1 ColMajor +OpMemberDecorate %20 1 MatrixStride 8 +OpMemberDecorate %20 2 Offset 96 +OpMemberDecorate %20 3 Offset 100 +OpMemberDecorate %20 4 Offset 144 +OpMemberDecorate %20 5 Offset 160 +OpMemberDecorate %22 0 Offset 0 +OpMemberDecorate %22 0 ColMajor +OpMemberDecorate %22 0 MatrixStride 8 +OpDecorate %25 ArrayStride 32 OpMemberDecorate %26 0 Offset 0 OpMemberDecorate %26 0 ColMajor -OpMemberDecorate %26 0 MatrixStride 16 -OpMemberDecorate %26 1 Offset 64 -OpMemberDecorate %26 1 ColMajor -OpMemberDecorate %26 1 MatrixStride 8 -OpMemberDecorate %26 2 Offset 96 -OpMemberDecorate %26 3 Offset 100 -OpMemberDecorate %26 4 Offset 144 -OpMemberDecorate %26 5 Offset 160 -OpMemberDecorate %28 0 Offset 0 -OpMemberDecorate %28 0 ColMajor -OpMemberDecorate %28 0 MatrixStride 8 -OpDecorate %31 ArrayStride 32 -OpMemberDecorate %32 0 Offset 0 -OpMemberDecorate %32 0 ColMajor -OpMemberDecorate %32 0 MatrixStride 8 -OpDecorate %34 ArrayStride 4 -OpDecorate %35 ArrayStride 40 -OpDecorate %39 ArrayStride 4 -OpDecorate %42 ArrayStride 16 -OpDecorate %48 DescriptorSet 0 -OpDecorate %48 Binding 0 -OpDecorate %26 Block -OpDecorate %50 DescriptorSet 0 -OpDecorate %50 Binding 1 -OpDecorate %51 Block -OpMemberDecorate %51 0 Offset 0 -OpDecorate %53 DescriptorSet 0 -OpDecorate %53 Binding 2 -OpDecorate %54 Block -OpMemberDecorate %54 0 Offset 0 -OpDecorate %56 DescriptorSet 0 -OpDecorate %56 Binding 3 -OpDecorate %57 Block -OpMemberDecorate %57 0 Offset 0 +OpMemberDecorate %26 0 MatrixStride 8 +OpDecorate %28 ArrayStride 4 +OpDecorate %29 ArrayStride 40 +OpDecorate %33 ArrayStride 4 +OpDecorate %36 ArrayStride 16 +OpDecorate %47 DescriptorSet 0 +OpDecorate %47 Binding 0 +OpDecorate %20 Block +OpDecorate %49 DescriptorSet 0 +OpDecorate %49 Binding 1 +OpDecorate %50 Block +OpMemberDecorate %50 0 Offset 0 +OpDecorate %52 DescriptorSet 0 +OpDecorate %52 Binding 2 +OpDecorate %53 Block +OpMemberDecorate %53 0 Offset 0 +OpDecorate %55 DescriptorSet 0 +OpDecorate %55 Binding 3 +OpDecorate %56 Block +OpMemberDecorate %56 0 Offset 0 OpDecorate %234 BuiltIn VertexIndex OpDecorate %237 BuiltIn Position OpDecorate %285 Location 0 OpDecorate %309 BuiltIn LocalInvocationId %2 = OpTypeVoid -%4 = OpTypeInt 32 0 -%3 = OpConstant %4 0 -%6 = OpTypeInt 32 1 -%5 = OpConstant %6 0 -%7 = OpConstant %6 2 -%8 = OpConstant %6 10 -%9 = OpConstant %6 1 -%10 = OpConstant %6 5 -%11 = OpTypeVector %4 3 -%12 = OpTypeStruct %4 %11 %6 -%13 = OpTypeStruct %6 -%16 = OpTypeFloat 32 -%15 = OpTypeVector %16 3 -%14 = OpTypeMatrix %15 4 -%18 = OpTypeVector %16 2 -%17 = OpTypeMatrix %18 2 -%20 = OpConstant %4 2 -%19 = OpTypeArray %17 %20 -%22 = OpConstant %4 10 -%21 = OpTypeArray %6 %22 -%23 = OpTypeVector %4 2 -%24 = OpTypeArray %23 %20 -%25 = OpTypeRuntimeArray %13 -%26 = OpTypeStruct %14 %19 %6 %21 %24 %25 -%27 = OpTypeMatrix %18 3 -%28 = OpTypeStruct %27 -%29 = OpTypeVector %6 2 -%30 = OpTypeMatrix %18 4 -%31 = OpTypeArray %30 %20 -%32 = OpTypeStruct %31 -%33 = OpTypePointer Function %16 -%34 = OpTypeArray %16 %22 -%36 = OpConstant %4 5 -%35 = OpTypeArray %34 %36 -%37 = OpTypeVector %16 4 -%38 = OpTypePointer StorageBuffer %6 -%39 = OpTypeArray %6 %36 -%40 = OpTypeVector %6 4 -%41 = OpTypePointer Workgroup %4 -%42 = OpTypeArray %37 %20 -%43 = OpTypePointer Function %42 -%44 = OpConstantComposite %11 %3 %3 %3 -%45 = OpConstantComposite %12 %3 %44 %5 -%47 = OpTypePointer Private %12 -%46 = OpVariable %47 Private %45 -%49 = OpTypePointer StorageBuffer %26 -%48 = OpVariable %49 StorageBuffer -%51 = OpTypeStruct %28 -%52 = OpTypePointer Uniform %51 -%50 = OpVariable %52 Uniform -%54 = OpTypeStruct %29 -%55 = OpTypePointer StorageBuffer %54 -%53 = OpVariable %55 StorageBuffer -%57 = OpTypeStruct %32 -%58 = OpTypePointer Uniform %57 -%56 = OpVariable %58 Uniform -%59 = OpVariable %41 Workgroup -%61 = OpTypePointer Function %6 -%62 = OpConstantNull %6 -%64 = OpTypePointer Function %28 -%65 = OpConstantNull %28 -%68 = OpTypeFunction %2 -%69 = OpTypePointer Uniform %28 -%71 = OpConstant %16 1.0 -%72 = OpConstant %16 2.0 -%73 = OpConstant %16 3.0 -%74 = OpConstant %16 6.0 -%75 = OpConstant %16 5.0 -%76 = OpConstant %16 4.0 -%77 = OpConstant %16 9.0 -%78 = OpConstant %16 90.0 -%79 = OpConstant %16 10.0 -%80 = OpConstant %16 20.0 -%81 = OpConstant %16 30.0 -%82 = OpConstant %16 40.0 -%86 = OpTypePointer Uniform %27 -%89 = OpTypePointer Uniform %18 -%95 = OpTypePointer Uniform %16 -%96 = OpConstant %4 1 -%116 = OpTypePointer Function %27 -%122 = OpTypePointer Function %18 -%128 = OpTypePointer Function %16 -%138 = OpConstantNull %6 -%140 = OpTypePointer Function %32 -%141 = OpConstantNull %32 -%144 = OpTypePointer Uniform %32 -%146 = OpConstantNull %31 -%147 = OpConstantNull %31 -%148 = OpConstant %16 8.0 -%149 = OpConstant %16 7.0 -%153 = OpTypePointer Uniform %31 -%156 = OpTypePointer Uniform %30 -%179 = OpTypePointer Function %31 -%181 = OpTypePointer Function %30 -%204 = OpTypeFunction %16 %33 -%210 = OpTypeFunction %16 %35 -%217 = OpTypeFunction %2 %41 -%218 = OpConstant %4 42 -%223 = OpTypeFunction %2 %43 -%229 = OpConstantNull %16 -%231 = OpTypePointer Function %39 -%232 = OpConstantNull %39 -%235 = OpTypePointer Input %4 +%3 = OpTypeInt 32 0 +%4 = OpTypeVector %3 3 +%5 = OpTypeInt 32 1 +%6 = OpTypeStruct %3 %4 %5 +%7 = OpTypeStruct %5 +%10 = OpTypeFloat 32 +%9 = OpTypeVector %10 3 +%8 = OpTypeMatrix %9 4 +%12 = OpTypeVector %10 2 +%11 = OpTypeMatrix %12 2 +%14 = OpConstant %3 2 +%13 = OpTypeArray %11 %14 +%16 = OpConstant %3 10 +%15 = OpTypeArray %5 %16 +%17 = OpTypeVector %3 2 +%18 = OpTypeArray %17 %14 +%19 = OpTypeRuntimeArray %7 +%20 = OpTypeStruct %8 %13 %5 %15 %18 %19 +%21 = OpTypeMatrix %12 3 +%22 = OpTypeStruct %21 +%23 = OpTypeVector %5 2 +%24 = OpTypeMatrix %12 4 +%25 = OpTypeArray %24 %14 +%26 = OpTypeStruct %25 +%27 = OpTypePointer Function %10 +%28 = OpTypeArray %10 %16 +%30 = OpConstant %3 5 +%29 = OpTypeArray %28 %30 +%31 = OpTypeVector %10 4 +%32 = OpTypePointer StorageBuffer %5 +%33 = OpTypeArray %5 %30 +%34 = OpTypeVector %5 4 +%35 = OpTypePointer Workgroup %3 +%36 = OpTypeArray %31 %14 +%37 = OpTypePointer Function %36 +%38 = OpConstant %3 0 +%39 = OpConstantComposite %4 %38 %38 %38 +%40 = OpConstant %5 0 +%41 = OpConstantComposite %6 %38 %39 %40 +%42 = OpConstant %5 2 +%43 = OpConstant %5 10 +%44 = OpConstant %5 5 +%46 = OpTypePointer Private %6 +%45 = OpVariable %46 Private %41 +%48 = OpTypePointer StorageBuffer %20 +%47 = OpVariable %48 StorageBuffer +%50 = OpTypeStruct %22 +%51 = OpTypePointer Uniform %50 +%49 = OpVariable %51 Uniform +%53 = OpTypeStruct %23 +%54 = OpTypePointer StorageBuffer %53 +%52 = OpVariable %54 StorageBuffer +%56 = OpTypeStruct %26 +%57 = OpTypePointer Uniform %56 +%55 = OpVariable %57 Uniform +%58 = OpVariable %35 Workgroup +%60 = OpTypePointer Function %5 +%61 = OpConstantNull %5 +%63 = OpTypePointer Function %22 +%64 = OpConstantNull %22 +%67 = OpTypeFunction %2 +%68 = OpTypePointer Uniform %22 +%70 = OpConstant %5 1 +%71 = OpConstant %10 1.0 +%72 = OpConstant %10 2.0 +%73 = OpConstant %10 3.0 +%74 = OpConstant %10 6.0 +%75 = OpConstant %10 5.0 +%76 = OpConstant %10 4.0 +%77 = OpConstant %10 9.0 +%78 = OpConstant %10 90.0 +%79 = OpConstant %10 10.0 +%80 = OpConstant %10 20.0 +%81 = OpConstant %10 30.0 +%82 = OpConstant %10 40.0 +%86 = OpTypePointer Uniform %21 +%89 = OpTypePointer Uniform %12 +%95 = OpTypePointer Uniform %10 +%96 = OpConstant %3 1 +%116 = OpTypePointer Function %21 +%122 = OpTypePointer Function %12 +%128 = OpTypePointer Function %10 +%138 = OpConstantNull %5 +%140 = OpTypePointer Function %26 +%141 = OpConstantNull %26 +%144 = OpTypePointer Uniform %26 +%146 = OpConstantNull %25 +%147 = OpConstantNull %25 +%148 = OpConstant %10 8.0 +%149 = OpConstant %10 7.0 +%153 = OpTypePointer Uniform %25 +%156 = OpTypePointer Uniform %24 +%179 = OpTypePointer Function %25 +%181 = OpTypePointer Function %24 +%204 = OpTypeFunction %10 %27 +%210 = OpTypeFunction %10 %29 +%217 = OpTypeFunction %2 %35 +%218 = OpConstant %3 42 +%223 = OpTypeFunction %2 %37 +%229 = OpConstantNull %10 +%231 = OpTypePointer Function %33 +%232 = OpConstantNull %33 +%235 = OpTypePointer Input %3 %234 = OpVariable %235 Input -%238 = OpTypePointer Output %37 +%238 = OpTypePointer Output %31 %237 = OpVariable %238 Output -%241 = OpTypePointer StorageBuffer %29 -%244 = OpConstant %16 0.0 -%245 = OpConstant %4 3 -%246 = OpConstant %6 3 -%247 = OpConstant %6 4 -%248 = OpConstant %6 42 -%249 = OpConstantNull %35 -%254 = OpTypePointer StorageBuffer %14 -%257 = OpTypePointer StorageBuffer %24 -%258 = OpConstant %4 4 -%261 = OpTypePointer StorageBuffer %15 -%262 = OpTypePointer StorageBuffer %16 -%265 = OpTypePointer StorageBuffer %25 -%268 = OpTypePointer StorageBuffer %13 +%241 = OpTypePointer StorageBuffer %23 +%244 = OpConstant %10 0.0 +%245 = OpConstant %3 3 +%246 = OpConstant %5 3 +%247 = OpConstant %5 4 +%248 = OpConstant %5 42 +%249 = OpConstantNull %29 +%254 = OpTypePointer StorageBuffer %8 +%257 = OpTypePointer StorageBuffer %18 +%258 = OpConstant %3 4 +%261 = OpTypePointer StorageBuffer %9 +%262 = OpTypePointer StorageBuffer %10 +%265 = OpTypePointer StorageBuffer %19 +%268 = OpTypePointer StorageBuffer %7 %285 = OpVariable %238 Output -%288 = OpConstantNull %29 -%304 = OpConstantNull %42 -%308 = OpConstantNull %4 -%310 = OpTypePointer Input %11 +%288 = OpConstantNull %23 +%304 = OpConstantNull %36 +%308 = OpConstantNull %3 +%310 = OpTypePointer Input %4 %309 = OpVariable %310 Input -%312 = OpConstantNull %11 +%312 = OpConstantNull %4 %314 = OpTypeBool %313 = OpTypeVector %314 3 -%319 = OpConstant %4 264 -%67 = OpFunction %2 None %68 -%66 = OpLabel -%60 = OpVariable %61 Function %62 -%63 = OpVariable %64 Function %65 -%70 = OpAccessChain %69 %50 %3 +%319 = OpConstant %3 264 +%66 = OpFunction %2 None %67 +%65 = OpLabel +%59 = OpVariable %60 Function %61 +%62 = OpVariable %63 Function %64 +%69 = OpAccessChain %68 %49 %38 OpBranch %83 %83 = OpLabel -OpStore %60 %9 -%84 = OpLoad %6 %60 -%85 = OpISub %6 %84 %9 -OpStore %60 %85 -%87 = OpAccessChain %86 %70 %3 -%88 = OpLoad %27 %87 -%90 = OpAccessChain %89 %70 %3 %3 -%91 = OpLoad %18 %90 -%92 = OpLoad %6 %60 -%93 = OpAccessChain %89 %70 %3 %92 -%94 = OpLoad %18 %93 -%97 = OpAccessChain %95 %70 %3 %3 %96 -%98 = OpLoad %16 %97 -%99 = OpLoad %6 %60 -%100 = OpAccessChain %95 %70 %3 %3 %99 -%101 = OpLoad %16 %100 -%102 = OpLoad %6 %60 -%103 = OpAccessChain %95 %70 %3 %102 %96 -%104 = OpLoad %16 %103 -%105 = OpLoad %6 %60 -%106 = OpLoad %6 %60 -%107 = OpAccessChain %95 %70 %3 %105 %106 -%108 = OpLoad %16 %107 -%109 = OpCompositeConstruct %18 %71 %71 -%110 = OpCompositeConstruct %18 %72 %72 -%111 = OpCompositeConstruct %18 %73 %73 -%112 = OpCompositeConstruct %27 %109 %110 %111 -%113 = OpCompositeConstruct %28 %112 -OpStore %63 %113 -%114 = OpLoad %6 %60 -%115 = OpIAdd %6 %114 %9 -OpStore %60 %115 -%117 = OpCompositeConstruct %18 %74 %74 -%118 = OpCompositeConstruct %18 %75 %75 -%119 = OpCompositeConstruct %18 %76 %76 -%120 = OpCompositeConstruct %27 %117 %118 %119 -%121 = OpAccessChain %116 %63 %3 +OpStore %59 %70 +%84 = OpLoad %5 %59 +%85 = OpISub %5 %84 %70 +OpStore %59 %85 +%87 = OpAccessChain %86 %69 %38 +%88 = OpLoad %21 %87 +%90 = OpAccessChain %89 %69 %38 %38 +%91 = OpLoad %12 %90 +%92 = OpLoad %5 %59 +%93 = OpAccessChain %89 %69 %38 %92 +%94 = OpLoad %12 %93 +%97 = OpAccessChain %95 %69 %38 %38 %96 +%98 = OpLoad %10 %97 +%99 = OpLoad %5 %59 +%100 = OpAccessChain %95 %69 %38 %38 %99 +%101 = OpLoad %10 %100 +%102 = OpLoad %5 %59 +%103 = OpAccessChain %95 %69 %38 %102 %96 +%104 = OpLoad %10 %103 +%105 = OpLoad %5 %59 +%106 = OpLoad %5 %59 +%107 = OpAccessChain %95 %69 %38 %105 %106 +%108 = OpLoad %10 %107 +%109 = OpCompositeConstruct %12 %71 %71 +%110 = OpCompositeConstruct %12 %72 %72 +%111 = OpCompositeConstruct %12 %73 %73 +%112 = OpCompositeConstruct %21 %109 %110 %111 +%113 = OpCompositeConstruct %22 %112 +OpStore %62 %113 +%114 = OpLoad %5 %59 +%115 = OpIAdd %5 %114 %70 +OpStore %59 %115 +%117 = OpCompositeConstruct %12 %74 %74 +%118 = OpCompositeConstruct %12 %75 %75 +%119 = OpCompositeConstruct %12 %76 %76 +%120 = OpCompositeConstruct %21 %117 %118 %119 +%121 = OpAccessChain %116 %62 %38 OpStore %121 %120 -%123 = OpCompositeConstruct %18 %77 %77 -%124 = OpAccessChain %122 %63 %3 %3 +%123 = OpCompositeConstruct %12 %77 %77 +%124 = OpAccessChain %122 %62 %38 %38 OpStore %124 %123 -%125 = OpLoad %6 %60 -%126 = OpCompositeConstruct %18 %78 %78 -%127 = OpAccessChain %122 %63 %3 %125 +%125 = OpLoad %5 %59 +%126 = OpCompositeConstruct %12 %78 %78 +%127 = OpAccessChain %122 %62 %38 %125 OpStore %127 %126 -%129 = OpAccessChain %128 %63 %3 %3 %96 +%129 = OpAccessChain %128 %62 %38 %38 %96 OpStore %129 %79 -%130 = OpLoad %6 %60 -%131 = OpAccessChain %128 %63 %3 %3 %130 +%130 = OpLoad %5 %59 +%131 = OpAccessChain %128 %62 %38 %38 %130 OpStore %131 %80 -%132 = OpLoad %6 %60 -%133 = OpAccessChain %128 %63 %3 %132 %96 +%132 = OpLoad %5 %59 +%133 = OpAccessChain %128 %62 %38 %132 %96 OpStore %133 %81 -%134 = OpLoad %6 %60 -%135 = OpLoad %6 %60 -%136 = OpAccessChain %128 %63 %3 %134 %135 +%134 = OpLoad %5 %59 +%135 = OpLoad %5 %59 +%136 = OpAccessChain %128 %62 %38 %134 %135 OpStore %136 %82 OpReturn OpFunctionEnd -%143 = OpFunction %2 None %68 +%143 = OpFunction %2 None %67 %142 = OpLabel -%137 = OpVariable %61 Function %138 +%137 = OpVariable %60 Function %138 %139 = OpVariable %140 Function %141 -%145 = OpAccessChain %144 %56 %3 +%145 = OpAccessChain %144 %55 %38 OpBranch %150 %150 = OpLabel -OpStore %137 %9 -%151 = OpLoad %6 %137 -%152 = OpISub %6 %151 %9 +OpStore %137 %70 +%151 = OpLoad %5 %137 +%152 = OpISub %5 %151 %70 OpStore %137 %152 -%154 = OpAccessChain %153 %145 %3 -%155 = OpLoad %31 %154 -%157 = OpAccessChain %156 %145 %3 %3 -%158 = OpLoad %30 %157 -%159 = OpAccessChain %89 %145 %3 %3 %3 -%160 = OpLoad %18 %159 -%161 = OpLoad %6 %137 -%162 = OpAccessChain %89 %145 %3 %3 %161 -%163 = OpLoad %18 %162 -%164 = OpAccessChain %95 %145 %3 %3 %3 %96 -%165 = OpLoad %16 %164 -%166 = OpLoad %6 %137 -%167 = OpAccessChain %95 %145 %3 %3 %3 %166 -%168 = OpLoad %16 %167 -%169 = OpLoad %6 %137 -%170 = OpAccessChain %95 %145 %3 %3 %169 %96 -%171 = OpLoad %16 %170 -%172 = OpLoad %6 %137 -%173 = OpLoad %6 %137 -%174 = OpAccessChain %95 %145 %3 %3 %172 %173 -%175 = OpLoad %16 %174 -%176 = OpCompositeConstruct %32 %146 +%154 = OpAccessChain %153 %145 %38 +%155 = OpLoad %25 %154 +%157 = OpAccessChain %156 %145 %38 %38 +%158 = OpLoad %24 %157 +%159 = OpAccessChain %89 %145 %38 %38 %38 +%160 = OpLoad %12 %159 +%161 = OpLoad %5 %137 +%162 = OpAccessChain %89 %145 %38 %38 %161 +%163 = OpLoad %12 %162 +%164 = OpAccessChain %95 %145 %38 %38 %38 %96 +%165 = OpLoad %10 %164 +%166 = OpLoad %5 %137 +%167 = OpAccessChain %95 %145 %38 %38 %38 %166 +%168 = OpLoad %10 %167 +%169 = OpLoad %5 %137 +%170 = OpAccessChain %95 %145 %38 %38 %169 %96 +%171 = OpLoad %10 %170 +%172 = OpLoad %5 %137 +%173 = OpLoad %5 %137 +%174 = OpAccessChain %95 %145 %38 %38 %172 %173 +%175 = OpLoad %10 %174 +%176 = OpCompositeConstruct %26 %146 OpStore %139 %176 -%177 = OpLoad %6 %137 -%178 = OpIAdd %6 %177 %9 +%177 = OpLoad %5 %137 +%178 = OpIAdd %5 %177 %70 OpStore %137 %178 -%180 = OpAccessChain %179 %139 %3 +%180 = OpAccessChain %179 %139 %38 OpStore %180 %147 -%182 = OpCompositeConstruct %18 %148 %148 -%183 = OpCompositeConstruct %18 %149 %149 -%184 = OpCompositeConstruct %18 %74 %74 -%185 = OpCompositeConstruct %18 %75 %75 -%186 = OpCompositeConstruct %30 %182 %183 %184 %185 -%187 = OpAccessChain %181 %139 %3 %3 +%182 = OpCompositeConstruct %12 %148 %148 +%183 = OpCompositeConstruct %12 %149 %149 +%184 = OpCompositeConstruct %12 %74 %74 +%185 = OpCompositeConstruct %12 %75 %75 +%186 = OpCompositeConstruct %24 %182 %183 %184 %185 +%187 = OpAccessChain %181 %139 %38 %38 OpStore %187 %186 -%188 = OpCompositeConstruct %18 %77 %77 -%189 = OpAccessChain %122 %139 %3 %3 %3 +%188 = OpCompositeConstruct %12 %77 %77 +%189 = OpAccessChain %122 %139 %38 %38 %38 OpStore %189 %188 -%190 = OpLoad %6 %137 -%191 = OpCompositeConstruct %18 %78 %78 -%192 = OpAccessChain %122 %139 %3 %3 %190 +%190 = OpLoad %5 %137 +%191 = OpCompositeConstruct %12 %78 %78 +%192 = OpAccessChain %122 %139 %38 %38 %190 OpStore %192 %191 -%193 = OpAccessChain %128 %139 %3 %3 %3 %96 +%193 = OpAccessChain %128 %139 %38 %38 %38 %96 OpStore %193 %79 -%194 = OpLoad %6 %137 -%195 = OpAccessChain %128 %139 %3 %3 %3 %194 +%194 = OpLoad %5 %137 +%195 = OpAccessChain %128 %139 %38 %38 %38 %194 OpStore %195 %80 -%196 = OpLoad %6 %137 -%197 = OpAccessChain %128 %139 %3 %3 %196 %96 +%196 = OpLoad %5 %137 +%197 = OpAccessChain %128 %139 %38 %38 %196 %96 OpStore %197 %81 -%198 = OpLoad %6 %137 -%199 = OpLoad %6 %137 -%200 = OpAccessChain %128 %139 %3 %3 %198 %199 +%198 = OpLoad %5 %137 +%199 = OpLoad %5 %137 +%200 = OpAccessChain %128 %139 %38 %38 %198 %199 OpStore %200 %82 OpReturn OpFunctionEnd -%203 = OpFunction %16 None %204 -%202 = OpFunctionParameter %33 +%203 = OpFunction %10 None %204 +%202 = OpFunctionParameter %27 %201 = OpLabel OpBranch %205 %205 = OpLabel -%206 = OpLoad %16 %202 +%206 = OpLoad %10 %202 OpReturnValue %206 OpFunctionEnd -%209 = OpFunction %16 None %210 -%208 = OpFunctionParameter %35 +%209 = OpFunction %10 None %210 +%208 = OpFunctionParameter %29 %207 = OpLabel OpBranch %211 %211 = OpLabel -%212 = OpCompositeExtract %34 %208 4 -%213 = OpCompositeExtract %16 %212 9 +%212 = OpCompositeExtract %28 %208 4 +%213 = OpCompositeExtract %10 %212 9 OpReturnValue %213 OpFunctionEnd %216 = OpFunction %2 None %217 -%215 = OpFunctionParameter %41 +%215 = OpFunctionParameter %35 %214 = OpLabel OpBranch %219 %219 = OpLabel @@ -393,107 +393,107 @@ OpStore %215 %218 OpReturn OpFunctionEnd %222 = OpFunction %2 None %223 -%221 = OpFunctionParameter %43 +%221 = OpFunctionParameter %37 %220 = OpLabel OpBranch %224 %224 = OpLabel -%225 = OpCompositeConstruct %37 %71 %71 %71 %71 -%226 = OpCompositeConstruct %37 %72 %72 %72 %72 -%227 = OpCompositeConstruct %42 %225 %226 +%225 = OpCompositeConstruct %31 %71 %71 %71 %71 +%226 = OpCompositeConstruct %31 %72 %72 %72 %72 +%227 = OpCompositeConstruct %36 %225 %226 OpStore %221 %227 OpReturn OpFunctionEnd -%239 = OpFunction %2 None %68 +%239 = OpFunction %2 None %67 %233 = OpLabel -%228 = OpVariable %33 Function %229 +%228 = OpVariable %27 Function %229 %230 = OpVariable %231 Function %232 -%236 = OpLoad %4 %234 -%240 = OpAccessChain %69 %50 %3 -%242 = OpAccessChain %241 %53 %3 -%243 = OpAccessChain %144 %56 %3 +%236 = OpLoad %3 %234 +%240 = OpAccessChain %68 %49 %38 +%242 = OpAccessChain %241 %52 %38 +%243 = OpAccessChain %144 %55 %38 OpBranch %250 %250 = OpLabel OpStore %228 %244 -%251 = OpLoad %16 %228 +%251 = OpLoad %10 %228 OpStore %228 %71 -%252 = OpFunctionCall %2 %67 +%252 = OpFunctionCall %2 %66 %253 = OpFunctionCall %2 %143 -%255 = OpAccessChain %254 %48 %3 -%256 = OpLoad %14 %255 -%259 = OpAccessChain %257 %48 %258 -%260 = OpLoad %24 %259 -%263 = OpAccessChain %262 %48 %3 %245 %3 -%264 = OpLoad %16 %263 -%266 = OpArrayLength %4 %48 5 -%267 = OpISub %4 %266 %20 -%269 = OpAccessChain %38 %48 %36 %267 %3 -%270 = OpLoad %6 %269 -%271 = OpLoad %29 %242 -%272 = OpFunctionCall %16 %203 %228 -%273 = OpConvertFToS %6 %264 -%274 = OpCompositeConstruct %39 %270 %273 %246 %247 %10 +%255 = OpAccessChain %254 %47 %38 +%256 = OpLoad %8 %255 +%259 = OpAccessChain %257 %47 %258 +%260 = OpLoad %18 %259 +%263 = OpAccessChain %262 %47 %38 %245 %38 +%264 = OpLoad %10 %263 +%266 = OpArrayLength %3 %47 5 +%267 = OpISub %3 %266 %14 +%269 = OpAccessChain %32 %47 %30 %267 %38 +%270 = OpLoad %5 %269 +%271 = OpLoad %23 %242 +%272 = OpFunctionCall %10 %203 %228 +%273 = OpConvertFToS %5 %264 +%274 = OpCompositeConstruct %33 %270 %273 %246 %247 %44 OpStore %230 %274 -%275 = OpIAdd %4 %236 %96 -%276 = OpAccessChain %61 %230 %275 +%275 = OpIAdd %3 %236 %96 +%276 = OpAccessChain %60 %230 %275 OpStore %276 %248 -%277 = OpAccessChain %61 %230 %236 -%278 = OpLoad %6 %277 -%279 = OpFunctionCall %16 %209 %249 -%280 = OpCompositeConstruct %40 %278 %278 %278 %278 -%281 = OpConvertSToF %37 %280 -%282 = OpMatrixTimesVector %15 %256 %281 -%283 = OpCompositeConstruct %37 %282 %72 +%277 = OpAccessChain %60 %230 %236 +%278 = OpLoad %5 %277 +%279 = OpFunctionCall %10 %209 %249 +%280 = OpCompositeConstruct %34 %278 %278 %278 %278 +%281 = OpConvertSToF %31 %280 +%282 = OpMatrixTimesVector %9 %256 %281 +%283 = OpCompositeConstruct %31 %282 %72 OpStore %237 %283 OpReturn OpFunctionEnd -%286 = OpFunction %2 None %68 +%286 = OpFunction %2 None %67 %284 = OpLabel -%287 = OpAccessChain %241 %53 %3 +%287 = OpAccessChain %241 %52 %38 OpBranch %289 %289 = OpLabel -%290 = OpAccessChain %262 %48 %3 %96 %20 +%290 = OpAccessChain %262 %47 %38 %96 %14 OpStore %290 %71 -%291 = OpCompositeConstruct %15 %244 %244 %244 -%292 = OpCompositeConstruct %15 %71 %71 %71 -%293 = OpCompositeConstruct %15 %72 %72 %72 -%294 = OpCompositeConstruct %15 %73 %73 %73 -%295 = OpCompositeConstruct %14 %291 %292 %293 %294 -%296 = OpAccessChain %254 %48 %3 +%291 = OpCompositeConstruct %9 %244 %244 %244 +%292 = OpCompositeConstruct %9 %71 %71 %71 +%293 = OpCompositeConstruct %9 %72 %72 %72 +%294 = OpCompositeConstruct %9 %73 %73 %73 +%295 = OpCompositeConstruct %8 %291 %292 %293 %294 +%296 = OpAccessChain %254 %47 %38 OpStore %296 %295 -%297 = OpCompositeConstruct %23 %3 %3 -%298 = OpCompositeConstruct %23 %96 %96 -%299 = OpCompositeConstruct %24 %297 %298 -%300 = OpAccessChain %257 %48 %258 +%297 = OpCompositeConstruct %17 %38 %38 +%298 = OpCompositeConstruct %17 %96 %96 +%299 = OpCompositeConstruct %18 %297 %298 +%300 = OpAccessChain %257 %47 %258 OpStore %300 %299 -%301 = OpAccessChain %38 %48 %36 %96 %3 -OpStore %301 %9 +%301 = OpAccessChain %32 %47 %30 %96 %38 +OpStore %301 %70 OpStore %287 %288 -%302 = OpCompositeConstruct %37 %244 %244 %244 %244 +%302 = OpCompositeConstruct %31 %244 %244 %244 %244 OpStore %285 %302 OpReturn OpFunctionEnd -%306 = OpFunction %2 None %68 +%306 = OpFunction %2 None %67 %305 = OpLabel -%303 = OpVariable %43 Function %304 +%303 = OpVariable %37 Function %304 OpBranch %307 %307 = OpLabel -%311 = OpLoad %11 %309 +%311 = OpLoad %4 %309 %315 = OpIEqual %313 %311 %312 %316 = OpAll %314 %315 OpSelectionMerge %317 None OpBranchConditional %316 %318 %317 %318 = OpLabel -OpStore %59 %308 +OpStore %58 %308 OpBranch %317 %317 = OpLabel -OpControlBarrier %20 %20 %319 +OpControlBarrier %14 %14 %319 OpBranch %320 %320 = OpLabel -%321 = OpCompositeConstruct %37 %74 %74 %74 %74 -%322 = OpCompositeConstruct %37 %149 %149 %149 %149 -%323 = OpCompositeConstruct %42 %321 %322 +%321 = OpCompositeConstruct %31 %74 %74 %74 %74 +%322 = OpCompositeConstruct %31 %149 %149 %149 %149 +%323 = OpCompositeConstruct %36 %321 %322 OpStore %303 %323 -%324 = OpFunctionCall %2 %216 %59 +%324 = OpFunctionCall %2 %216 %58 %325 = OpFunctionCall %2 %222 %303 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/array-in-ctor.spvasm b/tests/out/spv/array-in-ctor.spvasm index 5511954fc4..61d1bd48df 100644 --- a/tests/out/spv/array-in-ctor.spvasm +++ b/tests/out/spv/array-in-ctor.spvasm @@ -8,32 +8,32 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %14 "cs_main" OpExecutionMode %14 LocalSize 1 1 1 -OpDecorate %6 ArrayStride 4 -OpMemberDecorate %9 0 Offset 0 +OpDecorate %4 ArrayStride 4 +OpMemberDecorate %7 0 Offset 0 OpDecorate %10 NonWritable OpDecorate %10 DescriptorSet 0 OpDecorate %10 Binding 0 OpDecorate %11 Block OpMemberDecorate %11 0 Offset 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 2 -%5 = OpTypeFloat 32 -%8 = OpTypeInt 32 0 -%7 = OpConstant %8 2 -%6 = OpTypeArray %5 %7 -%9 = OpTypeStruct %6 -%11 = OpTypeStruct %9 +%3 = OpTypeFloat 32 +%6 = OpTypeInt 32 0 +%5 = OpConstant %6 2 +%4 = OpTypeArray %3 %5 +%7 = OpTypeStruct %4 +%9 = OpTypeInt 32 1 +%8 = OpConstant %9 2 +%11 = OpTypeStruct %7 %12 = OpTypePointer StorageBuffer %11 %10 = OpVariable %12 StorageBuffer %15 = OpTypeFunction %2 -%16 = OpTypePointer StorageBuffer %9 -%17 = OpConstant %8 0 +%16 = OpTypePointer StorageBuffer %7 +%17 = OpConstant %6 0 %14 = OpFunction %2 None %15 %13 = OpLabel %18 = OpAccessChain %16 %10 %17 OpBranch %19 %19 = OpLabel -%20 = OpLoad %9 %18 +%20 = OpLoad %7 %18 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 e704340251..71e1cd6f1d 100644 --- a/tests/out/spv/array-in-function-return-type.spvasm +++ b/tests/out/spv/array-in-function-return-type.spvasm @@ -7,38 +7,38 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %20 "main" %18 OpExecutionMode %20 OriginUpperLeft -OpDecorate %6 ArrayStride 4 +OpDecorate %4 ArrayStride 4 OpDecorate %18 Location 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 2 -%5 = OpTypeFloat 32 -%8 = OpTypeInt 32 0 -%7 = OpConstant %8 2 -%6 = OpTypeArray %5 %7 -%9 = OpTypeVector %5 4 -%12 = OpTypeFunction %6 -%13 = OpConstant %5 1.0 -%14 = OpConstant %5 2.0 -%19 = OpTypePointer Output %9 +%3 = OpTypeFloat 32 +%6 = OpTypeInt 32 0 +%5 = OpConstant %6 2 +%4 = OpTypeArray %3 %5 +%7 = OpTypeVector %3 4 +%9 = OpTypeInt 32 1 +%8 = OpConstant %9 2 +%12 = OpTypeFunction %4 +%13 = OpConstant %3 1.0 +%14 = OpConstant %3 2.0 +%19 = OpTypePointer Output %7 %18 = OpVariable %19 Output %21 = OpTypeFunction %2 -%22 = OpConstant %5 0.0 -%11 = OpFunction %6 None %12 +%22 = OpConstant %3 0.0 +%11 = OpFunction %4 None %12 %10 = OpLabel OpBranch %15 %15 = OpLabel -%16 = OpCompositeConstruct %6 %13 %14 +%16 = OpCompositeConstruct %4 %13 %14 OpReturnValue %16 OpFunctionEnd %20 = OpFunction %2 None %21 %17 = OpLabel OpBranch %23 %23 = OpLabel -%24 = OpFunctionCall %6 %11 -%25 = OpCompositeExtract %5 %24 0 -%26 = OpCompositeExtract %5 %24 1 -%27 = OpCompositeConstruct %9 %25 %26 %22 %13 +%24 = OpFunctionCall %4 %11 +%25 = OpCompositeExtract %3 %24 0 +%26 = OpCompositeExtract %3 %24 1 +%27 = OpCompositeConstruct %7 %25 %26 %22 %13 OpStore %18 %27 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/atomicCompareExchange.spvasm b/tests/out/spv/atomicCompareExchange.spvasm index 1812f1a905..82ebc2f202 100644 --- a/tests/out/spv/atomicCompareExchange.spvasm +++ b/tests/out/spv/atomicCompareExchange.spvasm @@ -1,209 +1,208 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 127 +; Bound: 126 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %30 "test_atomic_compare_exchange_i32" -OpEntryPoint GLCompute %85 "test_atomic_compare_exchange_u32" -OpExecutionMode %30 LocalSize 1 1 1 -OpExecutionMode %85 LocalSize 1 1 1 +OpEntryPoint GLCompute %28 "test_atomic_compare_exchange_i32" +OpEntryPoint GLCompute %84 "test_atomic_compare_exchange_u32" +OpExecutionMode %28 LocalSize 1 1 1 +OpExecutionMode %84 LocalSize 1 1 1 +OpDecorate %5 ArrayStride 4 OpDecorate %7 ArrayStride 4 -OpDecorate %9 ArrayStride 4 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 4 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 4 +OpMemberDecorate %11 0 Offset 0 +OpMemberDecorate %11 1 Offset 4 +OpDecorate %12 DescriptorSet 0 +OpDecorate %12 Binding 0 +OpDecorate %13 Block OpMemberDecorate %13 0 Offset 0 -OpMemberDecorate %13 1 Offset 4 -OpDecorate %14 DescriptorSet 0 -OpDecorate %14 Binding 0 -OpDecorate %15 Block -OpMemberDecorate %15 0 Offset 0 -OpDecorate %17 DescriptorSet 0 -OpDecorate %17 Binding 1 -OpDecorate %18 Block -OpMemberDecorate %18 0 Offset 0 +OpDecorate %15 DescriptorSet 0 +OpDecorate %15 Binding 1 +OpDecorate %16 Block +OpMemberDecorate %16 0 Offset 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 0 -%3 = OpConstant %4 128 -%5 = OpConstant %4 1 -%6 = OpTypeInt 32 1 -%8 = OpConstant %4 128 -%7 = OpTypeArray %6 %8 -%9 = OpTypeArray %4 %8 -%10 = OpTypeBool -%11 = OpTypeFloat 32 -%12 = OpTypeStruct %6 %10 -%13 = OpTypeStruct %4 %10 -%15 = OpTypeStruct %7 -%16 = OpTypePointer StorageBuffer %15 -%14 = OpVariable %16 StorageBuffer -%18 = OpTypeStruct %9 -%19 = OpTypePointer StorageBuffer %18 -%17 = OpVariable %19 StorageBuffer -%21 = OpTypePointer Function %4 -%22 = OpConstantNull %4 -%24 = OpTypePointer Function %6 -%25 = OpConstantNull %6 -%27 = OpTypePointer Function %10 -%28 = OpConstantNull %10 -%31 = OpTypeFunction %2 -%32 = OpTypePointer StorageBuffer %7 -%33 = OpConstant %4 0 -%35 = OpConstantFalse %10 -%36 = OpConstant %11 1.0 -%49 = OpTypePointer StorageBuffer %6 -%52 = OpConstant %6 1 -%53 = OpConstant %4 64 -%79 = OpConstantNull %4 -%81 = OpConstantNull %4 -%83 = OpConstantNull %10 -%86 = OpTypePointer StorageBuffer %9 -%100 = OpTypePointer StorageBuffer %4 -%30 = OpFunction %2 None %31 -%29 = OpLabel -%20 = OpVariable %21 Function %22 -%23 = OpVariable %24 Function %25 -%26 = OpVariable %27 Function %28 -%34 = OpAccessChain %32 %14 %33 +%3 = OpTypeInt 32 0 +%4 = OpTypeInt 32 1 +%6 = OpConstant %3 128 +%5 = OpTypeArray %4 %6 +%7 = OpTypeArray %3 %6 +%8 = OpTypeBool +%9 = OpTypeFloat 32 +%10 = OpTypeStruct %4 %8 +%11 = OpTypeStruct %3 %8 +%13 = OpTypeStruct %5 +%14 = OpTypePointer StorageBuffer %13 +%12 = OpVariable %14 StorageBuffer +%16 = OpTypeStruct %7 +%17 = OpTypePointer StorageBuffer %16 +%15 = OpVariable %17 StorageBuffer +%19 = OpTypePointer Function %3 +%20 = OpConstantNull %3 +%22 = OpTypePointer Function %4 +%23 = OpConstantNull %4 +%25 = OpTypePointer Function %8 +%26 = OpConstantNull %8 +%29 = OpTypeFunction %2 +%30 = OpTypePointer StorageBuffer %5 +%31 = OpConstant %3 0 +%33 = OpConstantFalse %8 +%34 = OpConstant %9 1.0 +%35 = OpConstant %3 1 +%48 = OpTypePointer StorageBuffer %4 +%51 = OpConstant %4 1 +%52 = OpConstant %3 64 +%78 = OpConstantNull %3 +%80 = OpConstantNull %3 +%82 = OpConstantNull %8 +%85 = OpTypePointer StorageBuffer %7 +%99 = OpTypePointer StorageBuffer %3 +%28 = OpFunction %2 None %29 +%27 = OpLabel +%18 = OpVariable %19 Function %20 +%21 = OpVariable %22 Function %23 +%24 = OpVariable %25 Function %26 +%32 = OpAccessChain %30 %12 %31 +OpBranch %36 +%36 = OpLabel +OpStore %18 %31 OpBranch %37 %37 = OpLabel -OpStore %20 %33 -OpBranch %38 -%38 = OpLabel -OpLoopMerge %39 %41 None -OpBranch %40 -%40 = OpLabel -%42 = OpLoad %4 %20 -%43 = OpULessThan %10 %42 %3 -OpSelectionMerge %44 None -OpBranchConditional %43 %44 %45 -%45 = OpLabel +OpLoopMerge %38 %40 None OpBranch %39 +%39 = OpLabel +%41 = OpLoad %3 %18 +%42 = OpULessThan %8 %41 %6 +OpSelectionMerge %43 None +OpBranchConditional %42 %43 %44 %44 = OpLabel -OpBranch %46 -%46 = OpLabel -%48 = OpLoad %4 %20 -%50 = OpAccessChain %49 %34 %48 -%51 = OpAtomicLoad %6 %50 %52 %53 -OpStore %23 %51 -OpStore %26 %35 -OpBranch %54 -%54 = OpLabel -OpLoopMerge %55 %57 None -OpBranch %56 -%56 = OpLabel -%58 = OpLoad %10 %26 -%59 = OpLogicalNot %10 %58 -OpSelectionMerge %60 None -OpBranchConditional %59 %60 %61 -%61 = OpLabel +OpBranch %38 +%43 = OpLabel +OpBranch %45 +%45 = OpLabel +%47 = OpLoad %3 %18 +%49 = OpAccessChain %48 %32 %47 +%50 = OpAtomicLoad %4 %49 %51 %52 +OpStore %21 %50 +OpStore %24 %33 +OpBranch %53 +%53 = OpLabel +OpLoopMerge %54 %56 None OpBranch %55 +%55 = OpLabel +%57 = OpLoad %8 %24 +%58 = OpLogicalNot %8 %57 +OpSelectionMerge %59 None +OpBranchConditional %58 %59 %60 %60 = OpLabel +OpBranch %54 +%59 = OpLabel +OpBranch %61 +%61 = OpLabel +%63 = OpLoad %4 %21 +%64 = OpBitcast %9 %63 +%65 = OpFAdd %9 %64 %34 +%66 = OpBitcast %4 %65 +%67 = OpLoad %3 %18 +%68 = OpLoad %4 %21 +%70 = OpAccessChain %48 %32 %67 +%71 = OpAtomicCompareExchange %4 %70 %51 %52 %52 %66 %68 +%72 = OpIEqual %8 %71 %68 +%69 = OpCompositeConstruct %10 %71 %72 +%73 = OpCompositeExtract %4 %69 0 +OpStore %21 %73 +%74 = OpCompositeExtract %8 %69 1 +OpStore %24 %74 OpBranch %62 %62 = OpLabel -%64 = OpLoad %6 %23 -%65 = OpBitcast %11 %64 -%66 = OpFAdd %11 %65 %36 -%67 = OpBitcast %6 %66 -%68 = OpLoad %4 %20 -%69 = OpLoad %6 %23 -%71 = OpAccessChain %49 %34 %68 -%72 = OpAtomicCompareExchange %6 %71 %52 %53 %53 %67 %69 -%73 = OpIEqual %10 %72 %69 -%70 = OpCompositeConstruct %12 %72 %73 -%74 = OpCompositeExtract %6 %70 0 -OpStore %23 %74 -%75 = OpCompositeExtract %10 %70 1 -OpStore %26 %75 -OpBranch %63 -%63 = OpLabel -OpBranch %57 -%57 = OpLabel -OpBranch %54 -%55 = OpLabel -OpBranch %47 -%47 = OpLabel -OpBranch %41 -%41 = OpLabel -%76 = OpLoad %4 %20 -%77 = OpIAdd %4 %76 %5 -OpStore %20 %77 -OpBranch %38 -%39 = OpLabel +OpBranch %56 +%56 = OpLabel +OpBranch %53 +%54 = OpLabel +OpBranch %46 +%46 = OpLabel +OpBranch %40 +%40 = OpLabel +%75 = OpLoad %3 %18 +%76 = OpIAdd %3 %75 %35 +OpStore %18 %76 +OpBranch %37 +%38 = OpLabel OpReturn OpFunctionEnd -%85 = OpFunction %2 None %31 -%84 = OpLabel -%78 = OpVariable %21 Function %79 -%80 = OpVariable %21 Function %81 -%82 = OpVariable %27 Function %83 -%87 = OpAccessChain %86 %17 %33 +%84 = OpFunction %2 None %29 +%83 = OpLabel +%77 = OpVariable %19 Function %78 +%79 = OpVariable %19 Function %80 +%81 = OpVariable %25 Function %82 +%86 = OpAccessChain %85 %15 %31 +OpBranch %87 +%87 = OpLabel +OpStore %77 %31 OpBranch %88 %88 = OpLabel -OpStore %78 %33 -OpBranch %89 -%89 = OpLabel -OpLoopMerge %90 %92 None -OpBranch %91 -%91 = OpLabel -%93 = OpLoad %4 %78 -%94 = OpULessThan %10 %93 %3 -OpSelectionMerge %95 None -OpBranchConditional %94 %95 %96 -%96 = OpLabel +OpLoopMerge %89 %91 None OpBranch %90 +%90 = OpLabel +%92 = OpLoad %3 %77 +%93 = OpULessThan %8 %92 %6 +OpSelectionMerge %94 None +OpBranchConditional %93 %94 %95 %95 = OpLabel -OpBranch %97 -%97 = OpLabel -%99 = OpLoad %4 %78 -%101 = OpAccessChain %100 %87 %99 -%102 = OpAtomicLoad %4 %101 %52 %53 -OpStore %80 %102 -OpStore %82 %35 -OpBranch %103 -%103 = OpLabel -OpLoopMerge %104 %106 None -OpBranch %105 -%105 = OpLabel -%107 = OpLoad %10 %82 -%108 = OpLogicalNot %10 %107 -OpSelectionMerge %109 None -OpBranchConditional %108 %109 %110 -%110 = OpLabel +OpBranch %89 +%94 = OpLabel +OpBranch %96 +%96 = OpLabel +%98 = OpLoad %3 %77 +%100 = OpAccessChain %99 %86 %98 +%101 = OpAtomicLoad %3 %100 %51 %52 +OpStore %79 %101 +OpStore %81 %33 +OpBranch %102 +%102 = OpLabel +OpLoopMerge %103 %105 None OpBranch %104 +%104 = OpLabel +%106 = OpLoad %8 %81 +%107 = OpLogicalNot %8 %106 +OpSelectionMerge %108 None +OpBranchConditional %107 %108 %109 %109 = OpLabel +OpBranch %103 +%108 = OpLabel +OpBranch %110 +%110 = OpLabel +%112 = OpLoad %3 %79 +%113 = OpBitcast %9 %112 +%114 = OpFAdd %9 %113 %34 +%115 = OpBitcast %3 %114 +%116 = OpLoad %3 %77 +%117 = OpLoad %3 %79 +%119 = OpAccessChain %99 %86 %116 +%120 = OpAtomicCompareExchange %3 %119 %51 %52 %52 %115 %117 +%121 = OpIEqual %8 %120 %117 +%118 = OpCompositeConstruct %11 %120 %121 +%122 = OpCompositeExtract %3 %118 0 +OpStore %79 %122 +%123 = OpCompositeExtract %8 %118 1 +OpStore %81 %123 OpBranch %111 %111 = OpLabel -%113 = OpLoad %4 %80 -%114 = OpBitcast %11 %113 -%115 = OpFAdd %11 %114 %36 -%116 = OpBitcast %4 %115 -%117 = OpLoad %4 %78 -%118 = OpLoad %4 %80 -%120 = OpAccessChain %100 %87 %117 -%121 = OpAtomicCompareExchange %4 %120 %52 %53 %53 %116 %118 -%122 = OpIEqual %10 %121 %118 -%119 = OpCompositeConstruct %13 %121 %122 -%123 = OpCompositeExtract %4 %119 0 -OpStore %80 %123 -%124 = OpCompositeExtract %10 %119 1 -OpStore %82 %124 -OpBranch %112 -%112 = OpLabel -OpBranch %106 -%106 = OpLabel -OpBranch %103 -%104 = OpLabel -OpBranch %98 -%98 = OpLabel -OpBranch %92 -%92 = OpLabel -%125 = OpLoad %4 %78 -%126 = OpIAdd %4 %125 %5 -OpStore %78 %126 -OpBranch %89 -%90 = OpLabel +OpBranch %105 +%105 = OpLabel +OpBranch %102 +%103 = OpLabel +OpBranch %97 +%97 = OpLabel +OpBranch %91 +%91 = OpLabel +%124 = OpLoad %3 %77 +%125 = OpIAdd %3 %124 %35 +OpStore %77 %125 +OpBranch %88 +%89 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/atomicOps.spvasm b/tests/out/spv/atomicOps.spvasm index a30a92a306..65d078ad93 100644 --- a/tests/out/spv/atomicOps.spvasm +++ b/tests/out/spv/atomicOps.spvasm @@ -8,9 +8,9 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %29 "cs_main" %26 OpExecutionMode %29 LocalSize 2 1 1 -OpDecorate %6 ArrayStride 4 -OpMemberDecorate %8 0 Offset 0 -OpMemberDecorate %8 1 Offset 4 +OpDecorate %5 ArrayStride 4 +OpMemberDecorate %7 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 OpDecorate %10 DescriptorSet 0 OpDecorate %10 Binding 0 OpDecorate %11 Block @@ -25,51 +25,51 @@ OpDecorate %17 Block OpMemberDecorate %17 0 Offset 0 OpDecorate %26 BuiltIn LocalInvocationId %2 = OpTypeVoid +%3 = OpTypeInt 32 0 %4 = OpTypeInt 32 1 -%3 = OpConstant %4 2 -%5 = OpTypeInt 32 0 -%7 = OpConstant %5 2 -%6 = OpTypeArray %4 %7 -%8 = OpTypeStruct %5 %6 -%9 = OpTypeVector %5 3 -%11 = OpTypeStruct %5 +%6 = OpConstant %3 2 +%5 = OpTypeArray %4 %6 +%7 = OpTypeStruct %3 %5 +%8 = OpTypeVector %3 3 +%9 = OpConstant %4 2 +%11 = OpTypeStruct %3 %12 = OpTypePointer StorageBuffer %11 %10 = OpVariable %12 StorageBuffer -%14 = OpTypeStruct %6 +%14 = OpTypeStruct %5 %15 = OpTypePointer StorageBuffer %14 %13 = OpVariable %15 StorageBuffer -%17 = OpTypeStruct %8 +%17 = OpTypeStruct %7 %18 = OpTypePointer StorageBuffer %17 %16 = OpVariable %18 StorageBuffer -%20 = OpTypePointer Workgroup %5 +%20 = OpTypePointer Workgroup %3 %19 = OpVariable %20 Workgroup -%22 = OpTypePointer Workgroup %6 +%22 = OpTypePointer Workgroup %5 %21 = OpVariable %22 Workgroup -%24 = OpTypePointer Workgroup %8 +%24 = OpTypePointer Workgroup %7 %23 = OpVariable %24 Workgroup -%27 = OpTypePointer Input %9 +%27 = OpTypePointer Input %8 %26 = OpVariable %27 Input %30 = OpTypeFunction %2 -%31 = OpTypePointer StorageBuffer %5 -%32 = OpConstant %5 0 -%34 = OpTypePointer StorageBuffer %6 -%36 = OpTypePointer StorageBuffer %8 -%38 = OpConstant %5 1 +%31 = OpTypePointer StorageBuffer %3 +%32 = OpConstant %3 0 +%34 = OpTypePointer StorageBuffer %5 +%36 = OpTypePointer StorageBuffer %7 +%38 = OpConstant %3 1 %39 = OpConstant %4 1 -%41 = OpConstantNull %5 -%42 = OpConstantNull %6 -%43 = OpConstantNull %8 -%44 = OpConstantNull %9 +%41 = OpConstantNull %3 +%42 = OpConstantNull %5 +%43 = OpConstantNull %7 +%44 = OpConstantNull %8 %46 = OpTypeBool %45 = OpTypeVector %46 3 -%51 = OpConstant %5 264 -%53 = OpConstant %5 64 +%51 = OpConstant %3 264 +%53 = OpConstant %3 64 %54 = OpTypePointer StorageBuffer %4 -%58 = OpConstant %5 256 +%58 = OpConstant %3 256 %59 = OpTypePointer Workgroup %4 %29 = OpFunction %2 None %30 %25 = OpLabel -%28 = OpLoad %9 %26 +%28 = OpLoad %8 %26 %33 = OpAccessChain %31 %10 %32 %35 = OpAccessChain %34 %13 %32 %37 = OpAccessChain %36 %16 %32 @@ -85,7 +85,7 @@ OpStore %21 %42 OpStore %23 %43 OpBranch %49 %49 = OpLabel -OpControlBarrier %7 %7 %51 +OpControlBarrier %6 %6 %51 OpBranch %52 %52 = OpLabel OpAtomicStore %33 %39 %53 %38 @@ -95,146 +95,146 @@ OpAtomicStore %55 %39 %53 %39 OpAtomicStore %56 %39 %53 %38 %57 = OpAccessChain %54 %37 %38 %38 OpAtomicStore %57 %39 %53 %39 -OpAtomicStore %19 %3 %58 %38 +OpAtomicStore %19 %9 %58 %38 %60 = OpAccessChain %59 %21 %38 -OpAtomicStore %60 %3 %58 %39 +OpAtomicStore %60 %9 %58 %39 %61 = OpAccessChain %20 %23 %32 -OpAtomicStore %61 %3 %58 %38 +OpAtomicStore %61 %9 %58 %38 %62 = OpAccessChain %59 %23 %38 %38 -OpAtomicStore %62 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%63 = OpAtomicLoad %5 %33 %39 %53 +OpAtomicStore %62 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%63 = OpAtomicLoad %3 %33 %39 %53 %64 = OpAccessChain %54 %35 %38 %65 = OpAtomicLoad %4 %64 %39 %53 %66 = OpAccessChain %31 %37 %32 -%67 = OpAtomicLoad %5 %66 %39 %53 +%67 = OpAtomicLoad %3 %66 %39 %53 %68 = OpAccessChain %54 %37 %38 %38 %69 = OpAtomicLoad %4 %68 %39 %53 -%70 = OpAtomicLoad %5 %19 %3 %58 +%70 = OpAtomicLoad %3 %19 %9 %58 %71 = OpAccessChain %59 %21 %38 -%72 = OpAtomicLoad %4 %71 %3 %58 +%72 = OpAtomicLoad %4 %71 %9 %58 %73 = OpAccessChain %20 %23 %32 -%74 = OpAtomicLoad %5 %73 %3 %58 +%74 = OpAtomicLoad %3 %73 %9 %58 %75 = OpAccessChain %59 %23 %38 %38 -%76 = OpAtomicLoad %4 %75 %3 %58 -OpControlBarrier %7 %7 %51 -%77 = OpAtomicIAdd %5 %33 %39 %53 %38 +%76 = OpAtomicLoad %4 %75 %9 %58 +OpControlBarrier %6 %6 %51 +%77 = OpAtomicIAdd %3 %33 %39 %53 %38 %79 = OpAccessChain %54 %35 %38 %78 = OpAtomicIAdd %4 %79 %39 %53 %39 %81 = OpAccessChain %31 %37 %32 -%80 = OpAtomicIAdd %5 %81 %39 %53 %38 +%80 = OpAtomicIAdd %3 %81 %39 %53 %38 %83 = OpAccessChain %54 %37 %38 %38 %82 = OpAtomicIAdd %4 %83 %39 %53 %39 -%84 = OpAtomicIAdd %5 %19 %3 %58 %38 +%84 = OpAtomicIAdd %3 %19 %9 %58 %38 %86 = OpAccessChain %59 %21 %38 -%85 = OpAtomicIAdd %4 %86 %3 %58 %39 +%85 = OpAtomicIAdd %4 %86 %9 %58 %39 %88 = OpAccessChain %20 %23 %32 -%87 = OpAtomicIAdd %5 %88 %3 %58 %38 +%87 = OpAtomicIAdd %3 %88 %9 %58 %38 %90 = OpAccessChain %59 %23 %38 %38 -%89 = OpAtomicIAdd %4 %90 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%91 = OpAtomicISub %5 %33 %39 %53 %38 +%89 = OpAtomicIAdd %4 %90 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%91 = OpAtomicISub %3 %33 %39 %53 %38 %93 = OpAccessChain %54 %35 %38 %92 = OpAtomicISub %4 %93 %39 %53 %39 %95 = OpAccessChain %31 %37 %32 -%94 = OpAtomicISub %5 %95 %39 %53 %38 +%94 = OpAtomicISub %3 %95 %39 %53 %38 %97 = OpAccessChain %54 %37 %38 %38 %96 = OpAtomicISub %4 %97 %39 %53 %39 -%98 = OpAtomicISub %5 %19 %3 %58 %38 +%98 = OpAtomicISub %3 %19 %9 %58 %38 %100 = OpAccessChain %59 %21 %38 -%99 = OpAtomicISub %4 %100 %3 %58 %39 +%99 = OpAtomicISub %4 %100 %9 %58 %39 %102 = OpAccessChain %20 %23 %32 -%101 = OpAtomicISub %5 %102 %3 %58 %38 +%101 = OpAtomicISub %3 %102 %9 %58 %38 %104 = OpAccessChain %59 %23 %38 %38 -%103 = OpAtomicISub %4 %104 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%105 = OpAtomicUMax %5 %33 %39 %53 %38 +%103 = OpAtomicISub %4 %104 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%105 = OpAtomicUMax %3 %33 %39 %53 %38 %107 = OpAccessChain %54 %35 %38 %106 = OpAtomicSMax %4 %107 %39 %53 %39 %109 = OpAccessChain %31 %37 %32 -%108 = OpAtomicUMax %5 %109 %39 %53 %38 +%108 = OpAtomicUMax %3 %109 %39 %53 %38 %111 = OpAccessChain %54 %37 %38 %38 %110 = OpAtomicSMax %4 %111 %39 %53 %39 -%112 = OpAtomicUMax %5 %19 %3 %58 %38 +%112 = OpAtomicUMax %3 %19 %9 %58 %38 %114 = OpAccessChain %59 %21 %38 -%113 = OpAtomicSMax %4 %114 %3 %58 %39 +%113 = OpAtomicSMax %4 %114 %9 %58 %39 %116 = OpAccessChain %20 %23 %32 -%115 = OpAtomicUMax %5 %116 %3 %58 %38 +%115 = OpAtomicUMax %3 %116 %9 %58 %38 %118 = OpAccessChain %59 %23 %38 %38 -%117 = OpAtomicSMax %4 %118 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%119 = OpAtomicUMin %5 %33 %39 %53 %38 +%117 = OpAtomicSMax %4 %118 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%119 = OpAtomicUMin %3 %33 %39 %53 %38 %121 = OpAccessChain %54 %35 %38 %120 = OpAtomicSMin %4 %121 %39 %53 %39 %123 = OpAccessChain %31 %37 %32 -%122 = OpAtomicUMin %5 %123 %39 %53 %38 +%122 = OpAtomicUMin %3 %123 %39 %53 %38 %125 = OpAccessChain %54 %37 %38 %38 %124 = OpAtomicSMin %4 %125 %39 %53 %39 -%126 = OpAtomicUMin %5 %19 %3 %58 %38 +%126 = OpAtomicUMin %3 %19 %9 %58 %38 %128 = OpAccessChain %59 %21 %38 -%127 = OpAtomicSMin %4 %128 %3 %58 %39 +%127 = OpAtomicSMin %4 %128 %9 %58 %39 %130 = OpAccessChain %20 %23 %32 -%129 = OpAtomicUMin %5 %130 %3 %58 %38 +%129 = OpAtomicUMin %3 %130 %9 %58 %38 %132 = OpAccessChain %59 %23 %38 %38 -%131 = OpAtomicSMin %4 %132 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%133 = OpAtomicAnd %5 %33 %39 %53 %38 +%131 = OpAtomicSMin %4 %132 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%133 = OpAtomicAnd %3 %33 %39 %53 %38 %135 = OpAccessChain %54 %35 %38 %134 = OpAtomicAnd %4 %135 %39 %53 %39 %137 = OpAccessChain %31 %37 %32 -%136 = OpAtomicAnd %5 %137 %39 %53 %38 +%136 = OpAtomicAnd %3 %137 %39 %53 %38 %139 = OpAccessChain %54 %37 %38 %38 %138 = OpAtomicAnd %4 %139 %39 %53 %39 -%140 = OpAtomicAnd %5 %19 %3 %58 %38 +%140 = OpAtomicAnd %3 %19 %9 %58 %38 %142 = OpAccessChain %59 %21 %38 -%141 = OpAtomicAnd %4 %142 %3 %58 %39 +%141 = OpAtomicAnd %4 %142 %9 %58 %39 %144 = OpAccessChain %20 %23 %32 -%143 = OpAtomicAnd %5 %144 %3 %58 %38 +%143 = OpAtomicAnd %3 %144 %9 %58 %38 %146 = OpAccessChain %59 %23 %38 %38 -%145 = OpAtomicAnd %4 %146 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%147 = OpAtomicOr %5 %33 %39 %53 %38 +%145 = OpAtomicAnd %4 %146 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%147 = OpAtomicOr %3 %33 %39 %53 %38 %149 = OpAccessChain %54 %35 %38 %148 = OpAtomicOr %4 %149 %39 %53 %39 %151 = OpAccessChain %31 %37 %32 -%150 = OpAtomicOr %5 %151 %39 %53 %38 +%150 = OpAtomicOr %3 %151 %39 %53 %38 %153 = OpAccessChain %54 %37 %38 %38 %152 = OpAtomicOr %4 %153 %39 %53 %39 -%154 = OpAtomicOr %5 %19 %3 %58 %38 +%154 = OpAtomicOr %3 %19 %9 %58 %38 %156 = OpAccessChain %59 %21 %38 -%155 = OpAtomicOr %4 %156 %3 %58 %39 +%155 = OpAtomicOr %4 %156 %9 %58 %39 %158 = OpAccessChain %20 %23 %32 -%157 = OpAtomicOr %5 %158 %3 %58 %38 +%157 = OpAtomicOr %3 %158 %9 %58 %38 %160 = OpAccessChain %59 %23 %38 %38 -%159 = OpAtomicOr %4 %160 %3 %58 %39 -OpControlBarrier %7 %7 %51 -%161 = OpAtomicXor %5 %33 %39 %53 %38 +%159 = OpAtomicOr %4 %160 %9 %58 %39 +OpControlBarrier %6 %6 %51 +%161 = OpAtomicXor %3 %33 %39 %53 %38 %163 = OpAccessChain %54 %35 %38 %162 = OpAtomicXor %4 %163 %39 %53 %39 %165 = OpAccessChain %31 %37 %32 -%164 = OpAtomicXor %5 %165 %39 %53 %38 +%164 = OpAtomicXor %3 %165 %39 %53 %38 %167 = OpAccessChain %54 %37 %38 %38 %166 = OpAtomicXor %4 %167 %39 %53 %39 -%168 = OpAtomicXor %5 %19 %3 %58 %38 +%168 = OpAtomicXor %3 %19 %9 %58 %38 %170 = OpAccessChain %59 %21 %38 -%169 = OpAtomicXor %4 %170 %3 %58 %39 +%169 = OpAtomicXor %4 %170 %9 %58 %39 %172 = OpAccessChain %20 %23 %32 -%171 = OpAtomicXor %5 %172 %3 %58 %38 +%171 = OpAtomicXor %3 %172 %9 %58 %38 %174 = OpAccessChain %59 %23 %38 %38 -%173 = OpAtomicXor %4 %174 %3 %58 %39 -%175 = OpAtomicExchange %5 %33 %39 %53 %38 +%173 = OpAtomicXor %4 %174 %9 %58 %39 +%175 = OpAtomicExchange %3 %33 %39 %53 %38 %177 = OpAccessChain %54 %35 %38 %176 = OpAtomicExchange %4 %177 %39 %53 %39 %179 = OpAccessChain %31 %37 %32 -%178 = OpAtomicExchange %5 %179 %39 %53 %38 +%178 = OpAtomicExchange %3 %179 %39 %53 %38 %181 = OpAccessChain %54 %37 %38 %38 %180 = OpAtomicExchange %4 %181 %39 %53 %39 -%182 = OpAtomicExchange %5 %19 %3 %58 %38 +%182 = OpAtomicExchange %3 %19 %9 %58 %38 %184 = OpAccessChain %59 %21 %38 -%183 = OpAtomicExchange %4 %184 %3 %58 %39 +%183 = OpAtomicExchange %4 %184 %9 %58 %39 %186 = OpAccessChain %20 %23 %32 -%185 = OpAtomicExchange %5 %186 %3 %58 %38 +%185 = OpAtomicExchange %3 %186 %9 %58 %38 %188 = OpAccessChain %59 %23 %38 %38 -%187 = OpAtomicExchange %4 %188 %3 %58 %39 +%187 = OpAtomicExchange %4 %188 %9 %58 %39 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 4574eb1082..393df57bb6 100644 --- a/tests/out/spv/binding-arrays.spvasm +++ b/tests/out/spv/binding-arrays.spvasm @@ -10,8 +10,8 @@ OpExtension "SPV_EXT_descriptor_indexing" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %68 "main" %63 %66 OpExecutionMode %68 OriginUpperLeft -OpMemberDecorate %6 0 Offset 0 -OpMemberDecorate %23 0 Offset 0 +OpMemberDecorate %4 0 Offset 0 +OpMemberDecorate %21 0 Offset 0 OpDecorate %28 DescriptorSet 0 OpDecorate %28 Binding 0 OpDecorate %32 DescriptorSet 0 @@ -58,471 +58,471 @@ OpDecorate %399 NonUniform OpDecorate %401 NonUniform OpDecorate %424 NonUniform %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 5 -%5 = OpTypeInt 32 0 -%6 = OpTypeStruct %5 -%8 = OpTypeFloat 32 -%7 = OpTypeImage %8 2D 0 0 0 1 Unknown -%9 = OpTypeRuntimeArray %7 -%11 = OpConstant %5 5 -%10 = OpTypeArray %7 %11 -%12 = OpTypeImage %8 2D 0 1 0 1 Unknown -%13 = OpTypeArray %12 %11 -%14 = OpTypeImage %8 2D 0 0 1 1 Unknown -%15 = OpTypeArray %14 %11 -%16 = OpTypeImage %8 2D 1 0 0 1 Unknown -%17 = OpTypeArray %16 %11 -%18 = OpTypeImage %8 2D 0 0 0 2 Rgba32f -%19 = OpTypeArray %18 %11 -%20 = OpTypeSampler -%21 = OpTypeArray %20 %11 -%22 = OpTypeArray %20 %11 -%23 = OpTypeStruct %5 -%24 = OpTypeVector %8 4 -%25 = OpTypeVector %5 2 -%26 = OpTypeVector %8 2 -%27 = OpTypeVector %4 2 -%31 = OpConstant %5 10 -%30 = OpTypeArray %7 %31 +%3 = OpTypeInt 32 0 +%4 = OpTypeStruct %3 +%6 = OpTypeFloat 32 +%5 = OpTypeImage %6 2D 0 0 0 1 Unknown +%7 = OpTypeRuntimeArray %5 +%9 = OpConstant %3 5 +%8 = OpTypeArray %5 %9 +%10 = OpTypeImage %6 2D 0 1 0 1 Unknown +%11 = OpTypeArray %10 %9 +%12 = OpTypeImage %6 2D 0 0 1 1 Unknown +%13 = OpTypeArray %12 %9 +%14 = OpTypeImage %6 2D 1 0 0 1 Unknown +%15 = OpTypeArray %14 %9 +%16 = OpTypeImage %6 2D 0 0 0 2 Rgba32f +%17 = OpTypeArray %16 %9 +%18 = OpTypeSampler +%19 = OpTypeArray %18 %9 +%20 = OpTypeArray %18 %9 +%21 = OpTypeStruct %3 +%22 = OpTypeVector %6 4 +%23 = OpTypeVector %3 2 +%24 = OpTypeVector %6 2 +%26 = OpTypeInt 32 1 +%25 = OpTypeVector %26 2 +%27 = OpConstant %26 5 +%31 = OpConstant %3 10 +%30 = OpTypeArray %5 %31 %29 = OpTypePointer UniformConstant %30 %28 = OpVariable %29 UniformConstant -%33 = OpTypePointer UniformConstant %10 +%33 = OpTypePointer UniformConstant %8 %32 = OpVariable %33 UniformConstant -%35 = OpTypePointer UniformConstant %13 +%35 = OpTypePointer UniformConstant %11 %34 = OpVariable %35 UniformConstant -%37 = OpTypePointer UniformConstant %15 +%37 = OpTypePointer UniformConstant %13 %36 = OpVariable %37 UniformConstant -%39 = OpTypePointer UniformConstant %17 +%39 = OpTypePointer UniformConstant %15 %38 = OpVariable %39 UniformConstant -%41 = OpTypePointer UniformConstant %19 +%41 = OpTypePointer UniformConstant %17 %40 = OpVariable %41 UniformConstant -%43 = OpTypePointer UniformConstant %21 +%43 = OpTypePointer UniformConstant %19 %42 = OpVariable %43 UniformConstant -%45 = OpTypePointer UniformConstant %22 +%45 = OpTypePointer UniformConstant %20 %44 = OpVariable %45 UniformConstant -%47 = OpTypeStruct %6 +%47 = OpTypeStruct %4 %48 = OpTypePointer Uniform %47 %46 = OpVariable %48 Uniform -%50 = OpTypePointer Function %5 -%51 = OpConstantNull %5 -%53 = OpTypePointer Function %25 -%54 = OpConstantNull %25 -%56 = OpTypePointer Function %8 -%57 = OpConstantNull %8 -%59 = OpTypePointer Function %24 -%60 = OpConstantNull %24 -%64 = OpTypePointer Input %5 +%50 = OpTypePointer Function %3 +%51 = OpConstantNull %3 +%53 = OpTypePointer Function %23 +%54 = OpConstantNull %23 +%56 = OpTypePointer Function %6 +%57 = OpConstantNull %6 +%59 = OpTypePointer Function %22 +%60 = OpConstantNull %22 +%64 = OpTypePointer Input %3 %63 = OpVariable %64 Input -%67 = OpTypePointer Output %24 +%67 = OpTypePointer Output %22 %66 = OpVariable %67 Output %69 = OpTypeFunction %2 -%70 = OpTypePointer Uniform %6 -%71 = OpConstant %5 0 -%73 = OpConstant %8 0.0 -%74 = OpConstant %4 0 -%76 = OpTypePointer Uniform %5 -%84 = OpTypePointer UniformConstant %7 -%105 = OpTypePointer UniformConstant %20 -%108 = OpTypeSampledImage %7 -%129 = OpTypePointer UniformConstant %16 -%132 = OpTypePointer UniformConstant %20 -%135 = OpTypeSampledImage %16 +%70 = OpTypePointer Uniform %4 +%71 = OpConstant %3 0 +%73 = OpConstant %6 0.0 +%74 = OpConstant %26 0 +%76 = OpTypePointer Uniform %3 +%84 = OpTypePointer UniformConstant %5 +%105 = OpTypePointer UniformConstant %18 +%108 = OpTypeSampledImage %5 +%129 = OpTypePointer UniformConstant %14 +%132 = OpTypePointer UniformConstant %18 +%135 = OpTypeSampledImage %14 %158 = OpTypeBool -%159 = OpConstantNull %24 +%159 = OpConstantNull %22 %165 = OpTypeVector %158 2 -%175 = OpConstantNull %24 -%190 = OpConstantNull %24 -%203 = OpTypePointer UniformConstant %12 -%206 = OpTypeVector %4 3 -%244 = OpTypePointer UniformConstant %14 -%407 = OpTypePointer UniformConstant %18 +%175 = OpConstantNull %22 +%190 = OpConstantNull %22 +%203 = OpTypePointer UniformConstant %10 +%206 = OpTypeVector %26 3 +%244 = OpTypePointer UniformConstant %12 +%407 = OpTypePointer UniformConstant %16 %68 = OpFunction %2 None %69 %61 = OpLabel %52 = OpVariable %53 Function %54 %58 = OpVariable %59 Function %60 %49 = OpVariable %50 Function %51 %55 = OpVariable %56 Function %57 -%65 = OpLoad %5 %63 -%62 = OpCompositeConstruct %23 %65 +%65 = OpLoad %3 %63 +%62 = OpCompositeConstruct %21 %65 %72 = OpAccessChain %70 %46 %71 OpBranch %75 %75 = OpLabel %77 = OpAccessChain %76 %72 %71 -%78 = OpLoad %5 %77 -%79 = OpCompositeExtract %5 %62 0 +%78 = OpLoad %3 %77 +%79 = OpCompositeExtract %3 %62 0 OpStore %49 %71 -%80 = OpCompositeConstruct %25 %71 %71 +%80 = OpCompositeConstruct %23 %71 %71 OpStore %52 %80 OpStore %55 %73 -%81 = OpCompositeConstruct %24 %73 %73 %73 %73 +%81 = OpCompositeConstruct %22 %73 %73 %73 %73 OpStore %58 %81 -%82 = OpCompositeConstruct %26 %73 %73 -%83 = OpCompositeConstruct %27 %74 %74 +%82 = OpCompositeConstruct %24 %73 %73 +%83 = OpCompositeConstruct %25 %74 %74 %85 = OpAccessChain %84 %28 %71 -%86 = OpLoad %7 %85 -%87 = OpImageQuerySizeLod %27 %86 %71 -%88 = OpBitcast %25 %87 -%89 = OpLoad %25 %52 -%90 = OpIAdd %25 %89 %88 +%86 = OpLoad %5 %85 +%87 = OpImageQuerySizeLod %25 %86 %71 +%88 = OpBitcast %23 %87 +%89 = OpLoad %23 %52 +%90 = OpIAdd %23 %89 %88 OpStore %52 %90 %91 = OpAccessChain %84 %28 %78 -%92 = OpLoad %7 %91 -%93 = OpImageQuerySizeLod %27 %92 %71 -%94 = OpBitcast %25 %93 -%95 = OpLoad %25 %52 -%96 = OpIAdd %25 %95 %94 +%92 = OpLoad %5 %91 +%93 = OpImageQuerySizeLod %25 %92 %71 +%94 = OpBitcast %23 %93 +%95 = OpLoad %23 %52 +%96 = OpIAdd %23 %95 %94 OpStore %52 %96 %97 = OpAccessChain %84 %28 %79 -%98 = OpLoad %7 %97 -%99 = OpImageQuerySizeLod %27 %98 %71 -%100 = OpBitcast %25 %99 -%101 = OpLoad %25 %52 -%102 = OpIAdd %25 %101 %100 +%98 = OpLoad %5 %97 +%99 = OpImageQuerySizeLod %25 %98 %71 +%100 = OpBitcast %23 %99 +%101 = OpLoad %23 %52 +%102 = OpIAdd %23 %101 %100 OpStore %52 %102 %103 = OpAccessChain %84 %32 %71 -%104 = OpLoad %7 %103 +%104 = OpLoad %5 %103 %106 = OpAccessChain %105 %42 %71 -%107 = OpLoad %20 %106 +%107 = OpLoad %18 %106 %109 = OpSampledImage %108 %104 %107 -%110 = OpImageGather %24 %109 %82 %71 -%111 = OpLoad %24 %58 -%112 = OpFAdd %24 %111 %110 +%110 = OpImageGather %22 %109 %82 %71 +%111 = OpLoad %22 %58 +%112 = OpFAdd %22 %111 %110 OpStore %58 %112 %113 = OpAccessChain %84 %32 %78 -%114 = OpLoad %7 %113 +%114 = OpLoad %5 %113 %115 = OpAccessChain %105 %42 %78 -%116 = OpLoad %20 %115 +%116 = OpLoad %18 %115 %117 = OpSampledImage %108 %114 %116 -%118 = OpImageGather %24 %117 %82 %71 -%119 = OpLoad %24 %58 -%120 = OpFAdd %24 %119 %118 +%118 = OpImageGather %22 %117 %82 %71 +%119 = OpLoad %22 %58 +%120 = OpFAdd %22 %119 %118 OpStore %58 %120 %121 = OpAccessChain %84 %32 %79 -%122 = OpLoad %7 %121 +%122 = OpLoad %5 %121 %123 = OpAccessChain %105 %42 %79 -%124 = OpLoad %20 %123 +%124 = OpLoad %18 %123 %125 = OpSampledImage %108 %122 %124 -%126 = OpImageGather %24 %125 %82 %71 -%127 = OpLoad %24 %58 -%128 = OpFAdd %24 %127 %126 +%126 = OpImageGather %22 %125 %82 %71 +%127 = OpLoad %22 %58 +%128 = OpFAdd %22 %127 %126 OpStore %58 %128 %130 = OpAccessChain %129 %38 %71 -%131 = OpLoad %16 %130 +%131 = OpLoad %14 %130 %133 = OpAccessChain %132 %44 %71 -%134 = OpLoad %20 %133 +%134 = OpLoad %18 %133 %136 = OpSampledImage %135 %131 %134 -%137 = OpImageDrefGather %24 %136 %82 %73 -%138 = OpLoad %24 %58 -%139 = OpFAdd %24 %138 %137 +%137 = OpImageDrefGather %22 %136 %82 %73 +%138 = OpLoad %22 %58 +%139 = OpFAdd %22 %138 %137 OpStore %58 %139 %140 = OpAccessChain %129 %38 %78 -%141 = OpLoad %16 %140 +%141 = OpLoad %14 %140 %142 = OpAccessChain %132 %44 %78 -%143 = OpLoad %20 %142 +%143 = OpLoad %18 %142 %144 = OpSampledImage %135 %141 %143 -%145 = OpImageDrefGather %24 %144 %82 %73 -%146 = OpLoad %24 %58 -%147 = OpFAdd %24 %146 %145 +%145 = OpImageDrefGather %22 %144 %82 %73 +%146 = OpLoad %22 %58 +%147 = OpFAdd %22 %146 %145 OpStore %58 %147 %148 = OpAccessChain %129 %38 %79 -%149 = OpLoad %16 %148 +%149 = OpLoad %14 %148 %150 = OpAccessChain %132 %44 %79 -%151 = OpLoad %20 %150 +%151 = OpLoad %18 %150 %152 = OpSampledImage %135 %149 %151 -%153 = OpImageDrefGather %24 %152 %82 %73 -%154 = OpLoad %24 %58 -%155 = OpFAdd %24 %154 %153 +%153 = OpImageDrefGather %22 %152 %82 %73 +%154 = OpLoad %22 %58 +%155 = OpFAdd %22 %154 %153 OpStore %58 %155 %156 = OpAccessChain %84 %28 %71 -%157 = OpLoad %7 %156 -%160 = OpImageQueryLevels %4 %157 +%157 = OpLoad %5 %156 +%160 = OpImageQueryLevels %26 %157 %161 = OpULessThan %158 %74 %160 OpSelectionMerge %162 None OpBranchConditional %161 %163 %162 %163 = OpLabel -%164 = OpImageQuerySizeLod %27 %157 %74 +%164 = OpImageQuerySizeLod %25 %157 %74 %166 = OpULessThan %165 %83 %164 %167 = OpAll %158 %166 OpBranchConditional %167 %168 %162 %168 = OpLabel -%169 = OpImageFetch %24 %157 %83 Lod %74 +%169 = OpImageFetch %22 %157 %83 Lod %74 OpBranch %162 %162 = OpLabel -%170 = OpPhi %24 %159 %75 %159 %163 %169 %168 -%171 = OpLoad %24 %58 -%172 = OpFAdd %24 %171 %170 +%170 = OpPhi %22 %159 %75 %159 %163 %169 %168 +%171 = OpLoad %22 %58 +%172 = OpFAdd %22 %171 %170 OpStore %58 %172 %173 = OpAccessChain %84 %28 %78 -%174 = OpLoad %7 %173 -%176 = OpImageQueryLevels %4 %174 +%174 = OpLoad %5 %173 +%176 = OpImageQueryLevels %26 %174 %177 = OpULessThan %158 %74 %176 OpSelectionMerge %178 None OpBranchConditional %177 %179 %178 %179 = OpLabel -%180 = OpImageQuerySizeLod %27 %174 %74 +%180 = OpImageQuerySizeLod %25 %174 %74 %181 = OpULessThan %165 %83 %180 %182 = OpAll %158 %181 OpBranchConditional %182 %183 %178 %183 = OpLabel -%184 = OpImageFetch %24 %174 %83 Lod %74 +%184 = OpImageFetch %22 %174 %83 Lod %74 OpBranch %178 %178 = OpLabel -%185 = OpPhi %24 %175 %162 %175 %179 %184 %183 -%186 = OpLoad %24 %58 -%187 = OpFAdd %24 %186 %185 +%185 = OpPhi %22 %175 %162 %175 %179 %184 %183 +%186 = OpLoad %22 %58 +%187 = OpFAdd %22 %186 %185 OpStore %58 %187 %188 = OpAccessChain %84 %28 %79 -%189 = OpLoad %7 %188 -%191 = OpImageQueryLevels %4 %189 +%189 = OpLoad %5 %188 +%191 = OpImageQueryLevels %26 %189 %192 = OpULessThan %158 %74 %191 OpSelectionMerge %193 None OpBranchConditional %192 %194 %193 %194 = OpLabel -%195 = OpImageQuerySizeLod %27 %189 %74 +%195 = OpImageQuerySizeLod %25 %189 %74 %196 = OpULessThan %165 %83 %195 %197 = OpAll %158 %196 OpBranchConditional %197 %198 %193 %198 = OpLabel -%199 = OpImageFetch %24 %189 %83 Lod %74 +%199 = OpImageFetch %22 %189 %83 Lod %74 OpBranch %193 %193 = OpLabel -%200 = OpPhi %24 %190 %178 %190 %194 %199 %198 -%201 = OpLoad %24 %58 -%202 = OpFAdd %24 %201 %200 +%200 = OpPhi %22 %190 %178 %190 %194 %199 %198 +%201 = OpLoad %22 %58 +%202 = OpFAdd %22 %201 %200 OpStore %58 %202 %204 = OpAccessChain %203 %34 %71 -%205 = OpLoad %12 %204 +%205 = OpLoad %10 %204 %207 = OpImageQuerySizeLod %206 %205 %71 -%208 = OpCompositeExtract %4 %207 2 -%209 = OpBitcast %5 %208 -%210 = OpLoad %5 %49 -%211 = OpIAdd %5 %210 %209 +%208 = OpCompositeExtract %26 %207 2 +%209 = OpBitcast %3 %208 +%210 = OpLoad %3 %49 +%211 = OpIAdd %3 %210 %209 OpStore %49 %211 %212 = OpAccessChain %203 %34 %78 -%213 = OpLoad %12 %212 +%213 = OpLoad %10 %212 %214 = OpImageQuerySizeLod %206 %213 %71 -%215 = OpCompositeExtract %4 %214 2 -%216 = OpBitcast %5 %215 -%217 = OpLoad %5 %49 -%218 = OpIAdd %5 %217 %216 +%215 = OpCompositeExtract %26 %214 2 +%216 = OpBitcast %3 %215 +%217 = OpLoad %3 %49 +%218 = OpIAdd %3 %217 %216 OpStore %49 %218 %219 = OpAccessChain %203 %34 %79 -%220 = OpLoad %12 %219 +%220 = OpLoad %10 %219 %221 = OpImageQuerySizeLod %206 %220 %71 -%222 = OpCompositeExtract %4 %221 2 -%223 = OpBitcast %5 %222 -%224 = OpLoad %5 %49 -%225 = OpIAdd %5 %224 %223 +%222 = OpCompositeExtract %26 %221 2 +%223 = OpBitcast %3 %222 +%224 = OpLoad %3 %49 +%225 = OpIAdd %3 %224 %223 OpStore %49 %225 %226 = OpAccessChain %84 %32 %71 -%227 = OpLoad %7 %226 -%228 = OpImageQueryLevels %4 %227 -%229 = OpBitcast %5 %228 -%230 = OpLoad %5 %49 -%231 = OpIAdd %5 %230 %229 +%227 = OpLoad %5 %226 +%228 = OpImageQueryLevels %26 %227 +%229 = OpBitcast %3 %228 +%230 = OpLoad %3 %49 +%231 = OpIAdd %3 %230 %229 OpStore %49 %231 %232 = OpAccessChain %84 %32 %78 -%233 = OpLoad %7 %232 -%234 = OpImageQueryLevels %4 %233 -%235 = OpBitcast %5 %234 -%236 = OpLoad %5 %49 -%237 = OpIAdd %5 %236 %235 +%233 = OpLoad %5 %232 +%234 = OpImageQueryLevels %26 %233 +%235 = OpBitcast %3 %234 +%236 = OpLoad %3 %49 +%237 = OpIAdd %3 %236 %235 OpStore %49 %237 %238 = OpAccessChain %84 %32 %79 -%239 = OpLoad %7 %238 -%240 = OpImageQueryLevels %4 %239 -%241 = OpBitcast %5 %240 -%242 = OpLoad %5 %49 -%243 = OpIAdd %5 %242 %241 +%239 = OpLoad %5 %238 +%240 = OpImageQueryLevels %26 %239 +%241 = OpBitcast %3 %240 +%242 = OpLoad %3 %49 +%243 = OpIAdd %3 %242 %241 OpStore %49 %243 %245 = OpAccessChain %244 %36 %71 -%246 = OpLoad %14 %245 -%247 = OpImageQuerySamples %4 %246 -%248 = OpBitcast %5 %247 -%249 = OpLoad %5 %49 -%250 = OpIAdd %5 %249 %248 +%246 = OpLoad %12 %245 +%247 = OpImageQuerySamples %26 %246 +%248 = OpBitcast %3 %247 +%249 = OpLoad %3 %49 +%250 = OpIAdd %3 %249 %248 OpStore %49 %250 %251 = OpAccessChain %244 %36 %78 -%252 = OpLoad %14 %251 -%253 = OpImageQuerySamples %4 %252 -%254 = OpBitcast %5 %253 -%255 = OpLoad %5 %49 -%256 = OpIAdd %5 %255 %254 +%252 = OpLoad %12 %251 +%253 = OpImageQuerySamples %26 %252 +%254 = OpBitcast %3 %253 +%255 = OpLoad %3 %49 +%256 = OpIAdd %3 %255 %254 OpStore %49 %256 %257 = OpAccessChain %244 %36 %79 -%258 = OpLoad %14 %257 -%259 = OpImageQuerySamples %4 %258 -%260 = OpBitcast %5 %259 -%261 = OpLoad %5 %49 -%262 = OpIAdd %5 %261 %260 +%258 = OpLoad %12 %257 +%259 = OpImageQuerySamples %26 %258 +%260 = OpBitcast %3 %259 +%261 = OpLoad %3 %49 +%262 = OpIAdd %3 %261 %260 OpStore %49 %262 %263 = OpAccessChain %84 %32 %71 -%264 = OpLoad %7 %263 +%264 = OpLoad %5 %263 %265 = OpAccessChain %105 %42 %71 -%266 = OpLoad %20 %265 +%266 = OpLoad %18 %265 %267 = OpSampledImage %108 %264 %266 -%268 = OpImageSampleImplicitLod %24 %267 %82 -%269 = OpLoad %24 %58 -%270 = OpFAdd %24 %269 %268 +%268 = OpImageSampleImplicitLod %22 %267 %82 +%269 = OpLoad %22 %58 +%270 = OpFAdd %22 %269 %268 OpStore %58 %270 %271 = OpAccessChain %84 %32 %78 -%272 = OpLoad %7 %271 +%272 = OpLoad %5 %271 %273 = OpAccessChain %105 %42 %78 -%274 = OpLoad %20 %273 +%274 = OpLoad %18 %273 %275 = OpSampledImage %108 %272 %274 -%276 = OpImageSampleImplicitLod %24 %275 %82 -%277 = OpLoad %24 %58 -%278 = OpFAdd %24 %277 %276 +%276 = OpImageSampleImplicitLod %22 %275 %82 +%277 = OpLoad %22 %58 +%278 = OpFAdd %22 %277 %276 OpStore %58 %278 %279 = OpAccessChain %84 %32 %79 -%280 = OpLoad %7 %279 +%280 = OpLoad %5 %279 %281 = OpAccessChain %105 %42 %79 -%282 = OpLoad %20 %281 +%282 = OpLoad %18 %281 %283 = OpSampledImage %108 %280 %282 -%284 = OpImageSampleImplicitLod %24 %283 %82 -%285 = OpLoad %24 %58 -%286 = OpFAdd %24 %285 %284 +%284 = OpImageSampleImplicitLod %22 %283 %82 +%285 = OpLoad %22 %58 +%286 = OpFAdd %22 %285 %284 OpStore %58 %286 %287 = OpAccessChain %84 %32 %71 -%288 = OpLoad %7 %287 +%288 = OpLoad %5 %287 %289 = OpAccessChain %105 %42 %71 -%290 = OpLoad %20 %289 +%290 = OpLoad %18 %289 %291 = OpSampledImage %108 %288 %290 -%292 = OpImageSampleImplicitLod %24 %291 %82 Bias %73 -%293 = OpLoad %24 %58 -%294 = OpFAdd %24 %293 %292 +%292 = OpImageSampleImplicitLod %22 %291 %82 Bias %73 +%293 = OpLoad %22 %58 +%294 = OpFAdd %22 %293 %292 OpStore %58 %294 %295 = OpAccessChain %84 %32 %78 -%296 = OpLoad %7 %295 +%296 = OpLoad %5 %295 %297 = OpAccessChain %105 %42 %78 -%298 = OpLoad %20 %297 +%298 = OpLoad %18 %297 %299 = OpSampledImage %108 %296 %298 -%300 = OpImageSampleImplicitLod %24 %299 %82 Bias %73 -%301 = OpLoad %24 %58 -%302 = OpFAdd %24 %301 %300 +%300 = OpImageSampleImplicitLod %22 %299 %82 Bias %73 +%301 = OpLoad %22 %58 +%302 = OpFAdd %22 %301 %300 OpStore %58 %302 %303 = OpAccessChain %84 %32 %79 -%304 = OpLoad %7 %303 +%304 = OpLoad %5 %303 %305 = OpAccessChain %105 %42 %79 -%306 = OpLoad %20 %305 +%306 = OpLoad %18 %305 %307 = OpSampledImage %108 %304 %306 -%308 = OpImageSampleImplicitLod %24 %307 %82 Bias %73 -%309 = OpLoad %24 %58 -%310 = OpFAdd %24 %309 %308 +%308 = OpImageSampleImplicitLod %22 %307 %82 Bias %73 +%309 = OpLoad %22 %58 +%310 = OpFAdd %22 %309 %308 OpStore %58 %310 %311 = OpAccessChain %129 %38 %71 -%312 = OpLoad %16 %311 +%312 = OpLoad %14 %311 %313 = OpAccessChain %132 %44 %71 -%314 = OpLoad %20 %313 +%314 = OpLoad %18 %313 %315 = OpSampledImage %135 %312 %314 -%316 = OpImageSampleDrefImplicitLod %8 %315 %82 %73 -%317 = OpLoad %8 %55 -%318 = OpFAdd %8 %317 %316 +%316 = OpImageSampleDrefImplicitLod %6 %315 %82 %73 +%317 = OpLoad %6 %55 +%318 = OpFAdd %6 %317 %316 OpStore %55 %318 %319 = OpAccessChain %129 %38 %78 -%320 = OpLoad %16 %319 +%320 = OpLoad %14 %319 %321 = OpAccessChain %132 %44 %78 -%322 = OpLoad %20 %321 +%322 = OpLoad %18 %321 %323 = OpSampledImage %135 %320 %322 -%324 = OpImageSampleDrefImplicitLod %8 %323 %82 %73 -%325 = OpLoad %8 %55 -%326 = OpFAdd %8 %325 %324 +%324 = OpImageSampleDrefImplicitLod %6 %323 %82 %73 +%325 = OpLoad %6 %55 +%326 = OpFAdd %6 %325 %324 OpStore %55 %326 %327 = OpAccessChain %129 %38 %79 -%328 = OpLoad %16 %327 +%328 = OpLoad %14 %327 %329 = OpAccessChain %132 %44 %79 -%330 = OpLoad %20 %329 +%330 = OpLoad %18 %329 %331 = OpSampledImage %135 %328 %330 -%332 = OpImageSampleDrefImplicitLod %8 %331 %82 %73 -%333 = OpLoad %8 %55 -%334 = OpFAdd %8 %333 %332 +%332 = OpImageSampleDrefImplicitLod %6 %331 %82 %73 +%333 = OpLoad %6 %55 +%334 = OpFAdd %6 %333 %332 OpStore %55 %334 %335 = OpAccessChain %129 %38 %71 -%336 = OpLoad %16 %335 +%336 = OpLoad %14 %335 %337 = OpAccessChain %132 %44 %71 -%338 = OpLoad %20 %337 +%338 = OpLoad %18 %337 %339 = OpSampledImage %135 %336 %338 -%340 = OpImageSampleDrefExplicitLod %8 %339 %82 %73 Lod %73 -%341 = OpLoad %8 %55 -%342 = OpFAdd %8 %341 %340 +%340 = OpImageSampleDrefExplicitLod %6 %339 %82 %73 Lod %73 +%341 = OpLoad %6 %55 +%342 = OpFAdd %6 %341 %340 OpStore %55 %342 %343 = OpAccessChain %129 %38 %78 -%344 = OpLoad %16 %343 +%344 = OpLoad %14 %343 %345 = OpAccessChain %132 %44 %78 -%346 = OpLoad %20 %345 +%346 = OpLoad %18 %345 %347 = OpSampledImage %135 %344 %346 -%348 = OpImageSampleDrefExplicitLod %8 %347 %82 %73 Lod %73 -%349 = OpLoad %8 %55 -%350 = OpFAdd %8 %349 %348 +%348 = OpImageSampleDrefExplicitLod %6 %347 %82 %73 Lod %73 +%349 = OpLoad %6 %55 +%350 = OpFAdd %6 %349 %348 OpStore %55 %350 %351 = OpAccessChain %129 %38 %79 -%352 = OpLoad %16 %351 +%352 = OpLoad %14 %351 %353 = OpAccessChain %132 %44 %79 -%354 = OpLoad %20 %353 +%354 = OpLoad %18 %353 %355 = OpSampledImage %135 %352 %354 -%356 = OpImageSampleDrefExplicitLod %8 %355 %82 %73 Lod %73 -%357 = OpLoad %8 %55 -%358 = OpFAdd %8 %357 %356 +%356 = OpImageSampleDrefExplicitLod %6 %355 %82 %73 Lod %73 +%357 = OpLoad %6 %55 +%358 = OpFAdd %6 %357 %356 OpStore %55 %358 %359 = OpAccessChain %84 %32 %71 -%360 = OpLoad %7 %359 +%360 = OpLoad %5 %359 %361 = OpAccessChain %105 %42 %71 -%362 = OpLoad %20 %361 +%362 = OpLoad %18 %361 %363 = OpSampledImage %108 %360 %362 -%364 = OpImageSampleExplicitLod %24 %363 %82 Grad %82 %82 -%365 = OpLoad %24 %58 -%366 = OpFAdd %24 %365 %364 +%364 = OpImageSampleExplicitLod %22 %363 %82 Grad %82 %82 +%365 = OpLoad %22 %58 +%366 = OpFAdd %22 %365 %364 OpStore %58 %366 %367 = OpAccessChain %84 %32 %78 -%368 = OpLoad %7 %367 +%368 = OpLoad %5 %367 %369 = OpAccessChain %105 %42 %78 -%370 = OpLoad %20 %369 +%370 = OpLoad %18 %369 %371 = OpSampledImage %108 %368 %370 -%372 = OpImageSampleExplicitLod %24 %371 %82 Grad %82 %82 -%373 = OpLoad %24 %58 -%374 = OpFAdd %24 %373 %372 +%372 = OpImageSampleExplicitLod %22 %371 %82 Grad %82 %82 +%373 = OpLoad %22 %58 +%374 = OpFAdd %22 %373 %372 OpStore %58 %374 %375 = OpAccessChain %84 %32 %79 -%376 = OpLoad %7 %375 +%376 = OpLoad %5 %375 %377 = OpAccessChain %105 %42 %79 -%378 = OpLoad %20 %377 +%378 = OpLoad %18 %377 %379 = OpSampledImage %108 %376 %378 -%380 = OpImageSampleExplicitLod %24 %379 %82 Grad %82 %82 -%381 = OpLoad %24 %58 -%382 = OpFAdd %24 %381 %380 +%380 = OpImageSampleExplicitLod %22 %379 %82 Grad %82 %82 +%381 = OpLoad %22 %58 +%382 = OpFAdd %22 %381 %380 OpStore %58 %382 %383 = OpAccessChain %84 %32 %71 -%384 = OpLoad %7 %383 +%384 = OpLoad %5 %383 %385 = OpAccessChain %105 %42 %71 -%386 = OpLoad %20 %385 +%386 = OpLoad %18 %385 %387 = OpSampledImage %108 %384 %386 -%388 = OpImageSampleExplicitLod %24 %387 %82 Lod %73 -%389 = OpLoad %24 %58 -%390 = OpFAdd %24 %389 %388 +%388 = OpImageSampleExplicitLod %22 %387 %82 Lod %73 +%389 = OpLoad %22 %58 +%390 = OpFAdd %22 %389 %388 OpStore %58 %390 %391 = OpAccessChain %84 %32 %78 -%392 = OpLoad %7 %391 +%392 = OpLoad %5 %391 %393 = OpAccessChain %105 %42 %78 -%394 = OpLoad %20 %393 +%394 = OpLoad %18 %393 %395 = OpSampledImage %108 %392 %394 -%396 = OpImageSampleExplicitLod %24 %395 %82 Lod %73 -%397 = OpLoad %24 %58 -%398 = OpFAdd %24 %397 %396 +%396 = OpImageSampleExplicitLod %22 %395 %82 Lod %73 +%397 = OpLoad %22 %58 +%398 = OpFAdd %22 %397 %396 OpStore %58 %398 %399 = OpAccessChain %84 %32 %79 -%400 = OpLoad %7 %399 +%400 = OpLoad %5 %399 %401 = OpAccessChain %105 %42 %79 -%402 = OpLoad %20 %401 +%402 = OpLoad %18 %401 %403 = OpSampledImage %108 %400 %402 -%404 = OpImageSampleExplicitLod %24 %403 %82 Lod %73 -%405 = OpLoad %24 %58 -%406 = OpFAdd %24 %405 %404 +%404 = OpImageSampleExplicitLod %22 %403 %82 Lod %73 +%405 = OpLoad %22 %58 +%406 = OpFAdd %22 %405 %404 OpStore %58 %406 %408 = OpAccessChain %407 %40 %71 -%409 = OpLoad %18 %408 -%410 = OpLoad %24 %58 -%411 = OpImageQuerySize %27 %409 +%409 = OpLoad %16 %408 +%410 = OpLoad %22 %58 +%411 = OpImageQuerySize %25 %409 %412 = OpULessThan %165 %83 %411 %413 = OpAll %158 %412 OpSelectionMerge %414 None @@ -532,9 +532,9 @@ OpImageWrite %409 %83 %410 OpBranch %414 %414 = OpLabel %416 = OpAccessChain %407 %40 %78 -%417 = OpLoad %18 %416 -%418 = OpLoad %24 %58 -%419 = OpImageQuerySize %27 %417 +%417 = OpLoad %16 %416 +%418 = OpLoad %22 %58 +%419 = OpImageQuerySize %25 %417 %420 = OpULessThan %165 %83 %419 %421 = OpAll %158 %420 OpSelectionMerge %422 None @@ -544,9 +544,9 @@ OpImageWrite %417 %83 %418 OpBranch %422 %422 = OpLabel %424 = OpAccessChain %407 %40 %79 -%425 = OpLoad %18 %424 -%426 = OpLoad %24 %58 -%427 = OpImageQuerySize %27 %425 +%425 = OpLoad %16 %424 +%426 = OpLoad %22 %58 +%427 = OpImageQuerySize %25 %425 %428 = OpULessThan %165 %83 %427 %429 = OpAll %158 %428 OpSelectionMerge %430 None @@ -555,21 +555,21 @@ OpBranchConditional %429 %431 %430 OpImageWrite %425 %83 %426 OpBranch %430 %430 = OpLabel -%432 = OpLoad %25 %52 -%433 = OpLoad %5 %49 -%434 = OpCompositeConstruct %25 %433 %433 -%435 = OpIAdd %25 %432 %434 -%436 = OpConvertUToF %26 %435 -%437 = OpLoad %24 %58 -%438 = OpCompositeExtract %8 %436 0 -%439 = OpCompositeExtract %8 %436 1 -%440 = OpCompositeExtract %8 %436 0 -%441 = OpCompositeExtract %8 %436 1 -%442 = OpCompositeConstruct %24 %438 %439 %440 %441 -%443 = OpFAdd %24 %437 %442 -%444 = OpLoad %8 %55 -%445 = OpCompositeConstruct %24 %444 %444 %444 %444 -%446 = OpFAdd %24 %443 %445 +%432 = OpLoad %23 %52 +%433 = OpLoad %3 %49 +%434 = OpCompositeConstruct %23 %433 %433 +%435 = OpIAdd %23 %432 %434 +%436 = OpConvertUToF %24 %435 +%437 = OpLoad %22 %58 +%438 = OpCompositeExtract %6 %436 0 +%439 = OpCompositeExtract %6 %436 1 +%440 = OpCompositeExtract %6 %436 0 +%441 = OpCompositeExtract %6 %436 1 +%442 = OpCompositeConstruct %22 %438 %439 %440 %441 +%443 = OpFAdd %22 %437 %442 +%444 = OpLoad %6 %55 +%445 = OpCompositeConstruct %22 %444 %444 %444 %444 +%446 = OpFAdd %22 %443 %445 OpStore %66 %446 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 b09377b6b0..83a676a9ef 100644 --- a/tests/out/spv/binding-buffer-arrays.spvasm +++ b/tests/out/spv/binding-buffer-arrays.spvasm @@ -10,13 +10,13 @@ OpExtension "SPV_EXT_descriptor_indexing" OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %28 "main" %23 %26 OpExecutionMode %28 OriginUpperLeft -OpMemberDecorate %6 0 Offset 0 -OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %4 0 Offset 0 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %8 0 Offset 0 OpDecorate %11 NonWritable OpDecorate %11 DescriptorSet 0 OpDecorate %11 Binding 0 -OpDecorate %7 Block +OpDecorate %5 Block OpDecorate %15 DescriptorSet 0 OpDecorate %15 Binding 10 OpDecorate %16 Block @@ -26,79 +26,79 @@ OpDecorate %23 Flat OpDecorate %26 Location 0 OpDecorate %56 NonUniform %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 1 -%5 = OpTypeInt 32 0 -%6 = OpTypeStruct %5 -%7 = OpTypeStruct %5 -%9 = OpConstant %5 1 -%8 = OpTypeArray %7 %9 -%10 = OpTypeStruct %5 -%14 = OpConstant %5 10 -%13 = OpTypeArray %7 %14 +%3 = OpTypeInt 32 0 +%4 = OpTypeStruct %3 +%5 = OpTypeStruct %3 +%7 = OpConstant %3 1 +%6 = OpTypeArray %5 %7 +%8 = OpTypeStruct %3 +%10 = OpTypeInt 32 1 +%9 = OpConstant %10 1 +%14 = OpConstant %3 10 +%13 = OpTypeArray %5 %14 %12 = OpTypePointer StorageBuffer %13 %11 = OpVariable %12 StorageBuffer -%16 = OpTypeStruct %6 +%16 = OpTypeStruct %4 %17 = OpTypePointer Uniform %16 %15 = OpVariable %17 Uniform -%19 = OpTypePointer Function %5 -%20 = OpConstantNull %5 -%24 = OpTypePointer Input %5 +%19 = OpTypePointer Function %3 +%20 = OpConstantNull %3 +%24 = OpTypePointer Input %3 %23 = OpVariable %24 Input -%27 = OpTypePointer Output %5 +%27 = OpTypePointer Output %3 %26 = OpVariable %27 Output %29 = OpTypeFunction %2 -%30 = OpTypePointer Uniform %6 -%31 = OpConstant %5 0 -%33 = OpTypePointer StorageBuffer %8 -%35 = OpTypePointer Uniform %5 -%39 = OpTypePointer StorageBuffer %7 -%40 = OpTypePointer StorageBuffer %5 +%30 = OpTypePointer Uniform %4 +%31 = OpConstant %3 0 +%33 = OpTypePointer StorageBuffer %6 +%35 = OpTypePointer Uniform %3 +%39 = OpTypePointer StorageBuffer %5 +%40 = OpTypePointer StorageBuffer %3 %46 = OpTypeBool -%48 = OpConstantNull %5 -%57 = OpConstantNull %5 +%48 = OpConstantNull %3 +%57 = OpConstantNull %3 %28 = OpFunction %2 None %29 %21 = OpLabel %18 = OpVariable %19 Function %20 -%25 = OpLoad %5 %23 -%22 = OpCompositeConstruct %10 %25 +%25 = OpLoad %3 %23 +%22 = OpCompositeConstruct %8 %25 %32 = OpAccessChain %30 %15 %31 OpBranch %34 %34 = OpLabel %36 = OpAccessChain %35 %32 %31 -%37 = OpLoad %5 %36 -%38 = OpCompositeExtract %5 %22 0 +%37 = OpLoad %3 %36 +%38 = OpCompositeExtract %3 %22 0 OpStore %18 %31 %41 = OpAccessChain %40 %11 %31 %31 -%42 = OpLoad %5 %41 -%43 = OpLoad %5 %18 -%44 = OpIAdd %5 %43 %42 +%42 = OpLoad %3 %41 +%43 = OpLoad %3 %18 +%44 = OpIAdd %3 %43 %42 OpStore %18 %44 -%45 = OpULessThan %46 %37 %9 +%45 = OpULessThan %46 %37 %7 OpSelectionMerge %49 None OpBranchConditional %45 %50 %49 %50 = OpLabel %47 = OpAccessChain %40 %11 %37 %31 -%51 = OpLoad %5 %47 +%51 = OpLoad %3 %47 OpBranch %49 %49 = OpLabel -%52 = OpPhi %5 %48 %34 %51 %50 -%53 = OpLoad %5 %18 -%54 = OpIAdd %5 %53 %52 +%52 = OpPhi %3 %48 %34 %51 %50 +%53 = OpLoad %3 %18 +%54 = OpIAdd %3 %53 %52 OpStore %18 %54 -%55 = OpULessThan %46 %38 %9 +%55 = OpULessThan %46 %38 %7 OpSelectionMerge %58 None OpBranchConditional %55 %59 %58 %59 = OpLabel %56 = OpAccessChain %40 %11 %38 %31 -%60 = OpLoad %5 %56 +%60 = OpLoad %3 %56 OpBranch %58 %58 = OpLabel -%61 = OpPhi %5 %57 %49 %60 %59 -%62 = OpLoad %5 %18 -%63 = OpIAdd %5 %62 %61 +%61 = OpPhi %3 %57 %49 %60 %59 +%62 = OpLoad %3 %18 +%63 = OpIAdd %3 %62 %61 OpStore %18 %63 -%64 = OpLoad %5 %18 +%64 = OpLoad %3 %18 OpStore %26 %64 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/boids.spvasm b/tests/out/spv/boids.spvasm index 4b19d9b4fc..30e77fdcd4 100644 --- a/tests/out/spv/boids.spvasm +++ b/tests/out/spv/boids.spvasm @@ -8,20 +8,20 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %46 "main" %43 OpExecutionMode %46 LocalSize 64 1 1 -OpName %3 "NUM_PARTICLES" -OpMemberName %7 0 "pos" -OpMemberName %7 1 "vel" -OpName %7 "Particle" -OpMemberName %8 0 "deltaT" -OpMemberName %8 1 "rule1Distance" -OpMemberName %8 2 "rule2Distance" -OpMemberName %8 3 "rule3Distance" -OpMemberName %8 4 "rule1Scale" -OpMemberName %8 5 "rule2Scale" -OpMemberName %8 6 "rule3Scale" -OpName %8 "SimParams" -OpMemberName %10 0 "particles" -OpName %10 "Particles" +OpMemberName %6 0 "pos" +OpMemberName %6 1 "vel" +OpName %6 "Particle" +OpMemberName %7 0 "deltaT" +OpMemberName %7 1 "rule1Distance" +OpMemberName %7 2 "rule2Distance" +OpMemberName %7 3 "rule3Distance" +OpMemberName %7 4 "rule1Scale" +OpMemberName %7 5 "rule2Scale" +OpMemberName %7 6 "rule3Scale" +OpName %7 "SimParams" +OpMemberName %9 0 "particles" +OpName %9 "Particles" +OpName %12 "NUM_PARTICLES" OpName %13 "params" OpName %16 "particlesSrc" OpName %18 "particlesDst" @@ -37,17 +37,17 @@ OpName %37 "vel" OpName %39 "i" OpName %43 "global_invocation_id" OpName %46 "main" +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 8 OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 8 -OpMemberDecorate %8 0 Offset 0 -OpMemberDecorate %8 1 Offset 4 -OpMemberDecorate %8 2 Offset 8 -OpMemberDecorate %8 3 Offset 12 -OpMemberDecorate %8 4 Offset 16 -OpMemberDecorate %8 5 Offset 20 -OpMemberDecorate %8 6 Offset 24 -OpDecorate %9 ArrayStride 16 -OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpMemberDecorate %7 2 Offset 8 +OpMemberDecorate %7 3 Offset 12 +OpMemberDecorate %7 4 Offset 16 +OpMemberDecorate %7 5 Offset 20 +OpMemberDecorate %7 6 Offset 24 +OpDecorate %8 ArrayStride 16 +OpMemberDecorate %9 0 Offset 0 OpDecorate %13 DescriptorSet 0 OpDecorate %13 Binding 0 OpDecorate %14 Block @@ -55,64 +55,64 @@ OpMemberDecorate %14 0 Offset 0 OpDecorate %16 NonWritable OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 1 -OpDecorate %10 Block +OpDecorate %9 Block OpDecorate %18 DescriptorSet 0 OpDecorate %18 Binding 2 -OpDecorate %10 Block +OpDecorate %9 Block OpDecorate %43 BuiltIn GlobalInvocationId %2 = OpTypeVoid -%4 = OpTypeInt 32 0 -%3 = OpConstant %4 1500 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 2 -%7 = OpTypeStruct %5 %5 -%8 = OpTypeStruct %6 %6 %6 %6 %6 %6 %6 -%9 = OpTypeRuntimeArray %7 -%10 = OpTypeStruct %9 -%11 = OpTypeVector %4 3 -%12 = OpTypeInt 32 1 -%14 = OpTypeStruct %8 +%3 = OpTypeInt 32 0 +%5 = OpTypeFloat 32 +%4 = OpTypeVector %5 2 +%6 = OpTypeStruct %4 %4 +%7 = OpTypeStruct %5 %5 %5 %5 %5 %5 %5 +%8 = OpTypeRuntimeArray %6 +%9 = OpTypeStruct %8 +%10 = OpTypeVector %3 3 +%11 = OpTypeInt 32 1 +%12 = OpConstant %3 1500 +%14 = OpTypeStruct %7 %15 = OpTypePointer Uniform %14 %13 = OpVariable %15 Uniform -%17 = OpTypePointer StorageBuffer %10 +%17 = OpTypePointer StorageBuffer %9 %16 = OpVariable %17 StorageBuffer %18 = OpVariable %17 StorageBuffer -%20 = OpTypePointer Function %5 -%21 = OpConstantNull %5 -%23 = OpConstantNull %5 -%25 = OpConstantNull %5 -%27 = OpConstantNull %5 -%29 = OpConstantNull %5 -%31 = OpTypePointer Function %12 -%32 = OpConstantNull %12 -%34 = OpConstantNull %12 -%36 = OpConstantNull %5 -%38 = OpConstantNull %5 -%40 = OpTypePointer Function %4 -%41 = OpConstantNull %4 -%44 = OpTypePointer Input %11 +%20 = OpTypePointer Function %4 +%21 = OpConstantNull %4 +%23 = OpConstantNull %4 +%25 = OpConstantNull %4 +%27 = OpConstantNull %4 +%29 = OpConstantNull %4 +%31 = OpTypePointer Function %11 +%32 = OpConstantNull %11 +%34 = OpConstantNull %11 +%36 = OpConstantNull %4 +%38 = OpConstantNull %4 +%40 = OpTypePointer Function %3 +%41 = OpConstantNull %3 +%44 = OpTypePointer Input %10 %43 = OpVariable %44 Input %47 = OpTypeFunction %2 -%48 = OpTypePointer Uniform %8 -%49 = OpConstant %4 0 -%51 = OpConstant %6 0.0 -%52 = OpConstant %12 0 -%53 = OpConstant %12 1 -%54 = OpConstant %4 1 -%55 = OpConstant %6 0.1 -%56 = OpConstant %6 -1.0 -%57 = OpConstant %6 1.0 +%48 = OpTypePointer Uniform %7 +%49 = OpConstant %3 0 +%51 = OpConstant %5 0.0 +%52 = OpConstant %11 0 +%53 = OpConstant %11 1 +%54 = OpConstant %3 1 +%55 = OpConstant %5 0.1 +%56 = OpConstant %5 -1.0 +%57 = OpConstant %5 1.0 %60 = OpTypeBool -%64 = OpTypePointer StorageBuffer %9 -%65 = OpTypePointer StorageBuffer %7 -%66 = OpTypePointer StorageBuffer %5 -%95 = OpTypePointer Uniform %6 -%109 = OpConstant %4 2 -%123 = OpConstant %4 3 -%158 = OpConstant %4 4 -%164 = OpConstant %4 5 -%170 = OpConstant %4 6 -%187 = OpTypePointer Function %6 +%64 = OpTypePointer StorageBuffer %8 +%65 = OpTypePointer StorageBuffer %6 +%66 = OpTypePointer StorageBuffer %4 +%95 = OpTypePointer Uniform %5 +%109 = OpConstant %3 2 +%123 = OpConstant %3 3 +%158 = OpConstant %3 4 +%164 = OpConstant %3 5 +%170 = OpConstant %3 6 +%187 = OpTypePointer Function %5 %46 = OpFunction %2 None %47 %42 = OpLabel %39 = OpVariable %40 Function %41 @@ -125,28 +125,28 @@ OpDecorate %43 BuiltIn GlobalInvocationId %37 = OpVariable %20 Function %38 %30 = OpVariable %31 Function %32 %24 = OpVariable %20 Function %25 -%45 = OpLoad %11 %43 +%45 = OpLoad %10 %43 %50 = OpAccessChain %48 %13 %49 OpBranch %58 %58 = OpLabel -%59 = OpCompositeExtract %4 %45 0 -%61 = OpUGreaterThanEqual %60 %59 %3 +%59 = OpCompositeExtract %3 %45 0 +%61 = OpUGreaterThanEqual %60 %59 %12 OpSelectionMerge %62 None OpBranchConditional %61 %63 %62 %63 = OpLabel OpReturn %62 = OpLabel %67 = OpAccessChain %66 %16 %49 %59 %49 -%68 = OpLoad %5 %67 +%68 = OpLoad %4 %67 OpStore %19 %68 %69 = OpAccessChain %66 %16 %49 %59 %54 -%70 = OpLoad %5 %69 +%70 = OpLoad %4 %69 OpStore %22 %70 -%71 = OpCompositeConstruct %5 %51 %51 +%71 = OpCompositeConstruct %4 %51 %51 OpStore %24 %71 -%72 = OpCompositeConstruct %5 %51 %51 +%72 = OpCompositeConstruct %4 %51 %51 OpStore %26 %72 -%73 = OpCompositeConstruct %5 %51 %51 +%73 = OpCompositeConstruct %4 %51 %51 OpStore %28 %73 OpStore %30 %52 OpStore %33 %52 @@ -156,149 +156,149 @@ OpBranch %74 OpLoopMerge %75 %77 None OpBranch %76 %76 = OpLabel -%78 = OpLoad %4 %39 -%79 = OpUGreaterThanEqual %60 %78 %3 +%78 = OpLoad %3 %39 +%79 = OpUGreaterThanEqual %60 %78 %12 OpSelectionMerge %80 None OpBranchConditional %79 %81 %80 %81 = OpLabel OpBranch %75 %80 = OpLabel -%82 = OpLoad %4 %39 +%82 = OpLoad %3 %39 %83 = OpIEqual %60 %82 %59 OpSelectionMerge %84 None OpBranchConditional %83 %85 %84 %85 = OpLabel OpBranch %77 %84 = OpLabel -%86 = OpLoad %4 %39 +%86 = OpLoad %3 %39 %87 = OpAccessChain %66 %16 %49 %86 %49 -%88 = OpLoad %5 %87 +%88 = OpLoad %4 %87 OpStore %35 %88 -%89 = OpLoad %4 %39 +%89 = OpLoad %3 %39 %90 = OpAccessChain %66 %16 %49 %89 %54 -%91 = OpLoad %5 %90 +%91 = OpLoad %4 %90 OpStore %37 %91 -%92 = OpLoad %5 %35 -%93 = OpLoad %5 %19 -%94 = OpExtInst %6 %1 Distance %92 %93 +%92 = OpLoad %4 %35 +%93 = OpLoad %4 %19 +%94 = OpExtInst %5 %1 Distance %92 %93 %96 = OpAccessChain %95 %50 %54 -%97 = OpLoad %6 %96 +%97 = OpLoad %5 %96 %98 = OpFOrdLessThan %60 %94 %97 OpSelectionMerge %99 None OpBranchConditional %98 %100 %99 %100 = OpLabel -%101 = OpLoad %5 %24 -%102 = OpLoad %5 %35 -%103 = OpFAdd %5 %101 %102 +%101 = OpLoad %4 %24 +%102 = OpLoad %4 %35 +%103 = OpFAdd %4 %101 %102 OpStore %24 %103 -%104 = OpLoad %12 %30 -%105 = OpIAdd %12 %104 %53 +%104 = OpLoad %11 %30 +%105 = OpIAdd %11 %104 %53 OpStore %30 %105 OpBranch %99 %99 = OpLabel -%106 = OpLoad %5 %35 -%107 = OpLoad %5 %19 -%108 = OpExtInst %6 %1 Distance %106 %107 +%106 = OpLoad %4 %35 +%107 = OpLoad %4 %19 +%108 = OpExtInst %5 %1 Distance %106 %107 %110 = OpAccessChain %95 %50 %109 -%111 = OpLoad %6 %110 +%111 = OpLoad %5 %110 %112 = OpFOrdLessThan %60 %108 %111 OpSelectionMerge %113 None OpBranchConditional %112 %114 %113 %114 = OpLabel -%115 = OpLoad %5 %28 -%116 = OpLoad %5 %35 -%117 = OpLoad %5 %19 -%118 = OpFSub %5 %116 %117 -%119 = OpFSub %5 %115 %118 +%115 = OpLoad %4 %28 +%116 = OpLoad %4 %35 +%117 = OpLoad %4 %19 +%118 = OpFSub %4 %116 %117 +%119 = OpFSub %4 %115 %118 OpStore %28 %119 OpBranch %113 %113 = OpLabel -%120 = OpLoad %5 %35 -%121 = OpLoad %5 %19 -%122 = OpExtInst %6 %1 Distance %120 %121 +%120 = OpLoad %4 %35 +%121 = OpLoad %4 %19 +%122 = OpExtInst %5 %1 Distance %120 %121 %124 = OpAccessChain %95 %50 %123 -%125 = OpLoad %6 %124 +%125 = OpLoad %5 %124 %126 = OpFOrdLessThan %60 %122 %125 OpSelectionMerge %127 None OpBranchConditional %126 %128 %127 %128 = OpLabel -%129 = OpLoad %5 %26 -%130 = OpLoad %5 %37 -%131 = OpFAdd %5 %129 %130 +%129 = OpLoad %4 %26 +%130 = OpLoad %4 %37 +%131 = OpFAdd %4 %129 %130 OpStore %26 %131 -%132 = OpLoad %12 %33 -%133 = OpIAdd %12 %132 %53 +%132 = OpLoad %11 %33 +%133 = OpIAdd %11 %132 %53 OpStore %33 %133 OpBranch %127 %127 = OpLabel OpBranch %77 %77 = OpLabel -%134 = OpLoad %4 %39 -%135 = OpIAdd %4 %134 %54 +%134 = OpLoad %3 %39 +%135 = OpIAdd %3 %134 %54 OpStore %39 %135 OpBranch %74 %75 = OpLabel -%136 = OpLoad %12 %30 +%136 = OpLoad %11 %30 %137 = OpSGreaterThan %60 %136 %52 OpSelectionMerge %138 None OpBranchConditional %137 %139 %138 %139 = OpLabel -%140 = OpLoad %5 %24 -%141 = OpLoad %12 %30 -%142 = OpConvertSToF %6 %141 -%143 = OpCompositeConstruct %5 %142 %142 -%144 = OpFDiv %5 %140 %143 -%145 = OpLoad %5 %19 -%146 = OpFSub %5 %144 %145 +%140 = OpLoad %4 %24 +%141 = OpLoad %11 %30 +%142 = OpConvertSToF %5 %141 +%143 = OpCompositeConstruct %4 %142 %142 +%144 = OpFDiv %4 %140 %143 +%145 = OpLoad %4 %19 +%146 = OpFSub %4 %144 %145 OpStore %24 %146 OpBranch %138 %138 = OpLabel -%147 = OpLoad %12 %33 +%147 = OpLoad %11 %33 %148 = OpSGreaterThan %60 %147 %52 OpSelectionMerge %149 None OpBranchConditional %148 %150 %149 %150 = OpLabel -%151 = OpLoad %5 %26 -%152 = OpLoad %12 %33 -%153 = OpConvertSToF %6 %152 -%154 = OpCompositeConstruct %5 %153 %153 -%155 = OpFDiv %5 %151 %154 +%151 = OpLoad %4 %26 +%152 = OpLoad %11 %33 +%153 = OpConvertSToF %5 %152 +%154 = OpCompositeConstruct %4 %153 %153 +%155 = OpFDiv %4 %151 %154 OpStore %26 %155 OpBranch %149 %149 = OpLabel -%156 = OpLoad %5 %22 -%157 = OpLoad %5 %24 +%156 = OpLoad %4 %22 +%157 = OpLoad %4 %24 %159 = OpAccessChain %95 %50 %158 -%160 = OpLoad %6 %159 -%161 = OpVectorTimesScalar %5 %157 %160 -%162 = OpFAdd %5 %156 %161 -%163 = OpLoad %5 %28 +%160 = OpLoad %5 %159 +%161 = OpVectorTimesScalar %4 %157 %160 +%162 = OpFAdd %4 %156 %161 +%163 = OpLoad %4 %28 %165 = OpAccessChain %95 %50 %164 -%166 = OpLoad %6 %165 -%167 = OpVectorTimesScalar %5 %163 %166 -%168 = OpFAdd %5 %162 %167 -%169 = OpLoad %5 %26 +%166 = OpLoad %5 %165 +%167 = OpVectorTimesScalar %4 %163 %166 +%168 = OpFAdd %4 %162 %167 +%169 = OpLoad %4 %26 %171 = OpAccessChain %95 %50 %170 -%172 = OpLoad %6 %171 -%173 = OpVectorTimesScalar %5 %169 %172 -%174 = OpFAdd %5 %168 %173 +%172 = OpLoad %5 %171 +%173 = OpVectorTimesScalar %4 %169 %172 +%174 = OpFAdd %4 %168 %173 OpStore %22 %174 -%175 = OpLoad %5 %22 -%176 = OpExtInst %5 %1 Normalize %175 -%177 = OpLoad %5 %22 -%178 = OpExtInst %6 %1 Length %177 -%179 = OpExtInst %6 %1 FClamp %178 %51 %55 -%180 = OpVectorTimesScalar %5 %176 %179 +%175 = OpLoad %4 %22 +%176 = OpExtInst %4 %1 Normalize %175 +%177 = OpLoad %4 %22 +%178 = OpExtInst %5 %1 Length %177 +%179 = OpExtInst %5 %1 FClamp %178 %51 %55 +%180 = OpVectorTimesScalar %4 %176 %179 OpStore %22 %180 -%181 = OpLoad %5 %19 -%182 = OpLoad %5 %22 +%181 = OpLoad %4 %19 +%182 = OpLoad %4 %22 %183 = OpAccessChain %95 %50 %49 -%184 = OpLoad %6 %183 -%185 = OpVectorTimesScalar %5 %182 %184 -%186 = OpFAdd %5 %181 %185 +%184 = OpLoad %5 %183 +%185 = OpVectorTimesScalar %4 %182 %184 +%186 = OpFAdd %4 %181 %185 OpStore %19 %186 %188 = OpAccessChain %187 %19 %49 -%189 = OpLoad %6 %188 +%189 = OpLoad %5 %188 %190 = OpFOrdLessThan %60 %189 %56 OpSelectionMerge %191 None OpBranchConditional %190 %192 %191 @@ -308,7 +308,7 @@ OpStore %193 %57 OpBranch %191 %191 = OpLabel %194 = OpAccessChain %187 %19 %49 -%195 = OpLoad %6 %194 +%195 = OpLoad %5 %194 %196 = OpFOrdGreaterThan %60 %195 %57 OpSelectionMerge %197 None OpBranchConditional %196 %198 %197 @@ -318,7 +318,7 @@ OpStore %199 %56 OpBranch %197 %197 = OpLabel %200 = OpAccessChain %187 %19 %54 -%201 = OpLoad %6 %200 +%201 = OpLoad %5 %200 %202 = OpFOrdLessThan %60 %201 %56 OpSelectionMerge %203 None OpBranchConditional %202 %204 %203 @@ -328,7 +328,7 @@ OpStore %205 %57 OpBranch %203 %203 = OpLabel %206 = OpAccessChain %187 %19 %54 -%207 = OpLoad %6 %206 +%207 = OpLoad %5 %206 %208 = OpFOrdGreaterThan %60 %207 %57 OpSelectionMerge %209 None OpBranchConditional %208 %210 %209 @@ -337,10 +337,10 @@ OpBranchConditional %208 %210 %209 OpStore %211 %56 OpBranch %209 %209 = OpLabel -%212 = OpLoad %5 %19 +%212 = OpLoad %4 %19 %213 = OpAccessChain %66 %18 %49 %59 %49 OpStore %213 %212 -%214 = OpLoad %5 %22 +%214 = OpLoad %4 %22 %215 = OpAccessChain %66 %18 %49 %59 %54 OpStore %215 %214 OpReturn diff --git a/tests/out/spv/bounds-check-restrict.spvasm b/tests/out/spv/bounds-check-restrict.spvasm index f6ea5dcde8..8b13b44801 100644 --- a/tests/out/spv/bounds-check-restrict.spvasm +++ b/tests/out/spv/bounds-check-restrict.spvasm @@ -7,222 +7,222 @@ OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpDecorate %6 ArrayStride 4 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 48 -OpMemberDecorate %12 2 Offset 64 -OpMemberDecorate %12 2 ColMajor -OpMemberDecorate %12 2 MatrixStride 16 -OpMemberDecorate %12 3 Offset 112 +OpDecorate %4 ArrayStride 4 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 48 +OpMemberDecorate %10 2 Offset 64 +OpMemberDecorate %10 2 ColMajor +OpMemberDecorate %10 2 MatrixStride 16 +OpMemberDecorate %10 3 Offset 112 OpDecorate %13 DescriptorSet 0 OpDecorate %13 Binding 0 -OpDecorate %12 Block +OpDecorate %10 Block %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 10 -%5 = OpTypeFloat 32 -%8 = OpTypeInt 32 0 -%7 = OpConstant %8 10 -%6 = OpTypeArray %5 %7 -%9 = OpTypeVector %5 4 -%10 = OpTypeMatrix %9 3 -%11 = OpTypeRuntimeArray %5 -%12 = OpTypeStruct %6 %9 %10 %11 -%14 = OpTypePointer StorageBuffer %12 +%3 = OpTypeFloat 32 +%6 = OpTypeInt 32 0 +%5 = OpConstant %6 10 +%4 = OpTypeArray %3 %5 +%7 = OpTypeVector %3 4 +%8 = OpTypeMatrix %7 3 +%9 = OpTypeRuntimeArray %3 +%10 = OpTypeStruct %4 %7 %8 %9 +%11 = OpTypeInt 32 1 +%12 = OpConstant %11 10 +%14 = OpTypePointer StorageBuffer %10 %13 = OpVariable %14 StorageBuffer -%18 = OpTypeFunction %5 %4 -%20 = OpTypePointer StorageBuffer %6 -%21 = OpTypePointer StorageBuffer %5 -%22 = OpConstant %8 9 -%24 = OpConstant %8 0 -%31 = OpTypePointer StorageBuffer %11 -%33 = OpConstant %8 1 -%36 = OpConstant %8 3 -%43 = OpTypePointer StorageBuffer %9 -%44 = OpTypePointer StorageBuffer %5 -%52 = OpTypeFunction %5 %9 %4 -%59 = OpTypeFunction %9 %4 -%61 = OpTypePointer StorageBuffer %10 -%62 = OpTypePointer StorageBuffer %9 -%63 = OpConstant %8 2 -%71 = OpTypeFunction %5 %4 %4 -%80 = OpConstant %5 100.0 -%92 = OpTypeFunction %5 -%106 = OpTypeFunction %2 %4 %5 -%130 = OpTypeFunction %2 %4 %9 -%139 = OpTypeFunction %2 %4 %4 %5 -%159 = OpTypeFunction %2 %5 -%17 = OpFunction %5 None %18 -%16 = OpFunctionParameter %4 +%18 = OpTypeFunction %3 %11 +%20 = OpTypePointer StorageBuffer %4 +%21 = OpTypePointer StorageBuffer %3 +%22 = OpConstant %6 9 +%24 = OpConstant %6 0 +%31 = OpTypePointer StorageBuffer %9 +%33 = OpConstant %6 1 +%36 = OpConstant %6 3 +%43 = OpTypePointer StorageBuffer %7 +%44 = OpTypePointer StorageBuffer %3 +%52 = OpTypeFunction %3 %7 %11 +%59 = OpTypeFunction %7 %11 +%61 = OpTypePointer StorageBuffer %8 +%62 = OpTypePointer StorageBuffer %7 +%63 = OpConstant %6 2 +%71 = OpTypeFunction %3 %11 %11 +%80 = OpConstant %3 100.0 +%92 = OpTypeFunction %3 +%106 = OpTypeFunction %2 %11 %3 +%130 = OpTypeFunction %2 %11 %7 +%139 = OpTypeFunction %2 %11 %11 %3 +%159 = OpTypeFunction %2 %3 +%17 = OpFunction %3 None %18 +%16 = OpFunctionParameter %11 %15 = OpLabel OpBranch %19 %19 = OpLabel -%23 = OpExtInst %8 %1 UMin %16 %22 +%23 = OpExtInst %6 %1 UMin %16 %22 %25 = OpAccessChain %21 %13 %24 %23 -%26 = OpLoad %5 %25 +%26 = OpLoad %3 %25 OpReturnValue %26 OpFunctionEnd -%29 = OpFunction %5 None %18 -%28 = OpFunctionParameter %4 +%29 = OpFunction %3 None %18 +%28 = OpFunctionParameter %11 %27 = OpLabel OpBranch %30 %30 = OpLabel -%32 = OpArrayLength %8 %13 3 -%34 = OpISub %8 %32 %33 -%35 = OpExtInst %8 %1 UMin %28 %34 +%32 = OpArrayLength %6 %13 3 +%34 = OpISub %6 %32 %33 +%35 = OpExtInst %6 %1 UMin %28 %34 %37 = OpAccessChain %21 %13 %36 %35 -%38 = OpLoad %5 %37 +%38 = OpLoad %3 %37 OpReturnValue %38 OpFunctionEnd -%41 = OpFunction %5 None %18 -%40 = OpFunctionParameter %4 +%41 = OpFunction %3 None %18 +%40 = OpFunctionParameter %11 %39 = OpLabel OpBranch %42 %42 = OpLabel -%45 = OpExtInst %8 %1 UMin %40 %36 +%45 = OpExtInst %6 %1 UMin %40 %36 %46 = OpAccessChain %44 %13 %33 %45 -%47 = OpLoad %5 %46 +%47 = OpLoad %3 %46 OpReturnValue %47 OpFunctionEnd -%51 = OpFunction %5 None %52 -%49 = OpFunctionParameter %9 -%50 = OpFunctionParameter %4 +%51 = OpFunction %3 None %52 +%49 = OpFunctionParameter %7 +%50 = OpFunctionParameter %11 %48 = OpLabel OpBranch %53 %53 = OpLabel -%54 = OpExtInst %8 %1 UMin %50 %36 -%55 = OpVectorExtractDynamic %5 %49 %54 +%54 = OpExtInst %6 %1 UMin %50 %36 +%55 = OpVectorExtractDynamic %3 %49 %54 OpReturnValue %55 OpFunctionEnd -%58 = OpFunction %9 None %59 -%57 = OpFunctionParameter %4 +%58 = OpFunction %7 None %59 +%57 = OpFunctionParameter %11 %56 = OpLabel OpBranch %60 %60 = OpLabel -%64 = OpExtInst %8 %1 UMin %57 %63 +%64 = OpExtInst %6 %1 UMin %57 %63 %65 = OpAccessChain %62 %13 %63 %64 -%66 = OpLoad %9 %65 +%66 = OpLoad %7 %65 OpReturnValue %66 OpFunctionEnd -%70 = OpFunction %5 None %71 -%68 = OpFunctionParameter %4 -%69 = OpFunctionParameter %4 +%70 = OpFunction %3 None %71 +%68 = OpFunctionParameter %11 +%69 = OpFunctionParameter %11 %67 = OpLabel OpBranch %72 %72 = OpLabel -%73 = OpExtInst %8 %1 UMin %69 %36 -%74 = OpExtInst %8 %1 UMin %68 %63 +%73 = OpExtInst %6 %1 UMin %69 %36 +%74 = OpExtInst %6 %1 UMin %68 %63 %75 = OpAccessChain %44 %13 %63 %74 %73 -%76 = OpLoad %5 %75 +%76 = OpLoad %3 %75 OpReturnValue %76 OpFunctionEnd -%79 = OpFunction %5 None %18 -%78 = OpFunctionParameter %4 +%79 = OpFunction %3 None %18 +%78 = OpFunctionParameter %11 %77 = OpLabel OpBranch %81 %81 = OpLabel -%82 = OpConvertSToF %5 %78 -%83 = OpFDiv %5 %82 %80 -%84 = OpExtInst %5 %1 Sin %83 -%85 = OpFMul %5 %84 %80 -%86 = OpConvertFToS %4 %85 -%87 = OpExtInst %8 %1 UMin %86 %22 +%82 = OpConvertSToF %3 %78 +%83 = OpFDiv %3 %82 %80 +%84 = OpExtInst %3 %1 Sin %83 +%85 = OpFMul %3 %84 %80 +%86 = OpConvertFToS %11 %85 +%87 = OpExtInst %6 %1 UMin %86 %22 %88 = OpAccessChain %21 %13 %24 %87 -%89 = OpLoad %5 %88 +%89 = OpLoad %3 %88 OpReturnValue %89 OpFunctionEnd -%91 = OpFunction %5 None %92 +%91 = OpFunction %3 None %92 %90 = OpLabel OpBranch %93 %93 = OpLabel %94 = OpAccessChain %21 %13 %24 %22 -%95 = OpLoad %5 %94 +%95 = OpLoad %3 %94 %96 = OpAccessChain %44 %13 %33 %36 -%97 = OpLoad %5 %96 -%98 = OpFAdd %5 %95 %97 +%97 = OpLoad %3 %96 +%98 = OpFAdd %3 %95 %97 %99 = OpAccessChain %44 %13 %63 %63 %36 -%100 = OpLoad %5 %99 -%101 = OpFAdd %5 %98 %100 +%100 = OpLoad %3 %99 +%101 = OpFAdd %3 %98 %100 OpReturnValue %101 OpFunctionEnd %105 = OpFunction %2 None %106 -%103 = OpFunctionParameter %4 -%104 = OpFunctionParameter %5 +%103 = OpFunctionParameter %11 +%104 = OpFunctionParameter %3 %102 = OpLabel OpBranch %107 %107 = OpLabel -%108 = OpExtInst %8 %1 UMin %103 %22 +%108 = OpExtInst %6 %1 UMin %103 %22 %109 = OpAccessChain %21 %13 %24 %108 OpStore %109 %104 OpReturn OpFunctionEnd %113 = OpFunction %2 None %106 -%111 = OpFunctionParameter %4 -%112 = OpFunctionParameter %5 +%111 = OpFunctionParameter %11 +%112 = OpFunctionParameter %3 %110 = OpLabel OpBranch %114 %114 = OpLabel -%115 = OpArrayLength %8 %13 3 -%116 = OpISub %8 %115 %33 -%117 = OpExtInst %8 %1 UMin %111 %116 +%115 = OpArrayLength %6 %13 3 +%116 = OpISub %6 %115 %33 +%117 = OpExtInst %6 %1 UMin %111 %116 %118 = OpAccessChain %21 %13 %36 %117 OpStore %118 %112 OpReturn OpFunctionEnd %122 = OpFunction %2 None %106 -%120 = OpFunctionParameter %4 -%121 = OpFunctionParameter %5 +%120 = OpFunctionParameter %11 +%121 = OpFunctionParameter %3 %119 = OpLabel OpBranch %123 %123 = OpLabel -%124 = OpExtInst %8 %1 UMin %120 %36 +%124 = OpExtInst %6 %1 UMin %120 %36 %125 = OpAccessChain %44 %13 %33 %124 OpStore %125 %121 OpReturn OpFunctionEnd %129 = OpFunction %2 None %130 -%127 = OpFunctionParameter %4 -%128 = OpFunctionParameter %9 +%127 = OpFunctionParameter %11 +%128 = OpFunctionParameter %7 %126 = OpLabel OpBranch %131 %131 = OpLabel -%132 = OpExtInst %8 %1 UMin %127 %63 +%132 = OpExtInst %6 %1 UMin %127 %63 %133 = OpAccessChain %62 %13 %63 %132 OpStore %133 %128 OpReturn OpFunctionEnd %138 = OpFunction %2 None %139 -%135 = OpFunctionParameter %4 -%136 = OpFunctionParameter %4 -%137 = OpFunctionParameter %5 +%135 = OpFunctionParameter %11 +%136 = OpFunctionParameter %11 +%137 = OpFunctionParameter %3 %134 = OpLabel OpBranch %140 %140 = OpLabel -%141 = OpExtInst %8 %1 UMin %136 %36 -%142 = OpExtInst %8 %1 UMin %135 %63 +%141 = OpExtInst %6 %1 UMin %136 %36 +%142 = OpExtInst %6 %1 UMin %135 %63 %143 = OpAccessChain %44 %13 %63 %142 %141 OpStore %143 %137 OpReturn OpFunctionEnd %147 = OpFunction %2 None %106 -%145 = OpFunctionParameter %4 -%146 = OpFunctionParameter %5 +%145 = OpFunctionParameter %11 +%146 = OpFunctionParameter %3 %144 = OpLabel OpBranch %148 %148 = OpLabel -%149 = OpConvertSToF %5 %145 -%150 = OpFDiv %5 %149 %80 -%151 = OpExtInst %5 %1 Sin %150 -%152 = OpFMul %5 %151 %80 -%153 = OpConvertFToS %4 %152 -%154 = OpExtInst %8 %1 UMin %153 %22 +%149 = OpConvertSToF %3 %145 +%150 = OpFDiv %3 %149 %80 +%151 = OpExtInst %3 %1 Sin %150 +%152 = OpFMul %3 %151 %80 +%153 = OpConvertFToS %11 %152 +%154 = OpExtInst %6 %1 UMin %153 %22 %155 = OpAccessChain %21 %13 %24 %154 OpStore %155 %146 OpReturn OpFunctionEnd %158 = OpFunction %2 None %159 -%157 = OpFunctionParameter %5 +%157 = OpFunctionParameter %3 %156 = OpLabel OpBranch %160 %160 = OpLabel diff --git a/tests/out/spv/bounds-check-zero.spvasm b/tests/out/spv/bounds-check-zero.spvasm index c18b02063e..e5fcdce2f2 100644 --- a/tests/out/spv/bounds-check-zero.spvasm +++ b/tests/out/spv/bounds-check-zero.spvasm @@ -7,96 +7,96 @@ OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpDecorate %6 ArrayStride 4 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 48 -OpMemberDecorate %12 2 Offset 64 -OpMemberDecorate %12 2 ColMajor -OpMemberDecorate %12 2 MatrixStride 16 -OpMemberDecorate %12 3 Offset 112 +OpDecorate %4 ArrayStride 4 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 48 +OpMemberDecorate %10 2 Offset 64 +OpMemberDecorate %10 2 ColMajor +OpMemberDecorate %10 2 MatrixStride 16 +OpMemberDecorate %10 3 Offset 112 OpDecorate %13 DescriptorSet 0 OpDecorate %13 Binding 0 -OpDecorate %12 Block +OpDecorate %10 Block %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 10 -%5 = OpTypeFloat 32 -%8 = OpTypeInt 32 0 -%7 = OpConstant %8 10 -%6 = OpTypeArray %5 %7 -%9 = OpTypeVector %5 4 -%10 = OpTypeMatrix %9 3 -%11 = OpTypeRuntimeArray %5 -%12 = OpTypeStruct %6 %9 %10 %11 -%14 = OpTypePointer StorageBuffer %12 +%3 = OpTypeFloat 32 +%6 = OpTypeInt 32 0 +%5 = OpConstant %6 10 +%4 = OpTypeArray %3 %5 +%7 = OpTypeVector %3 4 +%8 = OpTypeMatrix %7 3 +%9 = OpTypeRuntimeArray %3 +%10 = OpTypeStruct %4 %7 %8 %9 +%11 = OpTypeInt 32 1 +%12 = OpConstant %11 10 +%14 = OpTypePointer StorageBuffer %10 %13 = OpVariable %14 StorageBuffer -%18 = OpTypeFunction %5 %4 -%20 = OpTypePointer StorageBuffer %6 -%21 = OpTypePointer StorageBuffer %5 +%18 = OpTypeFunction %3 %11 +%20 = OpTypePointer StorageBuffer %4 +%21 = OpTypePointer StorageBuffer %3 %23 = OpTypeBool -%24 = OpConstant %8 0 -%26 = OpConstantNull %5 -%35 = OpTypePointer StorageBuffer %11 -%38 = OpConstant %8 3 -%40 = OpConstantNull %5 -%49 = OpTypePointer StorageBuffer %9 -%50 = OpTypePointer StorageBuffer %5 -%51 = OpConstant %8 4 -%53 = OpConstant %8 1 -%55 = OpConstantNull %5 -%64 = OpTypeFunction %5 %9 %4 -%67 = OpConstantNull %5 -%75 = OpTypeFunction %9 %4 -%77 = OpTypePointer StorageBuffer %10 -%78 = OpTypePointer StorageBuffer %9 -%80 = OpConstant %8 2 -%82 = OpConstantNull %9 -%91 = OpTypeFunction %5 %4 %4 -%97 = OpConstantNull %5 -%105 = OpConstant %5 100.0 -%114 = OpConstantNull %5 -%121 = OpTypeFunction %5 -%123 = OpConstant %8 9 -%136 = OpTypeFunction %2 %4 %5 -%165 = OpTypeFunction %2 %4 %9 -%176 = OpTypeFunction %2 %4 %4 %5 -%201 = OpTypeFunction %2 %5 -%17 = OpFunction %5 None %18 -%16 = OpFunctionParameter %4 +%24 = OpConstant %6 0 +%26 = OpConstantNull %3 +%35 = OpTypePointer StorageBuffer %9 +%38 = OpConstant %6 3 +%40 = OpConstantNull %3 +%49 = OpTypePointer StorageBuffer %7 +%50 = OpTypePointer StorageBuffer %3 +%51 = OpConstant %6 4 +%53 = OpConstant %6 1 +%55 = OpConstantNull %3 +%64 = OpTypeFunction %3 %7 %11 +%67 = OpConstantNull %3 +%75 = OpTypeFunction %7 %11 +%77 = OpTypePointer StorageBuffer %8 +%78 = OpTypePointer StorageBuffer %7 +%80 = OpConstant %6 2 +%82 = OpConstantNull %7 +%91 = OpTypeFunction %3 %11 %11 +%97 = OpConstantNull %3 +%105 = OpConstant %3 100.0 +%114 = OpConstantNull %3 +%121 = OpTypeFunction %3 +%123 = OpConstant %6 9 +%136 = OpTypeFunction %2 %11 %3 +%165 = OpTypeFunction %2 %11 %7 +%176 = OpTypeFunction %2 %11 %11 %3 +%201 = OpTypeFunction %2 %3 +%17 = OpFunction %3 None %18 +%16 = OpFunctionParameter %11 %15 = OpLabel OpBranch %19 %19 = OpLabel -%22 = OpULessThan %23 %16 %7 +%22 = OpULessThan %23 %16 %5 OpSelectionMerge %27 None OpBranchConditional %22 %28 %27 %28 = OpLabel %25 = OpAccessChain %21 %13 %24 %16 -%29 = OpLoad %5 %25 +%29 = OpLoad %3 %25 OpBranch %27 %27 = OpLabel -%30 = OpPhi %5 %26 %19 %29 %28 +%30 = OpPhi %3 %26 %19 %29 %28 OpReturnValue %30 OpFunctionEnd -%33 = OpFunction %5 None %18 -%32 = OpFunctionParameter %4 +%33 = OpFunction %3 None %18 +%32 = OpFunctionParameter %11 %31 = OpLabel OpBranch %34 %34 = OpLabel -%36 = OpArrayLength %8 %13 3 +%36 = OpArrayLength %6 %13 3 %37 = OpULessThan %23 %32 %36 OpSelectionMerge %41 None OpBranchConditional %37 %42 %41 %42 = OpLabel %39 = OpAccessChain %21 %13 %38 %32 -%43 = OpLoad %5 %39 +%43 = OpLoad %3 %39 OpBranch %41 %41 = OpLabel -%44 = OpPhi %5 %40 %34 %43 %42 +%44 = OpPhi %3 %40 %34 %43 %42 OpReturnValue %44 OpFunctionEnd -%47 = OpFunction %5 None %18 -%46 = OpFunctionParameter %4 +%47 = OpFunction %3 None %18 +%46 = OpFunctionParameter %11 %45 = OpLabel OpBranch %48 %48 = OpLabel @@ -105,15 +105,15 @@ OpSelectionMerge %56 None OpBranchConditional %52 %57 %56 %57 = OpLabel %54 = OpAccessChain %50 %13 %53 %46 -%58 = OpLoad %5 %54 +%58 = OpLoad %3 %54 OpBranch %56 %56 = OpLabel -%59 = OpPhi %5 %55 %48 %58 %57 +%59 = OpPhi %3 %55 %48 %58 %57 OpReturnValue %59 OpFunctionEnd -%63 = OpFunction %5 None %64 -%61 = OpFunctionParameter %9 -%62 = OpFunctionParameter %4 +%63 = OpFunction %3 None %64 +%61 = OpFunctionParameter %7 +%62 = OpFunctionParameter %11 %60 = OpLabel OpBranch %65 %65 = OpLabel @@ -121,14 +121,14 @@ OpBranch %65 OpSelectionMerge %68 None OpBranchConditional %66 %69 %68 %69 = OpLabel -%70 = OpVectorExtractDynamic %5 %61 %62 +%70 = OpVectorExtractDynamic %3 %61 %62 OpBranch %68 %68 = OpLabel -%71 = OpPhi %5 %67 %65 %70 %69 +%71 = OpPhi %3 %67 %65 %70 %69 OpReturnValue %71 OpFunctionEnd -%74 = OpFunction %9 None %75 -%73 = OpFunctionParameter %4 +%74 = OpFunction %7 None %75 +%73 = OpFunctionParameter %11 %72 = OpLabel OpBranch %76 %76 = OpLabel @@ -137,15 +137,15 @@ OpSelectionMerge %83 None OpBranchConditional %79 %84 %83 %84 = OpLabel %81 = OpAccessChain %78 %13 %80 %73 -%85 = OpLoad %9 %81 +%85 = OpLoad %7 %81 OpBranch %83 %83 = OpLabel -%86 = OpPhi %9 %82 %76 %85 %84 +%86 = OpPhi %7 %82 %76 %85 %84 OpReturnValue %86 OpFunctionEnd -%90 = OpFunction %5 None %91 -%88 = OpFunctionParameter %4 -%89 = OpFunctionParameter %4 +%90 = OpFunction %3 None %91 +%88 = OpFunctionParameter %11 +%89 = OpFunctionParameter %11 %87 = OpLabel OpBranch %92 %92 = OpLabel @@ -156,54 +156,54 @@ OpSelectionMerge %98 None OpBranchConditional %95 %99 %98 %99 = OpLabel %96 = OpAccessChain %50 %13 %80 %88 %89 -%100 = OpLoad %5 %96 +%100 = OpLoad %3 %96 OpBranch %98 %98 = OpLabel -%101 = OpPhi %5 %97 %92 %100 %99 +%101 = OpPhi %3 %97 %92 %100 %99 OpReturnValue %101 OpFunctionEnd -%104 = OpFunction %5 None %18 -%103 = OpFunctionParameter %4 +%104 = OpFunction %3 None %18 +%103 = OpFunctionParameter %11 %102 = OpLabel OpBranch %106 %106 = OpLabel -%107 = OpConvertSToF %5 %103 -%108 = OpFDiv %5 %107 %105 -%109 = OpExtInst %5 %1 Sin %108 -%110 = OpFMul %5 %109 %105 -%111 = OpConvertFToS %4 %110 -%112 = OpULessThan %23 %111 %7 +%107 = OpConvertSToF %3 %103 +%108 = OpFDiv %3 %107 %105 +%109 = OpExtInst %3 %1 Sin %108 +%110 = OpFMul %3 %109 %105 +%111 = OpConvertFToS %11 %110 +%112 = OpULessThan %23 %111 %5 OpSelectionMerge %115 None OpBranchConditional %112 %116 %115 %116 = OpLabel %113 = OpAccessChain %21 %13 %24 %111 -%117 = OpLoad %5 %113 +%117 = OpLoad %3 %113 OpBranch %115 %115 = OpLabel -%118 = OpPhi %5 %114 %106 %117 %116 +%118 = OpPhi %3 %114 %106 %117 %116 OpReturnValue %118 OpFunctionEnd -%120 = OpFunction %5 None %121 +%120 = OpFunction %3 None %121 %119 = OpLabel OpBranch %122 %122 = OpLabel %124 = OpAccessChain %21 %13 %24 %123 -%125 = OpLoad %5 %124 +%125 = OpLoad %3 %124 %126 = OpAccessChain %50 %13 %53 %38 -%127 = OpLoad %5 %126 -%128 = OpFAdd %5 %125 %127 +%127 = OpLoad %3 %126 +%128 = OpFAdd %3 %125 %127 %129 = OpAccessChain %50 %13 %80 %80 %38 -%130 = OpLoad %5 %129 -%131 = OpFAdd %5 %128 %130 +%130 = OpLoad %3 %129 +%131 = OpFAdd %3 %128 %130 OpReturnValue %131 OpFunctionEnd %135 = OpFunction %2 None %136 -%133 = OpFunctionParameter %4 -%134 = OpFunctionParameter %5 +%133 = OpFunctionParameter %11 +%134 = OpFunctionParameter %3 %132 = OpLabel OpBranch %137 %137 = OpLabel -%138 = OpULessThan %23 %133 %7 +%138 = OpULessThan %23 %133 %5 OpSelectionMerge %140 None OpBranchConditional %138 %141 %140 %141 = OpLabel @@ -214,12 +214,12 @@ OpBranch %140 OpReturn OpFunctionEnd %145 = OpFunction %2 None %136 -%143 = OpFunctionParameter %4 -%144 = OpFunctionParameter %5 +%143 = OpFunctionParameter %11 +%144 = OpFunctionParameter %3 %142 = OpLabel OpBranch %146 %146 = OpLabel -%147 = OpArrayLength %8 %13 3 +%147 = OpArrayLength %6 %13 3 %148 = OpULessThan %23 %143 %147 OpSelectionMerge %150 None OpBranchConditional %148 %151 %150 @@ -231,8 +231,8 @@ OpBranch %150 OpReturn OpFunctionEnd %155 = OpFunction %2 None %136 -%153 = OpFunctionParameter %4 -%154 = OpFunctionParameter %5 +%153 = OpFunctionParameter %11 +%154 = OpFunctionParameter %3 %152 = OpLabel OpBranch %156 %156 = OpLabel @@ -247,8 +247,8 @@ OpBranch %159 OpReturn OpFunctionEnd %164 = OpFunction %2 None %165 -%162 = OpFunctionParameter %4 -%163 = OpFunctionParameter %9 +%162 = OpFunctionParameter %11 +%163 = OpFunctionParameter %7 %161 = OpLabel OpBranch %166 %166 = OpLabel @@ -263,9 +263,9 @@ OpBranch %169 OpReturn OpFunctionEnd %175 = OpFunction %2 None %176 -%172 = OpFunctionParameter %4 -%173 = OpFunctionParameter %4 -%174 = OpFunctionParameter %5 +%172 = OpFunctionParameter %11 +%173 = OpFunctionParameter %11 +%174 = OpFunctionParameter %3 %171 = OpLabel OpBranch %177 %177 = OpLabel @@ -282,17 +282,17 @@ OpBranch %182 OpReturn OpFunctionEnd %187 = OpFunction %2 None %136 -%185 = OpFunctionParameter %4 -%186 = OpFunctionParameter %5 +%185 = OpFunctionParameter %11 +%186 = OpFunctionParameter %3 %184 = OpLabel OpBranch %188 %188 = OpLabel -%189 = OpConvertSToF %5 %185 -%190 = OpFDiv %5 %189 %105 -%191 = OpExtInst %5 %1 Sin %190 -%192 = OpFMul %5 %191 %105 -%193 = OpConvertFToS %4 %192 -%194 = OpULessThan %23 %193 %7 +%189 = OpConvertSToF %3 %185 +%190 = OpFDiv %3 %189 %105 +%191 = OpExtInst %3 %1 Sin %190 +%192 = OpFMul %3 %191 %105 +%193 = OpConvertFToS %11 %192 +%194 = OpULessThan %23 %193 %5 OpSelectionMerge %196 None OpBranchConditional %194 %197 %196 %197 = OpLabel @@ -303,7 +303,7 @@ OpBranch %196 OpReturn OpFunctionEnd %200 = OpFunction %2 None %201 -%199 = OpFunctionParameter %5 +%199 = OpFunctionParameter %3 %198 = OpLabel OpBranch %202 %202 = OpLabel diff --git a/tests/out/spv/constructors.spvasm b/tests/out/spv/constructors.spvasm new file mode 100644 index 0000000000..2a2b3ad0f9 --- /dev/null +++ b/tests/out/spv/constructors.spvasm @@ -0,0 +1,100 @@ +; SPIR-V +; Version: 1.1 +; Generator: rspirv +; Bound: 90 +OpCapability Shader +%1 = OpExtInstImport "GLSL.std.450" +OpMemoryModel Logical GLSL450 +OpEntryPoint GLCompute %47 "main" +OpExecutionMode %47 LocalSize 1 1 1 +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 +OpDecorate %10 ArrayStride 16 +OpDecorate %15 ArrayStride 32 +OpDecorate %17 ArrayStride 4 +%2 = OpTypeVoid +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeInt 32 1 +%6 = OpTypeStruct %3 %5 +%7 = OpTypeVector %4 3 +%9 = OpTypeVector %4 2 +%8 = OpTypeMatrix %9 2 +%12 = OpTypeInt 32 0 +%11 = OpConstant %12 1 +%10 = OpTypeArray %8 %11 +%13 = OpTypeBool +%14 = OpTypeVector %12 2 +%16 = OpConstant %12 3 +%15 = OpTypeArray %6 %16 +%18 = OpConstant %12 4 +%17 = OpTypeArray %5 %18 +%19 = OpTypeMatrix %3 4 +%20 = OpTypeMatrix %7 2 +%21 = OpConstant %4 0.0 +%22 = OpConstant %4 1.0 +%23 = OpConstant %4 2.0 +%24 = OpConstantComposite %7 %21 %22 %23 +%25 = OpConstant %4 3.0 +%26 = OpConstantComposite %9 %21 %22 +%27 = OpConstantComposite %9 %23 %25 +%28 = OpConstantComposite %8 %26 %27 +%29 = OpConstant %5 1 +%30 = OpConstantComposite %10 %28 +%31 = OpConstantNull %13 +%32 = OpConstantNull %5 +%33 = OpConstantNull %12 +%34 = OpConstantNull %4 +%35 = OpConstantNull %14 +%36 = OpConstantNull %8 +%37 = OpConstant %5 3 +%38 = OpConstantNull %15 +%39 = OpConstantNull %6 +%40 = OpConstant %5 0 +%41 = OpConstant %5 2 +%42 = OpConstantComposite %17 %40 %29 %41 %37 +%44 = OpTypePointer Function %6 +%45 = OpConstantNull %6 +%48 = OpTypeFunction %2 +%49 = OpConstantNull %13 +%50 = OpConstantNull %5 +%51 = OpConstantNull %12 +%52 = OpConstantNull %4 +%53 = OpConstantNull %14 +%54 = OpConstantNull %8 +%55 = OpConstantNull %15 +%56 = OpConstantNull %6 +%57 = OpConstant %12 0 +%58 = OpConstantNull %13 +%59 = OpConstantNull %5 +%60 = OpConstantNull %12 +%61 = OpConstantNull %4 +%62 = OpConstantNull %14 +%63 = OpConstantNull %20 +%64 = OpConstantNull %14 +%65 = OpConstantNull %20 +%47 = OpFunction %2 None %48 +%46 = OpLabel +%43 = OpVariable %44 Function %45 +OpBranch %66 +%66 = OpLabel +%67 = OpCompositeConstruct %3 %22 %22 %22 %22 +%68 = OpCompositeConstruct %6 %67 %29 +OpStore %43 %68 +%69 = OpCompositeConstruct %9 %22 %21 +%70 = OpCompositeConstruct %9 %21 %22 +%71 = OpCompositeConstruct %8 %69 %70 +%72 = OpCompositeConstruct %3 %22 %21 %21 %21 +%73 = OpCompositeConstruct %3 %21 %22 %21 %21 +%74 = OpCompositeConstruct %3 %21 %21 %22 %21 +%75 = OpCompositeConstruct %3 %21 %21 %21 %22 +%76 = OpCompositeConstruct %19 %72 %73 %74 %75 +%77 = OpCompositeConstruct %14 %57 %57 +%78 = OpCompositeConstruct %9 %21 %21 +%79 = OpCompositeConstruct %9 %21 %21 +%80 = OpCompositeConstruct %8 %78 %79 +%81 = OpCompositeConstruct %17 %40 %29 %41 %37 +%87 = OpCopyObject %20 %63 +%89 = OpCopyObject %20 %65 +OpReturn +OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/globals.spvasm b/tests/out/spv/globals.spvasm index f50b806963..6e7e2958cd 100644 --- a/tests/out/spv/globals.spvasm +++ b/tests/out/spv/globals.spvasm @@ -1,22 +1,22 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 180 +; Bound: 179 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %103 "main" %123 +OpEntryPoint GLCompute %103 "main" %122 OpExecutionMode %103 LocalSize 1 1 1 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %13 0 Offset 0 -OpMemberDecorate %13 1 Offset 12 -OpDecorate %15 ArrayStride 8 -OpDecorate %17 ArrayStride 16 +OpDecorate %5 ArrayStride 4 +OpMemberDecorate %9 0 Offset 0 +OpMemberDecorate %9 1 Offset 12 +OpDecorate %11 ArrayStride 8 +OpDecorate %13 ArrayStride 16 +OpDecorate %17 ArrayStride 32 +OpDecorate %19 ArrayStride 64 OpDecorate %21 ArrayStride 32 -OpDecorate %23 ArrayStride 64 -OpDecorate %25 ArrayStride 32 -OpDecorate %26 ArrayStride 64 +OpDecorate %22 ArrayStride 64 OpDecorate %32 DescriptorSet 0 OpDecorate %32 Binding 1 OpDecorate %33 Block @@ -48,111 +48,110 @@ OpDecorate %50 DescriptorSet 0 OpDecorate %50 Binding 7 OpDecorate %51 Block OpMemberDecorate %51 0 Offset 0 -OpDecorate %123 BuiltIn LocalInvocationId +OpDecorate %122 BuiltIn LocalInvocationId %2 = OpTypeVoid -%4 = OpTypeBool -%3 = OpConstantTrue %4 -%6 = OpTypeInt 32 0 -%5 = OpConstant %6 10 -%8 = OpTypeInt 32 1 -%7 = OpConstant %8 20 -%9 = OpConstant %8 2 -%10 = OpTypeFloat 32 -%11 = OpTypeArray %10 %5 -%12 = OpTypeVector %10 3 -%13 = OpTypeStruct %12 %10 -%14 = OpTypeVector %10 2 -%15 = OpTypeRuntimeArray %14 -%16 = OpTypeVector %10 4 -%18 = OpConstant %6 20 +%3 = OpTypeBool +%4 = OpTypeFloat 32 +%7 = OpTypeInt 32 0 +%6 = OpConstant %7 10 +%5 = OpTypeArray %4 %6 +%8 = OpTypeVector %4 3 +%9 = OpTypeStruct %8 %4 +%10 = OpTypeVector %4 2 +%11 = OpTypeRuntimeArray %10 +%12 = OpTypeVector %4 4 +%14 = OpConstant %7 20 +%13 = OpTypeArray %12 %14 +%15 = OpTypeMatrix %10 3 +%16 = OpTypeMatrix %12 2 +%18 = OpConstant %7 2 %17 = OpTypeArray %16 %18 -%19 = OpTypeMatrix %14 3 -%20 = OpTypeMatrix %16 2 -%22 = OpConstant %6 2 -%21 = OpTypeArray %20 %22 -%23 = OpTypeArray %21 %22 -%24 = OpTypeMatrix %14 4 -%25 = OpTypeArray %24 %22 -%26 = OpTypeArray %25 %22 -%27 = OpTypeMatrix %12 3 -%29 = OpTypePointer Workgroup %11 +%19 = OpTypeArray %17 %18 +%20 = OpTypeMatrix %10 4 +%21 = OpTypeArray %20 %18 +%22 = OpTypeArray %21 %18 +%23 = OpTypeInt 32 1 +%24 = OpTypeMatrix %8 3 +%25 = OpConstantTrue %3 +%26 = OpConstant %23 20 +%27 = OpConstant %23 2 +%29 = OpTypePointer Workgroup %5 %28 = OpVariable %29 Workgroup -%31 = OpTypePointer Workgroup %6 +%31 = OpTypePointer Workgroup %7 %30 = OpVariable %31 Workgroup -%33 = OpTypeStruct %13 +%33 = OpTypeStruct %9 %34 = OpTypePointer StorageBuffer %33 %32 = OpVariable %34 StorageBuffer -%36 = OpTypeStruct %15 +%36 = OpTypeStruct %11 %37 = OpTypePointer StorageBuffer %36 %35 = OpVariable %37 StorageBuffer -%39 = OpTypeStruct %17 +%39 = OpTypeStruct %13 %40 = OpTypePointer Uniform %39 %38 = OpVariable %40 Uniform -%42 = OpTypeStruct %12 +%42 = OpTypeStruct %8 %43 = OpTypePointer Uniform %42 %41 = OpVariable %43 Uniform -%45 = OpTypeStruct %19 +%45 = OpTypeStruct %15 %46 = OpTypePointer Uniform %45 %44 = OpVariable %46 Uniform -%48 = OpTypeStruct %23 +%48 = OpTypeStruct %19 %49 = OpTypePointer Uniform %48 %47 = OpVariable %49 Uniform -%51 = OpTypeStruct %26 +%51 = OpTypeStruct %22 %52 = OpTypePointer Uniform %51 %50 = OpVariable %52 Uniform -%56 = OpTypeFunction %2 %12 -%59 = OpTypePointer Function %8 -%60 = OpConstantNull %8 +%56 = OpTypeFunction %2 %8 +%59 = OpTypePointer Function %23 +%60 = OpConstantNull %23 %63 = OpTypeFunction %2 -%64 = OpTypePointer StorageBuffer %13 -%65 = OpConstant %6 0 -%67 = OpConstant %10 1.0 -%68 = OpConstant %8 1 -%69 = OpConstant %10 2.0 -%70 = OpConstant %10 3.0 -%71 = OpConstantNull %27 -%72 = OpConstantNull %27 -%74 = OpTypePointer StorageBuffer %12 -%77 = OpTypePointer StorageBuffer %10 -%97 = OpTypePointer Function %10 -%98 = OpConstantNull %10 -%100 = OpTypePointer Function %4 -%101 = OpConstantNull %4 -%105 = OpTypePointer StorageBuffer %15 -%107 = OpTypePointer Uniform %17 -%109 = OpTypePointer Uniform %12 -%111 = OpTypePointer Uniform %19 -%113 = OpTypePointer Uniform %23 -%115 = OpTypePointer Uniform %26 -%117 = OpConstant %10 4.0 -%118 = OpConstantTrue %4 -%120 = OpConstantNull %11 -%121 = OpConstantNull %6 -%122 = OpTypeVector %6 3 -%124 = OpTypePointer Input %122 -%123 = OpVariable %124 Input -%126 = OpConstantNull %122 -%127 = OpTypeVector %4 3 -%132 = OpConstant %6 264 -%135 = OpTypePointer Workgroup %10 -%136 = OpTypePointer Uniform %25 -%137 = OpTypePointer Uniform %24 -%140 = OpTypePointer Uniform %21 -%141 = OpTypePointer Uniform %20 -%142 = OpTypePointer Uniform %16 -%147 = OpConstant %6 7 -%153 = OpConstant %6 6 -%155 = OpTypePointer StorageBuffer %14 -%156 = OpConstant %6 1 -%159 = OpConstant %6 5 -%161 = OpTypePointer Uniform %16 -%162 = OpTypePointer Uniform %10 -%163 = OpConstant %6 3 -%166 = OpConstant %6 4 -%168 = OpTypePointer StorageBuffer %10 -%179 = OpConstant %6 256 +%64 = OpTypePointer StorageBuffer %9 +%65 = OpConstant %7 0 +%67 = OpConstant %4 1.0 +%68 = OpConstant %23 1 +%69 = OpConstant %4 2.0 +%70 = OpConstant %4 3.0 +%71 = OpConstantNull %24 +%72 = OpConstantNull %24 +%74 = OpTypePointer StorageBuffer %8 +%77 = OpTypePointer StorageBuffer %4 +%97 = OpTypePointer Function %4 +%98 = OpConstantNull %4 +%100 = OpTypePointer Function %3 +%101 = OpConstantNull %3 +%105 = OpTypePointer StorageBuffer %11 +%107 = OpTypePointer Uniform %13 +%109 = OpTypePointer Uniform %8 +%111 = OpTypePointer Uniform %15 +%113 = OpTypePointer Uniform %19 +%115 = OpTypePointer Uniform %22 +%117 = OpConstant %4 4.0 +%119 = OpConstantNull %5 +%120 = OpConstantNull %7 +%121 = OpTypeVector %7 3 +%123 = OpTypePointer Input %121 +%122 = OpVariable %123 Input +%125 = OpConstantNull %121 +%126 = OpTypeVector %3 3 +%131 = OpConstant %7 264 +%134 = OpTypePointer Workgroup %4 +%135 = OpTypePointer Uniform %21 +%136 = OpTypePointer Uniform %20 +%139 = OpTypePointer Uniform %17 +%140 = OpTypePointer Uniform %16 +%141 = OpTypePointer Uniform %12 +%146 = OpConstant %7 7 +%152 = OpConstant %7 6 +%154 = OpTypePointer StorageBuffer %10 +%155 = OpConstant %7 1 +%158 = OpConstant %7 5 +%160 = OpTypePointer Uniform %12 +%161 = OpTypePointer Uniform %4 +%162 = OpConstant %7 3 +%165 = OpConstant %7 4 +%167 = OpTypePointer StorageBuffer %4 +%178 = OpConstant %7 256 %55 = OpFunction %2 None %56 -%54 = OpFunctionParameter %12 +%54 = OpFunctionParameter %8 %53 = OpLabel OpBranch %57 %57 = OpLabel @@ -164,7 +163,7 @@ OpFunctionEnd %66 = OpAccessChain %64 %32 %65 OpBranch %73 %73 = OpLabel -%75 = OpCompositeConstruct %12 %67 %67 %67 +%75 = OpCompositeConstruct %8 %67 %67 %67 %76 = OpAccessChain %74 %66 %65 OpStore %76 %75 OpStore %58 %68 @@ -172,23 +171,23 @@ OpStore %58 %68 OpStore %78 %67 %79 = OpAccessChain %77 %66 %65 %65 OpStore %79 %69 -%80 = OpLoad %8 %58 +%80 = OpLoad %23 %58 %81 = OpAccessChain %77 %66 %65 %80 OpStore %81 %70 -%82 = OpLoad %13 %66 -%83 = OpCompositeExtract %12 %82 0 -%84 = OpCompositeExtract %12 %82 0 -%85 = OpVectorShuffle %14 %84 %84 2 0 -%86 = OpCompositeExtract %12 %82 0 +%82 = OpLoad %9 %66 +%83 = OpCompositeExtract %8 %82 0 +%84 = OpCompositeExtract %8 %82 0 +%85 = OpVectorShuffle %10 %84 %84 2 0 +%86 = OpCompositeExtract %8 %82 0 %87 = OpFunctionCall %2 %55 %86 -%88 = OpCompositeExtract %12 %82 0 -%89 = OpVectorTimesMatrix %12 %88 %71 -%90 = OpCompositeExtract %12 %82 0 -%91 = OpMatrixTimesVector %12 %72 %90 -%92 = OpCompositeExtract %12 %82 0 -%93 = OpVectorTimesScalar %12 %92 %69 -%94 = OpCompositeExtract %12 %82 0 -%95 = OpVectorTimesScalar %12 %94 %69 +%88 = OpCompositeExtract %8 %82 0 +%89 = OpVectorTimesMatrix %8 %88 %71 +%90 = OpCompositeExtract %8 %82 0 +%91 = OpMatrixTimesVector %8 %72 %90 +%92 = OpCompositeExtract %8 %82 0 +%93 = OpVectorTimesScalar %8 %92 %69 +%94 = OpCompositeExtract %8 %82 0 +%95 = OpVectorTimesScalar %8 %94 %69 OpReturn OpFunctionEnd %103 = OpFunction %2 None %63 @@ -202,60 +201,60 @@ OpFunctionEnd %112 = OpAccessChain %111 %44 %65 %114 = OpAccessChain %113 %47 %65 %116 = OpAccessChain %115 %50 %65 -OpBranch %119 -%119 = OpLabel -%125 = OpLoad %122 %123 -%128 = OpIEqual %127 %125 %126 -%129 = OpAll %4 %128 -OpSelectionMerge %130 None -OpBranchConditional %129 %131 %130 -%131 = OpLabel -OpStore %28 %120 -OpStore %30 %121 -OpBranch %130 +OpBranch %118 +%118 = OpLabel +%124 = OpLoad %121 %122 +%127 = OpIEqual %126 %124 %125 +%128 = OpAll %3 %127 +OpSelectionMerge %129 None +OpBranchConditional %128 %130 %129 %130 = OpLabel -OpControlBarrier %22 %22 %132 -OpBranch %133 -%133 = OpLabel -%134 = OpFunctionCall %2 %62 -%138 = OpAccessChain %137 %116 %65 %65 -%139 = OpLoad %24 %138 -%143 = OpAccessChain %142 %114 %65 %65 %65 -%144 = OpLoad %16 %143 -%145 = OpMatrixTimesVector %14 %139 %144 -%146 = OpCompositeExtract %10 %145 0 -%148 = OpAccessChain %135 %28 %147 -OpStore %148 %146 -%149 = OpLoad %19 %112 -%150 = OpLoad %12 %110 -%151 = OpMatrixTimesVector %14 %149 %150 -%152 = OpCompositeExtract %10 %151 0 -%154 = OpAccessChain %135 %28 %153 -OpStore %154 %152 -%157 = OpAccessChain %77 %106 %156 %156 -%158 = OpLoad %10 %157 -%160 = OpAccessChain %135 %28 %159 -OpStore %160 %158 -%164 = OpAccessChain %162 %108 %65 %163 -%165 = OpLoad %10 %164 -%167 = OpAccessChain %135 %28 %166 -OpStore %167 %165 -%169 = OpAccessChain %168 %104 %156 -%170 = OpLoad %10 %169 -%171 = OpAccessChain %135 %28 %163 -OpStore %171 %170 -%172 = OpAccessChain %77 %104 %65 %65 -%173 = OpLoad %10 %172 -%174 = OpAccessChain %135 %28 %22 -OpStore %174 %173 -%175 = OpAccessChain %168 %104 %156 -OpStore %175 %117 -%176 = OpArrayLength %6 %35 0 -%177 = OpConvertUToF %10 %176 -%178 = OpAccessChain %135 %28 %156 -OpStore %178 %177 -OpAtomicStore %30 %9 %179 %22 +OpStore %28 %119 +OpStore %30 %120 +OpBranch %129 +%129 = OpLabel +OpControlBarrier %18 %18 %131 +OpBranch %132 +%132 = OpLabel +%133 = OpFunctionCall %2 %62 +%137 = OpAccessChain %136 %116 %65 %65 +%138 = OpLoad %20 %137 +%142 = OpAccessChain %141 %114 %65 %65 %65 +%143 = OpLoad %12 %142 +%144 = OpMatrixTimesVector %10 %138 %143 +%145 = OpCompositeExtract %4 %144 0 +%147 = OpAccessChain %134 %28 %146 +OpStore %147 %145 +%148 = OpLoad %15 %112 +%149 = OpLoad %8 %110 +%150 = OpMatrixTimesVector %10 %148 %149 +%151 = OpCompositeExtract %4 %150 0 +%153 = OpAccessChain %134 %28 %152 +OpStore %153 %151 +%156 = OpAccessChain %77 %106 %155 %155 +%157 = OpLoad %4 %156 +%159 = OpAccessChain %134 %28 %158 +OpStore %159 %157 +%163 = OpAccessChain %161 %108 %65 %162 +%164 = OpLoad %4 %163 +%166 = OpAccessChain %134 %28 %165 +OpStore %166 %164 +%168 = OpAccessChain %167 %104 %155 +%169 = OpLoad %4 %168 +%170 = OpAccessChain %134 %28 %162 +OpStore %170 %169 +%171 = OpAccessChain %77 %104 %65 %65 +%172 = OpLoad %4 %171 +%173 = OpAccessChain %134 %28 %18 +OpStore %173 %172 +%174 = OpAccessChain %167 %104 %155 +OpStore %174 %117 +%175 = OpArrayLength %7 %35 0 +%176 = OpConvertUToF %4 %175 +%177 = OpAccessChain %134 %28 %155 +OpStore %177 %176 +OpAtomicStore %30 %27 %178 %18 OpStore %96 %67 -OpStore %99 %118 +OpStore %99 %25 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/image.spvasm b/tests/out/spv/image.spvasm index 4f9dd442e0..fc82611455 100644 --- a/tests/out/spv/image.spvasm +++ b/tests/out/spv/image.spvasm @@ -113,608 +113,608 @@ OpDecorate %442 Location 0 OpDecorate %498 Location 0 OpDecorate %533 Location 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 3 -%5 = OpConstant %4 1 -%7 = OpTypeInt 32 0 -%6 = OpTypeImage %7 2D 0 0 0 1 Unknown -%8 = OpTypeImage %7 2D 0 0 1 1 Unknown -%10 = OpTypeFloat 32 -%9 = OpTypeImage %10 2D 1 0 1 1 Unknown -%11 = OpTypeImage %7 2D 0 0 0 2 Rgba8ui -%12 = OpTypeImage %7 2D 0 1 0 1 Unknown -%13 = OpTypeImage %7 1D 0 0 0 2 R32ui -%14 = OpTypeImage %7 1D 0 0 0 1 Unknown -%15 = OpTypeVector %7 3 -%16 = OpTypeVector %4 2 -%17 = OpTypeVector %7 2 -%18 = OpTypeVector %7 4 -%19 = OpTypeImage %10 1D 0 0 0 1 Unknown -%20 = OpTypeImage %10 2D 0 0 0 1 Unknown -%21 = OpTypeImage %4 2D 0 0 0 1 Unknown -%22 = OpTypeImage %10 2D 0 1 0 1 Unknown -%23 = OpTypeImage %10 Cube 0 0 0 1 Unknown -%24 = OpTypeImage %10 Cube 0 1 0 1 Unknown -%25 = OpTypeImage %10 3D 0 0 0 1 Unknown -%26 = OpTypeImage %10 2D 0 0 1 1 Unknown -%27 = OpTypeVector %10 4 -%28 = OpTypeSampler -%29 = OpTypeVector %10 2 -%30 = OpTypeVector %10 3 -%31 = OpTypeImage %10 2D 1 0 0 1 Unknown -%32 = OpTypeImage %10 2D 1 1 0 1 Unknown -%33 = OpTypeImage %10 Cube 1 0 0 1 Unknown -%34 = OpConstantComposite %16 %3 %5 -%36 = OpTypePointer UniformConstant %6 +%4 = OpTypeInt 32 0 +%3 = OpTypeImage %4 2D 0 0 0 1 Unknown +%5 = OpTypeImage %4 2D 0 0 1 1 Unknown +%7 = OpTypeFloat 32 +%6 = OpTypeImage %7 2D 1 0 1 1 Unknown +%8 = OpTypeImage %4 2D 0 0 0 2 Rgba8ui +%9 = OpTypeImage %4 2D 0 1 0 1 Unknown +%10 = OpTypeImage %4 1D 0 0 0 2 R32ui +%11 = OpTypeImage %4 1D 0 0 0 1 Unknown +%12 = OpTypeVector %4 3 +%14 = OpTypeInt 32 1 +%13 = OpTypeVector %14 2 +%15 = OpTypeVector %4 2 +%16 = OpTypeVector %4 4 +%17 = OpTypeImage %7 1D 0 0 0 1 Unknown +%18 = OpTypeImage %7 2D 0 0 0 1 Unknown +%19 = OpTypeImage %14 2D 0 0 0 1 Unknown +%20 = OpTypeImage %7 2D 0 1 0 1 Unknown +%21 = OpTypeImage %7 Cube 0 0 0 1 Unknown +%22 = OpTypeImage %7 Cube 0 1 0 1 Unknown +%23 = OpTypeImage %7 3D 0 0 0 1 Unknown +%24 = OpTypeImage %7 2D 0 0 1 1 Unknown +%25 = OpTypeVector %7 4 +%26 = OpTypeSampler +%27 = OpTypeVector %7 2 +%28 = OpTypeVector %7 3 +%29 = OpTypeImage %7 2D 1 0 0 1 Unknown +%30 = OpTypeImage %7 2D 1 1 0 1 Unknown +%31 = OpTypeImage %7 Cube 1 0 0 1 Unknown +%32 = OpConstant %14 3 +%33 = OpConstant %14 1 +%34 = OpConstantComposite %13 %32 %33 +%36 = OpTypePointer UniformConstant %3 %35 = OpVariable %36 UniformConstant -%38 = OpTypePointer UniformConstant %8 +%38 = OpTypePointer UniformConstant %5 %37 = OpVariable %38 UniformConstant -%40 = OpTypePointer UniformConstant %9 +%40 = OpTypePointer UniformConstant %6 %39 = OpVariable %40 UniformConstant -%42 = OpTypePointer UniformConstant %11 +%42 = OpTypePointer UniformConstant %8 %41 = OpVariable %42 UniformConstant -%44 = OpTypePointer UniformConstant %12 +%44 = OpTypePointer UniformConstant %9 %43 = OpVariable %44 UniformConstant -%46 = OpTypePointer UniformConstant %13 +%46 = OpTypePointer UniformConstant %10 %45 = OpVariable %46 UniformConstant -%48 = OpTypePointer UniformConstant %14 +%48 = OpTypePointer UniformConstant %11 %47 = OpVariable %48 UniformConstant -%50 = OpTypePointer UniformConstant %13 +%50 = OpTypePointer UniformConstant %10 %49 = OpVariable %50 UniformConstant -%52 = OpTypePointer UniformConstant %19 +%52 = OpTypePointer UniformConstant %17 %51 = OpVariable %52 UniformConstant -%54 = OpTypePointer UniformConstant %20 +%54 = OpTypePointer UniformConstant %18 %53 = OpVariable %54 UniformConstant %55 = OpVariable %36 UniformConstant -%57 = OpTypePointer UniformConstant %21 +%57 = OpTypePointer UniformConstant %19 %56 = OpVariable %57 UniformConstant -%59 = OpTypePointer UniformConstant %22 +%59 = OpTypePointer UniformConstant %20 %58 = OpVariable %59 UniformConstant -%61 = OpTypePointer UniformConstant %23 +%61 = OpTypePointer UniformConstant %21 %60 = OpVariable %61 UniformConstant -%63 = OpTypePointer UniformConstant %24 +%63 = OpTypePointer UniformConstant %22 %62 = OpVariable %63 UniformConstant -%65 = OpTypePointer UniformConstant %25 +%65 = OpTypePointer UniformConstant %23 %64 = OpVariable %65 UniformConstant -%67 = OpTypePointer UniformConstant %26 +%67 = OpTypePointer UniformConstant %24 %66 = OpVariable %67 UniformConstant -%69 = OpTypePointer UniformConstant %28 +%69 = OpTypePointer UniformConstant %26 %68 = OpVariable %69 UniformConstant -%71 = OpTypePointer UniformConstant %28 +%71 = OpTypePointer UniformConstant %26 %70 = OpVariable %71 UniformConstant -%73 = OpTypePointer UniformConstant %31 +%73 = OpTypePointer UniformConstant %29 %72 = OpVariable %73 UniformConstant -%75 = OpTypePointer UniformConstant %32 +%75 = OpTypePointer UniformConstant %30 %74 = OpVariable %75 UniformConstant -%77 = OpTypePointer UniformConstant %33 +%77 = OpTypePointer UniformConstant %31 %76 = OpVariable %77 UniformConstant -%80 = OpTypePointer Input %15 +%80 = OpTypePointer Input %12 %79 = OpVariable %80 Input %83 = OpTypeFunction %2 -%90 = OpConstant %4 10 -%91 = OpConstant %4 20 -%112 = OpTypeVector %4 3 +%90 = OpConstant %14 10 +%91 = OpConstant %14 20 +%112 = OpTypeVector %14 3 %170 = OpVariable %80 Input -%193 = OpTypePointer Output %27 +%193 = OpTypePointer Output %25 %192 = OpVariable %193 Output -%203 = OpConstant %7 0 +%203 = OpConstant %4 0 %258 = OpVariable %193 Output -%295 = OpTypePointer Function %27 -%296 = OpConstantNull %27 +%295 = OpTypePointer Function %25 +%296 = OpConstantNull %25 %298 = OpVariable %193 Output -%305 = OpConstant %10 0.5 -%306 = OpConstant %10 2.3 -%307 = OpConstant %10 2.0 -%308 = OpConstant %4 0 -%313 = OpTypeSampledImage %19 -%318 = OpTypeSampledImage %20 -%339 = OpTypeSampledImage %22 -%400 = OpTypeSampledImage %24 -%439 = OpTypePointer Function %10 -%440 = OpConstantNull %10 -%443 = OpTypePointer Output %10 +%305 = OpConstant %7 0.5 +%306 = OpConstant %7 2.3 +%307 = OpConstant %7 2.0 +%308 = OpConstant %14 0 +%313 = OpTypeSampledImage %17 +%318 = OpTypeSampledImage %18 +%339 = OpTypeSampledImage %20 +%400 = OpTypeSampledImage %22 +%439 = OpTypePointer Function %7 +%440 = OpConstantNull %7 +%443 = OpTypePointer Output %7 %442 = OpVariable %443 Output -%452 = OpTypeSampledImage %31 -%457 = OpTypeSampledImage %32 -%470 = OpTypeSampledImage %33 -%477 = OpConstant %10 0.0 +%452 = OpTypeSampledImage %29 +%457 = OpTypeSampledImage %30 +%470 = OpTypeSampledImage %31 +%477 = OpConstant %7 0.0 %498 = OpVariable %193 Output -%510 = OpConstant %7 1 -%513 = OpConstant %7 3 -%518 = OpTypeSampledImage %6 -%521 = OpTypeVector %4 4 -%522 = OpTypeSampledImage %21 +%510 = OpConstant %4 1 +%513 = OpConstant %4 3 +%518 = OpTypeSampledImage %3 +%521 = OpTypeVector %14 4 +%522 = OpTypeSampledImage %19 %533 = OpVariable %193 Output %82 = OpFunction %2 None %83 %78 = OpLabel -%81 = OpLoad %15 %79 -%84 = OpLoad %6 %35 -%85 = OpLoad %8 %37 -%86 = OpLoad %11 %41 -%87 = OpLoad %12 %43 -%88 = OpLoad %14 %47 -%89 = OpLoad %13 %49 +%81 = OpLoad %12 %79 +%84 = OpLoad %3 %35 +%85 = OpLoad %5 %37 +%86 = OpLoad %8 %41 +%87 = OpLoad %9 %43 +%88 = OpLoad %11 %47 +%89 = OpLoad %10 %49 OpBranch %92 %92 = OpLabel -%93 = OpImageQuerySize %16 %86 -%94 = OpBitcast %17 %93 -%95 = OpVectorShuffle %17 %81 %81 0 1 -%96 = OpIMul %17 %94 %95 -%97 = OpBitcast %16 %96 -%98 = OpCompositeConstruct %16 %90 %91 -%99 = OpSRem %16 %97 %98 -%100 = OpCompositeExtract %7 %81 2 -%101 = OpBitcast %4 %100 -%102 = OpImageFetch %18 %84 %99 Lod %101 -%103 = OpCompositeExtract %7 %81 2 -%104 = OpBitcast %4 %103 -%105 = OpImageFetch %18 %85 %99 Sample %104 -%106 = OpImageRead %18 %86 %99 -%107 = OpCompositeExtract %7 %81 2 -%108 = OpCompositeExtract %7 %81 2 -%109 = OpBitcast %4 %108 -%110 = OpIAdd %4 %109 %5 -%111 = OpBitcast %4 %107 +%93 = OpImageQuerySize %13 %86 +%94 = OpBitcast %15 %93 +%95 = OpVectorShuffle %15 %81 %81 0 1 +%96 = OpIMul %15 %94 %95 +%97 = OpBitcast %13 %96 +%98 = OpCompositeConstruct %13 %90 %91 +%99 = OpSRem %13 %97 %98 +%100 = OpCompositeExtract %4 %81 2 +%101 = OpBitcast %14 %100 +%102 = OpImageFetch %16 %84 %99 Lod %101 +%103 = OpCompositeExtract %4 %81 2 +%104 = OpBitcast %14 %103 +%105 = OpImageFetch %16 %85 %99 Sample %104 +%106 = OpImageRead %16 %86 %99 +%107 = OpCompositeExtract %4 %81 2 +%108 = OpCompositeExtract %4 %81 2 +%109 = OpBitcast %14 %108 +%110 = OpIAdd %14 %109 %33 +%111 = OpBitcast %14 %107 %113 = OpCompositeConstruct %112 %99 %111 -%114 = OpImageFetch %18 %87 %113 Lod %110 -%115 = OpCompositeExtract %7 %81 2 -%116 = OpBitcast %4 %115 -%117 = OpCompositeExtract %7 %81 2 -%118 = OpBitcast %4 %117 -%119 = OpIAdd %4 %118 %5 +%114 = OpImageFetch %16 %87 %113 Lod %110 +%115 = OpCompositeExtract %4 %81 2 +%116 = OpBitcast %14 %115 +%117 = OpCompositeExtract %4 %81 2 +%118 = OpBitcast %14 %117 +%119 = OpIAdd %14 %118 %33 %120 = OpCompositeConstruct %112 %99 %116 -%121 = OpImageFetch %18 %87 %120 Lod %119 -%122 = OpCompositeExtract %7 %81 0 -%123 = OpBitcast %4 %122 -%124 = OpCompositeExtract %7 %81 2 -%125 = OpBitcast %4 %124 -%126 = OpImageFetch %18 %88 %123 Lod %125 -%127 = OpBitcast %17 %99 -%128 = OpCompositeExtract %7 %81 2 -%129 = OpBitcast %4 %128 -%130 = OpImageFetch %18 %84 %127 Lod %129 -%131 = OpBitcast %17 %99 -%132 = OpCompositeExtract %7 %81 2 -%133 = OpBitcast %4 %132 -%134 = OpImageFetch %18 %85 %131 Sample %133 -%135 = OpBitcast %17 %99 -%136 = OpImageRead %18 %86 %135 -%137 = OpBitcast %17 %99 -%138 = OpCompositeExtract %7 %81 2 -%139 = OpCompositeExtract %7 %81 2 -%140 = OpBitcast %4 %139 -%141 = OpIAdd %4 %140 %5 -%142 = OpCompositeConstruct %15 %137 %138 -%143 = OpImageFetch %18 %87 %142 Lod %141 -%144 = OpBitcast %17 %99 -%145 = OpCompositeExtract %7 %81 2 -%146 = OpBitcast %4 %145 -%147 = OpCompositeExtract %7 %81 2 -%148 = OpBitcast %4 %147 -%149 = OpIAdd %4 %148 %5 -%150 = OpBitcast %7 %146 -%151 = OpCompositeConstruct %15 %144 %150 -%152 = OpImageFetch %18 %87 %151 Lod %149 -%153 = OpCompositeExtract %7 %81 0 -%155 = OpCompositeExtract %7 %81 2 -%156 = OpBitcast %4 %155 -%157 = OpImageFetch %18 %88 %153 Lod %156 -%158 = OpCompositeExtract %4 %99 0 -%159 = OpIAdd %18 %102 %105 -%160 = OpIAdd %18 %159 %106 -%161 = OpIAdd %18 %160 %114 -%162 = OpIAdd %18 %161 %121 +%121 = OpImageFetch %16 %87 %120 Lod %119 +%122 = OpCompositeExtract %4 %81 0 +%123 = OpBitcast %14 %122 +%124 = OpCompositeExtract %4 %81 2 +%125 = OpBitcast %14 %124 +%126 = OpImageFetch %16 %88 %123 Lod %125 +%127 = OpBitcast %15 %99 +%128 = OpCompositeExtract %4 %81 2 +%129 = OpBitcast %14 %128 +%130 = OpImageFetch %16 %84 %127 Lod %129 +%131 = OpBitcast %15 %99 +%132 = OpCompositeExtract %4 %81 2 +%133 = OpBitcast %14 %132 +%134 = OpImageFetch %16 %85 %131 Sample %133 +%135 = OpBitcast %15 %99 +%136 = OpImageRead %16 %86 %135 +%137 = OpBitcast %15 %99 +%138 = OpCompositeExtract %4 %81 2 +%139 = OpCompositeExtract %4 %81 2 +%140 = OpBitcast %14 %139 +%141 = OpIAdd %14 %140 %33 +%142 = OpCompositeConstruct %12 %137 %138 +%143 = OpImageFetch %16 %87 %142 Lod %141 +%144 = OpBitcast %15 %99 +%145 = OpCompositeExtract %4 %81 2 +%146 = OpBitcast %14 %145 +%147 = OpCompositeExtract %4 %81 2 +%148 = OpBitcast %14 %147 +%149 = OpIAdd %14 %148 %33 +%150 = OpBitcast %4 %146 +%151 = OpCompositeConstruct %12 %144 %150 +%152 = OpImageFetch %16 %87 %151 Lod %149 +%153 = OpCompositeExtract %4 %81 0 +%155 = OpCompositeExtract %4 %81 2 +%156 = OpBitcast %14 %155 +%157 = OpImageFetch %16 %88 %153 Lod %156 +%158 = OpCompositeExtract %14 %99 0 +%159 = OpIAdd %16 %102 %105 +%160 = OpIAdd %16 %159 %106 +%161 = OpIAdd %16 %160 %114 +%162 = OpIAdd %16 %161 %121 OpImageWrite %89 %158 %162 -%163 = OpCompositeExtract %4 %99 0 -%164 = OpBitcast %7 %163 -%165 = OpIAdd %18 %130 %134 -%166 = OpIAdd %18 %165 %136 -%167 = OpIAdd %18 %166 %143 -%168 = OpIAdd %18 %167 %152 +%163 = OpCompositeExtract %14 %99 0 +%164 = OpBitcast %4 %163 +%165 = OpIAdd %16 %130 %134 +%166 = OpIAdd %16 %165 %136 +%167 = OpIAdd %16 %166 %143 +%168 = OpIAdd %16 %167 %152 OpImageWrite %89 %164 %168 OpReturn OpFunctionEnd %172 = OpFunction %2 None %83 %169 = OpLabel -%171 = OpLoad %15 %170 -%173 = OpLoad %9 %39 -%174 = OpLoad %11 %41 -%175 = OpLoad %13 %49 +%171 = OpLoad %12 %170 +%173 = OpLoad %6 %39 +%174 = OpLoad %8 %41 +%175 = OpLoad %10 %49 OpBranch %176 %176 = OpLabel -%177 = OpImageQuerySize %16 %174 -%178 = OpBitcast %17 %177 -%179 = OpVectorShuffle %17 %171 %171 0 1 -%180 = OpIMul %17 %178 %179 -%181 = OpBitcast %16 %180 -%182 = OpCompositeConstruct %16 %90 %91 -%183 = OpSRem %16 %181 %182 -%184 = OpCompositeExtract %7 %171 2 -%185 = OpBitcast %4 %184 -%186 = OpImageFetch %27 %173 %183 Sample %185 -%187 = OpCompositeExtract %10 %186 0 -%188 = OpCompositeExtract %4 %183 0 -%189 = OpConvertFToU %7 %187 -%190 = OpCompositeConstruct %18 %189 %189 %189 %189 +%177 = OpImageQuerySize %13 %174 +%178 = OpBitcast %15 %177 +%179 = OpVectorShuffle %15 %171 %171 0 1 +%180 = OpIMul %15 %178 %179 +%181 = OpBitcast %13 %180 +%182 = OpCompositeConstruct %13 %90 %91 +%183 = OpSRem %13 %181 %182 +%184 = OpCompositeExtract %4 %171 2 +%185 = OpBitcast %14 %184 +%186 = OpImageFetch %25 %173 %183 Sample %185 +%187 = OpCompositeExtract %7 %186 0 +%188 = OpCompositeExtract %14 %183 0 +%189 = OpConvertFToU %4 %187 +%190 = OpCompositeConstruct %16 %189 %189 %189 %189 OpImageWrite %175 %188 %190 OpReturn OpFunctionEnd %194 = OpFunction %2 None %83 %191 = OpLabel -%195 = OpLoad %19 %51 -%196 = OpLoad %20 %53 -%197 = OpLoad %22 %58 -%198 = OpLoad %23 %60 -%199 = OpLoad %24 %62 -%200 = OpLoad %25 %64 -%201 = OpLoad %26 %66 +%195 = OpLoad %17 %51 +%196 = OpLoad %18 %53 +%197 = OpLoad %20 %58 +%198 = OpLoad %21 %60 +%199 = OpLoad %22 %62 +%200 = OpLoad %23 %64 +%201 = OpLoad %24 %66 OpBranch %202 %202 = OpLabel -%204 = OpImageQuerySizeLod %4 %195 %203 -%205 = OpBitcast %7 %204 -%206 = OpBitcast %4 %205 -%207 = OpImageQuerySizeLod %4 %195 %206 -%208 = OpBitcast %7 %207 -%209 = OpImageQuerySizeLod %16 %196 %203 -%210 = OpBitcast %17 %209 -%211 = OpImageQuerySizeLod %16 %196 %5 -%212 = OpBitcast %17 %211 +%204 = OpImageQuerySizeLod %14 %195 %203 +%205 = OpBitcast %4 %204 +%206 = OpBitcast %14 %205 +%207 = OpImageQuerySizeLod %14 %195 %206 +%208 = OpBitcast %4 %207 +%209 = OpImageQuerySizeLod %13 %196 %203 +%210 = OpBitcast %15 %209 +%211 = OpImageQuerySizeLod %13 %196 %33 +%212 = OpBitcast %15 %211 %213 = OpImageQuerySizeLod %112 %197 %203 -%214 = OpBitcast %15 %213 -%215 = OpVectorShuffle %17 %214 %214 0 1 -%216 = OpImageQuerySizeLod %112 %197 %5 -%217 = OpBitcast %15 %216 -%218 = OpVectorShuffle %17 %217 %217 0 1 -%219 = OpImageQuerySizeLod %16 %198 %203 -%220 = OpBitcast %17 %219 -%221 = OpImageQuerySizeLod %16 %198 %5 -%222 = OpBitcast %17 %221 +%214 = OpBitcast %12 %213 +%215 = OpVectorShuffle %15 %214 %214 0 1 +%216 = OpImageQuerySizeLod %112 %197 %33 +%217 = OpBitcast %12 %216 +%218 = OpVectorShuffle %15 %217 %217 0 1 +%219 = OpImageQuerySizeLod %13 %198 %203 +%220 = OpBitcast %15 %219 +%221 = OpImageQuerySizeLod %13 %198 %33 +%222 = OpBitcast %15 %221 %223 = OpImageQuerySizeLod %112 %199 %203 -%224 = OpBitcast %15 %223 -%225 = OpVectorShuffle %17 %224 %224 0 0 -%226 = OpImageQuerySizeLod %112 %199 %5 -%227 = OpBitcast %15 %226 -%228 = OpVectorShuffle %17 %227 %227 0 0 +%224 = OpBitcast %12 %223 +%225 = OpVectorShuffle %15 %224 %224 0 0 +%226 = OpImageQuerySizeLod %112 %199 %33 +%227 = OpBitcast %12 %226 +%228 = OpVectorShuffle %15 %227 %227 0 0 %229 = OpImageQuerySizeLod %112 %200 %203 -%230 = OpBitcast %15 %229 -%231 = OpImageQuerySizeLod %112 %200 %5 -%232 = OpBitcast %15 %231 -%233 = OpImageQuerySize %16 %201 -%234 = OpBitcast %17 %233 -%235 = OpCompositeExtract %7 %210 1 -%236 = OpIAdd %7 %205 %235 -%237 = OpCompositeExtract %7 %212 1 -%238 = OpIAdd %7 %236 %237 -%239 = OpCompositeExtract %7 %215 1 -%240 = OpIAdd %7 %238 %239 -%241 = OpCompositeExtract %7 %218 1 -%242 = OpIAdd %7 %240 %241 -%243 = OpCompositeExtract %7 %220 1 -%244 = OpIAdd %7 %242 %243 -%245 = OpCompositeExtract %7 %222 1 -%246 = OpIAdd %7 %244 %245 -%247 = OpCompositeExtract %7 %225 1 -%248 = OpIAdd %7 %246 %247 -%249 = OpCompositeExtract %7 %228 1 -%250 = OpIAdd %7 %248 %249 -%251 = OpCompositeExtract %7 %230 2 -%252 = OpIAdd %7 %250 %251 -%253 = OpCompositeExtract %7 %232 2 -%254 = OpIAdd %7 %252 %253 -%255 = OpConvertUToF %10 %254 -%256 = OpCompositeConstruct %27 %255 %255 %255 %255 +%230 = OpBitcast %12 %229 +%231 = OpImageQuerySizeLod %112 %200 %33 +%232 = OpBitcast %12 %231 +%233 = OpImageQuerySize %13 %201 +%234 = OpBitcast %15 %233 +%235 = OpCompositeExtract %4 %210 1 +%236 = OpIAdd %4 %205 %235 +%237 = OpCompositeExtract %4 %212 1 +%238 = OpIAdd %4 %236 %237 +%239 = OpCompositeExtract %4 %215 1 +%240 = OpIAdd %4 %238 %239 +%241 = OpCompositeExtract %4 %218 1 +%242 = OpIAdd %4 %240 %241 +%243 = OpCompositeExtract %4 %220 1 +%244 = OpIAdd %4 %242 %243 +%245 = OpCompositeExtract %4 %222 1 +%246 = OpIAdd %4 %244 %245 +%247 = OpCompositeExtract %4 %225 1 +%248 = OpIAdd %4 %246 %247 +%249 = OpCompositeExtract %4 %228 1 +%250 = OpIAdd %4 %248 %249 +%251 = OpCompositeExtract %4 %230 2 +%252 = OpIAdd %4 %250 %251 +%253 = OpCompositeExtract %4 %232 2 +%254 = OpIAdd %4 %252 %253 +%255 = OpConvertUToF %7 %254 +%256 = OpCompositeConstruct %25 %255 %255 %255 %255 OpStore %192 %256 OpReturn OpFunctionEnd %259 = OpFunction %2 None %83 %257 = OpLabel -%260 = OpLoad %20 %53 -%261 = OpLoad %22 %58 -%262 = OpLoad %23 %60 -%263 = OpLoad %24 %62 -%264 = OpLoad %25 %64 -%265 = OpLoad %26 %66 +%260 = OpLoad %18 %53 +%261 = OpLoad %20 %58 +%262 = OpLoad %21 %60 +%263 = OpLoad %22 %62 +%264 = OpLoad %23 %64 +%265 = OpLoad %24 %66 OpBranch %266 %266 = OpLabel -%267 = OpImageQueryLevels %4 %260 -%268 = OpBitcast %7 %267 -%269 = OpImageQueryLevels %4 %261 -%270 = OpBitcast %7 %269 +%267 = OpImageQueryLevels %14 %260 +%268 = OpBitcast %4 %267 +%269 = OpImageQueryLevels %14 %261 +%270 = OpBitcast %4 %269 %271 = OpImageQuerySizeLod %112 %261 %203 -%272 = OpCompositeExtract %4 %271 2 -%273 = OpBitcast %7 %272 -%274 = OpImageQueryLevels %4 %262 -%275 = OpBitcast %7 %274 -%276 = OpImageQueryLevels %4 %263 -%277 = OpBitcast %7 %276 +%272 = OpCompositeExtract %14 %271 2 +%273 = OpBitcast %4 %272 +%274 = OpImageQueryLevels %14 %262 +%275 = OpBitcast %4 %274 +%276 = OpImageQueryLevels %14 %263 +%277 = OpBitcast %4 %276 %278 = OpImageQuerySizeLod %112 %263 %203 -%279 = OpCompositeExtract %4 %278 2 -%280 = OpBitcast %7 %279 -%281 = OpImageQueryLevels %4 %264 -%282 = OpBitcast %7 %281 -%283 = OpImageQuerySamples %4 %265 -%284 = OpBitcast %7 %283 -%285 = OpIAdd %7 %273 %280 -%286 = OpIAdd %7 %285 %284 -%287 = OpIAdd %7 %286 %268 -%288 = OpIAdd %7 %287 %270 -%289 = OpIAdd %7 %288 %282 -%290 = OpIAdd %7 %289 %275 -%291 = OpIAdd %7 %290 %277 -%292 = OpConvertUToF %10 %291 -%293 = OpCompositeConstruct %27 %292 %292 %292 %292 +%279 = OpCompositeExtract %14 %278 2 +%280 = OpBitcast %4 %279 +%281 = OpImageQueryLevels %14 %264 +%282 = OpBitcast %4 %281 +%283 = OpImageQuerySamples %14 %265 +%284 = OpBitcast %4 %283 +%285 = OpIAdd %4 %273 %280 +%286 = OpIAdd %4 %285 %284 +%287 = OpIAdd %4 %286 %268 +%288 = OpIAdd %4 %287 %270 +%289 = OpIAdd %4 %288 %282 +%290 = OpIAdd %4 %289 %275 +%291 = OpIAdd %4 %290 %277 +%292 = OpConvertUToF %7 %291 +%293 = OpCompositeConstruct %25 %292 %292 %292 %292 OpStore %258 %293 OpReturn OpFunctionEnd %299 = OpFunction %2 None %83 %297 = OpLabel %294 = OpVariable %295 Function %296 -%300 = OpLoad %19 %51 -%301 = OpLoad %20 %53 -%302 = OpLoad %22 %58 -%303 = OpLoad %24 %62 -%304 = OpLoad %28 %68 +%300 = OpLoad %17 %51 +%301 = OpLoad %18 %53 +%302 = OpLoad %20 %58 +%303 = OpLoad %22 %62 +%304 = OpLoad %26 %68 OpBranch %309 %309 = OpLabel -%310 = OpCompositeConstruct %29 %305 %305 -%311 = OpCompositeConstruct %30 %305 %305 %305 -%312 = OpCompositeExtract %10 %310 0 +%310 = OpCompositeConstruct %27 %305 %305 +%311 = OpCompositeConstruct %28 %305 %305 %305 +%312 = OpCompositeExtract %7 %310 0 %314 = OpSampledImage %313 %300 %304 -%315 = OpImageSampleImplicitLod %27 %314 %312 -%316 = OpLoad %27 %294 -%317 = OpFAdd %27 %316 %315 +%315 = OpImageSampleImplicitLod %25 %314 %312 +%316 = OpLoad %25 %294 +%317 = OpFAdd %25 %316 %315 OpStore %294 %317 %319 = OpSampledImage %318 %301 %304 -%320 = OpImageSampleImplicitLod %27 %319 %310 -%321 = OpLoad %27 %294 -%322 = OpFAdd %27 %321 %320 +%320 = OpImageSampleImplicitLod %25 %319 %310 +%321 = OpLoad %25 %294 +%322 = OpFAdd %25 %321 %320 OpStore %294 %322 %323 = OpSampledImage %318 %301 %304 -%324 = OpImageSampleImplicitLod %27 %323 %310 ConstOffset %34 -%325 = OpLoad %27 %294 -%326 = OpFAdd %27 %325 %324 +%324 = OpImageSampleImplicitLod %25 %323 %310 ConstOffset %34 +%325 = OpLoad %25 %294 +%326 = OpFAdd %25 %325 %324 OpStore %294 %326 %327 = OpSampledImage %318 %301 %304 -%328 = OpImageSampleExplicitLod %27 %327 %310 Lod %306 -%329 = OpLoad %27 %294 -%330 = OpFAdd %27 %329 %328 +%328 = OpImageSampleExplicitLod %25 %327 %310 Lod %306 +%329 = OpLoad %25 %294 +%330 = OpFAdd %25 %329 %328 OpStore %294 %330 %331 = OpSampledImage %318 %301 %304 -%332 = OpImageSampleExplicitLod %27 %331 %310 Lod|ConstOffset %306 %34 -%333 = OpLoad %27 %294 -%334 = OpFAdd %27 %333 %332 +%332 = OpImageSampleExplicitLod %25 %331 %310 Lod|ConstOffset %306 %34 +%333 = OpLoad %25 %294 +%334 = OpFAdd %25 %333 %332 OpStore %294 %334 %335 = OpSampledImage %318 %301 %304 -%336 = OpImageSampleImplicitLod %27 %335 %310 Bias|ConstOffset %307 %34 -%337 = OpLoad %27 %294 -%338 = OpFAdd %27 %337 %336 +%336 = OpImageSampleImplicitLod %25 %335 %310 Bias|ConstOffset %307 %34 +%337 = OpLoad %25 %294 +%338 = OpFAdd %25 %337 %336 OpStore %294 %338 -%340 = OpConvertUToF %10 %203 -%341 = OpCompositeConstruct %30 %310 %340 +%340 = OpConvertUToF %7 %203 +%341 = OpCompositeConstruct %28 %310 %340 %342 = OpSampledImage %339 %302 %304 -%343 = OpImageSampleImplicitLod %27 %342 %341 -%344 = OpLoad %27 %294 -%345 = OpFAdd %27 %344 %343 +%343 = OpImageSampleImplicitLod %25 %342 %341 +%344 = OpLoad %25 %294 +%345 = OpFAdd %25 %344 %343 OpStore %294 %345 -%346 = OpConvertUToF %10 %203 -%347 = OpCompositeConstruct %30 %310 %346 +%346 = OpConvertUToF %7 %203 +%347 = OpCompositeConstruct %28 %310 %346 %348 = OpSampledImage %339 %302 %304 -%349 = OpImageSampleImplicitLod %27 %348 %347 ConstOffset %34 -%350 = OpLoad %27 %294 -%351 = OpFAdd %27 %350 %349 +%349 = OpImageSampleImplicitLod %25 %348 %347 ConstOffset %34 +%350 = OpLoad %25 %294 +%351 = OpFAdd %25 %350 %349 OpStore %294 %351 -%352 = OpConvertUToF %10 %203 -%353 = OpCompositeConstruct %30 %310 %352 +%352 = OpConvertUToF %7 %203 +%353 = OpCompositeConstruct %28 %310 %352 %354 = OpSampledImage %339 %302 %304 -%355 = OpImageSampleExplicitLod %27 %354 %353 Lod %306 -%356 = OpLoad %27 %294 -%357 = OpFAdd %27 %356 %355 +%355 = OpImageSampleExplicitLod %25 %354 %353 Lod %306 +%356 = OpLoad %25 %294 +%357 = OpFAdd %25 %356 %355 OpStore %294 %357 -%358 = OpConvertUToF %10 %203 -%359 = OpCompositeConstruct %30 %310 %358 +%358 = OpConvertUToF %7 %203 +%359 = OpCompositeConstruct %28 %310 %358 %360 = OpSampledImage %339 %302 %304 -%361 = OpImageSampleExplicitLod %27 %360 %359 Lod|ConstOffset %306 %34 -%362 = OpLoad %27 %294 -%363 = OpFAdd %27 %362 %361 +%361 = OpImageSampleExplicitLod %25 %360 %359 Lod|ConstOffset %306 %34 +%362 = OpLoad %25 %294 +%363 = OpFAdd %25 %362 %361 OpStore %294 %363 -%364 = OpConvertUToF %10 %203 -%365 = OpCompositeConstruct %30 %310 %364 +%364 = OpConvertUToF %7 %203 +%365 = OpCompositeConstruct %28 %310 %364 %366 = OpSampledImage %339 %302 %304 -%367 = OpImageSampleImplicitLod %27 %366 %365 Bias|ConstOffset %307 %34 -%368 = OpLoad %27 %294 -%369 = OpFAdd %27 %368 %367 +%367 = OpImageSampleImplicitLod %25 %366 %365 Bias|ConstOffset %307 %34 +%368 = OpLoad %25 %294 +%369 = OpFAdd %25 %368 %367 OpStore %294 %369 -%370 = OpConvertSToF %10 %308 -%371 = OpCompositeConstruct %30 %310 %370 +%370 = OpConvertSToF %7 %308 +%371 = OpCompositeConstruct %28 %310 %370 %372 = OpSampledImage %339 %302 %304 -%373 = OpImageSampleImplicitLod %27 %372 %371 -%374 = OpLoad %27 %294 -%375 = OpFAdd %27 %374 %373 +%373 = OpImageSampleImplicitLod %25 %372 %371 +%374 = OpLoad %25 %294 +%375 = OpFAdd %25 %374 %373 OpStore %294 %375 -%376 = OpConvertSToF %10 %308 -%377 = OpCompositeConstruct %30 %310 %376 +%376 = OpConvertSToF %7 %308 +%377 = OpCompositeConstruct %28 %310 %376 %378 = OpSampledImage %339 %302 %304 -%379 = OpImageSampleImplicitLod %27 %378 %377 ConstOffset %34 -%380 = OpLoad %27 %294 -%381 = OpFAdd %27 %380 %379 +%379 = OpImageSampleImplicitLod %25 %378 %377 ConstOffset %34 +%380 = OpLoad %25 %294 +%381 = OpFAdd %25 %380 %379 OpStore %294 %381 -%382 = OpConvertSToF %10 %308 -%383 = OpCompositeConstruct %30 %310 %382 +%382 = OpConvertSToF %7 %308 +%383 = OpCompositeConstruct %28 %310 %382 %384 = OpSampledImage %339 %302 %304 -%385 = OpImageSampleExplicitLod %27 %384 %383 Lod %306 -%386 = OpLoad %27 %294 -%387 = OpFAdd %27 %386 %385 +%385 = OpImageSampleExplicitLod %25 %384 %383 Lod %306 +%386 = OpLoad %25 %294 +%387 = OpFAdd %25 %386 %385 OpStore %294 %387 -%388 = OpConvertSToF %10 %308 -%389 = OpCompositeConstruct %30 %310 %388 +%388 = OpConvertSToF %7 %308 +%389 = OpCompositeConstruct %28 %310 %388 %390 = OpSampledImage %339 %302 %304 -%391 = OpImageSampleExplicitLod %27 %390 %389 Lod|ConstOffset %306 %34 -%392 = OpLoad %27 %294 -%393 = OpFAdd %27 %392 %391 +%391 = OpImageSampleExplicitLod %25 %390 %389 Lod|ConstOffset %306 %34 +%392 = OpLoad %25 %294 +%393 = OpFAdd %25 %392 %391 OpStore %294 %393 -%394 = OpConvertSToF %10 %308 -%395 = OpCompositeConstruct %30 %310 %394 +%394 = OpConvertSToF %7 %308 +%395 = OpCompositeConstruct %28 %310 %394 %396 = OpSampledImage %339 %302 %304 -%397 = OpImageSampleImplicitLod %27 %396 %395 Bias|ConstOffset %307 %34 -%398 = OpLoad %27 %294 -%399 = OpFAdd %27 %398 %397 +%397 = OpImageSampleImplicitLod %25 %396 %395 Bias|ConstOffset %307 %34 +%398 = OpLoad %25 %294 +%399 = OpFAdd %25 %398 %397 OpStore %294 %399 -%401 = OpConvertUToF %10 %203 -%402 = OpCompositeConstruct %27 %311 %401 +%401 = OpConvertUToF %7 %203 +%402 = OpCompositeConstruct %25 %311 %401 %403 = OpSampledImage %400 %303 %304 -%404 = OpImageSampleImplicitLod %27 %403 %402 -%405 = OpLoad %27 %294 -%406 = OpFAdd %27 %405 %404 +%404 = OpImageSampleImplicitLod %25 %403 %402 +%405 = OpLoad %25 %294 +%406 = OpFAdd %25 %405 %404 OpStore %294 %406 -%407 = OpConvertUToF %10 %203 -%408 = OpCompositeConstruct %27 %311 %407 +%407 = OpConvertUToF %7 %203 +%408 = OpCompositeConstruct %25 %311 %407 %409 = OpSampledImage %400 %303 %304 -%410 = OpImageSampleExplicitLod %27 %409 %408 Lod %306 -%411 = OpLoad %27 %294 -%412 = OpFAdd %27 %411 %410 +%410 = OpImageSampleExplicitLod %25 %409 %408 Lod %306 +%411 = OpLoad %25 %294 +%412 = OpFAdd %25 %411 %410 OpStore %294 %412 -%413 = OpConvertUToF %10 %203 -%414 = OpCompositeConstruct %27 %311 %413 +%413 = OpConvertUToF %7 %203 +%414 = OpCompositeConstruct %25 %311 %413 %415 = OpSampledImage %400 %303 %304 -%416 = OpImageSampleImplicitLod %27 %415 %414 Bias %307 -%417 = OpLoad %27 %294 -%418 = OpFAdd %27 %417 %416 +%416 = OpImageSampleImplicitLod %25 %415 %414 Bias %307 +%417 = OpLoad %25 %294 +%418 = OpFAdd %25 %417 %416 OpStore %294 %418 -%419 = OpConvertSToF %10 %308 -%420 = OpCompositeConstruct %27 %311 %419 +%419 = OpConvertSToF %7 %308 +%420 = OpCompositeConstruct %25 %311 %419 %421 = OpSampledImage %400 %303 %304 -%422 = OpImageSampleImplicitLod %27 %421 %420 -%423 = OpLoad %27 %294 -%424 = OpFAdd %27 %423 %422 +%422 = OpImageSampleImplicitLod %25 %421 %420 +%423 = OpLoad %25 %294 +%424 = OpFAdd %25 %423 %422 OpStore %294 %424 -%425 = OpConvertSToF %10 %308 -%426 = OpCompositeConstruct %27 %311 %425 +%425 = OpConvertSToF %7 %308 +%426 = OpCompositeConstruct %25 %311 %425 %427 = OpSampledImage %400 %303 %304 -%428 = OpImageSampleExplicitLod %27 %427 %426 Lod %306 -%429 = OpLoad %27 %294 -%430 = OpFAdd %27 %429 %428 +%428 = OpImageSampleExplicitLod %25 %427 %426 Lod %306 +%429 = OpLoad %25 %294 +%430 = OpFAdd %25 %429 %428 OpStore %294 %430 -%431 = OpConvertSToF %10 %308 -%432 = OpCompositeConstruct %27 %311 %431 +%431 = OpConvertSToF %7 %308 +%432 = OpCompositeConstruct %25 %311 %431 %433 = OpSampledImage %400 %303 %304 -%434 = OpImageSampleImplicitLod %27 %433 %432 Bias %307 -%435 = OpLoad %27 %294 -%436 = OpFAdd %27 %435 %434 +%434 = OpImageSampleImplicitLod %25 %433 %432 Bias %307 +%435 = OpLoad %25 %294 +%436 = OpFAdd %25 %435 %434 OpStore %294 %436 -%437 = OpLoad %27 %294 +%437 = OpLoad %25 %294 OpStore %298 %437 OpReturn OpFunctionEnd %444 = OpFunction %2 None %83 %441 = OpLabel %438 = OpVariable %439 Function %440 -%445 = OpLoad %28 %70 -%446 = OpLoad %31 %72 -%447 = OpLoad %32 %74 -%448 = OpLoad %33 %76 +%445 = OpLoad %26 %70 +%446 = OpLoad %29 %72 +%447 = OpLoad %30 %74 +%448 = OpLoad %31 %76 OpBranch %449 %449 = OpLabel -%450 = OpCompositeConstruct %29 %305 %305 -%451 = OpCompositeConstruct %30 %305 %305 %305 +%450 = OpCompositeConstruct %27 %305 %305 +%451 = OpCompositeConstruct %28 %305 %305 %305 %453 = OpSampledImage %452 %446 %445 -%454 = OpImageSampleDrefImplicitLod %10 %453 %450 %305 -%455 = OpLoad %10 %438 -%456 = OpFAdd %10 %455 %454 +%454 = OpImageSampleDrefImplicitLod %7 %453 %450 %305 +%455 = OpLoad %7 %438 +%456 = OpFAdd %7 %455 %454 OpStore %438 %456 -%458 = OpConvertUToF %10 %203 -%459 = OpCompositeConstruct %30 %450 %458 +%458 = OpConvertUToF %7 %203 +%459 = OpCompositeConstruct %28 %450 %458 %460 = OpSampledImage %457 %447 %445 -%461 = OpImageSampleDrefImplicitLod %10 %460 %459 %305 -%462 = OpLoad %10 %438 -%463 = OpFAdd %10 %462 %461 +%461 = OpImageSampleDrefImplicitLod %7 %460 %459 %305 +%462 = OpLoad %7 %438 +%463 = OpFAdd %7 %462 %461 OpStore %438 %463 -%464 = OpConvertSToF %10 %308 -%465 = OpCompositeConstruct %30 %450 %464 +%464 = OpConvertSToF %7 %308 +%465 = OpCompositeConstruct %28 %450 %464 %466 = OpSampledImage %457 %447 %445 -%467 = OpImageSampleDrefImplicitLod %10 %466 %465 %305 -%468 = OpLoad %10 %438 -%469 = OpFAdd %10 %468 %467 +%467 = OpImageSampleDrefImplicitLod %7 %466 %465 %305 +%468 = OpLoad %7 %438 +%469 = OpFAdd %7 %468 %467 OpStore %438 %469 %471 = OpSampledImage %470 %448 %445 -%472 = OpImageSampleDrefImplicitLod %10 %471 %451 %305 -%473 = OpLoad %10 %438 -%474 = OpFAdd %10 %473 %472 +%472 = OpImageSampleDrefImplicitLod %7 %471 %451 %305 +%473 = OpLoad %7 %438 +%474 = OpFAdd %7 %473 %472 OpStore %438 %474 %475 = OpSampledImage %452 %446 %445 -%476 = OpImageSampleDrefExplicitLod %10 %475 %450 %305 Lod %477 -%478 = OpLoad %10 %438 -%479 = OpFAdd %10 %478 %476 +%476 = OpImageSampleDrefExplicitLod %7 %475 %450 %305 Lod %477 +%478 = OpLoad %7 %438 +%479 = OpFAdd %7 %478 %476 OpStore %438 %479 -%480 = OpConvertUToF %10 %203 -%481 = OpCompositeConstruct %30 %450 %480 +%480 = OpConvertUToF %7 %203 +%481 = OpCompositeConstruct %28 %450 %480 %482 = OpSampledImage %457 %447 %445 -%483 = OpImageSampleDrefExplicitLod %10 %482 %481 %305 Lod %477 -%484 = OpLoad %10 %438 -%485 = OpFAdd %10 %484 %483 +%483 = OpImageSampleDrefExplicitLod %7 %482 %481 %305 Lod %477 +%484 = OpLoad %7 %438 +%485 = OpFAdd %7 %484 %483 OpStore %438 %485 -%486 = OpConvertSToF %10 %308 -%487 = OpCompositeConstruct %30 %450 %486 +%486 = OpConvertSToF %7 %308 +%487 = OpCompositeConstruct %28 %450 %486 %488 = OpSampledImage %457 %447 %445 -%489 = OpImageSampleDrefExplicitLod %10 %488 %487 %305 Lod %477 -%490 = OpLoad %10 %438 -%491 = OpFAdd %10 %490 %489 +%489 = OpImageSampleDrefExplicitLod %7 %488 %487 %305 Lod %477 +%490 = OpLoad %7 %438 +%491 = OpFAdd %7 %490 %489 OpStore %438 %491 %492 = OpSampledImage %470 %448 %445 -%493 = OpImageSampleDrefExplicitLod %10 %492 %451 %305 Lod %477 -%494 = OpLoad %10 %438 -%495 = OpFAdd %10 %494 %493 +%493 = OpImageSampleDrefExplicitLod %7 %492 %451 %305 Lod %477 +%494 = OpLoad %7 %438 +%495 = OpFAdd %7 %494 %493 OpStore %438 %495 -%496 = OpLoad %10 %438 +%496 = OpLoad %7 %438 OpStore %442 %496 OpReturn OpFunctionEnd %499 = OpFunction %2 None %83 %497 = OpLabel -%500 = OpLoad %20 %53 -%501 = OpLoad %6 %55 -%502 = OpLoad %21 %56 -%503 = OpLoad %28 %68 -%504 = OpLoad %28 %70 -%505 = OpLoad %31 %72 +%500 = OpLoad %18 %53 +%501 = OpLoad %3 %55 +%502 = OpLoad %19 %56 +%503 = OpLoad %26 %68 +%504 = OpLoad %26 %70 +%505 = OpLoad %29 %72 OpBranch %506 %506 = OpLabel -%507 = OpCompositeConstruct %29 %305 %305 +%507 = OpCompositeConstruct %27 %305 %305 %508 = OpSampledImage %318 %500 %503 -%509 = OpImageGather %27 %508 %507 %510 +%509 = OpImageGather %25 %508 %507 %510 %511 = OpSampledImage %318 %500 %503 -%512 = OpImageGather %27 %511 %507 %513 ConstOffset %34 +%512 = OpImageGather %25 %511 %507 %513 ConstOffset %34 %514 = OpSampledImage %452 %505 %504 -%515 = OpImageDrefGather %27 %514 %507 %305 +%515 = OpImageDrefGather %25 %514 %507 %305 %516 = OpSampledImage %452 %505 %504 -%517 = OpImageDrefGather %27 %516 %507 %305 ConstOffset %34 +%517 = OpImageDrefGather %25 %516 %507 %305 ConstOffset %34 %519 = OpSampledImage %518 %501 %503 -%520 = OpImageGather %18 %519 %507 %203 +%520 = OpImageGather %16 %519 %507 %203 %523 = OpSampledImage %522 %502 %503 %524 = OpImageGather %521 %523 %507 %203 -%525 = OpConvertUToF %27 %520 -%526 = OpConvertSToF %27 %524 -%527 = OpFAdd %27 %525 %526 -%528 = OpFAdd %27 %509 %512 -%529 = OpFAdd %27 %528 %515 -%530 = OpFAdd %27 %529 %517 -%531 = OpFAdd %27 %530 %527 +%525 = OpConvertUToF %25 %520 +%526 = OpConvertSToF %25 %524 +%527 = OpFAdd %25 %525 %526 +%528 = OpFAdd %25 %509 %512 +%529 = OpFAdd %25 %528 %515 +%530 = OpFAdd %25 %529 %517 +%531 = OpFAdd %25 %530 %527 OpStore %498 %531 OpReturn OpFunctionEnd %534 = OpFunction %2 None %83 %532 = OpLabel -%535 = OpLoad %28 %68 -%536 = OpLoad %31 %72 +%535 = OpLoad %26 %68 +%536 = OpLoad %29 %72 OpBranch %537 %537 = OpLabel -%538 = OpCompositeConstruct %29 %305 %305 +%538 = OpCompositeConstruct %27 %305 %305 %539 = OpSampledImage %452 %536 %535 -%540 = OpImageSampleImplicitLod %27 %539 %538 -%541 = OpCompositeExtract %10 %540 0 +%540 = OpImageSampleImplicitLod %25 %539 %538 +%541 = OpCompositeExtract %7 %540 0 %542 = OpSampledImage %452 %536 %535 -%543 = OpImageGather %27 %542 %538 %203 -%544 = OpCompositeConstruct %27 %541 %541 %541 %541 -%545 = OpFAdd %27 %544 %543 +%543 = OpImageGather %25 %542 %538 %203 +%544 = OpCompositeConstruct %25 %541 %541 %541 %541 +%545 = OpFAdd %25 %544 %543 OpStore %533 %545 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/interface.compute.spvasm b/tests/out/spv/interface.compute.spvasm index 533a3daa5f..df5e3edda4 100644 --- a/tests/out/spv/interface.compute.spvasm +++ b/tests/out/spv/interface.compute.spvasm @@ -7,61 +7,61 @@ OpCapability Shader OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %31 "compute" %19 %22 %24 %27 %29 OpExecutionMode %31 LocalSize 1 1 1 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 16 -OpMemberDecorate %9 0 Offset 0 -OpMemberDecorate %9 1 Offset 4 -OpMemberDecorate %9 2 Offset 8 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpMemberDecorate %7 2 Offset 8 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %13 0 Offset 0 OpDecorate %19 BuiltIn GlobalInvocationId OpDecorate %22 BuiltIn LocalInvocationId OpDecorate %24 BuiltIn LocalInvocationIndex OpDecorate %27 BuiltIn WorkgroupId OpDecorate %29 BuiltIn NumWorkgroups %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 1 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 4 -%7 = OpTypeStruct %5 %6 -%8 = OpTypeInt 32 0 -%9 = OpTypeStruct %6 %8 %6 -%10 = OpTypeBool -%12 = OpConstant %8 1 -%11 = OpTypeArray %8 %12 -%13 = OpTypeVector %8 3 -%14 = OpTypeStruct %8 -%15 = OpTypeStruct %8 -%17 = OpTypePointer Workgroup %11 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeStruct %3 %4 +%6 = OpTypeInt 32 0 +%7 = OpTypeStruct %4 %6 %4 +%8 = OpTypeBool +%10 = OpConstant %6 1 +%9 = OpTypeArray %6 %10 +%11 = OpTypeVector %6 3 +%12 = OpTypeStruct %6 +%13 = OpTypeStruct %6 +%15 = OpTypeInt 32 1 +%14 = OpConstant %15 1 +%17 = OpTypePointer Workgroup %9 %16 = OpVariable %17 Workgroup -%20 = OpTypePointer Input %13 +%20 = OpTypePointer Input %11 %19 = OpVariable %20 Input %22 = OpVariable %20 Input -%25 = OpTypePointer Input %8 +%25 = OpTypePointer Input %6 %24 = OpVariable %25 Input %27 = OpVariable %20 Input %29 = OpVariable %20 Input %32 = OpTypeFunction %2 -%34 = OpConstantNull %11 -%35 = OpConstantNull %13 -%36 = OpTypeVector %10 3 -%41 = OpConstant %8 2 -%42 = OpConstant %8 264 -%44 = OpTypePointer Workgroup %8 -%53 = OpConstant %8 0 +%34 = OpConstantNull %9 +%35 = OpConstantNull %11 +%36 = OpTypeVector %8 3 +%41 = OpConstant %6 2 +%42 = OpConstant %6 264 +%44 = OpTypePointer Workgroup %6 +%53 = OpConstant %6 0 %31 = OpFunction %2 None %32 %18 = OpLabel -%21 = OpLoad %13 %19 -%23 = OpLoad %13 %22 -%26 = OpLoad %8 %24 -%28 = OpLoad %13 %27 -%30 = OpLoad %13 %29 +%21 = OpLoad %11 %19 +%23 = OpLoad %11 %22 +%26 = OpLoad %6 %24 +%28 = OpLoad %11 %27 +%30 = OpLoad %11 %29 OpBranch %33 %33 = OpLabel %37 = OpIEqual %36 %23 %35 -%38 = OpAll %10 %37 +%38 = OpAll %8 %37 OpSelectionMerge %39 None OpBranchConditional %38 %40 %39 %40 = OpLabel @@ -71,14 +71,14 @@ OpBranch %39 OpControlBarrier %41 %41 %42 OpBranch %43 %43 = OpLabel -%45 = OpCompositeExtract %8 %21 0 -%46 = OpCompositeExtract %8 %23 0 -%47 = OpIAdd %8 %45 %46 -%48 = OpIAdd %8 %47 %26 -%49 = OpCompositeExtract %8 %28 0 -%50 = OpIAdd %8 %48 %49 -%51 = OpCompositeExtract %8 %30 0 -%52 = OpIAdd %8 %50 %51 +%45 = OpCompositeExtract %6 %21 0 +%46 = OpCompositeExtract %6 %23 0 +%47 = OpIAdd %6 %45 %46 +%48 = OpIAdd %6 %47 %26 +%49 = OpCompositeExtract %6 %28 0 +%50 = OpIAdd %6 %48 %49 +%51 = OpCompositeExtract %6 %30 0 +%52 = OpIAdd %6 %50 %51 %54 = OpAccessChain %44 %16 %53 OpStore %54 %52 OpReturn diff --git a/tests/out/spv/interface.fragment.spvasm b/tests/out/spv/interface.fragment.spvasm index 795ed31d70..6acbab9d78 100644 --- a/tests/out/spv/interface.fragment.spvasm +++ b/tests/out/spv/interface.fragment.spvasm @@ -9,14 +9,14 @@ OpMemoryModel Logical GLSL450 OpEntryPoint Fragment %37 "fragment" %18 %21 %24 %27 %30 %32 %34 %36 OpExecutionMode %37 OriginUpperLeft OpExecutionMode %37 DepthReplacing +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 16 -OpMemberDecorate %9 0 Offset 0 -OpMemberDecorate %9 1 Offset 4 -OpMemberDecorate %9 2 Offset 8 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpMemberDecorate %7 2 Offset 8 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %13 0 Offset 0 OpDecorate %18 Invariant OpDecorate %18 BuiltIn FragCoord OpDecorate %21 Location 1 @@ -30,59 +30,59 @@ OpDecorate %32 BuiltIn FragDepth OpDecorate %34 BuiltIn SampleMask OpDecorate %36 Location 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 1 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 4 -%7 = OpTypeStruct %5 %6 -%8 = OpTypeInt 32 0 -%9 = OpTypeStruct %6 %8 %6 -%10 = OpTypeBool -%12 = OpConstant %8 1 -%11 = OpTypeArray %8 %12 -%13 = OpTypeVector %8 3 -%14 = OpTypeStruct %8 -%15 = OpTypeStruct %8 -%19 = OpTypePointer Input %5 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeStruct %3 %4 +%6 = OpTypeInt 32 0 +%7 = OpTypeStruct %4 %6 %4 +%8 = OpTypeBool +%10 = OpConstant %6 1 +%9 = OpTypeArray %6 %10 +%11 = OpTypeVector %6 3 +%12 = OpTypeStruct %6 +%13 = OpTypeStruct %6 +%15 = OpTypeInt 32 1 +%14 = OpConstant %15 1 +%19 = OpTypePointer Input %3 %18 = OpVariable %19 Input -%22 = OpTypePointer Input %6 +%22 = OpTypePointer Input %4 %21 = OpVariable %22 Input -%25 = OpTypePointer Input %10 +%25 = OpTypePointer Input %8 %24 = OpVariable %25 Input -%28 = OpTypePointer Input %8 +%28 = OpTypePointer Input %6 %27 = OpVariable %28 Input %30 = OpVariable %28 Input -%33 = OpTypePointer Output %6 +%33 = OpTypePointer Output %4 %32 = OpVariable %33 Output -%35 = OpTypePointer Output %8 +%35 = OpTypePointer Output %6 %34 = OpVariable %35 Output %36 = OpVariable %33 Output %38 = OpTypeFunction %2 -%39 = OpConstant %6 0.0 -%40 = OpConstant %6 1.0 +%39 = OpConstant %4 0.0 +%40 = OpConstant %4 1.0 %37 = OpFunction %2 None %38 %16 = OpLabel -%20 = OpLoad %5 %18 -%23 = OpLoad %6 %21 -%17 = OpCompositeConstruct %7 %20 %23 -%26 = OpLoad %10 %24 -%29 = OpLoad %8 %27 -%31 = OpLoad %8 %30 +%20 = OpLoad %3 %18 +%23 = OpLoad %4 %21 +%17 = OpCompositeConstruct %5 %20 %23 +%26 = OpLoad %8 %24 +%29 = OpLoad %6 %27 +%31 = OpLoad %6 %30 OpBranch %41 %41 = OpLabel -%42 = OpShiftLeftLogical %8 %12 %29 -%43 = OpBitwiseAnd %8 %31 %42 -%44 = OpSelect %6 %26 %40 %39 -%45 = OpCompositeExtract %6 %17 1 -%46 = OpCompositeConstruct %9 %45 %43 %44 -%47 = OpCompositeExtract %6 %46 0 +%42 = OpShiftLeftLogical %6 %10 %29 +%43 = OpBitwiseAnd %6 %31 %42 +%44 = OpSelect %4 %26 %40 %39 +%45 = OpCompositeExtract %4 %17 1 +%46 = OpCompositeConstruct %7 %45 %43 %44 +%47 = OpCompositeExtract %4 %46 0 OpStore %32 %47 -%48 = OpLoad %6 %32 -%49 = OpExtInst %6 %1 FClamp %48 %39 %40 +%48 = OpLoad %4 %32 +%49 = OpExtInst %4 %1 FClamp %48 %39 %40 OpStore %32 %49 -%50 = OpCompositeExtract %8 %46 1 +%50 = OpCompositeExtract %6 %46 1 OpStore %34 %50 -%51 = OpCompositeExtract %6 %46 2 +%51 = OpCompositeExtract %4 %46 2 OpStore %36 %51 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 28b842dbef..6e930aa01a 100644 --- a/tests/out/spv/interface.vertex.spvasm +++ b/tests/out/spv/interface.vertex.spvasm @@ -6,14 +6,14 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %31 "vertex" %17 %20 %22 %24 %26 %28 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 16 -OpMemberDecorate %9 0 Offset 0 -OpMemberDecorate %9 1 Offset 4 -OpMemberDecorate %9 2 Offset 8 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpMemberDecorate %7 2 Offset 8 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %13 0 Offset 0 OpDecorate %17 BuiltIn VertexIndex OpDecorate %20 BuiltIn InstanceIndex OpDecorate %22 Location 10 @@ -22,47 +22,47 @@ OpDecorate %24 BuiltIn Position OpDecorate %26 Location 1 OpDecorate %28 BuiltIn PointSize %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 1 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 4 -%7 = OpTypeStruct %5 %6 -%8 = OpTypeInt 32 0 -%9 = OpTypeStruct %6 %8 %6 -%10 = OpTypeBool -%12 = OpConstant %8 1 -%11 = OpTypeArray %8 %12 -%13 = OpTypeVector %8 3 -%14 = OpTypeStruct %8 -%15 = OpTypeStruct %8 -%18 = OpTypePointer Input %8 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeStruct %3 %4 +%6 = OpTypeInt 32 0 +%7 = OpTypeStruct %4 %6 %4 +%8 = OpTypeBool +%10 = OpConstant %6 1 +%9 = OpTypeArray %6 %10 +%11 = OpTypeVector %6 3 +%12 = OpTypeStruct %6 +%13 = OpTypeStruct %6 +%15 = OpTypeInt 32 1 +%14 = OpConstant %15 1 +%18 = OpTypePointer Input %6 %17 = OpVariable %18 Input %20 = OpVariable %18 Input %22 = OpVariable %18 Input -%25 = OpTypePointer Output %5 +%25 = OpTypePointer Output %3 %24 = OpVariable %25 Output -%27 = OpTypePointer Output %6 +%27 = OpTypePointer Output %4 %26 = OpVariable %27 Output -%29 = OpTypePointer Output %6 +%29 = OpTypePointer Output %4 %28 = OpVariable %29 Output -%30 = OpConstant %6 1.0 +%30 = OpConstant %4 1.0 %32 = OpTypeFunction %2 %31 = OpFunction %2 None %32 %16 = OpLabel -%19 = OpLoad %8 %17 -%21 = OpLoad %8 %20 -%23 = OpLoad %8 %22 +%19 = OpLoad %6 %17 +%21 = OpLoad %6 %20 +%23 = OpLoad %6 %22 OpStore %28 %30 OpBranch %33 %33 = OpLabel -%34 = OpIAdd %8 %19 %21 -%35 = OpIAdd %8 %34 %23 -%36 = OpCompositeConstruct %5 %30 %30 %30 %30 -%37 = OpConvertUToF %6 %35 -%38 = OpCompositeConstruct %7 %36 %37 -%39 = OpCompositeExtract %5 %38 0 +%34 = OpIAdd %6 %19 %21 +%35 = OpIAdd %6 %34 %23 +%36 = OpCompositeConstruct %3 %30 %30 %30 %30 +%37 = OpConvertUToF %4 %35 +%38 = OpCompositeConstruct %5 %36 %37 +%39 = OpCompositeExtract %3 %38 0 OpStore %24 %39 -%40 = OpCompositeExtract %6 %38 1 +%40 = OpCompositeExtract %4 %38 1 OpStore %26 %40 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/interface.vertex_two_structs.spvasm b/tests/out/spv/interface.vertex_two_structs.spvasm index 5f555c0198..db2bf9b994 100644 --- a/tests/out/spv/interface.vertex_two_structs.spvasm +++ b/tests/out/spv/interface.vertex_two_structs.spvasm @@ -6,64 +6,64 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %32 "vertex_two_structs" %21 %25 %27 %29 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %5 1 Offset 16 OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 16 -OpMemberDecorate %9 0 Offset 0 -OpMemberDecorate %9 1 Offset 4 -OpMemberDecorate %9 2 Offset 8 -OpDecorate %11 ArrayStride 4 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %7 1 Offset 4 +OpMemberDecorate %7 2 Offset 8 +OpDecorate %9 ArrayStride 4 +OpMemberDecorate %12 0 Offset 0 +OpMemberDecorate %13 0 Offset 0 OpDecorate %21 BuiltIn VertexIndex OpDecorate %25 BuiltIn InstanceIndex OpDecorate %27 Invariant OpDecorate %27 BuiltIn Position OpDecorate %29 BuiltIn PointSize %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 1 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 4 -%7 = OpTypeStruct %5 %6 -%8 = OpTypeInt 32 0 -%9 = OpTypeStruct %6 %8 %6 -%10 = OpTypeBool -%12 = OpConstant %8 1 -%11 = OpTypeArray %8 %12 -%13 = OpTypeVector %8 3 -%14 = OpTypeStruct %8 -%15 = OpTypeStruct %8 -%17 = OpTypePointer Function %8 -%18 = OpConstantNull %8 -%22 = OpTypePointer Input %8 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%5 = OpTypeStruct %3 %4 +%6 = OpTypeInt 32 0 +%7 = OpTypeStruct %4 %6 %4 +%8 = OpTypeBool +%10 = OpConstant %6 1 +%9 = OpTypeArray %6 %10 +%11 = OpTypeVector %6 3 +%12 = OpTypeStruct %6 +%13 = OpTypeStruct %6 +%15 = OpTypeInt 32 1 +%14 = OpConstant %15 1 +%17 = OpTypePointer Function %6 +%18 = OpConstantNull %6 +%22 = OpTypePointer Input %6 %21 = OpVariable %22 Input %25 = OpVariable %22 Input -%28 = OpTypePointer Output %5 +%28 = OpTypePointer Output %3 %27 = OpVariable %28 Output -%30 = OpTypePointer Output %6 +%30 = OpTypePointer Output %4 %29 = OpVariable %30 Output -%31 = OpConstant %6 1.0 +%31 = OpConstant %4 1.0 %33 = OpTypeFunction %2 -%34 = OpConstant %8 2 -%35 = OpConstant %6 0.0 +%34 = OpConstant %6 2 +%35 = OpConstant %4 0.0 %32 = OpFunction %2 None %33 %19 = OpLabel %16 = OpVariable %17 Function %18 -%23 = OpLoad %8 %21 -%20 = OpCompositeConstruct %14 %23 -%26 = OpLoad %8 %25 -%24 = OpCompositeConstruct %15 %26 +%23 = OpLoad %6 %21 +%20 = OpCompositeConstruct %12 %23 +%26 = OpLoad %6 %25 +%24 = OpCompositeConstruct %13 %26 OpStore %29 %31 OpBranch %36 %36 = OpLabel OpStore %16 %34 -%37 = OpCompositeExtract %8 %20 0 -%38 = OpConvertUToF %6 %37 -%39 = OpCompositeExtract %8 %24 0 -%40 = OpConvertUToF %6 %39 -%41 = OpLoad %8 %16 -%42 = OpConvertUToF %6 %41 -%43 = OpCompositeConstruct %5 %38 %40 %42 %35 +%37 = OpCompositeExtract %6 %20 0 +%38 = OpConvertUToF %4 %37 +%39 = OpCompositeExtract %6 %24 0 +%40 = OpConvertUToF %4 %39 +%41 = OpLoad %6 %16 +%42 = OpConvertUToF %4 %41 +%43 = OpCompositeConstruct %3 %38 %40 %42 %35 OpStore %27 %43 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/operators.spvasm b/tests/out/spv/operators.spvasm index 783b789c29..22a67029cd 100644 --- a/tests/out/spv/operators.spvasm +++ b/tests/out/spv/operators.spvasm @@ -1,655 +1,592 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 591 +; Bound: 530 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %579 "main" -OpExecutionMode %579 LocalSize 1 1 1 -OpMemberDecorate %17 0 Offset 0 -OpMemberDecorate %17 1 Offset 16 -OpDecorate %22 ArrayStride 32 -OpDecorate %24 ArrayStride 4 +OpEntryPoint GLCompute %519 "main" +OpExecutionMode %519 LocalSize 1 1 1 %2 = OpTypeVoid %4 = OpTypeFloat 32 -%3 = OpConstant %4 1.0 -%5 = OpConstant %4 0.0 -%6 = OpConstant %4 0.5 -%8 = OpTypeInt 32 1 -%7 = OpConstant %8 1 -%9 = OpConstant %8 3 -%10 = OpTypeVector %4 4 -%11 = OpTypeVector %8 4 -%13 = OpTypeBool -%12 = OpTypeVector %13 4 -%14 = OpTypeVector %4 2 -%15 = OpTypeVector %4 3 -%16 = OpTypeVector %13 3 -%17 = OpTypeStruct %10 %8 -%18 = OpTypeMatrix %14 2 -%19 = OpTypeMatrix %10 4 -%20 = OpTypeInt 32 0 -%21 = OpTypeVector %20 2 -%23 = OpConstant %20 3 -%22 = OpTypeArray %17 %23 -%25 = OpConstant %20 4 -%24 = OpTypeArray %8 %25 -%26 = OpTypeMatrix %15 2 -%27 = OpTypeMatrix %15 3 -%28 = OpTypeMatrix %15 4 -%29 = OpTypeMatrix %10 3 -%30 = OpTypeVector %8 3 -%31 = OpConstantComposite %10 %3 %3 %3 %3 -%32 = OpConstantComposite %10 %5 %5 %5 %5 -%33 = OpConstantComposite %10 %6 %6 %6 %6 -%34 = OpConstantComposite %11 %7 %7 %7 %7 -%37 = OpTypeFunction %10 -%38 = OpConstantTrue %13 -%39 = OpConstant %8 0 -%40 = OpConstantFalse %13 -%41 = OpConstant %4 0.1 -%66 = OpConstant %4 2.0 -%67 = OpConstant %4 3.0 -%68 = OpConstant %4 4.0 -%69 = OpConstant %8 5 -%70 = OpConstant %8 2 -%86 = OpTypePointer Function %14 -%87 = OpConstantNull %14 -%90 = OpTypeFunction %14 -%106 = OpTypeFunction %15 %15 -%108 = OpConstantComposite %15 %5 %5 %5 -%110 = OpConstantComposite %15 %3 %3 %3 -%113 = OpTypePointer Function %17 -%114 = OpConstantNull %17 -%117 = OpTypeFunction %4 -%118 = OpConstantNull %13 -%119 = OpConstantNull %8 -%120 = OpConstantNull %20 -%121 = OpConstantNull %4 -%122 = OpConstantNull %21 -%123 = OpConstantNull %18 -%124 = OpConstantNull %22 -%125 = OpConstantNull %17 -%126 = OpConstant %20 0 -%127 = OpConstantNull %13 -%128 = OpConstantNull %8 -%129 = OpConstantNull %20 -%130 = OpConstantNull %4 -%131 = OpConstantNull %21 -%132 = OpConstantNull %26 -%133 = OpConstantNull %21 -%134 = OpConstantNull %26 -%159 = OpTypePointer Function %10 -%160 = OpTypePointer Function %4 -%165 = OpTypeFunction %2 -%168 = OpTypeVector %13 2 -%183 = OpConstant %4 -1.0 -%184 = OpConstant %20 2 -%185 = OpConstant %20 1 -%186 = OpConstantNull %27 -%187 = OpConstantNull %27 -%188 = OpConstantNull %27 -%189 = OpConstantNull %27 -%190 = OpConstantNull %27 -%191 = OpConstantNull %27 -%192 = OpConstantNull %28 -%193 = OpConstantNull %28 -%194 = OpConstantNull %28 -%195 = OpConstantNull %29 -%197 = OpTypeVector %8 2 -%208 = OpTypeVector %20 3 -%505 = OpTypePointer Function %8 -%506 = OpConstantNull %8 -%508 = OpTypePointer Function %30 -%509 = OpConstantNull %30 -%512 = OpConstantNull %30 -%540 = OpTypePointer Function %8 -%551 = OpConstant %8 -1 -%552 = OpConstant %8 -2 -%553 = OpConstant %8 -3 -%554 = OpConstant %8 4 -%555 = OpConstant %8 -5 -%556 = OpConstant %8 6 -%557 = OpConstant %8 -7 -%558 = OpConstant %8 -8 -%36 = OpFunction %10 None %37 -%35 = OpLabel -OpBranch %42 -%42 = OpLabel -%43 = OpSelect %8 %38 %7 %39 -%45 = OpCompositeConstruct %12 %38 %38 %38 %38 -%44 = OpSelect %10 %45 %31 %32 -%46 = OpCompositeConstruct %12 %40 %40 %40 %40 -%47 = OpSelect %10 %46 %32 %31 -%48 = OpExtInst %10 %1 FMix %32 %31 %33 -%50 = OpCompositeConstruct %10 %41 %41 %41 %41 -%49 = OpExtInst %10 %1 FMix %32 %31 %50 -%51 = OpCompositeExtract %8 %34 0 -%52 = OpBitcast %4 %51 -%53 = OpBitcast %10 %34 -%54 = OpConvertFToS %11 %32 -%55 = OpCompositeConstruct %11 %43 %43 %43 %43 -%56 = OpIAdd %11 %55 %54 -%57 = OpConvertSToF %10 %56 -%58 = OpFAdd %10 %57 %44 -%59 = OpFAdd %10 %58 %48 -%60 = OpFAdd %10 %59 %49 -%61 = OpCompositeConstruct %10 %52 %52 %52 %52 -%62 = OpFAdd %10 %60 %61 -%63 = OpFAdd %10 %62 %53 -OpReturnValue %63 +%3 = OpTypeVector %4 4 +%6 = OpTypeInt 32 1 +%5 = OpTypeVector %6 4 +%8 = OpTypeBool +%7 = OpTypeVector %8 4 +%9 = OpTypeVector %4 2 +%10 = OpTypeVector %4 3 +%11 = OpTypeVector %8 3 +%12 = OpTypeMatrix %10 3 +%13 = OpTypeMatrix %10 4 +%14 = OpTypeMatrix %3 3 +%15 = OpTypeVector %6 3 +%16 = OpConstant %4 1.0 +%17 = OpConstantComposite %3 %16 %16 %16 %16 +%18 = OpConstant %4 0.0 +%19 = OpConstantComposite %3 %18 %18 %18 %18 +%20 = OpConstant %4 0.5 +%21 = OpConstantComposite %3 %20 %20 %20 %20 +%22 = OpConstant %6 1 +%23 = OpConstantComposite %5 %22 %22 %22 %22 +%26 = OpTypeFunction %3 +%27 = OpConstantTrue %8 +%28 = OpConstant %6 0 +%29 = OpConstantFalse %8 +%30 = OpConstant %4 0.1 +%55 = OpConstant %4 2.0 +%56 = OpConstant %4 3.0 +%57 = OpConstant %4 4.0 +%58 = OpConstant %6 5 +%59 = OpConstant %6 2 +%75 = OpTypePointer Function %9 +%76 = OpConstantNull %9 +%79 = OpTypeFunction %9 +%95 = OpTypeFunction %10 %10 +%97 = OpConstantComposite %10 %18 %18 %18 +%99 = OpConstantComposite %10 %16 %16 %16 +%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 %12 +%126 = OpConstantNull %12 +%127 = OpConstantNull %12 +%128 = OpConstantNull %12 +%129 = OpConstantNull %12 +%130 = OpConstantNull %12 +%131 = OpConstantNull %13 +%132 = OpConstantNull %13 +%133 = OpConstantNull %13 +%134 = OpConstantNull %14 +%136 = OpTypeVector %6 2 +%147 = OpTypeVector %122 3 +%210 = OpTypeVector %122 2 +%445 = OpTypePointer Function %6 +%446 = OpConstantNull %6 +%448 = OpTypePointer Function %15 +%449 = OpConstantNull %15 +%452 = OpConstantNull %15 +%480 = OpTypePointer Function %6 +%491 = OpConstant %6 -1 +%492 = OpConstant %6 -2 +%493 = OpConstant %6 -3 +%494 = OpConstant %6 4 +%495 = OpConstant %6 -5 +%496 = OpConstant %6 6 +%497 = OpConstant %6 -7 +%498 = OpConstant %6 -8 +%25 = OpFunction %3 None %26 +%24 = OpLabel +OpBranch %31 +%31 = OpLabel +%32 = OpSelect %6 %27 %22 %28 +%34 = OpCompositeConstruct %7 %27 %27 %27 %27 +%33 = OpSelect %3 %34 %17 %19 +%35 = OpCompositeConstruct %7 %29 %29 %29 %29 +%36 = OpSelect %3 %35 %19 %17 +%37 = OpExtInst %3 %1 FMix %19 %17 %21 +%39 = OpCompositeConstruct %3 %30 %30 %30 %30 +%38 = OpExtInst %3 %1 FMix %19 %17 %39 +%40 = OpCompositeExtract %6 %23 0 +%41 = OpBitcast %4 %40 +%42 = OpBitcast %3 %23 +%43 = OpConvertFToS %5 %19 +%44 = OpCompositeConstruct %5 %32 %32 %32 %32 +%45 = OpIAdd %5 %44 %43 +%46 = OpConvertSToF %3 %45 +%47 = OpFAdd %3 %46 %33 +%48 = OpFAdd %3 %47 %37 +%49 = OpFAdd %3 %48 %38 +%50 = OpCompositeConstruct %3 %41 %41 %41 %41 +%51 = OpFAdd %3 %49 %50 +%52 = OpFAdd %3 %51 %42 +OpReturnValue %52 OpFunctionEnd -%65 = OpFunction %10 None %37 -%64 = OpLabel -OpBranch %71 -%71 = OpLabel -%72 = OpCompositeConstruct %14 %66 %66 -%73 = OpCompositeConstruct %14 %3 %3 -%74 = OpFAdd %14 %73 %72 -%75 = OpCompositeConstruct %14 %67 %67 -%76 = OpFSub %14 %74 %75 -%77 = OpCompositeConstruct %14 %68 %68 -%78 = OpFDiv %14 %76 %77 -%79 = OpCompositeConstruct %11 %69 %69 %69 %69 -%80 = OpCompositeConstruct %11 %70 %70 %70 %70 -%81 = OpSRem %11 %79 %80 -%82 = OpVectorShuffle %10 %78 %78 0 1 0 1 -%83 = OpConvertSToF %10 %81 -%84 = OpFAdd %10 %82 %83 -OpReturnValue %84 +%54 = OpFunction %3 None %26 +%53 = OpLabel +OpBranch %60 +%60 = OpLabel +%61 = OpCompositeConstruct %9 %55 %55 +%62 = OpCompositeConstruct %9 %16 %16 +%63 = OpFAdd %9 %62 %61 +%64 = OpCompositeConstruct %9 %56 %56 +%65 = OpFSub %9 %63 %64 +%66 = OpCompositeConstruct %9 %57 %57 +%67 = OpFDiv %9 %65 %66 +%68 = OpCompositeConstruct %5 %58 %58 %58 %58 +%69 = OpCompositeConstruct %5 %59 %59 %59 %59 +%70 = OpSRem %5 %68 %69 +%71 = OpVectorShuffle %3 %67 %67 0 1 0 1 +%72 = OpConvertSToF %3 %70 +%73 = OpFAdd %3 %71 %72 +OpReturnValue %73 OpFunctionEnd -%89 = OpFunction %14 None %90 -%88 = OpLabel -%85 = OpVariable %86 Function %87 -OpBranch %91 -%91 = OpLabel -%92 = OpCompositeConstruct %14 %66 %66 -OpStore %85 %92 -%93 = OpLoad %14 %85 -%94 = OpCompositeConstruct %14 %3 %3 -%95 = OpFAdd %14 %93 %94 -OpStore %85 %95 -%96 = OpLoad %14 %85 -%97 = OpCompositeConstruct %14 %67 %67 -%98 = OpFSub %14 %96 %97 -OpStore %85 %98 -%99 = OpLoad %14 %85 -%100 = OpCompositeConstruct %14 %68 %68 -%101 = OpFDiv %14 %99 %100 -OpStore %85 %101 -%102 = OpLoad %14 %85 -OpReturnValue %102 +%78 = OpFunction %9 None %79 +%77 = OpLabel +%74 = OpVariable %75 Function %76 +OpBranch %80 +%80 = OpLabel +%81 = OpCompositeConstruct %9 %55 %55 +OpStore %74 %81 +%82 = OpLoad %9 %74 +%83 = OpCompositeConstruct %9 %16 %16 +%84 = OpFAdd %9 %82 %83 +OpStore %74 %84 +%85 = OpLoad %9 %74 +%86 = OpCompositeConstruct %9 %56 %56 +%87 = OpFSub %9 %85 %86 +OpStore %74 %87 +%88 = OpLoad %9 %74 +%89 = OpCompositeConstruct %9 %57 %57 +%90 = OpFDiv %9 %88 %89 +OpStore %74 %90 +%91 = OpLoad %9 %74 +OpReturnValue %91 OpFunctionEnd -%105 = OpFunction %15 None %106 -%104 = OpFunctionParameter %15 -%103 = OpLabel -OpBranch %107 -%107 = OpLabel -%109 = OpFUnordNotEqual %16 %104 %108 -%111 = OpSelect %15 %109 %110 %108 -OpReturnValue %111 +%94 = OpFunction %10 None %95 +%93 = OpFunctionParameter %10 +%92 = OpLabel +OpBranch %96 +%96 = OpLabel +%98 = OpFUnordNotEqual %11 %93 %97 +%100 = OpSelect %10 %98 %99 %97 +OpReturnValue %100 OpFunctionEnd -%116 = OpFunction %4 None %117 -%115 = OpLabel -%112 = OpVariable %113 Function %114 -OpBranch %135 -%135 = OpLabel -%136 = OpCompositeConstruct %10 %3 %3 %3 %3 -%137 = OpCompositeConstruct %17 %136 %7 -OpStore %112 %137 -%138 = OpCompositeConstruct %14 %3 %5 -%139 = OpCompositeConstruct %14 %5 %3 -%140 = OpCompositeConstruct %18 %138 %139 -%141 = OpCompositeConstruct %10 %3 %5 %5 %5 -%142 = OpCompositeConstruct %10 %5 %3 %5 %5 -%143 = OpCompositeConstruct %10 %5 %5 %3 %5 -%144 = OpCompositeConstruct %10 %5 %5 %5 %3 -%145 = OpCompositeConstruct %19 %141 %142 %143 %144 -%146 = OpCompositeConstruct %21 %126 %126 -%147 = OpCompositeConstruct %14 %5 %5 -%148 = OpCompositeConstruct %14 %5 %5 -%149 = OpCompositeConstruct %18 %147 %148 -%150 = OpCompositeConstruct %24 %39 %7 %70 %9 -%156 = OpCopyObject %26 %132 -%158 = OpCopyObject %26 %134 -%161 = OpAccessChain %160 %112 %126 %126 -%162 = OpLoad %4 %161 -OpReturnValue %162 -OpFunctionEnd -%164 = OpFunction %2 None %165 -%163 = OpLabel -OpBranch %166 -%166 = OpLabel -%167 = OpLogicalNot %13 %38 -%169 = OpCompositeConstruct %168 %38 %38 -%170 = OpLogicalNot %168 %169 -%171 = OpLogicalOr %13 %38 %40 -%172 = OpLogicalAnd %13 %38 %40 -%173 = OpLogicalOr %13 %38 %40 -%174 = OpCompositeConstruct %16 %38 %38 %38 -%175 = OpCompositeConstruct %16 %40 %40 %40 -%176 = OpLogicalOr %16 %174 %175 -%177 = OpLogicalAnd %13 %38 %40 -%178 = OpCompositeConstruct %12 %38 %38 %38 %38 -%179 = OpCompositeConstruct %12 %40 %40 %40 %40 -%180 = OpLogicalAnd %12 %178 %179 +%102 = OpFunction %2 None %103 +%101 = OpLabel +OpBranch %104 +%104 = OpLabel +%105 = OpLogicalNot %8 %27 +%107 = OpCompositeConstruct %106 %27 %27 +%108 = OpLogicalNot %106 %107 +%109 = OpLogicalOr %8 %27 %29 +%110 = OpLogicalAnd %8 %27 %29 +%111 = OpLogicalOr %8 %27 %29 +%112 = OpCompositeConstruct %11 %27 %27 %27 +%113 = OpCompositeConstruct %11 %29 %29 %29 +%114 = OpLogicalOr %11 %112 %113 +%115 = OpLogicalAnd %8 %27 %29 +%116 = OpCompositeConstruct %7 %27 %27 %27 %27 +%117 = OpCompositeConstruct %7 %29 %29 %29 %29 +%118 = OpLogicalAnd %7 %116 %117 OpReturn OpFunctionEnd -%182 = OpFunction %2 None %165 -%181 = OpLabel -OpBranch %196 -%196 = OpLabel -%198 = OpCompositeConstruct %197 %7 %7 -%199 = OpSNegate %197 %198 -%200 = OpCompositeConstruct %14 %3 %3 -%201 = OpFNegate %14 %200 -%202 = OpIAdd %8 %70 %7 -%203 = OpIAdd %20 %184 %185 -%204 = OpFAdd %4 %66 %3 -%205 = OpCompositeConstruct %197 %70 %70 -%206 = OpCompositeConstruct %197 %7 %7 -%207 = OpIAdd %197 %205 %206 -%209 = OpCompositeConstruct %208 %184 %184 %184 -%210 = OpCompositeConstruct %208 %185 %185 %185 -%211 = OpIAdd %208 %209 %210 -%212 = OpCompositeConstruct %10 %66 %66 %66 %66 -%213 = OpCompositeConstruct %10 %3 %3 %3 %3 -%214 = OpFAdd %10 %212 %213 -%215 = OpISub %8 %70 %7 -%216 = OpISub %20 %184 %185 -%217 = OpFSub %4 %66 %3 -%218 = OpCompositeConstruct %197 %70 %70 -%219 = OpCompositeConstruct %197 %7 %7 -%220 = OpISub %197 %218 %219 -%221 = OpCompositeConstruct %208 %184 %184 %184 -%222 = OpCompositeConstruct %208 %185 %185 %185 -%223 = OpISub %208 %221 %222 -%224 = OpCompositeConstruct %10 %66 %66 %66 %66 -%225 = OpCompositeConstruct %10 %3 %3 %3 %3 -%226 = OpFSub %10 %224 %225 -%227 = OpIMul %8 %70 %7 -%228 = OpIMul %20 %184 %185 -%229 = OpFMul %4 %66 %3 -%230 = OpCompositeConstruct %197 %70 %70 -%231 = OpCompositeConstruct %197 %7 %7 -%232 = OpIMul %197 %230 %231 -%233 = OpCompositeConstruct %208 %184 %184 %184 -%234 = OpCompositeConstruct %208 %185 %185 %185 -%235 = OpIMul %208 %233 %234 -%236 = OpCompositeConstruct %10 %66 %66 %66 %66 -%237 = OpCompositeConstruct %10 %3 %3 %3 %3 -%238 = OpFMul %10 %236 %237 -%239 = OpSDiv %8 %70 %7 -%240 = OpUDiv %20 %184 %185 -%241 = OpFDiv %4 %66 %3 -%242 = OpCompositeConstruct %197 %70 %70 -%243 = OpCompositeConstruct %197 %7 %7 -%244 = OpSDiv %197 %242 %243 -%245 = OpCompositeConstruct %208 %184 %184 %184 -%246 = OpCompositeConstruct %208 %185 %185 %185 -%247 = OpUDiv %208 %245 %246 -%248 = OpCompositeConstruct %10 %66 %66 %66 %66 -%249 = OpCompositeConstruct %10 %3 %3 %3 %3 -%250 = OpFDiv %10 %248 %249 -%251 = OpSRem %8 %70 %7 -%252 = OpUMod %20 %184 %185 -%253 = OpFRem %4 %66 %3 -%254 = OpCompositeConstruct %197 %70 %70 -%255 = OpCompositeConstruct %197 %7 %7 -%256 = OpSRem %197 %254 %255 -%257 = OpCompositeConstruct %208 %184 %184 %184 -%258 = OpCompositeConstruct %208 %185 %185 %185 -%259 = OpUMod %208 %257 %258 -%260 = OpCompositeConstruct %10 %66 %66 %66 %66 -%261 = OpCompositeConstruct %10 %3 %3 %3 %3 -%262 = OpFRem %10 %260 %261 -OpBranch %263 -%263 = OpLabel -%265 = OpCompositeConstruct %197 %70 %70 -%266 = OpCompositeConstruct %197 %7 %7 -%267 = OpIAdd %197 %265 %266 -%268 = OpCompositeConstruct %197 %7 %7 -%269 = OpCompositeConstruct %197 %70 %70 -%270 = OpIAdd %197 %269 %268 -%271 = OpCompositeConstruct %21 %184 %184 -%272 = OpCompositeConstruct %21 %185 %185 -%273 = OpIAdd %21 %271 %272 -%274 = OpCompositeConstruct %21 %185 %185 -%275 = OpCompositeConstruct %21 %184 %184 -%276 = OpIAdd %21 %275 %274 -%277 = OpCompositeConstruct %14 %66 %66 -%278 = OpCompositeConstruct %14 %3 %3 -%279 = OpFAdd %14 %277 %278 -%280 = OpCompositeConstruct %14 %3 %3 -%281 = OpCompositeConstruct %14 %66 %66 -%282 = OpFAdd %14 %281 %280 -%283 = OpCompositeConstruct %197 %70 %70 -%284 = OpCompositeConstruct %197 %7 %7 -%285 = OpISub %197 %283 %284 -%286 = OpCompositeConstruct %197 %7 %7 -%287 = OpCompositeConstruct %197 %70 %70 -%288 = OpISub %197 %287 %286 -%289 = OpCompositeConstruct %21 %184 %184 -%290 = OpCompositeConstruct %21 %185 %185 -%291 = OpISub %21 %289 %290 -%292 = OpCompositeConstruct %21 %185 %185 -%293 = OpCompositeConstruct %21 %184 %184 -%294 = OpISub %21 %293 %292 -%295 = OpCompositeConstruct %14 %66 %66 -%296 = OpCompositeConstruct %14 %3 %3 -%297 = OpFSub %14 %295 %296 -%298 = OpCompositeConstruct %14 %3 %3 -%299 = OpCompositeConstruct %14 %66 %66 -%300 = OpFSub %14 %299 %298 -%301 = OpCompositeConstruct %197 %70 %70 -%303 = OpCompositeConstruct %197 %7 %7 -%302 = OpIMul %197 %301 %303 -%304 = OpCompositeConstruct %197 %7 %7 -%306 = OpCompositeConstruct %197 %70 %70 -%305 = OpIMul %197 %304 %306 -%307 = OpCompositeConstruct %21 %184 %184 -%309 = OpCompositeConstruct %21 %185 %185 -%308 = OpIMul %21 %307 %309 -%310 = OpCompositeConstruct %21 %185 %185 -%312 = OpCompositeConstruct %21 %184 %184 -%311 = OpIMul %21 %310 %312 -%313 = OpCompositeConstruct %14 %66 %66 -%314 = OpVectorTimesScalar %14 %313 %3 -%315 = OpCompositeConstruct %14 %3 %3 -%316 = OpVectorTimesScalar %14 %315 %66 -%317 = OpCompositeConstruct %197 %70 %70 -%318 = OpCompositeConstruct %197 %7 %7 -%319 = OpSDiv %197 %317 %318 -%320 = OpCompositeConstruct %197 %7 %7 -%321 = OpCompositeConstruct %197 %70 %70 -%322 = OpSDiv %197 %321 %320 -%323 = OpCompositeConstruct %21 %184 %184 -%324 = OpCompositeConstruct %21 %185 %185 -%325 = OpUDiv %21 %323 %324 -%326 = OpCompositeConstruct %21 %185 %185 -%327 = OpCompositeConstruct %21 %184 %184 -%328 = OpUDiv %21 %327 %326 -%329 = OpCompositeConstruct %14 %66 %66 -%330 = OpCompositeConstruct %14 %3 %3 -%331 = OpFDiv %14 %329 %330 -%332 = OpCompositeConstruct %14 %3 %3 -%333 = OpCompositeConstruct %14 %66 %66 -%334 = OpFDiv %14 %333 %332 -%335 = OpCompositeConstruct %197 %70 %70 -%336 = OpCompositeConstruct %197 %7 %7 -%337 = OpSRem %197 %335 %336 -%338 = OpCompositeConstruct %197 %7 %7 -%339 = OpCompositeConstruct %197 %70 %70 -%340 = OpSRem %197 %339 %338 -%341 = OpCompositeConstruct %21 %184 %184 -%342 = OpCompositeConstruct %21 %185 %185 -%343 = OpUMod %21 %341 %342 -%344 = OpCompositeConstruct %21 %185 %185 -%345 = OpCompositeConstruct %21 %184 %184 -%346 = OpUMod %21 %345 %344 -%347 = OpCompositeConstruct %14 %66 %66 -%348 = OpCompositeConstruct %14 %3 %3 -%349 = OpFRem %14 %347 %348 -%350 = OpCompositeConstruct %14 %3 %3 -%351 = OpCompositeConstruct %14 %66 %66 -%352 = OpFRem %14 %351 %350 -OpBranch %264 -%264 = OpLabel -%354 = OpCompositeExtract %15 %186 0 -%355 = OpCompositeExtract %15 %187 0 -%356 = OpFAdd %15 %354 %355 -%357 = OpCompositeExtract %15 %186 1 -%358 = OpCompositeExtract %15 %187 1 -%359 = OpFAdd %15 %357 %358 -%360 = OpCompositeExtract %15 %186 2 -%361 = OpCompositeExtract %15 %187 2 -%362 = OpFAdd %15 %360 %361 -%353 = OpCompositeConstruct %27 %356 %359 %362 -%364 = OpCompositeExtract %15 %188 0 -%365 = OpCompositeExtract %15 %189 0 -%366 = OpFSub %15 %364 %365 -%367 = OpCompositeExtract %15 %188 1 -%368 = OpCompositeExtract %15 %189 1 -%369 = OpFSub %15 %367 %368 -%370 = OpCompositeExtract %15 %188 2 -%371 = OpCompositeExtract %15 %189 2 -%372 = OpFSub %15 %370 %371 -%363 = OpCompositeConstruct %27 %366 %369 %372 -%373 = OpMatrixTimesScalar %27 %190 %3 -%374 = OpMatrixTimesScalar %27 %191 %66 -%375 = OpCompositeConstruct %10 %3 %3 %3 %3 -%376 = OpMatrixTimesVector %15 %192 %375 -%377 = OpCompositeConstruct %15 %66 %66 %66 -%378 = OpVectorTimesMatrix %10 %377 %193 -%379 = OpMatrixTimesMatrix %27 %194 %195 +%120 = OpFunction %2 None %103 +%119 = OpLabel +OpBranch %135 +%135 = OpLabel +%137 = OpCompositeConstruct %136 %22 %22 +%138 = OpSNegate %136 %137 +%139 = OpCompositeConstruct %9 %16 %16 +%140 = OpFNegate %9 %139 +%141 = OpIAdd %6 %59 %22 +%142 = OpIAdd %122 %123 %124 +%143 = OpFAdd %4 %55 %16 +%144 = OpCompositeConstruct %136 %59 %59 +%145 = OpCompositeConstruct %136 %22 %22 +%146 = OpIAdd %136 %144 %145 +%148 = OpCompositeConstruct %147 %123 %123 %123 +%149 = OpCompositeConstruct %147 %124 %124 %124 +%150 = OpIAdd %147 %148 %149 +%151 = OpCompositeConstruct %3 %55 %55 %55 %55 +%152 = OpCompositeConstruct %3 %16 %16 %16 %16 +%153 = OpFAdd %3 %151 %152 +%154 = OpISub %6 %59 %22 +%155 = OpISub %122 %123 %124 +%156 = OpFSub %4 %55 %16 +%157 = OpCompositeConstruct %136 %59 %59 +%158 = OpCompositeConstruct %136 %22 %22 +%159 = OpISub %136 %157 %158 +%160 = OpCompositeConstruct %147 %123 %123 %123 +%161 = OpCompositeConstruct %147 %124 %124 %124 +%162 = OpISub %147 %160 %161 +%163 = OpCompositeConstruct %3 %55 %55 %55 %55 +%164 = OpCompositeConstruct %3 %16 %16 %16 %16 +%165 = OpFSub %3 %163 %164 +%166 = OpIMul %6 %59 %22 +%167 = OpIMul %122 %123 %124 +%168 = OpFMul %4 %55 %16 +%169 = OpCompositeConstruct %136 %59 %59 +%170 = OpCompositeConstruct %136 %22 %22 +%171 = OpIMul %136 %169 %170 +%172 = OpCompositeConstruct %147 %123 %123 %123 +%173 = OpCompositeConstruct %147 %124 %124 %124 +%174 = OpIMul %147 %172 %173 +%175 = OpCompositeConstruct %3 %55 %55 %55 %55 +%176 = OpCompositeConstruct %3 %16 %16 %16 %16 +%177 = OpFMul %3 %175 %176 +%178 = OpSDiv %6 %59 %22 +%179 = OpUDiv %122 %123 %124 +%180 = OpFDiv %4 %55 %16 +%181 = OpCompositeConstruct %136 %59 %59 +%182 = OpCompositeConstruct %136 %22 %22 +%183 = OpSDiv %136 %181 %182 +%184 = OpCompositeConstruct %147 %123 %123 %123 +%185 = OpCompositeConstruct %147 %124 %124 %124 +%186 = OpUDiv %147 %184 %185 +%187 = OpCompositeConstruct %3 %55 %55 %55 %55 +%188 = OpCompositeConstruct %3 %16 %16 %16 %16 +%189 = OpFDiv %3 %187 %188 +%190 = OpSRem %6 %59 %22 +%191 = OpUMod %122 %123 %124 +%192 = OpFRem %4 %55 %16 +%193 = OpCompositeConstruct %136 %59 %59 +%194 = OpCompositeConstruct %136 %22 %22 +%195 = OpSRem %136 %193 %194 +%196 = OpCompositeConstruct %147 %123 %123 %123 +%197 = OpCompositeConstruct %147 %124 %124 %124 +%198 = OpUMod %147 %196 %197 +%199 = OpCompositeConstruct %3 %55 %55 %55 %55 +%200 = OpCompositeConstruct %3 %16 %16 %16 %16 +%201 = OpFRem %3 %199 %200 +OpBranch %202 +%202 = OpLabel +%204 = OpCompositeConstruct %136 %59 %59 +%205 = OpCompositeConstruct %136 %22 %22 +%206 = OpIAdd %136 %204 %205 +%207 = OpCompositeConstruct %136 %22 %22 +%208 = OpCompositeConstruct %136 %59 %59 +%209 = OpIAdd %136 %208 %207 +%211 = OpCompositeConstruct %210 %123 %123 +%212 = OpCompositeConstruct %210 %124 %124 +%213 = OpIAdd %210 %211 %212 +%214 = OpCompositeConstruct %210 %124 %124 +%215 = OpCompositeConstruct %210 %123 %123 +%216 = OpIAdd %210 %215 %214 +%217 = OpCompositeConstruct %9 %55 %55 +%218 = OpCompositeConstruct %9 %16 %16 +%219 = OpFAdd %9 %217 %218 +%220 = OpCompositeConstruct %9 %16 %16 +%221 = OpCompositeConstruct %9 %55 %55 +%222 = OpFAdd %9 %221 %220 +%223 = OpCompositeConstruct %136 %59 %59 +%224 = OpCompositeConstruct %136 %22 %22 +%225 = OpISub %136 %223 %224 +%226 = OpCompositeConstruct %136 %22 %22 +%227 = OpCompositeConstruct %136 %59 %59 +%228 = OpISub %136 %227 %226 +%229 = OpCompositeConstruct %210 %123 %123 +%230 = OpCompositeConstruct %210 %124 %124 +%231 = OpISub %210 %229 %230 +%232 = OpCompositeConstruct %210 %124 %124 +%233 = OpCompositeConstruct %210 %123 %123 +%234 = OpISub %210 %233 %232 +%235 = OpCompositeConstruct %9 %55 %55 +%236 = OpCompositeConstruct %9 %16 %16 +%237 = OpFSub %9 %235 %236 +%238 = OpCompositeConstruct %9 %16 %16 +%239 = OpCompositeConstruct %9 %55 %55 +%240 = OpFSub %9 %239 %238 +%241 = OpCompositeConstruct %136 %59 %59 +%243 = OpCompositeConstruct %136 %22 %22 +%242 = OpIMul %136 %241 %243 +%244 = OpCompositeConstruct %136 %22 %22 +%246 = OpCompositeConstruct %136 %59 %59 +%245 = OpIMul %136 %244 %246 +%247 = OpCompositeConstruct %210 %123 %123 +%249 = OpCompositeConstruct %210 %124 %124 +%248 = OpIMul %210 %247 %249 +%250 = OpCompositeConstruct %210 %124 %124 +%252 = OpCompositeConstruct %210 %123 %123 +%251 = OpIMul %210 %250 %252 +%253 = OpCompositeConstruct %9 %55 %55 +%254 = OpVectorTimesScalar %9 %253 %16 +%255 = OpCompositeConstruct %9 %16 %16 +%256 = OpVectorTimesScalar %9 %255 %55 +%257 = OpCompositeConstruct %136 %59 %59 +%258 = OpCompositeConstruct %136 %22 %22 +%259 = OpSDiv %136 %257 %258 +%260 = OpCompositeConstruct %136 %22 %22 +%261 = OpCompositeConstruct %136 %59 %59 +%262 = OpSDiv %136 %261 %260 +%263 = OpCompositeConstruct %210 %123 %123 +%264 = OpCompositeConstruct %210 %124 %124 +%265 = OpUDiv %210 %263 %264 +%266 = OpCompositeConstruct %210 %124 %124 +%267 = OpCompositeConstruct %210 %123 %123 +%268 = OpUDiv %210 %267 %266 +%269 = OpCompositeConstruct %9 %55 %55 +%270 = OpCompositeConstruct %9 %16 %16 +%271 = OpFDiv %9 %269 %270 +%272 = OpCompositeConstruct %9 %16 %16 +%273 = OpCompositeConstruct %9 %55 %55 +%274 = OpFDiv %9 %273 %272 +%275 = OpCompositeConstruct %136 %59 %59 +%276 = OpCompositeConstruct %136 %22 %22 +%277 = OpSRem %136 %275 %276 +%278 = OpCompositeConstruct %136 %22 %22 +%279 = OpCompositeConstruct %136 %59 %59 +%280 = OpSRem %136 %279 %278 +%281 = OpCompositeConstruct %210 %123 %123 +%282 = OpCompositeConstruct %210 %124 %124 +%283 = OpUMod %210 %281 %282 +%284 = OpCompositeConstruct %210 %124 %124 +%285 = OpCompositeConstruct %210 %123 %123 +%286 = OpUMod %210 %285 %284 +%287 = OpCompositeConstruct %9 %55 %55 +%288 = OpCompositeConstruct %9 %16 %16 +%289 = OpFRem %9 %287 %288 +%290 = OpCompositeConstruct %9 %16 %16 +%291 = OpCompositeConstruct %9 %55 %55 +%292 = OpFRem %9 %291 %290 +OpBranch %203 +%203 = OpLabel +%294 = OpCompositeExtract %10 %125 0 +%295 = OpCompositeExtract %10 %126 0 +%296 = OpFAdd %10 %294 %295 +%297 = OpCompositeExtract %10 %125 1 +%298 = OpCompositeExtract %10 %126 1 +%299 = OpFAdd %10 %297 %298 +%300 = OpCompositeExtract %10 %125 2 +%301 = OpCompositeExtract %10 %126 2 +%302 = OpFAdd %10 %300 %301 +%293 = OpCompositeConstruct %12 %296 %299 %302 +%304 = OpCompositeExtract %10 %127 0 +%305 = OpCompositeExtract %10 %128 0 +%306 = OpFSub %10 %304 %305 +%307 = OpCompositeExtract %10 %127 1 +%308 = OpCompositeExtract %10 %128 1 +%309 = OpFSub %10 %307 %308 +%310 = OpCompositeExtract %10 %127 2 +%311 = OpCompositeExtract %10 %128 2 +%312 = OpFSub %10 %310 %311 +%303 = OpCompositeConstruct %12 %306 %309 %312 +%313 = OpMatrixTimesScalar %12 %129 %16 +%314 = OpMatrixTimesScalar %12 %130 %55 +%315 = OpCompositeConstruct %3 %16 %16 %16 %16 +%316 = OpMatrixTimesVector %10 %131 %315 +%317 = OpCompositeConstruct %10 %55 %55 %55 +%318 = OpVectorTimesMatrix %3 %317 %132 +%319 = OpMatrixTimesMatrix %12 %133 %134 OpReturn OpFunctionEnd -%381 = OpFunction %2 None %165 -%380 = OpLabel -OpBranch %382 -%382 = OpLabel -%383 = OpNot %8 %7 -%384 = OpNot %20 %185 -%385 = OpCompositeConstruct %197 %7 %7 -%386 = OpNot %197 %385 -%387 = OpCompositeConstruct %208 %185 %185 %185 -%388 = OpNot %208 %387 -%389 = OpBitwiseOr %8 %70 %7 -%390 = OpBitwiseOr %20 %184 %185 -%391 = OpCompositeConstruct %197 %70 %70 -%392 = OpCompositeConstruct %197 %7 %7 -%393 = OpBitwiseOr %197 %391 %392 -%394 = OpCompositeConstruct %208 %184 %184 %184 -%395 = OpCompositeConstruct %208 %185 %185 %185 -%396 = OpBitwiseOr %208 %394 %395 -%397 = OpBitwiseAnd %8 %70 %7 -%398 = OpBitwiseAnd %20 %184 %185 -%399 = OpCompositeConstruct %197 %70 %70 -%400 = OpCompositeConstruct %197 %7 %7 -%401 = OpBitwiseAnd %197 %399 %400 -%402 = OpCompositeConstruct %208 %184 %184 %184 -%403 = OpCompositeConstruct %208 %185 %185 %185 -%404 = OpBitwiseAnd %208 %402 %403 -%405 = OpBitwiseXor %8 %70 %7 -%406 = OpBitwiseXor %20 %184 %185 -%407 = OpCompositeConstruct %197 %70 %70 -%408 = OpCompositeConstruct %197 %7 %7 -%409 = OpBitwiseXor %197 %407 %408 -%410 = OpCompositeConstruct %208 %184 %184 %184 -%411 = OpCompositeConstruct %208 %185 %185 %185 -%412 = OpBitwiseXor %208 %410 %411 -%413 = OpShiftLeftLogical %8 %70 %185 -%414 = OpShiftLeftLogical %20 %184 %185 -%415 = OpCompositeConstruct %197 %70 %70 -%416 = OpCompositeConstruct %21 %185 %185 -%417 = OpShiftLeftLogical %197 %415 %416 -%418 = OpCompositeConstruct %208 %184 %184 %184 -%419 = OpCompositeConstruct %208 %185 %185 %185 -%420 = OpShiftLeftLogical %208 %418 %419 -%421 = OpShiftRightArithmetic %8 %70 %185 -%422 = OpShiftRightLogical %20 %184 %185 -%423 = OpCompositeConstruct %197 %70 %70 -%424 = OpCompositeConstruct %21 %185 %185 -%425 = OpShiftRightArithmetic %197 %423 %424 -%426 = OpCompositeConstruct %208 %184 %184 %184 -%427 = OpCompositeConstruct %208 %185 %185 %185 -%428 = OpShiftRightLogical %208 %426 %427 +%321 = OpFunction %2 None %103 +%320 = OpLabel +OpBranch %322 +%322 = OpLabel +%323 = OpNot %6 %22 +%324 = OpNot %122 %124 +%325 = OpCompositeConstruct %136 %22 %22 +%326 = OpNot %136 %325 +%327 = OpCompositeConstruct %147 %124 %124 %124 +%328 = OpNot %147 %327 +%329 = OpBitwiseOr %6 %59 %22 +%330 = OpBitwiseOr %122 %123 %124 +%331 = OpCompositeConstruct %136 %59 %59 +%332 = OpCompositeConstruct %136 %22 %22 +%333 = OpBitwiseOr %136 %331 %332 +%334 = OpCompositeConstruct %147 %123 %123 %123 +%335 = OpCompositeConstruct %147 %124 %124 %124 +%336 = OpBitwiseOr %147 %334 %335 +%337 = OpBitwiseAnd %6 %59 %22 +%338 = OpBitwiseAnd %122 %123 %124 +%339 = OpCompositeConstruct %136 %59 %59 +%340 = OpCompositeConstruct %136 %22 %22 +%341 = OpBitwiseAnd %136 %339 %340 +%342 = OpCompositeConstruct %147 %123 %123 %123 +%343 = OpCompositeConstruct %147 %124 %124 %124 +%344 = OpBitwiseAnd %147 %342 %343 +%345 = OpBitwiseXor %6 %59 %22 +%346 = OpBitwiseXor %122 %123 %124 +%347 = OpCompositeConstruct %136 %59 %59 +%348 = OpCompositeConstruct %136 %22 %22 +%349 = OpBitwiseXor %136 %347 %348 +%350 = OpCompositeConstruct %147 %123 %123 %123 +%351 = OpCompositeConstruct %147 %124 %124 %124 +%352 = OpBitwiseXor %147 %350 %351 +%353 = OpShiftLeftLogical %6 %59 %124 +%354 = OpShiftLeftLogical %122 %123 %124 +%355 = OpCompositeConstruct %136 %59 %59 +%356 = OpCompositeConstruct %210 %124 %124 +%357 = OpShiftLeftLogical %136 %355 %356 +%358 = OpCompositeConstruct %147 %123 %123 %123 +%359 = OpCompositeConstruct %147 %124 %124 %124 +%360 = OpShiftLeftLogical %147 %358 %359 +%361 = OpShiftRightArithmetic %6 %59 %124 +%362 = OpShiftRightLogical %122 %123 %124 +%363 = OpCompositeConstruct %136 %59 %59 +%364 = OpCompositeConstruct %210 %124 %124 +%365 = OpShiftRightArithmetic %136 %363 %364 +%366 = OpCompositeConstruct %147 %123 %123 %123 +%367 = OpCompositeConstruct %147 %124 %124 %124 +%368 = OpShiftRightLogical %147 %366 %367 OpReturn OpFunctionEnd -%430 = OpFunction %2 None %165 -%429 = OpLabel -OpBranch %431 -%431 = OpLabel -%432 = OpIEqual %13 %70 %7 -%433 = OpIEqual %13 %184 %185 -%434 = OpFOrdEqual %13 %66 %3 -%435 = OpCompositeConstruct %197 %70 %70 -%436 = OpCompositeConstruct %197 %7 %7 -%437 = OpIEqual %168 %435 %436 -%438 = OpCompositeConstruct %208 %184 %184 %184 -%439 = OpCompositeConstruct %208 %185 %185 %185 -%440 = OpIEqual %16 %438 %439 -%441 = OpCompositeConstruct %10 %66 %66 %66 %66 -%442 = OpCompositeConstruct %10 %3 %3 %3 %3 -%443 = OpFOrdEqual %12 %441 %442 -%444 = OpINotEqual %13 %70 %7 -%445 = OpINotEqual %13 %184 %185 -%446 = OpFOrdNotEqual %13 %66 %3 -%447 = OpCompositeConstruct %197 %70 %70 -%448 = OpCompositeConstruct %197 %7 %7 -%449 = OpINotEqual %168 %447 %448 -%450 = OpCompositeConstruct %208 %184 %184 %184 -%451 = OpCompositeConstruct %208 %185 %185 %185 -%452 = OpINotEqual %16 %450 %451 -%453 = OpCompositeConstruct %10 %66 %66 %66 %66 -%454 = OpCompositeConstruct %10 %3 %3 %3 %3 -%455 = OpFOrdNotEqual %12 %453 %454 -%456 = OpSLessThan %13 %70 %7 -%457 = OpULessThan %13 %184 %185 -%458 = OpFOrdLessThan %13 %66 %3 -%459 = OpCompositeConstruct %197 %70 %70 -%460 = OpCompositeConstruct %197 %7 %7 -%461 = OpSLessThan %168 %459 %460 -%462 = OpCompositeConstruct %208 %184 %184 %184 -%463 = OpCompositeConstruct %208 %185 %185 %185 -%464 = OpULessThan %16 %462 %463 -%465 = OpCompositeConstruct %10 %66 %66 %66 %66 -%466 = OpCompositeConstruct %10 %3 %3 %3 %3 -%467 = OpFOrdLessThan %12 %465 %466 -%468 = OpSLessThanEqual %13 %70 %7 -%469 = OpULessThanEqual %13 %184 %185 -%470 = OpFOrdLessThanEqual %13 %66 %3 -%471 = OpCompositeConstruct %197 %70 %70 -%472 = OpCompositeConstruct %197 %7 %7 -%473 = OpSLessThanEqual %168 %471 %472 -%474 = OpCompositeConstruct %208 %184 %184 %184 -%475 = OpCompositeConstruct %208 %185 %185 %185 -%476 = OpULessThanEqual %16 %474 %475 -%477 = OpCompositeConstruct %10 %66 %66 %66 %66 -%478 = OpCompositeConstruct %10 %3 %3 %3 %3 -%479 = OpFOrdLessThanEqual %12 %477 %478 -%480 = OpSGreaterThan %13 %70 %7 -%481 = OpUGreaterThan %13 %184 %185 -%482 = OpFOrdGreaterThan %13 %66 %3 -%483 = OpCompositeConstruct %197 %70 %70 -%484 = OpCompositeConstruct %197 %7 %7 -%485 = OpSGreaterThan %168 %483 %484 -%486 = OpCompositeConstruct %208 %184 %184 %184 -%487 = OpCompositeConstruct %208 %185 %185 %185 -%488 = OpUGreaterThan %16 %486 %487 -%489 = OpCompositeConstruct %10 %66 %66 %66 %66 -%490 = OpCompositeConstruct %10 %3 %3 %3 %3 -%491 = OpFOrdGreaterThan %12 %489 %490 -%492 = OpSGreaterThanEqual %13 %70 %7 -%493 = OpUGreaterThanEqual %13 %184 %185 -%494 = OpFOrdGreaterThanEqual %13 %66 %3 -%495 = OpCompositeConstruct %197 %70 %70 -%496 = OpCompositeConstruct %197 %7 %7 -%497 = OpSGreaterThanEqual %168 %495 %496 -%498 = OpCompositeConstruct %208 %184 %184 %184 -%499 = OpCompositeConstruct %208 %185 %185 %185 -%500 = OpUGreaterThanEqual %16 %498 %499 -%501 = OpCompositeConstruct %10 %66 %66 %66 %66 -%502 = OpCompositeConstruct %10 %3 %3 %3 %3 -%503 = OpFOrdGreaterThanEqual %12 %501 %502 +%370 = OpFunction %2 None %103 +%369 = OpLabel +OpBranch %371 +%371 = OpLabel +%372 = OpIEqual %8 %59 %22 +%373 = OpIEqual %8 %123 %124 +%374 = OpFOrdEqual %8 %55 %16 +%375 = OpCompositeConstruct %136 %59 %59 +%376 = OpCompositeConstruct %136 %22 %22 +%377 = OpIEqual %106 %375 %376 +%378 = OpCompositeConstruct %147 %123 %123 %123 +%379 = OpCompositeConstruct %147 %124 %124 %124 +%380 = OpIEqual %11 %378 %379 +%381 = OpCompositeConstruct %3 %55 %55 %55 %55 +%382 = OpCompositeConstruct %3 %16 %16 %16 %16 +%383 = OpFOrdEqual %7 %381 %382 +%384 = OpINotEqual %8 %59 %22 +%385 = OpINotEqual %8 %123 %124 +%386 = OpFOrdNotEqual %8 %55 %16 +%387 = OpCompositeConstruct %136 %59 %59 +%388 = OpCompositeConstruct %136 %22 %22 +%389 = OpINotEqual %106 %387 %388 +%390 = OpCompositeConstruct %147 %123 %123 %123 +%391 = OpCompositeConstruct %147 %124 %124 %124 +%392 = OpINotEqual %11 %390 %391 +%393 = OpCompositeConstruct %3 %55 %55 %55 %55 +%394 = OpCompositeConstruct %3 %16 %16 %16 %16 +%395 = OpFOrdNotEqual %7 %393 %394 +%396 = OpSLessThan %8 %59 %22 +%397 = OpULessThan %8 %123 %124 +%398 = OpFOrdLessThan %8 %55 %16 +%399 = OpCompositeConstruct %136 %59 %59 +%400 = OpCompositeConstruct %136 %22 %22 +%401 = OpSLessThan %106 %399 %400 +%402 = OpCompositeConstruct %147 %123 %123 %123 +%403 = OpCompositeConstruct %147 %124 %124 %124 +%404 = OpULessThan %11 %402 %403 +%405 = OpCompositeConstruct %3 %55 %55 %55 %55 +%406 = OpCompositeConstruct %3 %16 %16 %16 %16 +%407 = OpFOrdLessThan %7 %405 %406 +%408 = OpSLessThanEqual %8 %59 %22 +%409 = OpULessThanEqual %8 %123 %124 +%410 = OpFOrdLessThanEqual %8 %55 %16 +%411 = OpCompositeConstruct %136 %59 %59 +%412 = OpCompositeConstruct %136 %22 %22 +%413 = OpSLessThanEqual %106 %411 %412 +%414 = OpCompositeConstruct %147 %123 %123 %123 +%415 = OpCompositeConstruct %147 %124 %124 %124 +%416 = OpULessThanEqual %11 %414 %415 +%417 = OpCompositeConstruct %3 %55 %55 %55 %55 +%418 = OpCompositeConstruct %3 %16 %16 %16 %16 +%419 = OpFOrdLessThanEqual %7 %417 %418 +%420 = OpSGreaterThan %8 %59 %22 +%421 = OpUGreaterThan %8 %123 %124 +%422 = OpFOrdGreaterThan %8 %55 %16 +%423 = OpCompositeConstruct %136 %59 %59 +%424 = OpCompositeConstruct %136 %22 %22 +%425 = OpSGreaterThan %106 %423 %424 +%426 = OpCompositeConstruct %147 %123 %123 %123 +%427 = OpCompositeConstruct %147 %124 %124 %124 +%428 = OpUGreaterThan %11 %426 %427 +%429 = OpCompositeConstruct %3 %55 %55 %55 %55 +%430 = OpCompositeConstruct %3 %16 %16 %16 %16 +%431 = OpFOrdGreaterThan %7 %429 %430 +%432 = OpSGreaterThanEqual %8 %59 %22 +%433 = OpUGreaterThanEqual %8 %123 %124 +%434 = OpFOrdGreaterThanEqual %8 %55 %16 +%435 = OpCompositeConstruct %136 %59 %59 +%436 = OpCompositeConstruct %136 %22 %22 +%437 = OpSGreaterThanEqual %106 %435 %436 +%438 = OpCompositeConstruct %147 %123 %123 %123 +%439 = OpCompositeConstruct %147 %124 %124 %124 +%440 = OpUGreaterThanEqual %11 %438 %439 +%441 = OpCompositeConstruct %3 %55 %55 %55 %55 +%442 = OpCompositeConstruct %3 %16 %16 %16 %16 +%443 = OpFOrdGreaterThanEqual %7 %441 %442 OpReturn OpFunctionEnd -%511 = OpFunction %2 None %165 -%510 = OpLabel -%504 = OpVariable %505 Function %506 -%507 = OpVariable %508 Function %509 -OpBranch %513 -%513 = OpLabel -OpStore %504 %7 -%514 = OpLoad %8 %504 -%515 = OpIAdd %8 %514 %7 -OpStore %504 %515 -%516 = OpLoad %8 %504 -%517 = OpISub %8 %516 %7 -OpStore %504 %517 -%518 = OpLoad %8 %504 -%519 = OpLoad %8 %504 -%520 = OpIMul %8 %519 %518 -OpStore %504 %520 -%521 = OpLoad %8 %504 -%522 = OpLoad %8 %504 -%523 = OpSDiv %8 %522 %521 -OpStore %504 %523 -%524 = OpLoad %8 %504 -%525 = OpSRem %8 %524 %7 -OpStore %504 %525 -%526 = OpLoad %8 %504 -%527 = OpBitwiseAnd %8 %526 %39 -OpStore %504 %527 -%528 = OpLoad %8 %504 -%529 = OpBitwiseOr %8 %528 %39 -OpStore %504 %529 -%530 = OpLoad %8 %504 -%531 = OpBitwiseXor %8 %530 %39 -OpStore %504 %531 -%532 = OpLoad %8 %504 -%533 = OpShiftLeftLogical %8 %532 %184 -OpStore %504 %533 -%534 = OpLoad %8 %504 -%535 = OpShiftRightArithmetic %8 %534 %185 -OpStore %504 %535 -%536 = OpLoad %8 %504 -%537 = OpIAdd %8 %536 %7 -OpStore %504 %537 -%538 = OpLoad %8 %504 -%539 = OpISub %8 %538 %7 -OpStore %504 %539 -OpStore %507 %512 -%541 = OpAccessChain %540 %507 %185 -%542 = OpLoad %8 %541 -%543 = OpIAdd %8 %542 %7 -%544 = OpAccessChain %540 %507 %185 -OpStore %544 %543 -%545 = OpAccessChain %540 %507 %185 -%546 = OpLoad %8 %545 -%547 = OpISub %8 %546 %7 -%548 = OpAccessChain %540 %507 %185 -OpStore %548 %547 +%451 = OpFunction %2 None %103 +%450 = OpLabel +%444 = OpVariable %445 Function %446 +%447 = OpVariable %448 Function %449 +OpBranch %453 +%453 = OpLabel +OpStore %444 %22 +%454 = OpLoad %6 %444 +%455 = OpIAdd %6 %454 %22 +OpStore %444 %455 +%456 = OpLoad %6 %444 +%457 = OpISub %6 %456 %22 +OpStore %444 %457 +%458 = OpLoad %6 %444 +%459 = OpLoad %6 %444 +%460 = OpIMul %6 %459 %458 +OpStore %444 %460 +%461 = OpLoad %6 %444 +%462 = OpLoad %6 %444 +%463 = OpSDiv %6 %462 %461 +OpStore %444 %463 +%464 = OpLoad %6 %444 +%465 = OpSRem %6 %464 %22 +OpStore %444 %465 +%466 = OpLoad %6 %444 +%467 = OpBitwiseAnd %6 %466 %28 +OpStore %444 %467 +%468 = OpLoad %6 %444 +%469 = OpBitwiseOr %6 %468 %28 +OpStore %444 %469 +%470 = OpLoad %6 %444 +%471 = OpBitwiseXor %6 %470 %28 +OpStore %444 %471 +%472 = OpLoad %6 %444 +%473 = OpShiftLeftLogical %6 %472 %123 +OpStore %444 %473 +%474 = OpLoad %6 %444 +%475 = OpShiftRightArithmetic %6 %474 %124 +OpStore %444 %475 +%476 = OpLoad %6 %444 +%477 = OpIAdd %6 %476 %22 +OpStore %444 %477 +%478 = OpLoad %6 %444 +%479 = OpISub %6 %478 %22 +OpStore %444 %479 +OpStore %447 %452 +%481 = OpAccessChain %480 %447 %124 +%482 = OpLoad %6 %481 +%483 = OpIAdd %6 %482 %22 +%484 = OpAccessChain %480 %447 %124 +OpStore %484 %483 +%485 = OpAccessChain %480 %447 %124 +%486 = OpLoad %6 %485 +%487 = OpISub %6 %486 %22 +%488 = OpAccessChain %480 %447 %124 +OpStore %488 %487 OpReturn OpFunctionEnd -%550 = OpFunction %2 None %165 -%549 = OpLabel -OpBranch %559 -%559 = OpLabel -%560 = OpSNegate %8 %552 -%561 = OpSNegate %8 %553 -%562 = OpSNegate %8 %554 -%563 = OpSNegate %8 %562 -%564 = OpSNegate %8 %555 -%565 = OpSNegate %8 %564 -%566 = OpSNegate %8 %556 -%567 = OpSNegate %8 %566 -%568 = OpSNegate %8 %567 -%569 = OpSNegate %8 %568 -%570 = OpSNegate %8 %557 -%571 = OpSNegate %8 %570 -%572 = OpSNegate %8 %571 -%573 = OpSNegate %8 %572 -%574 = OpSNegate %8 %558 -%575 = OpSNegate %8 %574 -%576 = OpSNegate %8 %575 -%577 = OpSNegate %8 %576 +%490 = OpFunction %2 None %103 +%489 = OpLabel +OpBranch %499 +%499 = OpLabel +%500 = OpSNegate %6 %492 +%501 = OpSNegate %6 %493 +%502 = OpSNegate %6 %494 +%503 = OpSNegate %6 %502 +%504 = OpSNegate %6 %495 +%505 = OpSNegate %6 %504 +%506 = OpSNegate %6 %496 +%507 = OpSNegate %6 %506 +%508 = OpSNegate %6 %507 +%509 = OpSNegate %6 %508 +%510 = OpSNegate %6 %497 +%511 = OpSNegate %6 %510 +%512 = OpSNegate %6 %511 +%513 = OpSNegate %6 %512 +%514 = OpSNegate %6 %498 +%515 = OpSNegate %6 %514 +%516 = OpSNegate %6 %515 +%517 = OpSNegate %6 %516 OpReturn OpFunctionEnd -%579 = OpFunction %2 None %165 -%578 = OpLabel -OpBranch %580 -%580 = OpLabel -%581 = OpFunctionCall %10 %36 -%582 = OpFunctionCall %10 %65 -%583 = OpVectorShuffle %15 %31 %31 0 1 2 -%584 = OpFunctionCall %15 %105 %583 -%585 = OpFunctionCall %4 %116 -%586 = OpFunctionCall %2 %164 -%587 = OpFunctionCall %2 %182 -%588 = OpFunctionCall %2 %381 -%589 = OpFunctionCall %2 %430 -%590 = OpFunctionCall %2 %511 +%519 = OpFunction %2 None %103 +%518 = OpLabel +OpBranch %520 +%520 = OpLabel +%521 = OpFunctionCall %3 %25 +%522 = OpFunctionCall %3 %54 +%523 = OpVectorShuffle %10 %17 %17 0 1 2 +%524 = OpFunctionCall %10 %94 %523 +%525 = OpFunctionCall %2 %102 +%526 = OpFunctionCall %2 %120 +%527 = OpFunctionCall %2 %321 +%528 = OpFunctionCall %2 %370 +%529 = OpFunctionCall %2 %451 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/padding.spvasm b/tests/out/spv/padding.spvasm index 0efcef10e4..93c4ce63c7 100644 --- a/tests/out/spv/padding.spvasm +++ b/tests/out/spv/padding.spvasm @@ -6,31 +6,31 @@ OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 OpEntryPoint Vertex %28 "vertex" %26 -OpMemberName %7 0 "a" -OpName %7 "S" -OpMemberName %8 0 "a" -OpMemberName %8 1 "b" -OpName %8 "Test" +OpMemberName %5 0 "a" +OpName %5 "S" +OpMemberName %6 0 "a" +OpMemberName %6 1 "b" +OpName %6 "Test" +OpMemberName %10 0 "a" +OpMemberName %10 1 "b" +OpName %10 "Test2" OpMemberName %12 0 "a" OpMemberName %12 1 "b" -OpName %12 "Test2" -OpMemberName %14 0 "a" -OpMemberName %14 1 "b" -OpName %14 "Test3" +OpName %12 "Test3" OpName %16 "input1" OpName %19 "input2" OpName %22 "input3" OpName %28 "vertex" -OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %8 0 Offset 0 -OpMemberDecorate %8 1 Offset 16 -OpDecorate %9 ArrayStride 16 +OpMemberDecorate %5 0 Offset 0 +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 +OpDecorate %7 ArrayStride 16 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 32 OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 32 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %14 0 ColMajor -OpMemberDecorate %14 0 MatrixStride 16 -OpMemberDecorate %14 1 Offset 64 +OpMemberDecorate %12 0 ColMajor +OpMemberDecorate %12 0 MatrixStride 16 +OpMemberDecorate %12 1 Offset 64 OpDecorate %16 DescriptorSet 0 OpDecorate %16 Binding 0 OpDecorate %17 Block @@ -45,38 +45,38 @@ OpDecorate %23 Block OpMemberDecorate %23 0 Offset 0 OpDecorate %26 BuiltIn Position %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 2 -%6 = OpTypeFloat 32 -%5 = OpTypeVector %6 3 -%7 = OpTypeStruct %5 -%8 = OpTypeStruct %7 %6 -%11 = OpTypeInt 32 0 -%10 = OpConstant %11 2 -%9 = OpTypeArray %5 %10 -%12 = OpTypeStruct %9 %6 -%13 = OpTypeMatrix %5 4 -%14 = OpTypeStruct %13 %6 -%15 = OpTypeVector %6 4 -%17 = OpTypeStruct %8 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 3 +%5 = OpTypeStruct %3 +%6 = OpTypeStruct %5 %4 +%9 = OpTypeInt 32 0 +%8 = OpConstant %9 2 +%7 = OpTypeArray %3 %8 +%10 = OpTypeStruct %7 %4 +%11 = OpTypeMatrix %3 4 +%12 = OpTypeStruct %11 %4 +%13 = OpTypeVector %4 4 +%15 = OpTypeInt 32 1 +%14 = OpConstant %15 2 +%17 = OpTypeStruct %6 %18 = OpTypePointer Uniform %17 %16 = OpVariable %18 Uniform -%20 = OpTypeStruct %12 +%20 = OpTypeStruct %10 %21 = OpTypePointer Uniform %20 %19 = OpVariable %21 Uniform -%23 = OpTypeStruct %14 +%23 = OpTypeStruct %12 %24 = OpTypePointer Uniform %23 %22 = OpVariable %24 Uniform -%27 = OpTypePointer Output %15 +%27 = OpTypePointer Output %13 %26 = OpVariable %27 Output %29 = OpTypeFunction %2 -%30 = OpTypePointer Uniform %8 -%31 = OpConstant %11 0 -%33 = OpTypePointer Uniform %12 -%35 = OpTypePointer Uniform %14 -%37 = OpConstant %6 1.0 -%40 = OpTypePointer Uniform %6 -%41 = OpConstant %11 1 +%30 = OpTypePointer Uniform %6 +%31 = OpConstant %9 0 +%33 = OpTypePointer Uniform %10 +%35 = OpTypePointer Uniform %12 +%37 = OpConstant %4 1.0 +%40 = OpTypePointer Uniform %4 +%41 = OpConstant %9 1 %28 = OpFunction %2 None %29 %25 = OpLabel %32 = OpAccessChain %30 %16 %31 @@ -84,16 +84,16 @@ OpDecorate %26 BuiltIn Position %36 = OpAccessChain %35 %22 %31 OpBranch %38 %38 = OpLabel -%39 = OpCompositeConstruct %15 %37 %37 %37 %37 +%39 = OpCompositeConstruct %13 %37 %37 %37 %37 %42 = OpAccessChain %40 %32 %41 -%43 = OpLoad %6 %42 -%44 = OpVectorTimesScalar %15 %39 %43 +%43 = OpLoad %4 %42 +%44 = OpVectorTimesScalar %13 %39 %43 %45 = OpAccessChain %40 %34 %41 -%46 = OpLoad %6 %45 -%47 = OpVectorTimesScalar %15 %44 %46 +%46 = OpLoad %4 %45 +%47 = OpVectorTimesScalar %13 %44 %46 %48 = OpAccessChain %40 %36 %41 -%49 = OpLoad %6 %48 -%50 = OpVectorTimesScalar %15 %47 %49 +%49 = OpLoad %4 %48 +%50 = OpVectorTimesScalar %13 %47 %49 OpStore %26 %50 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/policy-mix.spvasm b/tests/out/spv/policy-mix.spvasm index 970da7d103..ea77b3bb44 100644 --- a/tests/out/spv/policy-mix.spvasm +++ b/tests/out/spv/policy-mix.spvasm @@ -8,10 +8,10 @@ OpCapability Linkage OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpMemberName %14 0 "a" -OpName %14 "InStorage" -OpMemberName %17 0 "a" -OpName %17 "InUniform" +OpMemberName %8 0 "a" +OpName %8 "InStorage" +OpMemberName %11 0 "a" +OpName %11 "InUniform" OpName %26 "in_storage" OpName %29 "in_uniform" OpName %32 "image_2d_array" @@ -22,13 +22,13 @@ OpName %43 "c" OpName %44 "i" OpName %45 "l" OpName %46 "mock_function" -OpDecorate %11 ArrayStride 16 -OpMemberDecorate %14 0 Offset 0 -OpDecorate %15 ArrayStride 16 -OpMemberDecorate %17 0 Offset 0 -OpDecorate %19 ArrayStride 4 -OpDecorate %21 ArrayStride 4 -OpDecorate %24 ArrayStride 16 +OpDecorate %5 ArrayStride 16 +OpMemberDecorate %8 0 Offset 0 +OpDecorate %9 ArrayStride 16 +OpMemberDecorate %11 0 Offset 0 +OpDecorate %13 ArrayStride 4 +OpDecorate %15 ArrayStride 4 +OpDecorate %19 ArrayStride 16 OpDecorate %26 NonWritable OpDecorate %26 DescriptorSet 0 OpDecorate %26 Binding 0 @@ -41,87 +41,87 @@ OpMemberDecorate %30 0 Offset 0 OpDecorate %32 DescriptorSet 0 OpDecorate %32 Binding 2 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 10 -%5 = OpConstant %4 20 -%6 = OpConstant %4 30 -%7 = OpConstant %4 40 -%8 = OpConstant %4 2 -%10 = OpTypeFloat 32 -%9 = OpTypeVector %10 4 -%13 = OpTypeInt 32 0 -%12 = OpConstant %13 10 -%11 = OpTypeArray %9 %12 -%14 = OpTypeStruct %11 -%16 = OpConstant %13 20 -%15 = OpTypeArray %9 %16 -%17 = OpTypeStruct %15 -%18 = OpTypeImage %10 2D 0 1 0 1 Unknown -%20 = OpConstant %13 30 -%19 = OpTypeArray %10 %20 -%22 = OpConstant %13 40 -%21 = OpTypeArray %10 %22 -%23 = OpTypeVector %4 2 -%25 = OpConstant %13 2 -%24 = OpTypeArray %9 %25 -%27 = OpTypeStruct %14 +%4 = OpTypeFloat 32 +%3 = OpTypeVector %4 4 +%7 = OpTypeInt 32 0 +%6 = OpConstant %7 10 +%5 = OpTypeArray %3 %6 +%8 = OpTypeStruct %5 +%10 = OpConstant %7 20 +%9 = OpTypeArray %3 %10 +%11 = OpTypeStruct %9 +%12 = OpTypeImage %4 2D 0 1 0 1 Unknown +%14 = OpConstant %7 30 +%13 = OpTypeArray %4 %14 +%16 = OpConstant %7 40 +%15 = OpTypeArray %4 %16 +%18 = OpTypeInt 32 1 +%17 = OpTypeVector %18 2 +%20 = OpConstant %7 2 +%19 = OpTypeArray %3 %20 +%21 = OpConstant %18 10 +%22 = OpConstant %18 20 +%23 = OpConstant %18 30 +%24 = OpConstant %18 40 +%25 = OpConstant %18 2 +%27 = OpTypeStruct %8 %28 = OpTypePointer StorageBuffer %27 %26 = OpVariable %28 StorageBuffer -%30 = OpTypeStruct %17 +%30 = OpTypeStruct %11 %31 = OpTypePointer Uniform %30 %29 = OpVariable %31 Uniform -%33 = OpTypePointer UniformConstant %18 +%33 = OpTypePointer UniformConstant %12 %32 = OpVariable %33 UniformConstant -%35 = OpTypePointer Workgroup %19 +%35 = OpTypePointer Workgroup %13 %34 = OpVariable %35 Workgroup -%37 = OpTypePointer Private %21 -%38 = OpConstantNull %21 +%37 = OpTypePointer Private %15 +%38 = OpConstantNull %15 %36 = OpVariable %37 Private %38 -%40 = OpTypePointer Function %24 -%41 = OpConstantNull %24 -%47 = OpTypeFunction %9 %23 %4 %4 -%48 = OpTypePointer StorageBuffer %14 -%49 = OpConstant %13 0 -%51 = OpTypePointer Uniform %17 -%54 = OpConstant %10 0.707 -%55 = OpConstant %10 0.0 -%56 = OpConstant %10 1.0 -%61 = OpTypePointer StorageBuffer %11 -%62 = OpTypePointer StorageBuffer %9 -%65 = OpTypePointer Uniform %15 -%66 = OpTypePointer Uniform %9 -%70 = OpTypeVector %4 3 +%40 = OpTypePointer Function %19 +%41 = OpConstantNull %19 +%47 = OpTypeFunction %3 %17 %18 %18 +%48 = OpTypePointer StorageBuffer %8 +%49 = OpConstant %7 0 +%51 = OpTypePointer Uniform %11 +%54 = OpConstant %4 0.707 +%55 = OpConstant %4 0.0 +%56 = OpConstant %4 1.0 +%61 = OpTypePointer StorageBuffer %5 +%62 = OpTypePointer StorageBuffer %3 +%65 = OpTypePointer Uniform %9 +%66 = OpTypePointer Uniform %3 +%70 = OpTypeVector %18 3 %72 = OpTypeBool -%73 = OpConstantNull %9 +%73 = OpConstantNull %3 %79 = OpTypeVector %72 3 -%86 = OpTypePointer Workgroup %10 -%87 = OpConstant %13 29 -%93 = OpTypePointer Private %10 -%94 = OpConstant %13 39 -%100 = OpTypePointer Function %9 -%101 = OpConstant %13 1 -%46 = OpFunction %9 None %47 -%43 = OpFunctionParameter %23 -%44 = OpFunctionParameter %4 -%45 = OpFunctionParameter %4 +%86 = OpTypePointer Workgroup %4 +%87 = OpConstant %7 29 +%93 = OpTypePointer Private %4 +%94 = OpConstant %7 39 +%100 = OpTypePointer Function %3 +%101 = OpConstant %7 1 +%46 = OpFunction %3 None %47 +%43 = OpFunctionParameter %17 +%44 = OpFunctionParameter %18 +%45 = OpFunctionParameter %18 %42 = OpLabel %39 = OpVariable %40 Function %41 %50 = OpAccessChain %48 %26 %49 %52 = OpAccessChain %51 %29 %49 -%53 = OpLoad %18 %32 +%53 = OpLoad %12 %32 OpBranch %57 %57 = OpLabel -%58 = OpCompositeConstruct %9 %54 %55 %55 %56 -%59 = OpCompositeConstruct %9 %55 %54 %55 %56 -%60 = OpCompositeConstruct %24 %58 %59 +%58 = OpCompositeConstruct %3 %54 %55 %55 %56 +%59 = OpCompositeConstruct %3 %55 %54 %55 %56 +%60 = OpCompositeConstruct %19 %58 %59 OpStore %39 %60 %63 = OpAccessChain %62 %50 %49 %44 -%64 = OpLoad %9 %63 +%64 = OpLoad %3 %63 %67 = OpAccessChain %66 %52 %49 %44 -%68 = OpLoad %9 %67 -%69 = OpFAdd %9 %64 %68 +%68 = OpLoad %3 %67 +%69 = OpFAdd %3 %64 %68 %71 = OpCompositeConstruct %70 %43 %44 -%74 = OpImageQueryLevels %4 %53 +%74 = OpImageQueryLevels %18 %53 %75 = OpULessThan %72 %45 %74 OpSelectionMerge %76 None OpBranchConditional %75 %77 %76 @@ -131,24 +131,24 @@ OpBranchConditional %75 %77 %76 %81 = OpAll %72 %80 OpBranchConditional %81 %82 %76 %82 = OpLabel -%83 = OpImageFetch %9 %53 %71 Lod %45 +%83 = OpImageFetch %3 %53 %71 Lod %45 OpBranch %76 %76 = OpLabel -%84 = OpPhi %9 %73 %57 %73 %77 %83 %82 -%85 = OpFAdd %9 %69 %84 -%88 = OpExtInst %13 %1 UMin %44 %87 +%84 = OpPhi %3 %73 %57 %73 %77 %83 %82 +%85 = OpFAdd %3 %69 %84 +%88 = OpExtInst %7 %1 UMin %44 %87 %89 = OpAccessChain %86 %34 %88 -%90 = OpLoad %10 %89 -%91 = OpCompositeConstruct %9 %90 %90 %90 %90 -%92 = OpFAdd %9 %85 %91 -%95 = OpExtInst %13 %1 UMin %44 %94 +%90 = OpLoad %4 %89 +%91 = OpCompositeConstruct %3 %90 %90 %90 %90 +%92 = OpFAdd %3 %85 %91 +%95 = OpExtInst %7 %1 UMin %44 %94 %96 = OpAccessChain %93 %36 %95 -%97 = OpLoad %10 %96 -%98 = OpCompositeConstruct %9 %97 %97 %97 %97 -%99 = OpFAdd %9 %92 %98 -%102 = OpExtInst %13 %1 UMin %44 %101 +%97 = OpLoad %4 %96 +%98 = OpCompositeConstruct %3 %97 %97 %97 %97 +%99 = OpFAdd %3 %92 %98 +%102 = OpExtInst %7 %1 UMin %44 %101 %103 = OpAccessChain %100 %39 %102 -%104 = OpLoad %9 %103 -%105 = OpFAdd %9 %99 %104 +%104 = OpLoad %3 %103 +%105 = OpFAdd %3 %99 %104 OpReturnValue %105 OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/quad.spvasm b/tests/out/spv/quad.spvasm index 4c82c92b07..3de529f6b5 100644 --- a/tests/out/spv/quad.spvasm +++ b/tests/out/spv/quad.spvasm @@ -10,10 +10,10 @@ OpEntryPoint Fragment %44 "frag_main" %41 %43 OpEntryPoint Fragment %60 "fs_extra" %59 OpExecutionMode %44 OriginUpperLeft OpExecutionMode %60 OriginUpperLeft -OpName %3 "c_scale" -OpMemberName %7 0 "uv" -OpMemberName %7 1 "position" -OpName %7 "VertexOutput" +OpMemberName %6 0 "uv" +OpMemberName %6 1 "position" +OpName %6 "VertexOutput" +OpName %9 "c_scale" OpName %10 "u_texture" OpName %12 "u_sampler" OpName %15 "pos" @@ -24,8 +24,8 @@ OpName %24 "vert_main" OpName %41 "uv" OpName %44 "frag_main" OpName %60 "fs_extra" -OpMemberDecorate %7 0 Offset 0 -OpMemberDecorate %7 1 Offset 16 +OpMemberDecorate %6 0 Offset 0 +OpMemberDecorate %6 1 Offset 16 OpDecorate %10 DescriptorSet 0 OpDecorate %10 Binding 0 OpDecorate %12 DescriptorSet 0 @@ -38,73 +38,73 @@ OpDecorate %41 Location 0 OpDecorate %43 Location 0 OpDecorate %59 Location 0 %2 = OpTypeVoid -%4 = OpTypeFloat 32 -%3 = OpConstant %4 1.2 -%5 = OpTypeVector %4 2 -%6 = OpTypeVector %4 4 -%7 = OpTypeStruct %5 %6 -%8 = OpTypeImage %4 2D 0 0 0 1 Unknown -%9 = OpTypeSampler -%11 = OpTypePointer UniformConstant %8 +%3 = OpTypeFloat 32 +%4 = OpTypeVector %3 2 +%5 = OpTypeVector %3 4 +%6 = OpTypeStruct %4 %5 +%7 = OpTypeImage %3 2D 0 0 0 1 Unknown +%8 = OpTypeSampler +%9 = OpConstant %3 1.2 +%11 = OpTypePointer UniformConstant %7 %10 = OpVariable %11 UniformConstant -%13 = OpTypePointer UniformConstant %9 +%13 = OpTypePointer UniformConstant %8 %12 = OpVariable %13 UniformConstant -%16 = OpTypePointer Input %5 +%16 = OpTypePointer Input %4 %15 = OpVariable %16 Input %18 = OpVariable %16 Input -%21 = OpTypePointer Output %5 +%21 = OpTypePointer Output %4 %20 = OpVariable %21 Output -%23 = OpTypePointer Output %6 +%23 = OpTypePointer Output %5 %22 = OpVariable %23 Output %25 = OpTypeFunction %2 -%26 = OpConstant %4 0.0 -%27 = OpConstant %4 1.0 -%34 = OpTypePointer Output %4 +%26 = OpConstant %3 0.0 +%27 = OpConstant %3 1.0 +%34 = OpTypePointer Output %3 %36 = OpTypeInt 32 0 %35 = OpConstant %36 1 %41 = OpVariable %16 Input %43 = OpVariable %23 Output -%48 = OpTypeSampledImage %8 +%48 = OpTypeSampledImage %7 %52 = OpTypeBool %59 = OpVariable %23 Output -%61 = OpConstant %4 0.5 +%61 = OpConstant %3 0.5 %24 = OpFunction %2 None %25 %14 = OpLabel -%17 = OpLoad %5 %15 -%19 = OpLoad %5 %18 +%17 = OpLoad %4 %15 +%19 = OpLoad %4 %18 OpBranch %28 %28 = OpLabel -%29 = OpVectorTimesScalar %5 %17 %3 -%30 = OpCompositeConstruct %6 %29 %26 %27 -%31 = OpCompositeConstruct %7 %19 %30 -%32 = OpCompositeExtract %5 %31 0 +%29 = OpVectorTimesScalar %4 %17 %9 +%30 = OpCompositeConstruct %5 %29 %26 %27 +%31 = OpCompositeConstruct %6 %19 %30 +%32 = OpCompositeExtract %4 %31 0 OpStore %20 %32 -%33 = OpCompositeExtract %6 %31 1 +%33 = OpCompositeExtract %5 %31 1 OpStore %22 %33 %37 = OpAccessChain %34 %22 %35 -%38 = OpLoad %4 %37 -%39 = OpFNegate %4 %38 +%38 = OpLoad %3 %37 +%39 = OpFNegate %3 %38 OpStore %37 %39 OpReturn OpFunctionEnd %44 = OpFunction %2 None %25 %40 = OpLabel -%42 = OpLoad %5 %41 -%45 = OpLoad %8 %10 -%46 = OpLoad %9 %12 +%42 = OpLoad %4 %41 +%45 = OpLoad %7 %10 +%46 = OpLoad %8 %12 OpBranch %47 %47 = OpLabel %49 = OpSampledImage %48 %45 %46 -%50 = OpImageSampleImplicitLod %6 %49 %42 -%51 = OpCompositeExtract %4 %50 3 +%50 = OpImageSampleImplicitLod %5 %49 %42 +%51 = OpCompositeExtract %3 %50 3 %53 = OpFOrdEqual %52 %51 %26 OpSelectionMerge %54 None OpBranchConditional %53 %55 %54 %55 = OpLabel OpKill %54 = OpLabel -%56 = OpCompositeExtract %4 %50 3 -%57 = OpVectorTimesScalar %6 %50 %56 +%56 = OpCompositeExtract %3 %50 3 +%57 = OpVectorTimesScalar %5 %50 %56 OpStore %43 %57 OpReturn OpFunctionEnd @@ -112,7 +112,7 @@ OpFunctionEnd %58 = OpLabel OpBranch %62 %62 = OpLabel -%63 = OpCompositeConstruct %6 %26 %61 %26 %61 +%63 = OpCompositeConstruct %5 %26 %61 %26 %61 OpStore %59 %63 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/shadow.spvasm b/tests/out/spv/shadow.spvasm index 26ee96559b..20fd9ccbf7 100644 --- a/tests/out/spv/shadow.spvasm +++ b/tests/out/spv/shadow.spvasm @@ -1,430 +1,429 @@ ; SPIR-V ; Version: 1.2 ; Generator: rspirv -; Bound: 271 +; Bound: 270 OpCapability Shader OpExtension "SPV_KHR_storage_buffer_storage_class" %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint Vertex %90 "vs_main" %80 %83 %85 %87 %89 -OpEntryPoint Fragment %149 "fs_main" %140 %143 %146 %148 -OpEntryPoint Fragment %218 "fs_main_without_storage" %211 %213 %215 %217 -OpExecutionMode %149 OriginUpperLeft -OpExecutionMode %218 OriginUpperLeft -OpName %7 "c_max_lights" -OpMemberName %13 0 "view_proj" -OpMemberName %13 1 "num_lights" -OpName %13 "Globals" -OpMemberName %14 0 "world" -OpMemberName %14 1 "color" -OpName %14 "Entity" -OpMemberName %16 0 "proj_position" -OpMemberName %16 1 "world_normal" -OpMemberName %16 2 "world_position" -OpName %16 "VertexOutput" -OpMemberName %19 0 "proj" -OpMemberName %19 1 "pos" -OpMemberName %19 2 "color" -OpName %19 "Light" -OpName %26 "c_ambient" -OpName %27 "u_globals" -OpName %30 "u_entity" -OpName %33 "s_lights" -OpName %36 "u_lights" -OpName %39 "t_shadow" -OpName %41 "sampler_shadow" -OpName %44 "light_id" -OpName %45 "homogeneous_coords" -OpName %46 "fetch_shadow" -OpName %76 "out" -OpName %80 "position" -OpName %83 "normal" -OpName %85 "proj_position" -OpName %87 "world_normal" -OpName %89 "world_position" -OpName %90 "vs_main" -OpName %133 "color" -OpName %135 "i" -OpName %140 "proj_position" -OpName %143 "world_normal" -OpName %146 "world_position" -OpName %149 "fs_main" -OpName %205 "color" -OpName %207 "i" -OpName %211 "proj_position" -OpName %213 "world_normal" -OpName %215 "world_position" -OpName %218 "fs_main_without_storage" -OpMemberDecorate %13 0 Offset 0 -OpMemberDecorate %13 0 ColMajor -OpMemberDecorate %13 0 MatrixStride 16 -OpMemberDecorate %13 1 Offset 64 -OpMemberDecorate %14 0 Offset 0 -OpMemberDecorate %14 0 ColMajor -OpMemberDecorate %14 0 MatrixStride 16 -OpMemberDecorate %14 1 Offset 64 -OpMemberDecorate %16 0 Offset 0 -OpMemberDecorate %16 1 Offset 16 -OpMemberDecorate %16 2 Offset 32 -OpMemberDecorate %19 0 Offset 0 -OpMemberDecorate %19 0 ColMajor -OpMemberDecorate %19 0 MatrixStride 16 -OpMemberDecorate %19 1 Offset 64 -OpMemberDecorate %19 2 Offset 80 -OpDecorate %20 ArrayStride 96 -OpDecorate %21 ArrayStride 96 -OpDecorate %27 DescriptorSet 0 -OpDecorate %27 Binding 0 -OpDecorate %28 Block -OpMemberDecorate %28 0 Offset 0 -OpDecorate %30 DescriptorSet 1 -OpDecorate %30 Binding 0 -OpDecorate %31 Block -OpMemberDecorate %31 0 Offset 0 -OpDecorate %33 NonWritable -OpDecorate %33 DescriptorSet 0 -OpDecorate %33 Binding 1 -OpDecorate %34 Block -OpMemberDecorate %34 0 Offset 0 -OpDecorate %36 DescriptorSet 0 -OpDecorate %36 Binding 1 -OpDecorate %37 Block -OpMemberDecorate %37 0 Offset 0 +OpEntryPoint Vertex %88 "vs_main" %78 %81 %83 %85 %87 +OpEntryPoint Fragment %148 "fs_main" %139 %142 %145 %147 +OpEntryPoint Fragment %217 "fs_main_without_storage" %210 %212 %214 %216 +OpExecutionMode %148 OriginUpperLeft +OpExecutionMode %217 OriginUpperLeft +OpMemberName %8 0 "view_proj" +OpMemberName %8 1 "num_lights" +OpName %8 "Globals" +OpMemberName %9 0 "world" +OpMemberName %9 1 "color" +OpName %9 "Entity" +OpMemberName %11 0 "proj_position" +OpMemberName %11 1 "world_normal" +OpMemberName %11 2 "world_position" +OpName %11 "VertexOutput" +OpMemberName %15 0 "proj" +OpMemberName %15 1 "pos" +OpMemberName %15 2 "color" +OpName %15 "Light" +OpName %24 "c_ambient" +OpName %18 "c_max_lights" +OpName %25 "u_globals" +OpName %28 "u_entity" +OpName %31 "s_lights" +OpName %34 "u_lights" +OpName %37 "t_shadow" +OpName %39 "sampler_shadow" +OpName %42 "light_id" +OpName %43 "homogeneous_coords" +OpName %44 "fetch_shadow" +OpName %74 "out" +OpName %78 "position" +OpName %81 "normal" +OpName %83 "proj_position" +OpName %85 "world_normal" +OpName %87 "world_position" +OpName %88 "vs_main" +OpName %132 "color" +OpName %134 "i" +OpName %139 "proj_position" +OpName %142 "world_normal" +OpName %145 "world_position" +OpName %148 "fs_main" +OpName %204 "color" +OpName %206 "i" +OpName %210 "proj_position" +OpName %212 "world_normal" +OpName %214 "world_position" +OpName %217 "fs_main_without_storage" +OpMemberDecorate %8 0 Offset 0 +OpMemberDecorate %8 0 ColMajor +OpMemberDecorate %8 0 MatrixStride 16 +OpMemberDecorate %8 1 Offset 64 +OpMemberDecorate %9 0 Offset 0 +OpMemberDecorate %9 0 ColMajor +OpMemberDecorate %9 0 MatrixStride 16 +OpMemberDecorate %9 1 Offset 64 +OpMemberDecorate %11 0 Offset 0 +OpMemberDecorate %11 1 Offset 16 +OpMemberDecorate %11 2 Offset 32 +OpMemberDecorate %15 0 Offset 0 +OpMemberDecorate %15 0 ColMajor +OpMemberDecorate %15 0 MatrixStride 16 +OpMemberDecorate %15 1 Offset 64 +OpMemberDecorate %15 2 Offset 80 +OpDecorate %16 ArrayStride 96 +OpDecorate %17 ArrayStride 96 +OpDecorate %25 DescriptorSet 0 +OpDecorate %25 Binding 0 +OpDecorate %26 Block +OpMemberDecorate %26 0 Offset 0 +OpDecorate %28 DescriptorSet 1 +OpDecorate %28 Binding 0 +OpDecorate %29 Block +OpMemberDecorate %29 0 Offset 0 +OpDecorate %31 NonWritable +OpDecorate %31 DescriptorSet 0 +OpDecorate %31 Binding 1 +OpDecorate %32 Block +OpMemberDecorate %32 0 Offset 0 +OpDecorate %34 DescriptorSet 0 +OpDecorate %34 Binding 1 +OpDecorate %35 Block +OpMemberDecorate %35 0 Offset 0 +OpDecorate %37 DescriptorSet 0 +OpDecorate %37 Binding 2 OpDecorate %39 DescriptorSet 0 -OpDecorate %39 Binding 2 -OpDecorate %41 DescriptorSet 0 -OpDecorate %41 Binding 3 -OpDecorate %80 Location 0 -OpDecorate %83 Location 1 -OpDecorate %85 BuiltIn Position -OpDecorate %87 Location 0 -OpDecorate %89 Location 1 -OpDecorate %140 BuiltIn FragCoord -OpDecorate %143 Location 0 -OpDecorate %146 Location 1 -OpDecorate %148 Location 0 -OpDecorate %211 BuiltIn FragCoord -OpDecorate %213 Location 0 -OpDecorate %215 Location 1 -OpDecorate %217 Location 0 +OpDecorate %39 Binding 3 +OpDecorate %78 Location 0 +OpDecorate %81 Location 1 +OpDecorate %83 BuiltIn Position +OpDecorate %85 Location 0 +OpDecorate %87 Location 1 +OpDecorate %139 BuiltIn FragCoord +OpDecorate %142 Location 0 +OpDecorate %145 Location 1 +OpDecorate %147 Location 0 +OpDecorate %210 BuiltIn FragCoord +OpDecorate %212 Location 0 +OpDecorate %214 Location 1 +OpDecorate %216 Location 0 %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 10 -%6 = OpTypeFloat 32 -%5 = OpConstant %6 0.05 -%8 = OpTypeInt 32 0 -%7 = OpConstant %8 10 -%9 = OpConstant %8 1 -%11 = OpTypeVector %6 4 -%10 = OpTypeMatrix %11 4 -%12 = OpTypeVector %8 4 -%13 = OpTypeStruct %10 %12 -%14 = OpTypeStruct %10 %11 -%15 = OpTypeVector %6 3 -%16 = OpTypeStruct %11 %15 %11 -%17 = OpTypeVector %4 4 -%18 = OpTypeMatrix %15 3 -%19 = OpTypeStruct %10 %11 %11 -%20 = OpTypeRuntimeArray %19 -%22 = OpConstant %8 10 -%21 = OpTypeArray %19 %22 -%23 = OpTypeImage %6 2D 1 1 0 1 Unknown -%24 = OpTypeSampler -%25 = OpTypeVector %6 2 -%26 = OpConstantComposite %15 %5 %5 %5 -%28 = OpTypeStruct %13 -%29 = OpTypePointer Uniform %28 -%27 = OpVariable %29 Uniform -%31 = OpTypeStruct %14 -%32 = OpTypePointer Uniform %31 -%30 = OpVariable %32 Uniform -%34 = OpTypeStruct %20 -%35 = OpTypePointer StorageBuffer %34 -%33 = OpVariable %35 StorageBuffer -%37 = OpTypeStruct %21 -%38 = OpTypePointer Uniform %37 -%36 = OpVariable %38 Uniform -%40 = OpTypePointer UniformConstant %23 +%5 = OpTypeFloat 32 +%4 = OpTypeVector %5 4 +%3 = OpTypeMatrix %4 4 +%7 = OpTypeInt 32 0 +%6 = OpTypeVector %7 4 +%8 = OpTypeStruct %3 %6 +%9 = OpTypeStruct %3 %4 +%10 = OpTypeVector %5 3 +%11 = OpTypeStruct %4 %10 %4 +%13 = OpTypeInt 32 1 +%12 = OpTypeVector %13 4 +%14 = OpTypeMatrix %10 3 +%15 = OpTypeStruct %3 %4 %4 +%16 = OpTypeRuntimeArray %15 +%18 = OpConstant %7 10 +%17 = OpTypeArray %15 %18 +%19 = OpTypeImage %5 2D 1 1 0 1 Unknown +%20 = OpTypeSampler +%21 = OpTypeVector %5 2 +%22 = OpConstant %13 10 +%23 = OpConstant %5 0.05 +%24 = OpConstantComposite %10 %23 %23 %23 +%26 = OpTypeStruct %8 +%27 = OpTypePointer Uniform %26 +%25 = OpVariable %27 Uniform +%29 = OpTypeStruct %9 +%30 = OpTypePointer Uniform %29 +%28 = OpVariable %30 Uniform +%32 = OpTypeStruct %16 +%33 = OpTypePointer StorageBuffer %32 +%31 = OpVariable %33 StorageBuffer +%35 = OpTypeStruct %17 +%36 = OpTypePointer Uniform %35 +%34 = OpVariable %36 Uniform +%38 = OpTypePointer UniformConstant %19 +%37 = OpVariable %38 UniformConstant +%40 = OpTypePointer UniformConstant %20 %39 = OpVariable %40 UniformConstant -%42 = OpTypePointer UniformConstant %24 -%41 = OpVariable %42 UniformConstant -%47 = OpTypeFunction %6 %8 %11 -%50 = OpConstant %6 0.0 -%51 = OpConstant %6 1.0 -%52 = OpConstant %6 0.5 -%53 = OpConstant %6 -0.5 -%56 = OpTypeBool -%71 = OpTypeSampledImage %23 -%77 = OpTypePointer Function %16 -%78 = OpConstantNull %16 -%81 = OpTypePointer Input %17 -%80 = OpVariable %81 Input -%83 = OpVariable %81 Input -%86 = OpTypePointer Output %11 +%45 = OpTypeFunction %5 %7 %4 +%48 = OpConstant %5 0.0 +%49 = OpConstant %5 1.0 +%50 = OpConstant %5 0.5 +%51 = OpConstant %5 -0.5 +%54 = OpTypeBool +%69 = OpTypeSampledImage %19 +%75 = OpTypePointer Function %11 +%76 = OpConstantNull %11 +%79 = OpTypePointer Input %12 +%78 = OpVariable %79 Input +%81 = OpVariable %79 Input +%84 = OpTypePointer Output %4 +%83 = OpVariable %84 Output +%86 = OpTypePointer Output %10 %85 = OpVariable %86 Output -%88 = OpTypePointer Output %15 -%87 = OpVariable %88 Output -%89 = OpVariable %86 Output -%91 = OpTypeFunction %2 -%92 = OpTypePointer Uniform %13 -%93 = OpConstant %8 0 -%95 = OpTypePointer Uniform %14 -%98 = OpTypePointer Uniform %10 -%105 = OpTypePointer Function %15 -%113 = OpTypeVector %4 3 -%118 = OpTypePointer Function %11 -%119 = OpConstant %8 2 -%127 = OpTypePointer Output %6 -%134 = OpConstantNull %15 -%136 = OpTypePointer Function %8 -%137 = OpConstantNull %8 -%141 = OpTypePointer Input %11 -%140 = OpVariable %141 Input -%144 = OpTypePointer Input %15 -%143 = OpVariable %144 Input -%146 = OpVariable %141 Input -%148 = OpVariable %86 Output -%152 = OpTypePointer StorageBuffer %20 -%164 = OpTypePointer Uniform %12 -%165 = OpTypePointer Uniform %8 -%175 = OpTypePointer StorageBuffer %19 -%201 = OpTypePointer Uniform %11 -%206 = OpConstantNull %15 -%208 = OpConstantNull %8 -%211 = OpVariable %141 Input -%213 = OpVariable %144 Input -%215 = OpVariable %141 Input -%217 = OpVariable %86 Output -%221 = OpTypePointer Uniform %21 -%242 = OpTypePointer Uniform %19 -%46 = OpFunction %6 None %47 -%44 = OpFunctionParameter %8 -%45 = OpFunctionParameter %11 -%43 = OpLabel -%48 = OpLoad %23 %39 -%49 = OpLoad %24 %41 -OpBranch %54 -%54 = OpLabel -%55 = OpCompositeExtract %6 %45 3 -%57 = OpFOrdLessThanEqual %56 %55 %50 -OpSelectionMerge %58 None -OpBranchConditional %57 %59 %58 -%59 = OpLabel -OpReturnValue %51 -%58 = OpLabel -%60 = OpCompositeConstruct %25 %52 %53 -%61 = OpCompositeExtract %6 %45 3 -%62 = OpFDiv %6 %51 %61 -%63 = OpVectorShuffle %25 %45 %45 0 1 -%64 = OpFMul %25 %63 %60 -%65 = OpVectorTimesScalar %25 %64 %62 -%66 = OpCompositeConstruct %25 %52 %52 -%67 = OpFAdd %25 %65 %66 -%68 = OpBitcast %4 %44 -%69 = OpCompositeExtract %6 %45 2 -%70 = OpFMul %6 %69 %62 -%72 = OpConvertSToF %6 %68 -%73 = OpCompositeConstruct %15 %67 %72 -%74 = OpSampledImage %71 %48 %49 -%75 = OpImageSampleDrefExplicitLod %6 %74 %73 %70 Lod %50 -OpReturnValue %75 +%87 = OpVariable %84 Output +%89 = OpTypeFunction %2 +%90 = OpTypePointer Uniform %8 +%91 = OpConstant %7 0 +%93 = OpTypePointer Uniform %9 +%96 = OpTypePointer Uniform %3 +%103 = OpTypePointer Function %10 +%111 = OpTypeVector %13 3 +%115 = OpConstant %7 1 +%117 = OpTypePointer Function %4 +%118 = OpConstant %7 2 +%126 = OpTypePointer Output %5 +%133 = OpConstantNull %10 +%135 = OpTypePointer Function %7 +%136 = OpConstantNull %7 +%140 = OpTypePointer Input %4 +%139 = OpVariable %140 Input +%143 = OpTypePointer Input %10 +%142 = OpVariable %143 Input +%145 = OpVariable %140 Input +%147 = OpVariable %84 Output +%151 = OpTypePointer StorageBuffer %16 +%163 = OpTypePointer Uniform %6 +%164 = OpTypePointer Uniform %7 +%174 = OpTypePointer StorageBuffer %15 +%200 = OpTypePointer Uniform %4 +%205 = OpConstantNull %10 +%207 = OpConstantNull %7 +%210 = OpVariable %140 Input +%212 = OpVariable %143 Input +%214 = OpVariable %140 Input +%216 = OpVariable %84 Output +%220 = OpTypePointer Uniform %17 +%241 = OpTypePointer Uniform %15 +%44 = OpFunction %5 None %45 +%42 = OpFunctionParameter %7 +%43 = OpFunctionParameter %4 +%41 = OpLabel +%46 = OpLoad %19 %37 +%47 = OpLoad %20 %39 +OpBranch %52 +%52 = OpLabel +%53 = OpCompositeExtract %5 %43 3 +%55 = OpFOrdLessThanEqual %54 %53 %48 +OpSelectionMerge %56 None +OpBranchConditional %55 %57 %56 +%57 = OpLabel +OpReturnValue %49 +%56 = OpLabel +%58 = OpCompositeConstruct %21 %50 %51 +%59 = OpCompositeExtract %5 %43 3 +%60 = OpFDiv %5 %49 %59 +%61 = OpVectorShuffle %21 %43 %43 0 1 +%62 = OpFMul %21 %61 %58 +%63 = OpVectorTimesScalar %21 %62 %60 +%64 = OpCompositeConstruct %21 %50 %50 +%65 = OpFAdd %21 %63 %64 +%66 = OpBitcast %13 %42 +%67 = OpCompositeExtract %5 %43 2 +%68 = OpFMul %5 %67 %60 +%70 = OpConvertSToF %5 %66 +%71 = OpCompositeConstruct %10 %65 %70 +%72 = OpSampledImage %69 %46 %47 +%73 = OpImageSampleDrefExplicitLod %5 %72 %71 %68 Lod %48 +OpReturnValue %73 OpFunctionEnd -%90 = OpFunction %2 None %91 -%79 = OpLabel -%76 = OpVariable %77 Function %78 -%82 = OpLoad %17 %80 -%84 = OpLoad %17 %83 -%94 = OpAccessChain %92 %27 %93 -%96 = OpAccessChain %95 %30 %93 -OpBranch %97 -%97 = OpLabel -%99 = OpAccessChain %98 %96 %93 -%100 = OpLoad %10 %99 -%101 = OpAccessChain %98 %96 %93 -%102 = OpLoad %10 %101 -%103 = OpConvertSToF %11 %82 -%104 = OpMatrixTimesVector %11 %102 %103 -%106 = OpCompositeExtract %11 %100 0 -%107 = OpVectorShuffle %15 %106 %106 0 1 2 -%108 = OpCompositeExtract %11 %100 1 -%109 = OpVectorShuffle %15 %108 %108 0 1 2 -%110 = OpCompositeExtract %11 %100 2 -%111 = OpVectorShuffle %15 %110 %110 0 1 2 -%112 = OpCompositeConstruct %18 %107 %109 %111 -%114 = OpVectorShuffle %113 %84 %84 0 1 2 -%115 = OpConvertSToF %15 %114 -%116 = OpMatrixTimesVector %15 %112 %115 -%117 = OpAccessChain %105 %76 %9 -OpStore %117 %116 -%120 = OpAccessChain %118 %76 %119 -OpStore %120 %104 -%121 = OpAccessChain %98 %94 %93 -%122 = OpLoad %10 %121 -%123 = OpMatrixTimesVector %11 %122 %104 -%124 = OpAccessChain %118 %76 %93 -OpStore %124 %123 -%125 = OpLoad %16 %76 -%126 = OpCompositeExtract %11 %125 0 -OpStore %85 %126 -%128 = OpAccessChain %127 %85 %9 -%129 = OpLoad %6 %128 -%130 = OpFNegate %6 %129 -OpStore %128 %130 -%131 = OpCompositeExtract %15 %125 1 +%88 = OpFunction %2 None %89 +%77 = OpLabel +%74 = OpVariable %75 Function %76 +%80 = OpLoad %12 %78 +%82 = OpLoad %12 %81 +%92 = OpAccessChain %90 %25 %91 +%94 = OpAccessChain %93 %28 %91 +OpBranch %95 +%95 = OpLabel +%97 = OpAccessChain %96 %94 %91 +%98 = OpLoad %3 %97 +%99 = OpAccessChain %96 %94 %91 +%100 = OpLoad %3 %99 +%101 = OpConvertSToF %4 %80 +%102 = OpMatrixTimesVector %4 %100 %101 +%104 = OpCompositeExtract %4 %98 0 +%105 = OpVectorShuffle %10 %104 %104 0 1 2 +%106 = OpCompositeExtract %4 %98 1 +%107 = OpVectorShuffle %10 %106 %106 0 1 2 +%108 = OpCompositeExtract %4 %98 2 +%109 = OpVectorShuffle %10 %108 %108 0 1 2 +%110 = OpCompositeConstruct %14 %105 %107 %109 +%112 = OpVectorShuffle %111 %82 %82 0 1 2 +%113 = OpConvertSToF %10 %112 +%114 = OpMatrixTimesVector %10 %110 %113 +%116 = OpAccessChain %103 %74 %115 +OpStore %116 %114 +%119 = OpAccessChain %117 %74 %118 +OpStore %119 %102 +%120 = OpAccessChain %96 %92 %91 +%121 = OpLoad %3 %120 +%122 = OpMatrixTimesVector %4 %121 %102 +%123 = OpAccessChain %117 %74 %91 +OpStore %123 %122 +%124 = OpLoad %11 %74 +%125 = OpCompositeExtract %4 %124 0 +OpStore %83 %125 +%127 = OpAccessChain %126 %83 %115 +%128 = OpLoad %5 %127 +%129 = OpFNegate %5 %128 +OpStore %127 %129 +%130 = OpCompositeExtract %10 %124 1 +OpStore %85 %130 +%131 = OpCompositeExtract %4 %124 2 OpStore %87 %131 -%132 = OpCompositeExtract %11 %125 2 -OpStore %89 %132 OpReturn OpFunctionEnd -%149 = OpFunction %2 None %91 -%138 = OpLabel -%133 = OpVariable %105 Function %134 -%135 = OpVariable %136 Function %137 -%142 = OpLoad %11 %140 -%145 = OpLoad %15 %143 -%147 = OpLoad %11 %146 -%139 = OpCompositeConstruct %16 %142 %145 %147 -%150 = OpAccessChain %92 %27 %93 -%151 = OpAccessChain %95 %30 %93 -%153 = OpAccessChain %152 %33 %93 -%154 = OpLoad %23 %39 -%155 = OpLoad %24 %41 -OpBranch %156 -%156 = OpLabel -%157 = OpCompositeExtract %15 %139 1 -%158 = OpExtInst %15 %1 Normalize %157 -OpStore %133 %26 -OpStore %135 %93 -OpBranch %159 -%159 = OpLabel -OpLoopMerge %160 %162 None -OpBranch %161 -%161 = OpLabel -%163 = OpLoad %8 %135 -%166 = OpAccessChain %165 %150 %9 %93 -%167 = OpLoad %8 %166 -%168 = OpExtInst %8 %1 UMin %167 %7 -%169 = OpULessThan %56 %163 %168 -OpSelectionMerge %170 None -OpBranchConditional %169 %170 %171 -%171 = OpLabel +%148 = OpFunction %2 None %89 +%137 = OpLabel +%132 = OpVariable %103 Function %133 +%134 = OpVariable %135 Function %136 +%141 = OpLoad %4 %139 +%144 = OpLoad %10 %142 +%146 = OpLoad %4 %145 +%138 = OpCompositeConstruct %11 %141 %144 %146 +%149 = OpAccessChain %90 %25 %91 +%150 = OpAccessChain %93 %28 %91 +%152 = OpAccessChain %151 %31 %91 +%153 = OpLoad %19 %37 +%154 = OpLoad %20 %39 +OpBranch %155 +%155 = OpLabel +%156 = OpCompositeExtract %10 %138 1 +%157 = OpExtInst %10 %1 Normalize %156 +OpStore %132 %24 +OpStore %134 %91 +OpBranch %158 +%158 = OpLabel +OpLoopMerge %159 %161 None OpBranch %160 +%160 = OpLabel +%162 = OpLoad %7 %134 +%165 = OpAccessChain %164 %149 %115 %91 +%166 = OpLoad %7 %165 +%167 = OpExtInst %7 %1 UMin %166 %18 +%168 = OpULessThan %54 %162 %167 +OpSelectionMerge %169 None +OpBranchConditional %168 %169 %170 %170 = OpLabel +OpBranch %159 +%169 = OpLabel +OpBranch %171 +%171 = OpLabel +%173 = OpLoad %7 %134 +%175 = OpAccessChain %174 %152 %173 +%176 = OpLoad %15 %175 +%177 = OpLoad %7 %134 +%178 = OpCompositeExtract %3 %176 0 +%179 = OpCompositeExtract %4 %138 2 +%180 = OpMatrixTimesVector %4 %178 %179 +%181 = OpFunctionCall %5 %44 %177 %180 +%182 = OpCompositeExtract %4 %176 1 +%183 = OpVectorShuffle %10 %182 %182 0 1 2 +%184 = OpCompositeExtract %4 %138 2 +%185 = OpVectorShuffle %10 %184 %184 0 1 2 +%186 = OpFSub %10 %183 %185 +%187 = OpExtInst %10 %1 Normalize %186 +%188 = OpDot %5 %157 %187 +%189 = OpExtInst %5 %1 FMax %48 %188 +%190 = OpFMul %5 %181 %189 +%191 = OpCompositeExtract %4 %176 2 +%192 = OpVectorShuffle %10 %191 %191 0 1 2 +%193 = OpVectorTimesScalar %10 %192 %190 +%194 = OpLoad %10 %132 +%195 = OpFAdd %10 %194 %193 +OpStore %132 %195 OpBranch %172 %172 = OpLabel -%174 = OpLoad %8 %135 -%176 = OpAccessChain %175 %153 %174 -%177 = OpLoad %19 %176 -%178 = OpLoad %8 %135 -%179 = OpCompositeExtract %10 %177 0 -%180 = OpCompositeExtract %11 %139 2 -%181 = OpMatrixTimesVector %11 %179 %180 -%182 = OpFunctionCall %6 %46 %178 %181 -%183 = OpCompositeExtract %11 %177 1 -%184 = OpVectorShuffle %15 %183 %183 0 1 2 -%185 = OpCompositeExtract %11 %139 2 -%186 = OpVectorShuffle %15 %185 %185 0 1 2 -%187 = OpFSub %15 %184 %186 -%188 = OpExtInst %15 %1 Normalize %187 -%189 = OpDot %6 %158 %188 -%190 = OpExtInst %6 %1 FMax %50 %189 -%191 = OpFMul %6 %182 %190 -%192 = OpCompositeExtract %11 %177 2 -%193 = OpVectorShuffle %15 %192 %192 0 1 2 -%194 = OpVectorTimesScalar %15 %193 %191 -%195 = OpLoad %15 %133 -%196 = OpFAdd %15 %195 %194 -OpStore %133 %196 -OpBranch %173 -%173 = OpLabel -OpBranch %162 -%162 = OpLabel -%197 = OpLoad %8 %135 -%198 = OpIAdd %8 %197 %9 -OpStore %135 %198 -OpBranch %159 -%160 = OpLabel -%199 = OpLoad %15 %133 -%200 = OpCompositeConstruct %11 %199 %51 -%202 = OpAccessChain %201 %151 %9 -%203 = OpLoad %11 %202 -%204 = OpFMul %11 %200 %203 -OpStore %148 %204 +OpBranch %161 +%161 = OpLabel +%196 = OpLoad %7 %134 +%197 = OpIAdd %7 %196 %115 +OpStore %134 %197 +OpBranch %158 +%159 = OpLabel +%198 = OpLoad %10 %132 +%199 = OpCompositeConstruct %4 %198 %49 +%201 = OpAccessChain %200 %150 %115 +%202 = OpLoad %4 %201 +%203 = OpFMul %4 %199 %202 +OpStore %147 %203 OpReturn OpFunctionEnd -%218 = OpFunction %2 None %91 -%209 = OpLabel -%205 = OpVariable %105 Function %206 -%207 = OpVariable %136 Function %208 -%212 = OpLoad %11 %211 -%214 = OpLoad %15 %213 -%216 = OpLoad %11 %215 -%210 = OpCompositeConstruct %16 %212 %214 %216 -%219 = OpAccessChain %92 %27 %93 -%220 = OpAccessChain %95 %30 %93 -%222 = OpAccessChain %221 %36 %93 -%223 = OpLoad %23 %39 -%224 = OpLoad %24 %41 -OpBranch %225 -%225 = OpLabel -%226 = OpCompositeExtract %15 %210 1 -%227 = OpExtInst %15 %1 Normalize %226 -OpStore %205 %26 -OpStore %207 %93 -OpBranch %228 -%228 = OpLabel -OpLoopMerge %229 %231 None -OpBranch %230 -%230 = OpLabel -%232 = OpLoad %8 %207 -%233 = OpAccessChain %165 %219 %9 %93 -%234 = OpLoad %8 %233 -%235 = OpExtInst %8 %1 UMin %234 %7 -%236 = OpULessThan %56 %232 %235 -OpSelectionMerge %237 None -OpBranchConditional %236 %237 %238 -%238 = OpLabel +%217 = OpFunction %2 None %89 +%208 = OpLabel +%204 = OpVariable %103 Function %205 +%206 = OpVariable %135 Function %207 +%211 = OpLoad %4 %210 +%213 = OpLoad %10 %212 +%215 = OpLoad %4 %214 +%209 = OpCompositeConstruct %11 %211 %213 %215 +%218 = OpAccessChain %90 %25 %91 +%219 = OpAccessChain %93 %28 %91 +%221 = OpAccessChain %220 %34 %91 +%222 = OpLoad %19 %37 +%223 = OpLoad %20 %39 +OpBranch %224 +%224 = OpLabel +%225 = OpCompositeExtract %10 %209 1 +%226 = OpExtInst %10 %1 Normalize %225 +OpStore %204 %24 +OpStore %206 %91 +OpBranch %227 +%227 = OpLabel +OpLoopMerge %228 %230 None OpBranch %229 +%229 = OpLabel +%231 = OpLoad %7 %206 +%232 = OpAccessChain %164 %218 %115 %91 +%233 = OpLoad %7 %232 +%234 = OpExtInst %7 %1 UMin %233 %18 +%235 = OpULessThan %54 %231 %234 +OpSelectionMerge %236 None +OpBranchConditional %235 %236 %237 %237 = OpLabel +OpBranch %228 +%236 = OpLabel +OpBranch %238 +%238 = OpLabel +%240 = OpLoad %7 %206 +%242 = OpAccessChain %241 %221 %240 +%243 = OpLoad %15 %242 +%244 = OpLoad %7 %206 +%245 = OpCompositeExtract %3 %243 0 +%246 = OpCompositeExtract %4 %209 2 +%247 = OpMatrixTimesVector %4 %245 %246 +%248 = OpFunctionCall %5 %44 %244 %247 +%249 = OpCompositeExtract %4 %243 1 +%250 = OpVectorShuffle %10 %249 %249 0 1 2 +%251 = OpCompositeExtract %4 %209 2 +%252 = OpVectorShuffle %10 %251 %251 0 1 2 +%253 = OpFSub %10 %250 %252 +%254 = OpExtInst %10 %1 Normalize %253 +%255 = OpDot %5 %226 %254 +%256 = OpExtInst %5 %1 FMax %48 %255 +%257 = OpFMul %5 %248 %256 +%258 = OpCompositeExtract %4 %243 2 +%259 = OpVectorShuffle %10 %258 %258 0 1 2 +%260 = OpVectorTimesScalar %10 %259 %257 +%261 = OpLoad %10 %204 +%262 = OpFAdd %10 %261 %260 +OpStore %204 %262 OpBranch %239 %239 = OpLabel -%241 = OpLoad %8 %207 -%243 = OpAccessChain %242 %222 %241 -%244 = OpLoad %19 %243 -%245 = OpLoad %8 %207 -%246 = OpCompositeExtract %10 %244 0 -%247 = OpCompositeExtract %11 %210 2 -%248 = OpMatrixTimesVector %11 %246 %247 -%249 = OpFunctionCall %6 %46 %245 %248 -%250 = OpCompositeExtract %11 %244 1 -%251 = OpVectorShuffle %15 %250 %250 0 1 2 -%252 = OpCompositeExtract %11 %210 2 -%253 = OpVectorShuffle %15 %252 %252 0 1 2 -%254 = OpFSub %15 %251 %253 -%255 = OpExtInst %15 %1 Normalize %254 -%256 = OpDot %6 %227 %255 -%257 = OpExtInst %6 %1 FMax %50 %256 -%258 = OpFMul %6 %249 %257 -%259 = OpCompositeExtract %11 %244 2 -%260 = OpVectorShuffle %15 %259 %259 0 1 2 -%261 = OpVectorTimesScalar %15 %260 %258 -%262 = OpLoad %15 %205 -%263 = OpFAdd %15 %262 %261 -OpStore %205 %263 -OpBranch %240 -%240 = OpLabel -OpBranch %231 -%231 = OpLabel -%264 = OpLoad %8 %207 -%265 = OpIAdd %8 %264 %9 -OpStore %207 %265 -OpBranch %228 -%229 = OpLabel -%266 = OpLoad %15 %205 -%267 = OpCompositeConstruct %11 %266 %51 -%268 = OpAccessChain %201 %220 %9 -%269 = OpLoad %11 %268 -%270 = OpFMul %11 %267 %269 -OpStore %217 %270 +OpBranch %230 +%230 = OpLabel +%263 = OpLoad %7 %206 +%264 = OpIAdd %7 %263 %115 +OpStore %206 %264 +OpBranch %227 +%228 = OpLabel +%265 = OpLoad %10 %204 +%266 = OpCompositeConstruct %4 %265 %49 +%267 = OpAccessChain %200 %219 %115 +%268 = OpLoad %4 %267 +%269 = OpFMul %4 %266 %268 +OpStore %216 %269 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/workgroup-uniform-load.spvasm b/tests/out/spv/workgroup-uniform-load.spvasm index c8ae47c2fa..87f212a799 100644 --- a/tests/out/spv/workgroup-uniform-load.spvasm +++ b/tests/out/spv/workgroup-uniform-load.spvasm @@ -1,67 +1,66 @@ ; SPIR-V ; Version: 1.1 ; Generator: rspirv -; Bound: 41 +; Bound: 40 OpCapability Shader %1 = OpExtInstImport "GLSL.std.450" OpMemoryModel Logical GLSL450 -OpEntryPoint GLCompute %15 "test_workgroupUniformLoad" %12 %20 -OpExecutionMode %15 LocalSize 4 1 1 -OpDecorate %6 ArrayStride 4 -OpDecorate %12 BuiltIn WorkgroupId -OpDecorate %20 BuiltIn LocalInvocationId +OpEntryPoint GLCompute %14 "test_workgroupUniformLoad" %11 %19 +OpExecutionMode %14 LocalSize 4 1 1 +OpDecorate %5 ArrayStride 4 +OpDecorate %11 BuiltIn WorkgroupId +OpDecorate %19 BuiltIn LocalInvocationId %2 = OpTypeVoid -%4 = OpTypeInt 32 0 -%3 = OpConstant %4 128 -%5 = OpTypeInt 32 1 -%7 = OpConstant %4 128 -%6 = OpTypeArray %5 %7 -%8 = OpTypeVector %4 3 -%10 = OpTypePointer Workgroup %6 -%9 = OpVariable %10 Workgroup -%13 = OpTypePointer Input %8 -%12 = OpVariable %13 Input -%16 = OpTypeFunction %2 -%17 = OpConstant %5 10 -%19 = OpConstantNull %6 -%21 = OpTypePointer Input %8 -%20 = OpVariable %21 Input -%23 = OpConstantNull %8 -%25 = OpTypeBool -%24 = OpTypeVector %25 3 -%30 = OpConstant %4 2 -%31 = OpConstant %4 264 -%34 = OpTypePointer Workgroup %5 -%15 = OpFunction %2 None %16 -%11 = OpLabel -%14 = OpLoad %8 %12 -OpBranch %18 -%18 = OpLabel -%22 = OpLoad %8 %20 -%26 = OpIEqual %24 %22 %23 -%27 = OpAll %25 %26 -OpSelectionMerge %28 None -OpBranchConditional %27 %29 %28 -%29 = OpLabel -OpStore %9 %19 -OpBranch %28 +%3 = OpTypeInt 32 0 +%4 = OpTypeInt 32 1 +%6 = OpConstant %3 128 +%5 = OpTypeArray %4 %6 +%7 = OpTypeVector %3 3 +%9 = OpTypePointer Workgroup %5 +%8 = OpVariable %9 Workgroup +%12 = OpTypePointer Input %7 +%11 = OpVariable %12 Input +%15 = OpTypeFunction %2 +%16 = OpConstant %4 10 +%18 = OpConstantNull %5 +%20 = OpTypePointer Input %7 +%19 = OpVariable %20 Input +%22 = OpConstantNull %7 +%24 = OpTypeBool +%23 = OpTypeVector %24 3 +%29 = OpConstant %3 2 +%30 = OpConstant %3 264 +%33 = OpTypePointer Workgroup %4 +%14 = OpFunction %2 None %15 +%10 = OpLabel +%13 = OpLoad %7 %11 +OpBranch %17 +%17 = OpLabel +%21 = OpLoad %7 %19 +%25 = OpIEqual %23 %21 %22 +%26 = OpAll %24 %25 +OpSelectionMerge %27 None +OpBranchConditional %26 %28 %27 %28 = OpLabel -OpControlBarrier %30 %30 %31 -OpBranch %32 -%32 = OpLabel -%33 = OpCompositeExtract %4 %14 0 -OpControlBarrier %30 %30 %31 -%35 = OpAccessChain %34 %9 %33 -%36 = OpLoad %5 %35 -OpControlBarrier %30 %30 %31 -%37 = OpSGreaterThan %25 %36 %17 -OpSelectionMerge %38 None -OpBranchConditional %37 %39 %40 -%39 = OpLabel -OpControlBarrier %30 %30 %31 +OpStore %8 %18 +OpBranch %27 +%27 = OpLabel +OpControlBarrier %29 %29 %30 +OpBranch %31 +%31 = OpLabel +%32 = OpCompositeExtract %3 %13 0 +OpControlBarrier %29 %29 %30 +%34 = OpAccessChain %33 %8 %32 +%35 = OpLoad %4 %34 +OpControlBarrier %29 %29 %30 +%36 = OpSGreaterThan %24 %35 %16 +OpSelectionMerge %37 None +OpBranchConditional %36 %38 %39 +%38 = OpLabel +OpControlBarrier %29 %29 %30 OpReturn -%40 = OpLabel +%39 = OpLabel OpReturn -%38 = OpLabel +%37 = OpLabel OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/spv/workgroup-var-init.spvasm b/tests/out/spv/workgroup-var-init.spvasm index e95a11aa90..905ed00bf3 100644 --- a/tests/out/spv/workgroup-var-init.spvasm +++ b/tests/out/spv/workgroup-var-init.spvasm @@ -8,53 +8,53 @@ OpExtension "SPV_KHR_storage_buffer_storage_class" OpMemoryModel Logical GLSL450 OpEntryPoint GLCompute %19 "main" %27 OpExecutionMode %19 LocalSize 1 1 1 -OpMemberName %12 0 "arr" -OpMemberName %12 1 "atom" -OpMemberName %12 2 "atom_arr" -OpName %12 "WStruct" +OpMemberName %10 0 "arr" +OpMemberName %10 1 "atom" +OpMemberName %10 2 "atom_arr" +OpName %10 "WStruct" OpName %13 "w_mem" OpName %15 "output" OpName %19 "main" +OpDecorate %4 ArrayStride 4 OpDecorate %7 ArrayStride 4 -OpDecorate %9 ArrayStride 4 -OpDecorate %11 ArrayStride 32 -OpMemberDecorate %12 0 Offset 0 -OpMemberDecorate %12 1 Offset 2048 -OpMemberDecorate %12 2 Offset 2052 +OpDecorate %9 ArrayStride 32 +OpMemberDecorate %10 0 Offset 0 +OpMemberDecorate %10 1 Offset 2048 +OpMemberDecorate %10 2 Offset 2052 OpDecorate %15 DescriptorSet 0 OpDecorate %15 Binding 0 OpDecorate %16 Block OpMemberDecorate %16 0 Offset 0 OpDecorate %27 BuiltIn LocalInvocationId %2 = OpTypeVoid -%4 = OpTypeInt 32 1 -%3 = OpConstant %4 512 -%5 = OpConstant %4 8 -%6 = OpTypeInt 32 0 -%8 = OpConstant %6 512 +%3 = OpTypeInt 32 0 +%5 = OpConstant %3 512 +%4 = OpTypeArray %3 %5 +%6 = OpTypeInt 32 1 +%8 = OpConstant %3 8 %7 = OpTypeArray %6 %8 -%10 = OpConstant %6 8 -%9 = OpTypeArray %4 %10 -%11 = OpTypeArray %9 %10 -%12 = OpTypeStruct %7 %4 %11 -%14 = OpTypePointer Workgroup %12 +%9 = OpTypeArray %7 %8 +%10 = OpTypeStruct %4 %6 %9 +%11 = OpConstant %6 512 +%12 = OpConstant %6 8 +%14 = OpTypePointer Workgroup %10 %13 = OpVariable %14 Workgroup -%16 = OpTypeStruct %7 +%16 = OpTypeStruct %4 %17 = OpTypePointer StorageBuffer %16 %15 = OpVariable %17 StorageBuffer %20 = OpTypeFunction %2 -%21 = OpTypePointer StorageBuffer %7 -%22 = OpConstant %6 0 -%25 = OpConstantNull %12 -%26 = OpTypeVector %6 3 +%21 = OpTypePointer StorageBuffer %4 +%22 = OpConstant %3 0 +%25 = OpConstantNull %10 +%26 = OpTypeVector %3 3 %28 = OpTypePointer Input %26 %27 = OpVariable %28 Input %30 = OpConstantNull %26 %32 = OpTypeBool %31 = OpTypeVector %32 3 -%37 = OpConstant %6 2 -%38 = OpConstant %6 264 -%40 = OpTypePointer Workgroup %7 +%37 = OpConstant %3 2 +%38 = OpConstant %3 264 +%40 = OpTypePointer Workgroup %4 %19 = OpFunction %2 None %20 %18 = OpLabel %23 = OpAccessChain %21 %15 %22 @@ -73,7 +73,7 @@ OpControlBarrier %37 %37 %38 OpBranch %39 %39 = OpLabel %41 = OpAccessChain %40 %13 %22 -%42 = OpLoad %7 %41 +%42 = OpLoad %4 %41 OpStore %23 %42 OpReturn OpFunctionEnd \ No newline at end of file diff --git a/tests/out/wgsl/access.wgsl b/tests/out/wgsl/access.wgsl index c8b87516f8..77ebe1ee18 100644 --- a/tests/out/wgsl/access.wgsl +++ b/tests/out/wgsl/access.wgsl @@ -41,8 +41,8 @@ fn test_matrix_within_struct_accesses() { var t: Baz; idx = 1; - let _e2 = idx; - idx = (_e2 - 1); + let _e3 = idx; + idx = (_e3 - 1); let l0_ = baz.m; let l1_ = baz.m[0]; let _e15 = idx; @@ -56,8 +56,8 @@ fn test_matrix_within_struct_accesses() { let _e43 = idx; let l6_ = baz.m[_e41][_e43]; t = Baz(mat3x2(vec2(1.0), vec2(2.0), vec2(3.0))); - let _e55 = idx; - idx = (_e55 + 1); + let _e56 = idx; + idx = (_e56 + 1); t.m = mat3x2(vec2(6.0), vec2(5.0), vec2(4.0)); t.m[0] = vec2(9.0); let _e72 = idx; @@ -78,8 +78,8 @@ fn test_matrix_within_array_within_struct_accesses() { var t_1: MatCx2InArray; idx_1 = 1; - let _e2 = idx_1; - idx_1 = (_e2 - 1); + let _e3 = idx_1; + idx_1 = (_e3 - 1); let l0_1 = nested_mat_cx2_.am; let l1_1 = nested_mat_cx2_.am[0]; let l2_1 = nested_mat_cx2_.am[0][0]; @@ -94,8 +94,8 @@ fn test_matrix_within_array_within_struct_accesses() { let _e60 = idx_1; let l7_ = nested_mat_cx2_.am[0][_e58][_e60]; t_1 = MatCx2InArray(array, 2>()); - let _e66 = idx_1; - idx_1 = (_e66 + 1); + let _e67 = idx_1; + idx_1 = (_e67 + 1); t_1.am = array, 2>(); t_1.am[0] = mat4x2(vec2(8.0), vec2(7.0), vec2(6.0), vec2(5.0)); t_1.am[0][0] = vec2(9.0); diff --git a/tests/out/wgsl/atomicCompareExchange.wgsl b/tests/out/wgsl/atomicCompareExchange.wgsl index d9f0c0add4..2ff428bd71 100644 --- a/tests/out/wgsl/atomicCompareExchange.wgsl +++ b/tests/out/wgsl/atomicCompareExchange.wgsl @@ -51,8 +51,8 @@ fn test_atomic_compare_exchange_i32_() { } } continuing { - let _e26 = i; - i = (_e26 + 1u); + let _e27 = i; + i = (_e27 + 1u); } } return; @@ -94,8 +94,8 @@ fn test_atomic_compare_exchange_u32_() { } } continuing { - let _e26 = i_1; - i_1 = (_e26 + 1u); + let _e27 = i_1; + i_1 = (_e27 + 1u); } } return; diff --git a/tests/out/wgsl/bevy-pbr-frag.wgsl b/tests/out/wgsl/bevy-pbr-frag.wgsl index 41fc6e399c..249298dcc9 100644 --- a/tests/out/wgsl/bevy-pbr-frag.wgsl +++ b/tests/out/wgsl/bevy-pbr-frag.wgsl @@ -49,10 +49,8 @@ struct FragmentOutput { } const MAX_POINT_LIGHTS: i32 = 10; - const MAX_DIRECTIONAL_LIGHTS: i32 = 1; - -const PI: f32 = 3.1415927410125732; +const PI: f32 = 3.1415927; var v_WorldPosition_1: vec3; var v_WorldNormal_1: vec3; diff --git a/tests/out/wgsl/binding-arrays.dynamic.wgsl b/tests/out/wgsl/binding-arrays.dynamic.wgsl index 523b311276..bccabd060d 100644 --- a/tests/out/wgsl/binding-arrays.dynamic.wgsl +++ b/tests/out/wgsl/binding-arrays.dynamic.wgsl @@ -5,8 +5,8 @@ var global_1: binding_array; var global_2: vec4; fn function() { - let _e13 = textureSampleLevel(global[1], global_1[1], vec2(0.5, 0.5), 0.0); - global_2 = _e13; + let _e9 = textureSampleLevel(global[1], global_1[1], vec2(0.5, 0.5), 0.0); + global_2 = _e9; return; } diff --git a/tests/out/wgsl/binding-arrays.static.wgsl b/tests/out/wgsl/binding-arrays.static.wgsl index 2c1fb2be7e..e9dec5bf13 100644 --- a/tests/out/wgsl/binding-arrays.static.wgsl +++ b/tests/out/wgsl/binding-arrays.static.wgsl @@ -5,8 +5,8 @@ var global_1: binding_array; var global_2: vec4; fn function() { - let _e14 = textureSampleLevel(global[1], global_1[1], vec2(0.5, 0.5), 0.0); - global_2 = _e14; + let _e10 = textureSampleLevel(global[1], global_1[1], vec2(0.5, 0.5), 0.0); + global_2 = _e10; return; } diff --git a/tests/out/wgsl/binding-arrays.wgsl b/tests/out/wgsl/binding-arrays.wgsl index 97c992e4e2..7f181413bb 100644 --- a/tests/out/wgsl/binding-arrays.wgsl +++ b/tests/out/wgsl/binding-arrays.wgsl @@ -49,124 +49,124 @@ fn main(fragment_in: FragmentIn) -> @location(0) vec4 { let _e32 = textureDimensions(texture_array_unbounded[non_uniform_index]); let _e33 = u2_; u2_ = (_e33 + _e32); - let _e41 = textureGather(0, texture_array_bounded[0], samp[0], uv); - let _e42 = v4_; - v4_ = (_e42 + _e41); - let _e48 = textureGather(0, texture_array_bounded[uniform_index], samp[uniform_index], uv); - let _e49 = v4_; - v4_ = (_e49 + _e48); - let _e55 = textureGather(0, texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv); - let _e56 = v4_; - v4_ = (_e56 + _e55); - let _e65 = textureGatherCompare(texture_array_depth[0], samp_comp[0], uv, 0.0); - let _e66 = v4_; - v4_ = (_e66 + _e65); - let _e73 = textureGatherCompare(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); - let _e74 = v4_; - v4_ = (_e74 + _e73); - let _e81 = textureGatherCompare(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); - let _e82 = v4_; - v4_ = (_e82 + _e81); - let _e88 = textureLoad(texture_array_unbounded[0], pix, 0); - let _e89 = v4_; - v4_ = (_e89 + _e88); - let _e94 = textureLoad(texture_array_unbounded[uniform_index], pix, 0); - let _e95 = v4_; - v4_ = (_e95 + _e94); - let _e100 = textureLoad(texture_array_unbounded[non_uniform_index], pix, 0); - let _e101 = v4_; - v4_ = (_e101 + _e100); - let _e106 = textureNumLayers(texture_array_2darray[0]); - let _e107 = u1_; - u1_ = (_e107 + _e106); - let _e111 = textureNumLayers(texture_array_2darray[uniform_index]); - let _e112 = u1_; - u1_ = (_e112 + _e111); - let _e116 = textureNumLayers(texture_array_2darray[non_uniform_index]); - let _e117 = u1_; - u1_ = (_e117 + _e116); - let _e122 = textureNumLevels(texture_array_bounded[0]); - let _e123 = u1_; - u1_ = (_e123 + _e122); - let _e127 = textureNumLevels(texture_array_bounded[uniform_index]); - let _e128 = u1_; - u1_ = (_e128 + _e127); - let _e132 = textureNumLevels(texture_array_bounded[non_uniform_index]); - let _e133 = u1_; - u1_ = (_e133 + _e132); - let _e138 = textureNumSamples(texture_array_multisampled[0]); - let _e139 = u1_; - u1_ = (_e139 + _e138); - let _e143 = textureNumSamples(texture_array_multisampled[uniform_index]); - let _e144 = u1_; - u1_ = (_e144 + _e143); - let _e148 = textureNumSamples(texture_array_multisampled[non_uniform_index]); - let _e149 = u1_; - u1_ = (_e149 + _e148); - let _e157 = textureSample(texture_array_bounded[0], samp[0], uv); - let _e158 = v4_; - v4_ = (_e158 + _e157); - let _e164 = textureSample(texture_array_bounded[uniform_index], samp[uniform_index], uv); - let _e165 = v4_; - v4_ = (_e165 + _e164); - let _e171 = textureSample(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv); - let _e172 = v4_; - v4_ = (_e172 + _e171); - let _e181 = textureSampleBias(texture_array_bounded[0], samp[0], uv, 0.0); - let _e182 = v4_; - v4_ = (_e182 + _e181); - let _e189 = textureSampleBias(texture_array_bounded[uniform_index], samp[uniform_index], uv, 0.0); - let _e190 = v4_; - v4_ = (_e190 + _e189); - let _e197 = textureSampleBias(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, 0.0); - let _e198 = v4_; - v4_ = (_e198 + _e197); - let _e207 = textureSampleCompare(texture_array_depth[0], samp_comp[0], uv, 0.0); - let _e208 = v1_; - v1_ = (_e208 + _e207); - let _e215 = textureSampleCompare(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); - let _e216 = v1_; - v1_ = (_e216 + _e215); - let _e223 = textureSampleCompare(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); - let _e224 = v1_; - v1_ = (_e224 + _e223); - let _e233 = textureSampleCompareLevel(texture_array_depth[0], samp_comp[0], uv, 0.0); - let _e234 = v1_; - v1_ = (_e234 + _e233); - let _e241 = textureSampleCompareLevel(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); - let _e242 = v1_; - v1_ = (_e242 + _e241); - let _e249 = textureSampleCompareLevel(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); - let _e250 = v1_; - v1_ = (_e250 + _e249); - let _e258 = textureSampleGrad(texture_array_bounded[0], samp[0], uv, uv, uv); - let _e259 = v4_; - v4_ = (_e259 + _e258); - let _e265 = textureSampleGrad(texture_array_bounded[uniform_index], samp[uniform_index], uv, uv, uv); - let _e266 = v4_; - v4_ = (_e266 + _e265); - let _e272 = textureSampleGrad(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, uv, uv); - let _e273 = v4_; - v4_ = (_e273 + _e272); - let _e282 = textureSampleLevel(texture_array_bounded[0], samp[0], uv, 0.0); - let _e283 = v4_; - v4_ = (_e283 + _e282); - let _e290 = textureSampleLevel(texture_array_bounded[uniform_index], samp[uniform_index], uv, 0.0); - let _e291 = v4_; - v4_ = (_e291 + _e290); - let _e298 = textureSampleLevel(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, 0.0); - let _e299 = v4_; - v4_ = (_e299 + _e298); - let _e304 = v4_; - textureStore(texture_array_storage[0], pix, _e304); + let _e42 = textureGather(0, texture_array_bounded[0], samp[0], uv); + let _e43 = v4_; + v4_ = (_e43 + _e42); + let _e50 = textureGather(0, texture_array_bounded[uniform_index], samp[uniform_index], uv); + let _e51 = v4_; + v4_ = (_e51 + _e50); + let _e58 = textureGather(0, texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv); + let _e59 = v4_; + v4_ = (_e59 + _e58); + let _e68 = textureGatherCompare(texture_array_depth[0], samp_comp[0], uv, 0.0); + let _e69 = v4_; + v4_ = (_e69 + _e68); + let _e76 = textureGatherCompare(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); + let _e77 = v4_; + v4_ = (_e77 + _e76); + let _e84 = textureGatherCompare(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); + let _e85 = v4_; + v4_ = (_e85 + _e84); + let _e91 = textureLoad(texture_array_unbounded[0], pix, 0); + let _e92 = v4_; + v4_ = (_e92 + _e91); + let _e97 = textureLoad(texture_array_unbounded[uniform_index], pix, 0); + let _e98 = v4_; + v4_ = (_e98 + _e97); + let _e103 = textureLoad(texture_array_unbounded[non_uniform_index], pix, 0); + let _e104 = v4_; + v4_ = (_e104 + _e103); + let _e109 = textureNumLayers(texture_array_2darray[0]); + let _e110 = u1_; + u1_ = (_e110 + _e109); + let _e114 = textureNumLayers(texture_array_2darray[uniform_index]); + let _e115 = u1_; + u1_ = (_e115 + _e114); + let _e119 = textureNumLayers(texture_array_2darray[non_uniform_index]); + let _e120 = u1_; + u1_ = (_e120 + _e119); + let _e125 = textureNumLevels(texture_array_bounded[0]); + let _e126 = u1_; + u1_ = (_e126 + _e125); + let _e130 = textureNumLevels(texture_array_bounded[uniform_index]); + let _e131 = u1_; + u1_ = (_e131 + _e130); + let _e135 = textureNumLevels(texture_array_bounded[non_uniform_index]); + let _e136 = u1_; + u1_ = (_e136 + _e135); + let _e141 = textureNumSamples(texture_array_multisampled[0]); + let _e142 = u1_; + u1_ = (_e142 + _e141); + let _e146 = textureNumSamples(texture_array_multisampled[uniform_index]); + let _e147 = u1_; + u1_ = (_e147 + _e146); + let _e151 = textureNumSamples(texture_array_multisampled[non_uniform_index]); + let _e152 = u1_; + u1_ = (_e152 + _e151); + let _e160 = textureSample(texture_array_bounded[0], samp[0], uv); + let _e161 = v4_; + v4_ = (_e161 + _e160); + let _e167 = textureSample(texture_array_bounded[uniform_index], samp[uniform_index], uv); + let _e168 = v4_; + v4_ = (_e168 + _e167); + let _e174 = textureSample(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv); + let _e175 = v4_; + v4_ = (_e175 + _e174); + let _e184 = textureSampleBias(texture_array_bounded[0], samp[0], uv, 0.0); + let _e185 = v4_; + v4_ = (_e185 + _e184); + let _e192 = textureSampleBias(texture_array_bounded[uniform_index], samp[uniform_index], uv, 0.0); + let _e193 = v4_; + v4_ = (_e193 + _e192); + let _e200 = textureSampleBias(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, 0.0); + let _e201 = v4_; + v4_ = (_e201 + _e200); + let _e210 = textureSampleCompare(texture_array_depth[0], samp_comp[0], uv, 0.0); + let _e211 = v1_; + v1_ = (_e211 + _e210); + let _e218 = textureSampleCompare(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); + let _e219 = v1_; + v1_ = (_e219 + _e218); + let _e226 = textureSampleCompare(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); + let _e227 = v1_; + v1_ = (_e227 + _e226); + let _e236 = textureSampleCompareLevel(texture_array_depth[0], samp_comp[0], uv, 0.0); + let _e237 = v1_; + v1_ = (_e237 + _e236); + let _e244 = textureSampleCompareLevel(texture_array_depth[uniform_index], samp_comp[uniform_index], uv, 0.0); + let _e245 = v1_; + v1_ = (_e245 + _e244); + let _e252 = textureSampleCompareLevel(texture_array_depth[non_uniform_index], samp_comp[non_uniform_index], uv, 0.0); + let _e253 = v1_; + v1_ = (_e253 + _e252); + let _e261 = textureSampleGrad(texture_array_bounded[0], samp[0], uv, uv, uv); + let _e262 = v4_; + v4_ = (_e262 + _e261); + let _e268 = textureSampleGrad(texture_array_bounded[uniform_index], samp[uniform_index], uv, uv, uv); + let _e269 = v4_; + v4_ = (_e269 + _e268); + let _e275 = textureSampleGrad(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, uv, uv); + let _e276 = v4_; + v4_ = (_e276 + _e275); + let _e285 = textureSampleLevel(texture_array_bounded[0], samp[0], uv, 0.0); + let _e286 = v4_; + v4_ = (_e286 + _e285); + let _e293 = textureSampleLevel(texture_array_bounded[uniform_index], samp[uniform_index], uv, 0.0); + let _e294 = v4_; + v4_ = (_e294 + _e293); + let _e301 = textureSampleLevel(texture_array_bounded[non_uniform_index], samp[non_uniform_index], uv, 0.0); + let _e302 = v4_; + v4_ = (_e302 + _e301); let _e307 = v4_; - textureStore(texture_array_storage[uniform_index], pix, _e307); + textureStore(texture_array_storage[0], pix, _e307); let _e310 = v4_; - textureStore(texture_array_storage[non_uniform_index], pix, _e310); - let _e311 = u2_; - let _e312 = u1_; - let v2_ = vec2((_e311 + vec2(_e312))); - let _e316 = v4_; - let _e323 = v1_; - return ((_e316 + vec4(v2_.x, v2_.y, v2_.x, v2_.y)) + vec4(_e323)); + textureStore(texture_array_storage[uniform_index], pix, _e310); + let _e313 = v4_; + textureStore(texture_array_storage[non_uniform_index], pix, _e313); + let _e314 = u2_; + let _e315 = u1_; + let v2_ = vec2((_e314 + vec2(_e315))); + let _e319 = v4_; + let _e326 = v1_; + return ((_e319 + vec4(v2_.x, v2_.y, v2_.x, v2_.y)) + vec4(_e326)); } diff --git a/tests/out/wgsl/constructors.wgsl b/tests/out/wgsl/constructors.wgsl new file mode 100644 index 0000000000..7818e4c39e --- /dev/null +++ b/tests/out/wgsl/constructors.wgsl @@ -0,0 +1,37 @@ +struct Foo { + a: vec4, + b: i32, +} + +const const2_: vec3 = vec3(0.0, 1.0, 2.0); +const const3_: mat2x2 = mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0)); +const const4_: array, 1> = array, 1>(mat2x2(vec2(0.0, 1.0), vec2(2.0, 3.0))); +const cz0_: bool = bool(); +const cz1_: i32 = i32(); +const cz2_: u32 = u32(); +const cz3_: f32 = f32(); +const cz4_: vec2 = vec2(); +const cz5_: mat2x2 = mat2x2(); +const cz6_: array = array(); +const cz7_: Foo = Foo(); +const cp3_: array = array(0, 1, 2, 3); + +@compute @workgroup_size(1, 1, 1) +fn main() { + var foo: Foo; + + foo = Foo(vec4(1.0), 1); + let m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); + let m1_ = mat4x4(vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + let cit0_ = vec2(0u); + 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 ic6_ = bitcast>(vec2()); + let ic7_ = mat2x3(mat2x3()); +} diff --git a/tests/out/wgsl/do-while.wgsl b/tests/out/wgsl/do-while.wgsl index 2940016da1..50ed369f49 100644 --- a/tests/out/wgsl/do-while.wgsl +++ b/tests/out/wgsl/do-while.wgsl @@ -2,8 +2,8 @@ fn fb1_(cond: ptr) { loop { continue; continuing { - let _e6 = (*cond); - break if !(_e6); + let _e2 = (*cond); + break if !(_e2); } } return; diff --git a/tests/out/wgsl/empty-global-name.wgsl b/tests/out/wgsl/empty-global-name.wgsl index c84e56ad8d..11aa6b96e8 100644 --- a/tests/out/wgsl/empty-global-name.wgsl +++ b/tests/out/wgsl/empty-global-name.wgsl @@ -6,8 +6,8 @@ struct type_1 { var unnamed: type_1; fn function() { - let _e8 = unnamed.member; - unnamed.member = (_e8 + 1); + let _e4 = unnamed.member; + unnamed.member = (_e4 + 1); return; } diff --git a/tests/out/wgsl/expressions-frag.wgsl b/tests/out/wgsl/expressions-frag.wgsl index fc821ca8e4..e8e1a9f98a 100644 --- a/tests/out/wgsl/expressions-frag.wgsl +++ b/tests/out/wgsl/expressions-frag.wgsl @@ -15,6 +15,7 @@ struct FragmentOutput { } const strct: TestStruct = TestStruct(array, 2>(vec4(0u, 0u, 0u, 0u), vec4(1u, 1u, 1u, 1u))); + var global: f32; @group(0) @binding(0) var global_1: a_buf; @@ -401,7 +402,7 @@ fn testConstantLength(a_24: array) { fn indexConstantNonConstantIndex(i: i32) { var i_1: i32; - var local_5: TestStruct = TestStruct(array, 2>(vec4(0u, 0u, 0u, 0u), vec4(1u, 1u, 1u, 1u))); + var local_5: TestStruct = strct; var a_26: vec4; i_1 = i; diff --git a/tests/out/wgsl/global-constant-array-frag.wgsl b/tests/out/wgsl/global-constant-array-frag.wgsl index a82ad9483f..d6d4bfb61a 100644 --- a/tests/out/wgsl/global-constant-array-frag.wgsl +++ b/tests/out/wgsl/global-constant-array-frag.wgsl @@ -1,8 +1,9 @@ const array_: array = array(1.0, 2.0); + var i: u32; fn main_1() { - var local: array = array(1.0, 2.0); + var local: array = array_; let _e2 = i; } diff --git a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl index 10f5d25946..e68413c279 100644 --- a/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl +++ b/tests/out/wgsl/inv-hyperbolic-trig-functions.wgsl @@ -5,12 +5,12 @@ fn main_1() { var c: f32; var d: f32; + let _e4 = a; + b = asinh(_e4); + let _e6 = a; + c = acosh(_e6); let _e8 = a; - b = asinh(_e8); - let _e10 = a; - c = acosh(_e10); - let _e12 = a; - d = atanh(_e12); + d = atanh(_e8); return; } diff --git a/tests/out/wgsl/lexical-scopes.wgsl b/tests/out/wgsl/lexical-scopes.wgsl index d44f6679fb..22e59030ce 100644 --- a/tests/out/wgsl/lexical-scopes.wgsl +++ b/tests/out/wgsl/lexical-scopes.wgsl @@ -33,8 +33,8 @@ fn forLexicalScope(a_3: f32) { { } continuing { - let _e7 = a_4; - a_4 = (_e7 + 1); + let _e8 = a_4; + a_4 = (_e8 + 1); } } return; diff --git a/tests/out/wgsl/operators.wgsl b/tests/out/wgsl/operators.wgsl index fc72040452..9550bf8405 100644 --- a/tests/out/wgsl/operators.wgsl +++ b/tests/out/wgsl/operators.wgsl @@ -1,21 +1,17 @@ -struct Foo { - a: vec4, - b: i32, -} - const v_f32_one: vec4 = vec4(1.0, 1.0, 1.0, 1.0); const v_f32_zero: vec4 = vec4(0.0, 0.0, 0.0, 0.0); const v_f32_half: vec4 = vec4(0.5, 0.5, 0.5, 0.5); const v_i32_one: vec4 = vec4(1, 1, 1, 1); + fn builtins() -> vec4 { let s1_ = select(0, 1, true); - let s2_ = select(vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0), true); - let s3_ = select(vec4(1.0, 1.0, 1.0, 1.0), vec4(0.0, 0.0, 0.0, 0.0), vec4(false, false, false, false)); - let m1_ = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0), vec4(0.5, 0.5, 0.5, 0.5)); - let m2_ = mix(vec4(0.0, 0.0, 0.0, 0.0), vec4(1.0, 1.0, 1.0, 1.0), 0.1); - let b1_ = bitcast(vec4(1, 1, 1, 1).x); - let b2_ = bitcast>(vec4(1, 1, 1, 1)); - let v_i32_zero = vec4(vec4(0.0, 0.0, 0.0, 0.0)); + let s2_ = select(v_f32_zero, v_f32_one, true); + 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 b2_ = bitcast>(v_i32_one); + let v_i32_zero = vec4(v_f32_zero); return (((((vec4((vec4(s1_) + v_i32_zero)) + s2_) + m1_) + m2_) + vec4(b1_)) + b2_); } @@ -44,27 +40,6 @@ fn bool_cast(x: vec3) -> vec3 { return vec3(y); } -fn constructors() -> f32 { - var foo: Foo; - - foo = Foo(vec4(1.0), 1); - let m0_ = mat2x2(vec2(1.0, 0.0), vec2(0.0, 1.0)); - let m1_1 = 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 cit0_ = vec2(0u); - 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 ic6_ = bitcast>(vec2()); - let ic7_ = mat2x3(mat2x3()); - let _e71 = foo.a.x; - return _e71; -} - fn logical() { let neg0_ = !(true); let neg1_ = !(vec2(true)); @@ -243,15 +218,15 @@ fn assignment() { a_1 = (_e27 << 2u); let _e30 = a_1; a_1 = (_e30 >> 1u); - let _e32 = a_1; - a_1 = (_e32 + 1); - let _e35 = a_1; - a_1 = (_e35 - 1); + 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 _e47 = vec0_.y; - vec0_.y = (_e47 - 1); + let _e43 = vec0_.y; + vec0_.y = (_e43 + 1); + let _e48 = vec0_.y; + vec0_.y = (_e48 - 1); return; } @@ -269,8 +244,7 @@ fn negation_avoids_prefix_decrement() { fn main() { let _e0 = builtins(); let _e1 = splat(); - let _e4 = bool_cast(vec4(1.0, 1.0, 1.0, 1.0).xyz); - let _e5 = constructors(); + let _e4 = bool_cast(v_f32_one.xyz); logical(); arithmetic(); bit(); diff --git a/tests/out/wgsl/quad-vert.wgsl b/tests/out/wgsl/quad-vert.wgsl index 2c824e8736..72da615ccb 100644 --- a/tests/out/wgsl/quad-vert.wgsl +++ b/tests/out/wgsl/quad-vert.wgsl @@ -12,14 +12,14 @@ struct VertexOutput { var v_uv: vec2; var a_uv_1: vec2; -var perVertexStruct: gl_PerVertex = gl_PerVertex(vec4(0.0, 0.0, 0.0, 1.0), 1.0, array(0.0), array(0.0)); +var perVertexStruct: gl_PerVertex = gl_PerVertex(vec4(0.0, 0.0, 0.0, 1.0), 1.0, array(), array()); var a_pos_1: vec2; fn main_1() { - let _e12 = a_uv_1; - v_uv = _e12; - let _e13 = a_pos_1; - perVertexStruct.gl_Position = vec4(_e13.x, _e13.y, 0.0, 1.0); + let _e8 = a_uv_1; + v_uv = _e8; + let _e9 = a_pos_1; + perVertexStruct.gl_Position = vec4(_e9.x, _e9.y, 0.0, 1.0); return; } diff --git a/tests/out/wgsl/quad.wgsl b/tests/out/wgsl/quad.wgsl index b4cf4dd28d..3a92981d95 100644 --- a/tests/out/wgsl/quad.wgsl +++ b/tests/out/wgsl/quad.wgsl @@ -3,7 +3,7 @@ struct VertexOutput { @builtin(position) position: vec4, } -const c_scale: f32 = 1.2000000476837158; +const c_scale: f32 = 1.2; @group(0) @binding(0) var u_texture: texture_2d; diff --git a/tests/out/wgsl/quad_glsl-vert.wgsl b/tests/out/wgsl/quad_glsl-vert.wgsl index 68661486cd..b8d52e04c9 100644 --- a/tests/out/wgsl/quad_glsl-vert.wgsl +++ b/tests/out/wgsl/quad_glsl-vert.wgsl @@ -3,7 +3,7 @@ struct VertexOutput { @builtin(position) member: vec4, } -const c_scale: f32 = 1.2000000476837158; +const c_scale: f32 = 1.2; var a_pos_1: vec2; var a_uv_1: vec2; diff --git a/tests/out/wgsl/shadow.wgsl b/tests/out/wgsl/shadow.wgsl index d93c716bac..8000e785ff 100644 --- a/tests/out/wgsl/shadow.wgsl +++ b/tests/out/wgsl/shadow.wgsl @@ -20,7 +20,7 @@ struct Light { color: vec4, } -const c_ambient: vec3 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); +const c_ambient: vec3 = vec3(0.05, 0.05, 0.05); const c_max_lights: u32 = 10u; @group(0) @binding(0) @@ -68,7 +68,7 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4 { var i: u32; let normal_1 = normalize(in.world_normal); - color = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color = c_ambient; i = 0u; loop { let _e7 = i; @@ -88,8 +88,8 @@ fn fs_main(in: VertexOutput) -> @location(0) vec4 { color = (_e37 + ((_e23 * diffuse) * light.color.xyz)); } continuing { - let _e39 = i; - i = (_e39 + 1u); + let _e40 = i; + i = (_e40 + 1u); } } let _e42 = color; @@ -103,7 +103,7 @@ fn fs_main_without_storage(in_1: VertexOutput) -> @location(0) vec4 { var i_1: u32; let normal_2 = normalize(in_1.world_normal); - color_1 = vec3(0.05000000074505806, 0.05000000074505806, 0.05000000074505806); + color_1 = c_ambient; i_1 = 0u; loop { let _e7 = i_1; @@ -123,8 +123,8 @@ fn fs_main_without_storage(in_1: VertexOutput) -> @location(0) vec4 { color_1 = (_e37 + ((_e23 * diffuse_1) * light_1.color.xyz)); } continuing { - let _e39 = i_1; - i_1 = (_e39 + 1u); + let _e40 = i_1; + i_1 = (_e40 + 1u); } } let _e42 = color_1; diff --git a/tests/snapshots.rs b/tests/snapshots.rs index 658e5fe7f3..e1e1144139 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -607,6 +607,10 @@ fn convert_wgsl() { ("invariant", Targets::GLSL), ("ray-query", Targets::SPIRV | Targets::METAL), ("hlsl-keyword", Targets::HLSL), + ( + "constructors", + 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 9ae76837ea..48318f2804 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -952,18 +952,18 @@ fn invalid_arrays() { ┌─ wgsl:1:24 │ 1 │ alias Bad = array; - │ ^ must be positive + │ ^ must be greater than zero "###, ); check( "alias Bad = array;", - r###"error: array element count must resolve to an integer scalar (u32 or i32) + r###"error: array element count must be greater than zero ┌─ wgsl:1:24 │ 1 │ alias Bad = array; - │ ^^ must resolve to u32/i32 + │ ^^ must be greater than zero "###, );