GLES: Remove hardcoded shader limits
Perform whole-shader analysis to determine usage limits.
Use these limits to allocate compile time and runtime arrays.
Removes the constants:
MAX_SHADER_NESTED_LOOPS
MAX_SHADER_NESTED_IFS
MAX_SHADER_CALL_STACK_SIZE
Also switched to using dynamic containers to remove the MAX_SHADER_CALL_SITES limit, which I believe to have been buggy and broken.
Bug: b/123587120
Change-Id: I89be80072183ac2aac28124df236888309e7207c
Reviewed-on: https://swiftshader-review.googlesource.com/c/24668
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
diff --git a/src/Shader/VertexProgram.cpp b/src/Shader/VertexProgram.cpp
index 8bae9cf..0463ea6 100644
--- a/src/Shader/VertexProgram.cpp
+++ b/src/Shader/VertexProgram.cpp
@@ -24,12 +24,24 @@
namespace sw
{
VertexProgram::VertexProgram(const VertexProcessor::State &state, const VertexShader *shader)
- : VertexRoutine(state, shader), shader(shader), r(shader->indirectAddressableTemporaries)
+ : VertexRoutine(state, shader),
+ shader(shader),
+ r(shader->indirectAddressableTemporaries),
+ aL(shader->getLimits().loops),
+ increment(shader->getLimits().loops),
+ iteration(shader->getLimits().loops),
+ callStack(shader->getLimits().stack)
{
- for(int i = 0; i < MAX_SHADER_CALL_SITES; i++)
- {
- labelBlock[i] = 0;
- }
+ auto limits = shader->getLimits();
+ ifDepth.setLimit(limits.ifs);
+ loopRepDepth.setLimit(limits.loops);
+ currentLabel.setLimit(limits.functions);
+
+ ifFalseBlock.resize(limits.ifs);
+ loopRepTestBlock.resize(limits.loops);
+ loopRepEndBlock.resize(limits.loops);
+ labelBlock.resize(limits.functions);
+ isConditionalIf.resize(limits.ifs);
loopDepth = -1;
enableStack[0] = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF);