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

Function ValidateMemoryModel

source/val/validate_mode_setting.cpp:939–974  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

937}
938
939spv_result_t ValidateMemoryModel(ValidationState_t& _,
940 const Instruction* inst) {
941 // Already produced an error if multiple memory model instructions are
942 // present.
943 if (_.memory_model() != spv::MemoryModel::VulkanKHR &&
944 _.HasCapability(spv::Capability::VulkanMemoryModelKHR)) {
945 return _.diag(SPV_ERROR_INVALID_DATA, inst)
946 << "VulkanMemoryModelKHR capability must only be specified if "
947 "the VulkanKHR memory model is used.";
948 }
949
950 if (spvIsOpenCLEnv(_.context()->target_env)) {
951 if ((_.addressing_model() != spv::AddressingModel::Physical32) &&
952 (_.addressing_model() != spv::AddressingModel::Physical64)) {
953 return _.diag(SPV_ERROR_INVALID_DATA, inst)
954 << "Addressing model must be Physical32 or Physical64 "
955 << "in the OpenCL environment.";
956 }
957 if (_.memory_model() != spv::MemoryModel::OpenCL) {
958 return _.diag(SPV_ERROR_INVALID_DATA, inst)
959 << "Memory model must be OpenCL in the OpenCL environment.";
960 }
961 }
962
963 if (spvIsVulkanEnv(_.context()->target_env)) {
964 if ((_.addressing_model() != spv::AddressingModel::Logical) &&
965 (_.addressing_model() !=
966 spv::AddressingModel::PhysicalStorageBuffer64)) {
967 return _.diag(SPV_ERROR_INVALID_DATA, inst)
968 << _.VkErrorID(4635)
969 << "Addressing model must be Logical or PhysicalStorageBuffer64 "
970 << "in the Vulkan environment.";
971 }
972 }
973 return SPV_SUCCESS;
974}
975
976bool PerEntryExecutionMode(spv::ExecutionMode mode) {
977 switch (mode) {

Callers 1

ModeSettingPassFunction · 0.85

Calls 8

spvIsOpenCLEnvFunction · 0.85
spvIsVulkanEnvFunction · 0.85
memory_modelMethod · 0.80
diagMethod · 0.80
addressing_modelMethod · 0.80
VkErrorIDMethod · 0.80
HasCapabilityMethod · 0.45
contextMethod · 0.45

Tested by

no test coverage detected