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

Side by Side Diff: ui/gl/gl_gl_api_implementation.cc

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Make TexSubImage validation agree with TexImage validation Created 6 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_gl_api_implementation.h" 5 #include "ui/gl/gl_gl_api_implementation.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #include "ui/gl/gl_state_restorer.h" 14 #include "ui/gl/gl_state_restorer.h"
15 #include "ui/gl/gl_surface.h" 15 #include "ui/gl/gl_surface.h"
16 #include "ui/gl/gl_switches.h" 16 #include "ui/gl/gl_switches.h"
17 #include "ui/gl/gl_version_info.h"
17 18
18 namespace gfx { 19 namespace gfx {
19 20
20 // The GL Api being used. This could be g_real_gl or gl_trace_gl 21 // The GL Api being used. This could be g_real_gl or gl_trace_gl
21 static GLApi* g_gl; 22 static GLApi* g_gl;
22 // A GL Api that calls directly into the driver. 23 // A GL Api that calls directly into the driver.
23 static RealGLApi* g_real_gl; 24 static RealGLApi* g_real_gl;
24 // A GL Api that calls TRACE and then calls another GL api. 25 // A GL Api that calls TRACE and then calls another GL api.
25 static TraceGLApi* g_trace_gl; 26 static TraceGLApi* g_trace_gl;
27 // GL version used when initializing dynamic bindings.
28 static GLVersionInfo* g_version_info = NULL;
26 29
27 namespace { 30 namespace {
28 31
29 static inline GLenum GetInternalFormat(GLenum internal_format) { 32 static inline GLenum GetInternalFormat(GLenum internal_format) {
30 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) { 33 if (gfx::GetGLImplementation() != gfx::kGLImplementationEGLGLES2) {
31 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT) 34 if (internal_format == GL_BGRA_EXT || internal_format == GL_BGRA8_EXT)
32 return GL_RGBA8; 35 return GL_RGBA8;
33 } 36 }
34 return internal_format; 37 return internal_format;
35 } 38 }
36 39
37 // TODO(epenner): Could the above function be merged into this and removed? 40 // TODO(epenner): Could the above function be merged into this and removed?
38 static inline GLenum GetTexInternalFormat(GLenum internal_format, 41 static inline GLenum GetTexInternalFormat(GLenum internal_format,
39 GLenum format, 42 GLenum format,
40 GLenum type) { 43 GLenum type) {
41 GLenum gl_internal_format = GetInternalFormat(internal_format); 44 GLenum gl_internal_format = GetInternalFormat(internal_format);
42 45
43 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2) 46 // g_version_info must be initialized when this function is bound.
47 DCHECK(gfx::g_version_info);
48 if (type == GL_FLOAT && gfx::g_version_info->is_angle &&
49 gfx::g_version_info->is_es2) {
50 // It's possible that the texture is using a sized internal format, and
51 // ANGLE exposing GLES2 API doesn't support those.
52 // TODO(oetuaho@nvidia.com): Remove these conversions once ANGLE has the
53 // support.
54 // http://code.google.com/p/angleproject/issues/detail?id=556
55 switch (format) {
56 case GL_RGBA:
57 gl_internal_format = GL_RGBA;
58 break;
59 case GL_RGB:
60 gl_internal_format = GL_RGB;
61 break;
62 default:
63 break;
64 }
65 }
66
67 if (gfx::g_version_info->is_es)
44 return gl_internal_format; 68 return gl_internal_format;
45 69
46 if (type == GL_FLOAT) { 70 if (type == GL_FLOAT) {
47 switch (format) { 71 switch (format) {
48 case GL_RGBA: 72 case GL_RGBA:
49 gl_internal_format = GL_RGBA32F_ARB; 73 gl_internal_format = GL_RGBA32F_ARB;
50 break; 74 break;
51 case GL_RGB: 75 case GL_RGB:
52 gl_internal_format = GL_RGB32F_ARB; 76 gl_internal_format = GL_RGB32F_ARB;
53 break; 77 break;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 void SetGLApi(GLApi* api) { 225 void SetGLApi(GLApi* api) {
202 g_current_gl_context_tls->Set(api); 226 g_current_gl_context_tls->Set(api);
203 } 227 }
204 228
205 void SetGLToRealGLApi() { 229 void SetGLToRealGLApi() {
206 SetGLApi(g_gl); 230 SetGLApi(g_gl);
207 } 231 }
208 232
209 void InitializeDynamicGLBindingsGL(GLContext* context) { 233 void InitializeDynamicGLBindingsGL(GLContext* context) {
210 g_driver_gl.InitializeCustomDynamicBindings(context); 234 g_driver_gl.InitializeCustomDynamicBindings(context);
235 DCHECK(context && context->IsCurrent(NULL) && !g_version_info);
236 g_version_info = new GLVersionInfo(context->GetGLVersion().c_str(),
237 context->GetGLRenderer().c_str());
211 } 238 }
212 239
213 void InitializeDebugGLBindingsGL() { 240 void InitializeDebugGLBindingsGL() {
214 g_driver_gl.InitializeDebugBindings(); 241 g_driver_gl.InitializeDebugBindings();
215 } 242 }
216 243
217 void InitializeNullDrawGLBindingsGL() { 244 void InitializeNullDrawGLBindingsGL() {
218 g_driver_gl.InitializeNullDrawBindings(); 245 g_driver_gl.InitializeNullDrawBindings();
219 } 246 }
220 247
221 void ClearGLBindingsGL() { 248 void ClearGLBindingsGL() {
222 if (g_real_gl) { 249 if (g_real_gl) {
223 delete g_real_gl; 250 delete g_real_gl;
224 g_real_gl = NULL; 251 g_real_gl = NULL;
225 } 252 }
226 if (g_trace_gl) { 253 if (g_trace_gl) {
227 delete g_trace_gl; 254 delete g_trace_gl;
228 g_trace_gl = NULL; 255 g_trace_gl = NULL;
229 } 256 }
230 g_gl = NULL; 257 g_gl = NULL;
231 g_driver_gl.ClearBindings(); 258 g_driver_gl.ClearBindings();
232 if (g_current_gl_context_tls) { 259 if (g_current_gl_context_tls) {
233 delete g_current_gl_context_tls; 260 delete g_current_gl_context_tls;
234 g_current_gl_context_tls = NULL; 261 g_current_gl_context_tls = NULL;
235 } 262 }
263 if (g_version_info) {
264 delete g_version_info;
265 g_version_info = NULL;
266 }
236 } 267 }
237 268
238 GLApi::GLApi() { 269 GLApi::GLApi() {
239 } 270 }
240 271
241 GLApi::~GLApi() { 272 GLApi::~GLApi() {
242 if (GetCurrentGLApi() == this) 273 if (GetCurrentGLApi() == this)
243 SetGLApi(NULL); 274 SetGLApi(NULL);
244 } 275 }
245 276
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) { 381 const GLubyte* VirtualGLApi::glGetStringFn(GLenum name) {
351 switch (name) { 382 switch (name) {
352 case GL_EXTENSIONS: 383 case GL_EXTENSIONS:
353 return reinterpret_cast<const GLubyte*>(extensions_.c_str()); 384 return reinterpret_cast<const GLubyte*>(extensions_.c_str());
354 default: 385 default:
355 return driver_->fn.glGetStringFn(name); 386 return driver_->fn.glGetStringFn(name);
356 } 387 }
357 } 388 }
358 389
359 } // namespace gfx 390 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698