Unify constant floats and constant doubles; they can all be constant doubles.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21921 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
.rsample.frag
|
sample.frag
|
||||||
sample.vert
|
sample.vert
|
||||||
specExamples.frag
|
specExamples.frag
|
||||||
specExamples.vert
|
specExamples.vert
|
||||||
|
|||||||
@@ -42,20 +42,32 @@ class constUnion {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
|
||||||
void setIConst(int i) {iConst = i; type = EbtInt; }
|
void setIConst(int i)
|
||||||
void setUConst(unsigned int u) {uConst = u; type = EbtUint; }
|
{
|
||||||
void setFConst(float f) {fConst = f; type = EbtFloat; }
|
iConst = i;
|
||||||
void setDConst(double d) {dConst = d; type = EbtDouble; }
|
type = EbtInt;
|
||||||
void setBConst(bool b) {bConst = b; type = EbtBool; }
|
}
|
||||||
|
|
||||||
|
void setUConst(unsigned int u)
|
||||||
|
{
|
||||||
|
uConst = u;
|
||||||
|
type = EbtUint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setDConst(double d)
|
||||||
|
{
|
||||||
|
dConst = d;
|
||||||
|
type = EbtDouble;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBConst(bool b)
|
||||||
|
{
|
||||||
|
bConst = b;
|
||||||
|
type = EbtBool;
|
||||||
|
}
|
||||||
|
|
||||||
int getIConst() { return iConst; }
|
|
||||||
unsigned int getUConst() { return uConst; }
|
|
||||||
float getFConst() { return fConst; }
|
|
||||||
double getDConst() { return dConst; }
|
|
||||||
bool getBConst() { return bConst; }
|
|
||||||
int getIConst() const { return iConst; }
|
int getIConst() const { return iConst; }
|
||||||
unsigned int getUConst() const { return uConst; }
|
unsigned int getUConst() const { return uConst; }
|
||||||
float getFConst() const { return fConst; }
|
|
||||||
double getDConst() const { return dConst; }
|
double getDConst() const { return dConst; }
|
||||||
bool getBConst() const { return bConst; }
|
bool getBConst() const { return bConst; }
|
||||||
|
|
||||||
@@ -75,14 +87,6 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const float f) const
|
|
||||||
{
|
|
||||||
if (f == fConst)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const double d) const
|
bool operator==(const double d) const
|
||||||
{
|
{
|
||||||
if (d == dConst)
|
if (d == dConst)
|
||||||
@@ -114,11 +118,6 @@ public:
|
|||||||
if (constant.uConst == uConst)
|
if (constant.uConst == uConst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
break;
|
|
||||||
case EbtFloat:
|
|
||||||
if (constant.fConst == fConst)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
if (constant.dConst == dConst)
|
if (constant.dConst == dConst)
|
||||||
@@ -175,11 +174,6 @@ public:
|
|||||||
if (uConst > constant.uConst)
|
if (uConst > constant.uConst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
|
||||||
case EbtFloat:
|
|
||||||
if (fConst > constant.fConst)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
if (dConst > constant.dConst)
|
if (dConst > constant.dConst)
|
||||||
@@ -207,11 +201,6 @@ public:
|
|||||||
if (uConst < constant.uConst)
|
if (uConst < constant.uConst)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
|
||||||
case EbtFloat:
|
|
||||||
if (fConst < constant.fConst)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
if (dConst < constant.dConst)
|
if (dConst < constant.dConst)
|
||||||
@@ -233,7 +222,6 @@ public:
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
|
||||||
case EbtUint: returnValue.setUConst(uConst + constant.uConst); break;
|
case EbtUint: returnValue.setUConst(uConst + constant.uConst); break;
|
||||||
case EbtFloat: returnValue.setFConst(fConst + constant.fConst); break;
|
|
||||||
case EbtDouble: returnValue.setDConst(dConst + constant.dConst); break;
|
case EbtDouble: returnValue.setDConst(dConst + constant.dConst); break;
|
||||||
default: assert(false && "Default missing");
|
default: assert(false && "Default missing");
|
||||||
}
|
}
|
||||||
@@ -248,7 +236,6 @@ public:
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
|
||||||
case EbtUint: returnValue.setUConst(uConst - constant.uConst); break;
|
case EbtUint: returnValue.setUConst(uConst - constant.uConst); break;
|
||||||
case EbtFloat: returnValue.setFConst(fConst - constant.fConst); break;
|
|
||||||
case EbtDouble: returnValue.setDConst(dConst - constant.dConst); break;
|
case EbtDouble: returnValue.setDConst(dConst - constant.dConst); break;
|
||||||
default: assert(false && "Default missing");
|
default: assert(false && "Default missing");
|
||||||
}
|
}
|
||||||
@@ -263,7 +250,6 @@ public:
|
|||||||
switch (type) {
|
switch (type) {
|
||||||
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
|
||||||
case EbtUint: returnValue.setUConst(uConst * constant.uConst); break;
|
case EbtUint: returnValue.setUConst(uConst * constant.uConst); break;
|
||||||
case EbtFloat: returnValue.setFConst(fConst * constant.fConst); break;
|
|
||||||
case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
|
case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break;
|
||||||
default: assert(false && "Default missing");
|
default: assert(false && "Default missing");
|
||||||
}
|
}
|
||||||
@@ -414,8 +400,7 @@ private:
|
|||||||
int iConst; // used for ivec, scalar ints
|
int iConst; // used for ivec, scalar ints
|
||||||
unsigned int uConst; // used for uvec, scalar uints
|
unsigned int uConst; // used for uvec, scalar uints
|
||||||
bool bConst; // used for bvec, scalar bools
|
bool bConst; // used for bvec, scalar bools
|
||||||
float fConst; // used for vec, mat, scalar floats
|
double dConst; // used for vec, dvec, mat, dmat, scalar floats and doubles
|
||||||
double dConst; // used for dvec, dmat, scalar doubles
|
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
TBasicType type;
|
TBasicType type;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
//POSSIBILITY OF SUCH DAMAGE.
|
//POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "float.h"
|
//??#include "float.h"
|
||||||
#include "localintermediate.h"
|
#include "localintermediate.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -160,10 +160,10 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
newConstArray = new constUnion[getMatrixRows() * node->getMatrixCols()];
|
newConstArray = new constUnion[getMatrixRows() * node->getMatrixCols()];
|
||||||
for (int row = 0; row < getMatrixRows(); row++) {
|
for (int row = 0; row < getMatrixRows(); row++) {
|
||||||
for (int column = 0; column < node->getMatrixCols(); column++) {
|
for (int column = 0; column < node->getMatrixCols(); column++) {
|
||||||
float sum = 0.0f;
|
double sum = 0.0f;
|
||||||
for (int i = 0; i < node->getMatrixRows(); i++)
|
for (int i = 0; i < node->getMatrixRows(); i++)
|
||||||
sum += unionArray[i * getMatrixRows() + row].getFConst() * rightUnionArray[column * node->getMatrixRows() + i].getFConst();
|
sum += unionArray[i * getMatrixRows() + row].getDConst() * rightUnionArray[column * node->getMatrixRows() + i].getDConst();
|
||||||
newConstArray[column * getMatrixRows() + row].setFConst(sum);
|
newConstArray[column * getMatrixRows() + row].setDConst(sum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
|
returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
|
||||||
@@ -174,9 +174,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
switch (getType().getBasicType()) {
|
switch (getType().getBasicType()) {
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
if (rightUnionArray[i] == 0.0f) {
|
if (rightUnionArray[i] == 0.0f) {
|
||||||
newConstArray[i].setFConst(FLT_MAX);
|
newConstArray[i].setDConst(FLT_MAX); // TODO: double support
|
||||||
} else
|
} else
|
||||||
newConstArray[i].setFConst(unionArray[i].getFConst() / rightUnionArray[i].getFConst());
|
newConstArray[i].setDConst(unionArray[i].getDConst() / rightUnionArray[i].getDConst());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
@@ -202,11 +202,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
case EOpMatrixTimesVector:
|
case EOpMatrixTimesVector:
|
||||||
newConstArray = new constUnion[getMatrixRows()];
|
newConstArray = new constUnion[getMatrixRows()];
|
||||||
for (int i = 0; i < getMatrixRows(); i++) {
|
for (int i = 0; i < getMatrixRows(); i++) {
|
||||||
float sum = 0.0f;
|
double sum = 0.0f;
|
||||||
for (int j = 0; j < node->getVectorSize(); j++) {
|
for (int j = 0; j < node->getVectorSize(); j++) {
|
||||||
sum += unionArray[j*getMatrixRows() + i].getFConst() * rightUnionArray[j].getFConst();
|
sum += unionArray[j*getMatrixRows() + i].getDConst() * rightUnionArray[j].getDConst();
|
||||||
}
|
}
|
||||||
newConstArray[i].setFConst(sum);
|
newConstArray[i].setDConst(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnType = TType(getBasicType(), EvqConst, getMatrixRows());
|
returnType = TType(getBasicType(), EvqConst, getMatrixRows());
|
||||||
@@ -215,10 +215,10 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||||||
case EOpVectorTimesMatrix:
|
case EOpVectorTimesMatrix:
|
||||||
newConstArray = new constUnion[node->getMatrixCols()];
|
newConstArray = new constUnion[node->getMatrixCols()];
|
||||||
for (int i = 0; i < node->getMatrixCols(); i++) {
|
for (int i = 0; i < node->getMatrixCols(); i++) {
|
||||||
float sum = 0.0f;
|
double sum = 0.0f;
|
||||||
for (int j = 0; j < getVectorSize(); j++)
|
for (int j = 0; j < getVectorSize(); j++)
|
||||||
sum += unionArray[j].getFConst() * rightUnionArray[i*node->getMatrixRows() + j].getFConst();
|
sum += unionArray[j].getDConst() * rightUnionArray[i*node->getMatrixRows() + j].getDConst();
|
||||||
newConstArray[i].setFConst(sum);
|
newConstArray[i].setDConst(sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
returnType = TType(getBasicType(), EvqConst, node->getMatrixCols());
|
returnType = TType(getBasicType(), EvqConst, node->getMatrixCols());
|
||||||
@@ -392,13 +392,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
sum += double(unionArray[i].getFConst()) * unionArray[i].getFConst();
|
sum += double(unionArray[i].getDConst()) * unionArray[i].getDConst();
|
||||||
double length = sqrt(sum);
|
double length = sqrt(sum);
|
||||||
if (op == EOpLength)
|
if (op == EOpLength)
|
||||||
newConstArray[0].setFConst(float(length));
|
newConstArray[0].setDConst(length);
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < objectSize; i++)
|
for (int i = 0; i < objectSize; i++)
|
||||||
newConstArray[i].setFConst(float(unionArray[i].getFConst() / length));
|
newConstArray[i].setDConst(unionArray[i].getDConst() / length);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -406,12 +406,11 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Functionality: constant folding: separate component-wise from non-component-wise
|
|
||||||
for (int i = 0; i < objectSize; i++) {
|
for (int i = 0; i < objectSize; i++) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case EOpNegative:
|
case EOpNegative:
|
||||||
switch (getType().getBasicType()) {
|
switch (getType().getBasicType()) {
|
||||||
case EbtFloat: newConstArray[i].setFConst(-unionArray[i].getFConst()); break;
|
case EbtFloat: newConstArray[i].setDConst(-unionArray[i].getDConst()); break;
|
||||||
case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
|
case EbtInt: newConstArray[i].setIConst(-unionArray[i].getIConst()); break;
|
||||||
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
|
case EbtUint: newConstArray[i].setUConst(static_cast<unsigned int>(-static_cast<int>(unionArray[i].getUConst()))); break;
|
||||||
default:
|
default:
|
||||||
@@ -432,28 +431,28 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
newConstArray[i] = ~unionArray[i];
|
newConstArray[i] = ~unionArray[i];
|
||||||
break;
|
break;
|
||||||
case EOpRadians:
|
case EOpRadians:
|
||||||
newConstArray[i].setFConst(static_cast<float>(unionArray[i].getFConst() * pi / 180.0));
|
newConstArray[i].setDConst(unionArray[i].getDConst() * pi / 180.0);
|
||||||
break;
|
break;
|
||||||
case EOpDegrees:
|
case EOpDegrees:
|
||||||
newConstArray[i].setFConst(static_cast<float>(unionArray[i].getFConst() * 180.0 / pi));
|
newConstArray[i].setDConst(unionArray[i].getDConst() * 180.0 / pi);
|
||||||
break;
|
break;
|
||||||
case EOpSin:
|
case EOpSin:
|
||||||
newConstArray[i].setFConst(sin(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(sin(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
case EOpCos:
|
case EOpCos:
|
||||||
newConstArray[i].setFConst(cos(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(cos(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
case EOpTan:
|
case EOpTan:
|
||||||
newConstArray[i].setFConst(tan(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(tan(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
case EOpAsin:
|
case EOpAsin:
|
||||||
newConstArray[i].setFConst(asin(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(asin(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
case EOpAcos:
|
case EOpAcos:
|
||||||
newConstArray[i].setFConst(acos(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(acos(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
case EOpAtan:
|
case EOpAtan:
|
||||||
newConstArray[i].setFConst(atan(unionArray[i].getFConst()));
|
newConstArray[i].setDConst(atan(unionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EOpLength:
|
case EOpLength:
|
||||||
@@ -465,7 +464,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||||||
case EOpDPdy:
|
case EOpDPdy:
|
||||||
case EOpFwidth:
|
case EOpFwidth:
|
||||||
// The derivatives are all mandated to create a constant 0.
|
// The derivatives are all mandated to create a constant 0.
|
||||||
newConstArray[i].setFConst(0.0f);
|
newConstArray[i].setDConst(0.0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// TODO: Functionality: constant folding: the rest of the ops have to be fleshed out
|
// TODO: Functionality: constant folding: the rest of the ops have to be fleshed out
|
||||||
@@ -583,9 +582,9 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
|
|||||||
case EOpMax:
|
case EOpMax:
|
||||||
for (int i = 0; i < objectSize; i++) {
|
for (int i = 0; i < objectSize; i++) {
|
||||||
if (aggrNode->getOp() == EOpMax)
|
if (aggrNode->getOp() == EOpMax)
|
||||||
newConstArray[i].setFConst(std::max(childConstUnions[0]->getFConst(), childConstUnions[1]->getFConst()));
|
newConstArray[i].setDConst(std::max(childConstUnions[0]->getDConst(), childConstUnions[1]->getDConst()));
|
||||||
else
|
else
|
||||||
newConstArray[i].setFConst(std::min(childConstUnions[0]->getFConst(), childConstUnions[1]->getFConst()));
|
newConstArray[i].setDConst(std::min(childConstUnions[0]->getDConst(), childConstUnions[1]->getDConst()));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -1343,19 +1343,19 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
switch (node->getType().getBasicType()) {
|
switch (node->getType().getBasicType()) {
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
leftUnionArray[i].setFConst(static_cast<float>(rightUnionArray[i].getIConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getIConst()));
|
||||||
break;
|
break;
|
||||||
case EbtUint:
|
case EbtUint:
|
||||||
leftUnionArray[i].setFConst(static_cast<float>(rightUnionArray[i].getUConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getUConst()));
|
||||||
break;
|
break;
|
||||||
case EbtBool:
|
case EbtBool:
|
||||||
leftUnionArray[i].setFConst(static_cast<float>(rightUnionArray[i].getBConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
leftUnionArray[i] = rightUnionArray[i];
|
leftUnionArray[i] = rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
leftUnionArray[i].setFConst(static_cast<float>(rightUnionArray[i].getBConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
|
infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
|
||||||
@@ -1365,17 +1365,15 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
switch (node->getType().getBasicType()) {
|
switch (node->getType().getBasicType()) {
|
||||||
case EbtInt:
|
case EbtInt:
|
||||||
leftUnionArray[i].setDConst(static_cast<float>(rightUnionArray[i].getIConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getIConst()));
|
||||||
break;
|
break;
|
||||||
case EbtUint:
|
case EbtUint:
|
||||||
leftUnionArray[i].setDConst(static_cast<float>(rightUnionArray[i].getUConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getUConst()));
|
||||||
break;
|
break;
|
||||||
case EbtBool:
|
case EbtBool:
|
||||||
leftUnionArray[i].setDConst(static_cast<float>(rightUnionArray[i].getBConst()));
|
leftUnionArray[i].setDConst(static_cast<double>(rightUnionArray[i].getBConst()));
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
leftUnionArray[i].setDConst(static_cast<float>(rightUnionArray[i].getFConst()));
|
|
||||||
break;
|
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
leftUnionArray[i] = rightUnionArray[i];
|
leftUnionArray[i] = rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
@@ -1396,8 +1394,6 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getBConst()));
|
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getBConst()));
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getFConst()));
|
|
||||||
break;
|
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getDConst()));
|
leftUnionArray[i].setIConst(static_cast<int>(rightUnionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
@@ -1418,8 +1414,6 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getBConst()));
|
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getBConst()));
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getFConst()));
|
|
||||||
break;
|
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getDConst()));
|
leftUnionArray[i].setUConst(static_cast<unsigned int>(rightUnionArray[i].getDConst()));
|
||||||
break;
|
break;
|
||||||
@@ -1440,10 +1434,8 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
|
|||||||
leftUnionArray[i] = rightUnionArray[i];
|
leftUnionArray[i] = rightUnionArray[i];
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
leftUnionArray[i].setBConst(rightUnionArray[i].getFConst() != 0.0f);
|
|
||||||
break;
|
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
leftUnionArray[i].setBConst(rightUnionArray[i].getDConst() != 0.0f);
|
leftUnionArray[i].setBConst(rightUnionArray[i].getDConst() != 0.0);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
|
infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
|
||||||
|
|||||||
@@ -544,10 +544,10 @@ int yy_input(char* buf, int max_size);
|
|||||||
0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
|
0{D}+{U} { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
|
||||||
{D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.u = strtoul(yytext, 0, 0); return UINTCONSTANT; }
|
{D}+{U} { pyylval->lex.line = yylineno; pyylval->lex.u = strtoul(yytext, 0, 0); return UINTCONSTANT; }
|
||||||
|
|
||||||
{D}+{F} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return FLOATCONSTANT; }
|
{D}+{F} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return FLOATCONSTANT; }
|
||||||
{D}+{E}{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return FLOATCONSTANT; }
|
{D}+{E}{F}? { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return FLOATCONSTANT; }
|
||||||
{D}+"."{D}*({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return FLOATCONSTANT; }
|
{D}+"."{D}*({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return FLOATCONSTANT; }
|
||||||
"."{D}+({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return FLOATCONSTANT; }
|
"."{D}+({E})?{F}? { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return FLOATCONSTANT; }
|
||||||
|
|
||||||
{D}+{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return DOUBLECONSTANT; }
|
{D}+{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return DOUBLECONSTANT; }
|
||||||
{D}+{E}{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return DOUBLECONSTANT; }
|
{D}+{E}{LF} { pyylval->lex.line = yylineno; pyylval->lex.d = atof(yytext); return DOUBLECONSTANT; }
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ extern void yyerror(const char*);
|
|||||||
TSourceLoc line;
|
TSourceLoc line;
|
||||||
union {
|
union {
|
||||||
TString *string;
|
TString *string;
|
||||||
float f;
|
|
||||||
int i;
|
int i;
|
||||||
unsigned int u;
|
unsigned int u;
|
||||||
bool b;
|
bool b;
|
||||||
@@ -278,7 +277,7 @@ primary_expression
|
|||||||
}
|
}
|
||||||
| FLOATCONSTANT {
|
| FLOATCONSTANT {
|
||||||
constUnion *unionArray = new constUnion[1];
|
constUnion *unionArray = new constUnion[1];
|
||||||
unionArray->setFConst($1.f);
|
unionArray->setDConst($1.d);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
|
||||||
}
|
}
|
||||||
| DOUBLECONSTANT {
|
| DOUBLECONSTANT {
|
||||||
@@ -360,7 +359,7 @@ postfix_expression
|
|||||||
|
|
||||||
if ($$ == 0) {
|
if ($$ == 0) {
|
||||||
constUnion *unionArray = new constUnion[1];
|
constUnion *unionArray = new constUnion[1];
|
||||||
unionArray->setFConst(0.0f);
|
unionArray->setDConst(0.0);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line);
|
||||||
} else {
|
} else {
|
||||||
TType newType($1->getType());
|
TType newType($1->getType());
|
||||||
@@ -594,7 +593,7 @@ function_call
|
|||||||
// error message was put out by PaFindFunction()
|
// error message was put out by PaFindFunction()
|
||||||
// Put on a dummy node for error recovery
|
// Put on a dummy node for error recovery
|
||||||
constUnion *unionArray = new constUnion[1];
|
constUnion *unionArray = new constUnion[1];
|
||||||
unionArray->setFConst(0.0f);
|
unionArray->setDConst(0.0);
|
||||||
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
|
$$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
|
||||||
parseContext.recover();
|
parseContext.recover();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,19 +410,11 @@ void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
|||||||
out.debug << "\n";
|
out.debug << "\n";
|
||||||
break;
|
break;
|
||||||
case EbtFloat:
|
case EbtFloat:
|
||||||
{
|
|
||||||
const int maxSize = 300;
|
|
||||||
char buf[maxSize];
|
|
||||||
snprintf(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getFConst(), "const float");
|
|
||||||
|
|
||||||
out.debug << buf << "\n";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EbtDouble:
|
case EbtDouble:
|
||||||
{
|
{
|
||||||
const int maxSize = 300;
|
const int maxSize = 300;
|
||||||
char buf[maxSize];
|
char buf[maxSize];
|
||||||
snprintf(buf, maxSize, "%f (%s)", node->getUnionArrayPointer()[i].getDConst(), "const double");
|
snprintf(buf, maxSize, "%f", node->getUnionArrayPointer()[i].getDConst());
|
||||||
|
|
||||||
out.debug << buf << "\n";
|
out.debug << buf << "\n";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
|
|||||||
if (index - i == 0 || (i - index) % (matrixRows + 1) == 0 )
|
if (index - i == 0 || (i - index) % (matrixRows + 1) == 0 )
|
||||||
leftUnionArray[i] = rightUnionArray[count];
|
leftUnionArray[i] = rightUnionArray[count];
|
||||||
else
|
else
|
||||||
leftUnionArray[i].setFConst(0.0f);
|
leftUnionArray[i].setDConst(0.0);
|
||||||
|
|
||||||
(oit->index)++;
|
(oit->index)++;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user