| 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/test_helper.h" | 5 #include "gpu/command_buffer/service/test_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 336 |
| 337 void TestHelper::SetupContextGroupInitExpectations( | 337 void TestHelper::SetupContextGroupInitExpectations( |
| 338 ::gl::MockGLInterface* gl, | 338 ::gl::MockGLInterface* gl, |
| 339 const DisallowedFeatures& disallowed_features, | 339 const DisallowedFeatures& disallowed_features, |
| 340 const char* extensions, | 340 const char* extensions, |
| 341 const char* gl_version, | 341 const char* gl_version, |
| 342 ContextType context_type, | 342 ContextType context_type, |
| 343 bool bind_generates_resource) { | 343 bool bind_generates_resource) { |
| 344 InSequence sequence; | 344 InSequence sequence; |
| 345 | 345 |
| 346 bool enable_es3 = !(context_type == CONTEXT_TYPE_OPENGLES2 || |
| 347 context_type == CONTEXT_TYPE_WEBGL1); |
| 348 |
| 346 gl::GLVersionInfo gl_info(gl_version, "", extensions); | 349 gl::GLVersionInfo gl_info(gl_version, "", extensions); |
| 347 | 350 |
| 348 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version, | 351 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", gl_version, |
| 349 context_type, | 352 context_type); |
| 350 context_type == CONTEXT_TYPE_WEBGL2 || | |
| 351 context_type == CONTEXT_TYPE_OPENGLES3); | |
| 352 | |
| 353 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) | 353 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_RENDERBUFFER_SIZE, _)) |
| 354 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) | 354 .WillOnce(SetArgumentPointee<1>(kMaxRenderbufferSize)) |
| 355 .RetiresOnSaturation(); | 355 .RetiresOnSaturation(); |
| 356 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || | 356 if (strstr(extensions, "GL_EXT_framebuffer_multisample") || |
| 357 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || | 357 strstr(extensions, "GL_EXT_multisampled_render_to_texture") || |
| 358 gl_info.is_es3 || gl_info.is_desktop_core_profile) { | 358 gl_info.is_es3 || gl_info.is_desktop_core_profile) { |
| 359 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) | 359 EXPECT_CALL(*gl, GetIntegerv(GL_MAX_SAMPLES, _)) |
| 360 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) | 360 .WillOnce(SetArgumentPointee<1>(kMaxSamples)) |
| 361 .RetiresOnSaturation(); | 361 .RetiresOnSaturation(); |
| 362 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { | 362 } else if (strstr(extensions, "GL_IMG_multisampled_render_to_texture")) { |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 .Times(testing::Between(0, 1)) | 467 .Times(testing::Between(0, 1)) |
| 468 .WillRepeatedly(SetArgumentPointee<1>(kMaxProgramTexelOffset)) | 468 .WillRepeatedly(SetArgumentPointee<1>(kMaxProgramTexelOffset)) |
| 469 .RetiresOnSaturation(); | 469 .RetiresOnSaturation(); |
| 470 EXPECT_CALL(*gl, GetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, _)) | 470 EXPECT_CALL(*gl, GetIntegerv(GL_MIN_PROGRAM_TEXEL_OFFSET, _)) |
| 471 .Times(testing::Between(0, 1)) | 471 .Times(testing::Between(0, 1)) |
| 472 .WillRepeatedly(SetArgumentPointee<1>(kMinProgramTexelOffset)) | 472 .WillRepeatedly(SetArgumentPointee<1>(kMinProgramTexelOffset)) |
| 473 .RetiresOnSaturation(); | 473 .RetiresOnSaturation(); |
| 474 | 474 |
| 475 bool use_default_textures = bind_generates_resource; | 475 bool use_default_textures = bind_generates_resource; |
| 476 SetupTextureManagerInitExpectations( | 476 SetupTextureManagerInitExpectations( |
| 477 gl, false, gl_info.is_es3_capable, gl_info.is_desktop_core_profile, | 477 gl, enable_es3, gl_info.is_es3_capable, gl_info.is_desktop_core_profile, |
| 478 extensions, use_default_textures); | 478 extensions, use_default_textures); |
| 479 } | 479 } |
| 480 | 480 |
| 481 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl, | 481 void TestHelper::SetupFeatureInfoInitExpectations(::gl::MockGLInterface* gl, |
| 482 const char* extensions) { | 482 const char* extensions) { |
| 483 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", "", | 483 SetupFeatureInfoInitExpectationsWithGLVersion(gl, extensions, "", "", |
| 484 CONTEXT_TYPE_OPENGLES2); | 484 CONTEXT_TYPE_OPENGLES2); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( | 487 void TestHelper::SetupFeatureInfoInitExpectationsWithGLVersion( |
| 488 ::gl::MockGLInterface* gl, | 488 ::gl::MockGLInterface* gl, |
| 489 const char* extensions, | 489 const char* extensions, |
| 490 const char* gl_renderer, | 490 const char* gl_renderer, |
| 491 const char* gl_version, | 491 const char* gl_version, |
| 492 ContextType context_type, | 492 ContextType context_type) { |
| 493 bool enable_es3) { | |
| 494 InSequence sequence; | 493 InSequence sequence; |
| 495 | 494 |
| 495 bool enable_es3 = context_type == CONTEXT_TYPE_WEBGL2 || |
| 496 context_type == CONTEXT_TYPE_OPENGLES3; |
| 497 |
| 496 EXPECT_CALL(*gl, GetString(GL_VERSION)) | 498 EXPECT_CALL(*gl, GetString(GL_VERSION)) |
| 497 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) | 499 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) |
| 498 .RetiresOnSaturation(); | 500 .RetiresOnSaturation(); |
| 499 | 501 |
| 500 // Persistent storage is needed for the split extension string. | 502 // Persistent storage is needed for the split extension string. |
| 501 split_extensions_.clear(); | 503 split_extensions_.clear(); |
| 502 if (extensions) { | 504 if (extensions) { |
| 503 split_extensions_ = base::SplitString( | 505 split_extensions_ = base::SplitString( |
| 504 extensions, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 506 extensions, " ", base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 505 } | 507 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 521 .RetiresOnSaturation(); | 523 .RetiresOnSaturation(); |
| 522 } | 524 } |
| 523 | 525 |
| 524 EXPECT_CALL(*gl, GetString(GL_VERSION)) | 526 EXPECT_CALL(*gl, GetString(GL_VERSION)) |
| 525 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) | 527 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_version))) |
| 526 .RetiresOnSaturation(); | 528 .RetiresOnSaturation(); |
| 527 EXPECT_CALL(*gl, GetString(GL_RENDERER)) | 529 EXPECT_CALL(*gl, GetString(GL_RENDERER)) |
| 528 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer))) | 530 .WillOnce(Return(reinterpret_cast<const uint8_t*>(gl_renderer))) |
| 529 .RetiresOnSaturation(); | 531 .RetiresOnSaturation(); |
| 530 | 532 |
| 531 if (!(context_type == CONTEXT_TYPE_WEBGL1 || | 533 if (enable_es3) { |
| 532 context_type == CONTEXT_TYPE_OPENGLES2) && | |
| 533 gl_info.is_es3_capable && enable_es3) { | |
| 534 EXPECT_CALL(*gl, GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, _)) | 534 EXPECT_CALL(*gl, GetIntegerv(GL_PIXEL_UNPACK_BUFFER_BINDING, _)) |
| 535 .WillOnce(SetArgPointee<1>(0)) | 535 .WillOnce(SetArgPointee<1>(0)) |
| 536 .RetiresOnSaturation(); | 536 .RetiresOnSaturation(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 if ((strstr(extensions, "GL_ARB_texture_float") || | 539 if ((strstr(extensions, "GL_ARB_texture_float") || |
| 540 gl_info.is_desktop_core_profile) || | 540 gl_info.is_desktop_core_profile) || |
| 541 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { | 541 (gl_info.is_es3 && strstr(extensions, "GL_EXT_color_buffer_float"))) { |
| 542 static const GLuint tx_ids[] = {101, 102}; | 542 static const GLuint tx_ids[] = {101, 102}; |
| 543 static const GLuint fb_ids[] = {103, 104}; | 543 static const GLuint fb_ids[] = {103, 104}; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 .Times(1) | 580 .Times(1) |
| 581 .RetiresOnSaturation(); | 581 .RetiresOnSaturation(); |
| 582 if (gl_info.is_es3) { | 582 if (gl_info.is_es3) { |
| 583 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 583 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 584 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) | 584 .WillOnce(Return(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT)) |
| 585 .RetiresOnSaturation(); | 585 .RetiresOnSaturation(); |
| 586 } else { | 586 } else { |
| 587 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 587 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 588 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) | 588 .WillOnce(Return(GL_FRAMEBUFFER_COMPLETE)) |
| 589 .RetiresOnSaturation(); | 589 .RetiresOnSaturation(); |
| 590 } |
| 590 | 591 |
| 591 if (enable_es3 && gl_info.is_es3_capable) { | 592 if (enable_es3) { |
| 592 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, | 593 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, |
| 593 0, GL_RED, GL_FLOAT, _)) | 594 0, GL_RED, GL_FLOAT, _)) |
| 594 .Times(1) | 595 .Times(1) |
| 595 .RetiresOnSaturation(); | 596 .RetiresOnSaturation(); |
| 596 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 597 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 597 .Times(1) | 598 .Times(1) |
| 598 .RetiresOnSaturation(); | 599 .RetiresOnSaturation(); |
| 599 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, | 600 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, |
| 600 0, GL_RG, GL_FLOAT, _)) | 601 0, GL_RG, GL_FLOAT, _)) |
| 601 .Times(1) | 602 .Times(1) |
| 602 .RetiresOnSaturation(); | 603 .RetiresOnSaturation(); |
| 603 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 604 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 604 .Times(1) | 605 .Times(1) |
| 605 .RetiresOnSaturation(); | 606 .RetiresOnSaturation(); |
| 606 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width, | 607 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width, |
| 607 0, GL_RGBA, GL_FLOAT, _)) | 608 0, GL_RGBA, GL_FLOAT, _)) |
| 608 .Times(1) | 609 .Times(1) |
| 609 .RetiresOnSaturation(); | 610 .RetiresOnSaturation(); |
| 610 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 611 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 611 .Times(1) | 612 .Times(1) |
| 612 .RetiresOnSaturation(); | 613 .RetiresOnSaturation(); |
| 613 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, width, | 614 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, width, |
| 614 0, GL_RED, GL_FLOAT, _)) | 615 0, GL_RED, GL_FLOAT, _)) |
| 615 .Times(1) | 616 .Times(1) |
| 616 .RetiresOnSaturation(); | 617 .RetiresOnSaturation(); |
| 617 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 618 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 618 .Times(1) | 619 .Times(1) |
| 619 .RetiresOnSaturation(); | 620 .RetiresOnSaturation(); |
| 620 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, width, width, | 621 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, width, width, |
| 621 0, GL_RG, GL_FLOAT, _)) | 622 0, GL_RG, GL_FLOAT, _)) |
| 622 .Times(1) | 623 .Times(1) |
| 623 .RetiresOnSaturation(); | 624 .RetiresOnSaturation(); |
| 624 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 625 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 625 .Times(1) | 626 .Times(1) |
| 626 .RetiresOnSaturation(); | 627 .RetiresOnSaturation(); |
| 627 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, | 628 EXPECT_CALL(*gl, TexImage2D(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, |
| 628 width, width, 0, GL_RGB, GL_FLOAT, _)) | 629 width, width, 0, GL_RGB, GL_FLOAT, _)) |
| 629 .Times(1) | 630 .Times(1) |
| 630 .RetiresOnSaturation(); | 631 .RetiresOnSaturation(); |
| 631 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) | 632 EXPECT_CALL(*gl, CheckFramebufferStatusEXT(GL_FRAMEBUFFER)) |
| 632 .Times(1) | 633 .Times(1) |
| 633 .RetiresOnSaturation(); | 634 .RetiresOnSaturation(); |
| 634 } | |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _)) | 638 EXPECT_CALL(*gl, DeleteFramebuffersEXT(1, _)) |
| 639 .Times(1) | 639 .Times(1) |
| 640 .RetiresOnSaturation(); | 640 .RetiresOnSaturation(); |
| 641 EXPECT_CALL(*gl, DeleteTextures(1, _)) | 641 EXPECT_CALL(*gl, DeleteTextures(1, _)) |
| 642 .Times(1) | 642 .Times(1) |
| 643 .RetiresOnSaturation(); | 643 .RetiresOnSaturation(); |
| 644 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[0])) | 644 EXPECT_CALL(*gl, BindFramebufferEXT(GL_FRAMEBUFFER, fb_ids[0])) |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 GLenum precision, | 1202 GLenum precision, |
| 1203 bool static_use, | 1203 bool static_use, |
| 1204 const std::string& name) { | 1204 const std::string& name) { |
| 1205 return ConstructShaderVariable<sh::OutputVariable>( | 1205 return ConstructShaderVariable<sh::OutputVariable>( |
| 1206 type, array_size, precision, static_use, name); | 1206 type, array_size, precision, static_use, name); |
| 1207 } | 1207 } |
| 1208 | 1208 |
| 1209 } // namespace gles2 | 1209 } // namespace gles2 |
| 1210 } // namespace gpu | 1210 } // namespace gpu |
| 1211 | 1211 |
| OLD | NEW |