Add type checks for hitObjectNV (#3689)

`VK_NV_ray_tracing_invocation_reorder` extension introduces `hitObjectNV`, a special opaque type
that can only be declared without storage qualifiers in either global or function scope.
Added checks/tests to enforce this constraint.

References:
https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VK_NV_ray_tracing_invocation_reorder.html
3e0d9a3b3f/extensions/nv/GLSL_NV_shader_invocation_reorder.txt (L180)

Co-authored-by: Tianyun <tianyuny@nvidia.com>
This commit is contained in:
dTry 2024-08-08 07:21:00 -07:00 committed by GitHub
parent 5398d55e33
commit 7c4d91e781
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 48 additions and 0 deletions

View file

@ -3936,6 +3936,18 @@ void TParseContext::accStructCheck(const TSourceLoc& loc, const TType& type, con
}
void TParseContext::hitObjectNVCheck(const TSourceLoc & loc, const TType & type, const TString & identifier)
{
if (type.getBasicType() == EbtStruct && containsFieldWithBasicType(type, EbtHitObjectNV)) {
error(loc, "struct is not allowed to contain hitObjectNV:", type.getTypeName().c_str(), identifier.c_str());
} else if (type.getBasicType() == EbtHitObjectNV) {
TStorageQualifier qualifier = type.getQualifier().storage;
if (qualifier != EvqGlobal && qualifier != EvqTemporary) {
error(loc, "hitObjectNV can only be declared in global or function scope with no storage qualifier:", "hitObjectNV", identifier.c_str());
}
}
}
void TParseContext::transparentOpaqueCheck(const TSourceLoc& loc, const TType& type, const TString& identifier)
{
if (parsingBuiltins)
@ -7875,6 +7887,7 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
transparentOpaqueCheck(loc, type, identifier);
atomicUintCheck(loc, type, identifier);
accStructCheck(loc, type, identifier);
hitObjectNVCheck(loc, type, identifier);
checkAndResizeMeshViewDim(loc, type, /*isBlockMember*/ false);
if (type.getQualifier().storage == EvqConst && type.containsReference()) {
error(loc, "variables with reference type can't have qualifier 'const'", "qualifier", "");