Add uint type (big change). For both int/uint, add the operators >>, <<, &, |, and ^. Also added unsigned literals and uint precision support. Also fixed how int/uint literal underflow/overflow is handled.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@21054 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
ae722a6230
commit
ebeeece6a7
16 changed files with 473 additions and 102 deletions
|
|
@ -120,11 +120,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
TIntermConstantUnion *node = constantNode->getAsConstantUnion();
|
||||
constUnion *rightUnionArray = node->getUnionArrayPointer();
|
||||
|
||||
if (getType().getBasicType() != node->getBasicType()) {
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding basic types don't match", getLine());
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
|
||||
// for a case like float f = vec4(2,3,4,5) + 1.2;
|
||||
rightUnionArray = new constUnion[objectSize];
|
||||
|
|
@ -190,6 +185,13 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
|
|||
} else
|
||||
newConstArray[i].setIConst(unionArray[i].getIConst() / rightUnionArray[i].getIConst());
|
||||
break;
|
||||
|
||||
case EbtUint:
|
||||
if (rightUnionArray[i] == 0) {
|
||||
newConstArray[i].setUConst(0xFFFFFFFF);
|
||||
} else
|
||||
newConstArray[i].setUConst(unionArray[i].getUConst() / rightUnionArray[i].getUConst());
|
||||
break;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", getLine());
|
||||
return 0;
|
||||
|
|
@ -388,6 +390,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
|
|||
switch (getType().getBasicType()) {
|
||||
case EbtFloat: newConstArray[i].setFConst(-unionArray[i].getFConst()); 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;
|
||||
default:
|
||||
infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", getLine());
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue