| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 // Must be called once before using the translator object. | 67 // Must be called once before using the translator object. |
| 68 virtual bool Init( | 68 virtual bool Init( |
| 69 sh::GLenum shader_type, | 69 sh::GLenum shader_type, |
| 70 ShShaderSpec shader_spec, | 70 ShShaderSpec shader_spec, |
| 71 const ShBuiltInResources* resources, | 71 const ShBuiltInResources* resources, |
| 72 GlslImplementationType glsl_implementation_type, | 72 GlslImplementationType glsl_implementation_type, |
| 73 ShCompileOptions driver_bug_workarounds) = 0; | 73 ShCompileOptions driver_bug_workarounds) = 0; |
| 74 | 74 |
| 75 // Translates the given shader source. | 75 // Translates the given shader source. |
| 76 // Returns true if translation is successful, false otherwise. | 76 // Returns true if translation is successful, false otherwise. |
| 77 virtual bool Translate(const char* shader) = 0; | 77 // Always fill |info_log| if it's non-null. |
| 78 | 78 // Upon success, fill |translated_shader|, |attrib_map|, |uniform_map|, |
| 79 // The following functions return results from the last translation. | 79 // |varying_map|, and |name_map| if they are non-null. |
| 80 // The results are NULL/empty if the translation was unsuccessful. | 80 virtual bool Translate(const std::string& shader_source, |
| 81 // A valid info-log is always returned irrespective of whether translation | 81 std::string* info_log, |
| 82 // was successful or not. | 82 std::string* translated_shader, |
| 83 virtual const char* translated_shader() const = 0; | 83 VariableMap* attrib_map, |
| 84 virtual const char* info_log() const = 0; | 84 VariableMap* uniform_map, |
| 85 | 85 VariableMap* varying_map, |
| 86 virtual const VariableMap& attrib_map() const = 0; | 86 NameMap* name_map) const = 0; |
| 87 virtual const VariableMap& uniform_map() const = 0; | |
| 88 virtual const VariableMap& varying_map() const = 0; | |
| 89 virtual const NameMap& name_map() const = 0; | |
| 90 | 87 |
| 91 // Return a string that is unique for a specfic set of options that would | 88 // Return a string that is unique for a specfic set of options that would |
| 92 // possibly affect compilation. | 89 // possibly affect compilation. |
| 93 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0; | 90 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const = 0; |
| 94 | 91 |
| 95 protected: | 92 protected: |
| 96 virtual ~ShaderTranslatorInterface() {} | 93 virtual ~ShaderTranslatorInterface() {} |
| 97 }; | 94 }; |
| 98 | 95 |
| 99 // Implementation of ShaderTranslatorInterface | 96 // Implementation of ShaderTranslatorInterface |
| (...skipping 16 matching lines...) Expand all Loading... |
| 116 | 113 |
| 117 // Overridden from ShaderTranslatorInterface. | 114 // Overridden from ShaderTranslatorInterface. |
| 118 virtual bool Init( | 115 virtual bool Init( |
| 119 sh::GLenum shader_type, | 116 sh::GLenum shader_type, |
| 120 ShShaderSpec shader_spec, | 117 ShShaderSpec shader_spec, |
| 121 const ShBuiltInResources* resources, | 118 const ShBuiltInResources* resources, |
| 122 GlslImplementationType glsl_implementation_type, | 119 GlslImplementationType glsl_implementation_type, |
| 123 ShCompileOptions driver_bug_workarounds) OVERRIDE; | 120 ShCompileOptions driver_bug_workarounds) OVERRIDE; |
| 124 | 121 |
| 125 // Overridden from ShaderTranslatorInterface. | 122 // Overridden from ShaderTranslatorInterface. |
| 126 virtual bool Translate(const char* shader) OVERRIDE; | 123 virtual bool Translate(const std::string& shader_source, |
| 127 | 124 std::string* info_log, |
| 128 // Overridden from ShaderTranslatorInterface. | 125 std::string* translated_source, |
| 129 virtual const char* translated_shader() const OVERRIDE; | 126 VariableMap* attrib_map, |
| 130 virtual const char* info_log() const OVERRIDE; | 127 VariableMap* uniform_map, |
| 131 | 128 VariableMap* varying_map, |
| 132 // Overridden from ShaderTranslatorInterface. | 129 NameMap* name_map) const OVERRIDE; |
| 133 virtual const VariableMap& attrib_map() const OVERRIDE; | |
| 134 virtual const VariableMap& uniform_map() const OVERRIDE; | |
| 135 virtual const VariableMap& varying_map() const OVERRIDE; | |
| 136 virtual const NameMap& name_map() const OVERRIDE; | |
| 137 | 130 |
| 138 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const | 131 virtual std::string GetStringForOptionsThatWouldAffectCompilation() const |
| 139 OVERRIDE; | 132 OVERRIDE; |
| 140 | 133 |
| 141 void AddDestructionObserver(DestructionObserver* observer); | 134 void AddDestructionObserver(DestructionObserver* observer); |
| 142 void RemoveDestructionObserver(DestructionObserver* observer); | 135 void RemoveDestructionObserver(DestructionObserver* observer); |
| 143 | 136 |
| 144 private: | 137 private: |
| 145 friend class base::RefCounted<ShaderTranslator>; | 138 friend class base::RefCounted<ShaderTranslator>; |
| 146 | 139 |
| 147 virtual ~ShaderTranslator(); | 140 virtual ~ShaderTranslator(); |
| 148 void ClearResults(); | |
| 149 int GetCompileOptions() const; | 141 int GetCompileOptions() const; |
| 150 | 142 |
| 151 ShHandle compiler_; | 143 ShHandle compiler_; |
| 152 ShBuiltInResources compiler_options_; | 144 ShBuiltInResources compiler_options_; |
| 153 scoped_ptr<char[]> translated_shader_; | |
| 154 scoped_ptr<char[]> info_log_; | |
| 155 VariableMap attrib_map_; | |
| 156 VariableMap uniform_map_; | |
| 157 VariableMap varying_map_; | |
| 158 NameMap name_map_; | |
| 159 bool implementation_is_glsl_es_; | 145 bool implementation_is_glsl_es_; |
| 160 ShCompileOptions driver_bug_workarounds_; | 146 ShCompileOptions driver_bug_workarounds_; |
| 161 ObserverList<DestructionObserver> destruction_observers_; | 147 ObserverList<DestructionObserver> destruction_observers_; |
| 162 | 148 |
| 163 DISALLOW_COPY_AND_ASSIGN(ShaderTranslator); | 149 DISALLOW_COPY_AND_ASSIGN(ShaderTranslator); |
| 164 }; | 150 }; |
| 165 | 151 |
| 166 } // namespace gles2 | 152 } // namespace gles2 |
| 167 } // namespace gpu | 153 } // namespace gpu |
| 168 | 154 |
| 169 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ | 155 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ |
| 170 | 156 |
| OLD | NEW |