summaryrefslogtreecommitdiff
path: root/thirdparty/glslang/glslang/MachineIndependent/localintermediate.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/glslang/glslang/MachineIndependent/localintermediate.h')
-rw-r--r--thirdparty/glslang/glslang/MachineIndependent/localintermediate.h145
1 files changed, 98 insertions, 47 deletions
diff --git a/thirdparty/glslang/glslang/MachineIndependent/localintermediate.h b/thirdparty/glslang/glslang/MachineIndependent/localintermediate.h
index 683290af74..3cdc1f10cf 100644
--- a/thirdparty/glslang/glslang/MachineIndependent/localintermediate.h
+++ b/thirdparty/glslang/glslang/MachineIndependent/localintermediate.h
@@ -162,7 +162,10 @@ struct TXfbBuffer {
#endif
// Track a set of strings describing how the module was processed.
-// Using the form:
+// This includes command line options, transforms, etc., ideally inclusive enough
+// to reproduce the steps used to transform the input source to the output.
+// E.g., see SPIR-V OpModuleProcessed.
+// Each "process" or "transform" uses is expressed in the form:
// process arg0 arg1 arg2 ...
// process arg0 arg1 arg2 ...
// where everything is textual, and there can be zero or more arguments
@@ -222,6 +225,40 @@ enum ComputeDerivativeMode {
LayoutDerivativeGroupLinear, // derivative_group_linearNV
};
+class TIdMaps {
+public:
+ TMap<TString, int>& operator[](int i) { return maps[i]; }
+ const TMap<TString, int>& operator[](int i) const { return maps[i]; }
+private:
+ TMap<TString, int> maps[EsiCount];
+};
+
+class TNumericFeatures {
+public:
+ TNumericFeatures() : features(0) { }
+ TNumericFeatures(const TNumericFeatures&) = delete;
+ TNumericFeatures& operator=(const TNumericFeatures&) = delete;
+ typedef enum : unsigned int {
+ shader_explicit_arithmetic_types = 1 << 0,
+ shader_explicit_arithmetic_types_int8 = 1 << 1,
+ shader_explicit_arithmetic_types_int16 = 1 << 2,
+ shader_explicit_arithmetic_types_int32 = 1 << 3,
+ shader_explicit_arithmetic_types_int64 = 1 << 4,
+ shader_explicit_arithmetic_types_float16 = 1 << 5,
+ shader_explicit_arithmetic_types_float32 = 1 << 6,
+ shader_explicit_arithmetic_types_float64 = 1 << 7,
+ shader_implicit_conversions = 1 << 8,
+ gpu_shader_fp64 = 1 << 9,
+ gpu_shader_int16 = 1 << 10,
+ gpu_shader_half_float = 1 << 11,
+ } feature;
+ void insert(feature f) { features |= f; }
+ void erase(feature f) { features &= ~f; }
+ bool contains(feature f) const { return (features & f) != 0; }
+private:
+ unsigned int features;
+};
+
//
// Set of helper functions to help parse and build the tree.
//
@@ -229,7 +266,10 @@ class TIntermediate {
public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
language(l),
- profile(p), version(v), treeRoot(0),
+#ifndef GLSLANG_ANGLE
+ profile(p), version(v),
+#endif
+ treeRoot(0),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invertY(false),
useStorageBuffer(false),
@@ -244,15 +284,16 @@ public:
inputPrimitive(ElgNone), outputPrimitive(ElgNone),
pixelCenterInteger(false), originUpperLeft(false),
vertexSpacing(EvsNone), vertexOrder(EvoNone), interlockOrdering(EioNone), pointMode(false), earlyFragmentTests(false),
- postDepthCoverage(false), depthLayout(EldNone),
+ postDepthCoverage(false), depthLayout(EldNone),
hlslFunctionality1(false),
blendEquations(0), xfbMode(false), multiStream(false),
layoutOverrideCoverage(false),
geoPassthroughEXT(false),
- numShaderRecordNVBlocks(0),
+ numShaderRecordBlocks(0),
computeDerivativeMode(LayoutDerivativeNone),
primitives(TQualifier::layoutNotSet),
numTaskNVBlocks(0),
+ layoutPrimitiveCulling(false),
autoMapBindings(false),
autoMapLocations(false),
flattenUniformArrays(false),
@@ -282,9 +323,20 @@ public:
#endif
}
- void setVersion(int v) { version = v; }
+ void setVersion(int v)
+ {
+#ifndef GLSLANG_ANGLE
+ version = v;
+#endif
+ }
+ void setProfile(EProfile p)
+ {
+#ifndef GLSLANG_ANGLE
+ profile = p;
+#endif
+ }
+
int getVersion() const { return version; }
- void setProfile(EProfile p) { profile = p; }
EProfile getProfile() const { return profile; }
void setSpv(const SpvVersion& s)
{
@@ -380,7 +432,7 @@ public:
void setSource(EShSource s) { source = s; }
EShSource getSource() const { return source; }
#else
- void setSource(EShSource s) { assert(s == EShSourceGlsl); }
+ void setSource(EShSource s) { assert(s == EShSourceGlsl); (void)s; }
EShSource getSource() const { return EShSourceGlsl; }
#endif
@@ -391,15 +443,15 @@ public:
TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
TIntermSymbol* addSymbol(const TIntermSymbol&);
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
- std::tuple<TIntermTyped*, TIntermTyped*> addConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1);
+ std::tuple<TIntermTyped*, TIntermTyped*> addPairConversion(TOperator op, TIntermTyped* node0, TIntermTyped* node1);
TIntermTyped* addUniShapeConversion(TOperator, const TType&, TIntermTyped*);
TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
- TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
- TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
- TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
- TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, TSourceLoc);
+ TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
+ TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
+ TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
+ TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, const TSourceLoc&);
TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType);
bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const;
bool isIntegralPromotion(TBasicType from, TBasicType to) const;
@@ -413,7 +465,7 @@ public:
TIntermAggregate* makeAggregate(TIntermNode* node);
TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
TIntermAggregate* makeAggregate(const TSourceLoc&);
- TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, TSourceLoc);
+ TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, const TSourceLoc&);
bool areAllChildConst(TIntermAggregate* aggrNode);
TIntermSelection* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
@@ -442,10 +494,11 @@ public:
// Low level functions to add nodes (no conversions or other higher level transformations)
// If a type is provided, the node's type will be set to it.
- TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc) const;
- TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, const TType&) const;
- TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc) const;
- TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc, const TType&) const;
+ TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&) const;
+ TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&,
+ const TType&) const;
+ TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&) const;
+ TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&, const TType&) const;
// Constant folding (in Constant.cpp)
TIntermTyped* fold(TIntermAggregate* aggrNode);
@@ -460,11 +513,7 @@ public:
void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&);
void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&);
- void setUseStorageBuffer()
- {
- useStorageBuffer = true;
- processes.addProcess("use-storage-buffer");
- }
+ void setUseStorageBuffer() { useStorageBuffer = true; }
bool usingStorageBuffer() const { return useStorageBuffer; }
void setDepthReplacing() { depthReplacing = true; }
bool isDepthReplacing() const { return depthReplacing; }
@@ -503,7 +552,7 @@ public:
bool getAutoMapBindings() const { return false; }
bool getAutoMapLocations() const { return false; }
int getNumPushConstants() const { return 0; }
- void addShaderRecordNVCount() { }
+ void addShaderRecordCount() { }
void addTaskNVCount() { }
void setUseVulkanMemoryModel() { }
bool usingVulkanMemoryModel() const { return false; }
@@ -583,7 +632,7 @@ public:
processes.addProcess("flatten-uniform-arrays");
}
bool getFlattenUniformArrays() const { return flattenUniformArrays; }
-#endif
+#endif
void setNoStorageFormat(bool b)
{
useUnknownFormat = b;
@@ -620,7 +669,7 @@ public:
void setTextureSamplerTransformMode(EShTextureSamplerTransformMode mode) { textureSamplerTransformMode = mode; }
int getNumPushConstants() const { return numPushConstants; }
- void addShaderRecordNVCount() { ++numShaderRecordNVBlocks; }
+ void addShaderRecordCount() { ++numShaderRecordBlocks; }
void addTaskNVCount() { ++numTaskNVBlocks; }
bool setInvocations(int i)
@@ -723,6 +772,8 @@ public:
void setLayoutDerivativeMode(ComputeDerivativeMode mode) { computeDerivativeMode = mode; }
bool hasLayoutDerivativeModeNone() const { return computeDerivativeMode != LayoutDerivativeNone; }
ComputeDerivativeMode getLayoutDerivativeModeNone() const { return computeDerivativeMode; }
+ void setLayoutPrimitiveCulling() { layoutPrimitiveCulling = true; }
+ bool getLayoutPrimitiveCulling() const { return layoutPrimitiveCulling; }
bool setPrimitives(int m)
{
if (primitives != TQualifier::layoutNotSet)
@@ -834,22 +885,25 @@ public:
bool getArithemeticInt8Enabled() const { return false; }
bool getArithemeticInt16Enabled() const { return false; }
bool getArithemeticFloat16Enabled() const { return false; }
+ void updateNumericFeature(TNumericFeatures::feature f, bool on) { }
#else
bool getArithemeticInt8Enabled() const {
- return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
- extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int8);
+ return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+ numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int8);
}
bool getArithemeticInt16Enabled() const {
- return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
- extensionRequested(E_GL_AMD_gpu_shader_int16) ||
- extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_int16);
+ return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+ numericFeatures.contains(TNumericFeatures::gpu_shader_int16) ||
+ numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_int16);
}
bool getArithemeticFloat16Enabled() const {
- return extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types) ||
- extensionRequested(E_GL_AMD_gpu_shader_half_float) ||
- extensionRequested(E_GL_EXT_shader_explicit_arithmetic_types_float16);
+ return numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types) ||
+ numericFeatures.contains(TNumericFeatures::gpu_shader_half_float) ||
+ numericFeatures.contains(TNumericFeatures::shader_explicit_arithmetic_types_float16);
}
+ void updateNumericFeature(TNumericFeatures::feature f, bool on)
+ { on ? numericFeatures.insert(f) : numericFeatures.erase(f); }
#endif
protected:
@@ -859,8 +913,8 @@ protected:
void mergeCallGraphs(TInfoSink&, TIntermediate&);
void mergeModes(TInfoSink&, TIntermediate&);
void mergeTrees(TInfoSink&, TIntermediate&);
- void seedIdMap(TMap<TString, int>& idMap, int& maxId);
- void remapIds(const TMap<TString, int>& idMap, int idShift, TIntermediate&);
+ void seedIdMap(TIdMaps& idMaps, int& maxId);
+ void remapIds(const TIdMaps& idMaps, int idShift, TIntermediate&);
void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals);
void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects);
void mergeImplicitArraySizes(TType&, const TType&);
@@ -881,17 +935,7 @@ protected:
bool specConstantPropagates(const TIntermTyped&, const TIntermTyped&);
void performTextureUpgradeAndSamplerRemovalTransformation(TIntermNode* root);
bool isConversionAllowed(TOperator op, TIntermTyped* node) const;
- std::tuple<TBasicType, TBasicType> getConversionDestinatonType(TBasicType type0, TBasicType type1, TOperator op) const;
-
- // JohnK: I think this function should go away.
- // This data structure is just a log to pass on to back ends.
- // Versioning and extensions are handled in Version.cpp, with a rich
- // set of functions for querying stages, versions, extension enable/disabled, etc.
-#ifdef GLSLANG_WEB
- bool extensionRequested(const char *extension) const { return false; }
-#else
- bool extensionRequested(const char *extension) const {return requestedExtensions.find(extension) != requestedExtensions.end();}
-#endif
+ std::tuple<TBasicType, TBasicType> getConversionDestinationType(TBasicType type0, TBasicType type1, TOperator op) const;
static const char* getResourceName(TResourceType);
@@ -901,8 +945,13 @@ protected:
typedef std::list<TCall> TGraph;
TGraph callGraph;
+#ifdef GLSLANG_ANGLE
+ const EProfile profile = ECoreProfile;
+ const int version = 450;
+#else
EProfile profile; // source profile
int version; // source version
+#endif
SpvVersion spvVersion;
TIntermNode* treeRoot;
std::set<std::string> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
@@ -945,10 +994,11 @@ protected:
bool multiStream;
bool layoutOverrideCoverage;
bool geoPassthroughEXT;
- int numShaderRecordNVBlocks;
+ int numShaderRecordBlocks;
ComputeDerivativeMode computeDerivativeMode;
int primitives;
int numTaskNVBlocks;
+ bool layoutPrimitiveCulling;
// Base shift values
std::array<unsigned int, EResCount> shiftBinding;
@@ -975,6 +1025,7 @@ protected:
std::unordered_map<std::string, int> uniformLocationOverrides;
int uniformLocationBase;
+ TNumericFeatures numericFeatures;
#endif
std::unordered_set<int> usedConstantId; // specialization constant ids used