[spv] put NonWritable on buffer variable itself (#405)

This commit is contained in:
Dzmitry Malyshau
2021-02-01 20:17:50 -05:00
committed by GitHub
parent 5def021b6e
commit e05baa2889
3 changed files with 27 additions and 47 deletions

View File

@@ -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 {

View File

@@ -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

View File

@@ -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