Allow OpTypeBool in UniformConstant (#5237)

See https://github.com/KhronosGroup/SPIRV-Registry/issues/72

* OpenGL allowed uniforms to be declared with boolean types, but the
  validator was overly strict in disallowing it
This commit is contained in:
alan-baker 2023-06-06 18:05:04 -04:00 committed by GitHub
parent 5ed21eb1e2
commit 59b4febd81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 3 deletions

View File

@ -442,6 +442,7 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
storage_class != spv::StorageClass::CrossWorkgroup &&
storage_class != spv::StorageClass::Private &&
storage_class != spv::StorageClass::Function &&
storage_class != spv::StorageClass::UniformConstant &&
storage_class != spv::StorageClass::RayPayloadKHR &&
storage_class != spv::StorageClass::IncomingRayPayloadKHR &&
storage_class != spv::StorageClass::HitAttributeKHR &&
@ -475,8 +476,8 @@ spv_result_t ValidateVariable(ValidationState_t& _, const Instruction* inst) {
"can only be used with non-externally visible shader Storage "
"Classes: Workgroup, CrossWorkgroup, Private, Function, "
"Input, Output, RayPayloadKHR, IncomingRayPayloadKHR, "
"HitAttributeKHR, CallableDataKHR, or "
"IncomingCallableDataKHR";
"HitAttributeKHR, CallableDataKHR, "
"IncomingCallableDataKHR, or UniformConstant";
}
}
}

View File

@ -2317,7 +2317,7 @@ OpFunctionEnd
"be used with non-externally visible shader Storage Classes: "
"Workgroup, CrossWorkgroup, Private, Function, Input, Output, "
"RayPayloadKHR, IncomingRayPayloadKHR, HitAttributeKHR, "
"CallableDataKHR, or IncomingCallableDataKHR")));
"CallableDataKHR, IncomingCallableDataKHR, or UniformConstant")));
}
TEST_P(ValidateIdWithMessage, OpVariableContainsBoolPrivateGood) {
@ -2339,6 +2339,25 @@ OpFunctionEnd
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_P(ValidateIdWithMessage, OpVariableContainsBoolUniformConstantGood) {
std::string spirv = kGLSL450MemoryModel + R"(
%bool = OpTypeBool
%int = OpTypeInt 32 0
%block = OpTypeStruct %bool %int
%_ptr_UniformConstant_block = OpTypePointer UniformConstant %block
%var = OpVariable %_ptr_UniformConstant_block UniformConstant
%void = OpTypeVoid
%fnty = OpTypeFunction %void
%main = OpFunction %void None %fnty
%entry = OpLabel
%load = OpLoad %block %var
OpReturn
OpFunctionEnd
)";
CompileSuccessfully(spirv.c_str());
EXPECT_EQ(SPV_SUCCESS, ValidateInstructions());
}
TEST_P(ValidateIdWithMessage, OpVariableContainsBoolPointerGood) {
std::string spirv = kGLSL450MemoryModel + R"(
%bool = OpTypeBool