Skip to content

Commit

Permalink
[naga wgsl-in] Rename convert_slice_to_common_leaf_scalar.
Browse files Browse the repository at this point in the history
This is a mouthful, but it's going to align better with functions to
be introduced in later commits.
  • Loading branch information
jimblandy committed Dec 13, 2023
1 parent eb92dcc commit 8f3c824
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions naga/src/front/wgsl/lower/construction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,10 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
},
Constructor::Type((_, &crate::TypeInner::Vector { size, scalar })),
) => {
ctx.convert_slice_to_common_scalar(std::slice::from_mut(&mut component), scalar)?;
ctx.convert_slice_to_common_leaf_scalar(
std::slice::from_mut(&mut component),
scalar,
)?;
expr = crate::Expression::Splat {
size,
value: component,
Expand All @@ -319,7 +322,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
.map_err(|index| {
Error::InvalidConstructorComponentType(spans[index], index as i32)
})?;
ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?;
ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?;
let inner = consensus_scalar.to_inner_vector(size);
let ty = ctx.ensure_type_exists(inner);
expr = crate::Expression::Compose { ty, components };
Expand Down Expand Up @@ -351,7 +354,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
let consensus_scalar = consensus_scalar
.automatic_conversion_combine(crate::Scalar::ABSTRACT_FLOAT)
.unwrap_or(consensus_scalar);
ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?;
ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?;
let vec_ty = ctx.ensure_type_exists(consensus_scalar.to_inner_vector(rows));

let components = components
Expand Down Expand Up @@ -425,7 +428,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
.map_err(|index| {
Error::InvalidConstructorComponentType(spans[index], index as i32)
})?;
ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?;
ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?;
let ty = ctx.ensure_type_exists(crate::TypeInner::Matrix {
columns,
rows,
Expand Down Expand Up @@ -473,7 +476,7 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
// do. And if this array construction is not well-typed,
// these conversions will not make it so, and we can let
// validation catch the error.
ctx.convert_slice_to_common_scalar(&mut components, consensus_scalar)?;
ctx.convert_slice_to_common_leaf_scalar(&mut components, consensus_scalar)?;
} else {
// There's no consensus scalar. Emit the `Compose`
// expression anyway, and let validation catch the problem.
Expand Down
2 changes: 1 addition & 1 deletion naga/src/front/wgsl/lower/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'source, 'temp, 'out> super::ExpressionContext<'source, 'temp, 'out> {
/// themselves whether the casts we we generate are justified,
/// perhaps by calling `TypeInner::automatically_converts_to` or
/// `Scalar::automatic_conversion_combine`.
pub fn convert_slice_to_common_scalar(
pub fn convert_slice_to_common_leaf_scalar(
&mut self,
exprs: &mut [Handle<crate::Expression>],
goal: crate::Scalar,
Expand Down

0 comments on commit 8f3c824

Please sign in to comment.