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

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

Issue 1830453002: WebGL: GL_RGB emulation for IOSurface backed textures. [For reference only] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile error. Created 4 years, 9 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 std::string* signature) const override { 122 std::string* signature) const override {
123 DCHECK(signature); 123 DCHECK(signature);
124 renderbuffer_->AddToSignature(signature); 124 renderbuffer_->AddToSignature(signature);
125 } 125 }
126 126
127 bool FormsFeedbackLoop(TextureRef* /* texture */, 127 bool FormsFeedbackLoop(TextureRef* /* texture */,
128 GLint /*level */) const override { 128 GLint /*level */) const override {
129 return false; 129 return false;
130 } 130 }
131 131
132 bool EmulatingRGB() const override { return false; }
133 bool Initialized() const override { return true; }
134 void SetInitialized(bool initialized) override {}
135
132 protected: 136 protected:
133 ~RenderbufferAttachment() override {} 137 ~RenderbufferAttachment() override {}
134 138
135 private: 139 private:
136 scoped_refptr<Renderbuffer> renderbuffer_; 140 scoped_refptr<Renderbuffer> renderbuffer_;
137 141
138 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); 142 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
139 }; 143 };
140 144
141 class TextureAttachment 145 class TextureAttachment
142 : public Framebuffer::Attachment { 146 : public Framebuffer::Attachment {
143 public: 147 public:
144 TextureAttachment( 148 TextureAttachment(TextureRef* texture_ref,
145 TextureRef* texture_ref, GLenum target, GLint level, 149 GLenum target,
146 GLsizei samples, GLint layer) 150 GLint level,
151 GLsizei samples,
152 GLint layer)
147 : texture_ref_(texture_ref), 153 : texture_ref_(texture_ref),
148 target_(target), 154 target_(target),
149 level_(level), 155 level_(level),
150 samples_(samples), 156 samples_(samples),
151 layer_(layer) { 157 layer_(layer),
152 } 158 initialized_(false) {}
153 159
154 GLsizei width() const override { 160 GLsizei width() const override {
155 GLsizei temp_width = 0; 161 GLsizei temp_width = 0;
156 GLsizei temp_height = 0; 162 GLsizei temp_height = 0;
157 texture_ref_->texture()->GetLevelSize( 163 texture_ref_->texture()->GetLevelSize(
158 target_, level_, &temp_width, &temp_height, nullptr); 164 target_, level_, &temp_width, &temp_height, nullptr);
159 return temp_width; 165 return temp_width;
160 } 166 }
161 167
162 GLsizei height() const override { 168 GLsizei height() const override {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 GLenum internal_format = 0; 249 GLenum internal_format = 0;
244 if (!texture_ref_->texture()->GetLevelType( 250 if (!texture_ref_->texture()->GetLevelType(
245 target_, level_, &type, &internal_format)) { 251 target_, level_, &type, &internal_format)) {
246 return false; 252 return false;
247 } 253 }
248 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType( 254 uint32_t need = GLES2Util::GetChannelsNeededForAttachmentType(
249 attachment_type, max_color_attachments); 255 attachment_type, max_color_attachments);
250 DCHECK_NE(0u, need); 256 DCHECK_NE(0u, need);
251 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format); 257 uint32_t have = GLES2Util::GetChannelsForFormat(internal_format);
252 258
259 have |= EmulatingRGB() ? GLES2Util::ChannelBits::kAlpha : 0;
260
253 // Workaround for NVIDIA drivers that incorrectly expose these formats as 261 // Workaround for NVIDIA drivers that incorrectly expose these formats as
254 // renderable: 262 // renderable:
255 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA || 263 if (internal_format == GL_LUMINANCE || internal_format == GL_ALPHA ||
256 internal_format == GL_LUMINANCE_ALPHA) { 264 internal_format == GL_LUMINANCE_ALPHA) {
257 return false; 265 return false;
258 } 266 }
259 if (context_type == CONTEXT_TYPE_WEBGL1 && 267 if (context_type == CONTEXT_TYPE_WEBGL1 &&
260 DetectWebGL1DepthStencilAttachmentConflicts(need, have)) 268 DetectWebGL1DepthStencilAttachmentConflicts(need, have))
261 return need == have; 269 return need == have;
262 return (need & have) != 0; 270 return (need & have) != 0;
263 } 271 }
264 272
265 size_t GetSignatureSize(TextureManager* texture_manager) const override { 273 size_t GetSignatureSize(TextureManager* texture_manager) const override {
266 return texture_manager->GetSignatureSize(); 274 return texture_manager->GetSignatureSize();
267 } 275 }
268 276
269 void AddToSignature(TextureManager* texture_manager, 277 void AddToSignature(TextureManager* texture_manager,
270 std::string* signature) const override { 278 std::string* signature) const override {
271 DCHECK(signature); 279 DCHECK(signature);
272 texture_manager->AddToSignature( 280 texture_manager->AddToSignature(
273 texture_ref_.get(), target_, level_, signature); 281 texture_ref_.get(), target_, level_, signature);
274 } 282 }
275 283
276 bool FormsFeedbackLoop(TextureRef* texture, GLint level) const override { 284 bool FormsFeedbackLoop(TextureRef* texture, GLint level) const override {
277 return texture == texture_ref_.get() && level == level_; 285 return texture == texture_ref_.get() && level == level_;
278 } 286 }
279 287
288 bool EmulatingRGB() const override {
289 return texture_ref_->texture()->EmulatingRGB();
290 }
291
292 bool Initialized() const override { return initialized_; }
293 void SetInitialized(bool initialized) override { initialized_ = initialized; }
294
280 protected: 295 protected:
281 ~TextureAttachment() override {} 296 ~TextureAttachment() override {}
282 297
283 private: 298 private:
284 scoped_refptr<TextureRef> texture_ref_; 299 scoped_refptr<TextureRef> texture_ref_;
285 GLenum target_; 300 GLenum target_;
286 GLint level_; 301 GLint level_;
287 GLsizei samples_; 302 GLsizei samples_;
288 GLint layer_; 303 GLint layer_;
304 bool initialized_;
289 305
290 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); 306 DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
291 }; 307 };
292 308
293 FramebufferManager::FramebufferManager( 309 FramebufferManager::FramebufferManager(
294 uint32_t max_draw_buffers, 310 uint32_t max_draw_buffers,
295 uint32_t max_color_attachments, 311 uint32_t max_color_attachments,
296 ContextType context_type, 312 ContextType context_type,
297 const scoped_refptr<FramebufferCompletenessCache>& 313 const scoped_refptr<FramebufferCompletenessCache>&
298 framebuffer_combo_complete_cache) 314 framebuffer_combo_complete_cache)
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 if (it->first >= GL_COLOR_ATTACHMENT0 && 409 if (it->first >= GL_COLOR_ATTACHMENT0 &&
394 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) { 410 it->first < GL_COLOR_ATTACHMENT0 + manager_->max_draw_buffers_) {
395 const Attachment* attachment = it->second.get(); 411 const Attachment* attachment = it->second.get();
396 if (!attachment->cleared()) 412 if (!attachment->cleared())
397 return true; 413 return true;
398 } 414 }
399 } 415 }
400 return false; 416 return false;
401 } 417 }
402 418
419 bool Framebuffer::HasUninitializedDrawBuffers() const {
420 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
421 if (draw_buffers_[i] != GL_NONE) {
422 const Attachment* attachment = GetAttachment(draw_buffers_[i]);
423 if (!attachment)
424 continue;
425 if (!attachment->EmulatingRGB())
426 continue;
427 if (attachment->Initialized())
428 continue;
429 return true;
430 }
431 }
432 return false;
433 }
434
435 void Framebuffer::SetDrawBuffersAsInitialized() {
436 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
437 if (draw_buffers_[i] != GL_NONE) {
438 AttachmentMap::iterator it = attachments_.find(draw_buffers_[i]);
439 if (it == attachments_.end())
440 continue;
441 Attachment* attachment = it->second.get();
442 if (!attachment)
443 continue;
444 if (!attachment->EmulatingRGB())
445 continue;
446 if (attachment->Initialized())
447 continue;
448 attachment->SetInitialized(true);
449 }
450 }
451 }
452
403 bool Framebuffer::HasUnclearedIntRenderbufferAttachments() const { 453 bool Framebuffer::HasUnclearedIntRenderbufferAttachments() const {
404 for (AttachmentMap::const_iterator it = attachments_.begin(); 454 for (AttachmentMap::const_iterator it = attachments_.begin();
405 it != attachments_.end(); ++it) { 455 it != attachments_.end(); ++it) {
406 if (!it->second->IsRenderbufferAttachment() || it->second->cleared()) 456 if (!it->second->IsRenderbufferAttachment() || it->second->cleared())
407 continue; 457 continue;
408 if (GLES2Util::IsIntegerFormat(it->second->internal_format())) 458 if (GLES2Util::IsIntegerFormat(it->second->internal_format()))
409 return true; 459 return true;
410 } 460 }
411 return false; 461 return false;
412 } 462 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 } 580 }
531 581
532 GLenum Framebuffer::GetReadBufferInternalFormat() const { 582 GLenum Framebuffer::GetReadBufferInternalFormat() const {
533 if (read_buffer_ == GL_NONE) 583 if (read_buffer_ == GL_NONE)
534 return 0; 584 return 0;
535 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); 585 AttachmentMap::const_iterator it = attachments_.find(read_buffer_);
536 if (it == attachments_.end()) { 586 if (it == attachments_.end()) {
537 return 0; 587 return 0;
538 } 588 }
539 const Attachment* attachment = it->second.get(); 589 const Attachment* attachment = it->second.get();
590 if (attachment->EmulatingRGB()) {
591 switch (attachment->internal_format()) {
592 case GL_RGBA:
593 return GL_RGB;
594 case GL_BGRA_EXT:
595 return GL_BGR_EXT;
596 default:
597 break;
598 }
599 }
540 return attachment->internal_format(); 600 return attachment->internal_format();
541 } 601 }
542 602
543 GLenum Framebuffer::GetReadBufferTextureType() const { 603 GLenum Framebuffer::GetReadBufferTextureType() const {
544 if (read_buffer_ == GL_NONE) 604 if (read_buffer_ == GL_NONE)
545 return 0; 605 return 0;
546 AttachmentMap::const_iterator it = attachments_.find(read_buffer_); 606 AttachmentMap::const_iterator it = attachments_.find(read_buffer_);
547 if (it == attachments_.end()) { 607 if (it == attachments_.end()) {
548 return 0; 608 return 0;
549 } 609 }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 for (GLsizei i = 0; i < n; ++i) 715 for (GLsizei i = 0; i < n; ++i)
656 draw_buffers_[i] = bufs[i]; 716 draw_buffers_[i] = bufs[i];
657 } 717 }
658 718
659 bool Framebuffer::HasAlphaMRT() const { 719 bool Framebuffer::HasAlphaMRT() const {
660 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) { 720 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
661 if (draw_buffers_[i] != GL_NONE) { 721 if (draw_buffers_[i] != GL_NONE) {
662 const Attachment* attachment = GetAttachment(draw_buffers_[i]); 722 const Attachment* attachment = GetAttachment(draw_buffers_[i]);
663 if (!attachment) 723 if (!attachment)
664 continue; 724 continue;
725 if (attachment->EmulatingRGB())
726 return false;
665 if ((GLES2Util::GetChannelsForFormat( 727 if ((GLES2Util::GetChannelsForFormat(
666 attachment->internal_format()) & 0x0008) != 0) 728 attachment->internal_format()) & 0x0008) != 0)
667 return true; 729 return true;
668 } 730 }
669 } 731 }
670 return false; 732 return false;
671 } 733 }
672 734
735 bool Framebuffer::EmulatingRGB() const {
736 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
737 if (draw_buffers_[i] != GL_NONE) {
738 const Attachment* attachment = GetAttachment(draw_buffers_[i]);
739 if (!attachment)
740 continue;
741 if (attachment->EmulatingRGB())
742 return true;
743 }
744 }
745 return false;
746 }
747
673 bool Framebuffer::HasSameInternalFormatsMRT() const { 748 bool Framebuffer::HasSameInternalFormatsMRT() const {
674 GLenum internal_format = 0; 749 GLenum internal_format = 0;
675 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) { 750 for (uint32_t i = 0; i < manager_->max_draw_buffers_; ++i) {
676 if (draw_buffers_[i] != GL_NONE) { 751 if (draw_buffers_[i] != GL_NONE) {
677 const Attachment* attachment = GetAttachment(draw_buffers_[i]); 752 const Attachment* attachment = GetAttachment(draw_buffers_[i]);
678 if (!attachment) 753 if (!attachment)
679 continue; 754 continue;
680 if (!internal_format) { 755 if (!internal_format) {
681 internal_format = attachment->internal_format(); 756 internal_format = attachment->internal_format();
682 } else if (internal_format != attachment->internal_format()) { 757 } else if (internal_format != attachment->internal_format()) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 916
842 bool FramebufferManager::IsComplete( 917 bool FramebufferManager::IsComplete(
843 Framebuffer* framebuffer) { 918 Framebuffer* framebuffer) {
844 DCHECK(framebuffer); 919 DCHECK(framebuffer);
845 return framebuffer->framebuffer_complete_state_count_id() == 920 return framebuffer->framebuffer_complete_state_count_id() ==
846 framebuffer_state_change_count_; 921 framebuffer_state_change_count_;
847 } 922 }
848 923
849 } // namespace gles2 924 } // namespace gles2
850 } // namespace gpu 925 } // 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