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

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

Issue 1273693002: command_buffer: Use GLSL core version that matches the OpenGL version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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"
(...skipping 13 matching lines...) Expand all
24 typedef base::hash_map<std::string, sh::Varying> VaryingMap; 24 typedef base::hash_map<std::string, sh::Varying> VaryingMap;
25 // Mapping between hashed name and original name. 25 // Mapping between hashed name and original name.
26 typedef base::hash_map<std::string, std::string> NameMap; 26 typedef base::hash_map<std::string, std::string> NameMap;
27 27
28 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just 28 // Translates a GLSL ES 2.0 shader to desktop GLSL shader, or just
29 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation. 29 // validates GLSL ES 2.0 shaders on a true GLSL ES implementation.
30 class ShaderTranslatorInterface 30 class ShaderTranslatorInterface
31 : public base::RefCounted<ShaderTranslatorInterface> { 31 : public base::RefCounted<ShaderTranslatorInterface> {
32 public: 32 public:
33 ShaderTranslatorInterface() {} 33 ShaderTranslatorInterface() {}
34 enum GlslImplementationType {
35 kGlsl,
36 kGlslES
37 };
38 34
39 // Initializes the translator. 35 // Initializes the translator.
40 // Must be called once before using the translator object. 36 // Must be called once before using the translator object.
41 virtual bool Init( 37 virtual bool Init(sh::GLenum shader_type,
42 sh::GLenum shader_type, 38 ShShaderSpec shader_spec,
43 ShShaderSpec shader_spec, 39 const ShBuiltInResources* resources,
44 const ShBuiltInResources* resources, 40 ShShaderOutput shader_output_language,
45 GlslImplementationType glsl_implementation_type, 41 ShCompileOptions driver_bug_workarounds) = 0;
46 ShCompileOptions driver_bug_workarounds) = 0;
47 42
48 // Translates the given shader source. 43 // Translates the given shader source.
49 // Returns true if translation is successful, false otherwise. 44 // Returns true if translation is successful, false otherwise.
50 // Always fill |info_log| if it's non-null. 45 // Always fill |info_log| if it's non-null.
51 // Upon success, fill |translated_shader|, |attrib_map|, |uniform_map|, 46 // Upon success, fill |translated_shader|, |attrib_map|, |uniform_map|,
52 // |varying_map|, and |name_map| if they are non-null. 47 // |varying_map|, and |name_map| if they are non-null.
53 virtual bool Translate(const std::string& shader_source, 48 virtual bool Translate(const std::string& shader_source,
54 std::string* info_log, 49 std::string* info_log,
55 std::string* translated_shader, 50 std::string* translated_shader,
56 int* shader_version, 51 int* shader_version,
(...skipping 28 matching lines...) Expand all
85 private: 80 private:
86 DISALLOW_COPY_AND_ASSIGN(DestructionObserver); 81 DISALLOW_COPY_AND_ASSIGN(DestructionObserver);
87 }; 82 };
88 83
89 ShaderTranslator(); 84 ShaderTranslator();
90 85
91 // Overridden from ShaderTranslatorInterface. 86 // Overridden from ShaderTranslatorInterface.
92 bool Init(sh::GLenum shader_type, 87 bool Init(sh::GLenum shader_type,
93 ShShaderSpec shader_spec, 88 ShShaderSpec shader_spec,
94 const ShBuiltInResources* resources, 89 const ShBuiltInResources* resources,
95 GlslImplementationType glsl_implementation_type, 90 ShShaderOutput shader_output_language,
96 ShCompileOptions driver_bug_workarounds) override; 91 ShCompileOptions driver_bug_workarounds) override;
97 92
98 // Overridden from ShaderTranslatorInterface. 93 // Overridden from ShaderTranslatorInterface.
99 bool Translate(const std::string& shader_source, 94 bool Translate(const std::string& shader_source,
100 std::string* info_log, 95 std::string* info_log,
101 std::string* translated_source, 96 std::string* translated_source,
102 int* shader_version, 97 int* shader_version,
103 AttributeMap* attrib_map, 98 AttributeMap* attrib_map,
104 UniformMap* uniform_map, 99 UniformMap* uniform_map,
105 VaryingMap* varying_map, 100 VaryingMap* varying_map,
106 NameMap* name_map) const override; 101 NameMap* name_map) const override;
107 102
108 std::string GetStringForOptionsThatWouldAffectCompilation() const override; 103 std::string GetStringForOptionsThatWouldAffectCompilation() const override;
109 104
110 void AddDestructionObserver(DestructionObserver* observer); 105 void AddDestructionObserver(DestructionObserver* observer);
111 void RemoveDestructionObserver(DestructionObserver* observer); 106 void RemoveDestructionObserver(DestructionObserver* observer);
112 107
113 private: 108 private:
114 ~ShaderTranslator() override; 109 ~ShaderTranslator() override;
115 110
116 int GetCompileOptions() const; 111 int GetCompileOptions() const;
117 112
118 ShHandle compiler_; 113 ShHandle compiler_;
119 bool implementation_is_glsl_es_;
120 ShCompileOptions driver_bug_workarounds_; 114 ShCompileOptions driver_bug_workarounds_;
121 base::ObserverList<DestructionObserver> destruction_observers_; 115 base::ObserverList<DestructionObserver> destruction_observers_;
122 }; 116 };
123 117
124 } // namespace gles2 118 } // namespace gles2
125 } // namespace gpu 119 } // namespace gpu
126 120
127 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_ 121 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_TRANSLATOR_H_
128 122
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698