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

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

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix extension names that are a substring of another name in FeatureInfo Created 6 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 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/feature_info.h"
9 #include "gpu/command_buffer/service/renderbuffer_manager.h" 10 #include "gpu/command_buffer/service/renderbuffer_manager.h"
10 #include "gpu/command_buffer/service/texture_manager.h" 11 #include "gpu/command_buffer/service/texture_manager.h"
11 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
12 13
13 namespace gpu { 14 namespace gpu {
14 namespace gles2 { 15 namespace gles2 {
15 16
16 DecoderFramebufferState::DecoderFramebufferState() 17 DecoderFramebufferState::DecoderFramebufferState()
17 : clear_state_dirty(false), 18 : clear_state_dirty(false),
18 bound_read_framebuffer(NULL), 19 bound_read_framebuffer(NULL),
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 96
96 virtual bool CanRenderTo() const OVERRIDE { 97 virtual bool CanRenderTo() const OVERRIDE {
97 return true; 98 return true;
98 } 99 }
99 100
100 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const OVERRIDE { 101 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const OVERRIDE {
101 // Nothing to do for renderbuffers. 102 // Nothing to do for renderbuffers.
102 } 103 }
103 104
104 virtual bool ValidForAttachmentType( 105 virtual bool ValidForAttachmentType(
105 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { 106 GLenum attachment_type, uint32 max_color_attachments,
107 const FeatureInfo*) OVERRIDE {
106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( 108 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
107 attachment_type, max_color_attachments); 109 attachment_type, max_color_attachments);
108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); 110 uint32 have = GLES2Util::GetChannelsForFormat(internal_format());
109 return (need & have) != 0; 111 return (need & have) != 0;
110 } 112 }
111 113
112 Renderbuffer* renderbuffer() const { 114 Renderbuffer* renderbuffer() const {
113 return renderbuffer_.get(); 115 return renderbuffer_.get();
114 } 116 }
115 117
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return texture_ref_->texture()->CanRenderTo(); 211 return texture_ref_->texture()->CanRenderTo();
210 } 212 }
211 213
212 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) 214 virtual void DetachFromFramebuffer(Framebuffer* framebuffer)
213 const OVERRIDE { 215 const OVERRIDE {
214 texture_ref_->texture()->DetachFromFramebuffer(); 216 texture_ref_->texture()->DetachFromFramebuffer();
215 framebuffer->OnTextureRefDetached(texture_ref_.get()); 217 framebuffer->OnTextureRefDetached(texture_ref_.get());
216 } 218 }
217 219
218 virtual bool ValidForAttachmentType( 220 virtual bool ValidForAttachmentType(
219 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { 221 GLenum attachment_type, uint32 max_color_attachments,
222 const FeatureInfo* feature_info) OVERRIDE {
220 GLenum type = 0; 223 GLenum type = 0;
221 GLenum internal_format = 0; 224 GLenum internal_format = 0;
222 if (!texture_ref_->texture()->GetLevelType( 225 if (!texture_ref_->texture()->GetLevelType(
223 target_, level_, &type, &internal_format)) { 226 target_, level_, &type, &internal_format)) {
224 return false; 227 return false;
225 } 228 }
226 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( 229 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
227 attachment_type, max_color_attachments); 230 attachment_type, max_color_attachments);
228 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); 231 uint32 have = GLES2Util::GetChannelsForFormat(internal_format);
229 232
230 // Workaround for NVIDIA drivers that incorrectly expose these formats as 233 // Workaround for NVIDIA drivers that incorrectly expose these formats as
231 // renderable: 234 // renderable:
232 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || 235 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA ||
233 internal_format == GL_LUMINANCE_ALPHA) { 236 internal_format == GL_LUMINANCE_ALPHA) {
234 return false; 237 return false;
235 } 238 }
239 if ((internal_format == GL_RGBA32F &&
240 !feature_info->feature_flags().chromium_color_buffer_float_rgba) ||
241 (internal_format == GL_RGB32F &&
242 !feature_info->feature_flags().chromium_color_buffer_float_rgb) ||
243 (type == GL_FLOAT &&
244 internal_format != GL_RGBA32F && internal_format != GL_RGB32F)) {
245 return false;
Ken Russell (switch to Gerrit) 2014/02/11 00:37:23 I'm pretty sure this is going to break ANGLE's abi
oetuaho-nv 2014/02/11 12:42:16 Right, I should have realized that ANGLE doesn't f
246 }
236 return (need & have) != 0; 247 return (need & have) != 0;
237 } 248 }
238 249
239 virtual void AddToSignature( 250 virtual void AddToSignature(
240 TextureManager* texture_manager, std::string* signature) const OVERRIDE { 251 TextureManager* texture_manager, std::string* signature) const OVERRIDE {
241 DCHECK(signature); 252 DCHECK(signature);
242 texture_manager->AddToSignature( 253 texture_manager->AddToSignature(
243 texture_ref_.get(), target_, level_, signature); 254 texture_ref_.get(), target_, level_, signature);
244 } 255 }
245 256
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 410
400 GLenum Framebuffer::GetColorAttachmentTextureType() const { 411 GLenum Framebuffer::GetColorAttachmentTextureType() const {
401 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0); 412 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0);
402 if (it == attachments_.end()) { 413 if (it == attachments_.end()) {
403 return 0; 414 return 0;
404 } 415 }
405 const Attachment* attachment = it->second.get(); 416 const Attachment* attachment = it->second.get();
406 return attachment->texture_type(); 417 return attachment->texture_type();
407 } 418 }
408 419
409 GLenum Framebuffer::IsPossiblyComplete() const { 420 GLenum Framebuffer::IsPossiblyComplete(const FeatureInfo* feature_info) const {
410 if (attachments_.empty()) { 421 if (attachments_.empty()) {
411 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; 422 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
412 } 423 }
413 424
414 GLsizei width = -1; 425 GLsizei width = -1;
415 GLsizei height = -1; 426 GLsizei height = -1;
416 for (AttachmentMap::const_iterator it = attachments_.begin(); 427 for (AttachmentMap::const_iterator it = attachments_.begin();
417 it != attachments_.end(); ++it) { 428 it != attachments_.end(); ++it) {
418 GLenum attachment_type = it->first; 429 GLenum attachment_type = it->first;
419 Attachment* attachment = it->second.get(); 430 Attachment* attachment = it->second.get();
420 if (!attachment->ValidForAttachmentType(attachment_type, 431 if (!attachment->ValidForAttachmentType(attachment_type,
421 manager_->max_color_attachments_)) { 432 manager_->max_color_attachments_,
433 feature_info)) {
422 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 434 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
423 } 435 }
424 if (width < 0) { 436 if (width < 0) {
425 width = attachment->width(); 437 width = attachment->width();
426 height = attachment->height(); 438 height = attachment->height();
427 if (width == 0 || height == 0) { 439 if (width == 0 || height == 0) {
428 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 440 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
429 } 441 }
430 } else { 442 } else {
431 if (attachment->width() != width || attachment->height() != height) { 443 if (attachment->width() != width || attachment->height() != height) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ++it) { 671 ++it) {
660 TextureDetachObserver* observer = *it; 672 TextureDetachObserver* observer = *it;
661 observer->OnTextureRefDetachedFromFramebuffer(texture); 673 observer->OnTextureRefDetachedFromFramebuffer(texture);
662 } 674 }
663 } 675 }
664 676
665 } // namespace gles2 677 } // namespace gles2
666 } // namespace gpu 678 } // namespace gpu
667 679
668 680
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698