Test for WorkgroupId not being a uvec3 (#2173)

Test for WorkgroupId not being a uvec3

Fixes #1545

Make %workgroup_id an Input variable as required by spec
This commit is contained in:
Alejandro Lopez 2018-12-05 16:34:57 -05:00 committed by David Neto
parent d9a972210f
commit 03afee3b90

View File

@ -1926,6 +1926,37 @@ OpStore %output_pos %pos
ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0)); ASSERT_EQ(SPV_SUCCESS, ValidateInstructions(SPV_ENV_VULKAN_1_0));
} }
TEST_F(ValidateBuiltIns, WorkgroupIdNotVec3) {
CodeGenerator generator = GetDefaultShaderCodeGenerator();
generator.before_types_ = R"(
OpDecorate %workgroup_size BuiltIn WorkgroupSize
OpDecorate %workgroup_id BuiltIn WorkgroupId
)";
generator.after_types_ = R"(
%workgroup_size = OpConstantComposite %u32vec3 %u32_1 %u32_1 %u32_1
%input_ptr = OpTypePointer Input %u32vec2
%workgroup_id = OpVariable %input_ptr Input
)";
EntryPoint entry_point;
entry_point.name = "main";
entry_point.execution_model = "GLCompute";
entry_point.interfaces = "%workgroup_id";
entry_point.body = R"(
%copy_size = OpCopyObject %u32vec3 %workgroup_size
%load_id = OpLoad %u32vec2 %workgroup_id
)";
generator.entry_points_.push_back(std::move(entry_point));
CompileSuccessfully(generator.Build(), SPV_ENV_VULKAN_1_0);
ASSERT_EQ(SPV_ERROR_INVALID_DATA, ValidateInstructions(SPV_ENV_VULKAN_1_0));
EXPECT_THAT(getDiagnosticString(),
HasSubstr("According to the Vulkan spec BuiltIn WorkgroupId "
"variable needs to be a 3-component 32-bit int vector. "
"ID <2> (OpVariable) has 2 components."));
}
TEST_F(ValidateBuiltIns, TwoBuiltInsFirstFails) { TEST_F(ValidateBuiltIns, TwoBuiltInsFirstFails) {
CodeGenerator generator = GetDefaultShaderCodeGenerator(); CodeGenerator generator = GetDefaultShaderCodeGenerator();