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