summaryrefslogtreecommitdiffstats
path: root/gpu
diff options
context:
space:
mode:
authoralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 21:09:41 +0000
committeralokp@chromium.org <alokp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-23 21:09:41 +0000
commitde17df394566479ee97d8871e1da5458b92935a3 (patch)
tree4ee107158e3b2d7d61b105b24e1e8d721a5169f3 /gpu
parent4551ba276ce0cbbed9a3e73bb4a778bc78f771e8 (diff)
downloadchromium_src-de17df394566479ee97d8871e1da5458b92935a3.zip
chromium_src-de17df394566479ee97d8871e1da5458b92935a3.tar.gz
chromium_src-de17df394566479ee97d8871e1da5458b92935a3.tar.bz2
Integrated glsl translator with command-buffer service.
Review URL: http://codereview.chromium.org/1773001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc68
-rw-r--r--gpu/gpu.gyp9
2 files changed, 71 insertions, 6 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index 8c07362..b005e512 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -32,6 +32,13 @@
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/command_buffer/service/texture_manager.h"
+// TODO(alokp): Remove GLES2_GPU_SERVICE_TRANSLATE_SHADER guard
+// as soon as translator is ready.
+//#define GLES2_GPU_SERVICE_TRANSLATE_SHADER
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
+#include "third_party/angleproject/include/GLSLANG/ShaderLang.h"
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
+
#if !defined(GL_DEPTH24_STENCIL8)
#define GL_DEPTH24_STENCIL8 0x88F0
#endif
@@ -1288,7 +1295,16 @@ bool GLES2DecoderImpl::Initialize(gfx::GLContext* context,
// isn't well documented; it was discovered in the Khronos OpenGL ES
// mailing list archives.
glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
-#endif
+
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
+ // Initialize GLSL ES to GLSL translator.
+ if (!ShInitialize()) {
+ DLOG(ERROR) << "Could not initialize GLSL translator.";
+ Destroy();
+ return false;
+ }
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
+#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
return true;
}
@@ -1644,6 +1660,13 @@ void GLES2DecoderImpl::Destroy() {
default_context_->Destroy();
default_context_.reset();
}
+
+#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
+ // Terminate GLSL translator.
+ ShFinalize();
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
+#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
}
void GLES2DecoderImpl::ResizeOffscreenFrameBuffer(const gfx::Size& size) {
@@ -2524,12 +2547,45 @@ void GLES2DecoderImpl::DoCompileShader(GLuint shader) {
SetGLError(GL_INVALID_OPERATION);
return;
}
- // TODO(gman): Run shader through compiler that converts GL ES 2.0 shader
- // to DesktopGL shader and pass that to glShaderSource and then
- // glCompileShader.
- const char* ptr = info->source().c_str();
- glShaderSource(shader, 1, &ptr, NULL);
+
+ // Translate GL ES 2.0 shader to Desktop GL shader and pass that to
+ // glShaderSource and then glCompileShader.
+ const char* shader_src = info->source().c_str();
+#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+#if defined(GLES2_GPU_SERVICE_TRANSLATE_SHADER)
+ int dbg_options = 0;
+ EShLanguage language = EShLangVertex;
+ TBuiltInResource resources;
+ // TODO(alokp): Ask gman how to get appropriate values.
+ resources.maxVertexAttribs = 8;
+ resources.maxVertexUniformVectors = 128;
+ resources.maxVaryingVectors = 8;
+ resources.maxVertexTextureImageUnits = 0;
+ resources.maxCombinedTextureImageUnits = 8;
+ resources.maxTextureImageUnits = 8;
+ resources.maxFragmentUniformVectors = 16;
+ resources.maxDrawBuffers = 1;
+ ShHandle compiler = ShConstructCompiler(language, dbg_options);
+ if (!ShCompile(compiler, &shader_src, 1, EShOptNone, &resources,
+ dbg_options)) {
+ // TODO(alokp): Ask gman where to set compile-status and info-log.
+ // May be add member variables to ShaderManager::ShaderInfo?
+ const char* info_log = ShGetInfoLog(compiler);
+ ShDestruct(compiler);
+ return;
+ }
+ shader_src = ShGetObjectCode(compiler);
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
+#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
+
+ glShaderSource(shader, 1, &shader_src, NULL);
glCompileShader(shader);
+
+#if !defined(GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2)
+#ifdef GLES2_GPU_SERVICE_TRANSLATE_SHADER
+ ShDestruct(compiler);
+#endif // GLES2_GPU_SERVICE_TRANSLATE_SHADER
+#endif // GLES2_GPU_SERVICE_BACKEND_NATIVE_GLES2
};
void GLES2DecoderImpl::DoGetShaderiv(
diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp
index d270126..d6a1ea4 100644
--- a/gpu/gpu.gyp
+++ b/gpu/gpu.gyp
@@ -289,6 +289,15 @@
],
},
],
+ #TODO(alokp): Remove os-conditional when translator_glsl starts
+ #compiling on all platforms.
+ ['OS == "win"',
+ {
+ 'dependencies': [
+ '../third_party/angleproject/src/build_angle.gyp:translator_glsl',
+ ],
+ },
+ ],
],
},
{