diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 16:10:47 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 16:10:47 +0000 |
commit | 8f91d18facbb775f674ad6e63755c49801d9abab (patch) | |
tree | 85dcfeaa725f0d778fc6795d78245d075e0341ac /gpu | |
parent | 361123eaed6f0393ce79dcbc5ecc12e8e976d0ea (diff) | |
download | chromium_src-8f91d18facbb775f674ad6e63755c49801d9abab.zip chromium_src-8f91d18facbb775f674ad6e63755c49801d9abab.tar.gz chromium_src-8f91d18facbb775f674ad6e63755c49801d9abab.tar.bz2 |
Hook up with Angle shader translator backend.
Using the newly implemented Angle shader translator backend selection. Before, we ignore the translated text if we run on top of Angle due to the lack of a GLSL ES backend. Now we output GLSL ES source code and feed it to Angle instead of the original source code. This allows us to perform processing during translation, for example, long variable name mapping.
BUG=84753
TEST=conformance/glsl-conformance.html passes on Windows/Angle
Review URL: http://codereview.chromium.org/7108049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89003 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/shader_translator.cc | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc index c11dcbd..c46d995 100644 --- a/gpu/command_buffer/service/shader_translator.cc +++ b/gpu/command_buffer/service/shader_translator.cc @@ -91,7 +91,11 @@ bool ShaderTranslator::Init(ShShaderType shader_type, if (!InitializeShaderTranslator()) return false; - compiler_ = ShConstructCompiler(shader_type, shader_spec, resources); + ShShaderOutput shader_output = + implementation_is_glsl_es ? SH_ESSL_OUTPUT : SH_GLSL_OUTPUT; + + compiler_ = ShConstructCompiler( + shader_type, shader_spec, shader_output, resources); implementation_is_glsl_es_ = implementation_is_glsl_es; return compiler_ != NULL; } @@ -107,23 +111,12 @@ bool ShaderTranslator::Translate(const char* shader) { SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS | SH_MAP_LONG_VARIABLE_NAMES; if (ShCompile(compiler_, &shader, 1, compile_options)) { success = true; - if (!implementation_is_glsl_es_) { - // Get translated shader. - int obj_code_len = 0; - ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); - if (obj_code_len > 1) { - translated_shader_.reset(new char[obj_code_len]); - ShGetObjectCode(compiler_, translated_shader_.get()); - } - } else { - // Pass down the original shader's source rather than the - // compiler's output. TODO(kbr): once the shader compiler has a - // GLSL ES backend, use its output. - int shader_code_len = 1 + strlen(shader); - if (shader_code_len > 1) { - translated_shader_.reset(new char[shader_code_len]); - strncpy(translated_shader_.get(), shader, shader_code_len); - } + // Get translated shader. + int obj_code_len = 0; + ShGetInfo(compiler_, SH_OBJECT_CODE_LENGTH, &obj_code_len); + if (obj_code_len > 1) { + translated_shader_.reset(new char[obj_code_len]); + ShGetObjectCode(compiler_, translated_shader_.get()); } // Get info for attribs and uniforms. GetVariableInfo(compiler_, SH_ACTIVE_ATTRIBUTES, &attrib_map_); |