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

Unified Diff: client/deps/glbench/src/main.cc

Issue 1588001: Added glReadPixels test. (Closed)
Patch Set: couple more readpixel tests Created 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/deps/glbench/src/main.cc
diff --git a/client/deps/glbench/src/main.cc b/client/deps/glbench/src/main.cc
index 1e78b7d6cba945e37abbb210d4d8d46d109128a4..bb5ff50733dd1d6c92e06c0e85509ca72b63d6d6 100644
--- a/client/deps/glbench/src/main.cc
+++ b/client/deps/glbench/src/main.cc
@@ -68,6 +68,7 @@ void RunTest(BenchFunc f, const char *name, float coefficient, bool inverse) {
}
static int arg1 = 0;
+static void *arg2 = NULL;
void SwapTestFunc(int iter) {
for (int i = 0 ; i < iter; ++i) {
@@ -789,7 +790,39 @@ void NoFillWindowManagerCompositingTest() {
TeardownCompositing();
}
-// TODO: get resources file from a command line option or something.
+void ReadPixelTestFunc(int iter) {
+ glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, arg2);
+ CHECK(glGetError() == 0);
+ for (int i = 0; i < iter; i++)
+ glReadPixels(0, 0, g_width, g_height, GL_RGBA, GL_UNSIGNED_BYTE, arg2);
+}
+
+// TODO: better test names.
+void ReadPixelTest() {
+ // One GL_RGBA pixel takes 4 bytes.
+ const int row_size = g_width * 4;
+ // Default GL_PACK_ALIGNMENT is 4, round up pixel row size to multiple of 4.
+ // This is a no-op because row_size is already divisible by 4.
+ // One is added so that we can test reads into unaligned location.
+ char* pixels = new char[((row_size + 3) & ~3) * g_height + 1];
+
+ arg2 = pixels;
+ RunTest(ReadPixelTestFunc, "mpixels_sec_pixel_read",
+ g_width * g_height, true);
+
+ // Reducing GL_PACK_ALIGNMENT can only make rows smaller. No need to
+ // reallocate the buffer.
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ RunTest(ReadPixelTestFunc, "mpixels_sec_pixel_read_2",
+ g_width * g_height, true);
+
+ arg2 = static_cast<void*>(pixels + 1);
+ RunTest(ReadPixelTestFunc, "mpixels_sec_pixel_read_3",
+ g_width * g_height, true);
+
+ delete[] pixels;
+}
+
// TODO: use proper command line parsing library.
static void ParseArgs(int argc, char *argv[]) {
const char **enabled_tests_ptr = enabled_tests;
@@ -833,6 +866,7 @@ int main(int argc, char *argv[]) {
YuvToRgbShaderTest2,
NoFillWindowManagerCompositingTest,
WindowManagerCompositingTest,
+ ReadPixelTest,
};
uint64_t done = GetUTime() + 1000000ULL * seconds_to_run;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698