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

Side by Side Diff: gpu/command_buffer/service/renderbuffer_manager.h

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 #ifndef GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory> 11 #include <memory>
12 #include <string> 12 #include <string>
13 13
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "gpu/command_buffer/service/framebuffer_manager.h"
17 #include "gpu/command_buffer/service/gl_utils.h" 18 #include "gpu/command_buffer/service/gl_utils.h"
18 #include "gpu/command_buffer/service/memory_tracking.h" 19 #include "gpu/command_buffer/service/memory_tracking.h"
19 #include "gpu/gpu_export.h" 20 #include "gpu/gpu_export.h"
20 21
21 namespace gpu { 22 namespace gpu {
22 namespace gles2 { 23 namespace gles2 {
23 24
24 class FeatureInfo; 25 class FeatureInfo;
25 class RenderbufferManager; 26 class RenderbufferManager;
26 27
(...skipping 10 matching lines...) Expand all
37 } 38 }
38 39
39 GLuint client_id() const { 40 GLuint client_id() const {
40 return client_id_; 41 return client_id_;
41 } 42 }
42 43
43 bool cleared() const { 44 bool cleared() const {
44 return cleared_; 45 return cleared_;
45 } 46 }
46 47
48 // Only meaningful when the format is DEPTH_STENCIL.
49 // Whether the particular part of the renderbuffer is cleared.
50 bool cleared(GLenum attachment) const {
51 if (!is_depth_stencil_)
qiankun 2016/07/14 06:48:21 Can this path be reached in your current implement
52 return cleared_;
53 if (attachment == GL_DEPTH_ATTACHMENT)
54 return depth_cleared_;
55 else if (attachment == GL_STENCIL_ATTACHMENT)
56 return stencil_cleared_;
57 // Should not be reached
qiankun 2016/07/14 06:48:21 Maybe" ? : " is better. Use NOTREACHED(); if kee
58 return cleared_;
59 }
60
47 GLenum internal_format() const { 61 GLenum internal_format() const {
48 return internal_format_; 62 return internal_format_;
49 } 63 }
50 64
51 GLsizei samples() const { 65 GLsizei samples() const {
52 return samples_; 66 return samples_;
53 } 67 }
54 68
55 GLsizei width() const { 69 GLsizei width() const {
56 return width_; 70 return width_;
(...skipping 21 matching lines...) Expand all
78 void AddToSignature(std::string* signature) const; 92 void AddToSignature(std::string* signature) const;
79 93
80 private: 94 private:
81 friend class RenderbufferManager; 95 friend class RenderbufferManager;
82 friend class base::RefCounted<Renderbuffer>; 96 friend class base::RefCounted<Renderbuffer>;
83 97
84 ~Renderbuffer(); 98 ~Renderbuffer();
85 99
86 void set_cleared(bool cleared) { 100 void set_cleared(bool cleared) {
87 cleared_ = cleared; 101 cleared_ = cleared;
102 depth_cleared_ = cleared;
103 stencil_cleared_ = cleared;
104 }
105
106 // Only meaningful when the format is DEPTH_STENCIL.
107 // cleared_ is true only when both depth and stencil parts are cleared.
108 void set_cleared(GLenum attachment, bool cleared) {
109 if (!is_depth_stencil_)
110 return;
111 if (attachment == GL_DEPTH_ATTACHMENT) {
112 depth_cleared_ = cleared;
113 cleared_ = (depth_cleared_ == stencil_cleared_) ? cleared : false;
114 }
115 else if (attachment == GL_STENCIL_ATTACHMENT) {
116 stencil_cleared_ = cleared;
117 cleared_ = (depth_cleared_ == stencil_cleared_) ? cleared : false;
118 }
88 } 119 }
89 120
90 void SetInfo( 121 void SetInfo(
91 GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) { 122 GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) {
92 samples_ = samples; 123 samples_ = samples;
93 internal_format_ = internalformat; 124 internal_format_ = internalformat;
125 is_depth_stencil_ = Framebuffer::IsDepthStencilFormat(internalformat);
94 width_ = width; 126 width_ = width;
95 height_ = height; 127 height_ = height;
96 cleared_ = false; 128 set_cleared(false);
97 } 129 }
98 130
99 void MarkAsDeleted() { 131 void MarkAsDeleted() {
100 client_id_ = 0; 132 client_id_ = 0;
101 } 133 }
102 134
103 // RenderbufferManager that owns this Renderbuffer. 135 // RenderbufferManager that owns this Renderbuffer.
104 RenderbufferManager* manager_; 136 RenderbufferManager* manager_;
105 137
106 // Client side renderbuffer id. 138 // Client side renderbuffer id.
107 GLuint client_id_; 139 GLuint client_id_;
108 140
109 // Service side renderbuffer id. 141 // Service side renderbuffer id.
110 GLuint service_id_; 142 GLuint service_id_;
111 143
112 // Whether this renderbuffer has been cleared 144 // Whether this renderbuffer has been cleared.
113 bool cleared_; 145 bool cleared_;
114 146
147 // Whether the format of this renderbuffer is DEPTH_STENCIL.
148 bool is_depth_stencil_;
149
150 // Only meaningful when format is DEPTH_STENCIL.
151 // Whether the depth part of the renderbuffer has been cleared.
152 bool depth_cleared_;
153 // Whether the stencil part of the renderbuffer has been cleared.
154 bool stencil_cleared_;
155
115 // Whether this renderbuffer has ever been bound. 156 // Whether this renderbuffer has ever been bound.
116 bool has_been_bound_; 157 bool has_been_bound_;
117 158
118 // Number of samples (for multi-sampled renderbuffers) 159 // Number of samples (for multi-sampled renderbuffers).
119 GLsizei samples_; 160 GLsizei samples_;
120 161
121 // Renderbuffer internalformat set through RenderbufferStorage(). 162 // Renderbuffer internalformat set through RenderbufferStorage().
122 GLenum internal_format_; 163 GLenum internal_format_;
123 164
124 // Dimensions of renderbuffer. 165 // Dimensions of renderbuffer.
125 GLsizei width_; 166 GLsizei width_;
126 GLsizei height_; 167 GLsizei height_;
127 }; 168 };
128 169
(...skipping 19 matching lines...) Expand all
148 bool HaveUnclearedRenderbuffers() const { 189 bool HaveUnclearedRenderbuffers() const {
149 return num_uncleared_renderbuffers_ != 0; 190 return num_uncleared_renderbuffers_ != 0;
150 } 191 }
151 192
152 void SetInfo( 193 void SetInfo(
153 Renderbuffer* renderbuffer, 194 Renderbuffer* renderbuffer,
154 GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); 195 GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
155 196
156 void SetCleared(Renderbuffer* renderbuffer, bool cleared); 197 void SetCleared(Renderbuffer* renderbuffer, bool cleared);
157 198
199 // Only meaningful when format is DEPTH_STENCIL.
200 // Sets the particular part of the renderbuffer as cleared or uncleared.
201 void SetCleared(Renderbuffer* renderbuffer, GLenum attachment, bool cleared);
202
158 // Must call before destruction. 203 // Must call before destruction.
159 void Destroy(bool have_context); 204 void Destroy(bool have_context);
160 205
161 // Creates a Renderbuffer for the given renderbuffer ids. 206 // Creates a Renderbuffer for the given renderbuffer ids.
162 void CreateRenderbuffer(GLuint client_id, GLuint service_id); 207 void CreateRenderbuffer(GLuint client_id, GLuint service_id);
163 208
164 // Gets the renderbuffer for the given renderbuffer id. 209 // Gets the renderbuffer for the given renderbuffer id.
165 Renderbuffer* GetRenderbuffer(GLuint client_id); 210 Renderbuffer* GetRenderbuffer(GLuint client_id);
166 211
167 // Removes a renderbuffer for the given renderbuffer id. 212 // Removes a renderbuffer for the given renderbuffer id.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 typedef base::hash_map<GLuint, scoped_refptr<Renderbuffer> > RenderbufferMap; 253 typedef base::hash_map<GLuint, scoped_refptr<Renderbuffer> > RenderbufferMap;
209 RenderbufferMap renderbuffers_; 254 RenderbufferMap renderbuffers_;
210 255
211 DISALLOW_COPY_AND_ASSIGN(RenderbufferManager); 256 DISALLOW_COPY_AND_ASSIGN(RenderbufferManager);
212 }; 257 };
213 258
214 } // namespace gles2 259 } // namespace gles2
215 } // namespace gpu 260 } // namespace gpu
216 261
217 #endif // GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_ 262 #endif // GPU_COMMAND_BUFFER_SERVICE_RENDERBUFFER_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698