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

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: Check that framebuffers really are supported and add tests 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/renderbuffer_manager.h" 9 #include "gpu/command_buffer/service/renderbuffer_manager.h"
10 #include "gpu/command_buffer/service/texture_manager.h" 10 #include "gpu/command_buffer/service/texture_manager.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 95
96 virtual bool CanRenderTo() const OVERRIDE { 96 virtual bool CanRenderTo() const OVERRIDE {
97 return true; 97 return true;
98 } 98 }
99 99
100 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const OVERRIDE { 100 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) const OVERRIDE {
101 // Nothing to do for renderbuffers. 101 // Nothing to do for renderbuffers.
102 } 102 }
103 103
104 virtual bool ValidForAttachmentType( 104 virtual bool ValidForAttachmentType(
105 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { 105 GLenum attachment_type, uint32 max_color_attachments,
106 bool) OVERRIDE {
106 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( 107 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
107 attachment_type, max_color_attachments); 108 attachment_type, max_color_attachments);
108 uint32 have = GLES2Util::GetChannelsForFormat(internal_format()); 109 uint32 have = GLES2Util::GetChannelsForFormat(internal_format());
109 return (need & have) != 0; 110 return (need & have) != 0;
110 } 111 }
111 112
112 Renderbuffer* renderbuffer() const { 113 Renderbuffer* renderbuffer() const {
113 return renderbuffer_.get(); 114 return renderbuffer_.get();
114 } 115 }
115 116
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 return texture_ref_->texture()->CanRenderTo(); 210 return texture_ref_->texture()->CanRenderTo();
210 } 211 }
211 212
212 virtual void DetachFromFramebuffer(Framebuffer* framebuffer) 213 virtual void DetachFromFramebuffer(Framebuffer* framebuffer)
213 const OVERRIDE { 214 const OVERRIDE {
214 texture_ref_->texture()->DetachFromFramebuffer(); 215 texture_ref_->texture()->DetachFromFramebuffer();
215 framebuffer->OnTextureRefDetached(texture_ref_.get()); 216 framebuffer->OnTextureRefDetached(texture_ref_.get());
216 } 217 }
217 218
218 virtual bool ValidForAttachmentType( 219 virtual bool ValidForAttachmentType(
219 GLenum attachment_type, uint32 max_color_attachments) OVERRIDE { 220 GLenum attachment_type, uint32 max_color_attachments,
221 bool allow_float_color_attachment) OVERRIDE {
220 GLenum type = 0; 222 GLenum type = 0;
221 GLenum internal_format = 0; 223 GLenum internal_format = 0;
222 if (!texture_ref_->texture()->GetLevelType( 224 if (!texture_ref_->texture()->GetLevelType(
223 target_, level_, &type, &internal_format)) { 225 target_, level_, &type, &internal_format)) {
224 return false; 226 return false;
225 } 227 }
226 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType( 228 uint32 need = GLES2Util::GetChannelsNeededForAttachmentType(
227 attachment_type, max_color_attachments); 229 attachment_type, max_color_attachments);
228 uint32 have = GLES2Util::GetChannelsForFormat(internal_format); 230 uint32 have = GLES2Util::GetChannelsForFormat(internal_format);
229 231
230 // Workaround for NVIDIA drivers that incorrectly expose these formats as 232 // Workaround for NVIDIA drivers that incorrectly expose these formats as
231 // renderable: 233 // renderable:
232 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || 234 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA ||
233 internal_format == GL_LUMINANCE_ALPHA) { 235 internal_format == GL_LUMINANCE_ALPHA) {
234 return false; 236 return false;
235 } 237 }
238 if (type == GL_FLOAT &&
239 (!allow_float_color_attachment ||
240 (internal_format != GL_RGBA32F && internal_format != GL_RGB32F))) {
241 return false;
242 }
236 return (need & have) != 0; 243 return (need & have) != 0;
237 } 244 }
238 245
239 virtual void AddToSignature( 246 virtual void AddToSignature(
240 TextureManager* texture_manager, std::string* signature) const OVERRIDE { 247 TextureManager* texture_manager, std::string* signature) const OVERRIDE {
241 DCHECK(signature); 248 DCHECK(signature);
242 texture_manager->AddToSignature( 249 texture_manager->AddToSignature(
243 texture_ref_.get(), target_, level_, signature); 250 texture_ref_.get(), target_, level_, signature);
244 } 251 }
245 252
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 406
400 GLenum Framebuffer::GetColorAttachmentTextureType() const { 407 GLenum Framebuffer::GetColorAttachmentTextureType() const {
401 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0); 408 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0);
402 if (it == attachments_.end()) { 409 if (it == attachments_.end()) {
403 return 0; 410 return 0;
404 } 411 }
405 const Attachment* attachment = it->second.get(); 412 const Attachment* attachment = it->second.get();
406 return attachment->texture_type(); 413 return attachment->texture_type();
407 } 414 }
408 415
409 GLenum Framebuffer::IsPossiblyComplete() const { 416 GLenum Framebuffer::IsPossiblyComplete(
417 bool allow_float_color_attachment) const {
410 if (attachments_.empty()) { 418 if (attachments_.empty()) {
411 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; 419 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
412 } 420 }
413 421
414 GLsizei width = -1; 422 GLsizei width = -1;
415 GLsizei height = -1; 423 GLsizei height = -1;
416 for (AttachmentMap::const_iterator it = attachments_.begin(); 424 for (AttachmentMap::const_iterator it = attachments_.begin();
417 it != attachments_.end(); ++it) { 425 it != attachments_.end(); ++it) {
418 GLenum attachment_type = it->first; 426 GLenum attachment_type = it->first;
419 Attachment* attachment = it->second.get(); 427 Attachment* attachment = it->second.get();
420 if (!attachment->ValidForAttachmentType(attachment_type, 428 if (!attachment->ValidForAttachmentType(attachment_type,
421 manager_->max_color_attachments_)) { 429 manager_->max_color_attachments_,
430 allow_float_color_attachment)) {
422 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 431 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
423 } 432 }
424 if (width < 0) { 433 if (width < 0) {
425 width = attachment->width(); 434 width = attachment->width();
426 height = attachment->height(); 435 height = attachment->height();
427 if (width == 0 || height == 0) { 436 if (width == 0 || height == 0) {
428 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 437 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
429 } 438 }
430 } else { 439 } else {
431 if (attachment->width() != width || attachment->height() != height) { 440 if (attachment->width() != width || attachment->height() != height) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ++it) { 668 ++it) {
660 TextureDetachObserver* observer = *it; 669 TextureDetachObserver* observer = *it;
661 observer->OnTextureRefDetachedFromFramebuffer(texture); 670 observer->OnTextureRefDetachedFromFramebuffer(texture);
662 } 671 }
663 } 672 }
664 673
665 } // namespace gles2 674 } // namespace gles2
666 } // namespace gpu 675 } // namespace gpu
667 676
668 677
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698