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

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

Issue 1415763009: command_buffer: Make inactive bound fragment inputs reserve the location (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@binduniformlocation-reserve-location
Patch Set: Created 5 years, 1 month 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_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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 kUniformMatrix2x4f = 1 << 16, 59 kUniformMatrix2x4f = 1 << 16,
60 kUniformMatrix3x2f = 1 << 17, 60 kUniformMatrix3x2f = 1 << 17,
61 kUniformMatrix3x4f = 1 << 18, 61 kUniformMatrix3x4f = 1 << 18,
62 kUniformMatrix4x2f = 1 << 19, 62 kUniformMatrix4x2f = 1 << 19,
63 kUniformMatrix4x3f = 1 << 20, 63 kUniformMatrix4x3f = 1 << 20,
64 }; 64 };
65 struct FragmentInputInfo { 65 struct FragmentInputInfo {
66 FragmentInputInfo(GLenum _type, GLuint _location) 66 FragmentInputInfo(GLenum _type, GLuint _location)
67 : type(_type), location(_location) {} 67 : type(_type), location(_location) {}
68 FragmentInputInfo() : type(GL_NONE), location(0) {} 68 FragmentInputInfo() : type(GL_NONE), location(0) {}
69 bool IsValid() const { return type != GL_NONE; }
70 GLenum type; 69 GLenum type;
71 GLuint location; 70 GLuint location;
72 }; 71 };
73 72
74 struct UniformInfo { 73 struct UniformInfo {
75 UniformInfo(); 74 UniformInfo();
76 UniformInfo(const std::string& client_name, 75 UniformInfo(const std::string& client_name,
77 GLint client_location_base, 76 GLint client_location_base,
78 GLenum _type, 77 GLenum _type,
79 bool _is_array, 78 bool _is_array,
(...skipping 20 matching lines...) Expand all
100 type(_type), 99 type(_type),
101 location(_location), 100 location(_location),
102 name(_name) { 101 name(_name) {
103 } 102 }
104 GLsizei size; 103 GLsizei size;
105 GLenum type; 104 GLenum type;
106 GLint location; 105 GLint location;
107 std::string name; 106 std::string name;
108 }; 107 };
109 108
110 class UniformLocationEntry { 109 template <typename T>
110 class ShaderVariableLocationEntry {
111 public: 111 public:
112 UniformLocationEntry() : uniform_(nullptr), inactive_(false) {} 112 ShaderVariableLocationEntry()
113 bool IsUnused() const { return !uniform_ && !inactive_; } 113 : shader_variable_(nullptr), inactive_(false) {}
114 bool IsUnused() const { return !shader_variable_ && !inactive_; }
114 bool IsInactive() const { return inactive_; } 115 bool IsInactive() const { return inactive_; }
115 bool IsActive() const { return uniform_; } 116 bool IsActive() const { return shader_variable_; }
116 void SetInactive() { 117 void SetInactive() {
117 uniform_ = nullptr; 118 shader_variable_ = nullptr;
118 inactive_ = true; 119 inactive_ = true;
119 } 120 }
120 void SetActive(UniformInfo* uniform) { 121 void SetActive(T* shader_variable) {
121 uniform_ = uniform; 122 shader_variable_ = shader_variable;
122 inactive_ = false; 123 inactive_ = false;
123 } 124 }
124 const UniformInfo* uniform() const { 125 const T* shader_variable() const {
125 DCHECK(IsActive()); 126 DCHECK(IsActive());
126 return uniform_; 127 return shader_variable_;
127 } 128 }
128 UniformInfo* uniform() { 129 T* shader_variable() {
129 DCHECK(IsActive()); 130 DCHECK(IsActive());
130 return uniform_; 131 return shader_variable_;
131 } 132 }
132 133
133 private: 134 private:
134 UniformInfo* uniform_; // Pointer to uniform_info_ vector entry. 135 T* shader_variable_; // Pointer to *_info_ vector entry.
135 bool inactive_; 136 bool inactive_;
136 }; 137 };
137 138
138 typedef std::vector<UniformInfo> UniformInfoVector; 139 typedef std::vector<UniformInfo> UniformInfoVector;
139 typedef std::vector<UniformLocationEntry> UniformLocationVector; 140 typedef std::vector<ShaderVariableLocationEntry<UniformInfo>>
141 UniformLocationVector;
140 typedef std::vector<VertexAttrib> AttribInfoVector; 142 typedef std::vector<VertexAttrib> AttribInfoVector;
141 typedef std::vector<FragmentInputInfo> FragmentInputInfoVector; 143 typedef std::vector<FragmentInputInfo> FragmentInputInfoVector;
144 typedef std::vector<ShaderVariableLocationEntry<FragmentInputInfo>>
145 FragmentInputLocationVector;
142 typedef std::vector<int> SamplerIndices; 146 typedef std::vector<int> SamplerIndices;
143 typedef std::map<std::string, GLint> LocationMap; 147 typedef std::map<std::string, GLint> LocationMap;
144 typedef std::vector<std::string> StringVector; 148 typedef std::vector<std::string> StringVector;
145 149
146 Program(ProgramManager* manager, GLuint service_id); 150 Program(ProgramManager* manager, GLuint service_id);
147 151
148 GLuint service_id() const { 152 GLuint service_id() const {
149 return service_id_; 153 return service_id_;
150 } 154 }
151 155
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const std::string* GetUniformMappedName( 188 const std::string* GetUniformMappedName(
185 const std::string& original_name) const; 189 const std::string& original_name) const;
186 190
187 // If the hashed name is not found, return NULL. 191 // If the hashed name is not found, return NULL.
188 const std::string* GetOriginalNameFromHashedName( 192 const std::string* GetOriginalNameFromHashedName(
189 const std::string& hashed_name) const; 193 const std::string& hashed_name) const;
190 194
191 const FragmentInputInfo* GetFragmentInputInfoByFakeLocation( 195 const FragmentInputInfo* GetFragmentInputInfoByFakeLocation(
192 GLint fake_location) const; 196 GLint fake_location) const;
193 197
198 bool IsInactiveFragmentInputLocationByFakeLocation(GLint fake_location) const;
199
194 // Gets the fake location of a uniform by name. 200 // Gets the fake location of a uniform by name.
195 GLint GetUniformFakeLocation(const std::string& name) const; 201 GLint GetUniformFakeLocation(const std::string& name) const;
196 202
197 // Gets the UniformInfo of a uniform by location. 203 // Gets the UniformInfo of a uniform by location.
198 const UniformInfo* GetUniformInfoByFakeLocation( 204 const UniformInfo* GetUniformInfoByFakeLocation(
199 GLint fake_location, GLint* real_location, GLint* array_index) const; 205 GLint fake_location, GLint* real_location, GLint* array_index) const;
200 206
201 // Returns true if |fake_location| is a location for an inactive uniform, 207 // Returns true if |fake_location| is a location for an inactive uniform,
202 // -1 or bound, non-existing uniform. 208 // -1 or bound, non-existing uniform.
203 bool IsInactiveUniformLocationByFakeLocation(GLint fake_location) const; 209 bool IsInactiveUniformLocationByFakeLocation(GLint fake_location) const;
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 GLsizei max_uniform_name_length_; 425 GLsizei max_uniform_name_length_;
420 426
421 // Uniform info by index. 427 // Uniform info by index.
422 UniformInfoVector uniform_infos_; 428 UniformInfoVector uniform_infos_;
423 UniformLocationVector uniform_locations_; 429 UniformLocationVector uniform_locations_;
424 430
425 // The indices of the uniforms that are samplers. 431 // The indices of the uniforms that are samplers.
426 SamplerIndices sampler_indices_; 432 SamplerIndices sampler_indices_;
427 433
428 FragmentInputInfoVector fragment_input_infos_; 434 FragmentInputInfoVector fragment_input_infos_;
435 FragmentInputLocationVector fragment_input_locations_;
429 436
430 // The program this Program is tracking. 437 // The program this Program is tracking.
431 GLuint service_id_; 438 GLuint service_id_;
432 439
433 // Shaders by type of shader. 440 // Shaders by type of shader.
434 scoped_refptr<Shader> 441 scoped_refptr<Shader>
435 attached_shaders_[kMaxAttachedShaders]; 442 attached_shaders_[kMaxAttachedShaders];
436 443
437 // True if this program is marked as deleted. 444 // True if this program is marked as deleted.
438 bool deleted_; 445 bool deleted_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 }; 554 };
548 555
549 inline const FeatureInfo& Program::feature_info() const { 556 inline const FeatureInfo& Program::feature_info() const {
550 return *manager_->feature_info_.get(); 557 return *manager_->feature_info_.get();
551 } 558 }
552 559
553 } // namespace gles2 560 } // namespace gles2
554 } // namespace gpu 561 } // namespace gpu
555 562
556 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 563 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698