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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 bool IsTextureAttachment() const override { return false; } | 83 bool IsTextureAttachment() const override { return false; } |
84 bool IsRenderbufferAttachment() const override { return true; } | 84 bool IsRenderbufferAttachment() const override { return true; } |
85 | 85 |
86 bool IsTexture(TextureRef* /* texture */) const override { return false; } | 86 bool IsTexture(TextureRef* /* texture */) const override { return false; } |
87 | 87 |
88 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { | 88 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { |
89 return renderbuffer_.get() == renderbuffer; | 89 return renderbuffer_.get() == renderbuffer; |
90 } | 90 } |
91 | 91 |
| 92 bool IsSameAttachment(const Attachment* attachment) const override { |
| 93 if (attachment->IsRenderbufferAttachment()) { |
| 94 const RenderbufferAttachment* other = |
| 95 reinterpret_cast<const RenderbufferAttachment*>(attachment); |
| 96 return IsRenderbuffer(other->renderbuffer()); |
| 97 } |
| 98 return false; |
| 99 } |
| 100 |
92 bool Is3D() const override { return false; } | 101 bool Is3D() const override { return false; } |
93 | 102 |
94 bool CanRenderTo(const FeatureInfo*) const override { return true; } | 103 bool CanRenderTo(const FeatureInfo*) const override { return true; } |
95 | 104 |
96 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 105 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
97 // Nothing to do for renderbuffers. | 106 // Nothing to do for renderbuffers. |
98 } | 107 } |
99 | 108 |
100 bool IsLayerValid() const override { return true; } | 109 bool IsLayerValid() const override { return true; } |
101 | 110 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_); | 222 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_); |
214 } | 223 } |
215 | 224 |
216 bool IsTextureAttachment() const override { return true; } | 225 bool IsTextureAttachment() const override { return true; } |
217 bool IsRenderbufferAttachment() const override { return false; } | 226 bool IsRenderbufferAttachment() const override { return false; } |
218 | 227 |
219 bool IsTexture(TextureRef* texture) const override { | 228 bool IsTexture(TextureRef* texture) const override { |
220 return texture == texture_ref_.get(); | 229 return texture == texture_ref_.get(); |
221 } | 230 } |
222 | 231 |
| 232 bool IsSameAttachment(const Attachment* attachment) const override { |
| 233 if (attachment->IsTextureAttachment()) { |
| 234 const TextureAttachment* other = |
| 235 reinterpret_cast<const TextureAttachment*>(attachment); |
| 236 return IsTexture(other->texture()) && |
| 237 layer_ == other->layer() && |
| 238 target_ == other->target() && |
| 239 level_ == other->level(); |
| 240 } |
| 241 return false; |
| 242 } |
| 243 |
223 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { | 244 bool IsRenderbuffer(Renderbuffer* /* renderbuffer */) const override { |
224 return false; | 245 return false; |
225 } | 246 } |
226 | 247 |
227 bool Is3D() const override { | 248 bool Is3D() const override { |
228 return (target_ == GL_TEXTURE_3D || target_ == GL_TEXTURE_2D_ARRAY); | 249 return (target_ == GL_TEXTURE_3D || target_ == GL_TEXTURE_2D_ARRAY); |
229 } | 250 } |
230 | 251 |
231 TextureRef* texture() const { | 252 TextureRef* texture() const { |
232 return texture_ref_.get(); | 253 return texture_ref_.get(); |
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
704 } else if (attachment->samples() != samples) { | 725 } else if (attachment->samples() != samples) { |
705 // It's possible that the specified samples isn't the actual samples a | 726 // It's possible that the specified samples isn't the actual samples a |
706 // GL implementation uses, but we always return INCOMPLETE_MULTISAMPLE | 727 // GL implementation uses, but we always return INCOMPLETE_MULTISAMPLE |
707 // here to ensure consistent behaviors across platforms. | 728 // here to ensure consistent behaviors across platforms. |
708 return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; | 729 return GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE; |
709 } | 730 } |
710 } | 731 } |
711 if (!attachment->CanRenderTo(feature_info)) { | 732 if (!attachment->CanRenderTo(feature_info)) { |
712 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 733 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
713 } | 734 } |
| 735 |
| 736 // Attaching an image to more than one color attachment point should return |
| 737 // FRAMEBUFFER_UNSUPPORTED. |
| 738 if (it->first >= GL_COLOR_ATTACHMENT0 && |
| 739 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_color_attachments_) { |
| 740 for (GLenum i = it->first + 1; |
| 741 i < GL_COLOR_ATTACHMENT0 + manager_->max_color_attachments_; i++) { |
| 742 const Attachment* other = GetAttachment(i); |
| 743 if (other && attachment->IsSameAttachment(other)) { |
| 744 return GL_FRAMEBUFFER_UNSUPPORTED; |
| 745 } |
| 746 } |
| 747 } |
714 } | 748 } |
715 | 749 |
716 // This does not mean the framebuffer is actually complete. It just means our | 750 // This does not mean the framebuffer is actually complete. It just means our |
717 // checks passed. | 751 // checks passed. |
718 return GL_FRAMEBUFFER_COMPLETE; | 752 return GL_FRAMEBUFFER_COMPLETE; |
719 } | 753 } |
720 | 754 |
721 GLenum Framebuffer::GetStatus( | 755 GLenum Framebuffer::GetStatus( |
722 TextureManager* texture_manager, GLenum target) const { | 756 TextureManager* texture_manager, GLenum target) const { |
723 if (!manager_->GetFramebufferComboCompleteCache()) { | 757 if (!manager_->GetFramebufferComboCompleteCache()) { |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1038 |
1005 bool FramebufferManager::IsComplete( | 1039 bool FramebufferManager::IsComplete( |
1006 Framebuffer* framebuffer) { | 1040 Framebuffer* framebuffer) { |
1007 DCHECK(framebuffer); | 1041 DCHECK(framebuffer); |
1008 return framebuffer->framebuffer_complete_state_count_id() == | 1042 return framebuffer->framebuffer_complete_state_count_id() == |
1009 framebuffer_state_change_count_; | 1043 framebuffer_state_change_count_; |
1010 } | 1044 } |
1011 | 1045 |
1012 } // namespace gles2 | 1046 } // namespace gles2 |
1013 } // namespace gpu | 1047 } // namespace gpu |
OLD | NEW |