Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Unified Diff: gpu/command_buffer/client/gles2_implementation_unittest.cc

Issue 706173005: Enable asynchronous glReadPixels on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add mechanism to propagate service-side glMapBuffer errors + tests. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/client/gles2_implementation_unittest.cc
diff --git a/gpu/command_buffer/client/gles2_implementation_unittest.cc b/gpu/command_buffer/client/gles2_implementation_unittest.cc
index 799618cb4d795512090201aa20550e3feb8cae11..70a09adb32d632305751a66f90b32cf07525b308 100644
--- a/gpu/command_buffer/client/gles2_implementation_unittest.cc
+++ b/gpu/command_buffer/client/gles2_implementation_unittest.cc
@@ -1676,8 +1676,8 @@ TEST_F(GLES2ImplementationTest, ReadPixels2Reads) {
scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]);
EXPECT_CALL(*command_buffer(), OnFlush())
- .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(1)))
- .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(1)))
+ .WillOnce(SetMemory(result1.ptr, static_cast<uint32>(GL_NO_ERROR)))
+ .WillOnce(SetMemory(result2.ptr, static_cast<uint32>(GL_NO_ERROR)))
.RetiresOnSaturation();
gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
@@ -1708,12 +1708,52 @@ TEST_F(GLES2ImplementationTest, ReadPixelsBadFormatType) {
scoped_ptr<int8[]> buffer(new int8[kWidth * kHeight * kBytesPerPixel]);
EXPECT_CALL(*command_buffer(), OnFlush())
- .Times(1)
+ .WillOnce(SetMemory(result1.ptr,
+ static_cast<uint32>(GL_INVALID_ENUM)))
.RetiresOnSaturation();
gl_->ReadPixels(0, 0, kWidth, kHeight, kFormat, kType, buffer.get());
}
+TEST_F(GLES2ImplementationTest, MapBufferErrorPropagation) {
+ const GLsizeiptr kBufferSize = 64;
+
+ // Create a buffer for readback purposes.
+ GLuint buffer = 0;
+ gl_->GenBuffers(1, &buffer);
+ gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, buffer);
+ gl_->BufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ kBufferSize,
+ NULL,
+ GL_STREAM_READ);
+
+ // Expect to successfully map the buffer that was just created.
+ EXPECT_CALL(*command_buffer(), OnFlush())
+ .Times(1)
+ .RetiresOnSaturation();
+ void* data = gl_->MapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ GL_READ_ONLY);
+ EXPECT_TRUE(data);
+ gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
+
+ // Simulate the service encountering a GL_OUT_OF_MEMORY error during a
+ // readback into the service-side buffer. The GL error code is internally
+ // stored in the 4 bytes following the end of the buffer.
+ *(reinterpret_cast<uint32_t*>(static_cast<uint8_t*>(data) + kBufferSize)) =
+ GL_OUT_OF_MEMORY;
+
+ // Now, try to map the buffer again and expect failure.
+ data = gl_->MapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ GL_READ_ONLY);
+ EXPECT_FALSE(data);
+ EXPECT_EQ(GL_OUT_OF_MEMORY, gl_->GetError());
+
+ // Clean up.
+ gl_->UnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
+ gl_->BindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ gl_->DeleteBuffers(1, &buffer);
+}
+
TEST_F(GLES2ImplementationTest, FreeUnusedSharedMemory) {
struct Cmds {
cmds::BufferSubData buf;

Powered by Google App Engine
This is Rietveld 408576698