Added check for temporary register overflow
Currently, when overflowing the number of temporary registers
allowed, SwiftShader will crash somewhere in the generated
code. This cl adds an early check to prevent the crash and
instead output an error message to the user.
Bug chromium:814987
Change-Id: Idadda21ee14298662763d986ee1283a5114c1c01
Reviewed-on: https://swiftshader-review.googlesource.com/18388
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/compiler/OutputASM.cpp b/src/OpenGL/compiler/OutputASM.cpp
index b3385c2..8477af2 100644
--- a/src/OpenGL/compiler/OutputASM.cpp
+++ b/src/OpenGL/compiler/OutputASM.cpp
@@ -3031,7 +3031,14 @@
int OutputASM::temporaryRegister(TIntermTyped *temporary)
{
- return allocate(temporaries, temporary);
+ int index = allocate(temporaries, temporary);
+ if(index >= sw::NUM_TEMPORARY_REGISTERS)
+ {
+ mContext.error(temporary->getLine(),
+ "Too many temporary registers required to compile shader",
+ pixelShader ? "pixel shader" : "vertex shader");
+ }
+ return index;
}
void OutputASM::setPixelShaderInputs(const TType& type, int var, bool flat)