| 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 | 7 |
| 8 #include "gpu/command_buffer/common/gl_mock.h" | 8 #include "gpu/command_buffer/common/gl_mock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 const GLuint kRenderbufferService1Id = 333; | 169 const GLuint kRenderbufferService1Id = 333; |
| 170 const GLuint kRenderbufferClient2Id = 34; | 170 const GLuint kRenderbufferClient2Id = 34; |
| 171 const GLuint kRenderbufferService2Id = 334; | 171 const GLuint kRenderbufferService2Id = 334; |
| 172 const GLuint kRenderbufferClient3Id = 35; | 172 const GLuint kRenderbufferClient3Id = 35; |
| 173 const GLuint kRenderbufferService3Id = 335; | 173 const GLuint kRenderbufferService3Id = 335; |
| 174 const GLuint kRenderbufferClient4Id = 36; | 174 const GLuint kRenderbufferClient4Id = 36; |
| 175 const GLuint kRenderbufferService4Id = 336; | 175 const GLuint kRenderbufferService4Id = 336; |
| 176 const GLsizei kWidth1 = 16; | 176 const GLsizei kWidth1 = 16; |
| 177 const GLsizei kHeight1 = 32; | 177 const GLsizei kHeight1 = 32; |
| 178 const GLenum kFormat1 = GL_RGBA4; | 178 const GLenum kFormat1 = GL_RGBA4; |
| 179 const GLenum kBadFormat1 = GL_DEPTH_COMPONENT16; |
| 179 const GLsizei kSamples1 = 0; | 180 const GLsizei kSamples1 = 0; |
| 180 const GLsizei kWidth2 = 16; | 181 const GLsizei kWidth2 = 16; |
| 181 const GLsizei kHeight2 = 32; | 182 const GLsizei kHeight2 = 32; |
| 182 const GLenum kFormat2 = GL_DEPTH_COMPONENT16; | 183 const GLenum kFormat2 = GL_DEPTH_COMPONENT16; |
| 183 const GLsizei kSamples2 = 0; | 184 const GLsizei kSamples2 = 0; |
| 184 const GLsizei kWidth3 = 16; | 185 const GLsizei kWidth3 = 16; |
| 185 const GLsizei kHeight3 = 32; | 186 const GLsizei kHeight3 = 32; |
| 186 const GLenum kFormat3 = GL_STENCIL_INDEX8; | 187 const GLenum kFormat3 = GL_STENCIL_INDEX8; |
| 187 const GLsizei kSamples3 = 0; | 188 const GLsizei kSamples3 = 0; |
| 188 const GLsizei kWidth4 = 16; | 189 const GLsizei kWidth4 = 16; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 205 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1); | 206 info_->AttachRenderbuffer(GL_COLOR_ATTACHMENT0, rb_info1); |
| 206 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 207 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
| 207 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); | 208 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_DEPTH_ATTACHMENT)); |
| 208 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), info_->GetColorAttachmentFormat()); | 209 EXPECT_EQ(static_cast<GLenum>(GL_RGBA4), info_->GetColorAttachmentFormat()); |
| 209 EXPECT_FALSE(info_->HasDepthAttachment()); | 210 EXPECT_FALSE(info_->HasDepthAttachment()); |
| 210 EXPECT_FALSE(info_->HasStencilAttachment()); | 211 EXPECT_FALSE(info_->HasStencilAttachment()); |
| 211 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 212 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
| 212 info_->IsPossiblyComplete()); | 213 info_->IsPossiblyComplete()); |
| 213 EXPECT_TRUE(info_->IsCleared()); | 214 EXPECT_TRUE(info_->IsCleared()); |
| 214 | 215 |
| 216 // Try a format that's not good for COLOR_ATTACHMENT0. |
| 217 renderbuffer_manager_.SetInfo( |
| 218 rb_info1, kSamples1, kBadFormat1, kWidth1, kHeight1); |
| 219 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
| 220 info_->IsPossiblyComplete()); |
| 221 |
| 222 // Try a good format. |
| 215 renderbuffer_manager_.SetInfo( | 223 renderbuffer_manager_.SetInfo( |
| 216 rb_info1, kSamples1, kFormat1, kWidth1, kHeight1); | 224 rb_info1, kSamples1, kFormat1, kWidth1, kHeight1); |
| 217 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); | 225 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); |
| 218 EXPECT_FALSE(info_->HasDepthAttachment()); | 226 EXPECT_FALSE(info_->HasDepthAttachment()); |
| 219 EXPECT_FALSE(info_->HasStencilAttachment()); | 227 EXPECT_FALSE(info_->HasStencilAttachment()); |
| 220 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 228 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 221 info_->IsPossiblyComplete()); | 229 info_->IsPossiblyComplete()); |
| 222 EXPECT_FALSE(info_->IsCleared()); | 230 EXPECT_FALSE(info_->IsCleared()); |
| 223 | 231 |
| 224 // check adding another | 232 // check adding another |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // Check adding one that is already cleared. | 270 // Check adding one that is already cleared. |
| 263 renderbuffer_manager_.CreateRenderbufferInfo( | 271 renderbuffer_manager_.CreateRenderbufferInfo( |
| 264 kRenderbufferClient3Id, kRenderbufferService3Id); | 272 kRenderbufferClient3Id, kRenderbufferService3Id); |
| 265 RenderbufferManager::RenderbufferInfo* rb_info3 = | 273 RenderbufferManager::RenderbufferInfo* rb_info3 = |
| 266 renderbuffer_manager_.GetRenderbufferInfo(kRenderbufferClient3Id); | 274 renderbuffer_manager_.GetRenderbufferInfo(kRenderbufferClient3Id); |
| 267 ASSERT_TRUE(rb_info3 != NULL); | 275 ASSERT_TRUE(rb_info3 != NULL); |
| 268 renderbuffer_manager_.SetInfo( | 276 renderbuffer_manager_.SetInfo( |
| 269 rb_info3, kSamples3, kFormat3, kWidth3, kHeight3); | 277 rb_info3, kSamples3, kFormat3, kWidth3, kHeight3); |
| 270 renderbuffer_manager_.SetCleared(rb_info3); | 278 renderbuffer_manager_.SetCleared(rb_info3); |
| 271 | 279 |
| 272 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info1); | 280 info_->AttachRenderbuffer(GL_STENCIL_ATTACHMENT, rb_info3); |
| 273 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); | 281 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); |
| 274 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); | 282 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); |
| 275 EXPECT_TRUE(info_->HasDepthAttachment()); | 283 EXPECT_TRUE(info_->HasDepthAttachment()); |
| 276 EXPECT_TRUE(info_->HasStencilAttachment()); | 284 EXPECT_TRUE(info_->HasStencilAttachment()); |
| 277 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 285 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 278 info_->IsPossiblyComplete()); | 286 info_->IsPossiblyComplete()); |
| 279 EXPECT_TRUE(info_->IsCleared()); | 287 EXPECT_TRUE(info_->IsCleared()); |
| 280 | 288 |
| 281 // Check marking the renderbuffer as unclared. | 289 // Check marking the renderbuffer as unclared. |
| 282 renderbuffer_manager_.SetInfo( | 290 renderbuffer_manager_.SetInfo( |
| 283 rb_info1, kSamples1, kFormat1, kWidth1, kHeight1); | 291 rb_info1, kSamples1, kFormat1, kWidth1, kHeight1); |
| 284 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); | 292 EXPECT_EQ(static_cast<GLenum>(kFormat1), info_->GetColorAttachmentFormat()); |
| 285 EXPECT_TRUE(info_->HasDepthAttachment()); | 293 EXPECT_TRUE(info_->HasDepthAttachment()); |
| 286 EXPECT_TRUE(info_->HasStencilAttachment()); | 294 EXPECT_TRUE(info_->HasStencilAttachment()); |
| 287 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 295 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 288 info_->IsPossiblyComplete()); | 296 info_->IsPossiblyComplete()); |
| 289 EXPECT_FALSE(info_->IsCleared()); | 297 EXPECT_FALSE(info_->IsCleared()); |
| 290 | 298 |
| 291 const FramebufferManager::FramebufferInfo::Attachment* attachment = | 299 const FramebufferManager::FramebufferInfo::Attachment* attachment = |
| 292 info_->GetAttachment(GL_COLOR_ATTACHMENT0); | 300 info_->GetAttachment(GL_COLOR_ATTACHMENT0); |
| 293 ASSERT_TRUE(attachment != NULL); | 301 ASSERT_TRUE(attachment != NULL); |
| 294 EXPECT_EQ(kWidth1, attachment->width()); | 302 EXPECT_EQ(kWidth1, attachment->width()); |
| 295 EXPECT_EQ(kHeight1, attachment->height()); | 303 EXPECT_EQ(kHeight1, attachment->height()); |
| 296 EXPECT_EQ(kSamples1, attachment->samples()); | 304 EXPECT_EQ(kSamples1, attachment->samples()); |
| 297 EXPECT_EQ(kFormat1, attachment->internal_format()); | 305 EXPECT_EQ(kFormat1, attachment->internal_format()); |
| 298 EXPECT_FALSE(attachment->cleared()); | 306 EXPECT_FALSE(attachment->cleared()); |
| 299 | 307 |
| 300 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); | 308 EXPECT_TRUE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
| 301 | 309 |
| 302 // Clear it. | 310 // Clear it. |
| 303 manager_.MarkAttachmentsAsCleared( | 311 manager_.MarkAttachmentsAsCleared( |
| 304 info_, &renderbuffer_manager_, &texture_manager_); | 312 info_, &renderbuffer_manager_, &texture_manager_); |
| 305 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_STENCIL_ATTACHMENT)); | 313 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
| 306 EXPECT_TRUE(info_->IsCleared()); | 314 EXPECT_TRUE(info_->IsCleared()); |
| 307 | 315 |
| 308 // Check replacing an attachment | 316 // Check replacing an attachment |
| 309 renderbuffer_manager_.CreateRenderbufferInfo( | 317 renderbuffer_manager_.CreateRenderbufferInfo( |
| 310 kRenderbufferClient4Id, kRenderbufferService4Id); | 318 kRenderbufferClient4Id, kRenderbufferService4Id); |
| 311 RenderbufferManager::RenderbufferInfo* rb_info4 = | 319 RenderbufferManager::RenderbufferInfo* rb_info4 = |
| 312 renderbuffer_manager_.GetRenderbufferInfo(kRenderbufferClient4Id); | 320 renderbuffer_manager_.GetRenderbufferInfo(kRenderbufferClient4Id); |
| 313 ASSERT_TRUE(rb_info4 != NULL); | 321 ASSERT_TRUE(rb_info4 != NULL); |
| 314 renderbuffer_manager_.SetInfo( | 322 renderbuffer_manager_.SetInfo( |
| 315 rb_info4, kSamples4, kFormat4, kWidth4, kHeight4); | 323 rb_info4, kSamples4, kFormat4, kWidth4, kHeight4); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 const GLuint kTextureService1Id = 333; | 379 const GLuint kTextureService1Id = 333; |
| 372 const GLuint kTextureClient2Id = 34; | 380 const GLuint kTextureClient2Id = 34; |
| 373 const GLuint kTextureService2Id = 334; | 381 const GLuint kTextureService2Id = 334; |
| 374 const GLint kDepth = 1; | 382 const GLint kDepth = 1; |
| 375 const GLint kBorder = 0; | 383 const GLint kBorder = 0; |
| 376 const GLenum kType = GL_UNSIGNED_BYTE; | 384 const GLenum kType = GL_UNSIGNED_BYTE; |
| 377 const GLsizei kWidth1 = 16; | 385 const GLsizei kWidth1 = 16; |
| 378 const GLsizei kHeight1 = 32; | 386 const GLsizei kHeight1 = 32; |
| 379 const GLint kLevel1 = 0; | 387 const GLint kLevel1 = 0; |
| 380 const GLenum kFormat1 = GL_RGBA; | 388 const GLenum kFormat1 = GL_RGBA; |
| 389 const GLenum kBadFormat1 = GL_DEPTH_COMPONENT16; |
| 381 const GLenum kTarget1 = GL_TEXTURE_2D; | 390 const GLenum kTarget1 = GL_TEXTURE_2D; |
| 382 const GLsizei kSamples1 = 0; | 391 const GLsizei kSamples1 = 0; |
| 383 const GLsizei kWidth2 = 16; | 392 const GLsizei kWidth2 = 16; |
| 384 const GLsizei kHeight2 = 32; | 393 const GLsizei kHeight2 = 32; |
| 385 const GLint kLevel2 = 0; | 394 const GLint kLevel2 = 0; |
| 386 const GLenum kFormat2 = GL_RGB; | 395 const GLenum kFormat2 = GL_RGB; |
| 387 const GLenum kTarget2 = GL_TEXTURE_2D; | 396 const GLenum kTarget2 = GL_TEXTURE_2D; |
| 388 const GLsizei kSamples2 = 0; | 397 const GLsizei kSamples2 = 0; |
| 389 const GLsizei kWidth3 = 75; | 398 const GLsizei kWidth3 = 75; |
| 390 const GLsizei kHeight3 = 123; | 399 const GLsizei kHeight3 = 123; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 404 ASSERT_TRUE(tex_info1 != NULL); | 413 ASSERT_TRUE(tex_info1 != NULL); |
| 405 | 414 |
| 406 // check adding one attachment | 415 // check adding one attachment |
| 407 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); | 416 info_->AttachTexture(GL_COLOR_ATTACHMENT0, tex_info1, kTarget1, kLevel1); |
| 408 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); | 417 EXPECT_FALSE(info_->HasUnclearedAttachment(GL_COLOR_ATTACHMENT0)); |
| 409 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), | 418 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
| 410 info_->IsPossiblyComplete()); | 419 info_->IsPossiblyComplete()); |
| 411 EXPECT_TRUE(info_->IsCleared()); | 420 EXPECT_TRUE(info_->IsCleared()); |
| 412 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); | 421 EXPECT_EQ(static_cast<GLenum>(0), info_->GetColorAttachmentFormat()); |
| 413 | 422 |
| 423 // Try format that doesn't work with COLOR_ATTACHMENT0 |
| 414 texture_manager_.SetInfoTarget(tex_info1, GL_TEXTURE_2D); | 424 texture_manager_.SetInfoTarget(tex_info1, GL_TEXTURE_2D); |
| 415 texture_manager_.SetLevelInfo( | 425 texture_manager_.SetLevelInfo( |
| 416 tex_info1, GL_TEXTURE_2D, kLevel1, | 426 tex_info1, GL_TEXTURE_2D, kLevel1, |
| 427 kBadFormat1, kWidth1, kHeight1, kDepth, kBorder, kBadFormat1, kType, |
| 428 true); |
| 429 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT), |
| 430 info_->IsPossiblyComplete()); |
| 431 |
| 432 // Try a good format. |
| 433 texture_manager_.SetLevelInfo( |
| 434 tex_info1, GL_TEXTURE_2D, kLevel1, |
| 417 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false); | 435 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, false); |
| 418 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 436 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 419 info_->IsPossiblyComplete()); | 437 info_->IsPossiblyComplete()); |
| 420 EXPECT_FALSE(info_->IsCleared()); | 438 EXPECT_FALSE(info_->IsCleared()); |
| 421 texture_manager_.SetLevelInfo( | 439 texture_manager_.SetLevelInfo( |
| 422 tex_info1, GL_TEXTURE_2D, kLevel1, | 440 tex_info1, GL_TEXTURE_2D, kLevel1, |
| 423 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true); | 441 kFormat1, kWidth1, kHeight1, kDepth, kBorder, kFormat1, kType, true); |
| 424 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), | 442 EXPECT_EQ(static_cast<GLenum>(GL_FRAMEBUFFER_COMPLETE), |
| 425 info_->IsPossiblyComplete()); | 443 info_->IsPossiblyComplete()); |
| 426 EXPECT_TRUE(info_->IsCleared()); | 444 EXPECT_TRUE(info_->IsCleared()); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 manager_.MarkAsComplete(info_); | 621 manager_.MarkAsComplete(info_); |
| 604 EXPECT_TRUE(manager_.IsComplete(info_)); | 622 EXPECT_TRUE(manager_.IsComplete(info_)); |
| 605 info_->UnbindTexture(kTarget1, tex_info2); | 623 info_->UnbindTexture(kTarget1, tex_info2); |
| 606 EXPECT_FALSE(manager_.IsComplete(info_)); | 624 EXPECT_FALSE(manager_.IsComplete(info_)); |
| 607 } | 625 } |
| 608 | 626 |
| 609 } // namespace gles2 | 627 } // namespace gles2 |
| 610 } // namespace gpu | 628 } // namespace gpu |
| 611 | 629 |
| 612 | 630 |
| OLD | NEW |