Merge pull request #641 from chaoc/passthrough

Add support for SPV_NV_geometry_shader_passthrough
This commit is contained in:
John Kessenich
2016-12-21 10:59:07 -07:00
committed by GitHub
13 changed files with 153 additions and 8 deletions

View File

@@ -599,6 +599,9 @@ public:
layoutFormat = ElfNone;
layoutPushConstant = false;
#ifdef NV_EXTENSIONS
layoutPassthrough = false;
#endif
}
bool hasLayout() const
{
@@ -652,6 +655,10 @@ public:
bool layoutPushConstant;
#ifdef NV_EXTENSIONS
bool layoutPassthrough;
#endif
bool hasUniformLayout() const
{
return hasMatrix() ||
@@ -1537,6 +1544,12 @@ public:
if (qualifier.layoutPushConstant)
p += snprintf(p, end - p, "push_constant ");
#ifdef NV_EXTENSIONS
if (qualifier.layoutPassthrough)
p += snprintf(p, end - p, "passthrough ");
#endif
p += snprintf(p, end - p, ") ");
}
}

View File

@@ -604,7 +604,11 @@ void TParseContext::fixIoArraySize(const TSourceLoc& loc, TType& type)
void TParseContext::ioArrayCheck(const TSourceLoc& loc, const TType& type, const TString& identifier)
{
if (! type.isArray() && ! symbolTable.atBuiltInLevel()) {
if (type.getQualifier().isArrayedIo(language))
if (type.getQualifier().isArrayedIo(language)
#ifdef NV_EXTENSIONS
&& !type.getQualifier().layoutPassthrough
#endif
)
error(loc, "type must be an array:", type.getStorageQualifierString(), identifier.c_str());
}
}
@@ -3459,6 +3463,20 @@ void TParseContext::redeclareBuiltinBlock(const TSourceLoc& loc, TTypeList& newT
// - remove unused members
// - ensure remaining qualifiers/types match
TType& type = block->getWritableType();
#ifdef NV_EXTENSIONS
// if gl_PerVertex is redeclared for the purpose of passing through "gl_Position"
// for passthrough purpose, the redclared block should have the same qualifers as
// the current one
if (currentBlockQualifier.layoutPassthrough)
{
type.getQualifier().layoutPassthrough = currentBlockQualifier.layoutPassthrough;
type.getQualifier().storage = currentBlockQualifier.storage;
type.getQualifier().layoutStream = currentBlockQualifier.layoutStream;
type.getQualifier().layoutXfbBuffer = currentBlockQualifier.layoutXfbBuffer;
}
#endif
TTypeList::iterator member = type.getWritableStruct()->begin();
size_t numOriginalMembersFound = 0;
while (member != type.getStruct()->end()) {
@@ -3928,6 +3946,14 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
publicType.shaderQualifiers.geometry = ElgTriangleStrip;
return;
}
#ifdef NV_EXTENSIONS
if (id == "passthrough") {
requireExtensions(loc, 1, &E_SPV_NV_geometry_shader_passthrough, "geometry shader passthrough");
publicType.qualifier.layoutPassthrough = true;
intermediate.setGeoPassthroughEXT();
return;
}
#endif
} else {
assert(language == EShLangTessEvaluation);
@@ -4328,6 +4354,11 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
if (src.layoutPushConstant)
dst.layoutPushConstant = true;
#ifdef NV_EXTENSIONS
if (src.layoutPassthrough)
dst.layoutPassthrough = true;
#endif
}
}

View File

@@ -197,6 +197,7 @@ void TParseVersions::initializeExtensionBehavior()
#ifdef NV_EXTENSIONS
extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable;
extensionBehavior[E_SPV_NV_geometry_shader_passthrough] = EBhDisable;
#endif
// AEP
@@ -309,6 +310,7 @@ void TParseVersions::getPreamble(std::string& preamble)
#ifdef NV_EXTENSIONS
"#define GL_NV_sample_mask_override_coverage 1\n"
"#define GL_NV_geometry_shader_passthrough 1\n"
#endif
;
}

View File

@@ -144,6 +144,7 @@ const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_sh
#endif
#ifdef NV_EXTENSIONS
const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
const char* const E_SPV_NV_geometry_shader_passthrough = "GL_NV_geometry_shader_passthrough";
#endif
// AEP

View File

@@ -469,9 +469,17 @@ void TIntermediate::finalCheck(TInfoSink& infoSink, bool keepUncalled)
case EShLangGeometry:
if (inputPrimitive == ElgNone)
error(infoSink, "At least one shader must specify an input layout primitive");
if (outputPrimitive == ElgNone)
if (outputPrimitive == ElgNone
#ifdef NV_EXTENSIONS
&& !getGeoPassthroughEXT()
#endif
)
error(infoSink, "At least one shader must specify an output layout primitive");
if (vertices == TQualifier::layoutNotSet)
if (vertices == TQualifier::layoutNotSet
#ifdef NV_EXTENSIONS
&& !getGeoPassthroughEXT()
#endif
)
error(infoSink, "At least one shader must specify a layout(max_vertices = value)");
break;
case EShLangFragment:

View File

@@ -153,6 +153,7 @@ public:
flattenUniformArrays(false),
#ifdef NV_EXTENSIONS
layoutOverrideCoverage(false),
geoPassthroughEXT(false),
#endif
useUnknownFormat(false)
{
@@ -393,6 +394,8 @@ public:
#ifdef NV_EXTENSIONS
void setLayoutOverrideCoverage() { layoutOverrideCoverage = true; }
bool getLayoutOverrideCoverage() const { return layoutOverrideCoverage; }
void setGeoPassthroughEXT() { geoPassthroughEXT = true; }
bool getGeoPassthroughEXT() const { return geoPassthroughEXT; }
#endif
protected:
@@ -457,6 +460,7 @@ protected:
#ifdef NV_EXTENSIONS
bool layoutOverrideCoverage;
bool geoPassthroughEXT;
#endif
typedef std::list<TCall> TGraph;