mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-10-18 19:20:05 +00:00
parent
352a411278
commit
b014238e08
@ -266,7 +266,8 @@ spv_result_t ValidateDecorationTarget(ValidationState_t& _, SpvDecoration dec,
|
||||
<< "BuiltIns can only target variables, structure members or "
|
||||
"constants";
|
||||
}
|
||||
if (inst->GetOperandAs<SpvBuiltIn>(2) == SpvBuiltInWorkgroupSize) {
|
||||
if (_.HasCapability(SpvCapabilityShader) &&
|
||||
inst->GetOperandAs<SpvBuiltIn>(2) == SpvBuiltInWorkgroupSize) {
|
||||
if (!spvOpcodeIsConstant(target->opcode())) {
|
||||
return fail() << "must be a constant for WorkgroupSize";
|
||||
}
|
||||
|
@ -32,6 +32,40 @@ using ::testing::Eq;
|
||||
using ::testing::HasSubstr;
|
||||
using ::testing::Values;
|
||||
|
||||
using DecorationTest = spvtest::ValidateBase<bool>;
|
||||
|
||||
TEST_F(DecorationTest, WorkgroupSizeShader) {
|
||||
const std::string text = R"(
|
||||
OpCapability Shader
|
||||
OpCapability Linkage
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpDecorate %ones BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%int_1 = OpConstant %int 1
|
||||
%ones = OpConstantComposite %int3 %int_1 %int_1 %int_1
|
||||
)";
|
||||
|
||||
CompileSuccessfully(text);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(DecorationTest, WorkgroupSizeKernel) {
|
||||
const std::string text = R"(
|
||||
OpCapability Kernel
|
||||
OpCapability Linkage
|
||||
OpMemoryModel Logical OpenCL
|
||||
OpDecorate %var BuiltIn WorkgroupSize
|
||||
%int = OpTypeInt 32 0
|
||||
%int3 = OpTypeVector %int 3
|
||||
%ptr = OpTypePointer Input %int3
|
||||
%var = OpVariable %ptr Input
|
||||
)";
|
||||
|
||||
CompileSuccessfully(text);
|
||||
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
|
||||
}
|
||||
|
||||
using MemberOnlyDecorations = spvtest::ValidateBase<std::string>;
|
||||
|
||||
TEST_P(MemberOnlyDecorations, MemberDecoration) {
|
||||
|
@ -1700,14 +1700,6 @@ std::make_pair(std::string(kOpenCLMemoryModel) +
|
||||
"%ptr = OpTypePointer Input %intt\n"
|
||||
"%var = OpVariable %ptr Input\n" + std::string(kVoidFVoid),
|
||||
AllCapabilities()),
|
||||
std::make_pair(std::string(kOpenCLMemoryModel) +
|
||||
"OpEntryPoint Kernel %func \"compute\" \n" +
|
||||
"OpDecorate %ones BuiltIn WorkgroupSize\n"
|
||||
"%intt = OpTypeInt 32 0\n"
|
||||
"%int3 = OpTypeVector %intt 3\n"
|
||||
"%int_1 = OpConstant %intt 1\n"
|
||||
"%ones = OpConstantComposite %int3 %int_1 %int_1 %int_1\n" + std::string(kVoidFVoid),
|
||||
AllCapabilities()),
|
||||
std::make_pair(std::string(kOpenCLMemoryModel) +
|
||||
"OpEntryPoint Kernel %func \"compute\" \n" +
|
||||
"OpDecorate %var BuiltIn WorkgroupId\n"
|
||||
|
Loading…
Reference in New Issue
Block a user