Front-end: Implement compile-time constant folding for any() and all().
This commit is contained in:
parent
91b7533d70
commit
d8509b3367
@ -374,6 +374,18 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 1 (const int)
|
0:? 1 (const int)
|
||||||
0:? 9.000000
|
0:? 9.000000
|
||||||
0:? false (const bool)
|
0:? false (const bool)
|
||||||
|
0:? 'cval1' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
0:? 'cval2' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval3' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval4' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
0:? 'cval5' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval6' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
|
||||||
|
|
||||||
Linked fragment stage:
|
Linked fragment stage:
|
||||||
@ -744,4 +756,16 @@ ERROR: node is still EOpNull!
|
|||||||
0:? 1 (const int)
|
0:? 1 (const int)
|
||||||
0:? 9.000000
|
0:? 9.000000
|
||||||
0:? false (const bool)
|
0:? false (const bool)
|
||||||
|
0:? 'cval1' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
0:? 'cval2' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval3' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval4' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
0:? 'cval5' (const bool)
|
||||||
|
0:? false (const bool)
|
||||||
|
0:? 'cval6' (const bool)
|
||||||
|
0:? true (const bool)
|
||||||
|
|
||||||
|
|||||||
@ -139,3 +139,10 @@ void foo4()
|
|||||||
{
|
{
|
||||||
int a = int(a0[2].f);
|
int a = int(a0[2].f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool cval1 = all(bvec4(true, true, true, true));
|
||||||
|
const bool cval2 = all(bvec4(false, false, false, false));
|
||||||
|
const bool cval3 = all(bvec4(true, true, false, true));
|
||||||
|
const bool cval4 = any(bvec4(true, true, true, true));
|
||||||
|
const bool cval5 = any(bvec4(false, false, false, false));
|
||||||
|
const bool cval6 = any(bvec4(false, true, false, false));
|
||||||
|
|||||||
@ -399,6 +399,27 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case EOpAny:
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
for (int i = 0; i < objectSize; i++) {
|
||||||
|
if (unionArray[i].getBConst())
|
||||||
|
result = true;
|
||||||
|
}
|
||||||
|
newConstArray[0].setBConst(result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EOpAll:
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
for (int i = 0; i < objectSize; i++) {
|
||||||
|
if (! unionArray[i].getBConst())
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
newConstArray[0].setBConst(result);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 3.0 Functionality: unary constant folding: the rest of the ops have to be fleshed out
|
// TODO: 3.0 Functionality: unary constant folding: the rest of the ops have to be fleshed out
|
||||||
|
|
||||||
case EOpPackSnorm2x16:
|
case EOpPackSnorm2x16:
|
||||||
@ -412,9 +433,6 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType)
|
|||||||
case EOpDeterminant:
|
case EOpDeterminant:
|
||||||
case EOpMatrixInverse:
|
case EOpMatrixInverse:
|
||||||
case EOpTranspose:
|
case EOpTranspose:
|
||||||
|
|
||||||
case EOpAny:
|
|
||||||
case EOpAll:
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user