Add support for primitive culling layout qualifier. (#2220)
* Add support for primitive culling layout qualifier. * Add error checks for primitive flags and negative test.
This commit is contained in:
parent
eba1389a01
commit
59216d5cd8
@ -1448,7 +1448,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion,
|
|||||||
builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb);
|
builder.addExecutionMode(shaderEntry, spv::ExecutionModeXfb);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sourceExtensions.find("GL_EXT_ray_flags_primitive_culling") != sourceExtensions.end()) {
|
if (glslangIntermediate->getLayoutPrimitiveCulling()) {
|
||||||
builder.addCapability(spv::CapabilityRayTraversalPrimitiveCullingProvisionalKHR);
|
builder.addCapability(spv::CapabilityRayTraversalPrimitiveCullingProvisionalKHR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
Test/baseResults/spv.ext.RayPrimCull_Errors.rgen.out
Normal file
9
Test/baseResults/spv.ext.RayPrimCull_Errors.rgen.out
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
spv.ext.RayPrimCull_Errors.rgen
|
||||||
|
ERROR: 0:3: 'primitive culling' : required extension not requested: GL_EXT_ray_flags_primitive_culling
|
||||||
|
ERROR: 0:5: 'primitive_culling' : layout qualifier can not have storage qualifiers
|
||||||
|
ERROR: 0:6: 'primitive_culling' : can only be applied as standalone
|
||||||
|
ERROR: 0:7: 'primitive_culling' : can only be applied as standalone
|
||||||
|
ERROR: 4 compilation errors. No code generated.
|
||||||
|
|
||||||
|
|
||||||
|
SPIR-V is not generated for failed compile or link
|
@ -2,6 +2,7 @@
|
|||||||
#extension GL_EXT_ray_query : enable
|
#extension GL_EXT_ray_query : enable
|
||||||
#extension GL_EXT_ray_flags_primitive_culling : enable
|
#extension GL_EXT_ray_flags_primitive_culling : enable
|
||||||
|
|
||||||
|
layout(primitive_culling);
|
||||||
struct Ray
|
struct Ray
|
||||||
{
|
{
|
||||||
vec3 pos;
|
vec3 pos;
|
||||||
|
@ -11,6 +11,7 @@ layout(shaderRecordEXT) buffer block
|
|||||||
vec3 origin;
|
vec3 origin;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
layout(primitive_culling);
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
uint lx = gl_LaunchIDEXT.x;
|
uint lx = gl_LaunchIDEXT.x;
|
||||||
|
10
Test/spv.ext.RayPrimCull_Errors.rgen
Normal file
10
Test/spv.ext.RayPrimCull_Errors.rgen
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#version 460
|
||||||
|
#extension GL_EXT_ray_tracing : enable
|
||||||
|
layout(primitive_culling);
|
||||||
|
#extension GL_EXT_ray_flags_primitive_culling : enable
|
||||||
|
layout(primitive_culling) uniform;
|
||||||
|
layout(primitive_culling, binding = 2) uniform accelerationStructureEXT as;
|
||||||
|
layout(std140, binding = 2, primitive_culling) buffer block { int x; };
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
}
|
@ -1235,6 +1235,7 @@ struct TShaderQualifiers {
|
|||||||
bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV set
|
bool layoutDerivativeGroupQuads; // true if layout derivative_group_quadsNV set
|
||||||
bool layoutDerivativeGroupLinear; // true if layout derivative_group_linearNV set
|
bool layoutDerivativeGroupLinear; // true if layout derivative_group_linearNV set
|
||||||
int primitives; // mesh shader "max_primitives"DerivativeGroupLinear; // true if layout derivative_group_linearNV set
|
int primitives; // mesh shader "max_primitives"DerivativeGroupLinear; // true if layout derivative_group_linearNV set
|
||||||
|
bool layoutPrimitiveCulling; // true if layout primitive_culling set
|
||||||
TLayoutDepth getDepth() const { return layoutDepth; }
|
TLayoutDepth getDepth() const { return layoutDepth; }
|
||||||
#else
|
#else
|
||||||
TLayoutDepth getDepth() const { return EldNone; }
|
TLayoutDepth getDepth() const { return EldNone; }
|
||||||
@ -1268,6 +1269,7 @@ struct TShaderQualifiers {
|
|||||||
layoutOverrideCoverage = false;
|
layoutOverrideCoverage = false;
|
||||||
layoutDerivativeGroupQuads = false;
|
layoutDerivativeGroupQuads = false;
|
||||||
layoutDerivativeGroupLinear = false;
|
layoutDerivativeGroupLinear = false;
|
||||||
|
layoutPrimitiveCulling = false;
|
||||||
primitives = TQualifier::layoutNotSet;
|
primitives = TQualifier::layoutNotSet;
|
||||||
interlockOrdering = EioNone;
|
interlockOrdering = EioNone;
|
||||||
#endif
|
#endif
|
||||||
@ -1331,6 +1333,8 @@ struct TShaderQualifiers {
|
|||||||
primitives = src.primitives;
|
primitives = src.primitives;
|
||||||
if (src.interlockOrdering != EioNone)
|
if (src.interlockOrdering != EioNone)
|
||||||
interlockOrdering = src.interlockOrdering;
|
interlockOrdering = src.interlockOrdering;
|
||||||
|
if (src.layoutPrimitiveCulling)
|
||||||
|
layoutPrimitiveCulling = src.layoutPrimitiveCulling;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5173,6 +5173,12 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (id == "primitive_culling") {
|
||||||
|
requireExtensions(loc, 1, &E_GL_EXT_ray_flags_primitive_culling, "primitive culling");
|
||||||
|
publicType.shaderQualifiers.layoutPrimitiveCulling = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), "");
|
error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), "");
|
||||||
@ -6104,6 +6110,8 @@ void TParseContext::checkNoShaderLayouts(const TSourceLoc& loc, const TShaderQua
|
|||||||
error(loc, message, "num_views", "");
|
error(loc, message, "num_views", "");
|
||||||
if (shaderQualifiers.interlockOrdering != EioNone)
|
if (shaderQualifiers.interlockOrdering != EioNone)
|
||||||
error(loc, message, TQualifier::getInterlockOrderingString(shaderQualifiers.interlockOrdering), "");
|
error(loc, message, TQualifier::getInterlockOrderingString(shaderQualifiers.interlockOrdering), "");
|
||||||
|
if (shaderQualifiers.layoutPrimitiveCulling)
|
||||||
|
error(loc, "can only be applied as standalone", "primitive_culling", "");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8368,6 +8376,16 @@ void TParseContext::updateStandaloneQualifierDefaults(const TSourceLoc& loc, con
|
|||||||
{
|
{
|
||||||
checkIoArraysConsistency(loc);
|
checkIoArraysConsistency(loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (publicType.shaderQualifiers.layoutPrimitiveCulling) {
|
||||||
|
if (publicType.qualifier.storage != EvqTemporary)
|
||||||
|
error(loc, "layout qualifier can not have storage qualifiers", "primitive_culling","", "");
|
||||||
|
else {
|
||||||
|
intermediate.setLayoutPrimitiveCulling();
|
||||||
|
}
|
||||||
|
// Exit early as further checks are not valid
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
const TQualifier& qualifier = publicType.qualifier;
|
const TQualifier& qualifier = publicType.qualifier;
|
||||||
|
|
||||||
|
@ -276,7 +276,8 @@ public:
|
|||||||
needToLegalize(false),
|
needToLegalize(false),
|
||||||
binaryDoubleOutput(false),
|
binaryDoubleOutput(false),
|
||||||
usePhysicalStorageBuffer(false),
|
usePhysicalStorageBuffer(false),
|
||||||
uniformLocationBase(0)
|
uniformLocationBase(0),
|
||||||
|
layoutPrimitiveCulling(false)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
localSize[0] = 1;
|
localSize[0] = 1;
|
||||||
@ -742,6 +743,8 @@ public:
|
|||||||
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
|
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
|
||||||
bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; }
|
bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; }
|
||||||
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; }
|
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; }
|
||||||
|
void setLayoutPrimitiveCulling() { layoutPrimitiveCulling = true; }
|
||||||
|
bool getLayoutPrimitiveCulling() const { return layoutPrimitiveCulling; }
|
||||||
bool setPrimitives(int m)
|
bool setPrimitives(int m)
|
||||||
{
|
{
|
||||||
if (primitives != TQualifier::layoutNotSet)
|
if (primitives != TQualifier::layoutNotSet)
|
||||||
@ -974,6 +977,7 @@ protected:
|
|||||||
ComputeDerivativeMode computeDerivativeMode;
|
ComputeDerivativeMode computeDerivativeMode;
|
||||||
int primitives;
|
int primitives;
|
||||||
int numTaskNVBlocks;
|
int numTaskNVBlocks;
|
||||||
|
bool layoutPrimitiveCulling;
|
||||||
|
|
||||||
// Base shift values
|
// Base shift values
|
||||||
std::array<unsigned int, EResCount> shiftBinding;
|
std::array<unsigned int, EResCount> shiftBinding;
|
||||||
|
@ -337,6 +337,7 @@ INSTANTIATE_TEST_CASE_P(
|
|||||||
"spv.ext.IntersectShader_Errors.rint",
|
"spv.ext.IntersectShader_Errors.rint",
|
||||||
"spv.ext.MissShader.rmiss",
|
"spv.ext.MissShader.rmiss",
|
||||||
"spv.ext.MissShader_Errors.rmiss",
|
"spv.ext.MissShader_Errors.rmiss",
|
||||||
|
"spv.ext.RayPrimCull_Errors.rgen",
|
||||||
"spv.ext.RayCallable.rcall",
|
"spv.ext.RayCallable.rcall",
|
||||||
"spv.ext.RayCallable_Errors.rcall",
|
"spv.ext.RayCallable_Errors.rcall",
|
||||||
"spv.ext.RayConstants.rgen",
|
"spv.ext.RayConstants.rgen",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user