diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 00:51:34 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-12 00:51:34 +0000 |
commit | f57bb2865fa146140d27e64c68148b79724f2f35 (patch) | |
tree | 03becedc67abf8a12fb1970ccaa7b3bbca06b6b7 /gpu/command_buffer/service/shader_translator.h | |
parent | 339d6dd4d356d062365a9a1a1aaf17f42d5349d3 (diff) | |
download | chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.zip chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.tar.gz chromium_src-f57bb2865fa146140d27e64c68148b79724f2f35.tar.bz2 |
Use the shader translator to correct bad type information
returned by OpenGL drivers.
TEST=unit tests, ran OpenGL ES 2.0 conformance tests and ran WebGL conformance test. Things that used to fail now pass.
BUG=none
Review URL: http://codereview.chromium.org/4829001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65882 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service/shader_translator.h')
-rw-r--r-- | gpu/command_buffer/service/shader_translator.h | 56 |
1 files changed, 45 insertions, 11 deletions
diff --git a/gpu/command_buffer/service/shader_translator.h b/gpu/command_buffer/service/shader_translator.h index 5054972..852ee5f 100644 --- a/gpu/command_buffer/service/shader_translator.h +++ b/gpu/command_buffer/service/shader_translator.h @@ -16,35 +16,69 @@ namespace gpu { namespace gles2 { // Translates GLSL ES 2.0 shader to desktop GLSL shader. -class ShaderTranslator { +class ShaderTranslatorInterface { public: - ShaderTranslator(); - ~ShaderTranslator(); + virtual ~ShaderTranslatorInterface() { } // Initializes the translator. // Must be called once before using the translator object. - bool Init(ShShaderType shader_type, - ShShaderSpec shader_spec, - const ShBuiltInResources* resources); + virtual bool Init( + ShShaderType shader_type, + ShShaderSpec shader_spec, + const ShBuiltInResources* resources) = 0; + // Translates the given shader source. // Returns true if translation is successful, false otherwise. - bool Translate(const char* shader); + virtual bool Translate(const char* shader) = 0; // The following functions return results from the last translation. // The results are NULL/empty if the translation was unsuccessful. // A valid info-log is always returned irrespective of whether translation // was successful or not. - const char* translated_shader() { return translated_shader_.get(); } - const char* info_log() { return info_log_.get(); } + virtual const char* translated_shader() const = 0; + virtual const char* info_log() const = 0; struct VariableInfo { + VariableInfo() + : type(0), + size(0) { + } + VariableInfo(int _type, int _size) + : type(_type), + size(_size) { + } int type; int size; }; // Mapping between variable name and info. typedef std::map<std::string, VariableInfo> VariableMap; - const VariableMap& attrib_map() { return attrib_map_; } - const VariableMap& uniform_map() { return uniform_map_; } + virtual const VariableMap& attrib_map() const = 0; + virtual const VariableMap& uniform_map() const = 0; +}; + +// Implementation of ShaderTranslatorInterface +class ShaderTranslator : public ShaderTranslatorInterface { + public: + ShaderTranslator(); + ~ShaderTranslator(); + + // Overridden from ShaderTranslatorInterface. + virtual bool Init( + ShShaderType shader_type, + ShShaderSpec shader_spec, + const ShBuiltInResources* resources); + + // Overridden from ShaderTranslatorInterface. + virtual bool Translate(const char* shader); + + // Overridden from ShaderTranslatorInterface. + virtual const char* translated_shader() const { + return translated_shader_.get(); } + virtual const char* info_log() const { return info_log_.get(); } + + // Overridden from ShaderTranslatorInterface. + virtual const VariableMap& attrib_map() const { return attrib_map_; } + virtual const VariableMap& uniform_map() const { return uniform_map_; } private: void ClearResults(); |