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

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

Issue 315283002: Framebuffer clear() needs to consider the situation some draw buffers are disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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) 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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 GLenum attachment) const { 353 GLenum attachment) const {
354 AttachmentMap::const_iterator it = 354 AttachmentMap::const_iterator it =
355 attachments_.find(attachment); 355 attachments_.find(attachment);
356 if (it != attachments_.end()) { 356 if (it != attachments_.end()) {
357 const Attachment* attachment = it->second.get(); 357 const Attachment* attachment = it->second.get();
358 return !attachment->cleared(); 358 return !attachment->cleared();
359 } 359 }
360 return false; 360 return false;
361 } 361 }
362 362
363 bool Framebuffer::HasUnclearedColorAttachments() const {
364 for (AttachmentMap::const_iterator it = attachments_.begin();
365 it != attachments_.end(); ++it) {
366 if (it->first >= GL_COLOR_ATTACHMENT0 &&
367 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) {
368 const Attachment* attachment = it->second.get();
369 if (!attachment->cleared())
370 return true;
371 }
372 }
373 return false;
374 }
375
376 void Framebuffer::ChangeDrawBuffersHelper(bool recover) const {
377 scoped_ptr<GLenum[]> buffers(new GLenum[manager_->max_draw_buffers_]);
378 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i)
379 buffers[i] = GL_NONE;
380 for (AttachmentMap::const_iterator it = attachments_.begin();
381 it != attachments_.end(); ++it) {
382 if (it->first >= GL_COLOR_ATTACHMENT0 &&
383 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) {
384 buffers[it->first - GL_COLOR_ATTACHMENT0] = it->first;
385 }
386 }
387 bool different = false;
388 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) {
389 if (buffers[i] != draw_buffers_[i]) {
390 different = true;
391 break;
392 }
393 }
394 if (different) {
395 if (recover)
396 glDrawBuffersARB(manager_->max_draw_buffers_, draw_buffers_.get());
397 else
398 glDrawBuffersARB(manager_->max_draw_buffers_, buffers.get());
399 }
400 }
401
402 void Framebuffer::PrepareDrawBuffersForClear() const {
403 bool recover = false;
404 ChangeDrawBuffersHelper(recover);
405 }
406
407 void Framebuffer::RestoreDrawBuffersAfterClear() const {
408 bool recover = true;
409 ChangeDrawBuffersHelper(recover);
410 }
411
363 void Framebuffer::MarkAttachmentAsCleared( 412 void Framebuffer::MarkAttachmentAsCleared(
364 RenderbufferManager* renderbuffer_manager, 413 RenderbufferManager* renderbuffer_manager,
365 TextureManager* texture_manager, 414 TextureManager* texture_manager,
366 GLenum attachment, 415 GLenum attachment,
367 bool cleared) { 416 bool cleared) {
368 AttachmentMap::iterator it = attachments_.find(attachment); 417 AttachmentMap::iterator it = attachments_.find(attachment);
369 if (it != attachments_.end()) { 418 if (it != attachments_.end()) {
370 Attachment* a = it->second.get(); 419 Attachment* a = it->second.get();
371 if (a->cleared() != cleared) { 420 if (a->cleared() != cleared) {
372 a->SetCleared(renderbuffer_manager, 421 a->SetCleared(renderbuffer_manager,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 index < static_cast<GLsizei>(manager_->max_draw_buffers_)); 558 index < static_cast<GLsizei>(manager_->max_draw_buffers_));
510 return draw_buffers_[index]; 559 return draw_buffers_[index];
511 } 560 }
512 561
513 void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) { 562 void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) {
514 DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_)); 563 DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_));
515 for (GLsizei i = 0; i < n; ++i) 564 for (GLsizei i = 0; i < n; ++i)
516 draw_buffers_[i] = bufs[i]; 565 draw_buffers_[i] = bufs[i];
517 } 566 }
518 567
568
569
519 bool Framebuffer::HasAlphaMRT() const { 570 bool Framebuffer::HasAlphaMRT() const {
520 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) { 571 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) {
521 if (draw_buffers_[i] != GL_NONE) { 572 if (draw_buffers_[i] != GL_NONE) {
522 const Attachment* attachment = GetAttachment(draw_buffers_[i]); 573 const Attachment* attachment = GetAttachment(draw_buffers_[i]);
523 if (!attachment) 574 if (!attachment)
524 continue; 575 continue;
525 if ((GLES2Util::GetChannelsForFormat( 576 if ((GLES2Util::GetChannelsForFormat(
526 attachment->internal_format()) & 0x0008) != 0) 577 attachment->internal_format()) & 0x0008) != 0)
527 return true; 578 return true;
528 } 579 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 ++it) { 735 ++it) {
685 TextureDetachObserver* observer = *it; 736 TextureDetachObserver* observer = *it;
686 observer->OnTextureRefDetachedFromFramebuffer(texture); 737 observer->OnTextureRefDetachedFromFramebuffer(texture);
687 } 738 }
688 } 739 }
689 740
690 } // namespace gles2 741 } // namespace gles2
691 } // namespace gpu 742 } // namespace gpu
692 743
693 744
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/framebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698