From 81639827d5d7426c64ea33950db412a8ecf95d67 Mon Sep 17 00:00:00 2001 From: John Kessenich Date: Wed, 19 Aug 2015 10:46:52 -0600 Subject: [PATCH] More preparation for pure built-in functions as enums: Add texturing op cracker. --- glslang/Include/intermediate.h | 113 +++++++++++++++++++++++++++++++-- glslang/Include/revision.h | 4 +- 2 files changed, 111 insertions(+), 6 deletions(-) diff --git a/glslang/Include/intermediate.h b/glslang/Include/intermediate.h index c613cc13..35092967 100644 --- a/glslang/Include/intermediate.h +++ b/glslang/Include/intermediate.h @@ -350,8 +350,7 @@ enum TOperator { // Image operations // - // N.B. The following is not being used yet, pending input, as switching - // to it from the current text-based approach will break existing consumers. + EOpImageGuardBegin, EOpImageQuerySize, EOpImageQuerySamples, @@ -366,11 +365,14 @@ enum TOperator { EOpImageAtomicExchange, EOpImageAtomicCompSwap, + EOpImageGuardEnd, + // // Texture operations // EOpTextureGuardBegin, + EOpTextureQuerySize, EOpTextureQueryLod, EOpTextureQueryLevels, @@ -392,6 +394,7 @@ enum TOperator { EOpTextureGather, EOpTextureGatherOffset, EOpTextureGatherOffsets, + EOpTextureGuardEnd, // @@ -605,6 +608,18 @@ protected: bool literal; // true if node represents a literal in the source code }; +// Represent the independent aspects of a texturing TOperator +struct TCrackedTextureOp { + bool query; + bool proj; + bool lod; + bool fetch; + bool offset; + bool offsets; + bool gather; + bool grad; +}; + // // Intermediate class for node types that hold operators. // @@ -613,9 +628,98 @@ public: virtual TIntermOperator* getAsOperator() { return this; } virtual const TIntermOperator* getAsOperator() const { return this; } TOperator getOp() const { return op; } + virtual bool promote() { return true; } bool modifiesState() const; bool isConstructor() const; - virtual bool promote() { return true; } + bool isTexture() const { return op > EOpTextureGuardBegin && op < EOpTextureGuardEnd; } + bool isImage() const { return op > EOpImageGuardBegin && op < EOpImageGuardEnd; } + + // Crack the op into the individual dimensions of texturing operation. + void crackTexture(TCrackedTextureOp& cracked) const + { + cracked.query = false; + cracked.proj = false; + cracked.lod = false; + cracked.fetch = false; + cracked.offset = false; + cracked.offsets = false; + cracked.gather = false; + cracked.grad = false; + + switch (op) { + case EOpTextureQuerySize: + case EOpTextureQueryLod: + case EOpTextureQueryLevels: + case EOpTextureQuerySamples: + cracked.query = true; + break; + case EOpTexture: + break; + case EOpTextureProj: + cracked.proj = true; + break; + case EOpTextureLod: + cracked.lod = true; + break; + case EOpTextureOffset: + cracked.offset = true; + break; + case EOpTextureFetch: + cracked.fetch = true; + break; + case EOpTextureFetchOffset: + cracked.fetch = true; + cracked.offset = true; + break; + case EOpTextureProjOffset: + cracked.offset = true; + cracked.proj = true; + break; + case EOpTextureLodOffset: + cracked.offset = true; + cracked.lod = true; + break; + case EOpTextureProjLod: + cracked.lod = true; + cracked.proj = true; + break; + case EOpTextureProjLodOffset: + cracked.offset = true; + cracked.lod = true; + cracked.proj = true; + break; + case EOpTextureGrad: + cracked.grad = true; + break; + case EOpTextureGradOffset: + cracked.grad = true; + cracked.offset = true; + break; + case EOpTextureProjGrad: + cracked.grad = true; + cracked.proj = true; + break; + case EOpTextureProjGradOffset: + cracked.grad = true; + cracked.offset = true; + cracked.proj = true; + break; + case EOpTextureGather: + cracked.gather = true; + break; + case EOpTextureGatherOffset: + cracked.gather = true; + cracked.offset = true; + break; + case EOpTextureGatherOffsets: + cracked.gather = true; + cracked.offsets = true; + break; + default: + break; + } + } + protected: TIntermOperator(TOperator o) : TIntermTyped(EbtFloat), op(o) {} TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {} @@ -651,7 +755,8 @@ public: TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {} virtual void traverse(TIntermTraverser*); virtual void setOperand(TIntermTyped* o) { operand = o; } - virtual TIntermTyped* getOperand() { return operand; } + virtual TIntermTyped* getOperand() { return operand; } + virtual const TIntermTyped* getOperand() const { return operand; } virtual TIntermUnary* getAsUnaryNode() { return this; } virtual const TIntermUnary* getAsUnaryNode() const { return this; } virtual bool promote(); diff --git a/glslang/Include/revision.h b/glslang/Include/revision.h index 90784856..c1945ee6 100644 --- a/glslang/Include/revision.h +++ b/glslang/Include/revision.h @@ -2,5 +2,5 @@ // For the version, it uses the latest git tag followed by the number of commits. // For the date, it uses the current date (when then script is run). -#define GLSLANG_REVISION "2.3.725" -#define GLSLANG_DATE "18-Aug-2015" +#define GLSLANG_REVISION "2.3.726" +#define GLSLANG_DATE "19-Aug-2015"