From b441a2595651f1ddcf5107b63e51fc33d3d4ab88 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Thu, 21 Jan 2021 20:00:36 -0500 Subject: [PATCH] Rename GlobalUse variants --- src/back/msl/writer.rs | 6 ++--- src/lib.rs | 4 ++-- src/proc/interface.rs | 12 +++++----- src/proc/validator.rs | 54 +++++++++++++++++++++--------------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/src/back/msl/writer.rs b/src/back/msl/writer.rs index d7eb311fd4..afe4607fee 100644 --- a/src/back/msl/writer.rs +++ b/src/back/msl/writer.rs @@ -40,7 +40,7 @@ impl<'a> TypedGlobalVariable<'a> { let (space_qualifier, reference) = match ty.inner { crate::TypeInner::Struct { .. } => match var.class { crate::StorageClass::Uniform | crate::StorageClass::Storage => { - let space = if self.usage.contains(crate::GlobalUse::STORE) { + let space = if self.usage.contains(crate::GlobalUse::WRITE) { "device " } else { "constant " @@ -930,7 +930,7 @@ impl Writer { module.global_variables.iter().zip(&fun.global_usage) { if var.class != crate::StorageClass::Input - || !usage.contains(crate::GlobalUse::LOAD) + || !usage.contains(crate::GlobalUse::READ) { continue; } @@ -956,7 +956,7 @@ impl Writer { module.global_variables.iter().zip(&fun.global_usage) { if var.class != crate::StorageClass::Output - || !usage.contains(crate::GlobalUse::STORE) + || !usage.contains(crate::GlobalUse::WRITE) { continue; } diff --git a/src/lib.rs b/src/lib.rs index b002ac82d5..297454fe97 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -445,9 +445,9 @@ bitflags::bitflags! { #[cfg_attr(feature = "deserialize", derive(Deserialize))] pub struct GlobalUse: u8 { /// Data will be read from the variable. - const LOAD = 0x1; + const READ = 0x1; /// Data will be written to the variable. - const STORE = 0x2; + const WRITE = 0x2; } } diff --git a/src/proc/interface.rs b/src/proc/interface.rs index 6c000cc3c6..65c3e6d48c 100644 --- a/src/proc/interface.rs +++ b/src/proc/interface.rs @@ -203,13 +203,13 @@ struct GlobalUseVisitor<'a>(&'a mut [crate::GlobalUse]); impl Visitor for GlobalUseVisitor<'_> { fn visit_expr(&mut self, expr: &crate::Expression) { if let crate::Expression::GlobalVariable(handle) = expr { - self.0[handle.index()] |= crate::GlobalUse::LOAD; + self.0[handle.index()] |= crate::GlobalUse::READ; } } fn visit_lhs_expr(&mut self, expr: &crate::Expression) { if let crate::Expression::GlobalVariable(handle) = expr { - self.0[handle.index()] |= crate::GlobalUse::STORE; + self.0[handle.index()] |= crate::GlobalUse::WRITE; } } } @@ -291,10 +291,10 @@ mod tests { assert_eq!( &function.global_usage, &[ - GlobalUse::LOAD, - GlobalUse::STORE, - GlobalUse::STORE, - GlobalUse::LOAD, + GlobalUse::READ, + GlobalUse::WRITE, + GlobalUse::WRITE, + GlobalUse::READ, ], ) } diff --git a/src/proc/validator.rs b/src/proc/validator.rs index 01e2bae606..390e83b5a5 100644 --- a/src/proc/validator.rs +++ b/src/proc/validator.rs @@ -219,10 +219,10 @@ impl crate::GlobalVariable { fn storage_usage(access: crate::StorageAccess) -> crate::GlobalUse { let mut storage_usage = crate::GlobalUse::empty(); if access.contains(crate::StorageAccess::LOAD) { - storage_usage |= crate::GlobalUse::LOAD; + storage_usage |= crate::GlobalUse::READ; } if access.contains(crate::StorageAccess::STORE) { - storage_usage |= crate::GlobalUse::STORE; + storage_usage |= crate::GlobalUse::WRITE; } storage_usage } @@ -230,24 +230,24 @@ fn storage_usage(access: crate::StorageAccess) -> crate::GlobalUse { fn built_in_usage(built_in: crate::BuiltIn) -> (crate::ShaderStage, crate::GlobalUse) { use crate::{BuiltIn as Bi, GlobalUse as Gu, ShaderStage as Ss}; match built_in { - Bi::BaseInstance => (Ss::Vertex, Gu::LOAD), - Bi::BaseVertex => (Ss::Vertex, Gu::LOAD), - Bi::ClipDistance => (Ss::Vertex, Gu::STORE), - Bi::InstanceIndex => (Ss::Vertex, Gu::LOAD), - Bi::PointSize => (Ss::Vertex, Gu::STORE), - Bi::Position => (Ss::Vertex, Gu::STORE), - Bi::VertexIndex => (Ss::Vertex, Gu::LOAD), - Bi::FragCoord => (Ss::Fragment, Gu::LOAD), - Bi::FragDepth => (Ss::Fragment, Gu::LOAD), - Bi::FrontFacing => (Ss::Fragment, Gu::LOAD), - Bi::SampleIndex => (Ss::Fragment, Gu::LOAD), - Bi::SampleMaskIn => (Ss::Fragment, Gu::LOAD), - Bi::SampleMaskOut => (Ss::Fragment, Gu::STORE), - Bi::GlobalInvocationId => (Ss::Compute, Gu::LOAD), - Bi::LocalInvocationId => (Ss::Compute, Gu::LOAD), - Bi::LocalInvocationIndex => (Ss::Compute, Gu::LOAD), - Bi::WorkGroupId => (Ss::Compute, Gu::LOAD), - Bi::WorkGroupSize => (Ss::Compute, Gu::LOAD), + Bi::BaseInstance => (Ss::Vertex, Gu::READ), + Bi::BaseVertex => (Ss::Vertex, Gu::READ), + Bi::ClipDistance => (Ss::Vertex, Gu::WRITE), + Bi::InstanceIndex => (Ss::Vertex, Gu::READ), + Bi::PointSize => (Ss::Vertex, Gu::WRITE), + Bi::Position => (Ss::Vertex, Gu::WRITE), + Bi::VertexIndex => (Ss::Vertex, Gu::READ), + Bi::FragCoord => (Ss::Fragment, Gu::READ), + Bi::FragDepth => (Ss::Fragment, Gu::READ), + Bi::FrontFacing => (Ss::Fragment, Gu::READ), + Bi::SampleIndex => (Ss::Fragment, Gu::READ), + Bi::SampleMaskIn => (Ss::Fragment, Gu::READ), + Bi::SampleMaskOut => (Ss::Fragment, Gu::WRITE), + Bi::GlobalInvocationId => (Ss::Compute, Gu::READ), + Bi::LocalInvocationId => (Ss::Compute, Gu::READ), + Bi::LocalInvocationIndex => (Ss::Compute, Gu::READ), + Bi::WorkGroupId => (Ss::Compute, Gu::READ), + Bi::WorkGroupSize => (Ss::Compute, Gu::READ), } } @@ -524,7 +524,7 @@ impl Validator { Some(crate::Binding::BuiltIn(built_in)) => { let (allowed_stage, allowed_usage) = built_in_usage(built_in); if allowed_stage != stage - || !allowed_usage.contains(crate::GlobalUse::LOAD) + || !allowed_usage.contains(crate::GlobalUse::READ) { return Err(EntryPointError::InvalidBuiltIn(built_in)); } @@ -537,14 +537,14 @@ impl Validator { Some(crate::Binding::Resource { .. }) => unreachable!(), None => (), } - crate::GlobalUse::LOAD + crate::GlobalUse::READ } crate::StorageClass::Output => { match var.binding { Some(crate::Binding::BuiltIn(built_in)) => { let (allowed_stage, allowed_usage) = built_in_usage(built_in); if allowed_stage != stage - || !allowed_usage.contains(crate::GlobalUse::STORE) + || !allowed_usage.contains(crate::GlobalUse::WRITE) { return Err(EntryPointError::InvalidBuiltIn(built_in)); } @@ -557,21 +557,21 @@ impl Validator { Some(crate::Binding::Resource { .. }) => unreachable!(), None => (), } - crate::GlobalUse::LOAD | crate::GlobalUse::STORE + crate::GlobalUse::READ | crate::GlobalUse::WRITE } - crate::StorageClass::Uniform => crate::GlobalUse::LOAD, + crate::StorageClass::Uniform => crate::GlobalUse::READ, crate::StorageClass::Storage => storage_usage(var.storage_access), crate::StorageClass::Handle => match module.types[var.ty].inner { crate::TypeInner::Image { class: crate::ImageClass::Storage(_), .. } => storage_usage(var.storage_access), - _ => crate::GlobalUse::LOAD, + _ => crate::GlobalUse::READ, }, crate::StorageClass::Private | crate::StorageClass::WorkGroup => { crate::GlobalUse::all() } - crate::StorageClass::PushConstant => crate::GlobalUse::LOAD, + crate::StorageClass::PushConstant => crate::GlobalUse::READ, }; if !allowed_usage.contains(usage) { log::warn!("\tUsage error for: {:?}", var);