Add support for SPV_NV_sample_mask_override_coverage

This commit is contained in:
chaoc
2016-12-19 16:29:34 -08:00
parent 7583ed73ef
commit 0ad6a4e60d
14 changed files with 215 additions and 1 deletions

View File

@@ -920,6 +920,10 @@ struct TShaderQualifiers {
TLayoutDepth layoutDepth;
bool blendEquation; // true if any blend equation was specified
#ifdef NV_EXTENSIONS
bool layoutOverrideCoverage; // true if layout override_coverage set
#endif
void init()
{
geometry = ElgNone;
@@ -939,6 +943,9 @@ struct TShaderQualifiers {
earlyFragmentTests = false;
layoutDepth = EldNone;
blendEquation = false;
#ifdef NV_EXTENSIONS
layoutOverrideCoverage = false;
#endif
}
// Merge in characteristics from the 'src' qualifier. They can override when
@@ -975,6 +982,10 @@ struct TShaderQualifiers {
layoutDepth = src.layoutDepth;
if (src.blendEquation)
blendEquation = src.blendEquation;
#ifdef NV_EXTENSIONS
if (src.layoutOverrideCoverage)
layoutOverrideCoverage = src.layoutOverrideCoverage;
#endif
}
};
@@ -1525,6 +1536,7 @@ public:
p += snprintf(p, end - p, "constant_id=%d ", qualifier.layoutSpecConstantId);
if (qualifier.layoutPushConstant)
p += snprintf(p, end - p, "push_constant ");
p += snprintf(p, end - p, ") ");
}
}

View File

@@ -3304,6 +3304,9 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
identifier == "gl_BackSecondaryColor" ||
identifier == "gl_SecondaryColor" ||
(identifier == "gl_Color" && language == EShLangFragment) ||
#ifdef NV_EXTENSIONS
identifier == "gl_SampleMask" ||
#endif
identifier == "gl_TexCoord") {
// Find the existing symbol, if any.
@@ -3381,8 +3384,16 @@ TSymbol* TParseContext::redeclareBuiltinVariable(const TSourceLoc& loc, const TS
if (! intermediate.setDepth(publicType.layoutDepth))
error(loc, "all redeclarations must use the same depth layout on", "redeclaration", symbol->getName().c_str());
}
}
#ifdef NV_EXTENSIONS
else if (identifier == "gl_SampleMask") {
if (!publicType.layoutOverrideCoverage) {
error(loc, "redeclaration only allowed for override_coverage layout", "redeclaration", symbol->getName().c_str());
}
intermediate.setLayoutOverrideCoverage();
}
#endif
// TODO: semantics quality: separate smooth from nothing declared, then use IsInterpolation for several tests above
return symbol;
@@ -4005,6 +4016,13 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
error(loc, "unknown blend equation", "blend_support", "");
return;
}
#ifdef NV_EXTENSIONS
if (id == "override_coverage") {
requireExtensions(loc, 1, &E_GL_NV_sample_mask_override_coverage, "sample mask override coverage");
publicType.shaderQualifiers.layoutOverrideCoverage = true;
return;
}
#endif
}
error(loc, "unrecognized layout identifier, or qualifier requires assignment (e.g., binding = 4)", id.c_str(), "");
}

View File

@@ -195,6 +195,10 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_AMD_gpu_shader_half_float] = EBhDisable;
#endif
#ifdef NV_EXTENSIONS
extensionBehavior[E_GL_NV_sample_mask_override_coverage] = EBhDisable;
#endif
// AEP
extensionBehavior[E_GL_ANDROID_extension_pack_es31a] = EBhDisable;
extensionBehavior[E_GL_KHR_blend_equation_advanced] = EBhDisable;
@@ -302,6 +306,10 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_AMD_gcn_shader 1\n"
"#define GL_AMD_gpu_shader_half_float 1\n"
#endif
#ifdef NV_EXTENSIONS
"#define GL_NV_sample_mask_override_coverage 1\n"
#endif
;
}

View File

@@ -142,6 +142,9 @@ const char* const E_GL_AMD_shader_explicit_vertex_parameter = "GL_AMD_shader
const char* const E_GL_AMD_gcn_shader = "GL_AMD_gcn_shader";
const char* const E_GL_AMD_gpu_shader_half_float = "GL_AMD_gpu_shader_half_float";
#endif
#ifdef NV_EXTENSIONS
const char* const E_GL_NV_sample_mask_override_coverage = "GL_NV_sample_mask_override_coverage";
#endif
// AEP
const char* const E_GL_ANDROID_extension_pack_es31a = "GL_ANDROID_extension_pack_es31a";

View File

@@ -151,6 +151,9 @@ public:
shiftUboBinding(0),
autoMapBindings(false),
flattenUniformArrays(false),
#ifdef NV_EXTENSIONS
layoutOverrideCoverage(false),
#endif
useUnknownFormat(false)
{
localSize[0] = 1;
@@ -387,6 +390,11 @@ public:
static int getBaseAlignment(const TType&, int& size, int& stride, bool std140, bool rowMajor);
bool promote(TIntermOperator*);
#ifdef NV_EXTENSIONS
void setLayoutOverrideCoverage() { layoutOverrideCoverage = true; }
bool getLayoutOverrideCoverage() const { return layoutOverrideCoverage; }
#endif
protected:
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, TIntermTyped* subtree, const TSourceLoc&);
void error(TInfoSink& infoSink, const char*);
@@ -447,6 +455,10 @@ protected:
bool xfbMode;
bool multiStream;
#ifdef NV_EXTENSIONS
bool layoutOverrideCoverage;
#endif
typedef std::list<TCall> TGraph;
TGraph callGraph;