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

Unified Diff: gpu/command_buffer/service/framebuffer_manager_unittest.cc

Issue 139013008: Implement support for rendering to 32-bit float textures on ES3 (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check that framebuffers really are supported and add tests Created 6 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/framebuffer_manager_unittest.cc
diff --git a/gpu/command_buffer/service/framebuffer_manager_unittest.cc b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
index a9b4388eda6af1d07f8d336360a100433be79fc9..8a2612c5fc5af9c6ffd298e934db0915c132de59 100644
--- a/gpu/command_buffer/service/framebuffer_manager_unittest.cc
+++ b/gpu/command_buffer/service/framebuffer_manager_unittest.cc
@@ -162,7 +162,7 @@ TEST_F(FramebufferInfoTest, Basic) {
EXPECT_FALSE(framebuffer_->HasDepthAttachment());
EXPECT_FALSE(framebuffer_->HasStencilAttachment());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
EXPECT_FALSE(manager_.IsComplete(framebuffer_));
@@ -216,14 +216,14 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_FALSE(framebuffer_->HasDepthAttachment());
EXPECT_FALSE(framebuffer_->HasStencilAttachment());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
// Try a format that's not good for COLOR_ATTACHMENT0.
renderbuffer_manager_.SetInfo(
renderbuffer1, kSamples1, kBadFormat1, kWidth1, kHeight1);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Try a good format.
renderbuffer_manager_.SetInfo(
@@ -233,7 +233,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_FALSE(framebuffer_->HasDepthAttachment());
EXPECT_FALSE(framebuffer_->HasStencilAttachment());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_FALSE(framebuffer_->IsCleared());
// check adding another
@@ -253,7 +253,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
// of attachments it could either get INCOMPLETE_ATTACHMENT because it's 0,0
// or INCOMPLETE_DIMENSIONS because it's not the same size as the other
// attachment.
- GLenum status = framebuffer_->IsPossiblyComplete();
+ GLenum status = framebuffer_->IsPossiblyComplete(false);
EXPECT_TRUE(
status == GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT ||
status == GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT);
@@ -262,7 +262,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
renderbuffer_manager_.SetInfo(
renderbuffer2, kSamples2, kFormat2, kWidth2, kHeight2);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_FALSE(framebuffer_->IsCleared());
EXPECT_TRUE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
@@ -272,7 +272,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
// Check adding one that is already cleared.
@@ -292,7 +292,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_TRUE(framebuffer_->HasDepthAttachment());
EXPECT_TRUE(framebuffer_->HasStencilAttachment());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
// Check marking the renderbuffer as unclared.
@@ -303,7 +303,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_TRUE(framebuffer_->HasDepthAttachment());
EXPECT_TRUE(framebuffer_->HasStencilAttachment());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_FALSE(framebuffer_->IsCleared());
const Framebuffer::Attachment* attachment =
@@ -344,7 +344,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_EQ(kFormat4, attachment->internal_format());
EXPECT_FALSE(attachment->cleared());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Check changing an attachment.
renderbuffer_manager_.SetInfo(
@@ -359,7 +359,7 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_FALSE(attachment->cleared());
EXPECT_FALSE(framebuffer_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Check removing it.
framebuffer_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, NULL);
@@ -371,18 +371,18 @@ TEST_F(FramebufferInfoTest, AttachRenderbuffer) {
EXPECT_TRUE(framebuffer_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Remove depth, Set color to 0 size.
framebuffer_->AttachRenderbuffer(GL_DEPTH_ATTACHMENT, NULL);
renderbuffer_manager_.SetInfo(renderbuffer1, kSamples1, kFormat1, 0, 0);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Remove color.
framebuffer_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, NULL);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
}
TEST_F(FramebufferInfoTest, AttachTexture) {
@@ -417,7 +417,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_FALSE(
framebuffer_->HasUnclearedAttachment(GL_DEPTH_STENCIL_ATTACHMENT));
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
texture_manager_.CreateTexture(kTextureClient1Id, kTextureService1Id);
scoped_refptr<TextureRef> texture1(
@@ -429,7 +429,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
GL_COLOR_ATTACHMENT0, texture1.get(), kTarget1, kLevel1, kSamples1);
EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
@@ -447,7 +447,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
kType,
true);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Try a good format.
texture_manager_.SetLevelInfo(texture1.get(),
@@ -462,7 +462,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
kType,
false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_FALSE(framebuffer_->IsCleared());
texture_manager_.SetLevelInfo(texture1.get(),
GL_TEXTURE_2D,
@@ -476,7 +476,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
kType,
true);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
EXPECT_EQ(static_cast<GLenum>(kFormat1),
framebuffer_->GetColorAttachmentFormat());
@@ -513,7 +513,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_EQ(static_cast<GLenum>(kFormat2),
framebuffer_->GetColorAttachmentFormat());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
attachment = framebuffer_->GetAttachment(GL_COLOR_ATTACHMENT0);
@@ -546,7 +546,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_EQ(static_cast<GLenum>(kFormat3),
framebuffer_->GetColorAttachmentFormat());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_FALSE(framebuffer_->IsCleared());
// Set to size 0
@@ -562,7 +562,7 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
kType,
false);
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
// Check removing it.
framebuffer_->AttachTexture(GL_COLOR_ATTACHMENT0, NULL, 0, 0, 0);
@@ -570,10 +570,79 @@ TEST_F(FramebufferInfoTest, AttachTexture) {
EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT),
- framebuffer_->IsPossiblyComplete());
+ framebuffer_->IsPossiblyComplete(false));
EXPECT_TRUE(framebuffer_->IsCleared());
}
+TEST_F(FramebufferInfoTest, AttachFloatTexture) {
+ const GLuint kTextureClientId = 33;
+ const GLuint kTextureServiceId = 333;
+ const GLint kDepth = 1;
+ const GLint kBorder = 0;
+ const GLenum kType = GL_FLOAT;
+ const GLsizei kWidth = 16;
+ const GLsizei kHeight = 32;
+ const GLint kLevel = 0;
+ const GLenum kFormat = GL_RGBA;
+ const GLenum kInternalFormat = GL_RGBA32F;
+ const GLenum kBadInternalFormat = GL_RGBA;
+ const GLenum kTarget = GL_TEXTURE_2D;
+ const GLsizei kSamples = 0;
+ EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0));
+ EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT));
+ EXPECT_FALSE(framebuffer_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT));
+
+ texture_manager_.CreateTexture(kTextureClientId, kTextureServiceId);
+ scoped_refptr<TextureRef> texture(
+ texture_manager_.GetTexture(kTextureClientId));
+ ASSERT_TRUE(texture.get() != NULL);
+
+ // check adding one attachment
+ framebuffer_->AttachTexture(
+ GL_COLOR_ATTACHMENT0, texture.get(), kTarget, kLevel, kSamples);
+ EXPECT_EQ(static_cast<GLenum>(0), framebuffer_->GetColorAttachmentFormat());
+
+ // Try unsized internalformat
+ texture_manager_.SetTarget(texture.get(), GL_TEXTURE_2D);
+ texture_manager_.SetLevelInfo(texture.get(),
+ GL_TEXTURE_2D,
+ kLevel,
+ kBadInternalFormat,
+ kWidth,
+ kHeight,
+ kDepth,
+ kBorder,
+ kFormat,
+ kType,
+ true);
+ // Texture with an unsized internalformat is not allowed as an attachment
+ // regardless of whether float color attachments are allowed in general.
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
+ framebuffer_->IsPossiblyComplete(false));
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
+ framebuffer_->IsPossiblyComplete(true));
+
+ // Try a good format.
+ texture_manager_.SetLevelInfo(texture.get(),
+ GL_TEXTURE_2D,
+ kLevel,
+ kInternalFormat,
+ kWidth,
+ kHeight,
+ kDepth,
+ kBorder,
+ kFormat,
+ kType,
+ false);
+ // Texture with a sized float internalformat is allowed as an attachment
+ // only if float color attachments allowed flag is true.
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT),
+ framebuffer_->IsPossiblyComplete(false));
+ EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE),
+ framebuffer_->IsPossiblyComplete(true));
+
+}
+
TEST_F(FramebufferInfoTest, UnbindRenderbuffer) {
const GLuint kRenderbufferClient1Id = 33;
const GLuint kRenderbufferService1Id = 333;

Powered by Google App Engine
This is Rietveld 408576698