Add EOpD3DCOLORtoUBYTE4 decomposition

This commit is contained in:
steve-lunarg
2017-01-03 14:42:18 -07:00
parent affc26674d
commit 7ea7ff4cd4
7 changed files with 174 additions and 7 deletions

View File

@@ -2629,6 +2629,27 @@ void HlslParseContext::decomposeIntrinsic(const TSourceLoc& loc, TIntermTyped*&
break;
}
case EOpD3DCOLORtoUBYTE4:
{
// ivec4 ( x.zyxw * 255.001953 );
TIntermTyped* arg0 = node->getAsUnaryNode()->getOperand();
TVectorFields fields(2,1,0,3);
TIntermTyped* swizzleIdx = intermediate.addSwizzle(fields, loc);
TIntermTyped* swizzled = intermediate.addIndex(EOpVectorSwizzle, arg0, swizzleIdx, loc);
swizzled->setType(arg0->getType());
swizzled->getWritableType().getQualifier().makeTemporary();
TIntermTyped* conversion = intermediate.addConstantUnion(255.001953f, EbtFloat, loc, true);
TIntermTyped* rangeConverted = handleBinaryMath(loc, "mul", EOpMul, conversion, swizzled);
rangeConverted->setType(arg0->getType());
rangeConverted->getWritableType().getQualifier().makeTemporary();
node = intermediate.addConversion(EOpConstructInt, TType(EbtInt, EvqTemporary, 4), rangeConverted);
node->setLoc(loc);
node->setType(TType(EbtInt, EvqTemporary, 4));
break;
}
default:
break; // most pass through unchanged
}

View File

@@ -1022,7 +1022,7 @@ void TBuiltInParseablesHlsl::identifyBuiltIns(int /*version*/, EProfile /*profil
symbolTable.relateToOperator("cosh", EOpCosh);
symbolTable.relateToOperator("countbits", EOpBitCount);
symbolTable.relateToOperator("cross", EOpCross);
// symbolTable.relateToOperator("D3DCOLORtoUBYTE4", EOpD3DCOLORtoUBYTE4);
symbolTable.relateToOperator("D3DCOLORtoUBYTE4", EOpD3DCOLORtoUBYTE4);
symbolTable.relateToOperator("ddx", EOpDPdx);
symbolTable.relateToOperator("ddx_coarse", EOpDPdxCoarse);
symbolTable.relateToOperator("ddx_fine", EOpDPdxFine);