summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/shader_translator.cc
diff options
context:
space:
mode:
authorzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 00:18:08 +0000
committerzmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 00:18:08 +0000
commit5b6f52fae391c57efaedc0d4a359466760247d10 (patch)
tree3b2e81e1dee71605e722104ff6821522eb311b73 /gpu/command_buffer/service/shader_translator.cc
parent9400c64565586091f67d4131850fd0836b18b511 (diff)
downloadchromium_src-5b6f52fae391c57efaedc0d4a359466760247d10.zip
chromium_src-5b6f52fae391c57efaedc0d4a359466760247d10.tar.gz
chromium_src-5b6f52fae391c57efaedc0d4a359466760247d10.tar.bz2
Hook up shader long variable name mapping with GPU command buffer port.
shader long variable name mapping is implemented in Angle shader translator. We should hook up the feature with GPU command buffer so long names won't cause shader compile/link failure or crashes. BUG=84753 TEST=tree green, webgl's conformance/glsl-conformance.html and conformance/glsl-long-variable-names pass on all platforms (Mac/Win/Linux), gles2 conformance test suites run ok. Review URL: http://codereview.chromium.org/6969100 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87899 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/shader_translator.cc')
-rw-r--r--gpu/command_buffer/service/shader_translator.cc19
1 files changed, 12 insertions, 7 deletions
diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc
index 1ef73fc..c11dcbd 100644
--- a/gpu/command_buffer/service/shader_translator.cc
+++ b/gpu/command_buffer/service/shader_translator.cc
@@ -26,7 +26,7 @@ bool InitializeShaderTranslator() {
using gpu::gles2::ShaderTranslator;
void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
ShaderTranslator::VariableMap* var_map) {
- int name_len = 0;
+ int name_len = 0, mapped_name_len = 0;
switch (var_type) {
case SH_ACTIVE_ATTRIBUTES:
ShGetInfo(compiler, SH_ACTIVE_ATTRIBUTE_MAX_LENGTH, &name_len);
@@ -36,8 +36,10 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
break;
default: NOTREACHED();
}
- if (name_len <= 1) return;
+ ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mapped_name_len);
+ if (name_len <= 1 || mapped_name_len <= 1) return;
scoped_array<char> name(new char[name_len]);
+ scoped_array<char> mapped_name(new char[mapped_name_len]);
int num_vars = 0;
ShGetInfo(compiler, var_type, &num_vars);
@@ -47,16 +49,18 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
switch (var_type) {
case SH_ACTIVE_ATTRIBUTES:
- ShGetActiveAttrib(compiler, i, NULL, &size, &type, name.get(), NULL);
+ ShGetActiveAttrib(
+ compiler, i, NULL, &size, &type, name.get(), mapped_name.get());
break;
case SH_ACTIVE_UNIFORMS:
- ShGetActiveUniform(compiler, i, NULL, &size, &type, name.get(), NULL);
+ ShGetActiveUniform(
+ compiler, i, NULL, &size, &type, name.get(), mapped_name.get());
break;
default: NOTREACHED();
}
- ShaderTranslator::VariableInfo info(type, size);
- (*var_map)[name.get()] = info;
+ ShaderTranslator::VariableInfo info(type, size, name.get());
+ (*var_map)[mapped_name.get()] = info;
}
}
} // namespace
@@ -99,7 +103,8 @@ bool ShaderTranslator::Translate(const char* shader) {
ClearResults();
bool success = false;
- int compile_options = SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS;
+ int compile_options =
+ 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_) {