diff --git a/source/val/validate_builtins.cpp b/source/val/validate_builtins.cpp index f9b29dd04c..89bd49ef57 100644 --- a/source/val/validate_builtins.cpp +++ b/source/val/validate_builtins.cpp @@ -3218,17 +3218,20 @@ spv_result_t BuiltInsValidator::ValidateI32Vec4InputAtDefinition( spv_result_t BuiltInsValidator::ValidateWorkgroupSizeAtDefinition( const Decoration& decoration, const Instruction& inst) { - if (spv_result_t error = ValidateI32Vec( - decoration, inst, 3, - [this, &inst](const std::string& message) -> spv_result_t { - return _.diag(SPV_ERROR_INVALID_DATA, &inst) - << _.VkErrorID(4427) << "According to the " - << spvLogStringForEnv(_.context()->target_env) - << " spec BuiltIn WorkgroupSize variable needs to be a " - "3-component 32-bit int vector. " - << message; - })) { - return error; + // Vulkan requires 32-bit int, but Universal has no restrictions + if (spvIsVulkanEnv(_.context()->target_env)) { + if (spv_result_t error = ValidateI32Vec( + decoration, inst, 3, + [this, &inst](const std::string& message) -> spv_result_t { + return _.diag(SPV_ERROR_INVALID_DATA, &inst) + << _.VkErrorID(4427) << "According to the " + << spvLogStringForEnv(_.context()->target_env) + << " spec BuiltIn WorkgroupSize variable needs to be a " + "3-component 32-bit int vector. " + << message; + })) { + return error; + } } if (!spvOpcodeIsConstant(inst.opcode())) { diff --git a/test/val/val_modes_test.cpp b/test/val/val_modes_test.cpp index ecde2457ca..6bd6e8ed99 100644 --- a/test/val/val_modes_test.cpp +++ b/test/val/val_modes_test.cpp @@ -318,6 +318,37 @@ OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1 "Local Size Id execution mode must not have a product of zero")); } +// https://github.com/KhronosGroup/SPIRV-Tools/issues/5939 +TEST_F(ValidateMode, KernelZeroLocalSize64) { + const std::string spirv = R"( + OpCapability Kernel + OpCapability Addresses + OpCapability Int64 + OpCapability Linkage + OpMemoryModel Physical64 OpenCL + OpEntryPoint Kernel %test "test" %__spirv_BuiltInWorkgroupSize + OpExecutionMode %test ContractionOff + OpDecorate %__spirv_BuiltInWorkgroupSize Constant + OpDecorate %__spirv_BuiltInWorkgroupSize LinkageAttributes "__spirv_BuiltInWorkgroupSize" Import + OpDecorate %__spirv_BuiltInWorkgroupSize BuiltIn WorkgroupSize + %void = OpTypeVoid + %ulong = OpTypeInt 64 0 + %v3ulong = OpTypeVector %ulong 3 +%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong + %8 = OpTypeFunction %void +%__spirv_BuiltInWorkgroupSize = OpVariable %_ptr_Input_v3ulong Input + %test = OpFunction %void None %8 + %entry = OpLabel + %11 = OpLoad %v3ulong %__spirv_BuiltInWorkgroupSize Aligned 1 + %12 = OpCompositeExtract %ulong %11 0 + OpReturn + OpFunctionEnd +)"; + + CompileSuccessfully(spirv); + EXPECT_EQ(SPV_SUCCESS, ValidateInstructions()); +} + TEST_F(ValidateMode, FragmentOriginLowerLeftVulkan) { const std::string spirv = R"( OpCapability Shader