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 kDepth24Supported
= false;
30 const bool kUseDefaultTextures
= false;
34 class FramebufferManagerTest
: public GpuServiceTest
{
36 FramebufferManagerTest()
38 texture_manager_(NULL
,
42 kMaxRectangleTextureSize
,
44 renderbuffer_manager_(NULL
,
48 ~FramebufferManagerTest() override
{
49 manager_
.Destroy(false);
50 texture_manager_
.Destroy(false);
51 renderbuffer_manager_
.Destroy(false);
56 FramebufferManager manager_
;
57 TextureManager texture_manager_
;
58 RenderbufferManager renderbuffer_manager_
;
61 TEST_F(FramebufferManagerTest
, Basic
) {
62 const GLuint kClient1Id
= 1;
63 const GLuint kService1Id
= 11;
64 const GLuint kClient2Id
= 2;
65 // Check we can create framebuffer.
66 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
67 // Check framebuffer got created.
68 Framebuffer
* framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
69 ASSERT_TRUE(framebuffer1
!= NULL
);
70 EXPECT_FALSE(framebuffer1
->IsDeleted());
71 EXPECT_EQ(kService1Id
, framebuffer1
->service_id());
73 EXPECT_TRUE(manager_
.GetClientId(framebuffer1
->service_id(), &client_id
));
74 EXPECT_EQ(kClient1Id
, client_id
);
75 // Check we get nothing for a non-existent framebuffer.
76 EXPECT_TRUE(manager_
.GetFramebuffer(kClient2Id
) == NULL
);
77 // Check trying to a remove non-existent framebuffers does not crash.
78 manager_
.RemoveFramebuffer(kClient2Id
);
79 // Check framebuffer gets deleted when last reference is released.
80 EXPECT_CALL(*gl_
, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id
)))
82 .RetiresOnSaturation();
83 // Check we can't get the framebuffer after we remove it.
84 manager_
.RemoveFramebuffer(kClient1Id
);
85 EXPECT_TRUE(manager_
.GetFramebuffer(kClient1Id
) == NULL
);
88 TEST_F(FramebufferManagerTest
, Destroy
) {
89 const GLuint kClient1Id
= 1;
90 const GLuint kService1Id
= 11;
91 // Check we can create framebuffer.
92 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
93 // Check framebuffer got created.
94 Framebuffer
* framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
95 ASSERT_TRUE(framebuffer1
!= NULL
);
96 EXPECT_CALL(*gl_
, DeleteFramebuffersEXT(1, ::testing::Pointee(kService1Id
)))
98 .RetiresOnSaturation();
99 manager_
.Destroy(true);
100 // Check the resources were released.
101 framebuffer1
= manager_
.GetFramebuffer(kClient1Id
);
102 ASSERT_TRUE(framebuffer1
== NULL
);
105 class FramebufferInfoTest
: public GpuServiceTest
{
107 static const GLuint kClient1Id
= 1;
108 static const GLuint kService1Id
= 11;
110 FramebufferInfoTest()
111 : manager_(kMaxDrawBuffers
, kMaxColorAttachments
),
112 feature_info_(new FeatureInfo()),
113 renderbuffer_manager_(NULL
, kMaxRenderbufferSize
, kMaxSamples
,
115 texture_manager_
.reset(new TextureManager(NULL
,
119 kMaxRectangleTextureSize
,
120 kUseDefaultTextures
));
122 ~FramebufferInfoTest() override
{
123 manager_
.Destroy(false);
124 texture_manager_
->Destroy(false);
125 renderbuffer_manager_
.Destroy(false);
129 void SetUp() override
{
130 InitializeContext("2.0", "GL_EXT_framebuffer_object");
133 void InitializeContext(const char* gl_version
, const char* extensions
) {
134 GpuServiceTest::SetUpWithGLVersion(gl_version
, extensions
);
135 TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion(gl_
.get(),
136 extensions
, "", gl_version
);
137 feature_info_
->Initialize();
138 manager_
.CreateFramebuffer(kClient1Id
, kService1Id
);
139 error_state_
.reset(new ::testing::StrictMock
<gles2::MockErrorState
>());
140 framebuffer_
= manager_
.GetFramebuffer(kClient1Id
);
141 ASSERT_TRUE(framebuffer_
!= NULL
);
144 FramebufferManager manager_
;
145 Framebuffer
* framebuffer_
;
146 scoped_refptr
<FeatureInfo
> feature_info_
;
147 scoped_ptr
<TextureManager
> texture_manager_
;
148 RenderbufferManager renderbuffer_manager_
;
149 scoped_ptr
<MockErrorState
> error_state_
;
152 // GCC requires these declarations, but MSVC requires they not be present
153 #ifndef COMPILER_MSVC
154 const GLuint
FramebufferInfoTest::kClient1Id
;
155 const GLuint
FramebufferInfoTest::kService1Id
;
158 TEST_F(FramebufferInfoTest
, Basic
) {
159 EXPECT_EQ(kService1Id
, framebuffer_
->service_id());
160 EXPECT_FALSE(framebuffer_
->IsDeleted());
161 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
));
162 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
));
163 EXPECT_TRUE(NULL
== framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
));
165 NULL
== framebuffer_
->GetAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
166 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
167 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
168 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
169 framebuffer_
->IsPossiblyComplete());
170 EXPECT_TRUE(framebuffer_
->IsCleared());
171 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
172 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
175 TEST_F(FramebufferInfoTest
, AttachRenderbuffer
) {
176 const GLuint kRenderbufferClient1Id
= 33;
177 const GLuint kRenderbufferService1Id
= 333;
178 const GLuint kRenderbufferClient2Id
= 34;
179 const GLuint kRenderbufferService2Id
= 334;
180 const GLuint kRenderbufferClient3Id
= 35;
181 const GLuint kRenderbufferService3Id
= 335;
182 const GLuint kRenderbufferClient4Id
= 36;
183 const GLuint kRenderbufferService4Id
= 336;
184 const GLsizei kWidth1
= 16;
185 const GLsizei kHeight1
= 32;
186 const GLenum kFormat1
= GL_RGBA4
;
187 const GLenum kBadFormat1
= GL_DEPTH_COMPONENT16
;
188 const GLsizei kSamples1
= 0;
189 const GLsizei kWidth2
= 16;
190 const GLsizei kHeight2
= 32;
191 const GLenum kFormat2
= GL_DEPTH_COMPONENT16
;
192 const GLsizei kSamples2
= 0;
193 const GLsizei kWidth3
= 16;
194 const GLsizei kHeight3
= 32;
195 const GLenum kFormat3
= GL_STENCIL_INDEX8
;
196 const GLsizei kSamples3
= 0;
197 const GLsizei kWidth4
= 16;
198 const GLsizei kHeight4
= 32;
199 const GLenum kFormat4
= GL_STENCIL_INDEX8
;
200 const GLsizei kSamples4
= 0;
202 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
203 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
204 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
206 framebuffer_
->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
208 renderbuffer_manager_
.CreateRenderbuffer(
209 kRenderbufferClient1Id
, kRenderbufferService1Id
);
210 Renderbuffer
* renderbuffer1
=
211 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient1Id
);
212 ASSERT_TRUE(renderbuffer1
!= NULL
);
214 // check adding one attachment
215 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, renderbuffer1
);
216 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
217 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
218 EXPECT_EQ(static_cast<GLenum
>(GL_RGBA4
),
219 framebuffer_
->GetColorAttachmentFormat());
220 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
221 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
222 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
223 framebuffer_
->IsPossiblyComplete());
224 EXPECT_TRUE(framebuffer_
->IsCleared());
226 // Try a format that's not good for COLOR_ATTACHMENT0.
227 renderbuffer_manager_
.SetInfo(
228 renderbuffer1
, kSamples1
, kBadFormat1
, kWidth1
, kHeight1
);
229 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
230 framebuffer_
->IsPossiblyComplete());
232 // Try a good format.
233 renderbuffer_manager_
.SetInfo(
234 renderbuffer1
, kSamples1
, kFormat1
, kWidth1
, kHeight1
);
235 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
236 framebuffer_
->GetColorAttachmentFormat());
237 EXPECT_FALSE(framebuffer_
->HasDepthAttachment());
238 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
239 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
240 framebuffer_
->IsPossiblyComplete());
241 EXPECT_FALSE(framebuffer_
->IsCleared());
243 // check adding another
244 renderbuffer_manager_
.CreateRenderbuffer(
245 kRenderbufferClient2Id
, kRenderbufferService2Id
);
246 Renderbuffer
* renderbuffer2
=
247 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient2Id
);
248 ASSERT_TRUE(renderbuffer2
!= NULL
);
249 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer2
);
250 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
251 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
252 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
253 framebuffer_
->GetColorAttachmentFormat());
254 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
255 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
256 // The attachment has a size of 0,0 so depending on the order of the map
257 // of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0
258 // or INCOMPLETE_DIMENSIONS because it's not the same size as the other
260 GLenum status
= framebuffer_
->IsPossiblyComplete();
262 status
== GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
||
263 status
== GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
);
264 EXPECT_FALSE(framebuffer_
->IsCleared());
266 renderbuffer_manager_
.SetInfo(
267 renderbuffer2
, kSamples2
, kFormat2
, kWidth2
, kHeight2
);
268 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
269 framebuffer_
->IsPossiblyComplete());
270 EXPECT_FALSE(framebuffer_
->IsCleared());
271 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
273 // check marking them as cleared.
274 manager_
.MarkAttachmentsAsCleared(
275 framebuffer_
, &renderbuffer_manager_
, texture_manager_
.get());
276 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
277 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
278 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
279 framebuffer_
->IsPossiblyComplete());
280 EXPECT_TRUE(framebuffer_
->IsCleared());
282 // Check adding one that is already cleared.
283 renderbuffer_manager_
.CreateRenderbuffer(
284 kRenderbufferClient3Id
, kRenderbufferService3Id
);
285 Renderbuffer
* renderbuffer3
=
286 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient3Id
);
287 ASSERT_TRUE(renderbuffer3
!= NULL
);
288 renderbuffer_manager_
.SetInfo(
289 renderbuffer3
, kSamples3
, kFormat3
, kWidth3
, kHeight3
);
290 renderbuffer_manager_
.SetCleared(renderbuffer3
, true);
292 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, renderbuffer3
);
293 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
294 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
295 framebuffer_
->GetColorAttachmentFormat());
296 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
297 EXPECT_TRUE(framebuffer_
->HasStencilAttachment());
298 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
299 framebuffer_
->IsPossiblyComplete());
300 EXPECT_TRUE(framebuffer_
->IsCleared());
302 // Check marking the renderbuffer as unclared.
303 renderbuffer_manager_
.SetInfo(
304 renderbuffer1
, kSamples1
, kFormat1
, kWidth1
, kHeight1
);
305 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
306 framebuffer_
->GetColorAttachmentFormat());
307 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
308 EXPECT_TRUE(framebuffer_
->HasStencilAttachment());
309 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
310 framebuffer_
->IsPossiblyComplete());
311 EXPECT_FALSE(framebuffer_
->IsCleared());
313 const Framebuffer::Attachment
* attachment
=
314 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
315 ASSERT_TRUE(attachment
!= NULL
);
316 EXPECT_EQ(kWidth1
, attachment
->width());
317 EXPECT_EQ(kHeight1
, attachment
->height());
318 EXPECT_EQ(kSamples1
, attachment
->samples());
319 EXPECT_EQ(kFormat1
, attachment
->internal_format());
320 EXPECT_FALSE(attachment
->cleared());
322 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
325 manager_
.MarkAttachmentsAsCleared(
326 framebuffer_
, &renderbuffer_manager_
, texture_manager_
.get());
327 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
328 EXPECT_TRUE(framebuffer_
->IsCleared());
330 // Check replacing an attachment
331 renderbuffer_manager_
.CreateRenderbuffer(
332 kRenderbufferClient4Id
, kRenderbufferService4Id
);
333 Renderbuffer
* renderbuffer4
=
334 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient4Id
);
335 ASSERT_TRUE(renderbuffer4
!= NULL
);
336 renderbuffer_manager_
.SetInfo(
337 renderbuffer4
, kSamples4
, kFormat4
, kWidth4
, kHeight4
);
339 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, renderbuffer4
);
340 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
341 EXPECT_FALSE(framebuffer_
->IsCleared());
343 attachment
= framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
);
344 ASSERT_TRUE(attachment
!= NULL
);
345 EXPECT_EQ(kWidth4
, attachment
->width());
346 EXPECT_EQ(kHeight4
, attachment
->height());
347 EXPECT_EQ(kSamples4
, attachment
->samples());
348 EXPECT_EQ(kFormat4
, attachment
->internal_format());
349 EXPECT_FALSE(attachment
->cleared());
350 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
351 framebuffer_
->IsPossiblyComplete());
353 // Check changing an attachment.
354 renderbuffer_manager_
.SetInfo(
355 renderbuffer4
, kSamples4
, kFormat4
, kWidth4
+ 1, kHeight4
);
357 attachment
= framebuffer_
->GetAttachment(GL_STENCIL_ATTACHMENT
);
358 ASSERT_TRUE(attachment
!= NULL
);
359 EXPECT_EQ(kWidth4
+ 1, attachment
->width());
360 EXPECT_EQ(kHeight4
, attachment
->height());
361 EXPECT_EQ(kSamples4
, attachment
->samples());
362 EXPECT_EQ(kFormat4
, attachment
->internal_format());
363 EXPECT_FALSE(attachment
->cleared());
364 EXPECT_FALSE(framebuffer_
->IsCleared());
365 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
),
366 framebuffer_
->IsPossiblyComplete());
368 // Check removing it.
369 framebuffer_
->AttachRenderbuffer(GL_STENCIL_ATTACHMENT
, NULL
);
370 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
371 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
372 framebuffer_
->GetColorAttachmentFormat());
373 EXPECT_TRUE(framebuffer_
->HasDepthAttachment());
374 EXPECT_FALSE(framebuffer_
->HasStencilAttachment());
376 EXPECT_TRUE(framebuffer_
->IsCleared());
377 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
378 framebuffer_
->IsPossiblyComplete());
380 // Remove depth, Set color to 0 size.
381 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, NULL
);
382 renderbuffer_manager_
.SetInfo(renderbuffer1
, kSamples1
, kFormat1
, 0, 0);
383 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
384 framebuffer_
->IsPossiblyComplete());
387 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, NULL
);
388 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
389 framebuffer_
->IsPossiblyComplete());
392 TEST_F(FramebufferInfoTest
, AttachTexture
) {
393 const GLuint kTextureClient1Id
= 33;
394 const GLuint kTextureService1Id
= 333;
395 const GLuint kTextureClient2Id
= 34;
396 const GLuint kTextureService2Id
= 334;
397 const GLint kDepth
= 1;
398 const GLint kBorder
= 0;
399 const GLenum kType
= GL_UNSIGNED_BYTE
;
400 const GLsizei kWidth1
= 16;
401 const GLsizei kHeight1
= 32;
402 const GLint kLevel1
= 0;
403 const GLenum kFormat1
= GL_RGBA
;
404 const GLenum kBadFormat1
= GL_DEPTH_COMPONENT16
;
405 const GLenum kTarget1
= GL_TEXTURE_2D
;
406 const GLsizei kSamples1
= 0;
407 const GLsizei kWidth2
= 16;
408 const GLsizei kHeight2
= 32;
409 const GLint kLevel2
= 0;
410 const GLenum kFormat2
= GL_RGB
;
411 const GLenum kTarget2
= GL_TEXTURE_2D
;
412 const GLsizei kSamples2
= 0;
413 const GLsizei kWidth3
= 75;
414 const GLsizei kHeight3
= 123;
415 const GLint kLevel3
= 0;
416 const GLenum kFormat3
= GL_RGB565
;
417 const GLsizei kSamples3
= 0;
418 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
419 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
420 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
422 framebuffer_
->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT
));
423 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
424 framebuffer_
->IsPossiblyComplete());
426 texture_manager_
->CreateTexture(kTextureClient1Id
, kTextureService1Id
);
427 scoped_refptr
<TextureRef
> texture1(
428 texture_manager_
->GetTexture(kTextureClient1Id
));
429 ASSERT_TRUE(texture1
.get() != NULL
);
431 // check adding one attachment
432 framebuffer_
->AttachTexture(
433 GL_COLOR_ATTACHMENT0
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
434 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
435 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
436 framebuffer_
->IsPossiblyComplete());
437 EXPECT_TRUE(framebuffer_
->IsCleared());
438 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
440 // Try format that doesn't work with COLOR_ATTACHMENT0
441 texture_manager_
->SetTarget(texture1
.get(), GL_TEXTURE_2D
);
442 texture_manager_
->SetLevelInfo(texture1
.get(),
453 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
454 framebuffer_
->IsPossiblyComplete());
456 // Try a good format.
457 texture_manager_
->SetLevelInfo(texture1
.get(),
468 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
469 framebuffer_
->IsPossiblyComplete());
470 EXPECT_FALSE(framebuffer_
->IsCleared());
471 texture_manager_
->SetLevelInfo(texture1
.get(),
482 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
483 framebuffer_
->IsPossiblyComplete());
484 EXPECT_TRUE(framebuffer_
->IsCleared());
485 EXPECT_EQ(static_cast<GLenum
>(kFormat1
),
486 framebuffer_
->GetColorAttachmentFormat());
488 const Framebuffer::Attachment
* attachment
=
489 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
490 ASSERT_TRUE(attachment
!= NULL
);
491 EXPECT_EQ(kWidth1
, attachment
->width());
492 EXPECT_EQ(kHeight1
, attachment
->height());
493 EXPECT_EQ(kSamples1
, attachment
->samples());
494 EXPECT_EQ(kFormat1
, attachment
->internal_format());
495 EXPECT_TRUE(attachment
->cleared());
497 // Check replacing an attachment
498 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
499 scoped_refptr
<TextureRef
> texture2(
500 texture_manager_
->GetTexture(kTextureClient2Id
));
501 ASSERT_TRUE(texture2
.get() != NULL
);
502 texture_manager_
->SetTarget(texture2
.get(), GL_TEXTURE_2D
);
503 texture_manager_
->SetLevelInfo(texture2
.get(),
515 framebuffer_
->AttachTexture(
516 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget2
, kLevel2
, kSamples2
);
517 EXPECT_EQ(static_cast<GLenum
>(kFormat2
),
518 framebuffer_
->GetColorAttachmentFormat());
519 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
520 framebuffer_
->IsPossiblyComplete());
521 EXPECT_TRUE(framebuffer_
->IsCleared());
523 attachment
= framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
524 ASSERT_TRUE(attachment
!= NULL
);
525 EXPECT_EQ(kWidth2
, attachment
->width());
526 EXPECT_EQ(kHeight2
, attachment
->height());
527 EXPECT_EQ(kSamples2
, attachment
->samples());
528 EXPECT_EQ(kFormat2
, attachment
->internal_format());
529 EXPECT_TRUE(attachment
->cleared());
531 // Check changing attachment
532 texture_manager_
->SetLevelInfo(texture2
.get(),
543 attachment
= framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
);
544 ASSERT_TRUE(attachment
!= NULL
);
545 EXPECT_EQ(kWidth3
, attachment
->width());
546 EXPECT_EQ(kHeight3
, attachment
->height());
547 EXPECT_EQ(kSamples3
, attachment
->samples());
548 EXPECT_EQ(kFormat3
, attachment
->internal_format());
549 EXPECT_FALSE(attachment
->cleared());
550 EXPECT_EQ(static_cast<GLenum
>(kFormat3
),
551 framebuffer_
->GetColorAttachmentFormat());
552 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
553 framebuffer_
->IsPossiblyComplete());
554 EXPECT_FALSE(framebuffer_
->IsCleared());
557 texture_manager_
->SetLevelInfo(texture2
.get(),
568 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
),
569 framebuffer_
->IsPossiblyComplete());
571 // Check removing it.
572 framebuffer_
->AttachTexture(GL_COLOR_ATTACHMENT0
, NULL
, 0, 0, 0);
573 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
574 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
576 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT
),
577 framebuffer_
->IsPossiblyComplete());
578 EXPECT_TRUE(framebuffer_
->IsCleared());
581 TEST_F(FramebufferInfoTest
, DrawBuffers
) {
582 const GLuint kTextureClientId
[] = { 33, 34 };
583 const GLuint kTextureServiceId
[] = { 333, 334 };
585 for (GLenum i
= GL_COLOR_ATTACHMENT0
;
586 i
< GL_COLOR_ATTACHMENT0
+ kMaxColorAttachments
; ++i
) {
587 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(i
));
589 EXPECT_FALSE(framebuffer_
->HasUnclearedColorAttachments());
591 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
),
592 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER0_ARB
));
593 for (GLenum i
= GL_DRAW_BUFFER1_ARB
;
594 i
< GL_DRAW_BUFFER0_ARB
+ kMaxDrawBuffers
; ++i
) {
595 EXPECT_EQ(static_cast<GLenum
>(GL_NONE
),
596 framebuffer_
->GetDrawBuffer(i
));
599 for (size_t ii
= 0; ii
< arraysize(kTextureClientId
); ++ii
) {
600 texture_manager_
->CreateTexture(
601 kTextureClientId
[ii
], kTextureServiceId
[ii
]);
602 scoped_refptr
<TextureRef
> texture(
603 texture_manager_
->GetTexture(kTextureClientId
[ii
]));
604 ASSERT_TRUE(texture
.get() != NULL
);
606 framebuffer_
->AttachTexture(
607 GL_COLOR_ATTACHMENT0
+ ii
, texture
.get(), GL_TEXTURE_2D
, 0, 0);
609 framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
+ ii
));
611 const Framebuffer::Attachment
* attachment
=
612 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
+ ii
);
613 ASSERT_TRUE(attachment
!= NULL
);
614 EXPECT_TRUE(attachment
->cleared());
616 EXPECT_TRUE(framebuffer_
->IsCleared());
617 EXPECT_FALSE(framebuffer_
->HasUnclearedColorAttachments());
619 // Set a texture as uncleared.
620 scoped_refptr
<TextureRef
> texture1(
621 texture_manager_
->GetTexture(kTextureClientId
[1]));
622 texture_manager_
->SetTarget(texture1
.get(), GL_TEXTURE_2D
);
623 texture_manager_
->SetLevelInfo(
624 texture1
.get(), GL_TEXTURE_2D
, 0, GL_RGBA
, 4, 4,
625 1, 0, GL_RGBA
, GL_UNSIGNED_BYTE
, false);
627 const Framebuffer::Attachment
* attachment1
=
628 framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT1
);
629 ASSERT_TRUE(attachment1
!= NULL
);
630 EXPECT_FALSE(attachment1
->cleared());
631 EXPECT_FALSE(framebuffer_
->IsCleared());
632 EXPECT_TRUE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT1
));
633 EXPECT_TRUE(framebuffer_
->HasUnclearedColorAttachments());
635 GLenum buffers
[] = { GL_COLOR_ATTACHMENT0
, GL_COLOR_ATTACHMENT1
};
636 framebuffer_
->SetDrawBuffers(2, buffers
);
637 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT0
),
638 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER0_ARB
));
639 EXPECT_EQ(static_cast<GLenum
>(GL_COLOR_ATTACHMENT1
),
640 framebuffer_
->GetDrawBuffer(GL_DRAW_BUFFER1_ARB
));
641 for (GLenum i
= GL_DRAW_BUFFER2_ARB
;
642 i
< GL_DRAW_BUFFER0_ARB
+ kMaxDrawBuffers
; ++i
) {
643 EXPECT_EQ(static_cast<GLenum
>(GL_NONE
),
644 framebuffer_
->GetDrawBuffer(i
));
648 framebuffer_
->PrepareDrawBuffersForClear();
649 framebuffer_
->RestoreDrawBuffersAfterClear();
651 // Now we disable a draw buffer 1.
652 buffers
[1] = GL_NONE
;
653 framebuffer_
->SetDrawBuffers(2, buffers
);
654 // We will enable the disabled draw buffer for clear(), and disable it
656 EXPECT_CALL(*gl_
, DrawBuffersARB(kMaxDrawBuffers
, _
))
658 .RetiresOnSaturation();
659 framebuffer_
->PrepareDrawBuffersForClear();
660 EXPECT_CALL(*gl_
, DrawBuffersARB(kMaxDrawBuffers
, _
))
662 .RetiresOnSaturation();
663 framebuffer_
->RestoreDrawBuffersAfterClear();
665 // Now remove draw buffer 1's attachment.
666 framebuffer_
->AttachTexture(GL_COLOR_ATTACHMENT1
, NULL
, 0, 0, 0);
667 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT1
) == NULL
);
670 framebuffer_
->PrepareDrawBuffersForClear();
671 framebuffer_
->RestoreDrawBuffersAfterClear();
674 class FramebufferInfoFloatTest
: public FramebufferInfoTest
{
676 FramebufferInfoFloatTest()
677 : FramebufferInfoTest() {
679 ~FramebufferInfoFloatTest() override
{}
682 void SetUp() override
{
683 InitializeContext("OpenGL ES 3.0",
684 "GL_OES_texture_float GL_EXT_color_buffer_float");
688 TEST_F(FramebufferInfoFloatTest
, AttachFloatTexture
) {
689 const GLuint kTextureClientId
= 33;
690 const GLuint kTextureServiceId
= 333;
691 const GLint kDepth
= 1;
692 const GLint kBorder
= 0;
693 const GLenum kType
= GL_FLOAT
;
694 const GLsizei kWidth
= 16;
695 const GLsizei kHeight
= 32;
696 const GLint kLevel
= 0;
697 const GLenum kFormat
= GL_RGBA
;
698 const GLenum kInternalFormat
= GL_RGBA32F
;
699 const GLenum kTarget
= GL_TEXTURE_2D
;
700 const GLsizei kSamples
= 0;
701 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0
));
702 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT
));
703 EXPECT_FALSE(framebuffer_
->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT
));
705 texture_manager_
->CreateTexture(kTextureClientId
, kTextureServiceId
);
706 scoped_refptr
<TextureRef
> texture(
707 texture_manager_
->GetTexture(kTextureClientId
));
708 ASSERT_TRUE(texture
.get() != NULL
);
710 framebuffer_
->AttachTexture(
711 GL_COLOR_ATTACHMENT0
, texture
.get(), kTarget
, kLevel
, kSamples
);
712 EXPECT_EQ(static_cast<GLenum
>(0), framebuffer_
->GetColorAttachmentFormat());
714 texture_manager_
->SetTarget(texture
.get(), GL_TEXTURE_2D
);
715 texture_manager_
->SetLevelInfo(texture
.get(),
726 // Texture with a sized float internalformat is allowed as an attachment
727 // since float color attachment extension is present.
728 EXPECT_EQ(static_cast<GLenum
>(GL_FRAMEBUFFER_COMPLETE
),
729 framebuffer_
->IsPossiblyComplete());
732 TEST_F(FramebufferInfoTest
, UnbindRenderbuffer
) {
733 const GLuint kRenderbufferClient1Id
= 33;
734 const GLuint kRenderbufferService1Id
= 333;
735 const GLuint kRenderbufferClient2Id
= 34;
736 const GLuint kRenderbufferService2Id
= 334;
738 renderbuffer_manager_
.CreateRenderbuffer(
739 kRenderbufferClient1Id
, kRenderbufferService1Id
);
740 Renderbuffer
* renderbuffer1
=
741 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient1Id
);
742 ASSERT_TRUE(renderbuffer1
!= NULL
);
743 renderbuffer_manager_
.CreateRenderbuffer(
744 kRenderbufferClient2Id
, kRenderbufferService2Id
);
745 Renderbuffer
* renderbuffer2
=
746 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient2Id
);
747 ASSERT_TRUE(renderbuffer2
!= NULL
);
749 // Attach to 2 attachment points.
750 framebuffer_
->AttachRenderbuffer(GL_COLOR_ATTACHMENT0
, renderbuffer1
);
751 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
752 // Check they were attached.
753 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
754 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
755 // Unbind unattached renderbuffer.
756 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer2
);
758 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
759 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
760 // Unbind renderbuffer.
761 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
762 // Check they were detached
763 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
764 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) == NULL
);
767 TEST_F(FramebufferInfoTest
, UnbindTexture
) {
768 const GLuint kTextureClient1Id
= 33;
769 const GLuint kTextureService1Id
= 333;
770 const GLuint kTextureClient2Id
= 34;
771 const GLuint kTextureService2Id
= 334;
772 const GLenum kTarget1
= GL_TEXTURE_2D
;
773 const GLint kLevel1
= 0;
774 const GLint kSamples1
= 0;
776 texture_manager_
->CreateTexture(kTextureClient1Id
, kTextureService1Id
);
777 scoped_refptr
<TextureRef
> texture1(
778 texture_manager_
->GetTexture(kTextureClient1Id
));
779 ASSERT_TRUE(texture1
.get() != NULL
);
780 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
781 scoped_refptr
<TextureRef
> texture2(
782 texture_manager_
->GetTexture(kTextureClient2Id
));
783 ASSERT_TRUE(texture2
.get() != NULL
);
785 // Attach to 2 attachment points.
786 framebuffer_
->AttachTexture(
787 GL_COLOR_ATTACHMENT0
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
788 framebuffer_
->AttachTexture(
789 GL_DEPTH_ATTACHMENT
, texture1
.get(), kTarget1
, kLevel1
, kSamples1
);
790 // Check they were attached.
791 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
792 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
793 // Unbind unattached texture.
794 framebuffer_
->UnbindTexture(kTarget1
, texture2
.get());
796 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) != NULL
);
797 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) != NULL
);
799 framebuffer_
->UnbindTexture(kTarget1
, texture1
.get());
800 // Check they were detached
801 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_COLOR_ATTACHMENT0
) == NULL
);
802 EXPECT_TRUE(framebuffer_
->GetAttachment(GL_DEPTH_ATTACHMENT
) == NULL
);
805 TEST_F(FramebufferInfoTest
, IsCompleteMarkAsComplete
) {
806 const GLuint kRenderbufferClient1Id
= 33;
807 const GLuint kRenderbufferService1Id
= 333;
808 const GLuint kTextureClient2Id
= 34;
809 const GLuint kTextureService2Id
= 334;
810 const GLenum kTarget1
= GL_TEXTURE_2D
;
811 const GLint kLevel1
= 0;
812 const GLint kSamples1
= 0;
814 renderbuffer_manager_
.CreateRenderbuffer(
815 kRenderbufferClient1Id
, kRenderbufferService1Id
);
816 Renderbuffer
* renderbuffer1
=
817 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient1Id
);
818 ASSERT_TRUE(renderbuffer1
!= NULL
);
819 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
820 scoped_refptr
<TextureRef
> texture2(
821 texture_manager_
->GetTexture(kTextureClient2Id
));
822 ASSERT_TRUE(texture2
.get() != NULL
);
824 // Check MarkAsComlete marks as complete.
825 manager_
.MarkAsComplete(framebuffer_
);
826 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
828 // Check at attaching marks as not complete.
829 framebuffer_
->AttachTexture(
830 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget1
, kLevel1
, kSamples1
);
831 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
832 manager_
.MarkAsComplete(framebuffer_
);
833 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
834 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
835 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
837 // Check MarkAttachmentsAsCleared marks as complete.
838 manager_
.MarkAttachmentsAsCleared(
839 framebuffer_
, &renderbuffer_manager_
, texture_manager_
.get());
840 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
842 // Check Unbind marks as not complete.
843 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
844 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
845 manager_
.MarkAsComplete(framebuffer_
);
846 EXPECT_TRUE(manager_
.IsComplete(framebuffer_
));
847 framebuffer_
->UnbindTexture(kTarget1
, texture2
.get());
848 EXPECT_FALSE(manager_
.IsComplete(framebuffer_
));
851 TEST_F(FramebufferInfoTest
, GetStatus
) {
852 const GLuint kRenderbufferClient1Id
= 33;
853 const GLuint kRenderbufferService1Id
= 333;
854 const GLuint kTextureClient2Id
= 34;
855 const GLuint kTextureService2Id
= 334;
856 const GLenum kTarget1
= GL_TEXTURE_2D
;
857 const GLint kLevel1
= 0;
858 const GLint kSamples1
= 0;
860 renderbuffer_manager_
.CreateRenderbuffer(
861 kRenderbufferClient1Id
, kRenderbufferService1Id
);
862 Renderbuffer
* renderbuffer1
=
863 renderbuffer_manager_
.GetRenderbuffer(kRenderbufferClient1Id
);
864 ASSERT_TRUE(renderbuffer1
!= NULL
);
865 texture_manager_
->CreateTexture(kTextureClient2Id
, kTextureService2Id
);
866 scoped_refptr
<TextureRef
> texture2(
867 texture_manager_
->GetTexture(kTextureClient2Id
));
868 ASSERT_TRUE(texture2
.get() != NULL
);
869 texture_manager_
->SetTarget(texture2
.get(), GL_TEXTURE_2D
);
871 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
872 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
873 .RetiresOnSaturation();
874 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
876 // Check a second call for the same type does not call anything
877 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
878 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
879 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
880 .RetiresOnSaturation();
882 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
884 // Check changing the attachments calls CheckFramebufferStatus.
885 framebuffer_
->AttachTexture(
886 GL_COLOR_ATTACHMENT0
, texture2
.get(), kTarget1
, kLevel1
, kSamples1
);
887 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
888 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
)).RetiresOnSaturation();
889 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
891 // Check a second call for the same type does not call anything.
892 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
893 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_FRAMEBUFFER
))
894 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
895 .RetiresOnSaturation();
897 framebuffer_
->GetStatus(texture_manager_
.get(), GL_FRAMEBUFFER
);
899 // Check a second call with a different target calls CheckFramebufferStatus.
900 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
901 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
902 .RetiresOnSaturation();
903 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
905 // Check a second call for the same type does not call anything.
906 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
907 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
908 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
909 .RetiresOnSaturation();
911 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
913 // Check adding another attachment calls CheckFramebufferStatus.
914 framebuffer_
->AttachRenderbuffer(GL_DEPTH_ATTACHMENT
, renderbuffer1
);
915 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
916 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
917 .RetiresOnSaturation();
918 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
920 // Check a second call for the same type does not call anything.
921 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
922 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
923 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
924 .RetiresOnSaturation();
926 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
928 // Check changing the format calls CheckFramebuffferStatus.
929 TestHelper::SetTexParameteriWithExpectations(gl_
.get(),
931 texture_manager_
.get(),
937 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
938 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT
))
939 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
940 .RetiresOnSaturation();
941 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
943 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls
944 // CheckFramebufferStatus
945 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
947 // Check putting it back does not call CheckFramebufferStatus.
948 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
949 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
950 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
951 .RetiresOnSaturation();
953 TestHelper::SetTexParameteriWithExpectations(gl_
.get(),
955 texture_manager_
.get(),
960 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);
962 // Check Unbinding does not call CheckFramebufferStatus
963 framebuffer_
->UnbindRenderbuffer(GL_RENDERBUFFER
, renderbuffer1
);
964 if (!framebuffer_
->AllowFramebufferComboCompleteMapForTesting()) {
965 EXPECT_CALL(*gl_
, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER
))
966 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE
))
967 .RetiresOnSaturation();
969 framebuffer_
->GetStatus(texture_manager_
.get(), GL_READ_FRAMEBUFFER
);