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

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: Rebase 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 // As a workaround for ANGLE implementing rendering to float textures in
240 // an unspecified way, accept all internalformats for float textures when
241 // using ANGLE. Otherwise only allow rendering to float textures as exposed
242 // by CHROMIUM_color_buffer_float_rgb(a).
piman 2014/02/11 21:28:38 I don't think this is right. When using ANGLE, we'
Ken Russell (switch to Gerrit) 2014/02/12 00:11:01 When running on ANGLE, the command buffer won't ex
243 if ((internal_format == GL_RGBA32F &&
244 !feature_info->feature_flags().chromium_color_buffer_float_rgba) ||
245 (internal_format == GL_RGB32F &&
246 !feature_info->feature_flags().chromium_color_buffer_float_rgb) ||
247 (type == GL_FLOAT && !feature_info->feature_flags().is_angle &&
248 internal_format != GL_RGBA32F && internal_format != GL_RGB32F)) {
249 return false;
250 }
236 return (need & have) != 0; 251 return (need & have) != 0;
237 } 252 }
238 253
239 virtual void AddToSignature( 254 virtual void AddToSignature(
240 TextureManager* texture_manager, std::string* signature) const OVERRIDE { 255 TextureManager* texture_manager, std::string* signature) const OVERRIDE {
241 DCHECK(signature); 256 DCHECK(signature);
242 texture_manager->AddToSignature( 257 texture_manager->AddToSignature(
243 texture_ref_.get(), target_, level_, signature); 258 texture_ref_.get(), target_, level_, signature);
244 } 259 }
245 260
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 414
400 GLenum Framebuffer::GetColorAttachmentTextureType() const { 415 GLenum Framebuffer::GetColorAttachmentTextureType() const {
401 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0); 416 AttachmentMap::const_iterator it = attachments_.find(GL_COLOR_ATTACHMENT0);
402 if (it == attachments_.end()) { 417 if (it == attachments_.end()) {
403 return 0; 418 return 0;
404 } 419 }
405 const Attachment* attachment = it->second.get(); 420 const Attachment* attachment = it->second.get();
406 return attachment->texture_type(); 421 return attachment->texture_type();
407 } 422 }
408 423
409 GLenum Framebuffer::IsPossiblyComplete() const { 424 GLenum Framebuffer::IsPossiblyComplete(const FeatureInfo* feature_info) const {
410 if (attachments_.empty()) { 425 if (attachments_.empty()) {
411 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; 426 return GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
412 } 427 }
413 428
414 GLsizei width = -1; 429 GLsizei width = -1;
415 GLsizei height = -1; 430 GLsizei height = -1;
416 for (AttachmentMap::const_iterator it = attachments_.begin(); 431 for (AttachmentMap::const_iterator it = attachments_.begin();
417 it != attachments_.end(); ++it) { 432 it != attachments_.end(); ++it) {
418 GLenum attachment_type = it->first; 433 GLenum attachment_type = it->first;
419 Attachment* attachment = it->second.get(); 434 Attachment* attachment = it->second.get();
420 if (!attachment->ValidForAttachmentType(attachment_type, 435 if (!attachment->ValidForAttachmentType(attachment_type,
421 manager_->max_color_attachments_)) { 436 manager_->max_color_attachments_,
437 feature_info)) {
422 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 438 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
423 } 439 }
424 if (width < 0) { 440 if (width < 0) {
425 width = attachment->width(); 441 width = attachment->width();
426 height = attachment->height(); 442 height = attachment->height();
427 if (width == 0 || height == 0) { 443 if (width == 0 || height == 0) {
428 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; 444 return GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
429 } 445 }
430 } else { 446 } else {
431 if (attachment->width() != width || attachment->height() != height) { 447 if (attachment->width() != width || attachment->height() != height) {
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ++it) { 675 ++it) {
660 TextureDetachObserver* observer = *it; 676 TextureDetachObserver* observer = *it;
661 observer->OnTextureRefDetachedFromFramebuffer(texture); 677 observer->OnTextureRefDetachedFromFramebuffer(texture);
662 } 678 }
663 } 679 }
664 680
665 } // namespace gles2 681 } // namespace gles2
666 } // namespace gpu 682 } // namespace gpu
667 683
668 684
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698