Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type checks for hitObjectNV #3689

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Test/baseResults/spv.nv.hitobject-errors.rgen.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
spv.nv.hitobject-errors.rgen
ERROR: 0:7: 'hitObjectNV' : hitObjectNV can only be declared in global or function scope with no storage qualifier: uHitObj
ERROR: 0:9: 'hitObjectNV' : hitObjectNV can only be declared in global or function scope with no storage qualifier: hobjIn
ERROR: 0:10: 'hitObjectNV' : hitObjectNV can only be declared in global or function scope with no storage qualifier: hobjOut
ERROR: 0:21: 'structure' : struct contains hitObjectNV : wrapper
ERROR: 4 compilation errors. No code generated.


SPIR-V is not generated for failed compile or link
24 changes: 24 additions & 0 deletions Test/spv.nv.hitobject-errors.rgen
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 460
#extension GL_EXT_ray_tracing : enable
#extension GL_NV_shader_invocation_reorder : enable


hitObjectNV hObjGlob; // OK
uniform hitObjectNV uHitObj; // ERROR

layout(location=0) in hitObjectNV hobjIn; // ERROR
out hitObjectNV hobjOut; // ERROR

struct hObjWrapper{
hitObjectNV objField;
vec3 v;
};

void foo(hitObjectNV hObjArg) {} // OK

void main()
{
hObjWrapper wrapper; // ERROR
hitObjectNV localHitObj; // OK
foo(localHitObj); // OK
}
13 changes: 13 additions & 0 deletions glslang/MachineIndependent/ParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 contains hitObjectNV :", type.getBasicTypeString().c_str(), identifier.c_str());
D7ry marked this conversation as resolved.
Show resolved Hide resolved
} 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)
Expand Down Expand Up @@ -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", "");
Expand Down
1 change: 1 addition & 0 deletions glslang/MachineIndependent/ParseHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ class TParseContext : public TParseContextBase {
void samplerCheck(const TSourceLoc&, const TType&, const TString& identifier, TIntermTyped* initializer);
void atomicUintCheck(const TSourceLoc&, const TType&, const TString& identifier);
void accStructCheck(const TSourceLoc & loc, const TType & type, const TString & identifier);
void hitObjectNVCheck(const TSourceLoc & loc, const TType & type, const TString & identifier);
void transparentOpaqueCheck(const TSourceLoc&, const TType&, const TString& identifier);
void memberQualifierCheck(glslang::TPublicType&);
void globalQualifierFixCheck(const TSourceLoc&, TQualifier&, bool isMemberCheck = false, const TPublicType* publicType = nullptr);
Expand Down
1 change: 1 addition & 0 deletions gtests/Spv.FromFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ INSTANTIATE_TEST_SUITE_P(

// SPV_NV_shader_execution_reorder

"spv.nv.hitobject-errors.rgen",
"spv.nv.hitobject-allops.rgen",
"spv.nv.hitobject-allops.rchit",
"spv.nv.hitobject-allops.rmiss",
Expand Down