Index: gpu/perftests/texture_upload_perftest.cc |
diff --git a/gpu/perftests/texture_upload_perftest.cc b/gpu/perftests/texture_upload_perftest.cc |
index f691c9e76d91f1b744f2609309ba91266e15f8b2..36de48ab776816401ae9ad91ff4f7ab290a605b4 100644 |
--- a/gpu/perftests/texture_upload_perftest.cc |
+++ b/gpu/perftests/texture_upload_perftest.cc |
@@ -96,12 +96,30 @@ class TextureUploadPerfTest : public testing::Test { |
void SetUp() override { |
// Initialize an offscreen surface and a gl context. |
gfx::GLSurface::InitializeOneOff(); |
- surface_ = gfx::GLSurface::CreateOffscreenGLSurface(size_); |
+ surface_ = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(4, 4)); |
gl_context_ = gfx::GLContext::CreateGLContext(NULL, // share_group |
surface_.get(), |
gfx::PreferIntegratedGpu); |
- |
ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get()); |
+ glGenTextures(1, &color_texture_); |
+ glBindTexture(GL_TEXTURE_2D, color_texture_); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size_.width(), size_.height(), 0, |
+ GL_RGBA, GL_UNSIGNED_BYTE, nullptr); |
+ |
+ glGenFramebuffersEXT(1, &framebuffer_object_); |
+ glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_object_); |
+ |
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
+ GL_TEXTURE_2D, color_texture_, 0); |
+ DCHECK_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
+ glCheckFramebufferStatusEXT(GL_FRAMEBUFFER)); |
+ |
+ glViewport(0, 0, size_.width(), size_.height()); |
+ |
if (gpu_timing_.Initialize(gl_context_.get())) { |
LOG(INFO) << "Gpu timing initialized with timer type: " |
<< gpu_timing_.GetTimerTypeName(); |
@@ -110,7 +128,6 @@ class TextureUploadPerfTest : public testing::Test { |
} else { |
LOG(WARNING) << "Can't initialize gpu timing"; |
} |
- |
// Prepare a simple program and a vertex buffer that will be |
// used to draw a quad on the offscreen surface. |
vertex_shader_ = LoadShader(GL_VERTEX_SHADER, kVertexShader); |
@@ -154,6 +171,13 @@ class TextureUploadPerfTest : public testing::Test { |
if (vertex_buffer_ != 0) { |
glDeleteShader(vertex_buffer_); |
} |
+ if (framebuffer_object_ != 0) { |
reveman
2015/02/18 16:21:33
nit: I think just "if (framebuffer_object_)" is pr
Daniele Castagna
2015/02/18 18:47:07
We don't need them. I checked the documentation fo
|
+ glBindFramebufferEXT(GL_FRAMEBUFFER, 0); |
+ glDeleteFramebuffersEXT(1, &framebuffer_object_); |
+ } |
+ if (color_texture_ != 0) { |
reveman
2015/02/18 16:21:33
nit: maybe remove "!= 0"
Daniele Castagna
2015/02/18 18:47:07
Removed all the if (blabla_ != 0)
|
+ glDeleteTextures(1, &color_texture_); |
+ } |
gl_context_ = nullptr; |
surface_ = nullptr; |
@@ -167,6 +191,8 @@ class TextureUploadPerfTest : public testing::Test { |
const GLenum format, |
const GLenum type) { |
ui::ScopedMakeCurrent smc(gl_context_.get(), surface_.get()); |
+ DCHECK_GT(framebuffer_object_, 0u); |
reveman
2015/02/18 16:21:33
nit: DCHECK_NE as less than 0 is not possible
Daniele Castagna
2015/02/18 18:47:07
Done.
|
+ glBindFramebufferEXT(GL_FRAMEBUFFER, framebuffer_object_); |
MeasurementTimers total_timers(&gpu_timing_); |
GLuint texture_id = 0; |
@@ -178,8 +204,8 @@ class TextureUploadPerfTest : public testing::Test { |
glTexImage2D(GL_TEXTURE_2D, 0, format, size_.width(), size_.height(), 0, |
format, type, &pixels[0]); |
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
CheckNoGlError(); |
@@ -222,11 +248,13 @@ class TextureUploadPerfTest : public testing::Test { |
return measurements; |
} |
- const gfx::Size size_; // for the offscreen surface and the texture |
+ const gfx::Size size_; // for the fbo and the texture |
scoped_refptr<gfx::GLContext> gl_context_; |
scoped_refptr<gfx::GLSurface> surface_; |
GPUTiming gpu_timing_; |
+ GLuint color_texture_ = 0; |
+ GLuint framebuffer_object_ = 0; |
GLuint vertex_shader_ = 0; |
GLuint fragment_shader_ = 0; |
GLuint program_object_ = 0; |