OLD | NEW |
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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
107 attachment_type, max_color_attachments); | 107 attachment_type, max_color_attachments); |
108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); | 108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); |
109 return (need & have) != 0; | 109 return (need & have) != 0; |
110 } | 110 } |
111 | 111 |
112 Renderbuffer* renderbuffer() const { | 112 Renderbuffer* renderbuffer() const { |
113 return renderbuffer_.get(); | 113 return renderbuffer_.get(); |
114 } | 114 } |
115 | 115 |
| 116 virtual size_t GetSignatureSize( |
| 117 TextureManager* texture_manager) const OVERRIDE { |
| 118 return renderbuffer_->GetSignatureSize(); |
| 119 } |
| 120 |
116 virtual void AddToSignature( | 121 virtual void AddToSignature( |
117 TextureManager* texture_manager, std::string* signature) const OVERRIDE { | 122 TextureManager* texture_manager, std::string* signature) const OVERRIDE { |
118 DCHECK(signature); | 123 DCHECK(signature); |
119 renderbuffer_->AddToSignature(signature); | 124 renderbuffer_->AddToSignature(signature); |
120 } | 125 } |
121 | 126 |
122 virtual void OnWillRenderTo() const OVERRIDE {} | 127 virtual void OnWillRenderTo() const OVERRIDE {} |
123 virtual void OnDidRenderTo() const OVERRIDE {} | 128 virtual void OnDidRenderTo() const OVERRIDE {} |
124 | 129 |
125 protected: | 130 protected: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 | 237 |
233 // Workaround for NVIDIA drivers that incorrectly expose these formats as | 238 // Workaround for NVIDIA drivers that incorrectly expose these formats as |
234 // renderable: | 239 // renderable: |
235 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || | 240 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || |
236 internal_format == GL_LUMINANCE_ALPHA) { | 241 internal_format == GL_LUMINANCE_ALPHA) { |
237 return false; | 242 return false; |
238 } | 243 } |
239 return (need & have) != 0; | 244 return (need & have) != 0; |
240 } | 245 } |
241 | 246 |
| 247 virtual size_t GetSignatureSize( |
| 248 TextureManager* texture_manager) const OVERRIDE { |
| 249 return texture_manager->GetSignatureSize(); |
| 250 } |
| 251 |
242 virtual void AddToSignature( | 252 virtual void AddToSignature( |
243 TextureManager* texture_manager, std::string* signature) const OVERRIDE { | 253 TextureManager* texture_manager, std::string* signature) const OVERRIDE { |
244 DCHECK(signature); | 254 DCHECK(signature); |
245 texture_manager->AddToSignature( | 255 texture_manager->AddToSignature( |
246 texture_ref_.get(), target_, level_, signature); | 256 texture_ref_.get(), target_, level_, signature); |
247 } | 257 } |
248 | 258 |
249 virtual void OnWillRenderTo() const OVERRIDE { | 259 virtual void OnWillRenderTo() const OVERRIDE { |
250 texture_ref_->texture()->OnWillModifyPixels(); | 260 texture_ref_->texture()->OnWillModifyPixels(); |
251 } | 261 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 // This does not mean the framebuffer is actually complete. It just means our | 511 // This does not mean the framebuffer is actually complete. It just means our |
502 // checks passed. | 512 // checks passed. |
503 return GL_FRAMEBUFFER_COMPLETE; | 513 return GL_FRAMEBUFFER_COMPLETE; |
504 } | 514 } |
505 | 515 |
506 GLenum Framebuffer::GetStatus( | 516 GLenum Framebuffer::GetStatus( |
507 TextureManager* texture_manager, GLenum target) const { | 517 TextureManager* texture_manager, GLenum target) const { |
508 // Check if we have this combo already. | 518 // Check if we have this combo already. |
509 std::string signature; | 519 std::string signature; |
510 if (allow_framebuffer_combo_complete_map_) { | 520 if (allow_framebuffer_combo_complete_map_) { |
511 signature = base::StringPrintf("|FBO|target=%04x", target); | 521 size_t signature_size = sizeof(target); |
512 for (AttachmentMap::const_iterator it = attachments_.begin(); | 522 for (AttachmentMap::const_iterator it = attachments_.begin(); |
513 it != attachments_.end(); ++it) { | 523 it != attachments_.end(); ++it) { |
514 Attachment* attachment = it->second.get(); | 524 Attachment* attachment = it->second.get(); |
515 signature += | 525 signature_size += sizeof(it->first) + |
516 base::StringPrintf("|Attachment|attachmentpoint=%04x", it->first); | 526 attachment->GetSignatureSize(texture_manager); |
| 527 } |
| 528 |
| 529 signature.reserve(signature_size); |
| 530 signature.append(reinterpret_cast<const char*>(&target), sizeof(target)); |
| 531 |
| 532 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 533 it != attachments_.end(); ++it) { |
| 534 Attachment* attachment = it->second.get(); |
| 535 signature.append(reinterpret_cast<const char*>(&it->first), |
| 536 sizeof(it->first)); |
517 attachment->AddToSignature(texture_manager, &signature); | 537 attachment->AddToSignature(texture_manager, &signature); |
518 } | 538 } |
| 539 DCHECK(signature.size() == signature_size); |
519 | 540 |
520 if (!framebuffer_combo_complete_map_) { | 541 if (!framebuffer_combo_complete_map_) { |
521 framebuffer_combo_complete_map_ = new FramebufferComboCompleteMap(); | 542 framebuffer_combo_complete_map_ = new FramebufferComboCompleteMap(); |
522 } | 543 } |
523 | 544 |
524 FramebufferComboCompleteMap::const_iterator it = | 545 FramebufferComboCompleteMap::const_iterator it = |
525 framebuffer_combo_complete_map_->find(signature); | 546 framebuffer_combo_complete_map_->find(signature); |
526 if (it != framebuffer_combo_complete_map_->end()) { | 547 if (it != framebuffer_combo_complete_map_->end()) { |
527 return GL_FRAMEBUFFER_COMPLETE; | 548 return GL_FRAMEBUFFER_COMPLETE; |
528 } | 549 } |
(...skipping 29 matching lines...) Expand all Loading... |
558 index < static_cast<GLsizei>(manager_->max_draw_buffers_)); | 579 index < static_cast<GLsizei>(manager_->max_draw_buffers_)); |
559 return draw_buffers_[index]; | 580 return draw_buffers_[index]; |
560 } | 581 } |
561 | 582 |
562 void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) { | 583 void Framebuffer::SetDrawBuffers(GLsizei n, const GLenum* bufs) { |
563 DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_)); | 584 DCHECK(n <= static_cast<GLsizei>(manager_->max_draw_buffers_)); |
564 for (GLsizei i = 0; i < n; ++i) | 585 for (GLsizei i = 0; i < n; ++i) |
565 draw_buffers_[i] = bufs[i]; | 586 draw_buffers_[i] = bufs[i]; |
566 } | 587 } |
567 | 588 |
568 | |
569 | |
570 bool Framebuffer::HasAlphaMRT() const { | 589 bool Framebuffer::HasAlphaMRT() const { |
571 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) { | 590 for (uint32 i = 0; i < manager_->max_draw_buffers_; ++i) { |
572 if (draw_buffers_[i] != GL_NONE) { | 591 if (draw_buffers_[i] != GL_NONE) { |
573 const Attachment* attachment = GetAttachment(draw_buffers_[i]); | 592 const Attachment* attachment = GetAttachment(draw_buffers_[i]); |
574 if (!attachment) | 593 if (!attachment) |
575 continue; | 594 continue; |
576 if ((GLES2Util::GetChannelsForFormat( | 595 if ((GLES2Util::GetChannelsForFormat( |
577 attachment->internal_format()) & 0x0008) != 0) | 596 attachment->internal_format()) & 0x0008) != 0) |
578 return true; | 597 return true; |
579 } | 598 } |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
735 ++it) { | 754 ++it) { |
736 TextureDetachObserver* observer = *it; | 755 TextureDetachObserver* observer = *it; |
737 observer->OnTextureRefDetachedFromFramebuffer(texture); | 756 observer->OnTextureRefDetachedFromFramebuffer(texture); |
738 } | 757 } |
739 } | 758 } |
740 | 759 |
741 } // namespace gles2 | 760 } // namespace gles2 |
742 } // namespace gpu | 761 } // namespace gpu |
743 | 762 |
744 | 763 |
OLD | NEW |