mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv] put NonWritable on buffer variable itself (#405)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user