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
3 // found in the LICENSE file.
5 #include "gpu/command_buffer/service/error_state_mock.h"
6 #include "gpu/command_buffer/service/framebuffer_manager.h"
7 #include "gpu/command_buffer/service/feature_info.h"
8 #include "gpu/command_buffer/service/gpu_service_test.h"
9 #include "gpu/command_buffer/service/renderbuffer_manager.h"
10 #include "gpu/command_buffer/service/test_helper.h"
11 #include "gpu/command_buffer/service/texture_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gl/gl_mock.h"
16 using ::testing::Return
;
22 const GLint kMaxTextureSize
= 64;
23 const GLint kMaxCubemapSize
= 64;
24 const GLint kMaxRectangleTextureSize
= 64;
25 const GLint kMaxRenderbufferSize
= 64;
26 const GLint kMaxSamples
= 4;
27 const uint32 kMaxDrawBuffers
= 16;
28 const uint32 kMaxColorAttachments
= 16;
29 const bool kUseDefaultTextures
= false;
33 class FramebufferManagerTest
: public GpuServiceTest
{
35 FramebufferManagerTest()
37 feature_info_(new FeatureInfo()) {
38 texture_manager_
.reset(new TextureManager(NULL
,
42 kMaxRectangleTextureSize
,
43 kUseDefaultTextures
));
44 renderbuffer_manager_
.reset(new RenderbufferManager(NULL
,
47 feature_info_
.get()));
49 ~FramebufferManagerTest() override
{
50 manager_
.Destroy(false);
51 texture_manager_
->Destroy(false);
52 renderbuffer_manager_
->Destroy(false);
57 FramebufferManager manager_
;
58 scoped_refptr
<FeatureInfo
> feature_info_
;
59 scoped_ptr
<TextureManager
> texture_manager_
;
60 scoped_ptr
<RenderbufferManager
> renderbuffer_manager_
;
63 TEST_F(FramebufferManagerTest
, Basic
) {
64 const GLuint kClient1Id
= 1;
65 const GLuint kService1Id
= 11;
66 const GLuint kClient2Id
= 2;
67 // Check we can create framebuffer.
68 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
69 // Check framebuffer got created.
70 Framebuffer
* framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
71 ASSERT_TRUE(framebuffer1
!= NULL
);
72 EXPECT_FALSE(framebuffer1
->IsDeleted());
73 EXPECT_EQ(kService1Id
, framebuffer1
->service_id());
75 EXPECT_TRUE(manager_
.GetClientId(framebuffer1
->service_id(), &client_id
));
76 EXPECT_EQ(kClient1Id
, client_id
);
77 // Check we get nothing for a non-existent framebuffer.
78 EXPECT_TRUE(manager_
.GetFramebuffer(kClient2Id
) == NULL
);
79 // Check trying to a remove non-existent framebuffers does not crash.
80 manager_
.RemoveFramebuffer(kClient2Id
);
81 // Check framebuffer gets deleted when last reference is released.
82 EXPECT_CALL(*gl_
, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id
)))
84 .RetiresOnSaturation();
85 // Check we can't get the framebuffer after we remove it.
86 manager_
.RemoveFramebuffer(kClient1Id
);
87 EXPECT_TRUE(manager_
.GetFramebuffer(kClient1Id
) == NULL
);
90 TEST_F(FramebufferManagerTest
, Destroy
) {
91 const GLuint kClient1Id
= 1;
92 const GLuint kService1Id
= 11;
93 // Check we can create framebuffer.
94 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
95 // Check framebuffer got created.
96 Framebuffer
* framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
97 ASSERT_TRUE(framebuffer1
!= NULL
);
98 EXPECT_CALL(*gl_
, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id
)))
100 .RetiresOnSaturation();
101 manager_
.Destroy(true);
102 // Check the resources were released.
103 framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
104 ASSERT_TRUE(framebuffer1
== NULL
);
107 class FramebufferInfoTest
: public GpuServiceTest
{
109 static const GLuint kClient1Id
= 1;
110 static const GLuint kService1Id
= 11;
112 FramebufferInfoTest()
113 : manager_(kMaxDrawBuffers
, kMaxColorAttachments
),
114 feature_info_(new FeatureInfo()) {
115 texture_manager_
.reset(new TextureManager(NULL
,
119 kMaxRectangleTextureSize
,
120 kUseDefaultTextures
));
121 renderbuffer_manager_
.reset(new RenderbufferManager(NULL
,
122 kMaxRenderbufferSize
,
124 feature_info_
.get()));
126 ~FramebufferInfoTest() override
{
127 manager_
.Destroy(false);
128 texture_manager_
->Destroy(false);
129 renderbuffer_manager_
->Destroy(false);
133 void SetUp() override
{
134 InitializeContext("2.0", "GL_EXT_framebuffer_object");
137 void InitializeContext(const char* gl_version
, const char* extensions
) {
138 GpuServiceTest::SetUpWithGLVersion(gl_version
, extensions
);
139 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_
.get(),
140 extensions
, "", gl_version
);
141 feature_info_
->Initialize();
142 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
143 error_state_
.reset(new ::testing::StrictMock
<gles2::MockErrorState
>());
144 framebuffer_
= manager_
.GetFramebuffer(kClient1Id
);
145 ASSERT_TRUE(framebuffer_
!= NULL
);
148 FramebufferManager manager_
;
149 Framebuffer
* framebuffer_
;
150 scoped_refptr
<FeatureInfo
> feature_info_
;
151 scoped_ptr
<TextureManager
> texture_manager_
;
152 scoped_ptr
<RenderbufferManager
> renderbuffer_manager_
;
153 scoped_ptr
<MockErrorState
> error_state_
;
156 // GCC requires these declarations, but MSVC requires they not be present
157 #ifndef COMPILER_MSVC
158 const GLuint
FramebufferInfoTest::kClient1Id
;
159 const GLuint
FramebufferInfoTest::kService1Id
;
162 TEST_F(FramebufferInfoTest
, Basic
) {
163 EXPECT_EQ(kService1Id
, framebuffer_
->service_id());
164 EXPECT_FALSE(framebuffer_
->IsDeleted());
165 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
));
166 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
));
167 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
));
169 NULL
== framebuffer_
->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
170 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
171 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
172 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
173 framebuffer_
->IsPossiblyComplete());
174 EXPECT_TRUE(framebuffer_
->IsCleared());
175 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
176 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
179 TEST_F(FramebufferInfoTest
, AttachRenderbuffer
) {
180 const GLuint kRenderbufferClient1Id
= 33;
181 const GLuint kRenderbufferService1Id
= 333;
182 const GLuint kRenderbufferClient2Id
= 34;
183 const GLuint kRenderbufferService2Id
= 334;
184 const GLuint kRenderbufferClient3Id
= 35;
185 const GLuint kRenderbufferService3Id
= 335;
186 const GLuint kRenderbufferClient4Id
= 36;
187 const GLuint kRenderbufferService4Id
= 336;
188 const GLsizei kWidth1
= 16;
189 const GLsizei kHeight1
= 32;
190 const GLenum kFormat1
= GL_RGBA4
;
191 const GLenum kBadFormat1
= GL_DEPTH_COMPONENT16
;
192 const GLsizei kSamples1
= 0;
193 const GLsizei kWidth2
= 16;
194 const GLsizei kHeight2
= 32;
195 const GLenum kFormat2
= GL_DEPTH_COMPONENT16
;
196 const GLsizei kSamples2
= 0;
197 const GLsizei kWidth3
= 16;
198 const GLsizei kHeight3
= 32;
199 const GLenum kFormat3
= GL_STENCIL_INDEX8
;
200 const GLsizei kSamples3
= 0;
201 const GLsizei kWidth4
= 16;
202 const GLsizei kHeight4
= 32;
203 const GLenum kFormat4
= GL_STENCIL_INDEX8
;
204 const GLsizei kSamples4
= 0;
206 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
207 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
208 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
210 framebuffer_
->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
212 renderbuffer_manager_
->CreateRenderbuffer(
213 kRenderbufferClient1Id
, kRenderbufferService1Id
);
214 Renderbuffer
* renderbuffer1
=
215 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient1Id
);
216 ASSERT_TRUE(renderbuffer1
!= NULL
);
218 // check adding one attachment
219 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, renderbuffer1
);
220 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
221 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
222 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA4
),
223 framebuffer_
->GetColorAttachmentFormat());
224 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
225 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
226 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
227 framebuffer_
->IsPossiblyComplete());
228 EXPECT_TRUE(framebuffer_
->IsCleared());
230 // Try a format that's not good for COLOR_ATTACHMENT0.
231 renderbuffer_manager_
->SetInfo(
232 renderbuffer1
, kSamples1
, kBadFormat1
, kWidth1
, kHeight1
);
233 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
234 framebuffer_
->IsPossiblyComplete());
236 // Try a good format.
237 renderbuffer_manager_
->SetInfo(
238 renderbuffer1
, kSamples1
, kFormat1
, kWidth1
, kHeight1
);
239 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
240 framebuffer_
->GetColorAttachmentFormat());
241 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
242 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
243 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
244 framebuffer_
->IsPossiblyComplete());
245 EXPECT_FALSE(framebuffer_
->IsCleared());
247 // check adding another
248 renderbuffer_manager_
->CreateRenderbuffer(
249 kRenderbufferClient2Id
, kRenderbufferService2Id
);
250 Renderbuffer
* renderbuffer2
=
251 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient2Id
);
252 ASSERT_TRUE(renderbuffer2
!= NULL
);
253 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer2
);
254 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
255 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
256 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
257 framebuffer_
->GetColorAttachmentFormat());
258 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
259 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
260 // The attachment has a size of 0,0 so depending on the order of the map
261 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0
262 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other
264 GLenum status
= framebuffer_
->IsPossiblyComplete();
266 status
== GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
||
267 status
== GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
);
268 EXPECT_FALSE(framebuffer_
->IsCleared());
270 renderbuffer_manager_
->SetInfo(
271 renderbuffer2
, kSamples2
, kFormat2
, kWidth2
, kHeight2
);
272 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
273 framebuffer_
->IsPossiblyComplete());
274 EXPECT_FALSE(framebuffer_
->IsCleared());
275 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
277 // check marking them as cleared.
278 manager_
.MarkAttachmentsAsCleared(
279 framebuffer_
, renderbuffer_manager_
.get(), texture_manager_
.get());
280 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
281 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
282 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
283 framebuffer_
->IsPossiblyComplete());
284 EXPECT_TRUE(framebuffer_
->IsCleared());
286 // Check adding one that is already cleared.
287 renderbuffer_manager_
->CreateRenderbuffer(
288 kRenderbufferClient3Id
, kRenderbufferService3Id
);
289 Renderbuffer
* renderbuffer3
=
290 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient3Id
);
291 ASSERT_TRUE(renderbuffer3
!= NULL
);
292 renderbuffer_manager_
->SetInfo(
293 renderbuffer3
, kSamples3
, kFormat3
, kWidth3
, kHeight3
);
294 renderbuffer_manager_
->SetCleared(renderbuffer3
, true);
296 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, renderbuffer3
);
297 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
298 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
299 framebuffer_
->GetColorAttachmentFormat());
300 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
301 EXPECT_TRUE(framebuffer_
->HasStencilAttachment());
302 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
303 framebuffer_
->IsPossiblyComplete());
304 EXPECT_TRUE(framebuffer_
->IsCleared());
306 // Check marking the renderbuffer as unclared.
307 renderbuffer_manager_
->SetInfo(
308 renderbuffer1
, kSamples1
, kFormat1
, kWidth1
, kHeight1
);
309 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
310 framebuffer_
->GetColorAttachmentFormat());
311 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
312 EXPECT_TRUE(framebuffer_
->HasStencilAttachment());
313 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
314 framebuffer_
->IsPossiblyComplete());
315 EXPECT_FALSE(framebuffer_
->IsCleared());
317 const Framebuffer::Attachment
* attachment
=
318 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
319 ASSERT_TRUE(attachment
!= NULL
);
320 EXPECT_EQ(kWidth1
, attachment
->width());
321 EXPECT_EQ(kHeight1
, attachment
->height());
322 EXPECT_EQ(kSamples1
, attachment
->samples());
323 EXPECT_EQ(kFormat1
, attachment
->internal_format());
324 EXPECT_FALSE(attachment
->cleared());
326 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
329 manager_
.MarkAttachmentsAsCleared(
330 framebuffer_
, renderbuffer_manager_
.get(), texture_manager_
.get());
331 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
332 EXPECT_TRUE(framebuffer_
->IsCleared());
334 // Check replacing an attachment
335 renderbuffer_manager_
->CreateRenderbuffer(
336 kRenderbufferClient4Id
, kRenderbufferService4Id
);
337 Renderbuffer
* renderbuffer4
=
338 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient4Id
);
339 ASSERT_TRUE(renderbuffer4
!= NULL
);
340 renderbuffer_manager_
->SetInfo(
341 renderbuffer4
, kSamples4
, kFormat4
, kWidth4
, kHeight4
);
343 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, renderbuffer4
);
344 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
345 EXPECT_FALSE(framebuffer_
->IsCleared());
347 attachment
= framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
);
348 ASSERT_TRUE(attachment
!= NULL
);
349 EXPECT_EQ(kWidth4
, attachment
->width());
350 EXPECT_EQ(kHeight4
, attachment
->height());
351 EXPECT_EQ(kSamples4
, attachment
->samples());
352 EXPECT_EQ(kFormat4
, attachment
->internal_format());
353 EXPECT_FALSE(attachment
->cleared());
354 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
355 framebuffer_
->IsPossiblyComplete());
357 // Check changing an attachment.
358 renderbuffer_manager_
->SetInfo(
359 renderbuffer4
, kSamples4
, kFormat4
, kWidth4
+ 1, kHeight4
);
361 attachment
= framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
);
362 ASSERT_TRUE(attachment
!= NULL
);
363 EXPECT_EQ(kWidth4
+ 1, attachment
->width());
364 EXPECT_EQ(kHeight4
, attachment
->height());
365 EXPECT_EQ(kSamples4
, attachment
->samples());
366 EXPECT_EQ(kFormat4
, attachment
->internal_format());
367 EXPECT_FALSE(attachment
->cleared());
368 EXPECT_FALSE(framebuffer_
->IsCleared());
369 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
),
370 framebuffer_
->IsPossiblyComplete());
372 // Check removing it.
373 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, NULL
);
374 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
375 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
376 framebuffer_
->GetColorAttachmentFormat());
377 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
378 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
380 EXPECT_TRUE(framebuffer_
->IsCleared());
381 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
382 framebuffer_
->IsPossiblyComplete());
384 // Remove depth, Set color to 0 size.
385 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, NULL
);
386 renderbuffer_manager_
->SetInfo(renderbuffer1
, kSamples1
, kFormat1
, 0, 0);
387 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
388 framebuffer_
->IsPossiblyComplete());
391 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, NULL
);
392 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
393 framebuffer_
->IsPossiblyComplete());
396 TEST_F(FramebufferInfoTest
, AttachTexture
) {
397 const GLuint kTextureClient1Id
= 33;
398 const GLuint kTextureService1Id
= 333;
399 const GLuint kTextureClient2Id
= 34;
400 const GLuint kTextureService2Id
= 334;
401 const GLint kDepth
= 1;
402 const GLint kBorder
= 0;
403 const GLenum kType
= GL_UNSIGNED_BYTE
;
404 const GLsizei kWidth1
= 16;
405 const GLsizei kHeight1
= 32;
406 const GLint kLevel1
= 0;
407 const GLenum kFormat1
= GL_RGBA
;
408 const GLenum kBadFormat1
= GL_DEPTH_COMPONENT16
;
409 const GLenum kTarget1
= GL_TEXTURE_2D
;
410 const GLsizei kSamples1
= 0;
411 const GLsizei kWidth2
= 16;
412 const GLsizei kHeight2
= 32;
413 const GLint kLevel2
= 0;
414 const GLenum kFormat2
= GL_RGB
;
415 const GLenum kTarget2
= GL_TEXTURE_2D
;
416 const GLsizei kSamples2
= 0;
417 const GLsizei kWidth3
= 75;
418 const GLsizei kHeight3
= 123;
419 const GLint kLevel3
= 0;
420 const GLenum kFormat3
= GL_RGB565
;
421 const GLsizei kSamples3
= 0;
422 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
423 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
424 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
426 framebuffer_
->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
427 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
428 framebuffer_
->IsPossiblyComplete());
430 texture_manager_
->CreateTexture(kTextureClient1Id
, kTextureService1Id
);
431 scoped_refptr
<TextureRef
> texture1(
432 texture_manager_
->GetTexture(kTextureClient1Id
));
433 ASSERT_TRUE(texture1
.get() != NULL
);
435 // check adding one attachment
436 framebuffer_
->AttachTexture(
437 GL_COLOR_ATTACHMENT0
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
438 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
439 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
440 framebuffer_
->IsPossiblyComplete());
441 EXPECT_TRUE(framebuffer_
->IsCleared());
442 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
444 // Try format that doesn't work with COLOR_ATTACHMENT0
445 texture_manager_
->SetTarget(texture1
.get(), GL_TEXTURE_2D
);
446 texture_manager_
->SetLevelInfo(texture1
.get(),
457 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
458 framebuffer_
->IsPossiblyComplete());
460 // Try a good format.
461 texture_manager_
->SetLevelInfo(texture1
.get(),
472 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
473 framebuffer_
->IsPossiblyComplete());
474 EXPECT_FALSE(framebuffer_
->IsCleared());
475 texture_manager_
->SetLevelInfo(texture1
.get(),
486 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
487 framebuffer_
->IsPossiblyComplete());
488 EXPECT_TRUE(framebuffer_
->IsCleared());
489 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
490 framebuffer_
->GetColorAttachmentFormat());
492 const Framebuffer::Attachment
* attachment
=
493 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
494 ASSERT_TRUE(attachment
!= NULL
);
495 EXPECT_EQ(kWidth1
, attachment
->width());
496 EXPECT_EQ(kHeight1
, attachment
->height());
497 EXPECT_EQ(kSamples1
, attachment
->samples());
498 EXPECT_EQ(kFormat1
, attachment
->internal_format());
499 EXPECT_TRUE(attachment
->cleared());
501 // Check replacing an attachment
502 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
503 scoped_refptr
<TextureRef
> texture2(
504 texture_manager_
->GetTexture(kTextureClient2Id
));
505 ASSERT_TRUE(texture2
.get() != NULL
);
506 texture_manager_
->SetTarget(texture2
.get(), GL_TEXTURE_2D
);
507 texture_manager_
->SetLevelInfo(texture2
.get(),
519 framebuffer_
->AttachTexture(
520 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget2
, kLevel2
, kSamples2
);
521 EXPECT_EQ(static_cast<GLenum
>(kFormat2
),
522 framebuffer_
->GetColorAttachmentFormat());
523 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
524 framebuffer_
->IsPossiblyComplete());
525 EXPECT_TRUE(framebuffer_
->IsCleared());
527 attachment
= framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
528 ASSERT_TRUE(attachment
!= NULL
);
529 EXPECT_EQ(kWidth2
, attachment
->width());
530 EXPECT_EQ(kHeight2
, attachment
->height());
531 EXPECT_EQ(kSamples2
, attachment
->samples());
532 EXPECT_EQ(kFormat2
, attachment
->internal_format());
533 EXPECT_TRUE(attachment
->cleared());
535 // Check changing attachment
536 texture_manager_
->SetLevelInfo(texture2
.get(),
547 attachment
= framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
548 ASSERT_TRUE(attachment
!= NULL
);
549 EXPECT_EQ(kWidth3
, attachment
->width());
550 EXPECT_EQ(kHeight3
, attachment
->height());
551 EXPECT_EQ(kSamples3
, attachment
->samples());
552 EXPECT_EQ(kFormat3
, attachment
->internal_format());
553 EXPECT_FALSE(attachment
->cleared());
554 EXPECT_EQ(static_cast<GLenum
>(kFormat3
),
555 framebuffer_
->GetColorAttachmentFormat());
556 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
557 framebuffer_
->IsPossiblyComplete());
558 EXPECT_FALSE(framebuffer_
->IsCleared());
561 texture_manager_
->SetLevelInfo(texture2
.get(),
572 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
573 framebuffer_
->IsPossiblyComplete());
575 // Check removing it.
576 framebuffer_
->AttachTexture(GL_COLOR_ATTACHMENT0
, NULL
, 0, 0, 0);
577 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
578 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
580 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
581 framebuffer_
->IsPossiblyComplete());
582 EXPECT_TRUE(framebuffer_
->IsCleared());
585 TEST_F(FramebufferInfoTest
, DrawBuffers
) {
586 const GLuint kTextureClientId
[] = { 33, 34 };
587 const GLuint kTextureServiceId
[] = { 333, 334 };
589 for (GLenum i
= GL_COLOR_ATTACHMENT0
;
590 i
< GL_COLOR_ATTACHMENT0
+ kMaxColorAttachments
; ++i
) {
591 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(i
));
593 EXPECT_FALSE(framebuffer_
->HasUnclearedColorAttachments());
595 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
),
596 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER0_ARB
));
597 for (GLenum i
= GL_DRAW_BUFFER1_ARB
;
598 i
< GL_DRAW_BUFFER0_ARB
+ kMaxDrawBuffers
; ++i
) {
599 EXPECT_EQ(static_cast<GLenum
>(GL_NONE
),
600 framebuffer_
->GetDrawBuffer(i
));
603 for (size_t ii
= 0; ii
< arraysize(kTextureClientId
); ++ii
) {
604 texture_manager_
->CreateTexture(
605 kTextureClientId
[ii
], kTextureServiceId
[ii
]);
606 scoped_refptr
<TextureRef
> texture(
607 texture_manager_
->GetTexture(kTextureClientId
[ii
]));
608 ASSERT_TRUE(texture
.get() != NULL
);
610 framebuffer_
->AttachTexture(
611 GL_COLOR_ATTACHMENT0
+ ii
, texture
.get(), GL_TEXTURE_2D
, 0, 0);
613 framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
+ ii
));
615 const Framebuffer::Attachment
* attachment
=
616 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
+ ii
);
617 ASSERT_TRUE(attachment
!= NULL
);
618 EXPECT_TRUE(attachment
->cleared());
620 EXPECT_TRUE(framebuffer_
->IsCleared());
621 EXPECT_FALSE(framebuffer_
->HasUnclearedColorAttachments());
623 // Set a texture as uncleared.
624 scoped_refptr
<TextureRef
> texture1(
625 texture_manager_
->GetTexture(kTextureClientId
[1]));
626 texture_manager_
->SetTarget(texture1
.get(), GL_TEXTURE_2D
);
627 texture_manager_
->SetLevelInfo(
628 texture1
.get(), GL_TEXTURE_2D
, 0, GL_RGBA
, 4, 4,
629 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, false);
631 const Framebuffer::Attachment
* attachment1
=
632 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT1
);
633 ASSERT_TRUE(attachment1
!= NULL
);
634 EXPECT_FALSE(attachment1
->cleared());
635 EXPECT_FALSE(framebuffer_
->IsCleared());
636 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT1
));
637 EXPECT_TRUE(framebuffer_
->HasUnclearedColorAttachments());
639 GLenum buffers
[] = { GL_COLOR_ATTACHMENT0
, GL_COLOR_ATTACHMENT1
};
640 framebuffer_
->SetDrawBuffers(2, buffers
);
641 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
),
642 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER0_ARB
));
643 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT1
),
644 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER1_ARB
));
645 for (GLenum i
= GL_DRAW_BUFFER2_ARB
;
646 i
< GL_DRAW_BUFFER0_ARB
+ kMaxDrawBuffers
; ++i
) {
647 EXPECT_EQ(static_cast<GLenum
>(GL_NONE
),
648 framebuffer_
->GetDrawBuffer(i
));
652 framebuffer_
->PrepareDrawBuffersForClear();
653 framebuffer_
->RestoreDrawBuffersAfterClear();
655 // Now we disable a draw buffer 1.
656 buffers
[1] = GL_NONE
;
657 framebuffer_
->SetDrawBuffers(2, buffers
);
658 // We will enable the disabled draw buffer for clear(), and disable it
660 EXPECT_CALL(*gl_
, DrawBuffersARB(kMaxDrawBuffers
, _
))
662 .RetiresOnSaturation();
663 framebuffer_
->PrepareDrawBuffersForClear();
664 EXPECT_CALL(*gl_
, DrawBuffersARB(kMaxDrawBuffers
, _
))
666 .RetiresOnSaturation();
667 framebuffer_
->RestoreDrawBuffersAfterClear();
669 // Now remove draw buffer 1's attachment.
670 framebuffer_
->AttachTexture(GL_COLOR_ATTACHMENT1
, NULL
, 0, 0, 0);
671 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT1
) == NULL
);
674 framebuffer_
->PrepareDrawBuffersForClear();
675 framebuffer_
->RestoreDrawBuffersAfterClear();
678 class FramebufferInfoFloatTest
: public FramebufferInfoTest
{
680 FramebufferInfoFloatTest()
681 : FramebufferInfoTest() {
683 ~FramebufferInfoFloatTest() override
{}
686 void SetUp() override
{
687 InitializeContext("OpenGL ES 3.0",
688 "GL_OES_texture_float GL_EXT_color_buffer_float");
692 TEST_F(FramebufferInfoFloatTest
, AttachFloatTexture
) {
693 const GLuint kTextureClientId
= 33;
694 const GLuint kTextureServiceId
= 333;
695 const GLint kDepth
= 1;
696 const GLint kBorder
= 0;
697 const GLenum kType
= GL_FLOAT
;
698 const GLsizei kWidth
= 16;
699 const GLsizei kHeight
= 32;
700 const GLint kLevel
= 0;
701 const GLenum kFormat
= GL_RGBA
;
702 const GLenum kInternalFormat
= GL_RGBA32F
;
703 const GLenum kTarget
= GL_TEXTURE_2D
;
704 const GLsizei kSamples
= 0;
705 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
706 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
707 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
709 texture_manager_
->CreateTexture(kTextureClientId
, kTextureServiceId
);
710 scoped_refptr
<TextureRef
> texture(
711 texture_manager_
->GetTexture(kTextureClientId
));
712 ASSERT_TRUE(texture
.get() != NULL
);
714 framebuffer_
->AttachTexture(
715 GL_COLOR_ATTACHMENT0
, texture
.get(), kTarget
, kLevel
, kSamples
);
716 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
718 texture_manager_
->SetTarget(texture
.get(), GL_TEXTURE_2D
);
719 texture_manager_
->SetLevelInfo(texture
.get(),
730 // Texture with a sized float internalformat is allowed as an attachment
731 // since float color attachment extension is present.
732 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
733 framebuffer_
->IsPossiblyComplete());
736 TEST_F(FramebufferInfoTest
, UnbindRenderbuffer
) {
737 const GLuint kRenderbufferClient1Id
= 33;
738 const GLuint kRenderbufferService1Id
= 333;
739 const GLuint kRenderbufferClient2Id
= 34;
740 const GLuint kRenderbufferService2Id
= 334;
742 renderbuffer_manager_
->CreateRenderbuffer(
743 kRenderbufferClient1Id
, kRenderbufferService1Id
);
744 Renderbuffer
* renderbuffer1
=
745 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient1Id
);
746 ASSERT_TRUE(renderbuffer1
!= NULL
);
747 renderbuffer_manager_
->CreateRenderbuffer(
748 kRenderbufferClient2Id
, kRenderbufferService2Id
);
749 Renderbuffer
* renderbuffer2
=
750 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient2Id
);
751 ASSERT_TRUE(renderbuffer2
!= NULL
);
753 // Attach to 2 attachment points.
754 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, renderbuffer1
);
755 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
756 // Check they were attached.
757 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
758 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
759 // Unbind unattached renderbuffer.
760 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer2
);
762 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
763 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
764 // Unbind renderbuffer.
765 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
766 // Check they were detached
767 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
768 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) == NULL
);
771 TEST_F(FramebufferInfoTest
, UnbindTexture
) {
772 const GLuint kTextureClient1Id
= 33;
773 const GLuint kTextureService1Id
= 333;
774 const GLuint kTextureClient2Id
= 34;
775 const GLuint kTextureService2Id
= 334;
776 const GLenum kTarget1
= GL_TEXTURE_2D
;
777 const GLint kLevel1
= 0;
778 const GLint kSamples1
= 0;
780 texture_manager_
->CreateTexture(kTextureClient1Id
, kTextureService1Id
);
781 scoped_refptr
<TextureRef
> texture1(
782 texture_manager_
->GetTexture(kTextureClient1Id
));
783 ASSERT_TRUE(texture1
.get() != NULL
);
784 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
785 scoped_refptr
<TextureRef
> texture2(
786 texture_manager_
->GetTexture(kTextureClient2Id
));
787 ASSERT_TRUE(texture2
.get() != NULL
);
789 // Attach to 2 attachment points.
790 framebuffer_
->AttachTexture(
791 GL_COLOR_ATTACHMENT0
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
792 framebuffer_
->AttachTexture(
793 GL_DEPTH_ATTACHMENT
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
794 // Check they were attached.
795 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
796 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
797 // Unbind unattached texture.
798 framebuffer_
->UnbindTexture(kTarget1
, texture2
.get());
800 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
801 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
803 framebuffer_
->UnbindTexture(kTarget1
, texture1
.get());
804 // Check they were detached
805 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
806 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) == NULL
);
809 TEST_F(FramebufferInfoTest
, IsCompleteMarkAsComplete
) {
810 const GLuint kRenderbufferClient1Id
= 33;
811 const GLuint kRenderbufferService1Id
= 333;
812 const GLuint kTextureClient2Id
= 34;
813 const GLuint kTextureService2Id
= 334;
814 const GLenum kTarget1
= GL_TEXTURE_2D
;
815 const GLint kLevel1
= 0;
816 const GLint kSamples1
= 0;
818 renderbuffer_manager_
->CreateRenderbuffer(
819 kRenderbufferClient1Id
, kRenderbufferService1Id
);
820 Renderbuffer
* renderbuffer1
=
821 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient1Id
);
822 ASSERT_TRUE(renderbuffer1
!= NULL
);
823 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
824 scoped_refptr
<TextureRef
> texture2(
825 texture_manager_
->GetTexture(kTextureClient2Id
));
826 ASSERT_TRUE(texture2
.get() != NULL
);
828 // Check MarkAsComlete marks as complete.
829 manager_
.MarkAsComplete(framebuffer_
);
830 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
832 // Check at attaching marks as not complete.
833 framebuffer_
->AttachTexture(
834 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget1
, kLevel1
, kSamples1
);
835 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
836 manager_
.MarkAsComplete(framebuffer_
);
837 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
838 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
839 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
841 // Check MarkAttachmentsAsCleared marks as complete.
842 manager_
.MarkAttachmentsAsCleared(
843 framebuffer_
, renderbuffer_manager_
.get(), texture_manager_
.get());
844 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
846 // Check Unbind marks as not complete.
847 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
848 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
849 manager_
.MarkAsComplete(framebuffer_
);
850 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
851 framebuffer_
->UnbindTexture(kTarget1
, texture2
.get());
852 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
855 TEST_F(FramebufferInfoTest
, GetStatus
) {
856 const GLuint kRenderbufferClient1Id
= 33;
857 const GLuint kRenderbufferService1Id
= 333;
858 const GLuint kTextureClient2Id
= 34;
859 const GLuint kTextureService2Id
= 334;
860 const GLenum kTarget1
= GL_TEXTURE_2D
;
861 const GLint kLevel1
= 0;
862 const GLint kSamples1
= 0;
864 renderbuffer_manager_
->CreateRenderbuffer(
865 kRenderbufferClient1Id
, kRenderbufferService1Id
);
866 Renderbuffer
* renderbuffer1
=
867 renderbuffer_manager_
->GetRenderbuffer(kRenderbufferClient1Id
);
868 ASSERT_TRUE(renderbuffer1
!= NULL
);
869 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
870 scoped_refptr
<TextureRef
> texture2(
871 texture_manager_
->GetTexture(kTextureClient2Id
));
872 ASSERT_TRUE(texture2
.get() != NULL
);
873 texture_manager_
->SetTarget(texture2
.get(), GL_TEXTURE_2D
);
875 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
876 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
877 .RetiresOnSaturation();
878 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
880 // Check a second call for the same type does not call anything
881 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
882 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
883 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
884 .RetiresOnSaturation();
886 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
888 // Check changing the attachments calls CheckFramebufferStatus.
889 framebuffer_
->AttachTexture(
890 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget1
, kLevel1
, kSamples1
);
891 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
892 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
)).RetiresOnSaturation();
893 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
895 // Check a second call for the same type does not call anything.
896 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
897 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
898 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
899 .RetiresOnSaturation();
901 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
903 // Check a second call with a different target calls CheckFramebufferStatus.
904 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
905 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
906 .RetiresOnSaturation();
907 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
909 // Check a second call for the same type does not call anything.
910 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
911 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
912 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
913 .RetiresOnSaturation();
915 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
917 // Check adding another attachment calls CheckFramebufferStatus.
918 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
919 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
920 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
921 .RetiresOnSaturation();
922 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
924 // Check a second call for the same type does not call anything.
925 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
926 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
927 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
928 .RetiresOnSaturation();
930 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
932 // Check changing the format calls CheckFramebuffferStatus.
933 TestHelper::SetTexParameteriWithExpectations(gl_
.get(),
935 texture_manager_
.get(),
941 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
942 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
))
943 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
944 .RetiresOnSaturation();
945 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
947 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls
948 // CheckFramebufferStatus
949 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
951 // Check putting it back does not call CheckFramebufferStatus.
952 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
953 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
954 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
955 .RetiresOnSaturation();
957 TestHelper::SetTexParameteriWithExpectations(gl_
.get(),
959 texture_manager_
.get(),
964 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
966 // Check Unbinding does not call CheckFramebufferStatus
967 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
968 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
969 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
970 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
971 .RetiresOnSaturation();
973 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);