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

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

Issue 2161383002: Add check if depth and stencil attachments are same image (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change NULL to nullptr 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
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "gpu/command_buffer/service/error_state_mock.h" 8 #include "gpu/command_buffer/service/error_state_mock.h"
9 #include "gpu/command_buffer/service/feature_info.h" 9 #include "gpu/command_buffer/service/feature_info.h"
10 #include "gpu/command_buffer/service/framebuffer_manager.h" 10 #include "gpu/command_buffer/service/framebuffer_manager.h"
(...skipping 21 matching lines...) Expand all
32 const GLint kMaxSamples = 4; 32 const GLint kMaxSamples = 4;
33 const uint32_t kMaxDrawBuffers = 16; 33 const uint32_t kMaxDrawBuffers = 16;
34 const uint32_t kMaxColorAttachments = 16; 34 const uint32_t kMaxColorAttachments = 16;
35 const bool kUseDefaultTextures = false; 35 const bool kUseDefaultTextures = false;
36 36
37 } // namespace 37 } // namespace
38 38
39 class FramebufferManagerTest : public GpuServiceTest { 39 class FramebufferManagerTest : public GpuServiceTest {
40 public: 40 public:
41 FramebufferManagerTest() 41 FramebufferManagerTest()
42 : manager_(1, 1, CONTEXT_TYPE_OPENGLES2, NULL), 42 : manager_(1, 1, CONTEXT_TYPE_OPENGLES2, nullptr),
43 feature_info_(new FeatureInfo()) { 43 feature_info_(new FeatureInfo()) {
44 texture_manager_.reset(new TextureManager(NULL, 44 texture_manager_.reset(new TextureManager(nullptr,
45 feature_info_.get(), 45 feature_info_.get(),
46 kMaxTextureSize, 46 kMaxTextureSize,
47 kMaxCubemapSize, 47 kMaxCubemapSize,
48 kMaxRectangleTextureSize, 48 kMaxRectangleTextureSize,
49 kMax3DTextureSize, 49 kMax3DTextureSize,
50 kMaxArrayTextureLayers, 50 kMaxArrayTextureLayers,
51 kUseDefaultTextures)); 51 kUseDefaultTextures));
52 renderbuffer_manager_.reset(new RenderbufferManager(NULL, 52 renderbuffer_manager_.reset(new RenderbufferManager(nullptr,
53 kMaxRenderbufferSize, 53 kMaxRenderbufferSize,
54 kMaxSamples, 54 kMaxSamples,
55 feature_info_.get())); 55 feature_info_.get()));
56 } 56 }
57 ~FramebufferManagerTest() override { 57 ~FramebufferManagerTest() override {
58 manager_.Destroy(false); 58 manager_.Destroy(false);
59 texture_manager_->Destroy(false); 59 texture_manager_->Destroy(false);
60 renderbuffer_manager_->Destroy(false); 60 renderbuffer_manager_->Destroy(false);
61 } 61 }
62 62
63 protected: 63 protected:
64 FramebufferManager manager_; 64 FramebufferManager manager_;
65 scoped_refptr<FeatureInfo> feature_info_; 65 scoped_refptr<FeatureInfo> feature_info_;
66 std::unique_ptr<TextureManager> texture_manager_; 66 std::unique_ptr<TextureManager> texture_manager_;
67 std::unique_ptr<RenderbufferManager> renderbuffer_manager_; 67 std::unique_ptr<RenderbufferManager> renderbuffer_manager_;
68 }; 68 };
69 69
70 TEST_F(FramebufferManagerTest, Basic) { 70 TEST_F(FramebufferManagerTest, Basic) {
71 const GLuint kClient1Id = 1; 71 const GLuint kClient1Id = 1;
72 const GLuint kService1Id = 11; 72 const GLuint kService1Id = 11;
73 const GLuint kClient2Id = 2; 73 const GLuint kClient2Id = 2;
74 // Check we can create framebuffer. 74 // Check we can create framebuffer.
75 manager_.CreateFramebuffer(kClient1Id, kService1Id); 75 manager_.CreateFramebuffer(kClient1Id, kService1Id);
76 // Check framebuffer got created. 76 // Check framebuffer got created.
77 Framebuffer* framebuffer1 = manager_.GetFramebuffer(kClient1Id); 77 Framebuffer* framebuffer1 = manager_.GetFramebuffer(kClient1Id);
78 ASSERT_TRUE(framebuffer1 != NULL); 78 ASSERT_TRUE(framebuffer1 != nullptr);
79 EXPECT_FALSE(framebuffer1->IsDeleted()); 79 EXPECT_FALSE(framebuffer1->IsDeleted());
80 EXPECT_EQ(kService1Id, framebuffer1->service_id()); 80 EXPECT_EQ(kService1Id, framebuffer1->service_id());
81 GLuint client_id = 0; 81 GLuint client_id = 0;
82 EXPECT_TRUE(manager_.GetClientId(framebuffer1->service_id(), &client_id)); 82 EXPECT_TRUE(manager_.GetClientId(framebuffer1->service_id(), &client_id));
83 EXPECT_EQ(kClient1Id, client_id); 83 EXPECT_EQ(kClient1Id, client_id);
84 // Check we get nothing for a non-existent framebuffer. 84 // Check we get nothing for a non-existent framebuffer.
85 EXPECT_TRUE(manager_.GetFramebuffer(kClient2Id) == NULL); 85 EXPECT_TRUE(manager_.GetFramebuffer(kClient2Id) == nullptr);
86 // Check trying to a remove non-existent framebuffers does not crash. 86 // Check trying to a remove non-existent framebuffers does not crash.
87 manager_.RemoveFramebuffer(kClient2Id); 87 manager_.RemoveFramebuffer(kClient2Id);
88 // Check framebuffer gets deleted when last reference is released. 88 // Check framebuffer gets deleted when last reference is released.
89 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id))) 89 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id)))
90 .Times(1) 90 .Times(1)
91 .RetiresOnSaturation(); 91 .RetiresOnSaturation();
92 // Check we can't get the framebuffer after we remove it. 92 // Check we can't get the framebuffer after we remove it.
93 manager_.RemoveFramebuffer(kClient1Id); 93 manager_.RemoveFramebuffer(kClient1Id);
94 EXPECT_TRUE(manager_.GetFramebuffer(kClient1Id) == NULL); 94 EXPECT_TRUE(manager_.GetFramebuffer(kClient1Id) == nullptr);
95 } 95 }
96 96
97 TEST_F(FramebufferManagerTest, Destroy) { 97 TEST_F(FramebufferManagerTest, Destroy) {
98 const GLuint kClient1Id = 1; 98 const GLuint kClient1Id = 1;
99 const GLuint kService1Id = 11; 99 const GLuint kService1Id = 11;
100 // Check we can create framebuffer. 100 // Check we can create framebuffer.
101 manager_.CreateFramebuffer(kClient1Id, kService1Id); 101 manager_.CreateFramebuffer(kClient1Id, kService1Id);
102 // Check framebuffer got created. 102 // Check framebuffer got created.
103 Framebuffer* framebuffer1 = manager_.GetFramebuffer(kClient1Id); 103 Framebuffer* framebuffer1 = manager_.GetFramebuffer(kClient1Id);
104 ASSERT_TRUE(framebuffer1 != NULL); 104 ASSERT_TRUE(framebuffer1 != nullptr);
105 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id))) 105 EXPECT_CALL(*gl_, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id)))
106 .Times(1) 106 .Times(1)
107 .RetiresOnSaturation(); 107 .RetiresOnSaturation();
108 manager_.Destroy(true); 108 manager_.Destroy(true);
109 // Check the resources were released. 109 // Check the resources were released.
110 framebuffer1 = manager_.GetFramebuffer(kClient1Id); 110 framebuffer1 = manager_.GetFramebuffer(kClient1Id);
111 ASSERT_TRUE(framebuffer1 == NULL); 111 ASSERT_TRUE(framebuffer1 == nullptr);
112 } 112 }
113 113
114 class FramebufferInfoTestBase : public GpuServiceTest { 114 class FramebufferInfoTestBase : public GpuServiceTest {
115 public: 115 public:
116 static const GLuint kClient1Id = 1; 116 static const GLuint kClient1Id = 1;
117 static const GLuint kService1Id = 11; 117 static const GLuint kService1Id = 11;
118 118
119 explicit FramebufferInfoTestBase(ContextType context_type) 119 explicit FramebufferInfoTestBase(ContextType context_type)
120 : manager_(kMaxDrawBuffers, 120 : manager_(kMaxDrawBuffers,
121 kMaxColorAttachments, 121 kMaxColorAttachments,
122 context_type, 122 context_type,
123 new FramebufferCompletenessCache), 123 new FramebufferCompletenessCache),
124 feature_info_(new FeatureInfo()) { 124 feature_info_(new FeatureInfo()) {
125 texture_manager_.reset(new TextureManager(NULL, 125 texture_manager_.reset(new TextureManager(nullptr,
126 feature_info_.get(), 126 feature_info_.get(),
127 kMaxTextureSize, 127 kMaxTextureSize,
128 kMaxCubemapSize, 128 kMaxCubemapSize,
129 kMaxRectangleTextureSize, 129 kMaxRectangleTextureSize,
130 kMax3DTextureSize, 130 kMax3DTextureSize,
131 kMaxArrayTextureLayers, 131 kMaxArrayTextureLayers,
132 kUseDefaultTextures)); 132 kUseDefaultTextures));
133 renderbuffer_manager_.reset(new RenderbufferManager(NULL, 133 renderbuffer_manager_.reset(new RenderbufferManager(nullptr,
134 kMaxRenderbufferSize, 134 kMaxRenderbufferSize,
135 kMaxSamples, 135 kMaxSamples,
136 feature_info_.get())); 136 feature_info_.get()));
137 } 137 }
138 ~FramebufferInfoTestBase() override { 138 ~FramebufferInfoTestBase() override {
139 manager_.Destroy(false); 139 manager_.Destroy(false);
140 texture_manager_->Destroy(false); 140 texture_manager_->Destroy(false);
141 renderbuffer_manager_->Destroy(false); 141 renderbuffer_manager_->Destroy(false);
142 } 142 }
143 143
144 protected: 144 protected:
145 void SetUp() override { 145 void SetUp() override {
146 InitializeContext("2.0", "GL_EXT_framebuffer_object"); 146 InitializeContext("2.0", "GL_EXT_framebuffer_object");
147 } 147 }
148 148
149 void InitializeContext(const char* gl_version, const char* extensions) { 149 void InitializeContext(const char* gl_version, const char* extensions) {
150 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); 150 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions);
151 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(), 151 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(),
152 extensions, "", gl_version); 152 extensions, "", gl_version);
153 feature_info_->InitializeForTesting(); 153 feature_info_->InitializeForTesting();
154 decoder_.reset(new MockGLES2Decoder()); 154 decoder_.reset(new MockGLES2Decoder());
155 manager_.CreateFramebuffer(kClient1Id, kService1Id); 155 manager_.CreateFramebuffer(kClient1Id, kService1Id);
156 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>()); 156 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>());
157 framebuffer_ = manager_.GetFramebuffer(kClient1Id); 157 framebuffer_ = manager_.GetFramebuffer(kClient1Id);
158 ASSERT_TRUE(framebuffer_ != NULL); 158 ASSERT_TRUE(framebuffer_ != nullptr);
159 } 159 }
160 160
161 FramebufferManager manager_; 161 FramebufferManager manager_;
162 Framebuffer* framebuffer_; 162 Framebuffer* framebuffer_;
163 scoped_refptr<FeatureInfo> feature_info_; 163 scoped_refptr<FeatureInfo> feature_info_;
164 std::unique_ptr<TextureManager> texture_manager_; 164 std::unique_ptr<TextureManager> texture_manager_;
165 std::unique_ptr<RenderbufferManager> renderbuffer_manager_; 165 std::unique_ptr<RenderbufferManager> renderbuffer_manager_;
166 std::unique_ptr<MockErrorState> error_state_; 166 std::unique_ptr<MockErrorState> error_state_;
167 std::unique_ptr<MockGLES2Decoder> decoder_; 167 std::unique_ptr<MockGLES2Decoder> decoder_;
168 }; 168 };
169 169
170 class FramebufferInfoTest : public FramebufferInfoTestBase { 170 class FramebufferInfoTest : public FramebufferInfoTestBase {
171 public: 171 public:
172 FramebufferInfoTest() : FramebufferInfoTestBase(CONTEXT_TYPE_OPENGLES2) {} 172 FramebufferInfoTest() : FramebufferInfoTestBase(CONTEXT_TYPE_OPENGLES2) {}
173 }; 173 };
174 174
175 // GCC requires these declarations, but MSVC requires they not be present 175 // GCC requires these declarations, but MSVC requires they not be present
176 #ifndef COMPILER_MSVC 176 #ifndef COMPILER_MSVC
177 const GLuint FramebufferInfoTestBase::kClient1Id; 177 const GLuint FramebufferInfoTestBase::kClient1Id;
178 const GLuint FramebufferInfoTestBase::kService1Id; 178 const GLuint FramebufferInfoTestBase::kService1Id;
179 #endif 179 #endif
180 180
181 TEST_F(FramebufferInfoTest, Basic) { 181 TEST_F(FramebufferInfoTest, Basic) {
182 EXPECT_EQ(kService1Id, framebuffer_->service_id()); 182 EXPECT_EQ(kService1Id, framebuffer_->service_id());
183 EXPECT_FALSE(framebuffer_->IsDeleted()); 183 EXPECT_FALSE(framebuffer_->IsDeleted());
184 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0)); 184 EXPECT_TRUE(nullptr == framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0));
185 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT)); 185 EXPECT_TRUE(nullptr == framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT));
186 EXPECT_TRUE(NULL == framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT)); 186 EXPECT_TRUE(nullptr == framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT));
187 EXPECT_TRUE( 187 EXPECT_TRUE(
188 NULL == framebuffer_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 188 nullptr == framebuffer_->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
189 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 189 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
190 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 190 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
191 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 191 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
192 framebuffer_->IsPossiblyComplete(feature_info_.get())); 192 framebuffer_->IsPossiblyComplete(feature_info_.get()));
193 EXPECT_TRUE(framebuffer_->IsCleared()); 193 EXPECT_TRUE(framebuffer_->IsCleared());
194 EXPECT_EQ(static_cast<GLenum>(0), 194 EXPECT_EQ(static_cast<GLenum>(0),
195 framebuffer_->GetReadBufferInternalFormat()); 195 framebuffer_->GetReadBufferInternalFormat());
196 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 196 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
197 } 197 }
198 198
199 TEST_F(FramebufferInfoTest, AttachRenderbuffer) { 199 TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
200 const GLuint kRenderbufferClient1Id = 33; 200 const GLuint kRenderbufferClient1Id = 33;
201 const GLuint kRenderbufferService1Id = 333; 201 const GLuint kRenderbufferService1Id = 333;
202 const GLuint kRenderbufferClient2Id = 34; 202 const GLuint kRenderbufferClient2Id = 34;
203 const GLuint kRenderbufferService2Id = 334; 203 const GLuint kRenderbufferService2Id = 334;
204 const GLuint kRenderbufferClient3Id = 35; 204 const GLuint kRenderbufferClient3Id = 35;
205 const GLuint kRenderbufferService3Id = 335; 205 const GLuint kRenderbufferService3Id = 335;
206 const GLuint kRenderbufferClient4Id = 36; 206 const GLuint kRenderbufferClient4Id = 36;
207 const GLuint kRenderbufferService4Id = 336; 207 const GLuint kRenderbufferService4Id = 336;
208 const GLuint kRenderbufferClient5Id = 37;
209 const GLuint kRenderbufferService5Id = 337;
208 const GLsizei kWidth1 = 16; 210 const GLsizei kWidth1 = 16;
209 const GLsizei kHeight1 = 32; 211 const GLsizei kHeight1 = 32;
210 const GLenum kFormat1 = GL_RGBA4; 212 const GLenum kFormat1 = GL_RGBA4;
211 const GLenum kBadFormat1 = GL_DEPTH_COMPONENT16; 213 const GLenum kBadFormat1 = GL_DEPTH_COMPONENT16;
212 const GLsizei kSamples1 = 0; 214 const GLsizei kSamples1 = 0;
213 const GLsizei kWidth2 = 16; 215 const GLsizei kWidth2 = 16;
214 const GLsizei kHeight2 = 32; 216 const GLsizei kHeight2 = 32;
215 const GLenum kFormat2 = GL_DEPTH_COMPONENT16; 217 const GLenum kFormat2 = GL_DEPTH_COMPONENT16;
216 const GLsizei kSamples2 = 0; 218 const GLsizei kSamples2 = 0;
217 const GLsizei kWidth3 = 16; 219 const GLsizei kWidth3 = 16;
218 const GLsizei kHeight3 = 32; 220 const GLsizei kHeight3 = 32;
219 const GLenum kFormat3 = GL_STENCIL_INDEX8; 221 const GLenum kFormat3 = GL_STENCIL_INDEX8;
220 const GLsizei kSamples3 = 0; 222 const GLsizei kSamples3 = 0;
221 const GLsizei kWidth4 = 16; 223 const GLsizei kWidth4 = 16;
222 const GLsizei kHeight4 = 32; 224 const GLsizei kHeight4 = 32;
223 const GLenum kFormat4 = GL_STENCIL_INDEX8; 225 const GLenum kFormat4 = GL_DEPTH24_STENCIL8;
224 const GLsizei kSamples4 = 0; 226 const GLsizei kSamples4 = 0;
225 const GLsizei kDifferentSamples4 = 1; 227 const GLsizei kWidth5 = 16;
228 const GLsizei kHeight5 = 32;
229 const GLenum kFormat5 = GL_DEPTH24_STENCIL8;
230 const GLsizei kSamples5 = 0;
231 const GLsizei kDifferentSamples5 = 1;
226 232
227 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 233 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
228 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 234 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
229 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 235 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
230 EXPECT_FALSE( 236 EXPECT_FALSE(
231 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 237 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
232 238
233 renderbuffer_manager_->CreateRenderbuffer( 239 renderbuffer_manager_->CreateRenderbuffer(
234 kRenderbufferClient1Id, kRenderbufferService1Id); 240 kRenderbufferClient1Id, kRenderbufferService1Id);
235 Renderbuffer* renderbuffer1 = 241 Renderbuffer* renderbuffer1 =
236 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id); 242 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id);
237 ASSERT_TRUE(renderbuffer1 != NULL); 243 ASSERT_TRUE(renderbuffer1 != nullptr);
238 244
239 // check adding one attachment 245 // Check adding one attachment.
240 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1); 246 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1);
241 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 247 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
242 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 248 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
243 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), 249 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4),
244 framebuffer_->GetReadBufferInternalFormat()); 250 framebuffer_->GetReadBufferInternalFormat());
245 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 251 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
246 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 252 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
247 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 253 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
248 framebuffer_->IsPossiblyComplete(feature_info_.get())); 254 framebuffer_->IsPossiblyComplete(feature_info_.get()));
249 EXPECT_TRUE(framebuffer_->IsCleared()); 255 EXPECT_TRUE(framebuffer_->IsCleared());
250 256
251 // Try a format that's not good for COLOR_ATTACHMENT0. 257 // Try a format that's not good for COLOR_ATTACHMENT0.
252 renderbuffer_manager_->SetInfo( 258 renderbuffer_manager_->SetInfo(
253 renderbuffer1, kSamples1, kBadFormat1, kWidth1, kHeight1); 259 renderbuffer1, kSamples1, kBadFormat1, kWidth1, kHeight1);
254 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 260 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
255 framebuffer_->IsPossiblyComplete(feature_info_.get())); 261 framebuffer_->IsPossiblyComplete(feature_info_.get()));
256 262
257 // Try a good format. 263 // Try a good format.
258 renderbuffer_manager_->SetInfo( 264 renderbuffer_manager_->SetInfo(
259 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1); 265 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1);
260 EXPECT_EQ(static_cast<GLenum>(kFormat1), 266 EXPECT_EQ(static_cast<GLenum>(kFormat1),
261 framebuffer_->GetReadBufferInternalFormat()); 267 framebuffer_->GetReadBufferInternalFormat());
262 EXPECT_FALSE(framebuffer_->HasDepthAttachment()); 268 EXPECT_FALSE(framebuffer_->HasDepthAttachment());
263 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 269 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
264 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 270 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
265 framebuffer_->IsPossiblyComplete(feature_info_.get())); 271 framebuffer_->IsPossiblyComplete(feature_info_.get()));
266 EXPECT_FALSE(framebuffer_->IsCleared()); 272 EXPECT_FALSE(framebuffer_->IsCleared());
267 273
268 // check adding another 274 // Check adding another.
269 renderbuffer_manager_->CreateRenderbuffer( 275 renderbuffer_manager_->CreateRenderbuffer(
270 kRenderbufferClient2Id, kRenderbufferService2Id); 276 kRenderbufferClient2Id, kRenderbufferService2Id);
271 Renderbuffer* renderbuffer2 = 277 Renderbuffer* renderbuffer2 =
272 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id); 278 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id);
273 ASSERT_TRUE(renderbuffer2 != NULL); 279 ASSERT_TRUE(renderbuffer2 != nullptr);
274 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2); 280 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2);
275 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 281 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
276 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 282 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
277 EXPECT_EQ(static_cast<GLenum>(kFormat1), 283 EXPECT_EQ(static_cast<GLenum>(kFormat1),
278 framebuffer_->GetReadBufferInternalFormat()); 284 framebuffer_->GetReadBufferInternalFormat());
279 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 285 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
280 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 286 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
281 // The attachment has a size of 0,0 so depending on the order of the map 287 // The attachment has a size of 0,0 so depending on the order of the map
282 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0 288 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0
283 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other 289 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other
284 // attachment. 290 // attachment.
285 GLenum status = framebuffer_->IsPossiblyComplete(feature_info_.get()); 291 GLenum status = framebuffer_->IsPossiblyComplete(feature_info_.get());
286 EXPECT_TRUE( 292 EXPECT_TRUE(
287 status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT || 293 status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT ||
288 status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT); 294 status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT);
289 EXPECT_FALSE(framebuffer_->IsCleared()); 295 EXPECT_FALSE(framebuffer_->IsCleared());
290 296
291 renderbuffer_manager_->SetInfo( 297 renderbuffer_manager_->SetInfo(
292 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2); 298 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2);
293 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 299 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
294 framebuffer_->IsPossiblyComplete(feature_info_.get())); 300 framebuffer_->IsPossiblyComplete(feature_info_.get()));
295 EXPECT_FALSE(framebuffer_->IsCleared()); 301 EXPECT_FALSE(framebuffer_->IsCleared());
296 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 302 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
297 303
298 // check marking them as cleared. 304 // Check marking them as cleared.
299 manager_.MarkAttachmentsAsCleared( 305 manager_.MarkAttachmentsAsCleared(
300 framebuffer_, renderbuffer_manager_.get(), texture_manager_.get()); 306 framebuffer_, renderbuffer_manager_.get(), texture_manager_.get());
301 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 307 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
302 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 308 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
303 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 309 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
304 framebuffer_->IsPossiblyComplete(feature_info_.get())); 310 framebuffer_->IsPossiblyComplete(feature_info_.get()));
305 EXPECT_TRUE(framebuffer_->IsCleared()); 311 EXPECT_TRUE(framebuffer_->IsCleared());
306 312
307 // Check adding one that is already cleared. 313 // Add another one to stencil attachment point.
308 renderbuffer_manager_->CreateRenderbuffer( 314 renderbuffer_manager_->CreateRenderbuffer(
309 kRenderbufferClient3Id, kRenderbufferService3Id); 315 kRenderbufferClient3Id, kRenderbufferService3Id);
310 Renderbuffer* renderbuffer3 = 316 Renderbuffer* renderbuffer3 =
311 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient3Id); 317 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient3Id);
312 ASSERT_TRUE(renderbuffer3 != NULL); 318 ASSERT_TRUE(renderbuffer3 != nullptr);
313 renderbuffer_manager_->SetInfo( 319 renderbuffer_manager_->SetInfo(
314 renderbuffer3, kSamples3, kFormat3, kWidth3, kHeight3); 320 renderbuffer3, kSamples3, kFormat3, kWidth3, kHeight3);
315 renderbuffer_manager_->SetCleared(renderbuffer3, true); 321 renderbuffer_manager_->SetCleared(renderbuffer3, true);
316 322
317 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer3); 323 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer3);
318 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 324 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
319 EXPECT_EQ(static_cast<GLenum>(kFormat1), 325 EXPECT_EQ(static_cast<GLenum>(kFormat1),
320 framebuffer_->GetReadBufferInternalFormat()); 326 framebuffer_->GetReadBufferInternalFormat());
321 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 327 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
322 EXPECT_TRUE(framebuffer_->HasStencilAttachment()); 328 EXPECT_TRUE(framebuffer_->HasStencilAttachment());
329 // Binding different images to depth and stencil attachment points should
330 // return FRAMEBUFFER_UNSUPPORTED.
331 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_UNSUPPORTED),
332 framebuffer_->IsPossiblyComplete(feature_info_.get()));
333
334 // Bind a renderbufer in format DEPTH_STENCIL to depth and stencil
335 // attachment points.
336 renderbuffer_manager_->CreateRenderbuffer(
337 kRenderbufferClient4Id, kRenderbufferService4Id);
338 Renderbuffer* renderbuffer4 =
339 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient4Id);
340 ASSERT_TRUE(renderbuffer4 != nullptr);
341 renderbuffer_manager_->SetInfo(
342 renderbuffer4, kSamples4, kFormat4, kWidth4, kHeight4);
343 renderbuffer_manager_->SetCleared(renderbuffer4, true);
344
345 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
346 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
347 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer4);
348 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer4);
349 EXPECT_EQ(static_cast<GLenum>(kFormat1),
350 framebuffer_->GetReadBufferInternalFormat());
351 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
352 EXPECT_TRUE(framebuffer_->HasStencilAttachment());
323 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 353 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
324 framebuffer_->IsPossiblyComplete(feature_info_.get())); 354 framebuffer_->IsPossiblyComplete(feature_info_.get()));
325 EXPECT_TRUE(framebuffer_->IsCleared()); 355 EXPECT_TRUE(framebuffer_->IsCleared());
326 356
327 // Check marking the renderbuffer as unclared. 357 // Check marking the renderbuffer as uncleared.
328 renderbuffer_manager_->SetInfo( 358 renderbuffer_manager_->SetInfo(
329 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1); 359 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1);
330 EXPECT_EQ(static_cast<GLenum>(kFormat1), 360 EXPECT_EQ(static_cast<GLenum>(kFormat1),
331 framebuffer_->GetReadBufferInternalFormat()); 361 framebuffer_->GetReadBufferInternalFormat());
332 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 362 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
333 EXPECT_TRUE(framebuffer_->HasStencilAttachment()); 363 EXPECT_TRUE(framebuffer_->HasStencilAttachment());
334 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 364 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
335 framebuffer_->IsPossiblyComplete(feature_info_.get())); 365 framebuffer_->IsPossiblyComplete(feature_info_.get()));
336 EXPECT_FALSE(framebuffer_->IsCleared()); 366 EXPECT_FALSE(framebuffer_->IsCleared());
337 367
338 const Framebuffer::Attachment* attachment = 368 const Framebuffer::Attachment* attachment =
339 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 369 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
340 ASSERT_TRUE(attachment != NULL); 370 ASSERT_TRUE(attachment != nullptr);
341 EXPECT_EQ(kWidth1, attachment->width()); 371 EXPECT_EQ(kWidth1, attachment->width());
342 EXPECT_EQ(kHeight1, attachment->height()); 372 EXPECT_EQ(kHeight1, attachment->height());
343 EXPECT_EQ(kSamples1, attachment->samples()); 373 EXPECT_EQ(kSamples1, attachment->samples());
344 EXPECT_EQ(kFormat1, attachment->internal_format()); 374 EXPECT_EQ(kFormat1, attachment->internal_format());
345 EXPECT_FALSE(attachment->cleared()); 375 EXPECT_FALSE(attachment->cleared());
346 376
347 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 377 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
348 378
349 // Clear it. 379 // Clear it.
350 manager_.MarkAttachmentsAsCleared( 380 manager_.MarkAttachmentsAsCleared(
351 framebuffer_, renderbuffer_manager_.get(), texture_manager_.get()); 381 framebuffer_, renderbuffer_manager_.get(), texture_manager_.get());
352 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 382 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
353 EXPECT_TRUE(framebuffer_->IsCleared()); 383 EXPECT_TRUE(framebuffer_->IsCleared());
354 384
355 // Check replacing an attachment 385 // Check replacing one attachment when both depth and stencil attachments
386 // are present.
356 renderbuffer_manager_->CreateRenderbuffer( 387 renderbuffer_manager_->CreateRenderbuffer(
357 kRenderbufferClient4Id, kRenderbufferService4Id); 388 kRenderbufferClient5Id, kRenderbufferService5Id);
358 Renderbuffer* renderbuffer4 = 389 Renderbuffer* renderbuffer5 =
359 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient4Id); 390 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient5Id);
360 ASSERT_TRUE(renderbuffer4 != NULL); 391 ASSERT_TRUE(renderbuffer5 != nullptr);
361 renderbuffer_manager_->SetInfo( 392 renderbuffer_manager_->SetInfo(
362 renderbuffer4, kSamples4, kFormat4, kWidth4, kHeight4); 393 renderbuffer5, kSamples5, kFormat5, kWidth5, kHeight5);
363 394
364 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer4); 395 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, renderbuffer5);
365 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 396 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
366 EXPECT_FALSE(framebuffer_->IsCleared()); 397 EXPECT_FALSE(framebuffer_->IsCleared());
367 398
368 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT); 399 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT);
369 ASSERT_TRUE(attachment != NULL); 400 ASSERT_TRUE(attachment != nullptr);
370 EXPECT_EQ(kWidth4, attachment->width()); 401 EXPECT_EQ(kWidth5, attachment->width());
371 EXPECT_EQ(kHeight4, attachment->height()); 402 EXPECT_EQ(kHeight5, attachment->height());
372 EXPECT_EQ(kSamples4, attachment->samples()); 403 EXPECT_EQ(kSamples5, attachment->samples());
373 EXPECT_EQ(kFormat4, attachment->internal_format()); 404 EXPECT_EQ(kFormat5, attachment->internal_format());
405 EXPECT_FALSE(attachment->cleared());
406 // Binding different images to depth and stencil attachment points should
407 // return FRAMEBUFFER_UNSUPPORTED.
408 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_UNSUPPORTED),
409 framebuffer_->IsPossiblyComplete(feature_info_.get()));
410
411 // Check replacing both depth and stencil attachments.
412 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer5);
413 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
414 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
415 EXPECT_FALSE(framebuffer_->IsCleared());
416
417 attachment = framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT);
418 EXPECT_EQ(kWidth5, attachment->width());
419 EXPECT_EQ(kHeight5, attachment->height());
420 EXPECT_EQ(kSamples5, attachment->samples());
421 EXPECT_EQ(kFormat5, attachment->internal_format());
374 EXPECT_FALSE(attachment->cleared()); 422 EXPECT_FALSE(attachment->cleared());
375 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 423 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
376 framebuffer_->IsPossiblyComplete(feature_info_.get())); 424 framebuffer_->IsPossiblyComplete(feature_info_.get()));
377 425
378 // Change samples. 426 // Change samples.
379 ASSERT_FALSE( 427 ASSERT_FALSE(
380 feature_info_->feature_flags().chromium_framebuffer_mixed_samples); 428 feature_info_->feature_flags().chromium_framebuffer_mixed_samples);
381 renderbuffer_manager_->SetInfo( 429 renderbuffer_manager_->SetInfo(
382 renderbuffer4, kDifferentSamples4, kFormat4, kWidth4, kHeight4); 430 renderbuffer5, kDifferentSamples5, kFormat5, kWidth5, kHeight5);
383 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE), 431 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE),
384 framebuffer_->IsPossiblyComplete(feature_info_.get())); 432 framebuffer_->IsPossiblyComplete(feature_info_.get()));
385 renderbuffer_manager_->SetInfo( 433 renderbuffer_manager_->SetInfo(
386 renderbuffer4, kSamples4, kFormat4, kWidth4, kHeight4); 434 renderbuffer5, kSamples5, kFormat5, kWidth5, kHeight5);
387 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 435 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
388 framebuffer_->IsPossiblyComplete(feature_info_.get())); 436 framebuffer_->IsPossiblyComplete(feature_info_.get()));
389 437
390 // Check changing an attachment. 438 // Check changing an attachment.
391 renderbuffer_manager_->SetInfo( 439 renderbuffer_manager_->SetInfo(
392 renderbuffer4, kSamples4, kFormat4, kWidth4 + 1, kHeight4); 440 renderbuffer5, kSamples5, kFormat5, kWidth5 + 1, kHeight5);
393 441
394 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT); 442 attachment = framebuffer_->GetAttachment(GL_STENCIL_ATTACHMENT);
395 ASSERT_TRUE(attachment != NULL); 443 ASSERT_TRUE(attachment != nullptr);
396 EXPECT_EQ(kWidth4 + 1, attachment->width()); 444 EXPECT_EQ(kWidth5 + 1, attachment->width());
397 EXPECT_EQ(kHeight4, attachment->height()); 445 EXPECT_EQ(kHeight5, attachment->height());
398 EXPECT_EQ(kSamples4, attachment->samples()); 446 EXPECT_EQ(kSamples5, attachment->samples());
399 EXPECT_EQ(kFormat4, attachment->internal_format()); 447 EXPECT_EQ(kFormat5, attachment->internal_format());
400 EXPECT_FALSE(attachment->cleared()); 448 EXPECT_FALSE(attachment->cleared());
401 EXPECT_FALSE(framebuffer_->IsCleared()); 449 EXPECT_FALSE(framebuffer_->IsCleared());
402 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT), 450 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT),
403 framebuffer_->IsPossiblyComplete(feature_info_.get())); 451 framebuffer_->IsPossiblyComplete(feature_info_.get()));
404 452
405 // Check removing it. 453 // Check removing it.
406 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL); 454 // Restore the width of renderbuffer5 to avoid INCOMPLETE_DIMENSIONS_EXT.
455 renderbuffer_manager_->SetInfo(
456 renderbuffer5, kSamples5, kFormat5, kWidth5, kHeight5);
457
458 framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, nullptr);
407 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 459 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
408 EXPECT_EQ(static_cast<GLenum>(kFormat1), 460 EXPECT_EQ(static_cast<GLenum>(kFormat1),
409 framebuffer_->GetReadBufferInternalFormat()); 461 framebuffer_->GetReadBufferInternalFormat());
410 EXPECT_TRUE(framebuffer_->HasDepthAttachment()); 462 EXPECT_TRUE(framebuffer_->HasDepthAttachment());
411 EXPECT_FALSE(framebuffer_->HasStencilAttachment()); 463 EXPECT_FALSE(framebuffer_->HasStencilAttachment());
412 464 EXPECT_FALSE(framebuffer_->IsCleared());
413 EXPECT_TRUE(framebuffer_->IsCleared());
414 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 465 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
415 framebuffer_->IsPossiblyComplete(feature_info_.get())); 466 framebuffer_->IsPossiblyComplete(feature_info_.get()));
416 467
417 // Remove depth, Set color to 0 size. 468 // Remove depth, Set color to 0 size.
418 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, NULL); 469 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, nullptr);
419 renderbuffer_manager_->SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0); 470 renderbuffer_manager_->SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0);
420 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 471 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
421 framebuffer_->IsPossiblyComplete(feature_info_.get())); 472 framebuffer_->IsPossiblyComplete(feature_info_.get()));
422 473
423 // Remove color. 474 // Remove color.
424 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL); 475 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, nullptr);
425 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 476 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
426 framebuffer_->IsPossiblyComplete(feature_info_.get())); 477 framebuffer_->IsPossiblyComplete(feature_info_.get()));
427 } 478 }
428 479
429 TEST_F(FramebufferInfoTest, AttachTexture2D) { 480 TEST_F(FramebufferInfoTest, AttachTexture2D) {
430 const GLuint kTextureClient1Id = 33; 481 const GLuint kTextureClient1Id = 33;
431 const GLuint kTextureService1Id = 333; 482 const GLuint kTextureService1Id = 333;
432 const GLuint kTextureClient2Id = 34; 483 const GLuint kTextureClient2Id = 34;
433 const GLuint kTextureService2Id = 334; 484 const GLuint kTextureService2Id = 334;
434 const GLint kDepth = 1; 485 const GLint kDepth = 1;
(...skipping 21 matching lines...) Expand all
456 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 507 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
457 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 508 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
458 EXPECT_FALSE( 509 EXPECT_FALSE(
459 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 510 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
460 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 511 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
461 framebuffer_->IsPossiblyComplete(feature_info_.get())); 512 framebuffer_->IsPossiblyComplete(feature_info_.get()));
462 513
463 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id); 514 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id);
464 scoped_refptr<TextureRef> texture1( 515 scoped_refptr<TextureRef> texture1(
465 texture_manager_->GetTexture(kTextureClient1Id)); 516 texture_manager_->GetTexture(kTextureClient1Id));
466 ASSERT_TRUE(texture1.get() != NULL); 517 ASSERT_TRUE(texture1.get() != nullptr);
467 518
468 // check adding one attachment 519 // check adding one attachment
469 framebuffer_->AttachTexture( 520 framebuffer_->AttachTexture(
470 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1); 521 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1);
471 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 522 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
472 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 523 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
473 framebuffer_->IsPossiblyComplete(feature_info_.get())); 524 framebuffer_->IsPossiblyComplete(feature_info_.get()));
474 EXPECT_TRUE(framebuffer_->IsCleared()); 525 EXPECT_TRUE(framebuffer_->IsCleared());
475 EXPECT_EQ(static_cast<GLenum>(0), 526 EXPECT_EQ(static_cast<GLenum>(0),
476 framebuffer_->GetReadBufferInternalFormat()); 527 framebuffer_->GetReadBufferInternalFormat());
(...skipping 17 matching lines...) Expand all
494 kFormat1, kWidth1, kHeight1, kDepth, kBorder, 545 kFormat1, kWidth1, kHeight1, kDepth, kBorder,
495 kFormat1, kType, gfx::Rect(kWidth1, kHeight1)); 546 kFormat1, kType, gfx::Rect(kWidth1, kHeight1));
496 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 547 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
497 framebuffer_->IsPossiblyComplete(feature_info_.get())); 548 framebuffer_->IsPossiblyComplete(feature_info_.get()));
498 EXPECT_TRUE(framebuffer_->IsCleared()); 549 EXPECT_TRUE(framebuffer_->IsCleared());
499 EXPECT_EQ(static_cast<GLenum>(kFormat1), 550 EXPECT_EQ(static_cast<GLenum>(kFormat1),
500 framebuffer_->GetReadBufferInternalFormat()); 551 framebuffer_->GetReadBufferInternalFormat());
501 552
502 const Framebuffer::Attachment* attachment = 553 const Framebuffer::Attachment* attachment =
503 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 554 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
504 ASSERT_TRUE(attachment != NULL); 555 ASSERT_TRUE(attachment != nullptr);
505 EXPECT_EQ(kWidth1, attachment->width()); 556 EXPECT_EQ(kWidth1, attachment->width());
506 EXPECT_EQ(kHeight1, attachment->height()); 557 EXPECT_EQ(kHeight1, attachment->height());
507 EXPECT_EQ(kSamples1, attachment->samples()); 558 EXPECT_EQ(kSamples1, attachment->samples());
508 EXPECT_EQ(kFormat1, attachment->internal_format()); 559 EXPECT_EQ(kFormat1, attachment->internal_format());
509 EXPECT_TRUE(attachment->cleared()); 560 EXPECT_TRUE(attachment->cleared());
510 561
511 // Check replacing an attachment 562 // Check replacing an attachment
512 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); 563 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id);
513 scoped_refptr<TextureRef> texture2( 564 scoped_refptr<TextureRef> texture2(
514 texture_manager_->GetTexture(kTextureClient2Id)); 565 texture_manager_->GetTexture(kTextureClient2Id));
515 ASSERT_TRUE(texture2.get() != NULL); 566 ASSERT_TRUE(texture2.get() != nullptr);
516 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D); 567 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D);
517 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel2, 568 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel2,
518 kFormat2, kWidth2, kHeight2, kDepth, kBorder, 569 kFormat2, kWidth2, kHeight2, kDepth, kBorder,
519 kFormat2, kType, gfx::Rect(kWidth2, kHeight2)); 570 kFormat2, kType, gfx::Rect(kWidth2, kHeight2));
520 571
521 framebuffer_->AttachTexture( 572 framebuffer_->AttachTexture(
522 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2); 573 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2);
523 EXPECT_EQ(static_cast<GLenum>(kFormat2), 574 EXPECT_EQ(static_cast<GLenum>(kFormat2),
524 framebuffer_->GetReadBufferInternalFormat()); 575 framebuffer_->GetReadBufferInternalFormat());
525 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 576 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
526 framebuffer_->IsPossiblyComplete(feature_info_.get())); 577 framebuffer_->IsPossiblyComplete(feature_info_.get()));
527 EXPECT_TRUE(framebuffer_->IsCleared()); 578 EXPECT_TRUE(framebuffer_->IsCleared());
528 579
529 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 580 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
530 ASSERT_TRUE(attachment != NULL); 581 ASSERT_TRUE(attachment != nullptr);
531 EXPECT_EQ(kWidth2, attachment->width()); 582 EXPECT_EQ(kWidth2, attachment->width());
532 EXPECT_EQ(kHeight2, attachment->height()); 583 EXPECT_EQ(kHeight2, attachment->height());
533 EXPECT_EQ(kSamples2, attachment->samples()); 584 EXPECT_EQ(kSamples2, attachment->samples());
534 EXPECT_EQ(kFormat2, attachment->internal_format()); 585 EXPECT_EQ(kFormat2, attachment->internal_format());
535 EXPECT_TRUE(attachment->cleared()); 586 EXPECT_TRUE(attachment->cleared());
536 587
537 // Check changing attachment 588 // Check changing attachment
538 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3, 589 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3,
539 kFormat3, kWidth3, kHeight3, kDepth, kBorder, 590 kFormat3, kWidth3, kHeight3, kDepth, kBorder,
540 kFormat3, kType, gfx::Rect()); 591 kFormat3, kType, gfx::Rect());
541 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 592 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
542 ASSERT_TRUE(attachment != NULL); 593 ASSERT_TRUE(attachment != nullptr);
543 EXPECT_EQ(kWidth3, attachment->width()); 594 EXPECT_EQ(kWidth3, attachment->width());
544 EXPECT_EQ(kHeight3, attachment->height()); 595 EXPECT_EQ(kHeight3, attachment->height());
545 EXPECT_EQ(kSamples3, attachment->samples()); 596 EXPECT_EQ(kSamples3, attachment->samples());
546 EXPECT_EQ(kFormat3, attachment->internal_format()); 597 EXPECT_EQ(kFormat3, attachment->internal_format());
547 EXPECT_FALSE(attachment->cleared()); 598 EXPECT_FALSE(attachment->cleared());
548 EXPECT_EQ(static_cast<GLenum>(kFormat3), 599 EXPECT_EQ(static_cast<GLenum>(kFormat3),
549 framebuffer_->GetReadBufferInternalFormat()); 600 framebuffer_->GetReadBufferInternalFormat());
550 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 601 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
551 framebuffer_->IsPossiblyComplete(feature_info_.get())); 602 framebuffer_->IsPossiblyComplete(feature_info_.get()));
552 EXPECT_FALSE(framebuffer_->IsCleared()); 603 EXPECT_FALSE(framebuffer_->IsCleared());
553 604
554 // Set to size 0 605 // Set to size 0
555 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3, 606 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3,
556 kFormat3, 0, 0, kDepth, kBorder, kFormat3, 607 kFormat3, 0, 0, kDepth, kBorder, kFormat3,
557 kType, gfx::Rect()); 608 kType, gfx::Rect());
558 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 609 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
559 framebuffer_->IsPossiblyComplete(feature_info_.get())); 610 framebuffer_->IsPossiblyComplete(feature_info_.get()));
560 611
561 // Check removing it. 612 // Check removing it.
562 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0); 613 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, nullptr, 0, 0, 0);
563 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 614 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == nullptr);
564 EXPECT_EQ(static_cast<GLenum>(0), 615 EXPECT_EQ(static_cast<GLenum>(0),
565 framebuffer_->GetReadBufferInternalFormat()); 616 framebuffer_->GetReadBufferInternalFormat());
566 617
567 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 618 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
568 framebuffer_->IsPossiblyComplete(feature_info_.get())); 619 framebuffer_->IsPossiblyComplete(feature_info_.get()));
569 EXPECT_TRUE(framebuffer_->IsCleared()); 620 EXPECT_TRUE(framebuffer_->IsCleared());
570 } 621 }
571 622
572 TEST_F(FramebufferInfoTest, AttachTextureCube) { 623 TEST_F(FramebufferInfoTest, AttachTextureCube) {
573 const GLuint kTextureClientId = 33; 624 const GLuint kTextureClientId = 33;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 EXPECT_EQ(kFormat, attachment->internal_format()); 734 EXPECT_EQ(kFormat, attachment->internal_format());
684 EXPECT_FALSE(attachment->cleared()); 735 EXPECT_FALSE(attachment->cleared());
685 } 736 }
686 737
687 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) { 738 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) {
688 const GLuint kTextureClientId = 33; 739 const GLuint kTextureClientId = 33;
689 const GLuint kTextureServiceId = 333; 740 const GLuint kTextureServiceId = 333;
690 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 741 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
691 scoped_refptr<TextureRef> texture( 742 scoped_refptr<TextureRef> texture(
692 texture_manager_->GetTexture(kTextureClientId)); 743 texture_manager_->GetTexture(kTextureClientId));
693 ASSERT_TRUE(texture.get() != NULL); 744 ASSERT_TRUE(texture.get() != nullptr);
694 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 745 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
695 framebuffer_->AttachTexture( 746 framebuffer_->AttachTexture(
696 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0); 747 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0);
697 const Framebuffer::Attachment* attachment = 748 const Framebuffer::Attachment* attachment =
698 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 749 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
699 ASSERT_TRUE(attachment != NULL); 750 ASSERT_TRUE(attachment != nullptr);
700 751
701 // Not cleared at all. 752 // Not cleared at all.
702 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 753 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4,
703 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 754 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
704 gfx::Rect()); 755 gfx::Rect());
705 EXPECT_FALSE(attachment->cleared()); 756 EXPECT_FALSE(attachment->cleared());
706 EXPECT_FALSE(attachment->IsPartiallyCleared()); 757 EXPECT_FALSE(attachment->IsPartiallyCleared());
707 EXPECT_FALSE(framebuffer_->IsCleared()); 758 EXPECT_FALSE(framebuffer_->IsCleared());
708 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 759 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
709 EXPECT_TRUE(framebuffer_->HasUnclearedColorAttachments()); 760 EXPECT_TRUE(framebuffer_->HasUnclearedColorAttachments());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 818 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
768 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); 819 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments());
769 } 820 }
770 821
771 TEST_F(FramebufferInfoTest, Clear3DTextureAttachments) { 822 TEST_F(FramebufferInfoTest, Clear3DTextureAttachments) {
772 const GLuint kTextureClientId = 33; 823 const GLuint kTextureClientId = 33;
773 const GLuint kTextureServiceId = 333; 824 const GLuint kTextureServiceId = 333;
774 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 825 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
775 scoped_refptr<TextureRef> texture( 826 scoped_refptr<TextureRef> texture(
776 texture_manager_->GetTexture(kTextureClientId)); 827 texture_manager_->GetTexture(kTextureClientId));
777 ASSERT_TRUE(texture.get() != NULL); 828 ASSERT_TRUE(texture.get() != nullptr);
778 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_3D); 829 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_3D);
779 framebuffer_->AttachTexture( 830 framebuffer_->AttachTexture(
780 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_3D, 0, 0); 831 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_3D, 0, 0);
781 const Framebuffer::Attachment* attachment = 832 const Framebuffer::Attachment* attachment =
782 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 833 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
783 ASSERT_TRUE(attachment != NULL); 834 ASSERT_TRUE(attachment != nullptr);
784 835
785 const int kWidth = 4; 836 const int kWidth = 4;
786 const int kHeight = 8; 837 const int kHeight = 8;
787 const int kDepth = 2; 838 const int kDepth = 2;
788 839
789 // Fully cleared. 840 // Fully cleared.
790 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8, 841 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8,
791 kWidth, kHeight, kDepth, 842 kWidth, kHeight, kDepth,
792 0, GL_RGBA, GL_UNSIGNED_BYTE, 843 0, GL_RGBA, GL_UNSIGNED_BYTE,
793 gfx::Rect(0, 0, kWidth, kHeight)); 844 gfx::Rect(0, 0, kWidth, kHeight));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 883 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
833 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); 884 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments());
834 } 885 }
835 886
836 TEST_F(FramebufferInfoTest, Clear3DOutsideRenderableRange) { 887 TEST_F(FramebufferInfoTest, Clear3DOutsideRenderableRange) {
837 const GLuint kTextureClientId = 33; 888 const GLuint kTextureClientId = 33;
838 const GLuint kTextureServiceId = 333; 889 const GLuint kTextureServiceId = 333;
839 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 890 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
840 scoped_refptr<TextureRef> texture( 891 scoped_refptr<TextureRef> texture(
841 texture_manager_->GetTexture(kTextureClientId)); 892 texture_manager_->GetTexture(kTextureClientId));
842 ASSERT_TRUE(texture.get() != NULL); 893 ASSERT_TRUE(texture.get() != nullptr);
843 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_3D); 894 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_3D);
844 // Set base level to 1 but attach level 0. 895 // Set base level to 1 but attach level 0.
845 TestHelper::SetTexParameteriWithExpectations(gl_.get(), 896 TestHelper::SetTexParameteriWithExpectations(gl_.get(),
846 error_state_.get(), 897 error_state_.get(),
847 texture_manager_.get(), 898 texture_manager_.get(),
848 texture.get(), 899 texture.get(),
849 GL_TEXTURE_BASE_LEVEL, 900 GL_TEXTURE_BASE_LEVEL,
850 1, 901 1,
851 GL_NO_ERROR); 902 GL_NO_ERROR);
852 framebuffer_->AttachTexture( 903 framebuffer_->AttachTexture(
853 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_3D, 0, 0); 904 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_3D, 0, 0);
854 const Framebuffer::Attachment* attachment = 905 const Framebuffer::Attachment* attachment =
855 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 906 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
856 ASSERT_TRUE(attachment != NULL); 907 ASSERT_TRUE(attachment != nullptr);
857 908
858 // Level 0 is not cleared at all. 909 // Level 0 is not cleared at all.
859 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_3D, 0, GL_RGBA, 4, 910 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_3D, 0, GL_RGBA, 4,
860 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 911 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
861 gfx::Rect()); 912 gfx::Rect());
862 // Level 1 is cleared. 913 // Level 1 is cleared.
863 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_3D, 1, GL_RGBA, 2, 914 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_3D, 1, GL_RGBA, 2,
864 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, 915 2, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE,
865 gfx::Rect(0, 0, 2, 2)); 916 gfx::Rect(0, 0, 2, 2));
866 EXPECT_FALSE(attachment->cleared()); 917 EXPECT_FALSE(attachment->cleared());
(...skipping 14 matching lines...) Expand all
881 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 932 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
882 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); 933 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments());
883 } 934 }
884 935
885 TEST_F(FramebufferInfoTest, ClearIntegerTextureAttachments) { 936 TEST_F(FramebufferInfoTest, ClearIntegerTextureAttachments) {
886 const GLuint kTextureClientId = 33; 937 const GLuint kTextureClientId = 33;
887 const GLuint kTextureServiceId = 333; 938 const GLuint kTextureServiceId = 333;
888 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 939 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
889 scoped_refptr<TextureRef> texture( 940 scoped_refptr<TextureRef> texture(
890 texture_manager_->GetTexture(kTextureClientId)); 941 texture_manager_->GetTexture(kTextureClientId));
891 ASSERT_TRUE(texture.get() != NULL); 942 ASSERT_TRUE(texture.get() != nullptr);
892 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 943 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
893 framebuffer_->AttachTexture( 944 framebuffer_->AttachTexture(
894 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0); 945 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0);
895 const Framebuffer::Attachment* attachment = 946 const Framebuffer::Attachment* attachment =
896 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 947 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
897 ASSERT_TRUE(attachment != NULL); 948 ASSERT_TRUE(attachment != nullptr);
898 949
899 const int kWidth = 4; 950 const int kWidth = 4;
900 const int kHeight = 8; 951 const int kHeight = 8;
901 952
902 // Fully cleared. 953 // Fully cleared.
903 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8UI, 954 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8UI,
904 kWidth, kHeight, 1, 955 kWidth, kHeight, 1,
905 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 956 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE,
906 gfx::Rect(0, 0, kWidth, kHeight)); 957 gfx::Rect(0, 0, kWidth, kHeight));
907 EXPECT_TRUE(attachment->cleared()); 958 EXPECT_TRUE(attachment->cleared());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 999 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
949 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); 1000 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments());
950 } 1001 }
951 1002
952 TEST_F(FramebufferInfoTest, ClearIntegerOutsideRenderableRange) { 1003 TEST_F(FramebufferInfoTest, ClearIntegerOutsideRenderableRange) {
953 const GLuint kTextureClientId = 33; 1004 const GLuint kTextureClientId = 33;
954 const GLuint kTextureServiceId = 333; 1005 const GLuint kTextureServiceId = 333;
955 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 1006 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
956 scoped_refptr<TextureRef> texture( 1007 scoped_refptr<TextureRef> texture(
957 texture_manager_->GetTexture(kTextureClientId)); 1008 texture_manager_->GetTexture(kTextureClientId));
958 ASSERT_TRUE(texture.get() != NULL); 1009 ASSERT_TRUE(texture.get() != nullptr);
959 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 1010 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
960 // Set base level to 1 but attach level 0. 1011 // Set base level to 1 but attach level 0.
961 TestHelper::SetTexParameteriWithExpectations(gl_.get(), 1012 TestHelper::SetTexParameteriWithExpectations(gl_.get(),
962 error_state_.get(), 1013 error_state_.get(),
963 texture_manager_.get(), 1014 texture_manager_.get(),
964 texture.get(), 1015 texture.get(),
965 GL_TEXTURE_BASE_LEVEL, 1016 GL_TEXTURE_BASE_LEVEL,
966 1, 1017 1,
967 GL_NO_ERROR); 1018 GL_NO_ERROR);
968 framebuffer_->AttachTexture( 1019 framebuffer_->AttachTexture(
969 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0); 1020 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0);
970 const Framebuffer::Attachment* attachment = 1021 const Framebuffer::Attachment* attachment =
971 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); 1022 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
972 ASSERT_TRUE(attachment != NULL); 1023 ASSERT_TRUE(attachment != nullptr);
973 1024
974 // Level 0 is not cleared at all. 1025 // Level 0 is not cleared at all.
975 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8UI, 4, 1026 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 0, GL_RGBA8UI, 4,
976 4, 1, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 1027 4, 1, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE,
977 gfx::Rect()); 1028 gfx::Rect());
978 // Level 1 is cleared. 1029 // Level 1 is cleared.
979 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 1, GL_RGBA8UI, 2, 1030 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, 1, GL_RGBA8UI, 2,
980 2, 1, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 1031 2, 1, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE,
981 gfx::Rect(0, 0, 2, 2)); 1032 gfx::Rect(0, 0, 2, 2));
982 EXPECT_FALSE(attachment->cleared()); 1033 EXPECT_FALSE(attachment->cleared());
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1257 const GLenum kInternalFormat = GL_RGBA32F; 1308 const GLenum kInternalFormat = GL_RGBA32F;
1258 const GLenum kTarget = GL_TEXTURE_2D; 1309 const GLenum kTarget = GL_TEXTURE_2D;
1259 const GLsizei kSamples = 0; 1310 const GLsizei kSamples = 0;
1260 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 1311 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
1261 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 1312 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
1262 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 1313 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
1263 1314
1264 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 1315 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
1265 scoped_refptr<TextureRef> texture( 1316 scoped_refptr<TextureRef> texture(
1266 texture_manager_->GetTexture(kTextureClientId)); 1317 texture_manager_->GetTexture(kTextureClientId));
1267 ASSERT_TRUE(texture.get() != NULL); 1318 ASSERT_TRUE(texture.get() != nullptr);
1268 1319
1269 framebuffer_->AttachTexture( 1320 framebuffer_->AttachTexture(
1270 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples); 1321 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples);
1271 EXPECT_EQ(static_cast<GLenum>(0), 1322 EXPECT_EQ(static_cast<GLenum>(0),
1272 framebuffer_->GetReadBufferInternalFormat()); 1323 framebuffer_->GetReadBufferInternalFormat());
1273 1324
1274 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 1325 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
1275 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, kLevel, 1326 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, kLevel,
1276 kInternalFormat, kWidth, kHeight, kDepth, 1327 kInternalFormat, kWidth, kHeight, kDepth,
1277 kBorder, kFormat, kType, gfx::Rect()); 1328 kBorder, kFormat, kType, gfx::Rect());
1278 // Texture with a sized float internalformat is allowed as an attachment 1329 // Texture with a sized float internalformat is allowed as an attachment
1279 // since float color attachment extension is present. 1330 // since float color attachment extension is present.
1280 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), 1331 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
1281 framebuffer_->IsPossiblyComplete(feature_info_.get())); 1332 framebuffer_->IsPossiblyComplete(feature_info_.get()));
1282 } 1333 }
1283 1334
1284 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) { 1335 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) {
1285 const GLuint kRenderbufferClient1Id = 33; 1336 const GLuint kRenderbufferClient1Id = 33;
1286 const GLuint kRenderbufferService1Id = 333; 1337 const GLuint kRenderbufferService1Id = 333;
1287 const GLuint kRenderbufferClient2Id = 34; 1338 const GLuint kRenderbufferClient2Id = 34;
1288 const GLuint kRenderbufferService2Id = 334; 1339 const GLuint kRenderbufferService2Id = 334;
1289 1340
1290 renderbuffer_manager_->CreateRenderbuffer( 1341 renderbuffer_manager_->CreateRenderbuffer(
1291 kRenderbufferClient1Id, kRenderbufferService1Id); 1342 kRenderbufferClient1Id, kRenderbufferService1Id);
1292 Renderbuffer* renderbuffer1 = 1343 Renderbuffer* renderbuffer1 =
1293 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id); 1344 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id);
1294 ASSERT_TRUE(renderbuffer1 != NULL); 1345 ASSERT_TRUE(renderbuffer1 != nullptr);
1295 renderbuffer_manager_->CreateRenderbuffer( 1346 renderbuffer_manager_->CreateRenderbuffer(
1296 kRenderbufferClient2Id, kRenderbufferService2Id); 1347 kRenderbufferClient2Id, kRenderbufferService2Id);
1297 Renderbuffer* renderbuffer2 = 1348 Renderbuffer* renderbuffer2 =
1298 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id); 1349 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id);
1299 ASSERT_TRUE(renderbuffer2 != NULL); 1350 ASSERT_TRUE(renderbuffer2 != nullptr);
1300 1351
1301 // Attach to 2 attachment points. 1352 // Attach to 2 attachment points.
1302 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1); 1353 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1);
1303 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer1); 1354 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer1);
1304 // Check they were attached. 1355 // Check they were attached.
1305 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 1356 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != nullptr);
1306 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 1357 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != nullptr);
1307 // Unbind unattached renderbuffer. 1358 // Unbind unattached renderbuffer.
1308 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer2); 1359 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer2);
1309 // Should be no-op. 1360 // Should be no-op.
1310 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 1361 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != nullptr);
1311 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 1362 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != nullptr);
1312 // Unbind renderbuffer. 1363 // Unbind renderbuffer.
1313 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1); 1364 framebuffer_->UnbindRenderbuffer(GL_RENDERBUFFER, renderbuffer1);
1314 // Check they were detached 1365 // Check they were detached
1315 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 1366 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == nullptr);
1316 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL); 1367 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == nullptr);
1317 } 1368 }
1318 1369
1319 TEST_F(FramebufferInfoTest, UnbindTexture) { 1370 TEST_F(FramebufferInfoTest, UnbindTexture) {
1320 const GLuint kTextureClient1Id = 33; 1371 const GLuint kTextureClient1Id = 33;
1321 const GLuint kTextureService1Id = 333; 1372 const GLuint kTextureService1Id = 333;
1322 const GLuint kTextureClient2Id = 34; 1373 const GLuint kTextureClient2Id = 34;
1323 const GLuint kTextureService2Id = 334; 1374 const GLuint kTextureService2Id = 334;
1324 const GLenum kTarget1 = GL_TEXTURE_2D; 1375 const GLenum kTarget1 = GL_TEXTURE_2D;
1325 const GLint kLevel1 = 0; 1376 const GLint kLevel1 = 0;
1326 const GLint kSamples1 = 0; 1377 const GLint kSamples1 = 0;
1327 1378
1328 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id); 1379 texture_manager_->CreateTexture(kTextureClient1Id, kTextureService1Id);
1329 scoped_refptr<TextureRef> texture1( 1380 scoped_refptr<TextureRef> texture1(
1330 texture_manager_->GetTexture(kTextureClient1Id)); 1381 texture_manager_->GetTexture(kTextureClient1Id));
1331 ASSERT_TRUE(texture1.get() != NULL); 1382 ASSERT_TRUE(texture1.get() != nullptr);
1332 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); 1383 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id);
1333 scoped_refptr<TextureRef> texture2( 1384 scoped_refptr<TextureRef> texture2(
1334 texture_manager_->GetTexture(kTextureClient2Id)); 1385 texture_manager_->GetTexture(kTextureClient2Id));
1335 ASSERT_TRUE(texture2.get() != NULL); 1386 ASSERT_TRUE(texture2.get() != nullptr);
1336 1387
1337 // Attach to 2 attachment points. 1388 // Attach to 2 attachment points.
1338 framebuffer_->AttachTexture( 1389 framebuffer_->AttachTexture(
1339 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1); 1390 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1);
1340 framebuffer_->AttachTexture( 1391 framebuffer_->AttachTexture(
1341 GL_DEPTH_ATTACHMENT, texture1.get(), kTarget1, kLevel1, kSamples1); 1392 GL_DEPTH_ATTACHMENT, texture1.get(), kTarget1, kLevel1, kSamples1);
1342 // Check they were attached. 1393 // Check they were attached.
1343 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 1394 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != nullptr);
1344 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 1395 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != nullptr);
1345 // Unbind unattached texture. 1396 // Unbind unattached texture.
1346 framebuffer_->UnbindTexture(kTarget1, texture2.get()); 1397 framebuffer_->UnbindTexture(kTarget1, texture2.get());
1347 // Should be no-op. 1398 // Should be no-op.
1348 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); 1399 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) != nullptr);
1349 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); 1400 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) != nullptr);
1350 // Unbind texture. 1401 // Unbind texture.
1351 framebuffer_->UnbindTexture(kTarget1, texture1.get()); 1402 framebuffer_->UnbindTexture(kTarget1, texture1.get());
1352 // Check they were detached 1403 // Check they were detached
1353 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 1404 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == nullptr);
1354 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL); 1405 EXPECT_TRUE(framebuffer_->GetAttachment(GL_DEPTH_ATTACHMENT) == nullptr);
1355 } 1406 }
1356 1407
1357 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) { 1408 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) {
1358 const GLuint kRenderbufferClient1Id = 33; 1409 const GLuint kRenderbufferClient1Id = 33;
1359 const GLuint kRenderbufferService1Id = 333; 1410 const GLuint kRenderbufferService1Id = 333;
1360 const GLuint kTextureClient2Id = 34; 1411 const GLuint kTextureClient2Id = 34;
1361 const GLuint kTextureService2Id = 334; 1412 const GLuint kTextureService2Id = 334;
1362 const GLenum kTarget1 = GL_TEXTURE_2D; 1413 const GLenum kTarget1 = GL_TEXTURE_2D;
1363 const GLint kLevel1 = 0; 1414 const GLint kLevel1 = 0;
1364 const GLint kSamples1 = 0; 1415 const GLint kSamples1 = 0;
1365 1416
1366 renderbuffer_manager_->CreateRenderbuffer( 1417 renderbuffer_manager_->CreateRenderbuffer(
1367 kRenderbufferClient1Id, kRenderbufferService1Id); 1418 kRenderbufferClient1Id, kRenderbufferService1Id);
1368 Renderbuffer* renderbuffer1 = 1419 Renderbuffer* renderbuffer1 =
1369 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id); 1420 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id);
1370 ASSERT_TRUE(renderbuffer1 != NULL); 1421 ASSERT_TRUE(renderbuffer1 != nullptr);
1371 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); 1422 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id);
1372 scoped_refptr<TextureRef> texture2( 1423 scoped_refptr<TextureRef> texture2(
1373 texture_manager_->GetTexture(kTextureClient2Id)); 1424 texture_manager_->GetTexture(kTextureClient2Id));
1374 ASSERT_TRUE(texture2.get() != NULL); 1425 ASSERT_TRUE(texture2.get() != nullptr);
1375 1426
1376 // Check MarkAsComlete marks as complete. 1427 // Check MarkAsComlete marks as complete.
1377 manager_.MarkAsComplete(framebuffer_); 1428 manager_.MarkAsComplete(framebuffer_);
1378 EXPECT_TRUE(manager_.IsComplete(framebuffer_)); 1429 EXPECT_TRUE(manager_.IsComplete(framebuffer_));
1379 1430
1380 // Check at attaching marks as not complete. 1431 // Check at attaching marks as not complete.
1381 framebuffer_->AttachTexture( 1432 framebuffer_->AttachTexture(
1382 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1, kSamples1); 1433 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget1, kLevel1, kSamples1);
1383 EXPECT_FALSE(manager_.IsComplete(framebuffer_)); 1434 EXPECT_FALSE(manager_.IsComplete(framebuffer_));
1384 manager_.MarkAsComplete(framebuffer_); 1435 manager_.MarkAsComplete(framebuffer_);
(...skipping 21 matching lines...) Expand all
1406 const GLuint kTextureClient2Id = 34; 1457 const GLuint kTextureClient2Id = 34;
1407 const GLuint kTextureService2Id = 334; 1458 const GLuint kTextureService2Id = 334;
1408 const GLenum kTarget1 = GL_TEXTURE_2D; 1459 const GLenum kTarget1 = GL_TEXTURE_2D;
1409 const GLint kLevel1 = 0; 1460 const GLint kLevel1 = 0;
1410 const GLint kSamples1 = 0; 1461 const GLint kSamples1 = 0;
1411 1462
1412 renderbuffer_manager_->CreateRenderbuffer( 1463 renderbuffer_manager_->CreateRenderbuffer(
1413 kRenderbufferClient1Id, kRenderbufferService1Id); 1464 kRenderbufferClient1Id, kRenderbufferService1Id);
1414 Renderbuffer* renderbuffer1 = 1465 Renderbuffer* renderbuffer1 =
1415 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id); 1466 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id);
1416 ASSERT_TRUE(renderbuffer1 != NULL); 1467 ASSERT_TRUE(renderbuffer1 != nullptr);
1417 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); 1468 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id);
1418 scoped_refptr<TextureRef> texture2( 1469 scoped_refptr<TextureRef> texture2(
1419 texture_manager_->GetTexture(kTextureClient2Id)); 1470 texture_manager_->GetTexture(kTextureClient2Id));
1420 ASSERT_TRUE(texture2.get() != NULL); 1471 ASSERT_TRUE(texture2.get() != nullptr);
1421 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D); 1472 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D);
1422 1473
1423 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) 1474 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER))
1424 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) 1475 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE))
1425 .RetiresOnSaturation(); 1476 .RetiresOnSaturation();
1426 framebuffer_->GetStatus(texture_manager_.get(), GL_FRAMEBUFFER); 1477 framebuffer_->GetStatus(texture_manager_.get(), GL_FRAMEBUFFER);
1427 1478
1428 // Check a second call for the same type does not call anything 1479 // Check a second call for the same type does not call anything
1429 framebuffer_->GetStatus(texture_manager_.get(), GL_FRAMEBUFFER); 1480 framebuffer_->GetStatus(texture_manager_.get(), GL_FRAMEBUFFER);
1430 1481
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 1553
1503 void InitializeContext(const char* gl_version, const char* extensions) { 1554 void InitializeContext(const char* gl_version, const char* extensions) {
1504 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions); 1555 GpuServiceTest::SetUpWithGLVersion(gl_version, extensions);
1505 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(), 1556 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_.get(),
1506 extensions, "", gl_version); 1557 extensions, "", gl_version);
1507 feature_info_->InitializeForTesting(CONTEXT_TYPE_OPENGLES3); 1558 feature_info_->InitializeForTesting(CONTEXT_TYPE_OPENGLES3);
1508 decoder_.reset(new MockGLES2Decoder()); 1559 decoder_.reset(new MockGLES2Decoder());
1509 manager_.CreateFramebuffer(kClient1Id, kService1Id); 1560 manager_.CreateFramebuffer(kClient1Id, kService1Id);
1510 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>()); 1561 error_state_.reset(new ::testing::StrictMock<gles2::MockErrorState>());
1511 framebuffer_ = manager_.GetFramebuffer(kClient1Id); 1562 framebuffer_ = manager_.GetFramebuffer(kClient1Id);
1512 ASSERT_TRUE(framebuffer_ != NULL); 1563 ASSERT_TRUE(framebuffer_ != nullptr);
1513 } 1564 }
1514 }; 1565 };
1515 1566
1516 TEST_F(FramebufferInfoES3Test, DifferentDimensions) { 1567 TEST_F(FramebufferInfoES3Test, DifferentDimensions) {
1517 const GLuint kRenderbufferClient1Id = 33; 1568 const GLuint kRenderbufferClient1Id = 33;
1518 const GLuint kRenderbufferService1Id = 333; 1569 const GLuint kRenderbufferService1Id = 333;
1519 const GLuint kRenderbufferClient2Id = 34; 1570 const GLuint kRenderbufferClient2Id = 34;
1520 const GLuint kRenderbufferService2Id = 334; 1571 const GLuint kRenderbufferService2Id = 334;
1521 const GLsizei kWidth1 = 16; 1572 const GLsizei kWidth1 = 16;
1522 const GLsizei kHeight1 = 32; 1573 const GLsizei kHeight1 = 32;
1523 const GLenum kFormat1 = GL_RGBA4; 1574 const GLenum kFormat1 = GL_RGBA4;
1524 const GLsizei kSamples1 = 0; 1575 const GLsizei kSamples1 = 0;
1525 const GLsizei kWidth2 = 32; // Different from kWidth1 1576 const GLsizei kWidth2 = 32; // Different from kWidth1
1526 const GLsizei kHeight2 = 32; 1577 const GLsizei kHeight2 = 32;
1527 const GLenum kFormat2 = GL_DEPTH_COMPONENT16; 1578 const GLenum kFormat2 = GL_DEPTH_COMPONENT16;
1528 const GLsizei kSamples2 = 0; 1579 const GLsizei kSamples2 = 0;
1529 1580
1530 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); 1581 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
1531 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); 1582 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
1532 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); 1583 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
1533 EXPECT_FALSE( 1584 EXPECT_FALSE(
1534 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); 1585 framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
1535 1586
1536 renderbuffer_manager_->CreateRenderbuffer( 1587 renderbuffer_manager_->CreateRenderbuffer(
1537 kRenderbufferClient1Id, kRenderbufferService1Id); 1588 kRenderbufferClient1Id, kRenderbufferService1Id);
1538 Renderbuffer* renderbuffer1 = 1589 Renderbuffer* renderbuffer1 =
1539 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id); 1590 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient1Id);
1540 ASSERT_TRUE(renderbuffer1 != NULL); 1591 ASSERT_TRUE(renderbuffer1 != nullptr);
1541 renderbuffer_manager_->SetInfo( 1592 renderbuffer_manager_->SetInfo(
1542 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1); 1593 renderbuffer1, kSamples1, kFormat1, kWidth1, kHeight1);
1543 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1); 1594 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, renderbuffer1);
1544 1595
1545 renderbuffer_manager_->CreateRenderbuffer( 1596 renderbuffer_manager_->CreateRenderbuffer(
1546 kRenderbufferClient2Id, kRenderbufferService2Id); 1597 kRenderbufferClient2Id, kRenderbufferService2Id);
1547 Renderbuffer* renderbuffer2 = 1598 Renderbuffer* renderbuffer2 =
1548 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id); 1599 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClient2Id);
1549 ASSERT_TRUE(renderbuffer2 != NULL); 1600 ASSERT_TRUE(renderbuffer2 != nullptr);
1550 renderbuffer_manager_->SetInfo( 1601 renderbuffer_manager_->SetInfo(
1551 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2); 1602 renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2);
1552 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2); 1603 framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, renderbuffer2);
1553 1604
1554 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT), 1605 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT),
1555 framebuffer_->IsPossiblyComplete(feature_info_.get())); 1606 framebuffer_->IsPossiblyComplete(feature_info_.get()));
1556 } 1607 }
1557 1608
1558 TEST_F(FramebufferInfoES3Test, DuplicatedAttachments) { 1609 TEST_F(FramebufferInfoES3Test, DuplicatedAttachments) {
1559 const GLuint kTextureClientId = 33; 1610 const GLuint kTextureClientId = 33;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1597 EXPECT_EQ(static_cast<GLenum>(GL_NONE), framebuffer_->read_buffer()); 1648 EXPECT_EQ(static_cast<GLenum>(GL_NONE), framebuffer_->read_buffer());
1598 EXPECT_FALSE(framebuffer_->GetReadBufferAttachment()); 1649 EXPECT_FALSE(framebuffer_->GetReadBufferAttachment());
1599 1650
1600 framebuffer_->set_read_buffer(GL_COLOR_ATTACHMENT1); 1651 framebuffer_->set_read_buffer(GL_COLOR_ATTACHMENT1);
1601 EXPECT_FALSE(framebuffer_->GetReadBufferAttachment()); 1652 EXPECT_FALSE(framebuffer_->GetReadBufferAttachment());
1602 1653
1603 renderbuffer_manager_->CreateRenderbuffer( 1654 renderbuffer_manager_->CreateRenderbuffer(
1604 kRenderbufferClientId, kRenderbufferServiceId); 1655 kRenderbufferClientId, kRenderbufferServiceId);
1605 Renderbuffer* renderbuffer = 1656 Renderbuffer* renderbuffer =
1606 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId); 1657 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId);
1607 ASSERT_TRUE(renderbuffer != NULL); 1658 ASSERT_TRUE(renderbuffer != nullptr);
1608 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer); 1659 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer);
1609 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment()); 1660 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment());
1610 } 1661 }
1611 1662
1612 } // namespace gles2 1663 } // namespace gles2
1613 } // namespace gpu 1664 } // namespace gpu
1614 1665
1615 1666
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698