diff --git a/src/back/spv/writer.rs b/src/back/spv/writer.rs index b5cfe69d70..ea806152ba 100644 --- a/src/back/spv/writer.rs +++ b/src/back/spv/writer.rs @@ -709,24 +709,19 @@ impl Writer { block: true, ref members, } => { - //TODO: put NonWritable/NonReadable on the global variable instead? - let storage_access = match self.struct_type_handles.get(&handle) { - Some(&access) => { - let decoration = if access.is_empty() { - spirv::Decoration::Block - } else { - spirv::Decoration::BufferBlock - }; - self.annotations - .push(super::instructions::instruction_decorate( - id, - decoration, - &[], - )); - access - } - None => crate::StorageAccess::empty(), - }; + if let Some(&access) = self.struct_type_handles.get(&handle) { + let decoration = if access.is_empty() { + spirv::Decoration::Block + } else { + spirv::Decoration::BufferBlock + }; + self.annotations + .push(super::instructions::instruction_decorate( + id, + decoration, + &[], + )); + } let mut current_offset = 0; let mut member_ids = Vec::with_capacity(members.len()); @@ -756,16 +751,6 @@ impl Writer { } } - if storage_access == crate::StorageAccess::LOAD { - self.annotations - .push(super::instructions::instruction_member_decorate( - id, - index as u32, - spirv::Decoration::NonWritable, - &[], - )); - } - if let crate::TypeInner::Matrix { columns, rows: _, @@ -939,24 +924,18 @@ impl Writer { } } - if let crate::TypeInner::Image { - class: crate::ImageClass::Storage(_), - .. - } = ir_module.types[global_variable.ty].inner - { - let decoration = match global_variable.storage_access { - crate::StorageAccess::LOAD => Some(spirv::Decoration::NonWritable), - crate::StorageAccess::STORE => Some(spirv::Decoration::NonReadable), - _ => None, - }; - if let Some(decoration) = decoration { - self.annotations - .push(super::instructions::instruction_decorate( - id, - decoration, - &[], - )); - } + let access_decoration = match global_variable.storage_access { + crate::StorageAccess::LOAD => Some(spirv::Decoration::NonWritable), + crate::StorageAccess::STORE => Some(spirv::Decoration::NonReadable), + _ => None, + }; + if let Some(decoration) = access_decoration { + self.annotations + .push(super::instructions::instruction_decorate( + id, + decoration, + &[], + )); } if let Some(interpolation) = global_variable.interpolation { diff --git a/tests/snapshots/snapshots__boids.spvasm.snap b/tests/snapshots/snapshots__boids.spvasm.snap index fac29f9aa5..19989836c3 100644 --- a/tests/snapshots/snapshots__boids.spvasm.snap +++ b/tests/snapshots/snapshots__boids.spvasm.snap @@ -17,6 +17,7 @@ OpMemberDecorate %45 1 Offset 8 OpDecorate %47 ArrayStride 16 OpDecorate %49 BufferBlock OpMemberDecorate %49 0 Offset 0 +OpDecorate %50 NonWritable OpDecorate %50 DescriptorSet 0 OpDecorate %50 Binding 1 OpDecorate %121 Block diff --git a/tests/snapshots/snapshots__shadow.spvasm.snap b/tests/snapshots/snapshots__shadow.spvasm.snap index 8d13d12835..e6e1991120 100644 --- a/tests/snapshots/snapshots__shadow.spvasm.snap +++ b/tests/snapshots/snapshots__shadow.spvasm.snap @@ -27,7 +27,7 @@ OpMemberDecorate %97 2 Offset 80 OpDecorate %99 ArrayStride 96 OpDecorate %101 BufferBlock OpMemberDecorate %101 0 Offset 0 -OpMemberDecorate %101 0 NonWritable +OpDecorate %102 NonWritable OpDecorate %102 DescriptorSet 0 OpDecorate %102 Binding 1 OpDecorate %111 Location 1