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

Unified 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: Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gl/gl_context.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gl/gl_gl_api_implementation.cc
diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc
index ce8a711cdff0d0ba5ec55189599e4b2036604edb..f795862563cd250429cad3fa19ec7dda7ae023ba 100644
--- a/ui/gl/gl_gl_api_implementation.cc
+++ b/ui/gl/gl_gl_api_implementation.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include <vector>
+#include "base/at_exit.h"
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "ui/gl/gl_context.h"
@@ -14,6 +15,7 @@
#include "ui/gl/gl_state_restorer.h"
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_switches.h"
+#include "ui/gl/gl_version_info.h"
namespace gfx {
@@ -23,6 +25,8 @@ static GLApi* g_gl;
static RealGLApi* g_real_gl;
// A GL Api that calls TRACE and then calls another GL api.
static TraceGLApi* g_trace_gl;
+// GL version used when initializing dynamic bindings.
+static GLVersionInfo* g_version_info = NULL;
namespace {
@@ -40,8 +44,31 @@ static inline GLenum GetTexInternalFormat(GLenum internal_format,
GLenum type) {
GLenum gl_internal_format = GetInternalFormat(internal_format);
- if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2)
+ if (gfx::g_version_info && gfx::g_version_info->is_es) {
+ if (gfx::g_version_info->is_es3) {
piman 2014/01/21 22:37:12 I think we want to limit the amount of magic that
oetuaho-nv 2014/01/22 09:46:54 Traditionally in OpenGL, the mechanism for the cli
+ // Use sized internal formats from core ES3 to get support for rendering
no sievers 2014/01/21 22:21:13 Why is the format being renderable relevant in thi
oetuaho-nv 2014/01/22 09:46:54 When creating textures, it's better to choose a re
+ // to 32-bit float render targets using EXT_color_buffer_float. ES2
+ // extension is still relied on to provide the float LUMINANCE/ALPHA
+ // formats missing from ES3.
+ if (type == GL_FLOAT) {
+ switch(format) {
+ case GL_RGBA:
+ gl_internal_format = GL_RGBA32F;
+ break;
+ case GL_RGB:
+ gl_internal_format = GL_RGB32F;
+ break;
+ default:
+ break;
+ }
+ }
+ // GL_HALF_FLOAT_OES textures can be renderable with
no sievers 2014/01/21 22:21:13 same here
+ // EXT_color_buffer_half_float, GL_HALF_FLOAT textures would require
+ // EXT_color_buffer_float and similar enum conversions as above.
+ DCHECK(type != GL_HALF_FLOAT);
no sievers 2014/01/21 22:21:13 Does this compile? Isn't it GL_HALF_FLOAT_OES?
no sievers 2014/01/21 22:21:13 Don't we need to allow this? Looking at feature_in
oetuaho-nv 2014/01/22 09:46:54 Both of these enums exist, and have different valu
+ }
return gl_internal_format;
+ }
if (type == GL_FLOAT) {
switch (format) {
@@ -144,6 +171,13 @@ static void GL_BINDING_CALL CustomRenderbufferStorageMultisampleEXT(
target, samples, gl_internal_format, width, height);
}
+static void CleanupVersionInfo(void* unused) {
+ if (g_version_info) {
+ delete g_version_info;
+ g_version_info = NULL;
+ }
+}
+
} // anonymous namespace
void DriverGL::InitializeCustomDynamicBindings(GLContext* context) {
@@ -193,6 +227,9 @@ void SetGLToRealGLApi() {
void InitializeDynamicGLBindingsGL(GLContext* context) {
g_driver_gl.InitializeCustomDynamicBindings(context);
+ DCHECK(context && context->IsCurrent(NULL) && !g_version_info);
+ g_version_info = new GLVersionInfo(context->GetGLVersion().c_str());
+ base::AtExitManager::RegisterCallback(CleanupVersionInfo, NULL);
no sievers 2014/01/21 22:21:13 Hmm, are you doing this because we are actually no
oetuaho-nv 2014/01/22 09:46:54 Ah, I should have realized from the code that putt
}
void InitializeDebugGLBindingsGL() {
@@ -218,6 +255,7 @@ void ClearGLBindingsGL() {
delete g_current_gl_context_tls;
g_current_gl_context_tls = NULL;
}
+ CleanupVersionInfo(NULL);
}
GLApi::GLApi() {
« no previous file with comments | « ui/gl/gl_context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698