HLSL: Fix possibly incorrect type conversion in StoreN and LoadN

Set type to r-value resulting from indexing vector, to prevent
float->uint conversion when source is already uint. Resulting
OpConvertFToU would otherwise fail validation because source is
already uint.
For LoadN, incorrect uint->float->uint can be avoided; fixing
potential truncation of big integer values.
This commit is contained in:
Jean-François Marquis
2017-12-15 12:57:33 -05:00
parent 3f0d4bcd6a
commit 3f0aff8ee5
4 changed files with 853 additions and 868 deletions

View File

@@ -3302,7 +3302,13 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
const TOperator idxOp = (offsetIdx->getQualifier().storage == EvqConst) ? EOpIndexDirect
: EOpIndexIndirect;
vec = intermediate.growAggregate(vec, intermediate.addIndex(idxOp, argArray, offsetIdx, loc));
TIntermTyped* indexVal = intermediate.addIndex(idxOp, argArray, offsetIdx, loc);
TType derefType(argArray->getType(), 0);
derefType.getQualifier().makeTemporary();
indexVal->setType(derefType);
vec = intermediate.growAggregate(vec, indexVal);
}
vec->setType(TType(argArray->getBasicType(), EvqTemporary, size));
@@ -3366,8 +3372,14 @@ void HlslParseContext::decomposeStructBufferMethods(const TSourceLoc& loc, TInte
const TType derefType(argArray->getType(), 0);
lValue->setType(derefType);
TIntermTyped* rValue = (size == 1) ? argValue :
intermediate.addIndex(EOpIndexDirect, argValue, idxConst, loc);
TIntermTyped* rValue;
if (size == 1) {
rValue = argValue;
} else {
rValue = intermediate.addIndex(EOpIndexDirect, argValue, idxConst, loc);
const TType indexType(argValue->getType(), 0);
rValue->setType(indexType);
}
TIntermTyped* assign = intermediate.addAssign(EOpAssign, lValue, rValue, loc);