Skip to content

Commit

Permalink
[spv-out] zero init variables in function and private address spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy committed May 10, 2022
1 parent ceb9292 commit 239bbbb
Show file tree
Hide file tree
Showing 13 changed files with 2,294 additions and 2,254 deletions.
12 changes: 11 additions & 1 deletion src/back/spv/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ impl Writer {
pointer_type_id,
id,
spirv::StorageClass::Function,
init_word,
init_word.or_else(|| {
let type_id = self.get_type_id(LookupType::Handle(variable.ty));
Some(self.write_constant_null(type_id))
}),
);
function
.variables
Expand Down Expand Up @@ -1325,6 +1328,13 @@ impl Writer {
}
};

let init_word = match global_variable.space {
crate::AddressSpace::Private => {
init_word.or_else(|| Some(self.write_constant_null(inner_type_id)))
}
_ => init_word,
};

Instruction::variable(pointer_type_id, id, class, init_word)
.to_words(&mut self.logical_layout.declarations);
Ok(id)
Expand Down
Loading

0 comments on commit 239bbbb

Please sign in to comment.