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