Prevent initializing outline edges to out of bound values
When multisampling is enabled, outline edges were getting
initialized to one of the primitive's X position. If the
primitive was out of bounds, then the default position was
out of bounds, which led to an initial out of bounds memory
access.
Added a clamp to fix the issue.
Bug chromium:779364
Change-Id: I4661f4229ee28a3032c763ed18dde799d3c3926b
Reviewed-on: https://swiftshader-review.googlesource.com/13528
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Shader/SetupRoutine.cpp b/src/Shader/SetupRoutine.cpp
index 2fd1883..d733c2d 100644
--- a/src/Shader/SetupRoutine.cpp
+++ b/src/Shader/SetupRoutine.cpp
@@ -224,7 +224,9 @@
if(state.multiSample > 1)
{
- Short x = Short((X[0] + 0xF) >> 4);
+ Int xMin = *Pointer<Int>(data + OFFSET(DrawData, scissorX0));
+ Int xMax = *Pointer<Int>(data + OFFSET(DrawData, scissorX1));
+ Short x = Short(Clamp((X[0] + 0xF) >> 4, xMin, xMax));
For(Int y = yMin - 1, y < yMax + 1, y++)
{