OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // These tests are run twice: | 5 // These tests are run twice: |
6 // Once in a gpu test with an in-process WebGraphicsContext3D. | 6 // Once in a gpu test with an in-process WebGraphicsContext3D. |
7 // Once in a browsertest with a gpu-process WebGraphicsContext3D. | 7 // Once in a browsertest with a gpu-process WebGraphicsContext3D. |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "gpu/GLES2/gl2extchromium.h" | 11 #include "gpu/GLES2/gl2extchromium.h" |
12 #include "gpu/command_buffer/client/context_support.h" | 12 #include "gpu/command_buffer/client/context_support.h" |
13 #include "gpu/command_buffer/common/sync_token.h" | 13 #include "gpu/command_buffer/common/sync_token.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class SignalTest : public ContextTestBase { | 17 class SignalTest : public ContextTestBase { |
18 public: | 18 public: |
19 static void RunOnlyOnce(base::Closure cb, int* tmp) { | 19 static void RunOnlyOnce(base::Closure cb, int* tmp) { |
20 CHECK_EQ(*tmp, 0); | 20 CHECK_EQ(*tmp, 0); |
21 ++*tmp; | 21 ++*tmp; |
22 cb.Run(); | 22 cb.Run(); |
23 } | 23 } |
24 | 24 |
25 // These tests should time out if the callback doesn't get called. | 25 // These tests should time out if the callback doesn't get called. |
26 void TestSignalSyncToken(const gpu::SyncToken& sync_token) { | 26 void TestSignalSyncPoint(unsigned sync_point) { |
27 base::RunLoop run_loop; | 27 base::RunLoop run_loop; |
28 context_support_->SignalSyncToken(sync_token, run_loop.QuitClosure()); | 28 context_support_->SignalSyncPoint(sync_point, run_loop.QuitClosure()); |
29 run_loop.Run(); | 29 run_loop.Run(); |
30 } | 30 } |
31 | 31 |
32 // These tests should time out if the callback doesn't get called. | 32 // These tests should time out if the callback doesn't get called. |
33 void TestSignalQuery(blink::WebGLId query) { | 33 void TestSignalQuery(blink::WebGLId query) { |
34 base::RunLoop run_loop; | 34 base::RunLoop run_loop; |
35 context_support_->SignalQuery( | 35 context_support_->SignalQuery( |
36 query, | 36 query, |
37 base::Bind( | 37 base::Bind( |
38 &RunOnlyOnce, run_loop.QuitClosure(), base::Owned(new int(0)))); | 38 &RunOnlyOnce, run_loop.QuitClosure(), base::Owned(new int(0)))); |
39 run_loop.Run(); | 39 run_loop.Run(); |
40 } | 40 } |
41 }; | 41 }; |
42 | 42 |
43 CONTEXT_TEST_F(SignalTest, BasicSignalSyncTokenTest) { | 43 CONTEXT_TEST_F(SignalTest, BasicSignalSyncPointTest) { |
44 if (!context_) | 44 if (!context_) |
45 return; | 45 return; |
46 | 46 |
47 const blink::WGC3Duint64 fence_sync = context_->insertFenceSyncCHROMIUM(); | |
48 context_->shallowFlushCHROMIUM(); | |
49 | |
50 gpu::SyncToken sync_token; | 47 gpu::SyncToken sync_token; |
51 ASSERT_TRUE(context_->genSyncTokenCHROMIUM(fence_sync, sync_token.GetData())); | 48 ASSERT_TRUE(context_->insertSyncPoint(sync_token.GetData())); |
52 | 49 TestSignalSyncPoint(static_cast<unsigned>(sync_token.release_count())); |
53 TestSignalSyncToken(sync_token); | |
54 }; | 50 }; |
55 | 51 |
56 CONTEXT_TEST_F(SignalTest, EmptySignalSyncTokenTest) { | 52 CONTEXT_TEST_F(SignalTest, InvalidSignalSyncPointTest) { |
57 if (!context_) | 53 if (!context_) |
58 return; | 54 return; |
59 | 55 |
60 // Signalling something that doesn't exist should run the callback | 56 // Signalling something that doesn't exist should run the callback |
61 // immediately. | 57 // immediately. |
62 gpu::SyncToken sync_token; | 58 TestSignalSyncPoint(1297824234); |
63 TestSignalSyncToken(sync_token); | |
64 }; | |
65 | |
66 CONTEXT_TEST_F(SignalTest, InvalidSignalSyncTokenTest) { | |
67 if (!context_) | |
68 return; | |
69 | |
70 // Signalling something that doesn't exist should run the callback | |
71 // immediately. | |
72 gpu::SyncToken sync_token(gpu::CommandBufferNamespace::GPU_IO, | |
73 1297824234, | |
74 9123743439); | |
75 TestSignalSyncToken(sync_token); | |
76 }; | 59 }; |
77 | 60 |
78 CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) { | 61 CONTEXT_TEST_F(SignalTest, BasicSignalQueryTest) { |
79 if (!context_) | 62 if (!context_) |
80 return; | 63 return; |
81 | 64 |
82 unsigned query = context_->createQueryEXT(); | 65 unsigned query = context_->createQueryEXT(); |
83 context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query); | 66 context_->beginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, query); |
84 context_->finish(); | 67 context_->finish(); |
85 context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); | 68 context_->endQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); |
(...skipping 18 matching lines...) Expand all Loading... |
104 // immediately. | 87 // immediately. |
105 TestSignalQuery(928729087); | 88 TestSignalQuery(928729087); |
106 TestSignalQuery(928729086); | 89 TestSignalQuery(928729086); |
107 TestSignalQuery(928729085); | 90 TestSignalQuery(928729085); |
108 TestSignalQuery(928729083); | 91 TestSignalQuery(928729083); |
109 TestSignalQuery(928729082); | 92 TestSignalQuery(928729082); |
110 TestSignalQuery(928729081); | 93 TestSignalQuery(928729081); |
111 }; | 94 }; |
112 | 95 |
113 }; | 96 }; |
OLD | NEW |