summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service/shader_translator.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/command_buffer/service/shader_translator.cc')
-rw-r--r--gpu/command_buffer/service/shader_translator.cc29
1 files changed, 16 insertions, 13 deletions
diff --git a/gpu/command_buffer/service/shader_translator.cc b/gpu/command_buffer/service/shader_translator.cc
index 5129bfc..f05c450 100644
--- a/gpu/command_buffer/service/shader_translator.cc
+++ b/gpu/command_buffer/service/shader_translator.cc
@@ -48,6 +48,9 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
case SH_ACTIVE_UNIFORMS:
ShGetInfo(compiler, SH_ACTIVE_UNIFORM_MAX_LENGTH, &name_len);
break;
+ case SH_VARYINGS:
+ ShGetInfo(compiler, SH_VARYING_MAX_LENGTH, &name_len);
+ break;
default: NOTREACHED();
}
ShGetInfo(compiler, SH_MAPPED_NAME_MAX_LENGTH, &mapped_name_len);
@@ -61,18 +64,11 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
ANGLEGetInfoType len = 0;
int size = 0;
ShDataType type = SH_NONE;
+ ShPrecisionType precision = SH_PRECISION_MEDIUMP;
- switch (var_type) {
- case SH_ACTIVE_ATTRIBUTES:
- ShGetActiveAttrib(
- compiler, i, &len, &size, &type, name.get(), mapped_name.get());
- break;
- case SH_ACTIVE_UNIFORMS:
- ShGetActiveUniform(
- compiler, i, &len, &size, &type, name.get(), mapped_name.get());
- break;
- default: NOTREACHED();
- }
+ ShGetVariableInfo(compiler, var_type, i,
+ &len, &size, &type, &precision,
+ name.get(), mapped_name.get());
// In theory we should CHECK(len <= name_len - 1) here, but ANGLE needs
// to handle long struct field name mapping before we can do this.
@@ -81,7 +77,7 @@ void GetVariableInfo(ShHandle compiler, ShShaderInfo var_type,
std::string name_string(name.get(), std::min(len, name_len - 1));
mapped_name.get()[mapped_name_len - 1] = '\0';
- ShaderTranslator::VariableInfo info(type, size, name_string);
+ ShaderTranslator::VariableInfo info(type, size, precision, name_string);
(*var_map)[mapped_name.get()] = info;
}
}
@@ -156,7 +152,7 @@ bool ShaderTranslator::Init(
int ShaderTranslator::GetCompileOptions() const {
int compile_options =
- SH_OBJECT_CODE | SH_ATTRIBUTES_UNIFORMS |
+ SH_OBJECT_CODE | SH_VARIABLES |
SH_MAP_LONG_VARIABLE_NAMES | SH_ENFORCE_PACKING_RESTRICTIONS |
SH_LIMIT_EXPRESSION_COMPLEXITY | SH_LIMIT_CALL_STACK_DEPTH;
@@ -190,6 +186,7 @@ bool ShaderTranslator::Translate(const char* shader) {
// Get info for attribs and uniforms.
GetVariableInfo(compiler_, SH_ACTIVE_ATTRIBUTES, &attrib_map_);
GetVariableInfo(compiler_, SH_ACTIVE_UNIFORMS, &uniform_map_);
+ GetVariableInfo(compiler_, SH_VARYINGS, &varying_map_);
// Get info for name hashing.
GetNameHashingInfo(compiler_, &name_map_);
}
@@ -281,6 +278,11 @@ ShaderTranslator::uniform_map() const {
return uniform_map_;
}
+const ShaderTranslatorInterface::VariableMap&
+ShaderTranslator::varying_map() const {
+ return varying_map_;
+}
+
const ShaderTranslatorInterface::NameMap&
ShaderTranslator::name_map() const {
return name_map_;
@@ -310,6 +312,7 @@ void ShaderTranslator::ClearResults() {
info_log_.reset();
attrib_map_.clear();
uniform_map_.clear();
+ varying_map_.clear();
name_map_.clear();
}