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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user