Commit 9cd7163e by Olli Etuaho Committed by Commit Bot

Fix setting array sizes on a constructor

Take any array sizes that have been explicitly specified in the shader text into account, and only set the ones that are unsized according to the arguments. BUG=angleproject:2125 TEST=angle_unittests Change-Id: I37d08a86c25f7cd4f3ce5689f2c9fad444e7d5ad Reviewed-on: https://chromium-review.googlesource.com/738141 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 4b8b650c
...@@ -3485,8 +3485,10 @@ TIntermTyped *TParseContext::addConstructor(TIntermSequence *arguments, ...@@ -3485,8 +3485,10 @@ TIntermTyped *TParseContext::addConstructor(TIntermSequence *arguments,
} }
TIntermTyped *firstElement = arguments->at(0)->getAsTyped(); TIntermTyped *firstElement = arguments->at(0)->getAsTyped();
ASSERT(firstElement); ASSERT(firstElement);
type.setArraySize(type.getArraySizes().size() - 1u, if (type.getOutermostArraySize() == 0u)
static_cast<unsigned int>(arguments->size())); {
type.sizeOutermostUnsizedArray(static_cast<unsigned int>(arguments->size()));
}
for (size_t i = 0; i < firstElement->getType().getArraySizes().size(); ++i) for (size_t i = 0; i < firstElement->getType().getArraySizes().size(); ++i)
{ {
if (type.getArraySizes()[i] == 0u) if (type.getArraySizes()[i] == 0u)
......
...@@ -5152,3 +5152,24 @@ TEST_F(FragmentShaderValidationTest, UnsizedNamelessParameter) ...@@ -5152,3 +5152,24 @@ TEST_F(FragmentShaderValidationTest, UnsizedNamelessParameter)
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog; FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
} }
} }
// Test that partially unsized array of arrays constructor sizes are validated.
TEST_F(FragmentShaderValidationTest, PartiallyUnsizedArrayOfArraysConstructor)
{
const std::string &shaderString =
R"(#version 310 es
precision highp float;
out vec4 color;
void main()
{
int a[][] = int[2][](int[1](1));
color = vec4(a[0][0]);
})";
if (compile(shaderString))
{
FAIL() << "Shader compilation succeeded, expecting failure:\n" << mInfoLog;
}
}
\ No newline at end of file
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