Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: gpu/command_buffer/service/shader_translator.h

Issue 23441050: Add driver bug workaround for SH_INIT_GL_POSITION. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gpu/command_buffer/service/mocks.h ('k') | gpu/command_buffer/service/shader_translator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "gpu/gpu_export.h" 15 #include "gpu/gpu_export.h"
16 #include "third_party/angle_dx11/include/GLSLANG/ShaderLang.h" 16 #include "third_party/angle_dx11/include/GLSLANG/ShaderLang.h"
17 17
18 namespace gpu { 18 namespace gpu {
19 namespace gles2 { 19 namespace gles2 {
20 20
21 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just 21 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just
22 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation. 22 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation.
23 class ShaderTranslatorInterface { 23 class ShaderTranslatorInterface {
24 public: 24 public:
25 enum GlslImplementationType { 25 enum GlslImplementationType {
26 kGlsl, 26 kGlsl,
27 kGlslES 27 kGlslES
28 }; 28 };
29 29
30 enum GlslBuiltInFunctionBehavior {
31 kGlslBuiltInFunctionOriginal,
32 kGlslBuiltInFunctionEmulated
33 };
34
35 struct VariableInfo { 30 struct VariableInfo {
36 VariableInfo() 31 VariableInfo()
37 : type(0), 32 : type(0),
38 size(0), 33 size(0),
39 precision(SH_PRECISION_UNDEFINED), 34 precision(SH_PRECISION_UNDEFINED),
40 static_use(0) { 35 static_use(0) {
41 } 36 }
42 37
43 VariableInfo(int _type, int _size, int _precision, 38 VariableInfo(int _type, int _size, int _precision,
44 int _static_use, std::string _name) 39 int _static_use, std::string _name)
(...skipping 23 matching lines...) Expand all
68 // Mapping between hashed name and original name. 63 // Mapping between hashed name and original name.
69 typedef base::hash_map<std::string, std::string> NameMap; 64 typedef base::hash_map<std::string, std::string> NameMap;
70 65
71 // Initializes the translator. 66 // Initializes the translator.
72 // Must be called once before using the translator object. 67 // Must be called once before using the translator object.
73 virtual bool Init( 68 virtual bool Init(
74 ShShaderType shader_type, 69 ShShaderType shader_type,
75 ShShaderSpec shader_spec, 70 ShShaderSpec shader_spec,
76 const ShBuiltInResources* resources, 71 const ShBuiltInResources* resources,
77 GlslImplementationType glsl_implementation_type, 72 GlslImplementationType glsl_implementation_type,
78 GlslBuiltInFunctionBehavior glsl_built_in_function_behavior) = 0; 73 ShCompileOptions driver_bug_workarounds) = 0;
79 74
80 // Translates the given shader source. 75 // Translates the given shader source.
81 // Returns true if translation is successful, false otherwise. 76 // Returns true if translation is successful, false otherwise.
82 virtual bool Translate(const char* shader) = 0; 77 virtual bool Translate(const char* shader) = 0;
83 78
84 // The following functions return results from the last translation. 79 // The following functions return results from the last translation.
85 // The results are NULL/empty if the translation was unsuccessful. 80 // The results are NULL/empty if the translation was unsuccessful.
86 // A valid info-log is always returned irrespective of whether translation 81 // A valid info-log is always returned irrespective of whether translation
87 // was successful or not. 82 // was successful or not.
88 virtual const char* translated_shader() const = 0; 83 virtual const char* translated_shader() const = 0;
(...skipping 29 matching lines...) Expand all
118 }; 113 };
119 114
120 ShaderTranslator(); 115 ShaderTranslator();
121 116
122 // Overridden from ShaderTranslatorInterface. 117 // Overridden from ShaderTranslatorInterface.
123 virtual bool Init( 118 virtual bool Init(
124 ShShaderType shader_type, 119 ShShaderType shader_type,
125 ShShaderSpec shader_spec, 120 ShShaderSpec shader_spec,
126 const ShBuiltInResources* resources, 121 const ShBuiltInResources* resources,
127 GlslImplementationType glsl_implementation_type, 122 GlslImplementationType glsl_implementation_type,
128 GlslBuiltInFunctionBehavior glsl_built_in_function_behavior) OVERRIDE; 123 ShCompileOptions driver_bug_workarounds) OVERRIDE;
129 124
130 // Overridden from ShaderTranslatorInterface. 125 // Overridden from ShaderTranslatorInterface.
131 virtual bool Translate(const char* shader) OVERRIDE; 126 virtual bool Translate(const char* shader) OVERRIDE;
132 127
133 // Overridden from ShaderTranslatorInterface. 128 // Overridden from ShaderTranslatorInterface.
134 virtual const char* translated_shader() const OVERRIDE; 129 virtual const char* translated_shader() const OVERRIDE;
135 virtual const char* info_log() const OVERRIDE; 130 virtual const char* info_log() const OVERRIDE;
136 131
137 // Overridden from ShaderTranslatorInterface. 132 // Overridden from ShaderTranslatorInterface.
138 virtual const VariableMap& attrib_map() const OVERRIDE; 133 virtual const VariableMap& attrib_map() const OVERRIDE;
(...skipping 16 matching lines...) Expand all
155 150
156 ShHandle compiler_; 151 ShHandle compiler_;
157 ShBuiltInResources compiler_options_; 152 ShBuiltInResources compiler_options_;
158 scoped_ptr<char[]> translated_shader_; 153 scoped_ptr<char[]> translated_shader_;
159 scoped_ptr<char[]> info_log_; 154 scoped_ptr<char[]> info_log_;
160 VariableMap attrib_map_; 155 VariableMap attrib_map_;
161 VariableMap uniform_map_; 156 VariableMap uniform_map_;
162 VariableMap varying_map_; 157 VariableMap varying_map_;
163 NameMap name_map_; 158 NameMap name_map_;
164 bool implementation_is_glsl_es_; 159 bool implementation_is_glsl_es_;
165 bool needs_built_in_function_emulation_; 160 ShCompileOptions driver_bug_workarounds_;
166 ObserverList<DestructionObserver> destruction_observers_; 161 ObserverList<DestructionObserver> destruction_observers_;
167 162
168 DISALLOW_COPY_AND_ASSIGN(ShaderTranslator); 163 DISALLOW_COPY_AND_ASSIGN(ShaderTranslator);
169 }; 164 };
170 165
171 } // namespace gles2 166 } // namespace gles2
172 } // namespace gpu 167 } // namespace gpu
173 168
174 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ 169 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_
175 170
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/mocks.h ('k') | gpu/command_buffer/service/shader_translator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698