| 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> |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 void SetAttribLocationBinding(const std::string& attrib, | 166 void SetAttribLocationBinding(const std::string& attrib, |
| 167 GLint location) { | 167 GLint location) { |
| 168 bind_attrib_location_map_[attrib] = location; | 168 bind_attrib_location_map_[attrib] = location; |
| 169 } | 169 } |
| 170 | 170 |
| 171 // Detects if there are attribute location conflicts from | 171 // Detects if there are attribute location conflicts from |
| 172 // glBindAttribLocation() calls. | 172 // glBindAttribLocation() calls. |
| 173 // We only consider the declared attributes in the program. | 173 // We only consider the declared attributes in the program. |
| 174 bool DetectAttribLocationBindingConflicts() const; | 174 bool DetectAttribLocationBindingConflicts() const; |
| 175 | 175 |
| 176 static inline GLint GetFakeLocation( | |
| 177 GLint fake_base_location, GLint element_index) { | |
| 178 return fake_base_location | element_index << 16; | |
| 179 } | |
| 180 | |
| 181 private: | 176 private: |
| 182 friend class base::RefCounted<ProgramInfo>; | 177 friend class base::RefCounted<ProgramInfo>; |
| 183 friend class ProgramManager; | 178 friend class ProgramManager; |
| 184 | 179 |
| 185 ~ProgramInfo(); | 180 ~ProgramInfo(); |
| 186 | 181 |
| 187 void set_log_info(const char* str) { | 182 void set_log_info(const char* str) { |
| 188 log_info_.reset(str ? new std::string(str) : NULL); | 183 log_info_.reset(str ? new std::string(str) : NULL); |
| 189 } | 184 } |
| 190 | 185 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 | 310 |
| 316 // Clears the uniforms for this program. | 311 // Clears the uniforms for this program. |
| 317 void ClearUniforms(ProgramInfo* info); | 312 void ClearUniforms(ProgramInfo* info); |
| 318 | 313 |
| 319 // Returns true if prefix is invalid for gl. | 314 // Returns true if prefix is invalid for gl. |
| 320 static bool IsInvalidPrefix(const char* name, size_t length); | 315 static bool IsInvalidPrefix(const char* name, size_t length); |
| 321 | 316 |
| 322 // Check if a ProgramInfo is owned by this ProgramManager. | 317 // Check if a ProgramInfo is owned by this ProgramManager. |
| 323 bool IsOwned(ProgramInfo* info); | 318 bool IsOwned(ProgramInfo* info); |
| 324 | 319 |
| 325 GLint SwizzleLocation(GLint unswizzled_location) const; | |
| 326 GLint UnswizzleLocation(GLint swizzled_location) const; | |
| 327 | |
| 328 private: | 320 private: |
| 329 void StartTracking(ProgramInfo* info); | 321 void StartTracking(ProgramInfo* info); |
| 330 void StopTracking(ProgramInfo* info); | 322 void StopTracking(ProgramInfo* info); |
| 331 | 323 |
| 332 // Info for each "successfully linked" program by service side program Id. | 324 // Info for each "successfully linked" program by service side program Id. |
| 333 // TODO(gman): Choose a faster container. | 325 // TODO(gman): Choose a faster container. |
| 334 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; | 326 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; |
| 335 ProgramInfoMap program_infos_; | 327 ProgramInfoMap program_infos_; |
| 336 | 328 |
| 337 int uniform_swizzle_; | |
| 338 | |
| 339 // Counts the number of ProgramInfo allocated with 'this' as its manager. | 329 // Counts the number of ProgramInfo allocated with 'this' as its manager. |
| 340 // Allows to check no ProgramInfo will outlive this. | 330 // Allows to check no ProgramInfo will outlive this. |
| 341 unsigned int program_info_count_; | 331 unsigned int program_info_count_; |
| 342 | 332 |
| 343 bool have_context_; | 333 bool have_context_; |
| 344 | 334 |
| 345 bool disable_workarounds_; | 335 bool disable_workarounds_; |
| 346 | 336 |
| 347 // Used to clear uniforms. | 337 // Used to clear uniforms. |
| 348 std::vector<uint8> zero_; | 338 std::vector<uint8> zero_; |
| 349 | 339 |
| 350 void RemoveProgramInfoIfUnused( | 340 void RemoveProgramInfoIfUnused( |
| 351 ShaderManager* shader_manager, ProgramInfo* info); | 341 ShaderManager* shader_manager, ProgramInfo* info); |
| 352 | 342 |
| 353 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 343 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
| 354 }; | 344 }; |
| 355 | 345 |
| 356 } // namespace gles2 | 346 } // namespace gles2 |
| 357 } // namespace gpu | 347 } // namespace gpu |
| 358 | 348 |
| 359 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 349 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |