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

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

Issue 1747013: Changes the code to use separate ids namspaces... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 8 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 GLsizei size; 57 GLsizei size;
58 GLenum type; 58 GLenum type;
59 GLint location; 59 GLint location;
60 std::string name; 60 std::string name;
61 }; 61 };
62 62
63 typedef std::vector<UniformInfo> UniformInfoVector; 63 typedef std::vector<UniformInfo> UniformInfoVector;
64 typedef std::vector<VertexAttribInfo> AttribInfoVector; 64 typedef std::vector<VertexAttribInfo> AttribInfoVector;
65 typedef std::vector<int> SamplerIndices; 65 typedef std::vector<int> SamplerIndices;
66 66
67 explicit ProgramInfo(GLuint program_id) 67 explicit ProgramInfo(GLuint service_id)
68 : max_attrib_name_length_(0), 68 : max_attrib_name_length_(0),
69 max_uniform_name_length_(0), 69 max_uniform_name_length_(0),
70 program_id_(program_id) { 70 service_id_(service_id),
71 valid_(false) {
72 }
73
74 GLuint service_id() const {
75 return service_id_;
71 } 76 }
72 77
73 const SamplerIndices& sampler_indices() { 78 const SamplerIndices& sampler_indices() {
74 return sampler_indices_; 79 return sampler_indices_;
75 } 80 }
76 81
82 // Resets the program after an unsuccessful link.
83 void Reset();
84
85 // Updates the program info after a successful link.
77 void Update(); 86 void Update();
78 87
79 const AttribInfoVector& GetAttribInfos() const { 88 const AttribInfoVector& GetAttribInfos() const {
80 return attrib_infos_; 89 return attrib_infos_;
81 } 90 }
82 91
83 const VertexAttribInfo* GetAttribInfo(GLint index) const { 92 const VertexAttribInfo* GetAttribInfo(GLint index) const {
84 return (static_cast<size_t>(index) < attrib_infos_.size()) ? 93 return (static_cast<size_t>(index) < attrib_infos_.size()) ?
85 &attrib_infos_[index] : NULL; 94 &attrib_infos_[index] : NULL;
86 } 95 }
(...skipping 10 matching lines...) Expand all
97 106
98 // Gets the type of a uniform by location. 107 // Gets the type of a uniform by location.
99 bool GetUniformTypeByLocation(GLint location, GLenum* type) const; 108 bool GetUniformTypeByLocation(GLint location, GLenum* type) const;
100 109
101 // Sets the sampler values for a uniform. 110 // Sets the sampler values for a uniform.
102 // This is safe to call for any location. If the location is not 111 // This is safe to call for any location. If the location is not
103 // a sampler uniform nothing will happen. 112 // a sampler uniform nothing will happen.
104 bool SetSamplers(GLint location, GLsizei count, const GLint* value); 113 bool SetSamplers(GLint location, GLsizei count, const GLint* value);
105 114
106 bool IsDeleted() const { 115 bool IsDeleted() const {
107 return program_id_ == 0; 116 return service_id_ == 0;
108 } 117 }
109 118
110 void GetProgramiv(GLenum pname, GLint* params); 119 void GetProgramiv(GLenum pname, GLint* params);
111 120
121 bool IsValid() const {
122 return valid_;
123 }
124
112 private: 125 private:
113 friend class base::RefCounted<ProgramInfo>; 126 friend class base::RefCounted<ProgramInfo>;
114 friend class ProgramManager; 127 friend class ProgramManager;
115 128
116 ~ProgramInfo() { } 129 ~ProgramInfo() { }
117 130
118 void MarkAsDeleted() { 131 void MarkAsDeleted() {
119 program_id_ = 0; 132 service_id_ = 0;
120 } 133 }
121 134
122 const UniformInfo* AddUniformInfo( 135 const UniformInfo* AddUniformInfo(
123 GLsizei size, GLenum type, GLint location, const std::string& name); 136 GLsizei size, GLenum type, GLint location, const std::string& name);
124 137
125 GLsizei max_attrib_name_length_; 138 GLsizei max_attrib_name_length_;
126 139
127 AttribInfoVector attrib_infos_; 140 AttribInfoVector attrib_infos_;
128 141
129 GLsizei max_uniform_name_length_; 142 GLsizei max_uniform_name_length_;
130 143
131 // Uniform info by index. 144 // Uniform info by index.
132 UniformInfoVector uniform_infos_; 145 UniformInfoVector uniform_infos_;
133 146
134 // Uniform location to index. 147 // Uniform location to index.
135 std::vector<GLint> location_to_index_map_; 148 std::vector<GLint> location_to_index_map_;
136 149
137 // The indices of the uniforms that are samplers. 150 // The indices of the uniforms that are samplers.
138 SamplerIndices sampler_indices_; 151 SamplerIndices sampler_indices_;
139 152
140 // The program this ProgramInfo is tracking. 153 // The program this ProgramInfo is tracking.
141 GLuint program_id_; 154 GLuint service_id_;
155
156 // This is true if glLinkProgram was successful.
157 bool valid_;
142 }; 158 };
143 159
144 ProgramManager() { } 160 ProgramManager() { }
145 161
146 // Creates a new program info. 162 // Creates a new program info.
147 void CreateProgramInfo(GLuint program_id); 163 void CreateProgramInfo(GLuint client_id, GLuint service_id);
148 164
149 // Gets a program info 165 // Gets a program info
150 ProgramInfo* GetProgramInfo(GLuint program_id); 166 ProgramInfo* GetProgramInfo(GLuint client_id);
151 167
152 // Deletes the program info for the given program. 168 // Deletes the program info for the given program.
153 void RemoveProgramInfo(GLuint program_id); 169 void RemoveProgramInfo(GLuint client_id);
154 170
155 // Returns true if prefix is invalid for gl. 171 // Returns true if prefix is invalid for gl.
156 static bool IsInvalidPrefix(const char* name, size_t length); 172 static bool IsInvalidPrefix(const char* name, size_t length);
157 173
158 private: 174 private:
159 // Info for each "successfully linked" program by service side program Id. 175 // Info for each "successfully linked" program by service side program Id.
160 // TODO(gman): Choose a faster container. 176 // TODO(gman): Choose a faster container.
161 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; 177 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap;
162 ProgramInfoMap program_infos_; 178 ProgramInfoMap program_infos_;
163 179
164 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 180 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
165 }; 181 };
166 182
167 } // namespace gles2 183 } // namespace gles2
168 } // namespace gpu 184 } // namespace gpu
169 185
170 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 186 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
171 187
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.h ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698