Add support for GL_NV_shader_invocation_reorder. (#3054)

This commit is contained in:
alelenv 2022-12-09 12:19:08 -08:00 committed by GitHub
parent 19d816c8c9
commit 4fc43cd3c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 7478 additions and 5636 deletions

View file

@ -2368,6 +2368,79 @@ void TParseContext::builtInOpCheck(const TSourceLoc& loc, const TFunction& fnCan
}
break;
case EOpHitObjectTraceRayNV:
if (!(*argp)[11]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "payload number", "");
else {
unsigned int location = (*argp)[11]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(0, location) < 0)
error(loc, "with layout(location =", "no rayPayloadEXT/rayPayloadInEXT declared", "%d)", location);
}
break;
case EOpHitObjectTraceRayMotionNV:
if (!(*argp)[12]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "payload number", "");
else {
unsigned int location = (*argp)[12]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(0, location) < 0)
error(loc, "with layout(location =", "no rayPayloadEXT/rayPayloadInEXT declared", "%d)", location);
}
break;
case EOpHitObjectExecuteShaderNV:
if (!(*argp)[1]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "payload number", "");
else {
unsigned int location = (*argp)[1]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(0, location) < 0)
error(loc, "with layout(location =", "no rayPayloadEXT/rayPayloadInEXT declared", "%d)", location);
}
break;
case EOpHitObjectRecordHitNV:
if (!(*argp)[12]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "hitobjectattribute number", "");
else {
unsigned int location = (*argp)[12]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(2, location) < 0)
error(loc, "with layout(location =", "no hitObjectAttributeNV declared", "%d)", location);
}
break;
case EOpHitObjectRecordHitMotionNV:
if (!(*argp)[13]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "hitobjectattribute number", "");
else {
unsigned int location = (*argp)[13]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(2, location) < 0)
error(loc, "with layout(location =", "no hitObjectAttributeNV declared", "%d)", location);
}
break;
case EOpHitObjectRecordHitWithIndexNV:
if (!(*argp)[11]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "hitobjectattribute number", "");
else {
unsigned int location = (*argp)[11]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(2, location) < 0)
error(loc, "with layout(location =", "no hitObjectAttributeNV declared", "%d)", location);
}
break;
case EOpHitObjectRecordHitWithIndexMotionNV:
if (!(*argp)[12]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "hitobjectattribute number", "");
else {
unsigned int location = (*argp)[12]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(2, location) < 0)
error(loc, "with layout(location =", "no hitObjectAttributeNV declared", "%d)", location);
}
break;
case EOpHitObjectGetAttributesNV:
if (!(*argp)[1]->getAsConstantUnion())
error(loc, "argument must be compile-time constant", "hitobjectattribute number", "");
else {
unsigned int location = (*argp)[1]->getAsConstantUnion()->getAsConstantUnion()->getConstArray()[0].getUConst();
if (!extensionTurnedOn(E_GL_EXT_spirv_intrinsics) && intermediate.checkLocationRT(2, location) < 0)
error(loc, "with layout(location =", "no hitObjectAttributeNV declared", "%d)", location);
}
break;
case EOpRayQueryGetIntersectionType:
case EOpRayQueryGetIntersectionT:
case EOpRayQueryGetIntersectionInstanceCustomIndex:
@ -4581,7 +4654,7 @@ void TParseContext::checkRuntimeSizable(const TSourceLoc& loc, const TIntermType
// check for additional things allowed by GL_EXT_nonuniform_qualifier
if (base.getBasicType() == EbtSampler || base.getBasicType() == EbtAccStruct || base.getBasicType() == EbtRayQuery ||
(base.getBasicType() == EbtBlock && base.getType().getQualifier().isUniformOrBuffer()))
base.getBasicType() == EbtHitObjectNV || (base.getBasicType() == EbtBlock && base.getType().getQualifier().isUniformOrBuffer()))
requireExtensions(loc, 1, &E_GL_EXT_nonuniform_qualifier, "variable index");
else
error(loc, "", "[", "array must be redeclared with a size before being indexed with a variable");
@ -5761,6 +5834,10 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
}
publicType.qualifier.layoutShaderRecord = true;
return;
} else if (id == "hitobjectshaderrecordnv") {
requireExtensions(loc, 1, &E_GL_NV_shader_invocation_reorder, "hitobject shader record NV");
publicType.qualifier.layoutHitObjectShaderRecordNV = true;
return;
}
}
@ -6232,6 +6309,8 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
dst.pervertexNV = true;
if (src.pervertexEXT)
dst.pervertexEXT = true;
if (src.layoutHitObjectShaderRecordNV)
dst.layoutHitObjectShaderRecordNV = true;
#endif
}
}
@ -6389,6 +6468,7 @@ void TParseContext::layoutTypeCheck(const TSourceLoc& loc, const TType& type)
case EvqHitAttr:
case EvqCallableData:
case EvqCallableDataIn:
case EvqHitObjectAttrNV:
break;
#endif
default:
@ -7344,7 +7424,10 @@ TIntermNode* TParseContext::declareVariable(const TSourceLoc& loc, TString& iden
if (initializer) {
if (type.getBasicType() == EbtRayQuery) {
error(loc, "ray queries can only be initialized by using the rayQueryInitializeEXT intrinsic:", "=", identifier.c_str());
} else if (type.getBasicType() == EbtHitObjectNV) {
error(loc, "hit objects cannot be initialized using initializers", "=", identifier.c_str());
}
}
if (type.isCoopMat()) {
@ -8771,6 +8854,10 @@ void TParseContext::blockStageIoCheck(const TSourceLoc& loc, const TQualifier& q
profileRequires(loc, ~EEsProfile, 460, 2, extsrt, "callableDataInNV block");
requireStage(loc, (EShLanguageMask)(EShLangCallableMask), "callableDataInNV block");
break;
case EvqHitObjectAttrNV:
profileRequires(loc, ~EEsProfile, 460, E_GL_NV_shader_invocation_reorder, "hitObjectAttributeNV block");
requireStage(loc, (EShLanguageMask)(EShLangRayGenMask | EShLangClosestHitMask | EShLangMissMask), "hitObjectAttributeNV block");
break;
#endif
default:
error(loc, "only uniform, buffer, in, or out blocks are supported", blockName->c_str(), "");