Commit b071b0f0 by Nicolas Capens

Restrict the size of shader arrays.

This prevents overflow issues in the HLSL translator and some drivers. The limit it hard-coded to 65536 to be larger than the Shader Model 5 register limit (4096) to account for register allocation optimizations and future hardware. BUG=379799 Change-Id: I3cd0d8ad2084c3ca675821bfad1fab48f78c76c7 Reviewed-on: https://chromium-review.googlesource.com/204521Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarNicolas Capens <nicolascapens@chromium.org>
parent d3d87064
...@@ -689,6 +689,18 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* ex ...@@ -689,6 +689,18 @@ bool TParseContext::arraySizeErrorCheck(const TSourceLoc& line, TIntermTyped* ex
return true; return true;
} }
// The size of arrays is restricted here to prevent issues further down the
// compiler/translator/driver stack. Shader Model 5 generation hardware is limited to
// 4096 registers so this should be reasonable even for aggressively optimizable code.
const int sizeLimit = 65536;
if (size > sizeLimit)
{
error(line, "array size too large", "");
size = 1;
return true;
}
return false; return false;
} }
......
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