mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 16:24:24 +00:00
[naga spv-out] Rename make_local
to LocalType::from_inner
.
Change the free function `back::spv::make_local` into an associated function `LocalType::from_inner`.
This commit is contained in:
parent
bf33e481f3
commit
0392cb783d
@ -3,8 +3,8 @@ Implementations for `BlockContext` methods.
|
||||
*/
|
||||
|
||||
use super::{
|
||||
helpers, index::BoundsCheckResult, make_local, selection::Selection, Block, BlockContext,
|
||||
Dimension, Error, Instruction, LocalType, LookupType, ResultMember, Writer, WriterFlags,
|
||||
helpers, index::BoundsCheckResult, selection::Selection, Block, BlockContext, Dimension, Error,
|
||||
Instruction, LocalType, LookupType, ResultMember, Writer, WriterFlags,
|
||||
};
|
||||
use crate::{arena::Handle, proc::TypeResolution, Statement};
|
||||
use spirv::Word;
|
||||
@ -1809,7 +1809,9 @@ impl<'w> BlockContext<'w> {
|
||||
Some(ty) => ty,
|
||||
None => LookupType::Handle(ty_handle),
|
||||
},
|
||||
TypeResolution::Value(ref inner) => LookupType::Local(make_local(inner).unwrap()),
|
||||
TypeResolution::Value(ref inner) => {
|
||||
LookupType::Local(LocalType::from_inner(inner).unwrap())
|
||||
}
|
||||
};
|
||||
let result_type_id = self.get_type_id(result_lookup_ty);
|
||||
|
||||
|
@ -246,9 +246,9 @@ impl LocalImageType {
|
||||
/// never synthesizes new struct types, so `LocalType` has nothing for that.
|
||||
///
|
||||
/// Each `LocalType` variant should be handled identically to its analogous
|
||||
/// `TypeInner` variant. You can use the [`make_local`] function to help with
|
||||
/// this, by converting everything possible to a `LocalType` before inspecting
|
||||
/// it.
|
||||
/// `TypeInner` variant. You can use the [`LocalType::from_inner`] function to
|
||||
/// help with this, by converting everything possible to a `LocalType` before
|
||||
/// inspecting it.
|
||||
///
|
||||
/// ## `LocalType` equality and SPIR-V `OpType` uniqueness
|
||||
///
|
||||
@ -357,13 +357,16 @@ struct LookupFunctionType {
|
||||
return_type_id: Word,
|
||||
}
|
||||
|
||||
fn make_local(inner: &crate::TypeInner) -> Option<LocalType> {
|
||||
impl LocalType {
|
||||
fn from_inner(inner: &crate::TypeInner) -> Option<Self> {
|
||||
Some(match *inner {
|
||||
crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => LocalType::Value {
|
||||
crate::TypeInner::Scalar(scalar) | crate::TypeInner::Atomic(scalar) => {
|
||||
LocalType::Value {
|
||||
vector_size: None,
|
||||
scalar,
|
||||
pointer_space: None,
|
||||
},
|
||||
}
|
||||
}
|
||||
crate::TypeInner::Vector { size, scalar } => LocalType::Value {
|
||||
vector_size: Some(size),
|
||||
scalar,
|
||||
@ -404,6 +407,7 @@ fn make_local(inner: &crate::TypeInner) -> Option<LocalType> {
|
||||
| crate::TypeInner::BindingArray { .. } => return None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum Dimension {
|
||||
|
@ -1,10 +1,10 @@
|
||||
use super::{
|
||||
block::DebugInfoInner,
|
||||
helpers::{contains_builtin, global_needs_wrapper, map_storage_class},
|
||||
make_local, Block, BlockContext, CachedConstant, CachedExpressions, DebugInfo,
|
||||
EntryPointContext, Error, Function, FunctionArgument, GlobalVariable, IdGenerator, Instruction,
|
||||
LocalType, LocalVariable, LogicalLayout, LookupFunctionType, LookupType, Options,
|
||||
PhysicalLayout, PipelineOptions, ResultMember, Writer, WriterFlags, BITS_PER_BYTE,
|
||||
Block, BlockContext, CachedConstant, CachedExpressions, DebugInfo, EntryPointContext, Error,
|
||||
Function, FunctionArgument, GlobalVariable, IdGenerator, Instruction, LocalType, LocalVariable,
|
||||
LogicalLayout, LookupFunctionType, LookupType, Options, PhysicalLayout, PipelineOptions,
|
||||
ResultMember, Writer, WriterFlags, BITS_PER_BYTE,
|
||||
};
|
||||
use crate::{
|
||||
arena::{Handle, HandleVec, UniqueArena},
|
||||
@ -254,7 +254,9 @@ impl Writer {
|
||||
pub(super) fn get_expression_lookup_type(&mut self, tr: &TypeResolution) -> LookupType {
|
||||
match *tr {
|
||||
TypeResolution::Handle(ty_handle) => LookupType::Handle(ty_handle),
|
||||
TypeResolution::Value(ref inner) => LookupType::Local(make_local(inner).unwrap()),
|
||||
TypeResolution::Value(ref inner) => {
|
||||
LookupType::Local(LocalType::from_inner(inner).unwrap())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1025,7 +1027,7 @@ impl Writer {
|
||||
// because some types which map to the same LocalType have different
|
||||
// capability requirements. See https://github.com/gfx-rs/wgpu/issues/5569
|
||||
self.request_type_capabilities(&ty.inner)?;
|
||||
let id = if let Some(local) = make_local(&ty.inner) {
|
||||
let id = if let Some(local) = LocalType::from_inner(&ty.inner) {
|
||||
// This type can be represented as a `LocalType`, so check if we've
|
||||
// already written an instruction for it. If not, do so now, with
|
||||
// `write_type_declaration_local`.
|
||||
|
Loading…
Reference in New Issue
Block a user