HLSL: add error for expected comparison sampler in SampleCmp* ops

This adds an error message if a non-comparison sampler is used with
comparison sampling methods.  There's no functional change for correct shaders.
This commit is contained in:
steve-lunarg 2017-04-21 09:54:53 -06:00
parent 32a385e9d7
commit 3cbc32f472
6 changed files with 224 additions and 0 deletions

View file

@ -3144,6 +3144,18 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
TIntermTyped* argCmpVal = argAggregate->getSequence()[3]->getAsTyped();
TIntermTyped* argOffset = nullptr;
// Sampler argument should be a sampler.
if (argSamp->getType().getBasicType() != EbtSampler) {
error(loc, "expected: sampler type", "", "");
return;
}
// Sampler should be a SamplerComparisonState
if (! argSamp->getType().getSampler().isShadow()) {
error(loc, "expected: SamplerComparisonState", "", "");
return;
}
// optional offset value
if (argAggregate->getSequence().size() > 4)
argOffset = argAggregate->getSequence()[4]->getAsTyped();
@ -3381,6 +3393,18 @@ void HlslParseContext::decomposeSampleMethods(const TSourceLoc& loc, TIntermType
bool hasOffset1 = false;
bool hasOffset4 = false;
// Sampler argument should be a sampler.
if (argSamp->getType().getBasicType() != EbtSampler) {
error(loc, "expected: sampler type", "", "");
return;
}
// Cmp forms require SamplerComparisonState
if (cmpValues > 0 && ! argSamp->getType().getSampler().isShadow()) {
error(loc, "expected: SamplerComparisonState", "", "");
return;
}
// Only 2D forms can have offsets. Discover if we have 0, 1 or 4 offsets.
if (dim == Esd2D) {
hasOffset1 = (argSize == (4+cmpValues) || argSize == (5+cmpValues));