@@ -2278,9 +2278,11 @@ spv_result_t CheckInvalidVulkanExplicitLayout(ValidationState_t& vstate) {
22782278 check_id = inst.GetOperandAs <uint32_t >(3 );
22792279 }
22802280 }
2281- layout_dec = UsesExplicitLayout (vstate, check_id, cache);
2282- if (!AllowsLayout (vstate, sc) && layout_dec != spv::Decoration::Max) {
2283- fail_id = check_id;
2281+ if (!AllowsLayout (vstate, sc)) {
2282+ layout_dec = UsesExplicitLayout (vstate, check_id, cache);
2283+ if (layout_dec != spv::Decoration::Max) {
2284+ fail_id = check_id;
2285+ }
22842286 }
22852287 break ;
22862288 }
@@ -2291,8 +2293,8 @@ spv_result_t CheckInvalidVulkanExplicitLayout(ValidationState_t& vstate) {
22912293 // Check both the base type and return type. The return type may have an
22922294 // invalid array stride.
22932295 sc = type_inst->GetOperandAs <spv::StorageClass>(1 );
2294- const auto base_type_id = inst.GetOperandAs <uint32_t >(2 );
22952296 if (!AllowsLayout (vstate, sc)) {
2297+ const auto base_type_id = inst.GetOperandAs <uint32_t >(2 );
22962298 layout_dec = UsesExplicitLayout (vstate, base_type_id, cache);
22972299 if (layout_dec != spv::Decoration::Max) {
22982300 fail_id = base_type_id;
@@ -2311,10 +2313,12 @@ spv_result_t CheckInvalidVulkanExplicitLayout(ValidationState_t& vstate) {
23112313 vstate.FindDef (inst.GetOperandAs <uint32_t >(3 ))->type_id ();
23122314 const auto ptr_ty = vstate.FindDef (ptr_ty_id);
23132315 sc = ptr_ty->GetOperandAs <spv::StorageClass>(1 );
2314- const auto base_type_id = inst.GetOperandAs <uint32_t >(2 );
2315- layout_dec = UsesExplicitLayout (vstate, base_type_id, cache);
2316- if (!AllowsLayout (vstate, sc) && layout_dec != spv::Decoration::Max) {
2317- fail_id = base_type_id;
2316+ if (!AllowsLayout (vstate, sc)) {
2317+ const auto base_type_id = inst.GetOperandAs <uint32_t >(2 );
2318+ layout_dec = UsesExplicitLayout (vstate, base_type_id, cache);
2319+ if (layout_dec != spv::Decoration::Max) {
2320+ fail_id = base_type_id;
2321+ }
23182322 }
23192323 break ;
23202324 }
@@ -2324,9 +2328,11 @@ spv_result_t CheckInvalidVulkanExplicitLayout(ValidationState_t& vstate) {
23242328 if (ptr_type->opcode () == spv::Op::OpTypeUntypedPointerKHR) {
23252329 // For untyped pointers check the return type for an invalid layout.
23262330 sc = ptr_type->GetOperandAs <spv::StorageClass>(1 );
2327- layout_dec = UsesExplicitLayout (vstate, type_id, cache);
2328- if (!AllowsLayout (vstate, sc) && layout_dec != spv::Decoration::Max) {
2329- fail_id = type_id;
2331+ if (!AllowsLayout (vstate, sc)) {
2332+ layout_dec = UsesExplicitLayout (vstate, type_id, cache);
2333+ if (layout_dec != spv::Decoration::Max) {
2334+ fail_id = type_id;
2335+ }
23302336 }
23312337 }
23322338 break ;
@@ -2338,10 +2344,12 @@ spv_result_t CheckInvalidVulkanExplicitLayout(ValidationState_t& vstate) {
23382344 // For untyped pointers, check the type of the data operand for an
23392345 // invalid layout.
23402346 sc = ptr_type->GetOperandAs <spv::StorageClass>(1 );
2341- const auto data_type_id = vstate.GetOperandTypeId (&inst, 1 );
2342- layout_dec = UsesExplicitLayout (vstate, data_type_id, cache);
2343- if (!AllowsLayout (vstate, sc) && layout_dec != spv::Decoration::Max) {
2344- fail_id = inst.GetOperandAs <uint32_t >(2 );
2347+ if (!AllowsLayout (vstate, sc)) {
2348+ const auto data_type_id = vstate.GetOperandTypeId (&inst, 1 );
2349+ layout_dec = UsesExplicitLayout (vstate, data_type_id, cache);
2350+ if (layout_dec != spv::Decoration::Max) {
2351+ fail_id = inst.GetOperandAs <uint32_t >(2 );
2352+ }
23452353 }
23462354 }
23472355 break ;
0 commit comments