OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
9 #include "gpu/command_buffer/common/gles2_cmd_format.h" | 9 #include "gpu/command_buffer/common/gles2_cmd_format.h" |
10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 10 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 | 384 |
385 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) | 385 EXPECT_CALL(*gl_, DrawArrays(GL_TRIANGLES, 0, kNumVertices)) |
386 .Times(1) | 386 .Times(1) |
387 .RetiresOnSaturation(); | 387 .RetiresOnSaturation(); |
388 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); | 388 EXPECT_EQ(error::kNoError, ExecuteCmd(draw_cmd)); |
389 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 389 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
390 } | 390 } |
391 | 391 |
392 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithDepth) { | 392 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithDepth) { |
393 InitState init; | 393 InitState init; |
394 init.gl_version = "3.0"; | |
395 init.has_depth = true; | 394 init.has_depth = true; |
396 init.request_depth = true; | 395 init.request_depth = true; |
397 init.bind_generates_resource = true; | 396 init.bind_generates_resource = true; |
398 InitDecoder(init); | 397 InitDecoder(init); |
399 | 398 |
400 Enable cmd; | 399 Enable cmd; |
401 cmd.Init(GL_DEPTH_TEST); | 400 cmd.Init(GL_DEPTH_TEST); |
402 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 401 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
403 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 402 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
404 | 403 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); | 436 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); |
438 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 437 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
439 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), | 438 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), |
440 result->GetNumResults()); | 439 result->GetNumResults()); |
441 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 440 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
442 EXPECT_EQ(1, result->GetData()[0]); | 441 EXPECT_EQ(1, result->GetData()[0]); |
443 } | 442 } |
444 | 443 |
445 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) { | 444 TEST_P(GLES2DecoderManualInitTest, DepthEnableWithoutRequestedDepth) { |
446 InitState init; | 445 InitState init; |
447 init.gl_version = "3.0"; | |
448 init.has_depth = true; | 446 init.has_depth = true; |
449 init.bind_generates_resource = true; | 447 init.bind_generates_resource = true; |
450 InitDecoder(init); | 448 InitDecoder(init); |
451 | 449 |
452 Enable cmd; | 450 Enable cmd; |
453 cmd.Init(GL_DEPTH_TEST); | 451 cmd.Init(GL_DEPTH_TEST); |
454 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 452 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
455 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 453 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
456 | 454 |
457 SetupDefaultProgram(); | 455 SetupDefaultProgram(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); | 487 cmd2.Init(GL_DEPTH_TEST, shared_memory_id_, shared_memory_offset_); |
490 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 488 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
491 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), | 489 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_DEPTH_TEST), |
492 result->GetNumResults()); | 490 result->GetNumResults()); |
493 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 491 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
494 EXPECT_EQ(1, result->GetData()[0]); | 492 EXPECT_EQ(1, result->GetData()[0]); |
495 } | 493 } |
496 | 494 |
497 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithStencil) { | 495 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithStencil) { |
498 InitState init; | 496 InitState init; |
499 init.gl_version = "3.0"; | |
500 init.has_stencil = true; | 497 init.has_stencil = true; |
501 init.request_stencil = true; | 498 init.request_stencil = true; |
502 init.bind_generates_resource = true; | 499 init.bind_generates_resource = true; |
503 InitDecoder(init); | 500 InitDecoder(init); |
504 | 501 |
505 Enable cmd; | 502 Enable cmd; |
506 cmd.Init(GL_STENCIL_TEST); | 503 cmd.Init(GL_STENCIL_TEST); |
507 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 504 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
508 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 505 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
509 | 506 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); | 540 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); |
544 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 541 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
545 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), | 542 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), |
546 result->GetNumResults()); | 543 result->GetNumResults()); |
547 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 544 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
548 EXPECT_EQ(1, result->GetData()[0]); | 545 EXPECT_EQ(1, result->GetData()[0]); |
549 } | 546 } |
550 | 547 |
551 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) { | 548 TEST_P(GLES2DecoderManualInitTest, StencilEnableWithoutRequestedStencil) { |
552 InitState init; | 549 InitState init; |
553 init.gl_version = "3.0"; | |
554 init.has_stencil = true; | 550 init.has_stencil = true; |
555 init.bind_generates_resource = true; | 551 init.bind_generates_resource = true; |
556 InitDecoder(init); | 552 InitDecoder(init); |
557 | 553 |
558 Enable cmd; | 554 Enable cmd; |
559 cmd.Init(GL_STENCIL_TEST); | 555 cmd.Init(GL_STENCIL_TEST); |
560 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 556 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
561 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 557 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
562 | 558 |
563 SetupDefaultProgram(); | 559 SetupDefaultProgram(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); | 591 cmd2.Init(GL_STENCIL_TEST, shared_memory_id_, shared_memory_offset_); |
596 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); | 592 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd2)); |
597 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), | 593 EXPECT_EQ(decoder_->GetGLES2Util()->GLGetNumValuesReturned(GL_STENCIL_TEST), |
598 result->GetNumResults()); | 594 result->GetNumResults()); |
599 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 595 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
600 EXPECT_EQ(1, result->GetData()[0]); | 596 EXPECT_EQ(1, result->GetData()[0]); |
601 } | 597 } |
602 | 598 |
603 TEST_P(GLES2DecoderManualInitTest, CachedColorMask) { | 599 TEST_P(GLES2DecoderManualInitTest, CachedColorMask) { |
604 InitState init; | 600 InitState init; |
605 init.gl_version = "3.0"; | |
606 init.has_alpha = true; | 601 init.has_alpha = true; |
607 init.has_depth = true; | 602 init.has_depth = true; |
608 init.has_stencil = true; | 603 init.has_stencil = true; |
609 init.request_alpha = true; | 604 init.request_alpha = true; |
610 init.request_depth = true; | 605 init.request_depth = true; |
611 init.request_stencil = true; | 606 init.request_stencil = true; |
612 init.bind_generates_resource = true; | 607 init.bind_generates_resource = true; |
613 InitDecoder(init); | 608 InitDecoder(init); |
614 | 609 |
615 SetupDefaultProgram(); | 610 SetupDefaultProgram(); |
616 SetupAllNeededVertexBuffers(); | 611 SetupAllNeededVertexBuffers(); |
617 SetupTexture(); | 612 SetupTexture(); |
618 | 613 |
619 // Test all color_bits combinations twice. | 614 // Test all color_bits combinations twice. |
620 for (int i = 0; i < 32; i++) { | 615 for (int i = 0; i < 32; i++) { |
621 GLuint color_bits = (i & 1 ? 0x0001 : 0x0000) | (i & 2 ? 0x0010 : 0x0000) | | 616 GLuint color_bits = (i & 1 ? 0x0001 : 0x0000) | (i & 2 ? 0x0010 : 0x0000) | |
622 (i & 4 ? 0x0100 : 0x0000) | (i & 8 ? 0x1000 : 0x0000); | 617 (i & 4 ? 0x0100 : 0x0000) | (i & 8 ? 0x1000 : 0x0000); |
623 | 618 |
624 // Toggle depth_test to force ApplyDirtyState each time. | 619 // Toggle depth_test to force ApplyDirtyState each time. |
625 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff); | 620 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff); |
626 DirtyStateMaskTest(color_bits, true, 0xffffffff, 0xffffffff); | 621 DirtyStateMaskTest(color_bits, true, 0xffffffff, 0xffffffff); |
627 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff); | 622 DirtyStateMaskTest(color_bits, false, 0xffffffff, 0xffffffff); |
628 } | 623 } |
629 } | 624 } |
630 | 625 |
631 TEST_P(GLES2DecoderManualInitTest, CachedDepthMask) { | 626 TEST_P(GLES2DecoderManualInitTest, CachedDepthMask) { |
632 InitState init; | 627 InitState init; |
633 init.gl_version = "3.0"; | |
634 init.has_alpha = true; | 628 init.has_alpha = true; |
635 init.has_depth = true; | 629 init.has_depth = true; |
636 init.has_stencil = true; | 630 init.has_stencil = true; |
637 init.request_alpha = true; | 631 init.request_alpha = true; |
638 init.request_depth = true; | 632 init.request_depth = true; |
639 init.request_stencil = true; | 633 init.request_stencil = true; |
640 init.bind_generates_resource = true; | 634 init.bind_generates_resource = true; |
641 InitDecoder(init); | 635 InitDecoder(init); |
642 | 636 |
643 SetupDefaultProgram(); | 637 SetupDefaultProgram(); |
644 SetupAllNeededVertexBuffers(); | 638 SetupAllNeededVertexBuffers(); |
645 SetupTexture(); | 639 SetupTexture(); |
646 | 640 |
647 // Test all depth_mask combinations twice. | 641 // Test all depth_mask combinations twice. |
648 for (int i = 0; i < 4; i++) { | 642 for (int i = 0; i < 4; i++) { |
649 bool depth_mask = (i & 1) == 1; | 643 bool depth_mask = (i & 1) == 1; |
650 | 644 |
651 // Toggle color masks to force ApplyDirtyState each time. | 645 // Toggle color masks to force ApplyDirtyState each time. |
652 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff); | 646 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff); |
653 DirtyStateMaskTest(0x0101, depth_mask, 0xffffffff, 0xffffffff); | 647 DirtyStateMaskTest(0x0101, depth_mask, 0xffffffff, 0xffffffff); |
654 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff); | 648 DirtyStateMaskTest(0x1010, depth_mask, 0xffffffff, 0xffffffff); |
655 } | 649 } |
656 } | 650 } |
657 | 651 |
658 TEST_P(GLES2DecoderManualInitTest, CachedStencilMask) { | 652 TEST_P(GLES2DecoderManualInitTest, CachedStencilMask) { |
659 InitState init; | 653 InitState init; |
660 init.gl_version = "3.0"; | |
661 init.has_alpha = true; | 654 init.has_alpha = true; |
662 init.has_depth = true; | 655 init.has_depth = true; |
663 init.has_stencil = true; | 656 init.has_stencil = true; |
664 init.request_alpha = true; | 657 init.request_alpha = true; |
665 init.request_depth = true; | 658 init.request_depth = true; |
666 init.request_stencil = true; | 659 init.request_stencil = true; |
667 init.bind_generates_resource = true; | 660 init.bind_generates_resource = true; |
668 InitDecoder(init); | 661 InitDecoder(init); |
669 | 662 |
670 SetupDefaultProgram(); | 663 SetupDefaultProgram(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
739 DrawArrays cmd; | 732 DrawArrays cmd; |
740 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); | 733 cmd.Init(GL_TRIANGLES, 0, kFakeLargeCount); |
741 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 734 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
742 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); | 735 EXPECT_EQ(GL_OUT_OF_MEMORY, GetGLError()); |
743 EXPECT_FALSE(GetDecoder()->WasContextLost()); | 736 EXPECT_FALSE(GetDecoder()->WasContextLost()); |
744 } | 737 } |
745 | 738 |
746 // Test that we lose context. | 739 // Test that we lose context. |
747 TEST_P(GLES2DecoderManualInitTest, LoseContextWhenOOM) { | 740 TEST_P(GLES2DecoderManualInitTest, LoseContextWhenOOM) { |
748 InitState init; | 741 InitState init; |
749 init.gl_version = "3.0"; | |
750 init.has_alpha = true; | 742 init.has_alpha = true; |
751 init.has_depth = true; | 743 init.has_depth = true; |
752 init.request_alpha = true; | 744 init.request_alpha = true; |
753 init.request_depth = true; | 745 init.request_depth = true; |
754 init.bind_generates_resource = true; | 746 init.bind_generates_resource = true; |
755 init.lose_context_when_out_of_memory = true; | 747 init.lose_context_when_out_of_memory = true; |
756 InitDecoder(init); | 748 InitDecoder(init); |
757 SetupDefaultProgram(); | 749 SetupDefaultProgram(); |
758 | 750 |
759 const GLsizei kFakeLargeCount = 0x1234; | 751 const GLsizei kFakeLargeCount = 0x1234; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 } | 848 } |
857 | 849 |
858 // Same as DrawArraysValidAttributesSucceeds, but with workaround | 850 // Same as DrawArraysValidAttributesSucceeds, but with workaround |
859 // |init_vertex_attributes|. | 851 // |init_vertex_attributes|. |
860 TEST_P(GLES2DecoderManualInitTest, InitVertexAttributes) { | 852 TEST_P(GLES2DecoderManualInitTest, InitVertexAttributes) { |
861 base::CommandLine command_line(0, NULL); | 853 base::CommandLine command_line(0, NULL); |
862 command_line.AppendSwitchASCII( | 854 command_line.AppendSwitchASCII( |
863 switches::kGpuDriverBugWorkarounds, | 855 switches::kGpuDriverBugWorkarounds, |
864 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES)); | 856 base::IntToString(gpu::INIT_VERTEX_ATTRIBUTES)); |
865 InitState init; | 857 InitState init; |
866 init.gl_version = "3.0"; | |
867 init.has_alpha = true; | 858 init.has_alpha = true; |
868 init.has_depth = true; | 859 init.has_depth = true; |
869 init.request_alpha = true; | 860 init.request_alpha = true; |
870 init.request_depth = true; | 861 init.request_depth = true; |
871 init.bind_generates_resource = true; | 862 init.bind_generates_resource = true; |
872 InitDecoderWithCommandLine(init, &command_line); | 863 InitDecoderWithCommandLine(init, &command_line); |
873 SetupDefaultProgram(); | 864 SetupDefaultProgram(); |
874 SetupTexture(); | 865 SetupTexture(); |
875 SetupVertexBuffer(); | 866 SetupVertexBuffer(); |
876 DoEnableVertexAttribArray(1); | 867 DoEnableVertexAttribArray(1); |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2387 .Times(1) | 2378 .Times(1) |
2388 .RetiresOnSaturation(); | 2379 .RetiresOnSaturation(); |
2389 DrawArrays cmd; | 2380 DrawArrays cmd; |
2390 cmd.Init(GL_TRIANGLES, 0, kNumVertices); | 2381 cmd.Init(GL_TRIANGLES, 0, kNumVertices); |
2391 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); | 2382 EXPECT_EQ(error::kNoError, ExecuteCmd(cmd)); |
2392 EXPECT_EQ(GL_NO_ERROR, GetGLError()); | 2383 EXPECT_EQ(GL_NO_ERROR, GetGLError()); |
2393 } | 2384 } |
2394 | 2385 |
2395 } // namespace gles2 | 2386 } // namespace gles2 |
2396 } // namespace gpu | 2387 } // namespace gpu |
OLD | NEW |