Commit 51634468 by John Kessenich Committed by GitHub

Merge pull request #568 from steve-lunarg/logicalop-fix

HLSL: allow component-wise operations for logical || and &&.
parents aba44400 27939caa
struct PS_OUTPUT
{
float4 Color : SV_Target0;
};
uniform bool4 b4a, b4b;
uniform bool b1a, b1b;
PS_OUTPUT main()
{
bool4 r00 = !b4a;
bool4 r01 = b4a && b4b; // vec, vec
bool4 r02 = b4a || b4b; // vec, vec
bool4 r10 = b1a && b4b; // scalar, vec
bool4 r11 = b1a || b4b; // scalar, vec
bool4 r20 = b4a && b1b; // vec, scalar
bool4 r21 = b4a || b1b; // vec, scalar
PS_OUTPUT psout;
psout.Color = r00 || r01 || r02 || r10 || r11 || r20 || r21;
return psout;
}
......@@ -797,6 +797,9 @@ TIntermTyped* TIntermediate::addShapeConversion(TOperator op, const TType& type,
case EOpNotEqual:
case EOpFunctionCall:
case EOpReturn:
case EOpLogicalAnd:
case EOpLogicalOr:
case EOpLogicalXor:
break;
default:
return node;
......@@ -1924,13 +1927,14 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
return false;
node.setLeft(left = convertedL); // also updates stack variable
node.setRight(right = convertedR); // also updates stack variable
} else {
// logical ops operate only on scalar Booleans and will promote to scalar Boolean.
if (left->getBasicType() != EbtBool || left->isVector() || left->isMatrix())
return false;
}
// logical ops operate only on scalar Booleans and will promote to scalar Boolean.
if (left->getBasicType() != EbtBool || left->isVector() || left->isMatrix())
return false;
node.setType(TType(EbtBool, EvqTemporary, left->getVectorSize()));
node.setType(TType(EbtBool));
break;
case EOpRightShift:
......
......@@ -145,6 +145,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.load.offsetarray.dx10.frag", "main"},
{"hlsl.logical.unary.frag", "main"},
{"hlsl.logical.binary.frag", "main"},
{"hlsl.logical.binary.vec.frag", "main"},
{"hlsl.multiEntry.vert", "RealEntrypoint"},
{"hlsl.multiReturn.frag", "main"},
{"hlsl.matrixindex.frag", "main"},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment