Merge pull request #567 from steve-lunarg/compare-fix
HLSL: Enable component-wise vector comparisons from operators
This commit is contained in:
commit
aba444005f
15 changed files with 635 additions and 155 deletions
|
|
@ -1892,13 +1892,26 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
|
|||
// Relational comparisons need numeric types and will promote to scalar Boolean.
|
||||
if (left->getBasicType() == EbtBool)
|
||||
return false;
|
||||
node.setType(TType(EbtBool));
|
||||
|
||||
node.setType(TType(EbtBool, EvqTemporary, left->getVectorSize()));
|
||||
break;
|
||||
|
||||
case EOpEqual:
|
||||
case EOpNotEqual:
|
||||
// All the above comparisons result in a bool (but not the vector compares)
|
||||
node.setType(TType(EbtBool));
|
||||
if (getSource() == EShSourceHlsl) {
|
||||
const int resultWidth = std::max(left->getVectorSize(), right->getVectorSize());
|
||||
|
||||
// In HLSL, == or != on vectors means component-wise comparison.
|
||||
if (resultWidth > 1) {
|
||||
op = (op == EOpEqual) ? EOpVectorEqual : EOpVectorNotEqual;
|
||||
node.setOp(op);
|
||||
}
|
||||
|
||||
node.setType(TType(EbtBool, EvqTemporary, resultWidth));
|
||||
} else {
|
||||
// All the above comparisons result in a bool (but not the vector compares)
|
||||
node.setType(TType(EbtBool));
|
||||
}
|
||||
break;
|
||||
|
||||
case EOpLogicalAnd:
|
||||
|
|
@ -1973,6 +1986,8 @@ bool TIntermediate::promoteBinary(TIntermBinary& node)
|
|||
|
||||
case EOpEqual:
|
||||
case EOpNotEqual:
|
||||
case EOpVectorEqual:
|
||||
case EOpVectorNotEqual:
|
||||
|
||||
case EOpLogicalAnd:
|
||||
case EOpLogicalOr:
|
||||
|
|
|
|||
|
|
@ -163,6 +163,8 @@ bool TOutputTraverser::visitBinary(TVisit /* visit */, TIntermBinary* node)
|
|||
case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
|
||||
case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
|
||||
case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
|
||||
case EOpVectorEqual: out.debug << "Equal"; break;
|
||||
case EOpVectorNotEqual: out.debug << "NotEqual"; break;
|
||||
|
||||
case EOpVectorTimesScalar: out.debug << "vector-scale"; break;
|
||||
case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue