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

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

Issue 1673113002: Move WebGL1 attachment image type / attachment point matching check to command buffer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 13 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
14 #include "gpu/command_buffer/service/framebuffer_completeness_cache.h" 14 #include "gpu/command_buffer/service/framebuffer_completeness_cache.h"
15 #include "gpu/command_buffer/service/renderbuffer_manager.h" 15 #include "gpu/command_buffer/service/renderbuffer_manager.h"
16 #include "gpu/command_buffer/service/texture_manager.h" 16 #include "gpu/command_buffer/service/texture_manager.h"
17 #include "ui/gl/gl_bindings.h" 17 #include "ui/gl/gl_bindings.h"
18 18
19 namespace gpu { 19 namespace gpu {
20 namespace gles2 { 20 namespace gles2 {
21 21
22 namespace {
23
24 bool DetectWebGL1DepthStencilAttachmentConflicts(
25 uint32_t needed_channels, uint32_t channels) {
26 switch (needed_channels) {
27 case GLES2Util::kDepth:
28 case GLES2Util::kStencil:
29 case GLES2Util::kDepth | GLES2Util::kStencil:
30 return (needed_channels != channels);
31 default:
32 return false;
33 }
34 }
35
36 } // namespace anonymous
37
22 DecoderFramebufferState::DecoderFramebufferState() 38 DecoderFramebufferState::DecoderFramebufferState()
23 : clear_state_dirty(false), 39 : clear_state_dirty(false),
24 bound_read_framebuffer(NULL), 40 bound_read_framebuffer(NULL),
25 bound_draw_framebuffer(NULL) { 41 bound_draw_framebuffer(NULL) {
26 } 42 }
27 43
28 DecoderFramebufferState::~DecoderFramebufferState() { 44 DecoderFramebufferState::~DecoderFramebufferState() {
29 } 45 }
30 46
31 class RenderbufferAttachment 47 class RenderbufferAttachment
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return renderbuffer_.get() == renderbuffer; 83 return renderbuffer_.get() == renderbuffer;
68 } 84 }
69 85
70 bool CanRenderTo(const FeatureInfo*) const override { return true; } 86 bool CanRenderTo(const FeatureInfo*) const override { return true; }
71 87
72 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { 88 void DetachFromFramebuffer(Framebuffer* framebuffer) const override {
73 // Nothing to do for renderbuffers. 89 // Nothing to do for renderbuffers.
74 } 90 }
75 91
76 bool ValidForAttachmentType(GLenum attachment_type, 92 bool ValidForAttachmentType(GLenum attachment_type,
93 ContextType context_type,
77 uint32_t max_color_attachments) override { 94 uint32_t max_color_attachments) override {
78 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( 95 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType(
79 attachment_type, max_color_attachments); 96 attachment_type, max_color_attachments);
97 DCHECK_NE(0u, need);
80 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format()); 98 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format());
99 if (context_type == CONTEXT_TYPE_WEBGL1 &&
100 DetectWebGL1DepthStencilAttachmentConflicts(need, have))
101 return false;
81 return (need & have) != 0; 102 return (need & have) != 0;
82 } 103 }
83 104
84 Renderbuffer* renderbuffer() const { 105 Renderbuffer* renderbuffer() const {
85 return renderbuffer_.get(); 106 return renderbuffer_.get();
86 } 107 }
87 108
88 size_t GetSignatureSize(TextureManager* texture_manager) const override { 109 size_t GetSignatureSize(TextureManager* texture_manager) const override {
89 return renderbuffer_->GetSignatureSize(); 110 return renderbuffer_->GetSignatureSize();
90 } 111 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 206
186 bool CanRenderTo(const FeatureInfo* feature_info) const override { 207 bool CanRenderTo(const FeatureInfo* feature_info) const override {
187 return texture_ref_->texture()->CanRenderTo(feature_info, level_); 208 return texture_ref_->texture()->CanRenderTo(feature_info, level_);
188 } 209 }
189 210
190 void DetachFromFramebuffer(Framebuffer* framebuffer) const override { 211 void DetachFromFramebuffer(Framebuffer* framebuffer) const override {
191 texture_ref_->texture()->DetachFromFramebuffer(); 212 texture_ref_->texture()->DetachFromFramebuffer();
192 } 213 }
193 214
194 bool ValidForAttachmentType(GLenum attachment_type, 215 bool ValidForAttachmentType(GLenum attachment_type,
216 ContextType context_type,
195 uint32_t max_color_attachments) override { 217 uint32_t max_color_attachments) override {
196 GLenum type = 0; 218 GLenum type = 0;
197 GLenum internal_format = 0; 219 GLenum internal_format = 0;
198 if (!texture_ref_->texture()->GetLevelType( 220 if (!texture_ref_->texture()->GetLevelType(
199 target_, level_, &type, &internal_format)) { 221 target_, level_, &type, &internal_format)) {
200 return false; 222 return false;
201 } 223 }
202 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( 224 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType(
203 attachment_type, max_color_attachments); 225 attachment_type, max_color_attachments);
226 DCHECK_NE(0u, need);
204 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format); 227 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format);
205 228
206 // Workaround for NVIDIA drivers that incorrectly expose these formats as 229 // Workaround for NVIDIA drivers that incorrectly expose these formats as
207 // renderable: 230 // renderable:
208 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || 231 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA ||
209 internal_format == GL_LUMINANCE_ALPHA) { 232 internal_format == GL_LUMINANCE_ALPHA) {
210 return false; 233 return false;
211 } 234 }
235 if (context_type == CONTEXT_TYPE_WEBGL1 &&
236 DetectWebGL1DepthStencilAttachmentConflicts(need, have))
237 return need == have;
212 return (need & have) != 0; 238 return (need & have) != 0;
213 } 239 }
214 240
215 size_t GetSignatureSize(TextureManager* texture_manager) const override { 241 size_t GetSignatureSize(TextureManager* texture_manager) const override {
216 return texture_manager->GetSignatureSize(); 242 return texture_manager->GetSignatureSize();
217 } 243 }
218 244
219 void AddToSignature(TextureManager* texture_manager, 245 void AddToSignature(TextureManager* texture_manager,
220 std::string* signature) const override { 246 std::string* signature) const override {
221 DCHECK(signature); 247 DCHECK(signature);
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; 499 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
474 } 500 }
475 501
476 GLsizei width = -1; 502 GLsizei width = -1;
477 GLsizei height = -1; 503 GLsizei height = -1;
478 for (AttachmentMap::const_iterator it = attachments_.begin(); 504 for (AttachmentMap::const_iterator it = attachments_.begin();
479 it != attachments_.end(); ++it) { 505 it != attachments_.end(); ++it) {
480 GLenum attachment_type = it->first; 506 GLenum attachment_type = it->first;
481 Attachment* attachment = it->second.get(); 507 Attachment* attachment = it->second.get();
482 if (!attachment->ValidForAttachmentType(attachment_type, 508 if (!attachment->ValidForAttachmentType(attachment_type,
509 feature_info->context_type(),
483 manager_->max_color_attachments_)) { 510 manager_->max_color_attachments_)) {
484 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 511 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
485 } 512 }
486 if (width < 0) { 513 if (width < 0) {
487 width = attachment->width(); 514 width = attachment->width();
488 height = attachment->height(); 515 height = attachment->height();
489 if (width == 0 || height == 0) { 516 if (width == 0 || height == 0) {
490 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 517 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
491 } 518 }
492 } else if (attachment->width() != width || attachment->height() != height) { 519 } else if (attachment->width() != width || attachment->height() != height) {
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 784
758 bool FramebufferManager::IsComplete( 785 bool FramebufferManager::IsComplete(
759 Framebuffer* framebuffer) { 786 Framebuffer* framebuffer) {
760 DCHECK(framebuffer); 787 DCHECK(framebuffer);
761 return framebuffer->framebuffer_complete_state_count_id() == 788 return framebuffer->framebuffer_complete_state_count_id() ==
762 framebuffer_state_change_count_; 789 framebuffer_state_change_count_;
763 } 790 }
764 791
765 } // namespace gles2 792 } // namespace gles2
766 } // namespace gpu 793 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.h ('k') | gpu/command_buffer/service/gles2_cmd_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698