| 420 | } |
| 421 | |
| 422 | bool SpirvValidator::ValidateVariables(const spirv::Module& module_state, const Location& loc) const { |
| 423 | bool skip = false; |
| 424 | |
| 425 | for (const spirv::Instruction* insn : module_state.static_data_.explicit_memory_inst) { |
| 426 | const uint32_t opcode = insn->Opcode(); |
| 427 | if (opcode == spv::OpVariable || opcode == spv::OpUntypedVariableKHR) { |
| 428 | const uint32_t storage_class = insn->StorageClass(); |
| 429 | if (storage_class == spv::StorageClassWorkgroup) { |
| 430 | // If Workgroup variable is initalized, make sure the feature is enabled |
| 431 | const bool untyped = opcode == spv::OpUntypedVariableKHR; |
| 432 | const bool has_initializer = insn->Length() > (untyped ? 5u : 4u); |
| 433 | if (has_initializer && !enabled_features.shaderZeroInitializeWorkgroupMemory) { |
| 434 | skip |= LogError("VUID-RuntimeSpirv-shaderZeroInitializeWorkgroupMemory-06372", module_state.handle(), loc, |
| 435 | "SPIR-V contains an %s with Workgroup Storage Class with an Initializer operand, but " |
| 436 | "shaderZeroInitializeWorkgroupMemory was not enabled.\n%s\n.", |
| 437 | string_SpvOpcode(opcode), insn->Describe().c_str()); |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | // Checks based off shaderStorageImage(Read|Write)WithoutFormat are |
| 442 | // disabled if VK_KHR_format_feature_flags2 is supported. |
| 443 | // |
| 444 | // https://github.com/KhronosGroup/Vulkan-Docs/blob/6177645341afc/appendices/spirvenv.txt#L553 |
| 445 | // |
| 446 | // The other checks need to take into account the format features and so |
| 447 | // we apply that in the descriptor set matching validation code (see |
| 448 | // descriptor_sets.cpp). |
| 449 | if (!special_supported.vk_khr_format_feature_flags2) { |
| 450 | skip |= ValidateShaderStorageImageFormatsVariables(module_state, *insn, loc); |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | // These check occur both when we see a OpVariable, but also during an OpLoad/OpStore pointing to an OpUntypedVariableKHR |
| 455 | skip |= Validate8And16BitStorage(module_state, *insn, loc); |
| 456 | } |
| 457 | |
| 458 | return skip; |
| 459 | } |
| 460 | |
| 461 | // This is to validate the VK_KHR_8bit_storage and VK_KHR_16bit_storage extensions |
| 462 | bool SpirvValidator::Validate8And16BitStorage(const spirv::Module& module_state, const spirv::Instruction& insn, |
nothing calls this directly
no test coverage detected