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/error_state_mock.h" | 5 #include "gpu/command_buffer/service/error_state_mock.h" |
6 #include "gpu/command_buffer/service/framebuffer_manager.h" | 6 #include "gpu/command_buffer/service/framebuffer_manager.h" |
7 #include "gpu/command_buffer/service/feature_info.h" | 7 #include "gpu/command_buffer/service/feature_info.h" |
8 #include "gpu/command_buffer/service/gpu_service_test.h" | 8 #include "gpu/command_buffer/service/gpu_service_test.h" |
9 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 9 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
10 #include "gpu/command_buffer/service/test_helper.h" | 10 #include "gpu/command_buffer/service/test_helper.h" |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 framebuffer_->AttachTexture( | 439 framebuffer_->AttachTexture( |
440 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1); | 440 GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1); |
441 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 441 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
442 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 442 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
443 framebuffer_->IsPossiblyComplete()); | 443 framebuffer_->IsPossiblyComplete()); |
444 EXPECT_TRUE(framebuffer_->IsCleared()); | 444 EXPECT_TRUE(framebuffer_->IsCleared()); |
445 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); | 445 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); |
446 | 446 |
447 // Try format that doesn't work with COLOR_ATTACHMENT0 | 447 // Try format that doesn't work with COLOR_ATTACHMENT0 |
448 texture_manager_->SetTarget(texture1.get(), GL_TEXTURE_2D); | 448 texture_manager_->SetTarget(texture1.get(), GL_TEXTURE_2D); |
449 texture_manager_->SetLevelInfo(texture1.get(), | 449 texture_manager_->SetLevelInfo( |
450 GL_TEXTURE_2D, | 450 texture1.get(), GL_TEXTURE_2D, kLevel1, kBadFormat1, kWidth1, kHeight1, |
451 kLevel1, | 451 kDepth, kBorder, kBadFormat1, kType, gfx::Rect(kWidth1, kHeight1)); |
452 kBadFormat1, | |
453 kWidth1, | |
454 kHeight1, | |
455 kDepth, | |
456 kBorder, | |
457 kBadFormat1, | |
458 kType, | |
459 true); | |
460 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 452 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
461 framebuffer_->IsPossiblyComplete()); | 453 framebuffer_->IsPossiblyComplete()); |
462 | 454 |
463 // Try a good format. | 455 // Try a good format. |
464 texture_manager_->SetLevelInfo(texture1.get(), | 456 texture_manager_->SetLevelInfo(texture1.get(), GL_TEXTURE_2D, kLevel1, |
465 GL_TEXTURE_2D, | 457 kFormat1, kWidth1, kHeight1, kDepth, kBorder, |
466 kLevel1, | 458 kFormat1, kType, gfx::Rect()); |
467 kFormat1, | |
468 kWidth1, | |
469 kHeight1, | |
470 kDepth, | |
471 kBorder, | |
472 kFormat1, | |
473 kType, | |
474 false); | |
475 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 459 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
476 framebuffer_->IsPossiblyComplete()); | 460 framebuffer_->IsPossiblyComplete()); |
477 EXPECT_FALSE(framebuffer_->IsCleared()); | 461 EXPECT_FALSE(framebuffer_->IsCleared()); |
478 texture_manager_->SetLevelInfo(texture1.get(), | 462 texture_manager_->SetLevelInfo(texture1.get(), GL_TEXTURE_2D, kLevel1, |
479 GL_TEXTURE_2D, | 463 kFormat1, kWidth1, kHeight1, kDepth, kBorder, |
480 kLevel1, | 464 kFormat1, kType, gfx::Rect(kWidth1, kHeight1)); |
481 kFormat1, | |
482 kWidth1, | |
483 kHeight1, | |
484 kDepth, | |
485 kBorder, | |
486 kFormat1, | |
487 kType, | |
488 true); | |
489 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 465 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
490 framebuffer_->IsPossiblyComplete()); | 466 framebuffer_->IsPossiblyComplete()); |
491 EXPECT_TRUE(framebuffer_->IsCleared()); | 467 EXPECT_TRUE(framebuffer_->IsCleared()); |
492 EXPECT_EQ(static_cast<GLenum>(kFormat1), | 468 EXPECT_EQ(static_cast<GLenum>(kFormat1), |
493 framebuffer_->GetColorAttachmentFormat()); | 469 framebuffer_->GetColorAttachmentFormat()); |
494 | 470 |
495 const Framebuffer::Attachment* attachment = | 471 const Framebuffer::Attachment* attachment = |
496 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); | 472 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); |
497 ASSERT_TRUE(attachment != NULL); | 473 ASSERT_TRUE(attachment != NULL); |
498 EXPECT_EQ(kWidth1, attachment->width()); | 474 EXPECT_EQ(kWidth1, attachment->width()); |
499 EXPECT_EQ(kHeight1, attachment->height()); | 475 EXPECT_EQ(kHeight1, attachment->height()); |
500 EXPECT_EQ(kSamples1, attachment->samples()); | 476 EXPECT_EQ(kSamples1, attachment->samples()); |
501 EXPECT_EQ(kFormat1, attachment->internal_format()); | 477 EXPECT_EQ(kFormat1, attachment->internal_format()); |
502 EXPECT_TRUE(attachment->cleared()); | 478 EXPECT_TRUE(attachment->cleared()); |
503 | 479 |
504 // Check replacing an attachment | 480 // Check replacing an attachment |
505 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); | 481 texture_manager_->CreateTexture(kTextureClient2Id, kTextureService2Id); |
506 scoped_refptr<TextureRef> texture2( | 482 scoped_refptr<TextureRef> texture2( |
507 texture_manager_->GetTexture(kTextureClient2Id)); | 483 texture_manager_->GetTexture(kTextureClient2Id)); |
508 ASSERT_TRUE(texture2.get() != NULL); | 484 ASSERT_TRUE(texture2.get() != NULL); |
509 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D); | 485 texture_manager_->SetTarget(texture2.get(), GL_TEXTURE_2D); |
510 texture_manager_->SetLevelInfo(texture2.get(), | 486 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel2, |
511 GL_TEXTURE_2D, | 487 kFormat2, kWidth2, kHeight2, kDepth, kBorder, |
512 kLevel2, | 488 kFormat2, kType, gfx::Rect(kWidth2, kHeight2)); |
513 kFormat2, | |
514 kWidth2, | |
515 kHeight2, | |
516 kDepth, | |
517 kBorder, | |
518 kFormat2, | |
519 kType, | |
520 true); | |
521 | 489 |
522 framebuffer_->AttachTexture( | 490 framebuffer_->AttachTexture( |
523 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2); | 491 GL_COLOR_ATTACHMENT0, texture2.get(), kTarget2, kLevel2, kSamples2); |
524 EXPECT_EQ(static_cast<GLenum>(kFormat2), | 492 EXPECT_EQ(static_cast<GLenum>(kFormat2), |
525 framebuffer_->GetColorAttachmentFormat()); | 493 framebuffer_->GetColorAttachmentFormat()); |
526 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 494 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
527 framebuffer_->IsPossiblyComplete()); | 495 framebuffer_->IsPossiblyComplete()); |
528 EXPECT_TRUE(framebuffer_->IsCleared()); | 496 EXPECT_TRUE(framebuffer_->IsCleared()); |
529 | 497 |
530 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); | 498 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); |
531 ASSERT_TRUE(attachment != NULL); | 499 ASSERT_TRUE(attachment != NULL); |
532 EXPECT_EQ(kWidth2, attachment->width()); | 500 EXPECT_EQ(kWidth2, attachment->width()); |
533 EXPECT_EQ(kHeight2, attachment->height()); | 501 EXPECT_EQ(kHeight2, attachment->height()); |
534 EXPECT_EQ(kSamples2, attachment->samples()); | 502 EXPECT_EQ(kSamples2, attachment->samples()); |
535 EXPECT_EQ(kFormat2, attachment->internal_format()); | 503 EXPECT_EQ(kFormat2, attachment->internal_format()); |
536 EXPECT_TRUE(attachment->cleared()); | 504 EXPECT_TRUE(attachment->cleared()); |
537 | 505 |
538 // Check changing attachment | 506 // Check changing attachment |
539 texture_manager_->SetLevelInfo(texture2.get(), | 507 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3, |
540 GL_TEXTURE_2D, | 508 kFormat3, kWidth3, kHeight3, kDepth, kBorder, |
541 kLevel3, | 509 kFormat3, kType, gfx::Rect()); |
542 kFormat3, | |
543 kWidth3, | |
544 kHeight3, | |
545 kDepth, | |
546 kBorder, | |
547 kFormat3, | |
548 kType, | |
549 false); | |
550 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); | 510 attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0); |
551 ASSERT_TRUE(attachment != NULL); | 511 ASSERT_TRUE(attachment != NULL); |
552 EXPECT_EQ(kWidth3, attachment->width()); | 512 EXPECT_EQ(kWidth3, attachment->width()); |
553 EXPECT_EQ(kHeight3, attachment->height()); | 513 EXPECT_EQ(kHeight3, attachment->height()); |
554 EXPECT_EQ(kSamples3, attachment->samples()); | 514 EXPECT_EQ(kSamples3, attachment->samples()); |
555 EXPECT_EQ(kFormat3, attachment->internal_format()); | 515 EXPECT_EQ(kFormat3, attachment->internal_format()); |
556 EXPECT_FALSE(attachment->cleared()); | 516 EXPECT_FALSE(attachment->cleared()); |
557 EXPECT_EQ(static_cast<GLenum>(kFormat3), | 517 EXPECT_EQ(static_cast<GLenum>(kFormat3), |
558 framebuffer_->GetColorAttachmentFormat()); | 518 framebuffer_->GetColorAttachmentFormat()); |
559 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 519 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
560 framebuffer_->IsPossiblyComplete()); | 520 framebuffer_->IsPossiblyComplete()); |
561 EXPECT_FALSE(framebuffer_->IsCleared()); | 521 EXPECT_FALSE(framebuffer_->IsCleared()); |
562 | 522 |
563 // Set to size 0 | 523 // Set to size 0 |
564 texture_manager_->SetLevelInfo(texture2.get(), | 524 texture_manager_->SetLevelInfo(texture2.get(), GL_TEXTURE_2D, kLevel3, |
565 GL_TEXTURE_2D, | 525 kFormat3, 0, 0, kDepth, kBorder, kFormat3, |
566 kLevel3, | 526 kType, gfx::Rect()); |
567 kFormat3, | |
568 0, | |
569 0, | |
570 kDepth, | |
571 kBorder, | |
572 kFormat3, | |
573 kType, | |
574 false); | |
575 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 527 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
576 framebuffer_->IsPossiblyComplete()); | 528 framebuffer_->IsPossiblyComplete()); |
577 | 529 |
578 // Check removing it. | 530 // Check removing it. |
579 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0); | 531 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0); |
580 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); | 532 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); |
581 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); | 533 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); |
582 | 534 |
583 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), | 535 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), |
584 framebuffer_->IsPossiblyComplete()); | 536 framebuffer_->IsPossiblyComplete()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 ASSERT_TRUE(attachment != NULL); | 572 ASSERT_TRUE(attachment != NULL); |
621 EXPECT_TRUE(attachment->cleared()); | 573 EXPECT_TRUE(attachment->cleared()); |
622 } | 574 } |
623 EXPECT_TRUE(framebuffer_->IsCleared()); | 575 EXPECT_TRUE(framebuffer_->IsCleared()); |
624 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); | 576 EXPECT_FALSE(framebuffer_->HasUnclearedColorAttachments()); |
625 | 577 |
626 // Set a texture as uncleared. | 578 // Set a texture as uncleared. |
627 scoped_refptr<TextureRef> texture1( | 579 scoped_refptr<TextureRef> texture1( |
628 texture_manager_->GetTexture(kTextureClientId[1])); | 580 texture_manager_->GetTexture(kTextureClientId[1])); |
629 texture_manager_->SetTarget(texture1.get(), GL_TEXTURE_2D); | 581 texture_manager_->SetTarget(texture1.get(), GL_TEXTURE_2D); |
630 texture_manager_->SetLevelInfo( | 582 texture_manager_->SetLevelInfo(texture1.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, |
631 texture1.get(), GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, | 583 4, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, |
632 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, false); | 584 gfx::Rect()); |
633 | 585 |
634 const Framebuffer::Attachment* attachment1 = | 586 const Framebuffer::Attachment* attachment1 = |
635 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT1); | 587 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT1); |
636 ASSERT_TRUE(attachment1 != NULL); | 588 ASSERT_TRUE(attachment1 != NULL); |
637 EXPECT_FALSE(attachment1->cleared()); | 589 EXPECT_FALSE(attachment1->cleared()); |
638 EXPECT_FALSE(framebuffer_->IsCleared()); | 590 EXPECT_FALSE(framebuffer_->IsCleared()); |
639 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT1)); | 591 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT1)); |
640 EXPECT_TRUE(framebuffer_->HasUnclearedColorAttachments()); | 592 EXPECT_TRUE(framebuffer_->HasUnclearedColorAttachments()); |
641 | 593 |
642 GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; | 594 GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 }; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
712 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); | 664 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); |
713 scoped_refptr<TextureRef> texture( | 665 scoped_refptr<TextureRef> texture( |
714 texture_manager_->GetTexture(kTextureClientId)); | 666 texture_manager_->GetTexture(kTextureClientId)); |
715 ASSERT_TRUE(texture.get() != NULL); | 667 ASSERT_TRUE(texture.get() != NULL); |
716 | 668 |
717 framebuffer_->AttachTexture( | 669 framebuffer_->AttachTexture( |
718 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples); | 670 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples); |
719 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); | 671 EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat()); |
720 | 672 |
721 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); | 673 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); |
722 texture_manager_->SetLevelInfo(texture.get(), | 674 texture_manager_->SetLevelInfo(texture.get(), GL_TEXTURE_2D, kLevel, |
723 GL_TEXTURE_2D, | 675 kInternalFormat, kWidth, kHeight, kDepth, |
724 kLevel, | 676 kBorder, kFormat, kType, gfx::Rect()); |
725 kInternalFormat, | |
726 kWidth, | |
727 kHeight, | |
728 kDepth, | |
729 kBorder, | |
730 kFormat, | |
731 kType, | |
732 false); | |
733 // Texture with a sized float internalformat is allowed as an attachment | 677 // Texture with a sized float internalformat is allowed as an attachment |
734 // since float color attachment extension is present. | 678 // since float color attachment extension is present. |
735 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 679 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
736 framebuffer_->IsPossiblyComplete()); | 680 framebuffer_->IsPossiblyComplete()); |
737 } | 681 } |
738 | 682 |
739 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) { | 683 TEST_F(FramebufferInfoTest, UnbindRenderbuffer) { |
740 const GLuint kRenderbufferClient1Id = 33; | 684 const GLuint kRenderbufferClient1Id = 33; |
741 const GLuint kRenderbufferService1Id = 333; | 685 const GLuint kRenderbufferService1Id = 333; |
742 const GLuint kRenderbufferClient2Id = 34; | 686 const GLuint kRenderbufferClient2Id = 34; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 917 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
974 .RetiresOnSaturation(); | 918 .RetiresOnSaturation(); |
975 } | 919 } |
976 framebuffer_->GetStatus(texture_manager_.get(), GL_READ_FRAMEBUFFER); | 920 framebuffer_->GetStatus(texture_manager_.get(), GL_READ_FRAMEBUFFER); |
977 } | 921 } |
978 | 922 |
979 } // namespace gles2 | 923 } // namespace gles2 |
980 } // namespace gpu | 924 } // namespace gpu |
981 | 925 |
982 | 926 |
OLD | NEW |