OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gpu/command_buffer/service/framebuffer_manager.h" | 5 #include "gpu/command_buffer/service/framebuffer_manager.h" |
6 #include "gpu/command_buffer/service/feature_info.h" | 6 #include "gpu/command_buffer/service/feature_info.h" |
| 7 #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" |
7 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 8 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 9 #include "gpu/command_buffer/service/test_helper.h" |
8 #include "gpu/command_buffer/service/texture_manager.h" | 10 #include "gpu/command_buffer/service/texture_manager.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gl/gl_mock.h" | 12 #include "ui/gl/gl_mock.h" |
11 | 13 |
12 using ::testing::Return; | 14 using ::testing::Return; |
13 | 15 |
14 namespace gpu { | 16 namespace gpu { |
15 namespace gles2 { | 17 namespace gles2 { |
16 | 18 |
17 class FramebufferManagerTest : public testing::Test { | 19 class FramebufferManagerTest : public testing::Test { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 manager_.Destroy(false); | 126 manager_.Destroy(false); |
125 texture_manager_.Destroy(false); | 127 texture_manager_.Destroy(false); |
126 renderbuffer_manager_.Destroy(false); | 128 renderbuffer_manager_.Destroy(false); |
127 } | 129 } |
128 | 130 |
129 protected: | 131 protected: |
130 virtual void SetUp() { | 132 virtual void SetUp() { |
131 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); | 133 gl_.reset(new ::testing::StrictMock< ::gfx::MockGLInterface>()); |
132 ::gfx::GLInterface::SetGLInterface(gl_.get()); | 134 ::gfx::GLInterface::SetGLInterface(gl_.get()); |
133 manager_.CreateFramebuffer(kClient1Id, kService1Id); | 135 manager_.CreateFramebuffer(kClient1Id, kService1Id); |
| 136 decoder_.reset(new ::testing::StrictMock<gles2::MockGLES2Decoder>()); |
134 info_ = manager_.GetFramebuffer(kClient1Id); | 137 info_ = manager_.GetFramebuffer(kClient1Id); |
135 ASSERT_TRUE(info_ != NULL); | 138 ASSERT_TRUE(info_ != NULL); |
136 } | 139 } |
137 | 140 |
138 virtual void TearDown() { | 141 virtual void TearDown() { |
139 ::gfx::GLInterface::SetGLInterface(NULL); | 142 ::gfx::GLInterface::SetGLInterface(NULL); |
140 gl_.reset(); | 143 gl_.reset(); |
141 } | 144 } |
142 | 145 |
143 // Use StrictMock to make 100% sure we know how GL will be called. | 146 // Use StrictMock to make 100% sure we know how GL will be called. |
144 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; | 147 scoped_ptr< ::testing::StrictMock< ::gfx::MockGLInterface> > gl_; |
145 FramebufferManager manager_; | 148 FramebufferManager manager_; |
146 Framebuffer* info_; | 149 Framebuffer* info_; |
147 TextureManager texture_manager_; | 150 TextureManager texture_manager_; |
148 RenderbufferManager renderbuffer_manager_; | 151 RenderbufferManager renderbuffer_manager_; |
| 152 scoped_ptr<MockGLES2Decoder> decoder_; |
149 }; | 153 }; |
150 | 154 |
151 // GCC requires these declarations, but MSVC requires they not be present | 155 // GCC requires these declarations, but MSVC requires they not be present |
152 #ifndef COMPILER_MSVC | 156 #ifndef COMPILER_MSVC |
153 const GLuint FramebufferInfoTest::kClient1Id; | 157 const GLuint FramebufferInfoTest::kClient1Id; |
154 const GLuint FramebufferInfoTest::kService1Id; | 158 const GLuint FramebufferInfoTest::kService1Id; |
155 const GLint FramebufferInfoTest::kMaxTextureSize; | 159 const GLint FramebufferInfoTest::kMaxTextureSize; |
156 const GLint FramebufferInfoTest::kMaxCubemapSize; | 160 const GLint FramebufferInfoTest::kMaxCubemapSize; |
157 const GLint FramebufferInfoTest::kMaxRenderbufferSize; | 161 const GLint FramebufferInfoTest::kMaxRenderbufferSize; |
158 #endif | 162 #endif |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 const GLenum kFormat3 = GL_RGB565; | 414 const GLenum kFormat3 = GL_RGB565; |
411 const GLsizei kSamples3 = 0; | 415 const GLsizei kSamples3 = 0; |
412 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 416 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
413 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); | 417 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); |
414 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); | 418 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); |
415 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); | 419 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT)); |
416 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), | 420 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), |
417 info_->IsPossiblyComplete()); | 421 info_->IsPossiblyComplete()); |
418 | 422 |
419 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); | 423 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); |
420 scoped_refptr<Texture> tex_info1( | 424 scoped_refptr<Texture> texture1( |
421 texture_manager_.GetTexture(kTextureClient1Id)); | 425 texture_manager_.GetTexture(kTextureClient1Id)); |
422 ASSERT_TRUE(tex_info1 != NULL); | 426 ASSERT_TRUE(texture1 != NULL); |
423 | 427 |
424 // check adding one attachment | 428 // check adding one attachment |
425 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); | 429 info_->AttachTexture(GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1); |
426 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 430 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
427 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 431 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
428 info_->IsPossiblyComplete()); | 432 info_->IsPossiblyComplete()); |
429 EXPECT_TRUE(info_->IsCleared()); | 433 EXPECT_TRUE(info_->IsCleared()); |
430 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); | 434 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); |
431 | 435 |
432 // Try format that doesn't work with COLOR_ATTACHMENT0 | 436 // Try format that doesn't work with COLOR_ATTACHMENT0 |
433 texture_manager_.SetInfoTarget(tex_info1, GL_TEXTURE_2D); | 437 texture_manager_.SetTarget(texture1, GL_TEXTURE_2D); |
434 texture_manager_.SetLevelInfo( | 438 texture_manager_.SetLevelInfo( |
435 tex_info1, GL_TEXTURE_2D, kLevel1, | 439 texture1, GL_TEXTURE_2D, kLevel1, |
436 kBadFormat1, kWidth1, kHeight1, kDepth, kBorder, kBadFormat1, kType, | 440 kBadFormat1, kWidth1, kHeight1, kDepth, kBorder, kBadFormat1, kType, |
437 true); | 441 true); |
438 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 442 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
439 info_->IsPossiblyComplete()); | 443 info_->IsPossiblyComplete()); |
440 | 444 |
441 // Try a good format. | 445 // Try a good format. |
442 texture_manager_.SetLevelInfo( | 446 texture_manager_.SetLevelInfo( |
443 tex_info1, GL_TEXTURE_2D, kLevel1, | 447 texture1, GL_TEXTURE_2D, kLevel1, |
444 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false); | 448 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false); |
445 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 449 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
446 info_->IsPossiblyComplete()); | 450 info_->IsPossiblyComplete()); |
447 EXPECT_FALSE(info_->IsCleared()); | 451 EXPECT_FALSE(info_->IsCleared()); |
448 texture_manager_.SetLevelInfo( | 452 texture_manager_.SetLevelInfo( |
449 tex_info1, GL_TEXTURE_2D, kLevel1, | 453 texture1, GL_TEXTURE_2D, kLevel1, |
450 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true); | 454 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true); |
451 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 455 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
452 info_->IsPossiblyComplete()); | 456 info_->IsPossiblyComplete()); |
453 EXPECT_TRUE(info_->IsCleared()); | 457 EXPECT_TRUE(info_->IsCleared()); |
454 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); | 458 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); |
455 | 459 |
456 const Framebuffer::Attachment* attachment = | 460 const Framebuffer::Attachment* attachment = |
457 info_->GetAttachment(GL_COLOR_ATTACHMENT0); | 461 info_->GetAttachment(GL_COLOR_ATTACHMENT0); |
458 ASSERT_TRUE(attachment != NULL); | 462 ASSERT_TRUE(attachment != NULL); |
459 EXPECT_EQ(kWidth1, attachment->width()); | 463 EXPECT_EQ(kWidth1, attachment->width()); |
460 EXPECT_EQ(kHeight1, attachment->height()); | 464 EXPECT_EQ(kHeight1, attachment->height()); |
461 EXPECT_EQ(kSamples1, attachment->samples()); | 465 EXPECT_EQ(kSamples1, attachment->samples()); |
462 EXPECT_EQ(kFormat1, attachment->internal_format()); | 466 EXPECT_EQ(kFormat1, attachment->internal_format()); |
463 EXPECT_TRUE(attachment->cleared()); | 467 EXPECT_TRUE(attachment->cleared()); |
464 | 468 |
465 // Check replacing an attachment | 469 // Check replacing an attachment |
466 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); | 470 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); |
467 scoped_refptr<Texture> tex_info2( | 471 scoped_refptr<Texture> texture2( |
468 texture_manager_.GetTexture(kTextureClient2Id)); | 472 texture_manager_.GetTexture(kTextureClient2Id)); |
469 ASSERT_TRUE(tex_info2 != NULL); | 473 ASSERT_TRUE(texture2 != NULL); |
470 texture_manager_.SetInfoTarget(tex_info2, GL_TEXTURE_2D); | 474 texture_manager_.SetTarget(texture2, GL_TEXTURE_2D); |
471 texture_manager_.SetLevelInfo( | 475 texture_manager_.SetLevelInfo( |
472 tex_info2, GL_TEXTURE_2D, kLevel2, | 476 texture2, GL_TEXTURE_2D, kLevel2, |
473 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType, true); | 477 kFormat2, kWidth2, kHeight2, kDepth, kBorder, kFormat2, kType, true); |
474 | 478 |
475 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget2, kLevel2); | 479 info_->AttachTexture(GL_COLOR_ATTACHMENT0, texture2, kTarget2, kLevel2); |
476 EXPECT_EQ(static_cast<GLenum>(kFormat2), info_->GetColorAttachmentFormat()); | 480 EXPECT_EQ(static_cast<GLenum>(kFormat2), info_->GetColorAttachmentFormat()); |
477 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 481 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
478 info_->IsPossiblyComplete()); | 482 info_->IsPossiblyComplete()); |
479 EXPECT_TRUE(info_->IsCleared()); | 483 EXPECT_TRUE(info_->IsCleared()); |
480 | 484 |
481 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); | 485 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); |
482 ASSERT_TRUE(attachment != NULL); | 486 ASSERT_TRUE(attachment != NULL); |
483 EXPECT_EQ(kWidth2, attachment->width()); | 487 EXPECT_EQ(kWidth2, attachment->width()); |
484 EXPECT_EQ(kHeight2, attachment->height()); | 488 EXPECT_EQ(kHeight2, attachment->height()); |
485 EXPECT_EQ(kSamples2, attachment->samples()); | 489 EXPECT_EQ(kSamples2, attachment->samples()); |
486 EXPECT_EQ(kFormat2, attachment->internal_format()); | 490 EXPECT_EQ(kFormat2, attachment->internal_format()); |
487 EXPECT_TRUE(attachment->cleared()); | 491 EXPECT_TRUE(attachment->cleared()); |
488 | 492 |
489 // Check changing attachment | 493 // Check changing attachment |
490 texture_manager_.SetLevelInfo( | 494 texture_manager_.SetLevelInfo( |
491 tex_info2, GL_TEXTURE_2D, kLevel3, | 495 texture2, GL_TEXTURE_2D, kLevel3, |
492 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType, false); | 496 kFormat3, kWidth3, kHeight3, kDepth, kBorder, kFormat3, kType, false); |
493 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); | 497 attachment = info_->GetAttachment(GL_COLOR_ATTACHMENT0); |
494 ASSERT_TRUE(attachment != NULL); | 498 ASSERT_TRUE(attachment != NULL); |
495 EXPECT_EQ(kWidth3, attachment->width()); | 499 EXPECT_EQ(kWidth3, attachment->width()); |
496 EXPECT_EQ(kHeight3, attachment->height()); | 500 EXPECT_EQ(kHeight3, attachment->height()); |
497 EXPECT_EQ(kSamples3, attachment->samples()); | 501 EXPECT_EQ(kSamples3, attachment->samples()); |
498 EXPECT_EQ(kFormat3, attachment->internal_format()); | 502 EXPECT_EQ(kFormat3, attachment->internal_format()); |
499 EXPECT_FALSE(attachment->cleared()); | 503 EXPECT_FALSE(attachment->cleared()); |
500 EXPECT_EQ(static_cast<GLenum>(kFormat3), info_->GetColorAttachmentFormat()); | 504 EXPECT_EQ(static_cast<GLenum>(kFormat3), info_->GetColorAttachmentFormat()); |
501 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 505 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
502 info_->IsPossiblyComplete()); | 506 info_->IsPossiblyComplete()); |
503 EXPECT_FALSE(info_->IsCleared()); | 507 EXPECT_FALSE(info_->IsCleared()); |
504 | 508 |
505 // Set to size 0 | 509 // Set to size 0 |
506 texture_manager_.SetLevelInfo( | 510 texture_manager_.SetLevelInfo( |
507 tex_info2, GL_TEXTURE_2D, kLevel3, | 511 texture2, GL_TEXTURE_2D, kLevel3, |
508 kFormat3, 0, 0, kDepth, kBorder, kFormat3, kType, false); | 512 kFormat3, 0, 0, kDepth, kBorder, kFormat3, kType, false); |
509 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 513 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
510 info_->IsPossiblyComplete()); | 514 info_->IsPossiblyComplete()); |
511 | 515 |
512 // Check removing it. | 516 // Check removing it. |
513 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0); | 517 info_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0); |
514 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); | 518 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); |
515 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); | 519 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); |
516 | 520 |
517 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), | 521 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 560 |
557 TEST_F(FramebufferInfoTest, UnbindTexture) { | 561 TEST_F(FramebufferInfoTest, UnbindTexture) { |
558 const GLuint kTextureClient1Id = 33; | 562 const GLuint kTextureClient1Id = 33; |
559 const GLuint kTextureService1Id = 333; | 563 const GLuint kTextureService1Id = 333; |
560 const GLuint kTextureClient2Id = 34; | 564 const GLuint kTextureClient2Id = 34; |
561 const GLuint kTextureService2Id = 334; | 565 const GLuint kTextureService2Id = 334; |
562 const GLenum kTarget1 = GL_TEXTURE_2D; | 566 const GLenum kTarget1 = GL_TEXTURE_2D; |
563 const GLint kLevel1 = 0; | 567 const GLint kLevel1 = 0; |
564 | 568 |
565 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); | 569 texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id); |
566 scoped_refptr<Texture> tex_info1( | 570 scoped_refptr<Texture> texture1( |
567 texture_manager_.GetTexture(kTextureClient1Id)); | 571 texture_manager_.GetTexture(kTextureClient1Id)); |
568 ASSERT_TRUE(tex_info1 != NULL); | 572 ASSERT_TRUE(texture1 != NULL); |
569 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); | 573 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); |
570 scoped_refptr<Texture> tex_info2( | 574 scoped_refptr<Texture> texture2( |
571 texture_manager_.GetTexture(kTextureClient2Id)); | 575 texture_manager_.GetTexture(kTextureClient2Id)); |
572 ASSERT_TRUE(tex_info2 != NULL); | 576 ASSERT_TRUE(texture2 != NULL); |
573 | 577 |
574 // Attach to 2 attachment points. | 578 // Attach to 2 attachment points. |
575 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); | 579 info_->AttachTexture(GL_COLOR_ATTACHMENT0, texture1, kTarget1, kLevel1); |
576 info_->AttachTexture(GL_DEPTH_ATTACHMENT, tex_info1, kTarget1, kLevel1); | 580 info_->AttachTexture(GL_DEPTH_ATTACHMENT, texture1, kTarget1, kLevel1); |
577 // Check they were attached. | 581 // Check they were attached. |
578 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); | 582 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); |
579 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); | 583 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); |
580 // Unbind unattached texture. | 584 // Unbind unattached texture. |
581 info_->UnbindTexture(kTarget1, tex_info2); | 585 info_->UnbindTexture(kTarget1, texture2); |
582 // Should be no-op. | 586 // Should be no-op. |
583 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); | 587 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) != NULL); |
584 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); | 588 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) != NULL); |
585 // Unbind texture. | 589 // Unbind texture. |
586 info_->UnbindTexture(kTarget1, tex_info1); | 590 info_->UnbindTexture(kTarget1, texture1); |
587 // Check they were detached | 591 // Check they were detached |
588 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); | 592 EXPECT_TRUE(info_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); |
589 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL); | 593 EXPECT_TRUE(info_->GetAttachment(GL_DEPTH_ATTACHMENT) == NULL); |
590 } | 594 } |
591 | 595 |
592 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) { | 596 TEST_F(FramebufferInfoTest, IsCompleteMarkAsComplete) { |
593 const GLuint kRenderbufferClient1Id = 33; | 597 const GLuint kRenderbufferClient1Id = 33; |
594 const GLuint kRenderbufferService1Id = 333; | 598 const GLuint kRenderbufferService1Id = 333; |
595 const GLuint kTextureClient2Id = 34; | 599 const GLuint kTextureClient2Id = 34; |
596 const GLuint kTextureService2Id = 334; | 600 const GLuint kTextureService2Id = 334; |
597 const GLenum kTarget1 = GL_TEXTURE_2D; | 601 const GLenum kTarget1 = GL_TEXTURE_2D; |
598 const GLint kLevel1 = 0; | 602 const GLint kLevel1 = 0; |
599 | 603 |
600 renderbuffer_manager_.CreateRenderbuffer( | 604 renderbuffer_manager_.CreateRenderbuffer( |
601 kRenderbufferClient1Id, kRenderbufferService1Id); | 605 kRenderbufferClient1Id, kRenderbufferService1Id); |
602 Renderbuffer* rb_info1 = | 606 Renderbuffer* rb_info1 = |
603 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); | 607 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); |
604 ASSERT_TRUE(rb_info1 != NULL); | 608 ASSERT_TRUE(rb_info1 != NULL); |
605 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); | 609 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); |
606 scoped_refptr<Texture> tex_info2( | 610 scoped_refptr<Texture> texture2( |
607 texture_manager_.GetTexture(kTextureClient2Id)); | 611 texture_manager_.GetTexture(kTextureClient2Id)); |
608 ASSERT_TRUE(tex_info2 != NULL); | 612 ASSERT_TRUE(texture2 != NULL); |
609 | 613 |
610 // Check MarkAsComlete marks as complete. | 614 // Check MarkAsComlete marks as complete. |
611 manager_.MarkAsComplete(info_); | 615 manager_.MarkAsComplete(info_); |
612 EXPECT_TRUE(manager_.IsComplete(info_)); | 616 EXPECT_TRUE(manager_.IsComplete(info_)); |
613 | 617 |
614 // Check at attaching marks as not complete. | 618 // Check at attaching marks as not complete. |
615 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget1, kLevel1); | 619 info_->AttachTexture(GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1); |
616 EXPECT_FALSE(manager_.IsComplete(info_)); | 620 EXPECT_FALSE(manager_.IsComplete(info_)); |
617 manager_.MarkAsComplete(info_); | 621 manager_.MarkAsComplete(info_); |
618 EXPECT_TRUE(manager_.IsComplete(info_)); | 622 EXPECT_TRUE(manager_.IsComplete(info_)); |
619 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); | 623 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); |
620 EXPECT_FALSE(manager_.IsComplete(info_)); | 624 EXPECT_FALSE(manager_.IsComplete(info_)); |
621 | 625 |
622 // Check MarkAttachmentsAsCleared marks as complete. | 626 // Check MarkAttachmentsAsCleared marks as complete. |
623 manager_.MarkAttachmentsAsCleared( | 627 manager_.MarkAttachmentsAsCleared( |
624 info_, &renderbuffer_manager_, &texture_manager_); | 628 info_, &renderbuffer_manager_, &texture_manager_); |
625 EXPECT_TRUE(manager_.IsComplete(info_)); | 629 EXPECT_TRUE(manager_.IsComplete(info_)); |
626 | 630 |
627 // Check Unbind marks as not complete. | 631 // Check Unbind marks as not complete. |
628 info_->UnbindRenderbuffer(GL_RENDERBUFFER, rb_info1); | 632 info_->UnbindRenderbuffer(GL_RENDERBUFFER, rb_info1); |
629 EXPECT_FALSE(manager_.IsComplete(info_)); | 633 EXPECT_FALSE(manager_.IsComplete(info_)); |
630 manager_.MarkAsComplete(info_); | 634 manager_.MarkAsComplete(info_); |
631 EXPECT_TRUE(manager_.IsComplete(info_)); | 635 EXPECT_TRUE(manager_.IsComplete(info_)); |
632 info_->UnbindTexture(kTarget1, tex_info2); | 636 info_->UnbindTexture(kTarget1, texture2); |
633 EXPECT_FALSE(manager_.IsComplete(info_)); | 637 EXPECT_FALSE(manager_.IsComplete(info_)); |
634 } | 638 } |
635 | 639 |
636 TEST_F(FramebufferInfoTest, Gettatus) { | 640 TEST_F(FramebufferInfoTest, GetStatus) { |
637 const GLuint kRenderbufferClient1Id = 33; | 641 const GLuint kRenderbufferClient1Id = 33; |
638 const GLuint kRenderbufferService1Id = 333; | 642 const GLuint kRenderbufferService1Id = 333; |
639 const GLuint kTextureClient2Id = 34; | 643 const GLuint kTextureClient2Id = 34; |
640 const GLuint kTextureService2Id = 334; | 644 const GLuint kTextureService2Id = 334; |
641 const GLenum kTarget1 = GL_TEXTURE_2D; | 645 const GLenum kTarget1 = GL_TEXTURE_2D; |
642 const GLint kLevel1 = 0; | 646 const GLint kLevel1 = 0; |
643 | 647 |
644 renderbuffer_manager_.CreateRenderbuffer( | 648 renderbuffer_manager_.CreateRenderbuffer( |
645 kRenderbufferClient1Id, kRenderbufferService1Id); | 649 kRenderbufferClient1Id, kRenderbufferService1Id); |
646 Renderbuffer* rb_info1 = | 650 Renderbuffer* rb_info1 = |
647 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); | 651 renderbuffer_manager_.GetRenderbuffer(kRenderbufferClient1Id); |
648 ASSERT_TRUE(rb_info1 != NULL); | 652 ASSERT_TRUE(rb_info1 != NULL); |
649 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); | 653 texture_manager_.CreateTexture(kTextureClient2Id, kTextureService2Id); |
650 scoped_refptr<Texture> tex_info2( | 654 scoped_refptr<Texture> texture2( |
651 texture_manager_.GetTexture(kTextureClient2Id)); | 655 texture_manager_.GetTexture(kTextureClient2Id)); |
652 ASSERT_TRUE(tex_info2 != NULL); | 656 ASSERT_TRUE(texture2 != NULL); |
653 texture_manager_.SetInfoTarget(tex_info2, GL_TEXTURE_2D); | 657 texture_manager_.SetTarget(texture2, GL_TEXTURE_2D); |
654 | 658 |
655 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 659 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
656 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 660 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
657 .RetiresOnSaturation(); | 661 .RetiresOnSaturation(); |
658 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); | 662 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); |
659 | 663 |
660 // Check a second call for the same type does not call anything | 664 // Check a second call for the same type does not call anything |
661 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); | 665 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); |
662 | 666 |
663 // Check changing the attachments calls CheckFramebufferStatus. | 667 // Check changing the attachments calls CheckFramebufferStatus. |
664 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info2, kTarget1, kLevel1); | 668 info_->AttachTexture(GL_COLOR_ATTACHMENT0, texture2, kTarget1, kLevel1); |
665 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 669 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
666 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 670 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
667 .RetiresOnSaturation(); | 671 .RetiresOnSaturation(); |
668 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); | 672 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); |
669 | 673 |
670 // Check a second call for the same type does not call anything. | 674 // Check a second call for the same type does not call anything. |
671 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); | 675 info_->GetStatus(&texture_manager_, GL_FRAMEBUFFER); |
672 | 676 |
673 // Check a second call with a different target calls CheckFramebufferStatus. | 677 // Check a second call with a different target calls CheckFramebufferStatus. |
674 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) | 678 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) |
675 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 679 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
676 .RetiresOnSaturation(); | 680 .RetiresOnSaturation(); |
677 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 681 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
678 | 682 |
679 // Check a second call for the same type does not call anything. | 683 // Check a second call for the same type does not call anything. |
680 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 684 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
681 | 685 |
682 // Check adding another attachment calls CheckFramebufferStatus. | 686 // Check adding another attachment calls CheckFramebufferStatus. |
683 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); | 687 info_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, rb_info1); |
684 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) | 688 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) |
685 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 689 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
686 .RetiresOnSaturation(); | 690 .RetiresOnSaturation(); |
687 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 691 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
688 | 692 |
689 // Check a second call for the same type does not call anything. | 693 // Check a second call for the same type does not call anything. |
690 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 694 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
691 | 695 |
692 // Check changing the format calls CheckFramebuffferStatus. | 696 // Check changing the format calls CheckFramebuffferStatus. |
693 texture_manager_.SetParameter(tex_info2, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 697 TestHelper::SetTexParameterWithExpectations( |
| 698 gl_.get(), decoder_.get(), &texture_manager_, |
| 699 texture2, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE, GL_NO_ERROR); |
694 | 700 |
695 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) | 701 EXPECT_CALL(*gl_, CheckFramebufferStatusEXT(GL_READ_FRAMEBUFFER)) |
696 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) | 702 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) |
697 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 703 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
698 .RetiresOnSaturation(); | 704 .RetiresOnSaturation(); |
699 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 705 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
700 | 706 |
701 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls | 707 // Check since it did not return FRAMEBUFFER_COMPLETE that it calls |
702 // CheckFramebufferStatus | 708 // CheckFramebufferStatus |
703 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 709 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
704 | 710 |
705 // Check putting it back does not call CheckFramebufferStatus. | 711 // Check putting it back does not call CheckFramebufferStatus. |
706 texture_manager_.SetParameter(tex_info2, GL_TEXTURE_WRAP_S, GL_REPEAT); | 712 TestHelper::SetTexParameterWithExpectations( |
| 713 gl_.get(), decoder_.get(), &texture_manager_, |
| 714 texture2, GL_TEXTURE_WRAP_S, GL_REPEAT, GL_NO_ERROR); |
707 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 715 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
708 | 716 |
709 // Check Unbinding does not call CheckFramebufferStatus | 717 // Check Unbinding does not call CheckFramebufferStatus |
710 info_->UnbindRenderbuffer(GL_RENDERBUFFER, rb_info1); | 718 info_->UnbindRenderbuffer(GL_RENDERBUFFER, rb_info1); |
711 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); | 719 info_->GetStatus(&texture_manager_, GL_READ_FRAMEBUFFER); |
712 } | 720 } |
713 | 721 |
714 } // namespace gles2 | 722 } // namespace gles2 |
715 } // namespace gpu | 723 } // namespace gpu |
716 | 724 |
717 | 725 |
OLD | NEW |