| 521 | } |
| 522 | |
| 523 | spv_result_t ValidateVariableStorageClass(ValidationState_t& _, |
| 524 | const Instruction* inst, |
| 525 | spv::StorageClass storage_class, |
| 526 | const Instruction* value_type) { |
| 527 | if (storage_class != spv::StorageClass::Workgroup && |
| 528 | storage_class != spv::StorageClass::CrossWorkgroup && |
| 529 | storage_class != spv::StorageClass::Private && |
| 530 | storage_class != spv::StorageClass::Function && |
| 531 | storage_class != spv::StorageClass::UniformConstant && |
| 532 | storage_class != spv::StorageClass::RayPayloadKHR && |
| 533 | storage_class != spv::StorageClass::IncomingRayPayloadKHR && |
| 534 | storage_class != spv::StorageClass::HitAttributeKHR && |
| 535 | storage_class != spv::StorageClass::CallableDataKHR && |
| 536 | storage_class != spv::StorageClass::IncomingCallableDataKHR && |
| 537 | storage_class != spv::StorageClass::TaskPayloadWorkgroupEXT && |
| 538 | storage_class != spv::StorageClass::HitObjectAttributeNV && |
| 539 | storage_class != spv::StorageClass::HitObjectAttributeEXT && |
| 540 | storage_class != spv::StorageClass::NodePayloadAMDX) { |
| 541 | bool storage_input_or_output = storage_class == spv::StorageClass::Input || |
| 542 | storage_class == spv::StorageClass::Output; |
| 543 | bool builtin = false; |
| 544 | if (storage_input_or_output) { |
| 545 | for (const Decoration& decoration : _.id_decorations(inst->id())) { |
| 546 | if (decoration.dec_type() == spv::Decoration::BuiltIn) { |
| 547 | builtin = true; |
| 548 | break; |
| 549 | } |
| 550 | } |
| 551 | } |
| 552 | if (!builtin && value_type && |
| 553 | ContainsInvalidBool(_, value_type, storage_input_or_output)) { |
| 554 | if (storage_input_or_output) { |
| 555 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 556 | << _.VkErrorID(7290) |
| 557 | << "If OpTypeBool is stored in conjunction with OpVariable " |
| 558 | "using Input or Output Storage Classes it requires a BuiltIn " |
| 559 | "decoration"; |
| 560 | |
| 561 | } else { |
| 562 | return _.diag(SPV_ERROR_INVALID_ID, inst) |
| 563 | << "If OpTypeBool is stored in conjunction with OpVariable, it " |
| 564 | "can only be used with non-externally visible shader Storage " |
| 565 | "Classes: Workgroup, CrossWorkgroup, Private, Function, " |
| 566 | "Input, Output, RayPayloadKHR, IncomingRayPayloadKHR, " |
| 567 | "HitAttributeKHR, CallableDataKHR, " |
| 568 | "IncomingCallableDataKHR, NodePayloadAMDX, or " |
| 569 | "UniformConstant"; |
| 570 | } |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | if (!_.IsValidStorageClass(storage_class)) { |
| 575 | return _.diag(SPV_ERROR_INVALID_BINARY, inst) |
| 576 | << _.VkErrorID(4643) |
| 577 | << "Invalid storage class for target environment"; |
| 578 | } |
| 579 | |
| 580 | if (storage_class == spv::StorageClass::Generic) { |
no test coverage detected