1// Copyright (c) 2013 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 evalutes the speed of uploading textures without actually drawing.
6
7#include "base/logging.h"
8
9#include "texturetest.h"
10#include "main.h"
11
12namespace glbench {
13
14class TextureUploadTest : public TextureTest {
15 public:
16  TextureUploadTest() {}
17  virtual ~TextureUploadTest() {}
18  virtual bool TestFunc(uint64_t iterations);
19  virtual const char* Name() const { return "texture_upload"; }
20  virtual bool IsDrawTest() const { return false; }
21};
22
23bool TextureUploadTest::TestFunc(uint64_t iterations) {
24  glGetError();
25
26  for (uint64_t i = 0; i < iterations; ++i) {
27    glBindTexture(GL_TEXTURE_2D, textures_[i % kNumberOfTextures]);
28    switch (flavor_) {
29      case TEX_IMAGE:
30        glTexImage2D(GL_TEXTURE_2D, 0, texel_gl_format_, width_, height_,
31                     0, texel_gl_format_, GL_UNSIGNED_BYTE,
32                     pixels_[i % kNumberOfTextures].get());
33        break;
34      case TEX_SUBIMAGE:
35        glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width_, height_,
36                        texel_gl_format_, GL_UNSIGNED_BYTE,
37                        pixels_[i % kNumberOfTextures].get());
38        break;
39    }
40  }
41
42  return true;
43}
44
45TestBase* GetTextureUploadTest() {
46  return new TextureUploadTest;
47}
48
49} // namespace glbench
50