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 58 matching lines...) Loading... |
69 bool cleared) override { | 69 bool cleared) override { |
70 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared); | 70 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared); |
71 } | 71 } |
72 | 72 |
73 bool IsTexture(TextureRef* /* texture */) const override { return false; } | 73 bool IsTexture(TextureRef* /* texture */) const override { return false; } |
74 | 74 |
75 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { | 75 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { |
76 return renderbuffer_.get() == renderbuffer; | 76 return renderbuffer_.get() == renderbuffer; |
77 } | 77 } |
78 | 78 |
| 79 bool IsAttachmentComplete(FeatureInfo* feature_info) const override { |
| 80 return true; |
| 81 } |
| 82 |
79 bool CanRenderTo() const override { return true; } | 83 bool CanRenderTo() const override { return true; } |
80 | 84 |
81 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 85 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
82 // Nothing to do for renderbuffers. | 86 // Nothing to do for renderbuffers. |
83 } | 87 } |
84 | 88 |
85 bool ValidForAttachmentType(GLenum attachment_type, | 89 bool ValidForAttachmentType(GLenum attachment_type, |
86 uint32 max_color_attachments) override { | 90 uint32 max_color_attachments) override { |
87 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( | 91 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( |
88 attachment_type, max_color_attachments); | 92 attachment_type, max_color_attachments); |
(...skipping 94 matching lines...) Loading... |
183 } | 187 } |
184 | 188 |
185 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { | 189 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { |
186 return false; | 190 return false; |
187 } | 191 } |
188 | 192 |
189 TextureRef* texture() const { | 193 TextureRef* texture() const { |
190 return texture_ref_.get(); | 194 return texture_ref_.get(); |
191 } | 195 } |
192 | 196 |
| 197 bool IsAttachmentComplete(FeatureInfo* feature_info) const override { |
| 198 return texture_ref_->texture()->IsTextureComplete(feature_info); |
| 199 } |
| 200 |
193 bool CanRenderTo() const override { | 201 bool CanRenderTo() const override { |
194 return texture_ref_->texture()->CanRenderTo(); | 202 return texture_ref_->texture()->CanRenderTo(); |
195 } | 203 } |
196 | 204 |
197 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 205 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
198 texture_ref_->texture()->DetachFromFramebuffer(); | 206 texture_ref_->texture()->DetachFromFramebuffer(); |
199 framebuffer->OnTextureRefDetached(texture_ref_.get()); | 207 framebuffer->OnTextureRefDetached(texture_ref_.get()); |
200 } | 208 } |
201 | 209 |
202 bool ValidForAttachmentType(GLenum attachment_type, | 210 bool ValidForAttachmentType(GLenum attachment_type, |
(...skipping 252 matching lines...) Loading... |
455 if (read_buffer_ == GL_NONE) | 463 if (read_buffer_ == GL_NONE) |
456 return 0; | 464 return 0; |
457 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); | 465 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); |
458 if (it == attachments_.end()) { | 466 if (it == attachments_.end()) { |
459 return 0; | 467 return 0; |
460 } | 468 } |
461 const Attachment* attachment = it->second.get(); | 469 const Attachment* attachment = it->second.get(); |
462 return attachment->texture_type(); | 470 return attachment->texture_type(); |
463 } | 471 } |
464 | 472 |
465 GLenum Framebuffer::IsPossiblyComplete() const { | 473 GLenum Framebuffer::IsPossiblyComplete(GLenum target, |
| 474 FeatureInfo* feature_info) const { |
466 if (attachments_.empty()) { | 475 if (attachments_.empty()) { |
467 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; | 476 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; |
468 } | 477 } |
469 | 478 |
470 GLsizei width = -1; | 479 GLsizei width = -1; |
471 GLsizei height = -1; | 480 GLsizei height = -1; |
472 for (AttachmentMap::const_iterator it = attachments_.begin(); | 481 for (AttachmentMap::const_iterator it = attachments_.begin(); |
473 it != attachments_.end(); ++it) { | 482 it != attachments_.end(); ++it) { |
474 GLenum attachment_type = it->first; | 483 GLenum attachment_type = it->first; |
475 Attachment* attachment = it->second.get(); | 484 Attachment* attachment = it->second.get(); |
476 if (!attachment->ValidForAttachmentType(attachment_type, | 485 if (!attachment->ValidForAttachmentType(attachment_type, |
477 manager_->max_color_attachments_)) { | 486 manager_->max_color_attachments_)) { |
478 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 487 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
479 } | 488 } |
480 if (width < 0) { | 489 if (width < 0) { |
481 width = attachment->width(); | 490 width = attachment->width(); |
482 height = attachment->height(); | 491 height = attachment->height(); |
483 if (width == 0 || height == 0) { | 492 if (width == 0 || height == 0) { |
484 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 493 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
485 } | 494 } |
486 } else if (manager_->context_type() != ContextGroup::CONTEXT_TYPE_WEBGL2) { | 495 } else if (manager_->context_type() != ContextGroup::CONTEXT_TYPE_WEBGL2) { |
487 // TODO(zmo): revisit this if we create ES3 contexts for clients other | 496 // TODO(zmo): revisit this if we create ES3 contexts for clients other |
488 // than WebGL 2. | 497 // than WebGL 2. |
489 if (attachment->width() != width || attachment->height() != height) { | 498 if (attachment->width() != width || attachment->height() != height) { |
490 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; | 499 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; |
491 } | 500 } |
492 } | 501 } |
493 | 502 |
494 if (!attachment->CanRenderTo()) { | 503 if (target != GL_READ_FRAMEBUFFER_EXT && !attachment->CanRenderTo()) { |
495 return GL_FRAMEBUFFER_UNSUPPORTED; | 504 return GL_FRAMEBUFFER_UNSUPPORTED; |
496 } | 505 } |
| 506 |
| 507 // See section 4.4.4 of the GLES3 spec. |
| 508 if (!attachment->IsAttachmentComplete(feature_info)) { |
| 509 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 510 } |
497 } | 511 } |
498 | 512 |
499 // This does not mean the framebuffer is actually complete. It just means our | 513 // This does not mean the framebuffer is actually complete. It just means our |
500 // checks passed. | 514 // checks passed. |
501 return GL_FRAMEBUFFER_COMPLETE; | 515 return GL_FRAMEBUFFER_COMPLETE; |
502 } | 516 } |
503 | 517 |
504 GLenum Framebuffer::GetStatus( | 518 GLenum Framebuffer::GetStatus( |
505 TextureManager* texture_manager, GLenum target) const { | 519 TextureManager* texture_manager, GLenum target) const { |
506 // Check if we have this combo already. | 520 // Check if we have this combo already. |
(...skipping 266 matching lines...) Loading... |
773 ++it) { | 787 ++it) { |
774 TextureDetachObserver* observer = *it; | 788 TextureDetachObserver* observer = *it; |
775 observer->OnTextureRefDetachedFromFramebuffer(texture); | 789 observer->OnTextureRefDetachedFromFramebuffer(texture); |
776 } | 790 } |
777 } | 791 } |
778 | 792 |
779 } // namespace gles2 | 793 } // namespace gles2 |
780 } // namespace gpu | 794 } // namespace gpu |
781 | 795 |
782 | 796 |
OLD | NEW |