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

Unified Diff: gpu/command_buffer/tests/gl_readback_unittests.cc

Issue 12892005: Implement client side PBOs for glReadPixel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updated tests Created 7 years, 9 months 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
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/tests/gl_readback_unittests.cc
diff --git a/gpu/command_buffer/tests/gl_readback_unittests.cc b/gpu/command_buffer/tests/gl_readback_unittests.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5311e4f8f203d70b2521cf6a5e1906a77bbc04d1
--- /dev/null
+++ b/gpu/command_buffer/tests/gl_readback_unittests.cc
@@ -0,0 +1,86 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <GLES2/gl2extchromium.h>
+
+#include "gpu/command_buffer/tests/gl_manager.h"
+#include "gpu/command_buffer/tests/gl_test_utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace gpu {
+
+class GLReadbackTest : public testing::Test {
+ protected:
+ virtual void SetUp() {
+ gl_.Initialize(GLManager::Options());
+ }
+
+ virtual void TearDown() {
+ gl_.Destroy();
+ }
+
+ GLManager gl_;
+};
+
+
+TEST_F(GLReadbackTest, ReadPixelsWithPBO) {
apatrick_chromium 2013/03/21 22:51:27 Can you clear the FBO to a particular color and th
hubbe 2013/03/21 23:00:58 Done.
+ const GLint kBytesPerPixel = 4;
+ const GLint kWidth = 2;
+ const GLint kHeight = 2;
+
+ GLuint b;
+ glGenBuffers(1, &b);
+ glBindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, b);
+ glBufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ kWidth * kHeight * kBytesPerPixel,
+ NULL,
+ 0 /* should be GL_STREAM_READ, but that is not defined in
+ GLES2, and the code currently doesn't care */);
+ glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ glFlush();
apatrick_chromium 2013/03/21 22:51:27 You shouldn't need this glFlush() because glMapBuf
hubbe 2013/03/21 23:00:58 Done.
+ EXPECT_TRUE(glMapBufferCHROMIUM(
+ GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ GL_READ_ONLY));
+ glUnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
+ glBindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ glDeleteBuffers(1, &b);
+ GLTestHelper::CheckGLError("no errors", __LINE__);
+}
+
+TEST_F(GLReadbackTest, ReadPixelsWithPBOAndQuery) {
+ const GLint kBytesPerPixel = 4;
+ const GLint kWidth = 2;
+ const GLint kHeight = 2;
+
+ GLuint b, q;
+ glGenBuffers(1, &b);
+ glGenQueriesEXT(1, &q);
apatrick_chromium 2013/03/21 22:51:27 The query object leaks.
hubbe 2013/03/21 23:00:58 Done.
+ glBindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, b);
+ glBufferData(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ kWidth * kHeight * kBytesPerPixel,
+ NULL,
+ 0 /* should be GL_STREAM_READ, but that is not defined in
+ GLES2, and the code currently doesn't care */);
+ glBeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, q);
+ glReadPixels(0, 0, kWidth, kHeight, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ glEndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
+ unsigned int done = 0;
+ while (!done) {
apatrick_chromium 2013/03/21 22:51:27 I think you need a glFlush before this loop.
hubbe 2013/03/21 23:00:58 Done.
+ glGetQueryObjectuivEXT(q, GL_QUERY_RESULT_AVAILABLE_EXT, &done);
+ }
+
+ // TODO(hubbe): Check that glMapBufferCHROMIUM does not block here.
+ EXPECT_TRUE(glMapBufferCHROMIUM(
+ GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM,
+ GL_READ_ONLY));
+ glUnmapBufferCHROMIUM(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM);
+ glBindBuffer(GL_PIXEL_PACK_TRANSFER_BUFFER_CHROMIUM, 0);
+ glDeleteBuffers(1, &b);
+ GLTestHelper::CheckGLError("no errors", __LINE__);
+}
+
+} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder.cc ('k') | gpu/gpu.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698