mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2024-11-23 12:10:06 +00:00
Forbid Generic variables.
This commit is contained in:
parent
7dbfdda609
commit
5f99fc33cd
@ -490,6 +490,9 @@ spv_result_t InstructionPass(ValidationState_t& _,
|
||||
case SpvOpVariable: {
|
||||
const SpvStorageClass storage_class =
|
||||
static_cast<SpvStorageClass>(inst->words[inst->operands[2].offset]);
|
||||
if (storage_class == SpvStorageClassGeneric)
|
||||
return _.diag(SPV_ERROR_INVALID_BINARY)
|
||||
<< "OpVariable storage class cannot be Generic";
|
||||
spvCheckReturn(StorageClassCapabilityCheck(_, storage_class));
|
||||
|
||||
if (_.getLayoutSection() == kLayoutFunctionDefinitions) {
|
||||
|
@ -381,9 +381,6 @@ make_pair(" %intt = OpTypeInt 32 0\n"
|
||||
make_pair(" %intt = OpTypeInt 32 0\n"
|
||||
" %ptrt = OpTypePointer Private %intt\n"
|
||||
" %var = OpVariable %ptrt Private\n", ShaderDependencies()),
|
||||
make_pair(" %intt = OpTypeInt 32 0\n"
|
||||
" %ptrt = OpTypePointer Generic %intt\n"
|
||||
" %var = OpVariable %ptrt Generic\n", KernelDependencies()),
|
||||
make_pair(" %intt = OpTypeInt 32 0\n"
|
||||
" %ptrt = OpTypePointer PushConstant %intt\n"
|
||||
" %var = OpVariable %ptrt PushConstant\n", ShaderDependencies()),
|
||||
|
@ -141,4 +141,34 @@ INSTANTIATE_TEST_CASE_P(MatrixOp, ValidateStorage,
|
||||
"AtomicCounter",
|
||||
"Image"));
|
||||
// clang-format on
|
||||
|
||||
TEST_F(ValidateStorage, GenericVariableOutsideFunction) {
|
||||
const auto str = R"(
|
||||
OpCapability Kernel
|
||||
OpMemoryModel Logical OpenCL
|
||||
%intt = OpTypeInt 32 1
|
||||
%ptrt = OpTypePointer Function %intt
|
||||
%var = OpVariable %ptrt Generic
|
||||
)";
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions());
|
||||
}
|
||||
|
||||
TEST_F(ValidateStorage, GenericVariableInsideFunction) {
|
||||
const auto str = R"(
|
||||
OpCapability Shader
|
||||
OpMemoryModel Logical GLSL450
|
||||
%intt = OpTypeInt 32 1
|
||||
%voidt = OpTypeVoid
|
||||
%vfunct = OpTypeFunction %voidt
|
||||
%ptrt = OpTypePointer Function %intt
|
||||
%func = OpFunction %voidt None %vfunct
|
||||
%funcl = OpLabel
|
||||
%var = OpVariable %ptrt Generic
|
||||
OpReturn
|
||||
OpFunctionEnd
|
||||
)";
|
||||
CompileSuccessfully(str);
|
||||
ASSERT_EQ(SPV_ERROR_INVALID_BINARY, ValidateInstructions());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user