Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "main.h" |
| 6 | #include "testbase.h" |
| 7 | |
| 8 | |
| 9 | namespace glbench { |
| 10 | |
| 11 | |
| 12 | class ClearTest : public TestBase { |
| 13 | public: |
| 14 | ClearTest() : mask_(0) {} |
| 15 | virtual ~ClearTest() {} |
Ilja H. Friedel | 439ea14 | 2014-02-21 20:29:10 -0800 | [diff] [blame] | 16 | virtual bool TestFunc(uint64_t iterations); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 17 | virtual bool Run(); |
Alexey Marinichev | f50ecb1 | 2010-06-14 15:21:41 -0700 | [diff] [blame] | 18 | virtual const char* Name() const { return "clear"; } |
Daniel Kurtz | bcad4fb | 2014-06-18 12:31:03 +0800 | [diff] [blame] | 19 | virtual bool IsDrawTest() const { return true; } |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 20 | virtual const char* Unit() const { return "mpixels_sec"; } |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 21 | |
| 22 | private: |
| 23 | GLbitfield mask_; |
| 24 | DISALLOW_COPY_AND_ASSIGN(ClearTest); |
| 25 | }; |
| 26 | |
| 27 | |
Ilja H. Friedel | 439ea14 | 2014-02-21 20:29:10 -0800 | [diff] [blame] | 28 | bool ClearTest::TestFunc(uint64_t iterations) { |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 29 | GLbitfield mask = mask_; |
| 30 | glClear(mask); |
| 31 | glFlush(); // Kick GPU as soon as possible |
Ilja H. Friedel | 439ea14 | 2014-02-21 20:29:10 -0800 | [diff] [blame] | 32 | for (uint64_t i = 0; i < iterations - 1; ++i) { |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 33 | glClear(mask); |
| 34 | } |
| 35 | return true; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | bool ClearTest::Run() { |
| 40 | mask_ = GL_COLOR_BUFFER_BIT; |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 41 | RunTest(this, "clear_color", g_width * g_height, g_width, g_height, true); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 42 | |
| 43 | mask_ = GL_DEPTH_BUFFER_BIT; |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 44 | RunTest(this, "clear_depth", g_width * g_height, g_width, g_height, true); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 45 | |
| 46 | mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 47 | RunTest(this, "clear_colordepth", |
Ilja Friedel | 3907fd1 | 2014-04-15 14:29:43 -0700 | [diff] [blame] | 48 | g_width * g_height, g_width, g_height, true); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 49 | |
| 50 | mask_ = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 51 | RunTest(this, "clear_depthstencil", |
Ilja Friedel | 3907fd1 | 2014-04-15 14:29:43 -0700 | [diff] [blame] | 52 | g_width * g_height, g_width, g_height, true); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 53 | |
| 54 | mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT; |
Daniel Kurtz | aace01b | 2014-06-17 21:05:24 +0800 | [diff] [blame] | 55 | RunTest(this, "clear_colordepthstencil", |
Ilja Friedel | 3907fd1 | 2014-04-15 14:29:43 -0700 | [diff] [blame] | 56 | g_width * g_height, g_width, g_height, true); |
Alexey Marinichev | 9f9b873 | 2010-05-20 19:33:44 -0700 | [diff] [blame] | 57 | return true; |
| 58 | } |
| 59 | |
| 60 | |
| 61 | TestBase* GetClearTest() { |
| 62 | return new ClearTest; |
| 63 | } |
| 64 | |
| 65 | } // namespace glbench |