Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: gpu/perftests/texture_upload_perftest.cc

Issue 1011503002: Set GLSL "precision" only if using OpenGL ES. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/containers/small_map.h" 8 #include "base/containers/small_map.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 26 matching lines...) Expand all
37 uniform vec2 translation; 37 uniform vec2 translation;
38 attribute vec2 a_position; 38 attribute vec2 a_position;
39 attribute vec2 a_texCoord; 39 attribute vec2 a_texCoord;
40 varying vec2 v_texCoord; 40 varying vec2 v_texCoord;
41 void main() { 41 void main() {
42 gl_Position = vec4( 42 gl_Position = vec4(
43 translation.x + a_position.x, translation.y + a_position.y, 0.0, 1.0); 43 translation.x + a_position.x, translation.y + a_position.y, 0.0, 1.0);
44 v_texCoord = a_texCoord; 44 v_texCoord = a_texCoord;
45 } 45 }
46 ); 46 );
47 const char kShaderDefaultFloatPrecision[] =
48 SHADER(
49 precision mediump float;
50 );
47 const char kFragmentShader[] = 51 const char kFragmentShader[] =
48 SHADER( 52 SHADER(
49 precision mediump float;
50 uniform sampler2D a_texture; 53 uniform sampler2D a_texture;
51 varying vec2 v_texCoord; 54 varying vec2 v_texCoord;
52 void main() { 55 void main() {
53 gl_FragColor = texture2D(a_texture, v_texCoord); 56 gl_FragColor = texture2D(a_texture, v_texCoord);
54 } 57 }
55 ); 58 );
56 // clang-format on 59 // clang-format on
57 60
58 void CheckNoGlError() { 61 void CheckNoGlError() {
59 CHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError()); 62 CHECK_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if (gpu_timing_client_->IsAvailable()) { 183 if (gpu_timing_client_->IsAvailable()) {
181 LOG(INFO) << "Gpu timing initialized with timer type: " 184 LOG(INFO) << "Gpu timing initialized with timer type: "
182 << gpu_timing_client_->GetTimerTypeName(); 185 << gpu_timing_client_->GetTimerTypeName();
183 gpu_timing_client_->InvalidateTimerOffset(); 186 gpu_timing_client_->InvalidateTimerOffset();
184 } else { 187 } else {
185 LOG(WARNING) << "Can't initialize gpu timing"; 188 LOG(WARNING) << "Can't initialize gpu timing";
186 } 189 }
187 // Prepare a simple program and a vertex buffer that will be 190 // Prepare a simple program and a vertex buffer that will be
188 // used to draw a quad on the offscreen surface. 191 // used to draw a quad on the offscreen surface.
189 vertex_shader_ = LoadShader(GL_VERTEX_SHADER, kVertexShader); 192 vertex_shader_ = LoadShader(GL_VERTEX_SHADER, kVertexShader);
190 fragment_shader_ = LoadShader(GL_FRAGMENT_SHADER, kFragmentShader); 193
194 bool is_gles = gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2;
195 fragment_shader_ = LoadShader(
196 GL_FRAGMENT_SHADER,
197 base::StringPrintf("%s%s", is_gles ? kShaderDefaultFloatPrecision : "",
198 kFragmentShader).c_str());
191 program_object_ = glCreateProgram(); 199 program_object_ = glCreateProgram();
192 CHECK_NE(0u, program_object_); 200 CHECK_NE(0u, program_object_);
193 201
194 glAttachShader(program_object_, vertex_shader_); 202 glAttachShader(program_object_, vertex_shader_);
195 glAttachShader(program_object_, fragment_shader_); 203 glAttachShader(program_object_, fragment_shader_);
196 glBindAttribLocation(program_object_, 0, "a_position"); 204 glBindAttribLocation(program_object_, 0, "a_position");
197 glBindAttribLocation(program_object_, 1, "a_texCoord"); 205 glBindAttribLocation(program_object_, 1, "a_texCoord");
198 glLinkProgram(program_object_); 206 glLinkProgram(program_object_);
199 207
200 GLint linked = -1; 208 GLint linked = -1;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 gpu_timing_client_->CheckAndResetTimerErrors(); 472 gpu_timing_client_->CheckAndResetTimerErrors();
465 if (!gpu_timer_errors) { 473 if (!gpu_timer_errors) {
466 upload_and_draw_timers.GetAsMeasurement("upload_and_draw") 474 upload_and_draw_timers.GetAsMeasurement("upload_and_draw")
467 .PrintResult("renaming"); 475 .PrintResult("renaming");
468 finish_timers.GetAsMeasurement("finish").PrintResult("renaming"); 476 finish_timers.GetAsMeasurement("finish").PrintResult("renaming");
469 } 477 }
470 } 478 }
471 479
472 } // namespace 480 } // namespace
473 } // namespace gpu 481 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698