Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spirv-val: Fix Workgroup for 64-bit int with Kernel #5940

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
s-perron marked this conversation as resolved.
Show resolved Hide resolved
}

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
Loading