• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2018 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 // This test evaluates the speed of rebinding the texture after each draw call.
6 
7 #include "main.h"
8 #include "texturetest.h"
9 
10 namespace glbench {
11 
12 class TextureRebindTest : public TextureTest {
13  public:
TextureRebindTest()14   TextureRebindTest() {}
15   virtual bool TextureMetaDataInit();
~TextureRebindTest()16   virtual ~TextureRebindTest() {}
17   virtual bool TestFunc(uint64_t iterations);
Name() const18   virtual const char* Name() const { return "texture_rebind"; }
IsDrawTest() const19   virtual bool IsDrawTest() const { return true; }
IsTextureUploadTest() const20   virtual bool IsTextureUploadTest() const { return false; }
21 };
22 
23 
TextureMetaDataInit()24 bool TextureRebindTest::TextureMetaDataInit(){
25     kTexelFormats.push_back(GL_RGBA);
26     kTexelFormatNames[GL_RGBA] = "rgba";
27     kTexelFormatSizes[GL_RGBA] = 4;
28     kFlavors[TEX_IMAGE] = "teximage2d";
29     return true;
30 }
31 
TestFunc(uint64_t iterations)32 bool TextureRebindTest::TestFunc(uint64_t iterations) {
33   for (uint64_t i = 0; i < iterations; ++i) {
34     for (uint64_t texture_idx = 0;
35          texture_idx < kNumberOfTextures;
36          texture_idx++) {
37       glBindTexture(GL_TEXTURE_2D, textures_[texture_idx]);
38       glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
39     }
40   }
41 
42   return true;
43 }
44 
GetTextureRebindTest()45 TestBase* GetTextureRebindTest() {
46   return new TextureRebindTest;
47 }
48 
49 }  // namespace glbench
50