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

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

Issue 2142353002: Validate fbo color image format and fragment shader output variable type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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_FRAMEBUFFER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "gpu/command_buffer/service/context_group.h" 17 #include "gpu/command_buffer/service/context_group.h"
18 #include "gpu/command_buffer/service/gl_utils.h" 18 #include "gpu/command_buffer/service/gl_utils.h"
19 #include "gpu/command_buffer/service/shader_manager.h"
19 #include "gpu/gpu_export.h" 20 #include "gpu/gpu_export.h"
20 21
21 namespace gpu { 22 namespace gpu {
22 namespace gles2 { 23 namespace gles2 {
23 24
24 class FeatureInfo; 25 class FeatureInfo;
25 class FramebufferCompletenessCache; 26 class FramebufferCompletenessCache;
26 class FramebufferManager; 27 class FramebufferManager;
27 class Renderbuffer; 28 class Renderbuffer;
28 class RenderbufferManager; 29 class RenderbufferManager;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 174
174 GLenum GetDrawBuffer(GLenum draw_buffer) const; 175 GLenum GetDrawBuffer(GLenum draw_buffer) const;
175 176
176 void SetDrawBuffers(GLsizei n, const GLenum* bufs); 177 void SetDrawBuffers(GLsizei n, const GLenum* bufs);
177 178
178 // If a color buffer is attached to GL_COLOR_ATTACHMENTi, enable that 179 // If a color buffer is attached to GL_COLOR_ATTACHMENTi, enable that
179 // draw buffer for glClear(). 180 // draw buffer for glClear().
180 // Return true if the DrawBuffers() is actually called. 181 // Return true if the DrawBuffers() is actually called.
181 bool PrepareDrawBuffersForClear() const; 182 bool PrepareDrawBuffersForClear() const;
182 183
183 // Restore draw buffers states that have been changed in 184 // Restore draw buffers states that have been changed.
184 // PrepareDrawBuffersForClear(). 185 void RestoreDrawBuffers() const;
185 void RestoreDrawBuffersAfterClear() const;
186 186
187 // Return true if any draw buffers has an alpha channel. 187 // Return true if any draw buffers has an alpha channel.
188 bool HasAlphaMRT() const; 188 bool HasAlphaMRT() const;
189 189
190 // Return false if any two active color attachments have different internal 190 // Return false if any two active color attachments have different internal
191 // formats. 191 // formats.
192 bool HasSameInternalFormatsMRT() const; 192 bool HasSameInternalFormatsMRT() const;
193 193
194 void set_read_buffer(GLenum read_buffer) { 194 void set_read_buffer(GLenum read_buffer) {
195 read_buffer_ = read_buffer; 195 read_buffer_ = read_buffer;
196 } 196 }
197 197
198 GLenum read_buffer() const { 198 GLenum read_buffer() const {
199 return read_buffer_; 199 return read_buffer_;
200 } 200 }
201 201
202 const std::vector<ShaderVariableBaseType>& GetColorAttachmentBaseTypes(
203 ) const {
204 return color_attachment_base_types_;
205 }
206
202 private: 207 private:
203 friend class FramebufferManager; 208 friend class FramebufferManager;
204 friend class base::RefCounted<Framebuffer>; 209 friend class base::RefCounted<Framebuffer>;
205 210
206 ~Framebuffer(); 211 ~Framebuffer();
207 212
208 void MarkAsDeleted(); 213 void MarkAsDeleted();
209 214
210 void MarkAttachmentsAsCleared( 215 void MarkAttachmentsAsCleared(
211 RenderbufferManager* renderbuffer_manager, 216 RenderbufferManager* renderbuffer_manager,
212 TextureManager* texture_manager, 217 TextureManager* texture_manager,
213 bool cleared); 218 bool cleared);
214 219
215 void MarkAsComplete(unsigned state_id) { 220 void MarkAsComplete(unsigned state_id) {
221 UpdateColorAttachmentBaseTypes();
216 framebuffer_complete_state_count_id_ = state_id; 222 framebuffer_complete_state_count_id_ = state_id;
217 } 223 }
218 224
219 unsigned framebuffer_complete_state_count_id() const { 225 unsigned framebuffer_complete_state_count_id() const {
220 return framebuffer_complete_state_count_id_; 226 return framebuffer_complete_state_count_id_;
221 } 227 }
222 228
229 // Cache color attachments' base types (FLOAT, INT, UINT) for optimization
230 // purpose. If an attachment point has no image, it's set as UNDEFINED_TYPE.
231 // This call is only valid on a complete fbo.
232 void UpdateColorAttachmentBaseTypes();
233
234 void ResetColorAttachmentBaseTypes();
235
223 // The managers that owns this. 236 // The managers that owns this.
224 FramebufferManager* manager_; 237 FramebufferManager* manager_;
225 238
226 bool deleted_; 239 bool deleted_;
227 240
228 // Service side framebuffer id. 241 // Service side framebuffer id.
229 GLuint service_id_; 242 GLuint service_id_;
230 243
231 // Whether this framebuffer has ever been bound. 244 // Whether this framebuffer has ever been bound.
232 bool has_been_bound_; 245 bool has_been_bound_;
233 246
234 // state count when this framebuffer was last checked for completeness. 247 // state count when this framebuffer was last checked for completeness.
235 unsigned framebuffer_complete_state_count_id_; 248 unsigned framebuffer_complete_state_count_id_;
236 249
237 // A map of attachments. 250 // A map of attachments.
238 typedef base::hash_map<GLenum, scoped_refptr<Attachment> > AttachmentMap; 251 typedef base::hash_map<GLenum, scoped_refptr<Attachment> > AttachmentMap;
239 AttachmentMap attachments_; 252 AttachmentMap attachments_;
240 253
241 std::unique_ptr<GLenum[]> draw_buffers_; 254 std::unique_ptr<GLenum[]> draw_buffers_;
242 255
256 std::vector<ShaderVariableBaseType> color_attachment_base_types_;
257
243 GLenum read_buffer_; 258 GLenum read_buffer_;
244 259
245 DISALLOW_COPY_AND_ASSIGN(Framebuffer); 260 DISALLOW_COPY_AND_ASSIGN(Framebuffer);
246 }; 261 };
247 262
248 struct DecoderFramebufferState { 263 struct DecoderFramebufferState {
249 DecoderFramebufferState(); 264 DecoderFramebufferState();
250 ~DecoderFramebufferState(); 265 ~DecoderFramebufferState();
251 266
252 // State saved for clearing so we can clear render buffers and then 267 // State saved for clearing so we can clear render buffers and then
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 348
334 scoped_refptr<FramebufferCompletenessCache> framebuffer_combo_complete_cache_; 349 scoped_refptr<FramebufferCompletenessCache> framebuffer_combo_complete_cache_;
335 350
336 DISALLOW_COPY_AND_ASSIGN(FramebufferManager); 351 DISALLOW_COPY_AND_ASSIGN(FramebufferManager);
337 }; 352 };
338 353
339 } // namespace gles2 354 } // namespace gles2
340 } // namespace gpu 355 } // namespace gpu
341 356
342 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_ 357 #endif // GPU_COMMAND_BUFFER_SERVICE_FRAMEBUFFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698