Web: Generalize _EXTENSIONS* in SPIR-V back-end.

About 50 fewer #ifdefs.
About 14K smaller.
Note, the base size is ill-defined due to optimizer settings (size vs. performance),
compression, and target architecture.  Some recent %'s are accidentally reported as
3X the real savings.  Early %'s were accurate.  What matters though is that each
step got worthwhile gains, and what the final size ends up being.
This commit is contained in:
John Kessenich 2019-08-06 07:00:58 -06:00
parent b6d3ee5aca
commit a28f7a75d1
11 changed files with 1188 additions and 1312 deletions

View file

@ -442,9 +442,11 @@ public:
{
precision = EpqNone;
invariant = false;
noContraction = false;
makeTemporary();
declaredBuiltIn = EbvNone;
#ifndef GLSLANG_WEB
noContraction = false;
#endif
}
// drop qualifiers that don't belong in a temporary variable
@ -517,11 +519,11 @@ public:
static_assert(EbvLast < 256, "need to increase size of TBuiltInVariable bitfields!");
TPrecisionQualifier precision : 3;
bool invariant : 1; // require canonical treatment for cross-shader invariance
bool noContraction: 1; // prevent contraction and reassociation, e.g., for 'precise' keyword, and expressions it affects
bool centroid : 1;
bool smooth : 1;
bool flat : 1;
#ifndef GLSLANG_WEB
bool noContraction: 1; // prevent contraction and reassociation, e.g., for 'precise' keyword, and expressions it affects
bool nopersp : 1;
bool explicitInterp : 1;
bool pervertexNV : 1;
@ -552,40 +554,36 @@ public:
{
return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || volatil || restrict || readonly || writeonly;
}
bool bufferReferenceNeedsVulkanMemoryModel() const
{
#ifdef GLSLANG_WEB
return false;
#else
// include qualifiers that map to load/store availability/visibility/nonprivate memory access operands
return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || nonprivate;
#endif
}
#ifdef GLSLANG_WEB
bool bufferReferenceNeedsVulkanMemoryModel() const { return false; }
bool isInterpolation() const
{
#ifndef GLSLANG_WEB
return flat || smooth || nopersp || explicitInterp;
#else
return flat || smooth;
#endif
}
#ifndef GLSLANG_WEB
bool isExplicitInterpolation() const { return false; }
bool isAuxiliary() const { return centroid; }
bool isNoContraction() const { return false; }
#else
bool bufferReferenceNeedsVulkanMemoryModel() const
{
// include qualifiers that map to load/store availability/visibility/nonprivate memory access operands
return subgroupcoherent || workgroupcoherent || queuefamilycoherent || devicecoherent || coherent || nonprivate;
}
bool isInterpolation() const
{
return flat || smooth || nopersp || explicitInterp;
}
bool isExplicitInterpolation() const
{
return explicitInterp;
}
#endif
bool isAuxiliary() const
{
#ifndef GLSLANG_WEB
return centroid || patch || sample || pervertexNV;
#else
return centroid;
#endif
}
bool isNoContraction() const { return noContraction; }
#endif
bool isPipeInput() const
{

View file

@ -1299,10 +1299,17 @@ public:
bool isConstructor() const;
bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; }
bool isSampling() const { return op > EOpSamplingGuardBegin && op < EOpSamplingGuardEnd; }
#ifdef GLSLANG_WEB
bool isImage() const { return false; }
bool isSparseTexture() const { return false; }
bool isImageFootprint() const { return false; }
bool isSparseImage() const { return false; }
#else
bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; }
bool isSparseTexture() const { return op > EOpSparseTextureGuardBegin && op < EOpSparseTextureGuardEnd; }
bool isImageFootprint() const { return op > EOpImageFootprintGuardBegin && op < EOpImageFootprintGuardEnd; }
bool isSparseImage() const { return op == EOpSparseImageLoad; }
#endif
void setOperationPrecision(TPrecisionQualifier p) { operationPrecision = p; }
TPrecisionQualifier getOperationPrecision() const { return operationPrecision != EpqNone ?