Skip to content

Commit

Permalink
spirv-val: Remove OpenCL ivec3 req (#5940)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg authored Jan 15, 2025
1 parent b8566d4 commit 6ea395b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 11 deletions.
25 changes: 14 additions & 11 deletions source/val/validate_builtins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
31 changes: 31 additions & 0 deletions test/val/val_modes_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ea395b

Please sign in to comment.