Skip to content

Commit e5b7552

Browse files
alister-chowdhurys-perron
authored andcommitted
Changed nonwritable logic to just count, rather than use a bitfield or vector
1 parent 97bd5df commit e5b7552

1 file changed

Lines changed: 8 additions & 20 deletions

File tree

source/opt/instruction.cpp

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -450,32 +450,20 @@ bool Instruction::IsVulkanStorageBufferNonWritable() const {
450450
}
451451
assert(base_type->opcode() == spv::Op::OpTypeStruct);
452452

453-
// Check that all individual members of the struct are NonWritable.
454-
analysis::DecorationManager* decoration_mgr = context()->get_decoration_mgr();
455-
456-
if (base_type->NumInOperands() <= 64) {
457-
uint64_t writeable_mask = (1llu << (base_type->NumInOperands())) - 1;
458-
decoration_mgr->ForEachDecoration(
459-
base_type->result_id(),
460-
static_cast<uint32_t>(spv::Decoration::NonWritable),
461-
[&writeable_mask](const Instruction& decr) {
462-
if (decr.opcode() == spv::Op::OpMemberDecorate) {
463-
writeable_mask &= ~(1llu << decr.GetSingleWordInOperand(1));
464-
}
465-
});
466-
return !writeable_mask;
467-
}
468-
469-
std::vector<uint32_t> nonwritable_members;
470-
decoration_mgr->ForEachDecoration(
453+
// Test if the number of NonWritable member decorations matches
454+
// the number of members within the struct.
455+
// We're assuming the decorations to have unique valid member id.
456+
uint32_t nonwritable_members = 0;
457+
context()->get_decoration_mgr()->ForEachDecoration(
471458
base_type->result_id(),
472459
static_cast<uint32_t>(spv::Decoration::NonWritable),
473460
[&nonwritable_members](const Instruction& decr) {
474461
if (decr.opcode() == spv::Op::OpMemberDecorate) {
475-
nonwritable_members.push_back(decr.GetSingleWordInOperand(1));
462+
++nonwritable_members;
476463
}
477464
});
478-
return nonwritable_members.size() == base_type->NumInOperands();
465+
466+
return nonwritable_members == base_type->NumInOperands();
479467
}
480468

481469
bool Instruction::IsVulkanStorageBufferVariable() const {

0 commit comments

Comments
 (0)