| 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 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 } | 572 } |
| 573 | 573 |
| 574 GLenum Framebuffer::IsPossiblyComplete(const FeatureInfo* feature_info) const { | 574 GLenum Framebuffer::IsPossiblyComplete(const FeatureInfo* feature_info) const { |
| 575 if (attachments_.empty()) { | 575 if (attachments_.empty()) { |
| 576 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; | 576 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; |
| 577 } | 577 } |
| 578 | 578 |
| 579 GLsizei width = -1; | 579 GLsizei width = -1; |
| 580 GLsizei height = -1; | 580 GLsizei height = -1; |
| 581 GLsizei samples = -1; | 581 GLsizei samples = -1; |
| 582 const bool kSamplesMustMatch = |
| 583 feature_info->context_type() == CONTEXT_TYPE_WEBGL1 || |
| 584 feature_info->context_type() == CONTEXT_TYPE_WEBGL2 || |
| 585 !feature_info->feature_flags().chromium_framebuffer_mixed_samples; |
| 586 |
| 582 for (AttachmentMap::const_iterator it = attachments_.begin(); | 587 for (AttachmentMap::const_iterator it = attachments_.begin(); |
| 583 it != attachments_.end(); ++it) { | 588 it != attachments_.end(); ++it) { |
| 584 GLenum attachment_type = it->first; | 589 GLenum attachment_type = it->first; |
| 585 Attachment* attachment = it->second.get(); | 590 Attachment* attachment = it->second.get(); |
| 586 if (!attachment->ValidForAttachmentType(attachment_type, | 591 if (!attachment->ValidForAttachmentType(attachment_type, |
| 587 feature_info->context_type(), | 592 feature_info->context_type(), |
| 588 manager_->max_color_attachments_)) { | 593 manager_->max_color_attachments_)) { |
| 589 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 594 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 590 } | 595 } |
| 591 if (!attachment->IsLayerValid()) { | 596 if (!attachment->IsLayerValid()) { |
| 592 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 597 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 593 } | 598 } |
| 594 if (width < 0) { | 599 if (width < 0) { |
| 595 width = attachment->width(); | 600 width = attachment->width(); |
| 596 height = attachment->height(); | 601 height = attachment->height(); |
| 597 if (width == 0 || height == 0) { | 602 if (width == 0 || height == 0) { |
| 598 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 603 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 599 } | 604 } |
| 600 } else if (attachment->width() != width || attachment->height() != height) { | 605 } else if (attachment->width() != width || attachment->height() != height) { |
| 601 // Since DirectX doesn't allow attachments to be of different sizes, | 606 // Since DirectX doesn't allow attachments to be of different sizes, |
| 602 // even though ES3 allows it, it is still forbidden to ensure consistent | 607 // even though ES3 allows it, it is still forbidden to ensure consistent |
| 603 // behaviors across platforms. | 608 // behaviors across platforms. |
| 604 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; | 609 return GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT; |
| 605 } | 610 } |
| 606 if (samples < 0) { | 611 |
| 607 samples = attachment->samples(); | 612 if (kSamplesMustMatch) { |
| 608 } else if (attachment->samples() != samples) { | 613 if (samples < 0) { |
| 609 // It's possible that the specified samples isn't the actual samples a | 614 samples = attachment->samples(); |
| 610 // GL implementation uses, but we always return INCOMPLETE_MULTISAMPLE | 615 } else if (attachment->samples() != samples) { |
| 611 // here to ensure consistent behaviors across platforms. | 616 // It's possible that the specified samples isn't the actual samples a |
| 612 return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; | 617 // GL implementation uses, but we always return INCOMPLETE_MULTISAMPLE |
| 618 // here to ensure consistent behaviors across platforms. |
| 619 return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; |
| 620 } |
| 613 } | 621 } |
| 614 if (!attachment->CanRenderTo(feature_info)) { | 622 if (!attachment->CanRenderTo(feature_info)) { |
| 615 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 623 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 616 } | 624 } |
| 617 } | 625 } |
| 618 | 626 |
| 619 // This does not mean the framebuffer is actually complete. It just means our | 627 // This does not mean the framebuffer is actually complete. It just means our |
| 620 // checks passed. | 628 // checks passed. |
| 621 return GL_FRAMEBUFFER_COMPLETE; | 629 return GL_FRAMEBUFFER_COMPLETE; |
| 622 } | 630 } |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 881 |
| 874 bool FramebufferManager::IsComplete( | 882 bool FramebufferManager::IsComplete( |
| 875 Framebuffer* framebuffer) { | 883 Framebuffer* framebuffer) { |
| 876 DCHECK(framebuffer); | 884 DCHECK(framebuffer); |
| 877 return framebuffer->framebuffer_complete_state_count_id() == | 885 return framebuffer->framebuffer_complete_state_count_id() == |
| 878 framebuffer_state_change_count_; | 886 framebuffer_state_change_count_; |
| 879 } | 887 } |
| 880 | 888 |
| 881 } // namespace gles2 | 889 } // namespace gles2 |
| 882 } // namespace gpu | 890 } // namespace gpu |
| OLD | NEW |