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 // Tests for GLES2Implementation. | 5 // Tests for GLES2Implementation. |
6 | 6 |
7 #include "gpu/command_buffer/client/gles2_implementation.h" | 7 #include "gpu/command_buffer/client/gles2_implementation.h" |
8 | 8 |
9 #include <GLES2/gl2ext.h> | 9 #include <GLES2/gl2ext.h> |
10 #include <GLES2/gl2extchromium.h> | 10 #include <GLES2/gl2extchromium.h> |
(...skipping 2663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2674 // Test BeginQueryEXT inserts command. | 2674 // Test BeginQueryEXT inserts command. |
2675 struct BeginCmds { | 2675 struct BeginCmds { |
2676 cmds::BeginQueryEXT begin_query; | 2676 cmds::BeginQueryEXT begin_query; |
2677 }; | 2677 }; |
2678 BeginCmds expected_begin_cmds; | 2678 BeginCmds expected_begin_cmds; |
2679 const void* commands = GetPut(); | 2679 const void* commands = GetPut(); |
2680 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); | 2680 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); |
2681 QueryTracker::Query* query = GetQuery(id1); | 2681 QueryTracker::Query* query = GetQuery(id1); |
2682 ASSERT_TRUE(query != NULL); | 2682 ASSERT_TRUE(query != NULL); |
2683 expected_begin_cmds.begin_query.Init( | 2683 expected_begin_cmds.begin_query.Init( |
2684 GL_ANY_SAMPLES_PASSED_EXT, id1, query->shm_id(), query->shm_offset()); | 2684 GL_ANY_SAMPLES_PASSED_EXT, |
| 2685 id1, |
| 2686 query->internal(), |
| 2687 query->shm_id(), |
| 2688 query->shm_offset()); |
2685 EXPECT_EQ(0, memcmp( | 2689 EXPECT_EQ(0, memcmp( |
2686 &expected_begin_cmds, commands, sizeof(expected_begin_cmds))); | 2690 &expected_begin_cmds, commands, sizeof(expected_begin_cmds))); |
2687 ClearCommands(); | 2691 ClearCommands(); |
2688 | 2692 |
2689 // Test GetQueryivEXT returns id. | 2693 // Test GetQueryivEXT returns id. |
2690 param = -1; | 2694 param = -1; |
2691 gl_->GetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, ¶m); | 2695 gl_->GetQueryivEXT(GL_ANY_SAMPLES_PASSED_EXT, GL_CURRENT_QUERY_EXT, ¶m); |
2692 EXPECT_EQ(id1, static_cast<GLuint>(param)); | 2696 EXPECT_EQ(id1, static_cast<GLuint>(param)); |
2693 gl_->GetQueryivEXT( | 2697 gl_->GetQueryivEXT( |
2694 GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, GL_CURRENT_QUERY_EXT, ¶m); | 2698 GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, GL_CURRENT_QUERY_EXT, ¶m); |
2695 EXPECT_EQ(0, param); | 2699 EXPECT_EQ(0, param); |
2696 | 2700 |
2697 // Test BeginQueryEXT fails if between Begin/End. | 2701 // Test BeginQueryEXT fails if between Begin/End. |
2698 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id2); | 2702 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id2); |
2699 EXPECT_TRUE(NoCommandsWritten()); | 2703 EXPECT_TRUE(NoCommandsWritten()); |
2700 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2704 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
2701 | 2705 |
2702 // Test EndQueryEXT fails if target not same as current query. | 2706 // Test EndQueryEXT fails if target not same as current query. |
2703 ClearCommands(); | 2707 ClearCommands(); |
2704 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); | 2708 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT); |
2705 EXPECT_TRUE(NoCommandsWritten()); | 2709 EXPECT_TRUE(NoCommandsWritten()); |
2706 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2710 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
2707 | 2711 |
2708 // Test EndQueryEXT sends command | 2712 // Test EndQueryEXT sends command |
2709 struct EndCmds { | 2713 struct EndCmds { |
2710 cmds::EndQueryEXT end_query; | 2714 cmds::EndQueryEXT end_query; |
2711 }; | 2715 }; |
2712 EndCmds expected_end_cmds; | 2716 EndCmds expected_end_cmds; |
2713 expected_end_cmds.end_query.Init( | 2717 expected_end_cmds.end_query.Init( |
2714 GL_ANY_SAMPLES_PASSED_EXT, query->submit_count()); | 2718 GL_ANY_SAMPLES_PASSED_EXT, query->internal(), query->submit_count()); |
2715 commands = GetPut(); | 2719 commands = GetPut(); |
2716 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); | 2720 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); |
2717 EXPECT_EQ(0, memcmp( | 2721 EXPECT_EQ(0, memcmp( |
2718 &expected_end_cmds, commands, sizeof(expected_end_cmds))); | 2722 &expected_end_cmds, commands, sizeof(expected_end_cmds))); |
2719 | 2723 |
2720 // Test EndQueryEXT fails if no current query. | 2724 // Test EndQueryEXT fails if no current query. |
2721 ClearCommands(); | 2725 ClearCommands(); |
2722 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); | 2726 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); |
2723 EXPECT_TRUE(NoCommandsWritten()); | 2727 EXPECT_TRUE(NoCommandsWritten()); |
2724 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2728 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
2725 | 2729 |
2726 // Test 2nd Begin/End increments count. | 2730 // Test 2nd Begin/End increments count. |
2727 uint32 old_submit_count = query->submit_count(); | 2731 uint32 old_submit_count = query->submit_count(); |
2728 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); | 2732 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_EXT, id1); |
2729 EXPECT_NE(old_submit_count, query->submit_count()); | 2733 EXPECT_NE(old_submit_count, query->submit_count()); |
2730 expected_end_cmds.end_query.Init( | 2734 expected_end_cmds.end_query.Init( |
2731 GL_ANY_SAMPLES_PASSED_EXT, query->submit_count()); | 2735 GL_ANY_SAMPLES_PASSED_EXT, query->internal(), query->submit_count()); |
2732 commands = GetPut(); | 2736 commands = GetPut(); |
2733 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); | 2737 gl_->EndQueryEXT(GL_ANY_SAMPLES_PASSED_EXT); |
2734 EXPECT_EQ(0, memcmp( | 2738 EXPECT_EQ(0, memcmp( |
2735 &expected_end_cmds, commands, sizeof(expected_end_cmds))); | 2739 &expected_end_cmds, commands, sizeof(expected_end_cmds))); |
2736 | 2740 |
2737 // Test BeginQueryEXT fails if target changed. | 2741 // Test BeginQueryEXT fails if target changed. |
2738 ClearCommands(); | 2742 ClearCommands(); |
2739 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, id1); | 2743 gl_->BeginQueryEXT(GL_ANY_SAMPLES_PASSED_CONSERVATIVE_EXT, id1); |
2740 EXPECT_TRUE(NoCommandsWritten()); | 2744 EXPECT_TRUE(NoCommandsWritten()); |
2741 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); | 2745 EXPECT_EQ(GL_INVALID_OPERATION, CheckError()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2773 QueryTracker::Query* query = GetQuery(id); | 2777 QueryTracker::Query* query = GetQuery(id); |
2774 ASSERT_TRUE(query != NULL); | 2778 ASSERT_TRUE(query != NULL); |
2775 | 2779 |
2776 // Test EndQueryEXT sends both begin and end command | 2780 // Test EndQueryEXT sends both begin and end command |
2777 struct EndCmds { | 2781 struct EndCmds { |
2778 cmds::BeginQueryEXT begin_query; | 2782 cmds::BeginQueryEXT begin_query; |
2779 cmds::EndQueryEXT end_query; | 2783 cmds::EndQueryEXT end_query; |
2780 }; | 2784 }; |
2781 EndCmds expected_end_cmds; | 2785 EndCmds expected_end_cmds; |
2782 expected_end_cmds.begin_query.Init( | 2786 expected_end_cmds.begin_query.Init( |
2783 GL_GET_ERROR_QUERY_CHROMIUM, id, query->shm_id(), query->shm_offset()); | 2787 GL_GET_ERROR_QUERY_CHROMIUM, |
| 2788 id, |
| 2789 query->internal(), |
| 2790 query->shm_id(), |
| 2791 query->shm_offset()); |
2784 expected_end_cmds.end_query.Init( | 2792 expected_end_cmds.end_query.Init( |
2785 GL_GET_ERROR_QUERY_CHROMIUM, query->submit_count()); | 2793 GL_GET_ERROR_QUERY_CHROMIUM, query->internal(), query->submit_count()); |
2786 const void* commands = GetPut(); | 2794 const void* commands = GetPut(); |
2787 gl_->EndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); | 2795 gl_->EndQueryEXT(GL_GET_ERROR_QUERY_CHROMIUM); |
2788 EXPECT_EQ(0, memcmp( | 2796 EXPECT_EQ(0, memcmp( |
2789 &expected_end_cmds, commands, sizeof(expected_end_cmds))); | 2797 &expected_end_cmds, commands, sizeof(expected_end_cmds))); |
2790 ClearCommands(); | 2798 ClearCommands(); |
2791 | 2799 |
2792 // Check result is not yet available. | 2800 // Check result is not yet available. |
2793 GLuint available = 0xBDu; | 2801 GLuint available = 0xBDu; |
2794 gl_->GetQueryObjectuivEXT(id, GL_QUERY_RESULT_AVAILABLE_EXT, &available); | 2802 gl_->GetQueryObjectuivEXT(id, GL_QUERY_RESULT_AVAILABLE_EXT, &available); |
2795 EXPECT_TRUE(NoCommandsWritten()); | 2803 EXPECT_TRUE(NoCommandsWritten()); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2871 ClearCommands(); | 2879 ClearCommands(); |
2872 gl_->Enable(GL_BLEND); | 2880 gl_->Enable(GL_BLEND); |
2873 EXPECT_TRUE(NoCommandsWritten()); | 2881 EXPECT_TRUE(NoCommandsWritten()); |
2874 } | 2882 } |
2875 | 2883 |
2876 | 2884 |
2877 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" | 2885 #include "gpu/command_buffer/client/gles2_implementation_unittest_autogen.h" |
2878 | 2886 |
2879 } // namespace gles2 | 2887 } // namespace gles2 |
2880 } // namespace gpu | 2888 } // namespace gpu |
OLD | NEW |