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