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

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

Issue 2149523002: Make invalidateFramebuffer no-op for DEPTH_STENCIL attachment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add depth_cleared_ and stencil_cleared_ for class texture and renderbuffer. Created 4 years, 5 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 30 matching lines...) Expand all
41 bound_draw_framebuffer(NULL) { 41 bound_draw_framebuffer(NULL) {
42 } 42 }
43 43
44 DecoderFramebufferState::~DecoderFramebufferState() { 44 DecoderFramebufferState::~DecoderFramebufferState() {
45 } 45 }
46 46
47 class RenderbufferAttachment 47 class RenderbufferAttachment
48 : public Framebuffer::Attachment { 48 : public Framebuffer::Attachment {
49 public: 49 public:
50 explicit RenderbufferAttachment( 50 explicit RenderbufferAttachment(
51 Renderbuffer* renderbuffer) 51 Renderbuffer* renderbuffer, GLenum attachment)
52 : renderbuffer_(renderbuffer) { 52 : renderbuffer_(renderbuffer),
53 attachment_(attachment) {
54 is_depth_stencil_ = renderbuffer ?
55 Framebuffer::IsDepthStencilFormat(internal_format()) : false;
53 } 56 }
54 57
55 GLsizei width() const override { return renderbuffer_->width(); } 58 GLsizei width() const override { return renderbuffer_->width(); }
56 59
57 GLsizei height() const override { return renderbuffer_->height(); } 60 GLsizei height() const override { return renderbuffer_->height(); }
58 61
59 GLenum internal_format() const override { 62 GLenum internal_format() const override {
60 return renderbuffer_->internal_format(); 63 return renderbuffer_->internal_format();
61 } 64 }
62 65
63 GLenum texture_type() const override { 66 GLenum texture_type() const override {
64 return TextureManager::ExtractTypeFromStorageFormat( 67 return TextureManager::ExtractTypeFromStorageFormat(
65 renderbuffer_->internal_format()); 68 renderbuffer_->internal_format());
66 } 69 }
67 70
68 GLsizei samples() const override { return renderbuffer_->samples(); } 71 GLsizei samples() const override { return renderbuffer_->samples(); }
69 72
70 GLuint object_name() const override { return renderbuffer_->client_id(); } 73 GLuint object_name() const override { return renderbuffer_->client_id(); }
71 74
72 bool cleared() const override { return renderbuffer_->cleared(); } 75 GLenum attachment() const override { return attachment_; }
76
77 bool IsDepthStencil() const override { return is_depth_stencil_; }
78
79 bool cleared() const override {
80 if (!is_depth_stencil_)
81 return renderbuffer_->cleared();
82 else
83 return renderbuffer_->cleared(attachment_);
84 }
73 85
74 void SetCleared(RenderbufferManager* renderbuffer_manager, 86 void SetCleared(RenderbufferManager* renderbuffer_manager,
75 TextureManager* /* texture_manager */, 87 TextureManager* /* texture_manager */,
76 bool cleared) override { 88 bool cleared) override {
77 DCHECK(renderbuffer_manager); 89 DCHECK(renderbuffer_manager);
78 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared); 90 if (!is_depth_stencil_)
91 renderbuffer_manager->SetCleared(renderbuffer_.get(), cleared);
92 else
93 renderbuffer_manager->SetCleared(renderbuffer_.get(),
94 attachment_,
95 cleared);
79 } 96 }
80 97
81 bool IsPartiallyCleared() const override { return false; } 98 bool IsPartiallyCleared() const override { return false; }
82 99
83 bool IsTextureAttachment() const override { return false; } 100 bool IsTextureAttachment() const override { return false; }
84 bool IsRenderbufferAttachment() const override { return true; } 101 bool IsRenderbufferAttachment() const override { return true; }
85 102
86 bool IsTexture(TextureRef* /* texture */) const override { return false; } 103 bool IsTexture(TextureRef* /* texture */) const override { return false; }
87 104
88 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override { 105 bool IsRenderbuffer(Renderbuffer* renderbuffer) const override {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 149 }
133 150
134 bool EmulatingRGB() const override { return false; } 151 bool EmulatingRGB() const override { return false; }
135 152
136 protected: 153 protected:
137 ~RenderbufferAttachment() override {} 154 ~RenderbufferAttachment() override {}
138 155
139 private: 156 private:
140 scoped_refptr<Renderbuffer> renderbuffer_; 157 scoped_refptr<Renderbuffer> renderbuffer_;
141 158
159 GLenum attachment_;
160 bool is_depth_stencil_;
161
142 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment); 162 DISALLOW_COPY_AND_ASSIGN(RenderbufferAttachment);
143 }; 163 };
144 164
145 class TextureAttachment 165 class TextureAttachment
146 : public Framebuffer::Attachment { 166 : public Framebuffer::Attachment {
147 public: 167 public:
148 TextureAttachment( 168 TextureAttachment(
149 TextureRef* texture_ref, GLenum target, GLint level, 169 TextureRef* texture_ref, GLenum target, GLint level,
150 GLsizei samples, GLint layer) 170 GLsizei samples, GLint layer, GLenum attachment)
151 : texture_ref_(texture_ref), 171 : texture_ref_(texture_ref),
152 target_(target), 172 target_(target),
153 level_(level), 173 level_(level),
154 samples_(samples), 174 samples_(samples),
155 layer_(layer) { 175 layer_(layer),
176 attachment_(attachment) {
177 is_depth_stencil_ = texture_ref ?
178 Framebuffer::IsDepthStencilFormat(internal_format()) : false;
156 } 179 }
157 180
158 GLsizei width() const override { 181 GLsizei width() const override {
159 GLsizei temp_width = 0; 182 GLsizei temp_width = 0;
160 GLsizei temp_height = 0; 183 GLsizei temp_height = 0;
161 texture_ref_->texture()->GetLevelSize( 184 texture_ref_->texture()->GetLevelSize(
162 target_, level_, &temp_width, &temp_height, nullptr); 185 target_, level_, &temp_width, &temp_height, nullptr);
163 return temp_width; 186 return temp_width;
164 } 187 }
165 188
(...skipping 24 matching lines...) Expand all
190 GLsizei samples() const override { return samples_; } 213 GLsizei samples() const override { return samples_; }
191 214
192 GLint layer() const { return layer_; } 215 GLint layer() const { return layer_; }
193 216
194 GLenum target() const { return target_; } 217 GLenum target() const { return target_; }
195 218
196 GLint level() const { return level_; } 219 GLint level() const { return level_; }
197 220
198 GLuint object_name() const override { return texture_ref_->client_id(); } 221 GLuint object_name() const override { return texture_ref_->client_id(); }
199 222
223 GLenum attachment() const override { return attachment_; }
224
225 bool IsDepthStencil() const override { return is_depth_stencil_; }
226
200 bool cleared() const override { 227 bool cleared() const override {
201 return texture_ref_->texture()->IsLevelCleared(target_, level_); 228 if (!is_depth_stencil_)
229 return texture_ref_->texture()->IsLevelCleared(target_, level_);
230 else
231 return texture_ref_->texture()->IsLevelCleared(target_, level_,
232 attachment_);
202 } 233 }
203 234
204 void SetCleared(RenderbufferManager* /* renderbuffer_manager */, 235 void SetCleared(RenderbufferManager* /* renderbuffer_manager */,
205 TextureManager* texture_manager, 236 TextureManager* texture_manager,
206 bool cleared) override { 237 bool cleared) override {
207 DCHECK(texture_manager); 238 DCHECK(texture_manager);
208 texture_manager->SetLevelCleared( 239 if (!is_depth_stencil_)
209 texture_ref_.get(), target_, level_, cleared); 240 texture_manager->SetLevelCleared(
241 texture_ref_.get(), target_, level_, cleared);
242 else
243 texture_manager->SetLevelCleared(
244 texture_ref_.get(), target_, level_, attachment_, cleared);
210 } 245 }
211 246
212 bool IsPartiallyCleared() const override { 247 bool IsPartiallyCleared() const override {
213 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_); 248 return texture_ref_->texture()->IsLevelPartiallyCleared(target_, level_);
214 } 249 }
215 250
216 bool IsTextureAttachment() const override { return true; } 251 bool IsTextureAttachment() const override { return true; }
217 bool IsRenderbufferAttachment() const override { return false; } 252 bool IsRenderbufferAttachment() const override { return false; }
218 253
219 bool IsTexture(TextureRef* texture) const override { 254 bool IsTexture(TextureRef* texture) const override {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 protected: 331 protected:
297 ~TextureAttachment() override {} 332 ~TextureAttachment() override {}
298 333
299 private: 334 private:
300 scoped_refptr<TextureRef> texture_ref_; 335 scoped_refptr<TextureRef> texture_ref_;
301 GLenum target_; 336 GLenum target_;
302 GLint level_; 337 GLint level_;
303 GLsizei samples_; 338 GLsizei samples_;
304 GLint layer_; 339 GLint layer_;
305 340
341 GLenum attachment_;
342 bool is_depth_stencil_;
343
306 DISALLOW_COPY_AND_ASSIGN(TextureAttachment); 344 DISALLOW_COPY_AND_ASSIGN(TextureAttachment);
307 }; 345 };
308 346
309 FramebufferManager::FramebufferManager( 347 FramebufferManager::FramebufferManager(
310 uint32_t max_draw_buffers, 348 uint32_t max_draw_buffers,
311 uint32_t max_color_attachments, 349 uint32_t max_color_attachments,
312 ContextType context_type, 350 ContextType context_type,
313 const scoped_refptr<FramebufferCompletenessCache>& 351 const scoped_refptr<FramebufferCompletenessCache>&
314 framebuffer_combo_complete_cache) 352 framebuffer_combo_complete_cache)
315 : framebuffer_state_change_count_(1), 353 : framebuffer_state_change_count_(1),
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 GLenum attachment, 567 GLenum attachment,
530 bool cleared) { 568 bool cleared) {
531 AttachmentMap::iterator it = attachments_.find(attachment); 569 AttachmentMap::iterator it = attachments_.find(attachment);
532 if (it != attachments_.end()) { 570 if (it != attachments_.end()) {
533 Attachment* a = it->second.get(); 571 Attachment* a = it->second.get();
534 if (a->cleared() != cleared) { 572 if (a->cleared() != cleared) {
535 a->SetCleared(renderbuffer_manager, 573 a->SetCleared(renderbuffer_manager,
536 texture_manager, 574 texture_manager,
537 cleared); 575 cleared);
538 } 576 }
577 } else if (attachment == GL_DEPTH_STENCIL_ATTACHMENT) {
qiankun 2016/07/14 06:48:21 What about move the else branch out of MarkAttachm
578 MarkAttachmentAsCleared(renderbuffer_manager, texture_manager,
579 GL_DEPTH_ATTACHMENT, cleared);
580 MarkAttachmentAsCleared(renderbuffer_manager, texture_manager,
581 GL_STENCIL_ATTACHMENT, cleared);
539 } 582 }
540 } 583 }
541 584
542 void Framebuffer::MarkAttachmentsAsCleared( 585 void Framebuffer::MarkAttachmentsAsCleared(
543 RenderbufferManager* renderbuffer_manager, 586 RenderbufferManager* renderbuffer_manager,
544 TextureManager* texture_manager, 587 TextureManager* texture_manager,
545 bool cleared) { 588 bool cleared) {
546 for (AttachmentMap::iterator it = attachments_.begin(); 589 for (AttachmentMap::iterator it = attachments_.begin();
547 it != attachments_.end(); ++it) { 590 it != attachments_.end(); ++it) {
548 Attachment* attachment = it->second.get(); 591 Attachment* attachment = it->second.get();
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 GLenum result = glCheckFramebufferStatusEXT(target); 760 GLenum result = glCheckFramebufferStatusEXT(target);
718 761
719 if (result == GL_FRAMEBUFFER_COMPLETE) { 762 if (result == GL_FRAMEBUFFER_COMPLETE) {
720 manager_->GetFramebufferComboCompleteCache()->SetComplete(signature); 763 manager_->GetFramebufferComboCompleteCache()->SetComplete(signature);
721 } 764 }
722 765
723 return result; 766 return result;
724 } 767 }
725 768
726 bool Framebuffer::IsCleared() const { 769 bool Framebuffer::IsCleared() const {
727 // are all the attachments cleaared? 770 // are all the attachments cleared?
728 for (AttachmentMap::const_iterator it = attachments_.begin(); 771 for (AttachmentMap::const_iterator it = attachments_.begin();
729 it != attachments_.end(); ++it) { 772 it != attachments_.end(); ++it) {
730 Attachment* attachment = it->second.get(); 773 Attachment* attachment = it->second.get();
731 if (!attachment->cleared()) { 774 if (!attachment->cleared()) {
732 return false; 775 return false;
733 } 776 }
734 } 777 }
735 return true; 778 return true;
736 } 779 }
737 780
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 } 883 }
841 } 884 }
842 885
843 void Framebuffer::AttachRenderbuffer( 886 void Framebuffer::AttachRenderbuffer(
844 GLenum attachment, Renderbuffer* renderbuffer) { 887 GLenum attachment, Renderbuffer* renderbuffer) {
845 const Attachment* a = GetAttachment(attachment); 888 const Attachment* a = GetAttachment(attachment);
846 if (a) 889 if (a)
847 a->DetachFromFramebuffer(this); 890 a->DetachFromFramebuffer(this);
848 if (renderbuffer) { 891 if (renderbuffer) {
849 attachments_[attachment] = scoped_refptr<Attachment>( 892 attachments_[attachment] = scoped_refptr<Attachment>(
850 new RenderbufferAttachment(renderbuffer)); 893 new RenderbufferAttachment(renderbuffer, attachment));
851 } else { 894 } else {
852 attachments_.erase(attachment); 895 attachments_.erase(attachment);
853 } 896 }
854 framebuffer_complete_state_count_id_ = 0; 897 framebuffer_complete_state_count_id_ = 0;
855 } 898 }
856 899
857 void Framebuffer::AttachTexture( 900 void Framebuffer::AttachTexture(
858 GLenum attachment, TextureRef* texture_ref, GLenum target, 901 GLenum attachment, TextureRef* texture_ref, GLenum target,
859 GLint level, GLsizei samples) { 902 GLint level, GLsizei samples) {
860 const Attachment* a = GetAttachment(attachment); 903 const Attachment* a = GetAttachment(attachment);
861 if (a) 904 if (a)
862 a->DetachFromFramebuffer(this); 905 a->DetachFromFramebuffer(this);
863 if (texture_ref) { 906 if (texture_ref) {
864 attachments_[attachment] = scoped_refptr<Attachment>( 907 attachments_[attachment] = scoped_refptr<Attachment>(
865 new TextureAttachment(texture_ref, target, level, samples, 0)); 908 new TextureAttachment(texture_ref, target, level,
909 samples, 0, attachment));
866 texture_ref->texture()->AttachToFramebuffer(); 910 texture_ref->texture()->AttachToFramebuffer();
867 } else { 911 } else {
868 attachments_.erase(attachment); 912 attachments_.erase(attachment);
869 } 913 }
870 framebuffer_complete_state_count_id_ = 0; 914 framebuffer_complete_state_count_id_ = 0;
871 } 915 }
872 916
873 void Framebuffer::AttachTextureLayer( 917 void Framebuffer::AttachTextureLayer(
874 GLenum attachment, TextureRef* texture_ref, GLenum target, 918 GLenum attachment, TextureRef* texture_ref, GLenum target,
875 GLint level, GLint layer) { 919 GLint level, GLint layer) {
876 const Attachment* a = GetAttachment(attachment); 920 const Attachment* a = GetAttachment(attachment);
877 if (a) 921 if (a)
878 a->DetachFromFramebuffer(this); 922 a->DetachFromFramebuffer(this);
879 if (texture_ref) { 923 if (texture_ref) {
880 attachments_[attachment] = scoped_refptr<Attachment>( 924 attachments_[attachment] = scoped_refptr<Attachment>(
881 new TextureAttachment(texture_ref, target, level, 0, layer)); 925 new TextureAttachment(texture_ref, target, level,
926 0, layer, attachment));
882 texture_ref->texture()->AttachToFramebuffer(); 927 texture_ref->texture()->AttachToFramebuffer();
883 } else { 928 } else {
884 attachments_.erase(attachment); 929 attachments_.erase(attachment);
885 } 930 }
886 framebuffer_complete_state_count_id_ = 0; 931 framebuffer_complete_state_count_id_ = 0;
887 } 932 }
888 933
889 const Framebuffer::Attachment* 934 const Framebuffer::Attachment*
890 Framebuffer::GetAttachment( 935 Framebuffer::GetAttachment(
891 GLenum attachment) const { 936 GLenum attachment) const {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 979
935 bool FramebufferManager::IsComplete( 980 bool FramebufferManager::IsComplete(
936 Framebuffer* framebuffer) { 981 Framebuffer* framebuffer) {
937 DCHECK(framebuffer); 982 DCHECK(framebuffer);
938 return framebuffer->framebuffer_complete_state_count_id() == 983 return framebuffer->framebuffer_complete_state_count_id() ==
939 framebuffer_state_change_count_; 984 framebuffer_state_change_count_;
940 } 985 }
941 986
942 } // namespace gles2 987 } // namespace gles2
943 } // namespace gpu 988 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698