MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateVariableVulkanDescriptor

Function ValidateVariableVulkanDescriptor

source/val/validate_memory.cpp:676–738  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676spv_result_t ValidateVariableVulkanDescriptor(ValidationState_t& _,
677 const Instruction* inst,
678 spv::StorageClass storage_class,
679 const Instruction& pointee) {
680 // Vulkan Push Constant Interface section: Check type of PushConstant
681 // variables.
682 if (storage_class == spv::StorageClass::PushConstant) {
683 if (pointee.opcode() != spv::Op::OpTypeStruct) {
684 return _.diag(SPV_ERROR_INVALID_ID, inst)
685 << _.VkErrorID(6808) << "PushConstant OpVariable <id> "
686 << _.getIdName(inst->id()) << " has illegal type.\n"
687 << "From Vulkan spec, Push Constant Interface section:\n"
688 << "Such variables must be typed as OpTypeStruct";
689 }
690 }
691
692 // Vulkan Descriptor Set Interface: Check type of UniformConstant and
693 // Uniform variables.
694 if (storage_class == spv::StorageClass::UniformConstant) {
695 if (!IsAllowedTypeOrArrayOfSame(
696 _, pointee,
697 {spv::Op::OpTypeImage, spv::Op::OpTypeSampler,
698 spv::Op::OpTypeSampledImage, spv::Op::OpTypeTensorARM,
699 spv::Op::OpTypeAccelerationStructureKHR})) {
700 return _.diag(SPV_ERROR_INVALID_ID, inst)
701 << _.VkErrorID(4655) << "UniformConstant OpVariable <id> "
702 << _.getIdName(inst->id()) << " has illegal type.\n"
703 << "Variables identified with the UniformConstant storage class "
704 << "are used only as handles to refer to opaque resources. Such "
705 << "variables must be typed as OpTypeImage, OpTypeSampler, "
706 << "OpTypeSampledImage, OpTypeAccelerationStructureKHR, "
707 << "or an array of one of these types.";
708 }
709 }
710
711 if (storage_class == spv::StorageClass::Uniform) {
712 if (!IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) {
713 return _.diag(SPV_ERROR_INVALID_ID, inst)
714 << _.VkErrorID(6807) << "Uniform OpVariable <id> "
715 << _.getIdName(inst->id()) << " has illegal type.\n"
716 << "From Vulkan spec:\n"
717 << "Variables identified with the Uniform storage class are "
718 << "used to access transparent buffer backed resources. Such "
719 << "variables must be typed as OpTypeStruct, or an array of "
720 << "this type";
721 }
722 }
723
724 if (storage_class == spv::StorageClass::StorageBuffer) {
725 if (!IsAllowedTypeOrArrayOfSame(_, pointee, {spv::Op::OpTypeStruct})) {
726 return _.diag(SPV_ERROR_INVALID_ID, inst)
727 << _.VkErrorID(6807) << "StorageBuffer OpVariable <id> "
728 << _.getIdName(inst->id()) << " has illegal type.\n"
729 << "From Vulkan spec:\n"
730 << "Variables identified with the StorageBuffer storage class "
731 "are used to access transparent buffer backed resources. "
732 "Such variables must be typed as OpTypeStruct, or an array "
733 "of this type";

Callers 1

ValidateVariableFunction · 0.85

Calls 6

diagMethod · 0.80
VkErrorIDMethod · 0.80
getIdNameMethod · 0.80
opcodeMethod · 0.45
idMethod · 0.45

Tested by

no test coverage detected