mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[naga wgsl] Add write_type_resolution method to TypeContext.
Add a new default method, `write_type_resolution`, to the `naga::common::wgsl::TypeResolution` trait, for writing `TypeResolution` values as WGSL.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
use super::{address_space_str, ToWgsl, TryToWgsl};
|
||||
use crate::common;
|
||||
use crate::proc::TypeResolution;
|
||||
use crate::{Handle, Scalar, TypeInner};
|
||||
|
||||
use core::fmt::Write;
|
||||
@@ -93,6 +94,14 @@ pub trait TypeContext<W: Write> {
|
||||
None => self.write_non_wgsl_scalar(scalar, out),
|
||||
}
|
||||
}
|
||||
|
||||
/// Write the [`TypeResolution`] `resolution` as a WGSL type.
|
||||
fn write_type_resolution(&self, resolution: &TypeResolution, out: &mut W) -> core::fmt::Result {
|
||||
match *resolution {
|
||||
TypeResolution::Handle(handle) => self.write_type(handle, out),
|
||||
TypeResolution::Value(ref inner) => self.write_type_inner(inner, out),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn try_write_type_inner<C, W>(ctx: &C, inner: &TypeInner, out: &mut W) -> Result<(), WriteTypeError>
|
||||
|
||||
Reference in New Issue
Block a user