Commit 6b596682 by steve-lunarg

HLSL: fix defect in EOpMethodSampleCmp* texture decomposition

HLSL holds the compare value in a separate intrinsic arg, but the AST wants a vector including the cmp val, except in the 4-dim coord case, where it doesn't fit and is in fact a separate AST parameter. This is awkward but necessary, given AST semantics. In the process, a new vector is constructed for the combined result, but this vector was not being given the correct TType, so was causing some downstream troubles. Now it is. A similar defect existed in OpTextureBias, and has also been fixed.
parent 5d45eade
...@@ -1496,6 +1496,10 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1496,6 +1496,10 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
constructCoord->getSequence().push_back(arg1); constructCoord->getSequence().push_back(arg1);
constructCoord->setLoc(loc); constructCoord->setLoc(loc);
// The input vector should never be less than 2, since there's always a bias.
// The max is for safety, and should be a no-op.
constructCoord->setType(TType(arg1->getBasicType(), EvqTemporary, std::max(arg1->getVectorSize() - 1, 0)));
TIntermAggregate* tex = new TIntermAggregate(EOpTexture); TIntermAggregate* tex = new TIntermAggregate(EOpTexture);
tex->getSequence().push_back(arg0); // sampler tex->getSequence().push_back(arg0); // sampler
tex->getSequence().push_back(constructCoord); // coordinate tex->getSequence().push_back(constructCoord); // coordinate
...@@ -1725,6 +1729,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType ...@@ -1725,6 +1729,7 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
if (coordDimWithCmpVal != 5) // cube array shadow is special. if (coordDimWithCmpVal != 5) // cube array shadow is special.
coordWithCmp->getSequence().push_back(argCmpVal); coordWithCmp->getSequence().push_back(argCmpVal);
coordWithCmp->setLoc(loc); coordWithCmp->setLoc(loc);
coordWithCmp->setType(TType(argCoord->getBasicType(), EvqTemporary, std::min(coordDimWithCmpVal, 4)));
TOperator textureOp = (op == EOpMethodSampleCmpLevelZero ? EOpTextureLod : EOpTexture); TOperator textureOp = (op == EOpMethodSampleCmpLevelZero ? EOpTextureLod : EOpTexture);
if (argOffset != nullptr) if (argOffset != nullptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment