mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-29 06:21:06 +00:00
spirv-val: Tests for zero product workgroup size
This commit is contained in:
parent
469668bc8d
commit
2e9855df82
@ -88,6 +88,99 @@ OpDecorate %int3_1 BuiltIn WorkgroupSize
|
||||
EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroWorkgroupSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpDecorate %int3_1 BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"WorkgroupSize decorations must not have a static product of zero"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroSpecWorkgroupSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpDecorate %int3_1 BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%int_0 = OpSpecConstant %int 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroSpecCompositeWorkgroupSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpDecorate %int3_1 BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%int_0 = OpSpecConstant %int 0
|
||||
%int_1 = OpSpecConstant %int 1
|
||||
%int3_1 = OpSpecConstantComposite %int3 %int_1 %int_0 %int_0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, KernelZeroWorkgroupSizeConstant) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Addresses
|
||||
OpCapability Linkage
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %main "main"
|
||||
OpDecorate %int3_1 BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int3_1 = OpConstantComposite %int3 %int_1 %int_0 %int_0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_ID, ValidateInstructions());
|
||||
EXPECT_THAT(getDiagnosticString(), HasSubstr("must be a variable"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, KernelZeroWorkgroupSizeVariable) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Addresses
|
||||
OpCapability Linkage
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %main "main"
|
||||
OpDecorate %var BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%ptr = OpTypePointer Input %int3
|
||||
%var = OpVariable %ptr Input
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeVulkanLocalSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
@ -101,6 +194,38 @@ OpExecutionMode %main LocalSize 1 1 1
|
||||
EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroLocalSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Local Size execution mode must not have a product of zero"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, KernelZeroLocalSize) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Addresses
|
||||
OpCapability Linkage
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 0
|
||||
)" + kVoidFunction;
|
||||
|
||||
CompileSuccessfully(spirv);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions());
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr("Local Size execution mode must not have a product of zero"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeVulkanLocalSizeIdBad) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
@ -135,6 +260,64 @@ OpExecutionModeId %main LocalSizeId %int_1 %int_1 %int_1
|
||||
EXPECT_THAT(SPV_SUCCESS, ValidateInstructions(env));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroLocalSizeId) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_0 = OpConstant %int 0
|
||||
)" + kVoidFunction;
|
||||
|
||||
spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
|
||||
CompileSuccessfully(spirv, env);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Local Size Id execution mode must not have a product of zero"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, GLComputeZeroSpecLocalSizeId) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_0 = OpSpecConstant %int 0
|
||||
)" + kVoidFunction;
|
||||
|
||||
spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
|
||||
CompileSuccessfully(spirv, env);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions(env));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, KernelZeroLocalSizeId) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Addresses
|
||||
OpCapability Linkage
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Physical32 OpenCL
|
||||
OpEntryPoint Kernel %main "main"
|
||||
OpExecutionModeId %main LocalSizeId %int_1 %int_0 %int_1
|
||||
%int = OpTypeInt 32 0
|
||||
%int_1 = OpConstant %int 1
|
||||
%int_0 = OpConstant %int 0
|
||||
)" + kVoidFunction;
|
||||
|
||||
spv_target_env env = SPV_ENV_UNIVERSAL_1_3;
|
||||
CompileSuccessfully(spirv, env);
|
||||
EXPECT_THAT(SPV_ERROR_INVALID_DATA, ValidateInstructions(env));
|
||||
EXPECT_THAT(
|
||||
getDiagnosticString(),
|
||||
HasSubstr(
|
||||
"Local Size Id execution mode must not have a product of zero"));
|
||||
}
|
||||
|
||||
TEST_F(ValidateMode, FragmentOriginLowerLeftVulkan) {
|
||||
const std::string spirv = R"(
|
||||
OpCapability Shader
|
||||
|
Loading…
Reference in New Issue
Block a user