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

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

Issue 18492005: Add GL_EXT_multisampled_render_to_texture support to command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: some cleanup Created 7 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 #include "gpu/command_buffer/service/framebuffer_manager.h" 5 #include "gpu/command_buffer/service/framebuffer_manager.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/renderbuffer_manager.h" 9 #include "gpu/command_buffer/service/renderbuffer_manager.h"
10 #include "gpu/command_buffer/service/texture_manager.h" 10 #include "gpu/command_buffer/service/texture_manager.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 private: 112 private:
113 scoped_refptr<Renderbuffer> renderbuffer_; 113 scoped_refptr<Renderbuffer> renderbuffer_;
114 114
115 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); 115 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
116 }; 116 };
117 117
118 class TextureAttachment 118 class TextureAttachment
119 : public Framebuffer::Attachment { 119 : public Framebuffer::Attachment {
120 public: 120 public:
121 TextureAttachment( 121 TextureAttachment(
122 TextureRef* texture_ref, GLenum target, GLint level) 122 TextureRef* texture_ref, GLenum target, GLint level, GLsizei samples)
123 : texture_ref_(texture_ref), 123 : texture_ref_(texture_ref),
124 target_(target), 124 target_(target),
125 level_(level) { 125 level_(level),
126 samples_(samples) {
126 } 127 }
127 128
128 virtual GLsizei width() const OVERRIDE { 129 virtual GLsizei width() const OVERRIDE {
129 GLsizei temp_width = 0; 130 GLsizei temp_width = 0;
130 GLsizei temp_height = 0; 131 GLsizei temp_height = 0;
131 texture_ref_->texture()->GetLevelSize( 132 texture_ref_->texture()->GetLevelSize(
132 target_, level_, &temp_width, &temp_height); 133 target_, level_, &temp_width, &temp_height);
133 return temp_width; 134 return temp_width;
134 } 135 }
135 136
136 virtual GLsizei height() const OVERRIDE { 137 virtual GLsizei height() const OVERRIDE {
137 GLsizei temp_width = 0; 138 GLsizei temp_width = 0;
138 GLsizei temp_height = 0; 139 GLsizei temp_height = 0;
139 texture_ref_->texture()->GetLevelSize( 140 texture_ref_->texture()->GetLevelSize(
140 target_, level_, &temp_width, &temp_height); 141 target_, level_, &temp_width, &temp_height);
141 return temp_height; 142 return temp_height;
142 } 143 }
143 144
144 virtual GLenum internal_format() const OVERRIDE { 145 virtual GLenum internal_format() const OVERRIDE {
145 GLenum temp_type = 0; 146 GLenum temp_type = 0;
146 GLenum temp_internal_format = 0; 147 GLenum temp_internal_format = 0;
147 texture_ref_->texture()->GetLevelType( 148 texture_ref_->texture()->GetLevelType(
148 target_, level_, &temp_type, &temp_internal_format); 149 target_, level_, &temp_type, &temp_internal_format);
149 return temp_internal_format; 150 return temp_internal_format;
150 } 151 }
151 152
152 virtual GLsizei samples() const OVERRIDE { 153 virtual GLsizei samples() const OVERRIDE {
153 return 0; 154 return samples_;
154 } 155 }
155 156
156 virtual GLuint object_name() const OVERRIDE { 157 virtual GLuint object_name() const OVERRIDE {
157 return texture_ref_->client_id(); 158 return texture_ref_->client_id();
158 } 159 }
159 160
160 virtual bool cleared() const OVERRIDE { 161 virtual bool cleared() const OVERRIDE {
161 return texture_ref_->texture()->IsLevelCleared(target_, level_); 162 return texture_ref_->texture()->IsLevelCleared(target_, level_);
162 } 163 }
163 164
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 texture_ref_.get(), target_, level_, signature); 213 texture_ref_.get(), target_, level_, signature);
213 } 214 }
214 215
215 protected: 216 protected:
216 virtual ~TextureAttachment() {} 217 virtual ~TextureAttachment() {}
217 218
218 private: 219 private:
219 scoped_refptr<TextureRef> texture_ref_; 220 scoped_refptr<TextureRef> texture_ref_;
220 GLenum target_; 221 GLenum target_;
221 GLint level_; 222 GLint level_;
223 GLsizei samples_;
222 224
223 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); 225 DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
224 }; 226 };
225 227
226 FramebufferManager::FramebufferManager( 228 FramebufferManager::FramebufferManager(
227 uint32 max_draw_buffers, uint32 max_color_attachments) 229 uint32 max_draw_buffers, uint32 max_color_attachments)
228 : framebuffer_state_change_count_(1), 230 : framebuffer_state_change_count_(1),
229 framebuffer_count_(0), 231 framebuffer_count_(0),
230 have_context_(true), 232 have_context_(true),
231 max_draw_buffers_(max_draw_buffers), 233 max_draw_buffers_(max_draw_buffers),
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
497 GLenum target, TextureRef* texture_ref) { 499 GLenum target, TextureRef* texture_ref) {
498 bool done; 500 bool done;
499 do { 501 do {
500 done = true; 502 done = true;
501 for (AttachmentMap::const_iterator it = attachments_.begin(); 503 for (AttachmentMap::const_iterator it = attachments_.begin();
502 it != attachments_.end(); ++it) { 504 it != attachments_.end(); ++it) {
503 Attachment* attachment = it->second.get(); 505 Attachment* attachment = it->second.get();
504 if (attachment->IsTexture(texture_ref)) { 506 if (attachment->IsTexture(texture_ref)) {
505 // TODO(gman): manually detach texture. 507 // TODO(gman): manually detach texture.
506 // glFramebufferTexture2DEXT(target, it->first, GL_TEXTURE_2D, 0, 0); 508 // glFramebufferTexture2DEXT(target, it->first, GL_TEXTURE_2D, 0, 0);
507 AttachTexture(it->first, NULL, GL_TEXTURE_2D, 0); 509 AttachTexture(it->first, NULL, GL_TEXTURE_2D, 0, 0);
508 done = false; 510 done = false;
509 break; 511 break;
510 } 512 }
511 } 513 }
512 } while (!done); 514 } while (!done);
513 } 515 }
514 516
515 Framebuffer* FramebufferManager::GetFramebuffer( 517 Framebuffer* FramebufferManager::GetFramebuffer(
516 GLuint client_id) { 518 GLuint client_id) {
517 FramebufferMap::iterator it = framebuffers_.find(client_id); 519 FramebufferMap::iterator it = framebuffers_.find(client_id);
(...skipping 17 matching lines...) Expand all
535 attachments_[attachment] = scoped_refptr<Attachment>( 537 attachments_[attachment] = scoped_refptr<Attachment>(
536 new RenderbufferAttachment(renderbuffer)); 538 new RenderbufferAttachment(renderbuffer));
537 } else { 539 } else {
538 attachments_.erase(attachment); 540 attachments_.erase(attachment);
539 } 541 }
540 framebuffer_complete_state_count_id_ = 0; 542 framebuffer_complete_state_count_id_ = 0;
541 } 543 }
542 544
543 void Framebuffer::AttachTexture( 545 void Framebuffer::AttachTexture(
544 GLenum attachment, TextureRef* texture_ref, GLenum target, 546 GLenum attachment, TextureRef* texture_ref, GLenum target,
545 GLint level) { 547 GLint level, GLsizei samples) {
546 const Attachment* a = GetAttachment(attachment); 548 const Attachment* a = GetAttachment(attachment);
547 if (a) 549 if (a)
548 a->DetachFromFramebuffer(); 550 a->DetachFromFramebuffer();
549 if (texture_ref) { 551 if (texture_ref) {
550 attachments_[attachment] = scoped_refptr<Attachment>( 552 attachments_[attachment] = scoped_refptr<Attachment>(
551 new TextureAttachment(texture_ref, target, level)); 553 new TextureAttachment(texture_ref, target, level, samples));
552 texture_ref->texture()->AttachToFramebuffer(); 554 texture_ref->texture()->AttachToFramebuffer();
553 } else { 555 } else {
554 attachments_.erase(attachment); 556 attachments_.erase(attachment);
555 } 557 }
556 framebuffer_complete_state_count_id_ = 0; 558 framebuffer_complete_state_count_id_ = 0;
557 } 559 }
558 560
559 const Framebuffer::Attachment* 561 const Framebuffer::Attachment*
560 Framebuffer::GetAttachment( 562 Framebuffer::GetAttachment(
561 GLenum attachment) const { 563 GLenum attachment) const {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 Framebuffer* framebuffer) { 602 Framebuffer* framebuffer) {
601 DCHECK(framebuffer); 603 DCHECK(framebuffer);
602 return framebuffer->framebuffer_complete_state_count_id() == 604 return framebuffer->framebuffer_complete_state_count_id() ==
603 framebuffer_state_change_count_; 605 framebuffer_state_change_count_;
604 } 606 }
605 607
606 } // namespace gles2 608 } // namespace gles2
607 } // namespace gpu 609 } // namespace gpu
608 610
609 611
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698