Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(85)

Side by Side Diff: gpu/command_buffer/service/framebuffer_manager.cc

Issue 2020473002: Check layer is valid for framebuffer 3D texture attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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(texture->target(), level_,
piman 2016/05/27 01:37:25 I think you need to take the attachment's target,
Zhenyao Mo 2016/05/27 12:44:35 Done. Added a unitttest to catch this bug.
248 &width, &height, &depth) &&
249 layer_ < depth);
250 }
251
241 bool ValidForAttachmentType(GLenum attachment_type, 252 bool ValidForAttachmentType(GLenum attachment_type,
242 ContextType context_type, 253 ContextType context_type,
243 uint32_t max_color_attachments) override { 254 uint32_t max_color_attachments) override {
244 GLenum type = 0; 255 GLenum type = 0;
245 GLenum internal_format = 0; 256 GLenum internal_format = 0;
246 if (!texture_ref_->texture()->GetLevelType( 257 if (!texture_ref_->texture()->GetLevelType(
247 target_, level_, &type, &internal_format)) { 258 target_, level_, &type, &internal_format)) {
248 return false; 259 return false;
249 } 260 }
250 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( 261 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType(
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 GLsizei height = -1; 581 GLsizei height = -1;
571 for (AttachmentMap::const_iterator it = attachments_.begin(); 582 for (AttachmentMap::const_iterator it = attachments_.begin();
572 it != attachments_.end(); ++it) { 583 it != attachments_.end(); ++it) {
573 GLenum attachment_type = it->first; 584 GLenum attachment_type = it->first;
574 Attachment* attachment = it->second.get(); 585 Attachment* attachment = it->second.get();
575 if (!attachment->ValidForAttachmentType(attachment_type, 586 if (!attachment->ValidForAttachmentType(attachment_type,
576 feature_info->context_type(), 587 feature_info->context_type(),
577 manager_->max_color_attachments_)) { 588 manager_->max_color_attachments_)) {
578 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 589 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
579 } 590 }
591 if (!attachment->IsLayerValid()) {
592 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
593 }
580 if (width < 0) { 594 if (width < 0) {
581 width = attachment->width(); 595 width = attachment->width();
582 height = attachment->height(); 596 height = attachment->height();
583 if (width == 0 || height == 0) { 597 if (width == 0 || height == 0) {
584 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 598 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
585 } 599 }
586 } else if (attachment->width() != width || attachment->height() != height) { 600 } else if (attachment->width() != width || attachment->height() != height) {
587 // Since DirectX doesn't allow attachments to be of different sizes, 601 // Since DirectX doesn't allow attachments to be of different sizes,
588 // even though ES3 allows it, it is still forbidden to ensure consistent 602 // even though ES3 allows it, it is still forbidden to ensure consistent
589 // behaviors across platforms. 603 // behaviors across platforms.
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 865
852 bool FramebufferManager::IsComplete( 866 bool FramebufferManager::IsComplete(
853 Framebuffer* framebuffer) { 867 Framebuffer* framebuffer) {
854 DCHECK(framebuffer); 868 DCHECK(framebuffer);
855 return framebuffer->framebuffer_complete_state_count_id() == 869 return framebuffer->framebuffer_complete_state_count_id() ==
856 framebuffer_state_change_count_; 870 framebuffer_state_change_count_;
857 } 871 }
858 872
859 } // namespace gles2 873 } // namespace gles2
860 } // namespace gpu 874 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/framebuffer_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698