From fc6d6c64830b12e6ee792d5ca23d4528a4e0eba0 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 16 Mar 2025 11:47:20 -0700 Subject: [PATCH] [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. --- naga/src/common/wgsl/types.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/naga/src/common/wgsl/types.rs b/naga/src/common/wgsl/types.rs index 56e5e63f65..319fabc37d 100644 --- a/naga/src/common/wgsl/types.rs +++ b/naga/src/common/wgsl/types.rs @@ -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 { 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(ctx: &C, inner: &TypeInner, out: &mut W) -> Result<(), WriteTypeError>