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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 bool Is3D() const override { return false; } | 92 bool Is3D() const override { return false; } |
93 | 93 |
94 bool CanRenderTo(const FeatureInfo*) const override { return true; } | 94 bool CanRenderTo(const FeatureInfo*) const override { return true; } |
95 | 95 |
96 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 96 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
97 // Nothing to do for renderbuffers. | 97 // Nothing to do for renderbuffers. |
98 } | 98 } |
99 | 99 |
| 100 bool IsLayerValid() const override { return true; } |
| 101 |
100 bool ValidForAttachmentType(GLenum attachment_type, | 102 bool ValidForAttachmentType(GLenum attachment_type, |
101 ContextType context_type, | 103 ContextType context_type, |
102 uint32_t max_color_attachments) override { | 104 uint32_t max_color_attachments) override { |
103 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( | 105 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( |
104 attachment_type, max_color_attachments); | 106 attachment_type, max_color_attachments); |
105 DCHECK_NE(0u, need); | 107 DCHECK_NE(0u, need); |
106 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format()); | 108 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format()); |
107 if (context_type == CONTEXT_TYPE_WEBGL1 && | 109 if (context_type == CONTEXT_TYPE_WEBGL1 && |
108 DetectWebGL1DepthStencilAttachmentConflicts(need, have)) | 110 DetectWebGL1DepthStencilAttachmentConflicts(need, have)) |
109 return false; | 111 return false; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 } | 233 } |
232 | 234 |
233 bool CanRenderTo(const FeatureInfo* feature_info) const override { | 235 bool CanRenderTo(const FeatureInfo* feature_info) const override { |
234 return texture_ref_->texture()->CanRenderTo(feature_info, level_); | 236 return texture_ref_->texture()->CanRenderTo(feature_info, level_); |
235 } | 237 } |
236 | 238 |
237 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { | 239 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { |
238 texture_ref_->texture()->DetachFromFramebuffer(); | 240 texture_ref_->texture()->DetachFromFramebuffer(); |
239 } | 241 } |
240 | 242 |
| 243 bool IsLayerValid() const override { |
| 244 Texture* texture = texture_ref_->texture(); |
| 245 DCHECK(texture); |
| 246 GLsizei width, height, depth; |
| 247 return (texture->GetLevelSize(target_, level_, &width, &height, &depth) && |
| 248 layer_ < depth); |
| 249 } |
| 250 |
241 bool ValidForAttachmentType(GLenum attachment_type, | 251 bool ValidForAttachmentType(GLenum attachment_type, |
242 ContextType context_type, | 252 ContextType context_type, |
243 uint32_t max_color_attachments) override { | 253 uint32_t max_color_attachments) override { |
244 GLenum type = 0; | 254 GLenum type = 0; |
245 GLenum internal_format = 0; | 255 GLenum internal_format = 0; |
246 if (!texture_ref_->texture()->GetLevelType( | 256 if (!texture_ref_->texture()->GetLevelType( |
247 target_, level_, &type, &internal_format)) { | 257 target_, level_, &type, &internal_format)) { |
248 return false; | 258 return false; |
249 } | 259 } |
250 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( | 260 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
570 GLsizei height = -1; | 580 GLsizei height = -1; |
571 for (AttachmentMap::const_iterator it = attachments_.begin(); | 581 for (AttachmentMap::const_iterator it = attachments_.begin(); |
572 it != attachments_.end(); ++it) { | 582 it != attachments_.end(); ++it) { |
573 GLenum attachment_type = it->first; | 583 GLenum attachment_type = it->first; |
574 Attachment* attachment = it->second.get(); | 584 Attachment* attachment = it->second.get(); |
575 if (!attachment->ValidForAttachmentType(attachment_type, | 585 if (!attachment->ValidForAttachmentType(attachment_type, |
576 feature_info->context_type(), | 586 feature_info->context_type(), |
577 manager_->max_color_attachments_)) { | 587 manager_->max_color_attachments_)) { |
578 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 588 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
579 } | 589 } |
| 590 if (!attachment->IsLayerValid()) { |
| 591 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
| 592 } |
580 if (width < 0) { | 593 if (width < 0) { |
581 width = attachment->width(); | 594 width = attachment->width(); |
582 height = attachment->height(); | 595 height = attachment->height(); |
583 if (width == 0 || height == 0) { | 596 if (width == 0 || height == 0) { |
584 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; | 597 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; |
585 } | 598 } |
586 } else if (attachment->width() != width || attachment->height() != height) { | 599 } else if (attachment->width() != width || attachment->height() != height) { |
587 // Since DirectX doesn't allow attachments to be of different sizes, | 600 // Since DirectX doesn't allow attachments to be of different sizes, |
588 // even though ES3 allows it, it is still forbidden to ensure consistent | 601 // even though ES3 allows it, it is still forbidden to ensure consistent |
589 // behaviors across platforms. | 602 // behaviors across platforms. |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 | 864 |
852 bool FramebufferManager::IsComplete( | 865 bool FramebufferManager::IsComplete( |
853 Framebuffer* framebuffer) { | 866 Framebuffer* framebuffer) { |
854 DCHECK(framebuffer); | 867 DCHECK(framebuffer); |
855 return framebuffer->framebuffer_complete_state_count_id() == | 868 return framebuffer->framebuffer_complete_state_count_id() == |
856 framebuffer_state_change_count_; | 869 framebuffer_state_change_count_; |
857 } | 870 } |
858 | 871 |
859 } // namespace gles2 | 872 } // namespace gles2 |
860 } // namespace gpu | 873 } // namespace gpu |
OLD | NEW |