mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
[naga wgsl-in] Let TypeInner::to_wgsl take the context by reference.
This commit is contained in:
parent
cbb59c7bf3
commit
941cd2e25c
@ -633,7 +633,7 @@ impl<'source, 'temp, 'out> ExpressionContext<'source, 'temp, 'out> {
|
||||
}
|
||||
|
||||
fn format_typeinner(&self, inner: &crate::TypeInner) -> String {
|
||||
inner.to_wgsl(self.module.to_ctx())
|
||||
inner.to_wgsl(&self.module.to_ctx())
|
||||
}
|
||||
|
||||
fn format_type(&self, handle: Handle<crate::Type>) -> String {
|
||||
@ -929,13 +929,13 @@ impl<'source, 'temp> Lowerer<'source, 'temp> {
|
||||
let expected = ty
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(ctx.module.to_ctx()));
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(&ctx.module.to_ctx()));
|
||||
|
||||
let ty = &ctx.module.types[inferred_type];
|
||||
let got = ty
|
||||
.name
|
||||
.clone()
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(ctx.module.to_ctx()));
|
||||
.unwrap_or_else(|| ty.inner.to_wgsl(&ctx.module.to_ctx()));
|
||||
|
||||
return Err(Error::InitializationTypeMismatch {
|
||||
name: c.name.span,
|
||||
|
@ -6,7 +6,7 @@ impl crate::TypeInner {
|
||||
/// Note: `TypeInner::Struct` doesn't include the name of the
|
||||
/// struct type. Therefore this method will simply return "struct"
|
||||
/// for them.
|
||||
pub fn to_wgsl(&self, gctx: crate::proc::GlobalCtx) -> String {
|
||||
pub fn to_wgsl(&self, gctx: &crate::proc::GlobalCtx) -> String {
|
||||
use crate::TypeInner as Ti;
|
||||
|
||||
match *self {
|
||||
@ -206,14 +206,14 @@ mod tests {
|
||||
stride: 4,
|
||||
size: crate::ArraySize::Constant(unsafe { NonZeroU32::new_unchecked(32) }),
|
||||
};
|
||||
assert_eq!(array.to_wgsl(gctx), "array<MyType1, 32>");
|
||||
assert_eq!(array.to_wgsl(&gctx), "array<MyType1, 32>");
|
||||
|
||||
let mat = crate::TypeInner::Matrix {
|
||||
rows: crate::VectorSize::Quad,
|
||||
columns: crate::VectorSize::Bi,
|
||||
width: 8,
|
||||
};
|
||||
assert_eq!(mat.to_wgsl(gctx), "mat2x4<f64>");
|
||||
assert_eq!(mat.to_wgsl(&gctx), "mat2x4<f64>");
|
||||
|
||||
let ptr = crate::TypeInner::Pointer {
|
||||
base: mytype2,
|
||||
@ -221,7 +221,7 @@ mod tests {
|
||||
access: crate::StorageAccess::default(),
|
||||
},
|
||||
};
|
||||
assert_eq!(ptr.to_wgsl(gctx), "ptr<MyType2>");
|
||||
assert_eq!(ptr.to_wgsl(&gctx), "ptr<MyType2>");
|
||||
|
||||
let img1 = crate::TypeInner::Image {
|
||||
dim: crate::ImageDimension::D2,
|
||||
@ -231,26 +231,26 @@ mod tests {
|
||||
multi: true,
|
||||
},
|
||||
};
|
||||
assert_eq!(img1.to_wgsl(gctx), "texture_multisampled_2d<f32>");
|
||||
assert_eq!(img1.to_wgsl(&gctx), "texture_multisampled_2d<f32>");
|
||||
|
||||
let img2 = crate::TypeInner::Image {
|
||||
dim: crate::ImageDimension::Cube,
|
||||
arrayed: true,
|
||||
class: crate::ImageClass::Depth { multi: false },
|
||||
};
|
||||
assert_eq!(img2.to_wgsl(gctx), "texture_depth_cube_array");
|
||||
assert_eq!(img2.to_wgsl(&gctx), "texture_depth_cube_array");
|
||||
|
||||
let img3 = crate::TypeInner::Image {
|
||||
dim: crate::ImageDimension::D2,
|
||||
arrayed: false,
|
||||
class: crate::ImageClass::Depth { multi: true },
|
||||
};
|
||||
assert_eq!(img3.to_wgsl(gctx), "texture_depth_multisampled_2d");
|
||||
assert_eq!(img3.to_wgsl(&gctx), "texture_depth_multisampled_2d");
|
||||
|
||||
let array = crate::TypeInner::BindingArray {
|
||||
base: mytype1,
|
||||
size: crate::ArraySize::Constant(unsafe { NonZeroU32::new_unchecked(32) }),
|
||||
};
|
||||
assert_eq!(array.to_wgsl(gctx), "binding_array<MyType1, 32>");
|
||||
assert_eq!(array.to_wgsl(&gctx), "binding_array<MyType1, 32>");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user