|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alexis Hetu <sugoi@google.com> |
| 3 | +Date: Wed, 12 Aug 2020 17:43:18 -0400 |
| 4 | +Subject: Fix copying cubemap textures out of bounds |
| 5 | +MIME-Version: 1.0 |
| 6 | +Content-Type: text/plain; charset=UTF-8 |
| 7 | +Content-Transfer-Encoding: 8bit |
| 8 | + |
| 9 | +Cubemap textures are created with a border, which means that their |
| 10 | +size is larger. Their range is also different. Instead of [0, dim-1], |
| 11 | +they have a [-1, dim] range. This means that if we copy them starting |
| 12 | +at [0, 0] for their full size, we'll overflow at the end, since the |
| 13 | +buffer starts at [-1, -1]. This cl prevents going through the fast |
| 14 | +copy path when we have a border. |
| 15 | + |
| 16 | +Bug: chromium:1115345 |
| 17 | +Change-Id: I333acfd6094645231eb111634359d82ed3d5c787 |
| 18 | +Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/47668 |
| 19 | +Presubmit-Ready: Alexis Hétu <sugoi@google.com> |
| 20 | +Reviewed-by: Corentin Wallez <cwallez@google.com> |
| 21 | +Reviewed-by: Chris Forbes <chrisforbes@google.com> |
| 22 | +Tested-by: Alexis Hétu <sugoi@google.com> |
| 23 | + |
| 24 | +diff --git a/src/OpenGL/libGLESv2/Device.cpp b/src/OpenGL/libGLESv2/Device.cpp |
| 25 | +index 0758428fb8c2aa91a21539d533e8b32d78d15e2a..8d80db73d5e43cb7463455f85beabaaf0d773bff 100644 |
| 26 | +--- a/src/OpenGL/libGLESv2/Device.cpp |
| 27 | ++++ b/src/OpenGL/libGLESv2/Device.cpp |
| 28 | +@@ -575,7 +575,7 @@ namespace es2 |
| 29 | + bool fullCopy = (sRect.x0 == 0.0f) && (sRect.y0 == 0.0f) && (dRect.x0 == 0) && (dRect.y0 == 0) && |
| 30 | + (sRect.x1 == (float)sWidth) && (sRect.y1 == (float)sHeight) && (dRect.x1 == dWidth) && (dRect.y1 == dHeight); |
| 31 | + bool alpha0xFF = false; |
| 32 | +- bool equalSlice = sourceSliceB == destSliceB; |
| 33 | ++ bool equalSlice = (sourceSliceB == destSliceB) && (source->getBorder() == 0) && (dest->getBorder() == 0); |
| 34 | + bool smallMargin = sourcePitchB <= source->getWidth() * Surface::bytes(source->getInternalFormat()) + 16; |
| 35 | + |
| 36 | + if((source->getInternalFormat() == FORMAT_A8R8G8B8 && dest->getInternalFormat() == FORMAT_X8R8G8B8) || |
0 commit comments