Web: Remove/rationalize a set of *_EXTENSIONS, using GLSLANG_WEB.
Focus was on the front end (not SPIR-V), minus the grammar. Reduces #ifdef count by around 320 and makes the web build 270K smaller, which is about 90% the target size. The grammar and scanner will be another step, as will the SPIR-V backend. This makes heavy use of methods #ifdef'd to return false as a global way of turning off code, relying on C++ DCE to do the rest.
This commit is contained in:
parent
e66dace97e
commit
7015bd658e
32 changed files with 2661 additions and 2712 deletions
|
|
@ -441,7 +441,7 @@ spv::Decoration TGlslangToSpvTraverser::TranslateInterpolationDecoration(const g
|
|||
if (qualifier.smooth)
|
||||
// Smooth decoration doesn't exist in SPIR-V 1.0
|
||||
return spv::DecorationMax;
|
||||
else if (qualifier.nopersp)
|
||||
else if (qualifier.isNonPerspective())
|
||||
return spv::DecorationNoPerspective;
|
||||
else if (qualifier.flat)
|
||||
return spv::DecorationFlat;
|
||||
|
|
@ -984,7 +984,7 @@ spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TTy
|
|||
assert(type.getBasicType() == glslang::EbtSampler);
|
||||
|
||||
// Check for capabilities
|
||||
switch (type.getQualifier().layoutFormat) {
|
||||
switch (type.getQualifier().getFormat()) {
|
||||
case glslang::ElfRg32f:
|
||||
case glslang::ElfRg16f:
|
||||
case glslang::ElfR11fG11fB10f:
|
||||
|
|
@ -1021,7 +1021,7 @@ spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TTy
|
|||
}
|
||||
|
||||
// do the translation
|
||||
switch (type.getQualifier().layoutFormat) {
|
||||
switch (type.getQualifier().getFormat()) {
|
||||
case glslang::ElfNone: return spv::ImageFormatUnknown;
|
||||
case glslang::ElfRgba32f: return spv::ImageFormatRgba32f;
|
||||
case glslang::ElfRgba16f: return spv::ImageFormatRgba16f;
|
||||
|
|
@ -1155,7 +1155,7 @@ spv::StorageClass TGlslangToSpvTraverser::TranslateStorageClass(const glslang::T
|
|||
}
|
||||
|
||||
if (type.getQualifier().isUniformOrBuffer()) {
|
||||
if (type.getQualifier().layoutPushConstant)
|
||||
if (type.getQualifier().isPushConstant())
|
||||
return spv::StorageClassPushConstant;
|
||||
if (type.getBasicType() == glslang::EbtBlock)
|
||||
return spv::StorageClassUniform;
|
||||
|
|
@ -1230,10 +1230,8 @@ bool IsDescriptorResource(const glslang::TType& type)
|
|||
// uniform and buffer blocks are included, unless it is a push_constant
|
||||
if (type.getBasicType() == glslang::EbtBlock)
|
||||
return type.getQualifier().isUniformOrBuffer() &&
|
||||
#ifdef NV_EXTENSIONS
|
||||
! type.getQualifier().layoutShaderRecordNV &&
|
||||
#endif
|
||||
! type.getQualifier().layoutPushConstant;
|
||||
! type.getQualifier().isShaderRecordNV() &&
|
||||
! type.getQualifier().isPushConstant();
|
||||
|
||||
// non block...
|
||||
// basically samplerXXX/subpass/sampler/texture are all included
|
||||
|
|
@ -1253,9 +1251,9 @@ void InheritQualifiers(glslang::TQualifier& child, const glslang::TQualifier& pa
|
|||
|
||||
if (parent.invariant)
|
||||
child.invariant = true;
|
||||
#ifndef GLSLANG_WEB
|
||||
if (parent.nopersp)
|
||||
child.nopersp = true;
|
||||
#ifdef AMD_EXTENSIONS
|
||||
if (parent.explicitInterp)
|
||||
child.explicitInterp = true;
|
||||
#endif
|
||||
|
|
@ -1802,7 +1800,7 @@ bool TGlslangToSpvTraverser::visitBinary(glslang::TVisit /* visit */, glslang::T
|
|||
// Load through a block reference is performed with a dot operator that
|
||||
// is mapped to EOpIndexDirectStruct. When we get to the actual reference,
|
||||
// do a load and reset the access chain.
|
||||
if (node->getLeft()->getBasicType() == glslang::EbtReference &&
|
||||
if (node->getLeft()->isReference() &&
|
||||
!node->getLeft()->getType().isArray() &&
|
||||
node->getOp() == glslang::EOpIndexDirectStruct)
|
||||
{
|
||||
|
|
@ -3560,7 +3558,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangStructToSpvType(const glslang::TTy
|
|||
|
||||
// Make forward pointers for any pointer members, and create a list of members to
|
||||
// convert to spirv types after creating the struct.
|
||||
if (glslangMember.getBasicType() == glslang::EbtReference) {
|
||||
if (glslangMember.isReference()) {
|
||||
if (forwardPointers.find(glslangMember.getReferentType()) == forwardPointers.end()) {
|
||||
deferredForwardPointers.push_back(std::make_pair(&glslangMember, memberQualifier));
|
||||
}
|
||||
|
|
@ -4093,7 +4091,7 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
|||
if (paramPrecision != spv::NoPrecision)
|
||||
decorations.push_back(paramPrecision);
|
||||
TranslateMemoryDecoration(type.getQualifier(), decorations, useVulkanMemoryModel);
|
||||
if (type.getBasicType() == glslang::EbtReference) {
|
||||
if (type.isReference()) {
|
||||
// Original and non-writable params pass the pointer directly and
|
||||
// use restrict/aliased, others are stored to a pointer in Function
|
||||
// memory and use RestrictPointer/AliasedPointer.
|
||||
|
|
@ -7741,6 +7739,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
|
|||
}
|
||||
if (symbol->getQualifier().hasAttachment())
|
||||
builder.addDecoration(id, spv::DecorationInputAttachmentIndex, symbol->getQualifier().layoutAttachment);
|
||||
#ifndef GLSLANG_WEB
|
||||
if (glslangIntermediate->getXfbMode()) {
|
||||
builder.addCapability(spv::CapabilityTransformFeedback);
|
||||
if (symbol->getQualifier().hasXfbBuffer()) {
|
||||
|
|
@ -7752,6 +7751,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
|
|||
if (symbol->getQualifier().hasXfbOffset())
|
||||
builder.addDecoration(id, spv::DecorationOffset, symbol->getQualifier().layoutXfbOffset);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (symbol->getType().isImage()) {
|
||||
std::vector<spv::Decoration> memory;
|
||||
|
|
@ -7815,7 +7815,7 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
|
|||
symbol->getType().getQualifier().semanticName);
|
||||
}
|
||||
|
||||
if (symbol->getBasicType() == glslang::EbtReference) {
|
||||
if (symbol->isReference()) {
|
||||
builder.addDecoration(id, symbol->getType().getQualifier().restrict ? spv::DecorationRestrictPointerEXT : spv::DecorationAliasedPointerEXT);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,12 +50,8 @@ namespace spv {
|
|||
// Include C-based headers that don't have a namespace
|
||||
#include "GLSL.ext.KHR.h"
|
||||
#include "GLSL.ext.EXT.h"
|
||||
#ifdef AMD_EXTENSIONS
|
||||
#include "GLSL.ext.AMD.h"
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
#include "GLSL.ext.NV.h"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -98,22 +94,17 @@ const char* ExecutionModelString(int model)
|
|||
case 4: return "Fragment";
|
||||
case 5: return "GLCompute";
|
||||
case 6: return "Kernel";
|
||||
#ifdef NV_EXTENSIONS
|
||||
case ExecutionModelTaskNV: return "TaskNV";
|
||||
case ExecutionModelMeshNV: return "MeshNV";
|
||||
#endif
|
||||
|
||||
default: return "Bad";
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case ExecutionModelRayGenerationNV: return "RayGenerationNV";
|
||||
case ExecutionModelIntersectionNV: return "IntersectionNV";
|
||||
case ExecutionModelAnyHitNV: return "AnyHitNV";
|
||||
case ExecutionModelClosestHitNV: return "ClosestHitNV";
|
||||
case ExecutionModelMissNV: return "MissNV";
|
||||
case ExecutionModelCallableNV: return "CallableNV";
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,13 +174,11 @@ const char* ExecutionModeString(int mode)
|
|||
|
||||
case 4446: return "PostDepthCoverage";
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case ExecutionModeOutputLinesNV: return "OutputLinesNV";
|
||||
case ExecutionModeOutputPrimitivesNV: return "OutputPrimitivesNV";
|
||||
case ExecutionModeOutputTrianglesNV: return "OutputTrianglesNV";
|
||||
case ExecutionModeDerivativeGroupQuadsNV: return "DerivativeGroupQuadsNV";
|
||||
case ExecutionModeDerivativeGroupLinearNV: return "DerivativeGroupLinearNV";
|
||||
#endif
|
||||
|
||||
case ExecutionModePixelInterlockOrderedEXT: return "PixelInterlockOrderedEXT";
|
||||
case ExecutionModePixelInterlockUnorderedEXT: return "PixelInterlockUnorderedEXT";
|
||||
|
|
@ -220,14 +209,12 @@ const char* StorageClassString(int StorageClass)
|
|||
case 11: return "Image";
|
||||
case 12: return "StorageBuffer";
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case StorageClassRayPayloadNV: return "RayPayloadNV";
|
||||
case StorageClassHitAttributeNV: return "HitAttributeNV";
|
||||
case StorageClassIncomingRayPayloadNV: return "IncomingRayPayloadNV";
|
||||
case StorageClassShaderRecordBufferNV: return "ShaderRecordBufferNV";
|
||||
case StorageClassCallableDataNV: return "CallableDataNV";
|
||||
case StorageClassIncomingCallableDataNV: return "IncomingCallableDataNV";
|
||||
#endif
|
||||
|
||||
case StorageClassPhysicalStorageBufferEXT: return "PhysicalStorageBufferEXT";
|
||||
|
||||
|
|
@ -289,10 +276,7 @@ const char* DecorationString(int decoration)
|
|||
case DecorationCeiling:
|
||||
default: return "Bad";
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case DecorationExplicitInterpAMD: return "ExplicitInterpAMD";
|
||||
#endif
|
||||
#ifdef NV_EXTENSIONS
|
||||
case DecorationOverrideCoverageNV: return "OverrideCoverageNV";
|
||||
case DecorationPassthroughNV: return "PassthroughNV";
|
||||
case DecorationViewportRelativeNV: return "ViewportRelativeNV";
|
||||
|
|
@ -301,7 +285,6 @@ const char* DecorationString(int decoration)
|
|||
case DecorationPerViewNV: return "PerViewNV";
|
||||
case DecorationPerTaskNV: return "PerTaskNV";
|
||||
case DecorationPerVertexNV: return "PerVertexNV";
|
||||
#endif
|
||||
|
||||
case DecorationNonUniformEXT: return "DecorationNonUniformEXT";
|
||||
case DecorationHlslCounterBufferGOOGLE: return "DecorationHlslCounterBufferGOOGLE";
|
||||
|
|
@ -371,7 +354,6 @@ const char* BuiltInString(int builtIn)
|
|||
case 4426: return "DrawIndex";
|
||||
case 5014: return "FragStencilRefEXT";
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case 4992: return "BaryCoordNoPerspAMD";
|
||||
case 4993: return "BaryCoordNoPerspCentroidAMD";
|
||||
case 4994: return "BaryCoordNoPerspSampleAMD";
|
||||
|
|
@ -379,9 +361,6 @@ const char* BuiltInString(int builtIn)
|
|||
case 4996: return "BaryCoordSmoothCentroidAMD";
|
||||
case 4997: return "BaryCoordSmoothSampleAMD";
|
||||
case 4998: return "BaryCoordPullModelAMD";
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case BuiltInLaunchIdNV: return "LaunchIdNV";
|
||||
case BuiltInLaunchSizeNV: return "LaunchSizeNV";
|
||||
case BuiltInWorldRayOriginNV: return "WorldRayOriginNV";
|
||||
|
|
@ -405,14 +384,12 @@ const char* BuiltInString(int builtIn)
|
|||
// case BuiltInInvocationsPerPixelNV: return "InvocationsPerPixelNV"; // superseded by BuiltInFragInvocationCountEXT
|
||||
case BuiltInBaryCoordNV: return "BaryCoordNV";
|
||||
case BuiltInBaryCoordNoPerspNV: return "BaryCoordNoPerspNV";
|
||||
#endif
|
||||
|
||||
case BuiltInFragSizeEXT: return "FragSizeEXT";
|
||||
case BuiltInFragInvocationCountEXT: return "FragInvocationCountEXT";
|
||||
|
||||
case 5264: return "FullyCoveredEXT";
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case BuiltInTaskCountNV: return "TaskCountNV";
|
||||
case BuiltInPrimitiveCountNV: return "PrimitiveCountNV";
|
||||
case BuiltInPrimitiveIndicesNV: return "PrimitiveIndicesNV";
|
||||
|
|
@ -421,7 +398,6 @@ const char* BuiltInString(int builtIn)
|
|||
case BuiltInLayerPerViewNV: return "LayerPerViewNV";
|
||||
case BuiltInMeshViewCountNV: return "MeshViewCountNV";
|
||||
case BuiltInMeshViewIndicesNV: return "MeshViewIndicesNV";
|
||||
#endif
|
||||
case BuiltInWarpsPerSMNV: return "WarpsPerSMNV";
|
||||
case BuiltInSMCountNV: return "SMCountNV";
|
||||
case BuiltInWarpIDNV: return "WarpIDNV";
|
||||
|
|
@ -780,11 +756,9 @@ const char* GroupOperationString(int gop)
|
|||
case GroupOperationInclusiveScan: return "InclusiveScan";
|
||||
case GroupOperationExclusiveScan: return "ExclusiveScan";
|
||||
case GroupOperationClusteredReduce: return "ClusteredReduce";
|
||||
#ifdef NV_EXTENSIONS
|
||||
case GroupOperationPartitionedReduceNV: return "PartitionedReduceNV";
|
||||
case GroupOperationPartitionedInclusiveScanNV: return "PartitionedInclusiveScanNV";
|
||||
case GroupOperationPartitionedExclusiveScanNV: return "PartitionedExclusiveScanNV";
|
||||
#endif
|
||||
|
||||
default: return "Bad";
|
||||
}
|
||||
|
|
@ -901,17 +875,14 @@ const char* CapabilityString(int info)
|
|||
|
||||
case CapabilityStencilExportEXT: return "StencilExportEXT";
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case CapabilityFloat16ImageAMD: return "Float16ImageAMD";
|
||||
case CapabilityImageGatherBiasLodAMD: return "ImageGatherBiasLodAMD";
|
||||
case CapabilityFragmentMaskAMD: return "FragmentMaskAMD";
|
||||
case CapabilityImageReadWriteLodAMD: return "ImageReadWriteLodAMD";
|
||||
#endif
|
||||
|
||||
case CapabilityAtomicStorageOps: return "AtomicStorageOps";
|
||||
|
||||
case CapabilitySampleMaskPostDepthCoverage: return "SampleMaskPostDepthCoverage";
|
||||
#ifdef NV_EXTENSIONS
|
||||
case CapabilityGeometryShaderPassthroughNV: return "GeometryShaderPassthroughNV";
|
||||
case CapabilityShaderViewportIndexLayerNV: return "ShaderViewportIndexLayerNV";
|
||||
case CapabilityShaderViewportMaskNV: return "ShaderViewportMaskNV";
|
||||
|
|
@ -926,7 +897,6 @@ const char* CapabilityString(int info)
|
|||
case CapabilityImageFootprintNV: return "ImageFootprintNV";
|
||||
// case CapabilityShadingRateNV: return "ShadingRateNV"; // superseded by FragmentDensityEXT
|
||||
case CapabilitySampleMaskOverrideCoverageNV: return "SampleMaskOverrideCoverageNV";
|
||||
#endif
|
||||
case CapabilityFragmentDensityEXT: return "FragmentDensityEXT";
|
||||
|
||||
case CapabilityFragmentFullyCoveredEXT: return "FragmentFullyCoveredEXT";
|
||||
|
|
@ -1336,7 +1306,6 @@ const char* OpcodeString(int op)
|
|||
case 4430: return "OpSubgroupAllEqualKHR";
|
||||
case 4432: return "OpSubgroupReadInvocationKHR";
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
case 5000: return "OpGroupIAddNonUniformAMD";
|
||||
case 5001: return "OpGroupFAddNonUniformAMD";
|
||||
case 5002: return "OpGroupFMinNonUniformAMD";
|
||||
|
|
@ -1348,14 +1317,12 @@ const char* OpcodeString(int op)
|
|||
|
||||
case 5011: return "OpFragmentMaskFetchAMD";
|
||||
case 5012: return "OpFragmentFetchAMD";
|
||||
#endif
|
||||
|
||||
case OpReadClockKHR: return "OpReadClockKHR";
|
||||
|
||||
case OpDecorateStringGOOGLE: return "OpDecorateStringGOOGLE";
|
||||
case OpMemberDecorateStringGOOGLE: return "OpMemberDecorateStringGOOGLE";
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
case OpGroupNonUniformPartitionNV: return "OpGroupNonUniformPartitionNV";
|
||||
case OpReportIntersectionNV: return "OpReportIntersectionNV";
|
||||
case OpIgnoreIntersectionNV: return "OpIgnoreIntersectionNV";
|
||||
|
|
@ -1365,7 +1332,6 @@ const char* OpcodeString(int op)
|
|||
case OpExecuteCallableNV: return "OpExecuteCallableNV";
|
||||
case OpImageSampleFootprintNV: return "OpImageSampleFootprintNV";
|
||||
case OpWritePackedPrimitiveIndices4x8NV: return "OpWritePackedPrimitiveIndices4x8NV";
|
||||
#endif
|
||||
|
||||
case OpTypeCooperativeMatrixNV: return "OpTypeCooperativeMatrixNV";
|
||||
case OpCooperativeMatrixLoadNV: return "OpCooperativeMatrixLoadNV";
|
||||
|
|
@ -2685,7 +2651,6 @@ void Parameterize()
|
|||
|
||||
InstructionDesc[OpModuleProcessed].operands.push(OperandLiteralString, "'process'");
|
||||
|
||||
#ifdef AMD_EXTENSIONS
|
||||
InstructionDesc[OpGroupIAddNonUniformAMD].operands.push(OperandScope, "'Execution'");
|
||||
InstructionDesc[OpGroupIAddNonUniformAMD].operands.push(OperandGroupOperation, "'Operation'");
|
||||
InstructionDesc[OpGroupIAddNonUniformAMD].operands.push(OperandId, "'X'");
|
||||
|
|
@ -2724,9 +2689,7 @@ void Parameterize()
|
|||
InstructionDesc[OpFragmentFetchAMD].operands.push(OperandId, "'Image'");
|
||||
InstructionDesc[OpFragmentFetchAMD].operands.push(OperandId, "'Coordinate'");
|
||||
InstructionDesc[OpFragmentFetchAMD].operands.push(OperandId, "'Fragment Index'");
|
||||
#endif
|
||||
|
||||
#ifdef NV_EXTENSIONS
|
||||
InstructionDesc[OpGroupNonUniformPartitionNV].operands.push(OperandId, "X");
|
||||
|
||||
InstructionDesc[OpTypeAccelerationStructureNV].setResultAndType(true, false);
|
||||
|
|
@ -2764,7 +2727,6 @@ void Parameterize()
|
|||
|
||||
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Index Offset'");
|
||||
InstructionDesc[OpWritePackedPrimitiveIndices4x8NV].operands.push(OperandId, "'Packed Indices'");
|
||||
#endif
|
||||
|
||||
InstructionDesc[OpTypeCooperativeMatrixNV].operands.push(OperandId, "'Component Type'");
|
||||
InstructionDesc[OpTypeCooperativeMatrixNV].operands.push(OperandId, "'Scope'");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue