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

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

Issue 2020473002: Check layer is valid for framebuffer 3D texture attachments. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix tex target bug Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include "gpu/command_buffer/service/error_state_mock.h" 8 #include "gpu/command_buffer/service/error_state_mock.h"
9 #include "gpu/command_buffer/service/feature_info.h" 9 #include "gpu/command_buffer/service/feature_info.h"
10 #include "gpu/command_buffer/service/framebuffer_manager.h" 10 #include "gpu/command_buffer/service/framebuffer_manager.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 renderbuffer_manager_->SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0); 406 renderbuffer_manager_->SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0);
407 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), 407 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
408 framebuffer_->IsPossiblyComplete(feature_info_.get())); 408 framebuffer_->IsPossiblyComplete(feature_info_.get()));
409 409
410 // Remove color. 410 // Remove color.
411 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL); 411 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL);
412 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 412 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
413 framebuffer_->IsPossiblyComplete(feature_info_.get())); 413 framebuffer_->IsPossiblyComplete(feature_info_.get()));
414 } 414 }
415 415
416 TEST_F(FramebufferInfoTest, AttachTexture) { 416 TEST_F(FramebufferInfoTest, AttachTexture2D) {
417 const GLuint kTextureClient1Id = 33; 417 const GLuint kTextureClient1Id = 33;
418 const GLuint kTextureService1Id = 333; 418 const GLuint kTextureService1Id = 333;
419 const GLuint kTextureClient2Id = 34; 419 const GLuint kTextureClient2Id = 34;
420 const GLuint kTextureService2Id = 334; 420 const GLuint kTextureService2Id = 334;
421 const GLint kDepth = 1; 421 const GLint kDepth = 1;
422 const GLint kBorder = 0; 422 const GLint kBorder = 0;
423 const GLenum kType = GL_UNSIGNED_BYTE; 423 const GLenum kType = GL_UNSIGNED_BYTE;
424 const GLsizei kWidth1 = 16; 424 const GLsizei kWidth1 = 16;
425 const GLsizei kHeight1 = 32; 425 const GLsizei kHeight1 = 32;
426 const GLint kLevel1 = 0; 426 const GLint kLevel1 = 0;
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0); 549 framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0);
550 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL); 550 EXPECT_TRUE(framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0) == NULL);
551 EXPECT_EQ(static_cast<GLenum>(0), 551 EXPECT_EQ(static_cast<GLenum>(0),
552 framebuffer_->GetReadBufferInternalFormat()); 552 framebuffer_->GetReadBufferInternalFormat());
553 553
554 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT), 554 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
555 framebuffer_->IsPossiblyComplete(feature_info_.get())); 555 framebuffer_->IsPossiblyComplete(feature_info_.get()));
556 EXPECT_TRUE(framebuffer_->IsCleared()); 556 EXPECT_TRUE(framebuffer_->IsCleared());
557 } 557 }
558 558
559 TEST_F(FramebufferInfoTest, AttachTextureCube) {
560 const GLuint kTextureClientId = 33;
561 const GLuint kTextureServiceId = 333;
562 const GLint kDepth = 1;
563 const GLint kBorder = 0;
564 const GLenum kType = GL_UNSIGNED_BYTE;
565 const GLsizei kWidth = 16;
566 const GLsizei kHeight = 16;
567 const GLint kLevel = 0;
568 const GLenum kFormat = GL_RGBA;
569 const GLenum kTarget = GL_TEXTURE_CUBE_MAP;
570 const GLsizei kSamples = 0;
571
572 const GLenum kTexTargets[] = {
573 GL_TEXTURE_CUBE_MAP_POSITIVE_X,
574 GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
575 GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
576 GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
577 GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
578 GL_TEXTURE_CUBE_MAP_NEGATIVE_Z};
579
580 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
581 framebuffer_->IsPossiblyComplete(feature_info_.get()));
582
583 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
584 scoped_refptr<TextureRef> texture(
585 texture_manager_->GetTexture(kTextureClientId));
586 ASSERT_TRUE(texture.get());
587
588 texture_manager_->SetTarget(texture.get(), kTarget);
589 framebuffer_->AttachTexture(
590 GL_COLOR_ATTACHMENT0, texture.get(), kTexTargets[0], kLevel, kSamples);
591 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
592 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
593 framebuffer_->IsPossiblyComplete(feature_info_.get()));
594 EXPECT_TRUE(framebuffer_->IsCleared());
595 EXPECT_EQ(static_cast<GLenum>(0),
596 framebuffer_->GetReadBufferInternalFormat());
597
598 texture_manager_->SetLevelInfo(texture.get(), kTexTargets[0], kLevel,
599 kFormat, kWidth, kHeight, kDepth, kBorder,
600 kFormat, kType, gfx::Rect(kWidth, kHeight));
601 EXPECT_TRUE(framebuffer_->IsCleared());
602 EXPECT_EQ(static_cast<GLenum>(kFormat),
603 framebuffer_->GetReadBufferInternalFormat());
604 // Cube incomplete.
605 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
606 framebuffer_->IsPossiblyComplete(feature_info_.get()));
607
608 for (size_t ii = 1; ii < 6; ++ii) {
609 texture_manager_->SetLevelInfo(texture.get(), kTexTargets[ii], kLevel,
610 kFormat, kWidth, kHeight, kDepth, kBorder,
611 kFormat, kType, gfx::Rect(kWidth, kHeight));
612 }
613 // Cube complete.
614 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
615 framebuffer_->IsPossiblyComplete(feature_info_.get()));
616 }
617
618 TEST_F(FramebufferInfoTest, AttachTextureLayer) {
619 const GLuint kTextureClientId = 33;
620 const GLuint kTextureServiceId = 333;
621 const GLint kBorder = 0;
622 const GLenum kType = GL_UNSIGNED_BYTE;
623 const GLsizei kWidth = 16;
624 const GLsizei kHeight = 32;
625 const GLint kDepth = 2;
626 const GLint kLevel = 0;
627 const GLenum kFormat = GL_RGBA;
628 const GLenum kTarget = GL_TEXTURE_2D_ARRAY;
629 const GLsizei kLayer = 0;
630 const GLint kWrongLayer = kDepth;
631
632 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
633 framebuffer_->IsPossiblyComplete(feature_info_.get()));
634
635 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
636 scoped_refptr<TextureRef> texture(
637 texture_manager_->GetTexture(kTextureClientId));
638 ASSERT_TRUE(texture.get());
639
640 framebuffer_->AttachTextureLayer(
641 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kWrongLayer);
642 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
643 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
644 framebuffer_->IsPossiblyComplete(feature_info_.get()));
645 EXPECT_TRUE(framebuffer_->IsCleared());
646 EXPECT_EQ(static_cast<GLenum>(0),
647 framebuffer_->GetReadBufferInternalFormat());
648
649 texture_manager_->SetTarget(texture.get(), kTarget);
650 texture_manager_->SetLevelInfo(texture.get(), kTarget, kLevel,
651 kFormat, kWidth, kHeight, kDepth, kBorder,
652 kFormat, kType, gfx::Rect());
653 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
654 framebuffer_->IsPossiblyComplete(feature_info_.get()));
655
656 framebuffer_->AttachTextureLayer(
657 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kLayer);
658 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
659 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
660 framebuffer_->IsPossiblyComplete(feature_info_.get()));
661 EXPECT_FALSE(framebuffer_->IsCleared());
662 EXPECT_EQ(static_cast<GLenum>(kFormat),
663 framebuffer_->GetReadBufferInternalFormat());
664
665 const Framebuffer::Attachment* attachment =
666 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
667 ASSERT_TRUE(attachment);
668 EXPECT_EQ(kWidth, attachment->width());
669 EXPECT_EQ(kHeight, attachment->height());
670 EXPECT_EQ(kFormat, attachment->internal_format());
671 EXPECT_FALSE(attachment->cleared());
672 }
673
559 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) { 674 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) {
560 const GLuint kTextureClientId = 33; 675 const GLuint kTextureClientId = 33;
561 const GLuint kTextureServiceId = 333; 676 const GLuint kTextureServiceId = 333;
562 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 677 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
563 scoped_refptr<TextureRef> texture( 678 scoped_refptr<TextureRef> texture(
564 texture_manager_->GetTexture(kTextureClientId)); 679 texture_manager_->GetTexture(kTextureClientId));
565 ASSERT_TRUE(texture.get() != NULL); 680 ASSERT_TRUE(texture.get() != NULL);
566 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 681 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
567 framebuffer_->AttachTexture( 682 framebuffer_->AttachTexture(
568 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0); 683 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0);
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1186 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId); 1301 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId);
1187 ASSERT_TRUE(renderbuffer != NULL); 1302 ASSERT_TRUE(renderbuffer != NULL);
1188 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer); 1303 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer);
1189 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment()); 1304 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment());
1190 } 1305 }
1191 1306
1192 } // namespace gles2 1307 } // namespace gles2
1193 } // namespace gpu 1308 } // namespace gpu
1194 1309
1195 1310
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/framebuffer_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698