summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authorjmadill@chromium.org <jmadill@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 02:42:59 +0000
committerjmadill@chromium.org <jmadill@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-03-01 02:42:59 +0000
commit77bfe744c34da500d8c81f0d1771945cc6208ce6 (patch)
tree8a55e9376256fedfa9c7e6fe11bb793c136fe710 /gpu
parent27cc600813dc8535a84359eec1a35aa5aa406b16 (diff)
downloadchromium_src-77bfe744c34da500d8c81f0d1771945cc6208ce6.zip
chromium_src-77bfe744c34da500d8c81f0d1771945cc6208ce6.tar.gz
chromium_src-77bfe744c34da500d8c81f0d1771945cc6208ce6.tar.bz2
Fail gracefully on PBO pack buffer failure.
In certain error conditions we could call glReadPixels with both a pack buffer bound and using a client pointer argument, which the GL would interpret as a large buffer offset. BUG=340694 Review URL: https://codereview.chromium.org/153953004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@254332 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc3
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc46
2 files changed, 49 insertions, 0 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index b64cc54..256d321 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -7369,6 +7369,9 @@ error::Error GLES2DecoderImpl::HandleReadPixels(
c, buffer));
glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
return error::kNoError;
+ } else {
+ // On error, unbind pack buffer and fall through to sync readpixels
+ glBindBuffer(GL_PIXEL_PACK_BUFFER_ARB, 0);
}
}
glReadPixels(x, y, width, height, format, type, pixels);
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
index 297e0c7..0b49b07 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc
@@ -2531,6 +2531,52 @@ TEST_F(GLES2DecoderTest, ReadPixelsInvalidArgs) {
EXPECT_NE(error::kNoError, ExecuteCmd(cmd));
}
+TEST_F(GLES2DecoderManualInitTest, ReadPixelsAsyncError) {
+ InitDecoder(
+ "GL_ARB_sync", // extensions
+ "opengl es 3.0", // gl version
+ true, // has alpha
+ false, // has depth
+ false, // has stencil
+ true, // request alpha
+ false, // request depth
+ false, // request stencil
+ true); // bind generates resource
+
+ typedef ReadPixels::Result Result;
+ Result* result = GetSharedMemoryAs<Result*>();
+
+ const GLsizei kWidth = 4;
+ const GLsizei kHeight = 4;
+ uint32 result_shm_id = kSharedMemoryId;
+ uint32 result_shm_offset = kSharedMemoryOffset;
+ uint32 pixels_shm_id = kSharedMemoryId;
+ uint32 pixels_shm_offset = kSharedMemoryOffset + sizeof(*result);
+
+ EXPECT_CALL(*gl_, GetError())
+ // first error check must pass to get to the test
+ .WillOnce(Return(GL_NO_ERROR))
+ // second check is after BufferData, simulate fail here
+ .WillOnce(Return(GL_INVALID_OPERATION))
+ // third error check is fall-through call to sync ReadPixels
+ .WillOnce(Return(GL_NO_ERROR))
+ .RetiresOnSaturation();
+
+ EXPECT_CALL(*gl_, ReadPixels(0, 0, kWidth, kHeight, GL_RGB,
+ GL_UNSIGNED_BYTE, _)).Times(1);
+ EXPECT_CALL(*gl_, GenBuffersARB(1, _)).Times(1);
+ EXPECT_CALL(*gl_, BindBuffer(GL_PIXEL_PACK_BUFFER_ARB, _)).Times(2);
+ EXPECT_CALL(*gl_, BufferData(GL_PIXEL_PACK_BUFFER_ARB, _, NULL,
+ GL_STREAM_READ)).Times(1);
+
+ ReadPixels cmd;
+ cmd.Init(0, 0, kWidth, kHeight, GL_RGB, GL_UNSIGNED_BYTE,
+ pixels_shm_id, pixels_shm_offset,
+ result_shm_id, result_shm_offset,
+ true);
+ EXPECT_EQ(error::kNoError, ExecuteCmd(cmd));
+}
+
TEST_F(GLES2DecoderTest, BindAttribLocation) {
const GLint kLocation = 2;
const char* kName = "testing";