HLSL: handle type conversion for any/all intrinsics

HLSL allows float/etc types for any/all intrinsics, while the
SPIR-V opcode requires bool.  This adds a simple decomposition
to type convert the argument.  It could get a little more clever
in some of the type cases if it ever had to.
This commit is contained in:
LoopDawg
2017-07-05 12:07:16 -06:00
parent 17b5f9175d
commit 54b9ff9c34
4 changed files with 3930 additions and 3800 deletions

View File

@@ -4101,6 +4101,28 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
break;
}
case EOpAny: // fall through
case EOpAll:
{
TIntermTyped* typedArg = arguments->getAsTyped();
// HLSL allows float/etc types here, and the SPIR-V opcode requires a bool.
// We'll convert here. Note that for efficiency, we could add a smarter
// decomposition for some type cases, e.g, maybe by decomposing a dot product.
if (typedArg->getType().getBasicType() != EbtBool) {
const TType boolType(EbtBool, EvqTemporary,
typedArg->getVectorSize(),
typedArg->getMatrixCols(),
typedArg->getMatrixRows(),
typedArg->isVector());
typedArg = intermediate.addConversion(EOpConstructBool, boolType, typedArg);
node->getAsUnaryNode()->setOperand(typedArg);
}
break;
}
case EOpSaturate:
{
// saturate(a) -> clamp(a,0,1)