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_PROGRAM_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "gpu/command_buffer/service/common_decoder.h" | 14 #include "gpu/command_buffer/service/common_decoder.h" |
15 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
17 #include "gpu/command_buffer/service/shader_manager.h" | 17 #include "gpu/command_buffer/service/shader_manager.h" |
18 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
19 | 19 |
20 namespace gpu { | 20 namespace gpu { |
21 namespace gles2 { | 21 namespace gles2 { |
22 | 22 |
23 class ProgramCache; | 23 class ProgramCache; |
24 class ProgramManager; | 24 class ProgramManager; |
25 class Shader; | 25 class Shader; |
26 class ShaderManager; | 26 class ShaderManager; |
27 class ShaderTranslator; | |
28 | 27 |
29 // This is used to track which attributes a particular program needs | 28 // This is used to track which attributes a particular program needs |
30 // so we can verify at glDrawXXX time that every attribute is either disabled | 29 // so we can verify at glDrawXXX time that every attribute is either disabled |
31 // or if enabled that it points to a valid source. | 30 // or if enabled that it points to a valid source. |
32 class GPU_EXPORT Program : public base::RefCounted<Program> { | 31 class GPU_EXPORT Program : public base::RefCounted<Program> { |
33 public: | 32 public: |
34 static const int kMaxAttachedShaders = 2; | 33 static const int kMaxAttachedShaders = 2; |
35 | 34 |
36 enum VaryingsPackingOption { | 35 enum VaryingsPackingOption { |
37 kCountOnlyStaticallyUsed, | 36 kCountOnlyStaticallyUsed, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 GLint fake_location, GLint* real_location, GLint* array_index) const; | 145 GLint fake_location, GLint* real_location, GLint* array_index) const; |
147 | 146 |
148 // Gets all the program info. | 147 // Gets all the program info. |
149 void GetProgramInfo( | 148 void GetProgramInfo( |
150 ProgramManager* manager, CommonDecoder::Bucket* bucket) const; | 149 ProgramManager* manager, CommonDecoder::Bucket* bucket) const; |
151 | 150 |
152 // Gets all the UniformBlock info. | 151 // Gets all the UniformBlock info. |
153 // Return false on overflow. | 152 // Return false on overflow. |
154 bool GetUniformBlocks(CommonDecoder::Bucket* bucket) const; | 153 bool GetUniformBlocks(CommonDecoder::Bucket* bucket) const; |
155 | 154 |
| 155 // Gets all the TransformFeedbackVarying info. |
| 156 // Return false on overflow. |
| 157 bool GetTransformFeedbackVaryings(CommonDecoder::Bucket* bucket) const; |
| 158 |
| 159 // Gather all info through glGetActiveUniformsiv, except for size, type, |
| 160 // name_length, which we gather through glGetActiveUniform in |
| 161 // glGetProgramInfoCHROMIUM. |
| 162 bool GetUniformsES3(CommonDecoder::Bucket* bucket) const; |
| 163 |
156 // Sets the sampler values for a uniform. | 164 // Sets the sampler values for a uniform. |
157 // This is safe to call for any location. If the location is not | 165 // This is safe to call for any location. If the location is not |
158 // a sampler uniform nothing will happen. | 166 // a sampler uniform nothing will happen. |
159 // Returns false if fake_location is a sampler and any value | 167 // Returns false if fake_location is a sampler and any value |
160 // is >= num_texture_units. Returns true otherwise. | 168 // is >= num_texture_units. Returns true otherwise. |
161 bool SetSamplers( | 169 bool SetSamplers( |
162 GLint num_texture_units, GLint fake_location, | 170 GLint num_texture_units, GLint fake_location, |
163 GLsizei count, const GLint* value); | 171 GLsizei count, const GLint* value); |
164 | 172 |
165 bool IsDeleted() const { | 173 bool IsDeleted() const { |
166 return deleted_; | 174 return deleted_; |
167 } | 175 } |
168 | 176 |
169 void GetProgramiv(GLenum pname, GLint* params); | 177 void GetProgramiv(GLenum pname, GLint* params); |
170 | 178 |
171 bool IsValid() const { | 179 bool IsValid() const { |
172 return valid_; | 180 return valid_; |
173 } | 181 } |
174 | 182 |
175 bool AttachShader(ShaderManager* manager, Shader* shader); | 183 bool AttachShader(ShaderManager* manager, Shader* shader); |
176 bool DetachShader(ShaderManager* manager, Shader* shader); | 184 bool DetachShader(ShaderManager* manager, Shader* shader); |
177 | 185 |
| 186 void CompileAttachedShaders(); |
| 187 bool AttachedShadersExist() const; |
178 bool CanLink() const; | 188 bool CanLink() const; |
179 | 189 |
180 // Performs glLinkProgram and related activities. | 190 // Performs glLinkProgram and related activities. |
181 bool Link(ShaderManager* manager, | 191 bool Link(ShaderManager* manager, |
182 ShaderTranslator* vertex_translator, | |
183 ShaderTranslator* fragment_shader, | |
184 VaryingsPackingOption varyings_packing_option, | 192 VaryingsPackingOption varyings_packing_option, |
185 const ShaderCacheCallback& shader_callback); | 193 const ShaderCacheCallback& shader_callback); |
186 | 194 |
187 // Performs glValidateProgram and related activities. | 195 // Performs glValidateProgram and related activities. |
188 void Validate(); | 196 void Validate(); |
189 | 197 |
190 const std::string* log_info() const { | 198 const std::string* log_info() const { |
191 return log_info_.get(); | 199 return log_info_.get(); |
192 } | 200 } |
193 | 201 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 451 |
444 uint32 max_varying_vectors_; | 452 uint32 max_varying_vectors_; |
445 | 453 |
446 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 454 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
447 }; | 455 }; |
448 | 456 |
449 } // namespace gles2 | 457 } // namespace gles2 |
450 } // namespace gpu | 458 } // namespace gpu |
451 | 459 |
452 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 460 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
OLD | NEW |