Commit 9f256d10 by SeongHwan Park Committed by Angle LUCI CQ

D3D11: Fix incorrect bounds checking in Blit11

This could lead to blitting depthStencil buffer incorrectly. Bug: angleproject:6140 Change-Id: I2c5786c0375f8e2fefe862da68929340844ce9ae Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3009736Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent daa19c0a
...@@ -72,3 +72,4 @@ Renaud Lepage ...@@ -72,3 +72,4 @@ Renaud Lepage
Artem Bolgar Artem Bolgar
Wander Lairson Costa Wander Lairson Costa
Stephan Hartmann Stephan Hartmann
SeongHwan Park
...@@ -114,7 +114,7 @@ void StretchedBlitNearest_PixelByPixel(const gl::Box &sourceArea, ...@@ -114,7 +114,7 @@ void StretchedBlitNearest_PixelByPixel(const gl::Box &sourceArea,
float xPerc = static_cast<float>(writeColumn - destArea.x) / (destArea.width - 1); float xPerc = static_cast<float>(writeColumn - destArea.x) / (destArea.width - 1);
float xRounded = floor(xPerc * (sourceArea.width - 1) + 0.5f); float xRounded = floor(xPerc * (sourceArea.width - 1) + 0.5f);
unsigned int readColumn = static_cast<unsigned int>( unsigned int readColumn = static_cast<unsigned int>(
gl::clamp(sourceArea.x + xRounded, 0, sourceSize.height - 1)); gl::clamp(sourceArea.x + xRounded, 0, sourceSize.width - 1));
const uint8_t *sourcePixel = const uint8_t *sourcePixel =
sourceData + readRow * sourceRowPitch + readColumn * srcPixelStride + readOffset; sourceData + readRow * sourceRowPitch + readColumn * srcPixelStride + readOffset;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
// initialized when the program is loaded from cache. // initialized when the program is loaded from cache.
6073 OPENGL : ProgramInterfaceTestES31.ReloadFromCacheShouldNotCrash/ES3_1_OpenGL__cached = SKIP 6073 OPENGL : ProgramInterfaceTestES31.ReloadFromCacheShouldNotCrash/ES3_1_OpenGL__cached = SKIP
6073 GLES : ProgramInterfaceTestES31.ReloadFromCacheShouldNotCrash/ES3_1_OpenGLES__cached = SKIP 6073 GLES : ProgramInterfaceTestES31.ReloadFromCacheShouldNotCrash/ES3_1_OpenGLES__cached = SKIP
6142 VULKAN : BlitFramebufferTest.BlitDepthStencilPixelByPixel/* = SKIP
// Windows // Windows
3786 WIN NVIDIA D3D11 : BufferDataOverflowTest.VertexBufferIntegerOverflow/* = SKIP 3786 WIN NVIDIA D3D11 : BufferDataOverflowTest.VertexBufferIntegerOverflow/* = SKIP
...@@ -58,6 +59,7 @@ ...@@ -58,6 +59,7 @@
6096 MAC METAL : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP 6096 MAC METAL : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP
6060 MAC METAL : BlitFramebufferTest.OOBWrite/* = SKIP 6060 MAC METAL : BlitFramebufferTest.OOBWrite/* = SKIP
6124 MAC OPENGL : GLSLTestLoops.*ContinueInSwitch/* = SKIP 6124 MAC OPENGL : GLSLTestLoops.*ContinueInSwitch/* = SKIP
6144 MAC OPENGL : BlitFramebufferTest.BlitDepthStencilPixelByPixel/* = SKIP
// D3D // D3D
6091 WIN D3D11 : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP 6091 WIN D3D11 : GLSLTest_ES3.InitGlobalComplexConstant/* = SKIP
......
...@@ -2571,6 +2571,60 @@ TEST_P(BlitFramebufferTest, OOBWrite) ...@@ -2571,6 +2571,60 @@ TEST_P(BlitFramebufferTest, OOBWrite)
ASSERT_GL_NO_ERROR(); ASSERT_GL_NO_ERROR();
} }
// Test blitting a depthStencil buffer with multiple depth values to a larger size.
TEST_P(BlitFramebufferTest, BlitDepthStencilPixelByPixel)
{
ANGLE_GL_PROGRAM(drawRed, essl3_shaders::vs::Simple(), essl3_shaders::fs::Red());
glViewport(0, 0, 128, 1);
glEnable(GL_DEPTH_TEST);
GLFramebuffer srcFramebuffer;
GLRenderbuffer srcRenderbuffer;
glBindFramebuffer(GL_FRAMEBUFFER, srcFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, srcRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 128, 1);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
srcRenderbuffer);
glClearDepthf(1.0f);
glClear(GL_DEPTH_BUFFER_BIT);
drawQuad(drawRed, essl1_shaders::PositionAttrib(), 0.0f, 0.5f);
glViewport(0, 0, 256, 2);
GLFramebuffer dstFramebuffer;
GLRenderbuffer dstRenderbuffer;
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dstFramebuffer);
glBindRenderbuffer(GL_RENDERBUFFER, dstRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, 256, 2);
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER,
dstRenderbuffer);
GLTexture dstColor;
glBindTexture(GL_TEXTURE_2D, dstColor);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA8, 256, 2);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, dstColor, 0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, srcFramebuffer);
glBlitFramebuffer(0, 0, 128, 1, 0, 0, 256, 2, GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT,
GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, dstFramebuffer);
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glDepthMask(false);
glDepthFunc(GL_LESS);
drawQuad(drawRed, essl1_shaders::PositionAttrib(), -0.01f, 0.5f);
EXPECT_PIXEL_RECT_EQ(64, 0, 128, 1, GLColor::red);
ANGLE_GL_PROGRAM(drawBlue, essl3_shaders::vs::Simple(), essl3_shaders::fs::Blue());
glEnable(GL_DEPTH_TEST);
glDepthMask(false);
glDepthFunc(GL_GREATER);
drawQuad(drawBlue, essl1_shaders::PositionAttrib(), 0.01f, 0.5f);
EXPECT_PIXEL_RECT_EQ(64, 0, 128, 1, GLColor::blue);
}
// 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