Translator: Fixed textureGatherOffsets validation

The parser only considered the case where the input to the
textureGatherOffsets() function is an aggregate constructor
node, but not if it is a pre-initialized constant variable.
Added code to handle the constant variable case.

Tests:KHR-GLES32.core.gpu_shader5.texture_gather_offsets_color
      KHR-GLES32.core.gpu_shader5.texture_gather_offsets_depth
Bug: angleproject:5362
Change-Id: Ib1dd3450071341082ea6f0f2a243c3bb3ef6b95a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3217852
Reviewed-by: Shahbaz Youssefi <[email protected]>
Commit-Queue: Brandon Schade <[email protected]>
This commit is contained in:
Brandon Schade authored and Angle LUCI CQ committed 2021-10-28 17:06:19 +00:00
1 parent 3a9f18f135
commit 5da062baf1
2 files changed
+9 -11

No files matched your search

+9 -7
View File
@@ -6609,10 +6609,13 @@ void TParseContext::checkTextureOffset(TIntermAggregate *functionCall)
if (isTextureGatherOffsets)
{
// If textureGatherOffsets, the offsets parameter is an array, which is expected as an
// aggregate constructor node.
// aggregate constructor node or as a symbol node with a constant value.
TIntermAggregate *offsetAggregate = offset->getAsAggregate();
TIntermSymbol *offsetSymbol = offset->getAsSymbolNode();
const TConstantUnion *offsetValues =
offsetAggregate ? offsetAggregate->getConstantValue() : nullptr;
offsetAggregate ? offsetAggregate->getConstantValue()
: offsetSymbol ? offsetSymbol->getConstantValue() : nullptr;
if (offsetValues == nullptr)
{
@@ -6622,17 +6625,16 @@ void TParseContext::checkTextureOffset(TIntermAggregate *functionCall)
}
constexpr unsigned int kOffsetsCount = 4;
const TType &offsetAggregateType = offsetAggregate->getType();
if (offsetAggregateType.getNumArraySizes() != 1 ||
offsetAggregateType.getArraySizes()[0] != kOffsetsCount)
const TType &offsetType =
offsetAggregate != nullptr ? offsetAggregate->getType() : offsetSymbol->getType();
if (offsetType.getNumArraySizes() != 1 || offsetType.getArraySizes()[0] != kOffsetsCount)
{
error(functionCall->getLine(), "Texture offsets must be an array of 4 elements",
func->name());
return;
}
TIntermNode *firstOffset = offsetAggregate->getSequence()->front();
size_t size = firstOffset->getAsTyped()->getType().getObjectSize();
size_t size = offsetType.getObjectSize() / kOffsetsCount;
for (unsigned int i = 0; i < kOffsetsCount; ++i)
{
checkSingleTextureOffset(offset->getLine(), &offsetValues[i * size], size,
@@ -96,10 +96,6 @@
// Validation error from EXT_gpu_shader5
5361 VULKAN : KHR-GLES32.core.gpu_shader5.precise_qualifier = FAIL
// Constant propagaion error with textureGatherOffsets
5362 VULKAN : KHR-GLES32.core.gpu_shader5.texture_gather_offsets_color = FAIL
5362 VULKAN : KHR-GLES32.core.gpu_shader5.texture_gather_offsets_depth = FAIL
// Validation error from EXT_copy_image
5363 VULKAN : KHR-GLES32.core.copy_image.r32i_texture = FAIL
5363 VULKAN : KHR-GLES32.core.copy_image.r32ui_texture = FAIL