Home | History | Annotate | Download | only in src
      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() {}
     16   virtual bool TestFunc(uint64_t iterations);
     17   virtual bool Run();
     18   virtual const char* Name() const { return "clear"; }
     19   virtual bool IsDrawTest() const { return true; }
     20   virtual const char* Unit() const { return "mpixels_sec"; }
     21 
     22  private:
     23   GLbitfield mask_;
     24   DISALLOW_COPY_AND_ASSIGN(ClearTest);
     25 };
     26 
     27 
     28 bool ClearTest::TestFunc(uint64_t iterations) {
     29   GLbitfield mask = mask_;
     30   glClear(mask);
     31   glFlush();  // Kick GPU as soon as possible
     32   for (uint64_t i = 0; i < iterations - 1; ++i) {
     33     glClear(mask);
     34   }
     35   return true;
     36 }
     37 
     38 
     39 bool ClearTest::Run() {
     40   mask_ = GL_COLOR_BUFFER_BIT;
     41   RunTest(this, "clear_color", g_width * g_height, g_width, g_height, true);
     42 
     43   mask_ = GL_DEPTH_BUFFER_BIT;
     44   RunTest(this, "clear_depth", g_width * g_height, g_width, g_height, true);
     45 
     46   mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;
     47   RunTest(this, "clear_colordepth",
     48           g_width * g_height, g_width, g_height, true);
     49 
     50   mask_ = GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
     51   RunTest(this, "clear_depthstencil",
     52           g_width * g_height, g_width, g_height, true);
     53 
     54   mask_ = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT;
     55   RunTest(this, "clear_colordepthstencil",
     56           g_width * g_height, g_width, g_height, true);
     57   return true;
     58 }
     59 
     60 
     61 TestBase* GetClearTest() {
     62   return new ClearTest;
     63 }
     64 
     65 } // namespace glbench
     66