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

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: 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
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 538 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, AttachTextureLayer) {
560 const GLuint kTextureClientId = 33;
561 const GLuint kTextureServiceId = 333;
562 const GLint kBorder = 0;
563 const GLenum kType = GL_UNSIGNED_BYTE;
564 const GLsizei kWidth = 16;
565 const GLsizei kHeight = 32;
566 const GLint kDepth = 2;
567 const GLint kLevel = 0;
568 const GLenum kFormat = GL_RGBA;
569 const GLenum kTarget = GL_TEXTURE_2D_ARRAY;
570 const GLsizei kLayer = 0;
571 const GLint kWrongLayer = kDepth;
572
573 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
574 framebuffer_->IsPossiblyComplete(feature_info_.get()));
575
576 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
577 scoped_refptr<TextureRef> texture(
578 texture_manager_->GetTexture(kTextureClientId));
579 ASSERT_TRUE(texture.get());
580
581 framebuffer_->AttachTextureLayer(
582 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kWrongLayer);
583 EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
584 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
585 framebuffer_->IsPossiblyComplete(feature_info_.get()));
586 EXPECT_TRUE(framebuffer_->IsCleared());
587 EXPECT_EQ(static_cast<GLenum>(0),
588 framebuffer_->GetReadBufferInternalFormat());
589
590 texture_manager_->SetTarget(texture.get(), kTarget);
591 texture_manager_->SetLevelInfo(texture.get(), kTarget, kLevel,
592 kFormat, kWidth, kHeight, kDepth, kBorder,
593 kFormat, kType, gfx::Rect());
594 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
595 framebuffer_->IsPossiblyComplete(feature_info_.get()));
596
597 framebuffer_->AttachTextureLayer(
598 GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kLayer);
599 EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
600 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
601 framebuffer_->IsPossiblyComplete(feature_info_.get()));
602 EXPECT_FALSE(framebuffer_->IsCleared());
603 EXPECT_EQ(static_cast<GLenum>(kFormat),
604 framebuffer_->GetReadBufferInternalFormat());
605
606 const Framebuffer::Attachment* attachment =
607 framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
608 ASSERT_TRUE(attachment);
609 EXPECT_EQ(kWidth, attachment->width());
610 EXPECT_EQ(kHeight, attachment->height());
611 EXPECT_EQ(kFormat, attachment->internal_format());
612 EXPECT_FALSE(attachment->cleared());
613 }
614
559 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) { 615 TEST_F(FramebufferInfoTest, ClearPartiallyClearedAttachments) {
560 const GLuint kTextureClientId = 33; 616 const GLuint kTextureClientId = 33;
561 const GLuint kTextureServiceId = 333; 617 const GLuint kTextureServiceId = 333;
562 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId); 618 texture_manager_->CreateTexture(kTextureClientId, kTextureServiceId);
563 scoped_refptr<TextureRef> texture( 619 scoped_refptr<TextureRef> texture(
564 texture_manager_->GetTexture(kTextureClientId)); 620 texture_manager_->GetTexture(kTextureClientId));
565 ASSERT_TRUE(texture.get() != NULL); 621 ASSERT_TRUE(texture.get() != NULL);
566 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D); 622 texture_manager_->SetTarget(texture.get(), GL_TEXTURE_2D);
567 framebuffer_->AttachTexture( 623 framebuffer_->AttachTexture(
568 GL_COLOR_ATTACHMENT0, texture.get(), GL_TEXTURE_2D, 0, 0); 624 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); 1242 renderbuffer_manager_->GetRenderbuffer(kRenderbufferClientId);
1187 ASSERT_TRUE(renderbuffer != NULL); 1243 ASSERT_TRUE(renderbuffer != NULL);
1188 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer); 1244 framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT1, renderbuffer);
1189 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment()); 1245 EXPECT_TRUE(framebuffer_->GetReadBufferAttachment());
1190 } 1246 }
1191 1247
1192 } // namespace gles2 1248 } // namespace gles2
1193 } // namespace gpu 1249 } // namespace gpu
1194 1250
1195 1251
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698