blob: 88a3618f26fab7af5c4164a6413d47e3dd2401a0 [file] [log] [blame]
Alexey Marinichev9f9b8732010-05-20 19:33:44 -07001// 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
9namespace glbench {
10
11
12class ClearTest : public TestBase {
13 public:
14 ClearTest() : mask_(0) {}
15 virtual ~ClearTest() {}
Ilja H. Friedel439ea142014-02-21 20:29:10 -080016 virtual bool TestFunc(uint64_t iterations);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070017 virtual bool Run();
Alexey Marinichevf50ecb12010-06-14 15:21:41 -070018 virtual const char* Name() const { return "clear"; }
Daniel Kurtzbcad4fb2014-06-18 12:31:03 +080019 virtual bool IsDrawTest() const { return true; }
Daniel Kurtzaace01b2014-06-17 21:05:24 +080020 virtual const char* Unit() const { return "mpixels_sec"; }
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070021
22 private:
23 GLbitfield mask_;
24 DISALLOW_COPY_AND_ASSIGN(ClearTest);
25};
26
27
Ilja H. Friedel439ea142014-02-21 20:29:10 -080028bool ClearTest::TestFunc(uint64_t iterations) {
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070029 GLbitfield mask = mask_;
30 glClear(mask);
31 glFlush(); // Kick GPU as soon as possible
Ilja H. Friedel439ea142014-02-21 20:29:10 -080032 for (uint64_t i = 0; i < iterations - 1; ++i) {
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070033 glClear(mask);
34 }
35 return true;
36}
37
38
39bool ClearTest::Run() {
40 mask_ = GL_COLOR_BUFFER_BIT;
Daniel Kurtzaace01b2014-06-17 21:05:24 +080041 RunTest(this, "clear_color", g_width * g_height, g_width, g_height, true);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070042
43 mask_ = GL_DEPTH_BUFFER_BIT;
Daniel Kurtzaace01b2014-06-17 21:05:24 +080044 RunTest(this, "clear_depth", g_width * g_height, g_width, g_height, true);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070045
46 mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
Daniel Kurtzaace01b2014-06-17 21:05:24 +080047 RunTest(this, "clear_colordepth",
Ilja Friedel3907fd12014-04-15 14:29:43 -070048 g_width * g_height, g_width, g_height, true);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070049
50 mask_ = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
Daniel Kurtzaace01b2014-06-17 21:05:24 +080051 RunTest(this, "clear_depthstencil",
Ilja Friedel3907fd12014-04-15 14:29:43 -070052 g_width * g_height, g_width, g_height, true);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070053
54 mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
Daniel Kurtzaace01b2014-06-17 21:05:24 +080055 RunTest(this, "clear_colordepthstencil",
Ilja Friedel3907fd12014-04-15 14:29:43 -070056 g_width * g_height, g_width, g_height, true);
Alexey Marinichev9f9b8732010-05-20 19:33:44 -070057 return true;
58}
59
60
61TestBase* GetClearTest() {
62 return new ClearTest;
63}
64
65} // namespace glbench