Commit bd797f75 by Jamie Madill Committed by Angle LUCI CQ

D3D11: Fix OOB write in Blit11.

This could happen for specific values of the 'dest' target. Bug: chromium:1219082 Change-Id: Ic19a5dc4a95531f9513403ad9c97a4b4c5dc5a6f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2961070Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent cc280ff3
...@@ -60,12 +60,13 @@ void StretchedBlitNearest_RowByRow(const gl::Box &sourceArea, ...@@ -60,12 +60,13 @@ void StretchedBlitNearest_RowByRow(const gl::Box &sourceArea,
uint8_t *destData) uint8_t *destData)
{ {
int srcHeightSubOne = (sourceArea.height - 1); int srcHeightSubOne = (sourceArea.height - 1);
size_t copySize = pixelSize * destArea.width; size_t copySize = pixelSize * clippedDestArea.width;
size_t srcOffset = sourceArea.x * pixelSize; size_t srcOffset = sourceArea.x * pixelSize;
size_t destOffset = destArea.x * pixelSize; size_t destOffset = clippedDestArea.x * pixelSize;
for (int y = clippedDestArea.y; y < clippedDestArea.y + clippedDestArea.height; y++) for (int y = clippedDestArea.y; y < clippedDestArea.y + clippedDestArea.height; y++)
{ {
// TODO: Fix divide by zero when height == 1. http://anglebug.com/6099
float yPerc = static_cast<float>(y - destArea.y) / (destArea.height - 1); float yPerc = static_cast<float>(y - destArea.y) / (destArea.height - 1);
// Interpolate using the original source rectangle to determine which row to sample from // Interpolate using the original source rectangle to determine which row to sample from
......
...@@ -39,9 +39,11 @@ ...@@ -39,9 +39,11 @@
6068 INTEL VULKAN : MultiviewRenderPrimitiveTest.LineStrip/* = SKIP 6068 INTEL VULKAN : MultiviewRenderPrimitiveTest.LineStrip/* = SKIP
// Mac // Mac
6025 MAC AMD OPENGL : IndexBufferOffsetTestES3.UseAsUBOThenUpdateThenUInt8Index/ES3_OpenGL = SKIP 6025 MAC AMD OPENGL : IndexBufferOffsetTestES3.UseAsUBOThenUpdateThenUInt8Index/* = SKIP
6025 MAC AMD OPENGL : IndexBufferOffsetTestES3.UseAsUBOThenUpdateThenUInt8IndexSmallUpdates/ES3_OpenGL = SKIP 6025 MAC AMD OPENGL : IndexBufferOffsetTestES3.UseAsUBOThenUpdateThenUInt8IndexSmallUpdates/* = SKIP
6096 MAC METAL : GLSLTest_ES3.InitGlobalComplexConstant/ES3_Metal = SKIP 6096 MAC METAL : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP
6060 MAC METAL : BlitFramebufferTest.OOBWrite/* = SKIP
6101 WIN OPENGL INTEL : BlitFramebufferTest.OOBWrite/* = SKIP
// D3D // D3D
6091 WIN D3D11 : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP 6091 WIN D3D11 : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP
......
...@@ -2548,6 +2548,29 @@ TEST_P(BlitFramebufferTest, BlitFramebufferStencilClipNoIntersection) ...@@ -2548,6 +2548,29 @@ TEST_P(BlitFramebufferTest, BlitFramebufferStencilClipNoIntersection)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
} }
// Covers an edge case with blitting borderline values.
TEST_P(BlitFramebufferTest, OOBWrite)
{
constexpr size_t length = 0x100000;
GLFramebuffer rfb;
GLFramebuffer dfb;
GLRenderbuffer rb1;
GLRenderbuffer rb2;
glBindFramebuffer(GL_READ_FRAMEBUFFER, rfb);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dfb);
glBindRenderbuffer(GL_RENDERBUFFER, rb1);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 0x1000, 2);
glBindRenderbuffer(GL_RENDERBUFFER, rb2);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 2, 2);
glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
rb1);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
rb2);
glBlitFramebuffer(1, 0, 0, 1, 1, 0, (2147483648 / 2) - (length / 4) + 1, 1,
GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT, GL_NEAREST);
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these // Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against. // tests should be run against.
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BlitFramebufferANGLETest); GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(BlitFramebufferANGLETest);
......
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