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 the Command Buffer Helper. | 5 // Tests for the Command Buffer Helper. |
6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
7 #include <list> | 10 #include <list> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/macros.h" |
11 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
12 #include "gpu/command_buffer/client/cmd_buffer_helper.h" | 16 #include "gpu/command_buffer/client/cmd_buffer_helper.h" |
13 #include "gpu/command_buffer/service/command_buffer_service.h" | 17 #include "gpu/command_buffer/service/command_buffer_service.h" |
14 #include "gpu/command_buffer/service/gpu_scheduler.h" | 18 #include "gpu/command_buffer/service/gpu_scheduler.h" |
15 #include "gpu/command_buffer/service/mocks.h" | 19 #include "gpu/command_buffer/service/mocks.h" |
16 #include "gpu/command_buffer/service/transfer_buffer_manager.h" | 20 #include "gpu/command_buffer/service/transfer_buffer_manager.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
18 | 22 |
19 namespace gpu { | 23 namespace gpu { |
20 | 24 |
21 using testing::Return; | 25 using testing::Return; |
22 using testing::Mock; | 26 using testing::Mock; |
23 using testing::Truly; | 27 using testing::Truly; |
24 using testing::Sequence; | 28 using testing::Sequence; |
25 using testing::DoAll; | 29 using testing::DoAll; |
26 using testing::Invoke; | 30 using testing::Invoke; |
27 using testing::_; | 31 using testing::_; |
28 | 32 |
29 const int32 kTotalNumCommandEntries = 32; | 33 const int32_t kTotalNumCommandEntries = 32; |
30 const int32 kCommandBufferSizeBytes = | 34 const int32_t kCommandBufferSizeBytes = |
31 kTotalNumCommandEntries * sizeof(CommandBufferEntry); | 35 kTotalNumCommandEntries * sizeof(CommandBufferEntry); |
32 const int32 kUnusedCommandId = 5; // we use 0 and 2 currently. | 36 const int32_t kUnusedCommandId = 5; // we use 0 and 2 currently. |
33 | 37 |
34 // Override CommandBufferService::Flush() to lock flushing and simulate | 38 // Override CommandBufferService::Flush() to lock flushing and simulate |
35 // the buffer becoming full in asynchronous mode. | 39 // the buffer becoming full in asynchronous mode. |
36 class CommandBufferServiceLocked : public CommandBufferService { | 40 class CommandBufferServiceLocked : public CommandBufferService { |
37 public: | 41 public: |
38 explicit CommandBufferServiceLocked( | 42 explicit CommandBufferServiceLocked( |
39 TransferBufferManagerInterface* transfer_buffer_manager) | 43 TransferBufferManagerInterface* transfer_buffer_manager) |
40 : CommandBufferService(transfer_buffer_manager), | 44 : CommandBufferService(transfer_buffer_manager), |
41 flush_locked_(false), | 45 flush_locked_(false), |
42 last_flush_(-1), | 46 last_flush_(-1), |
43 previous_put_offset_(0), | 47 previous_put_offset_(0), |
44 flush_count_(0) {} | 48 flush_count_(0) {} |
45 ~CommandBufferServiceLocked() override {} | 49 ~CommandBufferServiceLocked() override {} |
46 | 50 |
47 // Overridden from CommandBufferService | 51 // Overridden from CommandBufferService |
48 void Flush(int32 put_offset) override { | 52 void Flush(int32_t put_offset) override { |
49 flush_count_++; | 53 flush_count_++; |
50 if (!flush_locked_) { | 54 if (!flush_locked_) { |
51 last_flush_ = -1; | 55 last_flush_ = -1; |
52 previous_put_offset_ = put_offset; | 56 previous_put_offset_ = put_offset; |
53 CommandBufferService::Flush(put_offset); | 57 CommandBufferService::Flush(put_offset); |
54 } else { | 58 } else { |
55 last_flush_ = put_offset; | 59 last_flush_ = put_offset; |
56 } | 60 } |
57 } | 61 } |
58 | 62 |
59 void LockFlush() { flush_locked_ = true; } | 63 void LockFlush() { flush_locked_ = true; } |
60 | 64 |
61 void UnlockFlush() { flush_locked_ = false; } | 65 void UnlockFlush() { flush_locked_ = false; } |
62 | 66 |
63 int FlushCount() { return flush_count_; } | 67 int FlushCount() { return flush_count_; } |
64 | 68 |
65 void WaitForGetOffsetInRange(int32 start, int32 end) override { | 69 void WaitForGetOffsetInRange(int32_t start, int32_t end) override { |
66 // Flush only if it's required to unblock this Wait. | 70 // Flush only if it's required to unblock this Wait. |
67 if (last_flush_ != -1 && | 71 if (last_flush_ != -1 && |
68 !CommandBuffer::InRange(start, end, previous_put_offset_)) { | 72 !CommandBuffer::InRange(start, end, previous_put_offset_)) { |
69 previous_put_offset_ = last_flush_; | 73 previous_put_offset_ = last_flush_; |
70 CommandBufferService::Flush(last_flush_); | 74 CommandBufferService::Flush(last_flush_); |
71 last_flush_ = -1; | 75 last_flush_ = -1; |
72 } | 76 } |
73 CommandBufferService::WaitForGetOffsetInRange(start, end); | 77 CommandBufferService::WaitForGetOffsetInRange(start, end); |
74 } | 78 } |
75 | 79 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 virtual void TearDown() { | 125 virtual void TearDown() { |
122 // If the GpuScheduler posts any tasks, this forces them to run. | 126 // If the GpuScheduler posts any tasks, this forces them to run. |
123 base::MessageLoop::current()->RunUntilIdle(); | 127 base::MessageLoop::current()->RunUntilIdle(); |
124 test_command_args_.clear(); | 128 test_command_args_.clear(); |
125 } | 129 } |
126 | 130 |
127 const CommandParser* GetParser() const { | 131 const CommandParser* GetParser() const { |
128 return gpu_scheduler_->parser(); | 132 return gpu_scheduler_->parser(); |
129 } | 133 } |
130 | 134 |
131 int32 ImmediateEntryCount() const { return helper_->immediate_entry_count_; } | 135 int32_t ImmediateEntryCount() const { |
| 136 return helper_->immediate_entry_count_; |
| 137 } |
132 | 138 |
133 // Adds a command to the buffer through the helper, while adding it as an | 139 // Adds a command to the buffer through the helper, while adding it as an |
134 // expected call on the API mock. | 140 // expected call on the API mock. |
135 void AddCommandWithExpect(error::Error _return, | 141 void AddCommandWithExpect(error::Error _return, |
136 unsigned int command, | 142 unsigned int command, |
137 int arg_count, | 143 int arg_count, |
138 CommandBufferEntry *args) { | 144 CommandBufferEntry *args) { |
139 CommandHeader header; | 145 CommandHeader header; |
140 header.size = arg_count + 1; | 146 header.size = arg_count + 1; |
141 header.command = command; | 147 header.command = command; |
(...skipping 13 matching lines...) Expand all Loading... |
155 | 161 |
156 void AddUniqueCommandWithExpect(error::Error _return, int cmd_size) { | 162 void AddUniqueCommandWithExpect(error::Error _return, int cmd_size) { |
157 EXPECT_GE(cmd_size, 1); | 163 EXPECT_GE(cmd_size, 1); |
158 EXPECT_LT(cmd_size, kTotalNumCommandEntries); | 164 EXPECT_LT(cmd_size, kTotalNumCommandEntries); |
159 int arg_count = cmd_size - 1; | 165 int arg_count = cmd_size - 1; |
160 | 166 |
161 // Allocate array for args. | 167 // Allocate array for args. |
162 linked_ptr<std::vector<CommandBufferEntry> > args_ptr( | 168 linked_ptr<std::vector<CommandBufferEntry> > args_ptr( |
163 new std::vector<CommandBufferEntry>(arg_count ? arg_count : 1)); | 169 new std::vector<CommandBufferEntry>(arg_count ? arg_count : 1)); |
164 | 170 |
165 for (int32 ii = 0; ii < arg_count; ++ii) { | 171 for (int32_t ii = 0; ii < arg_count; ++ii) { |
166 (*args_ptr)[ii].value_uint32 = 0xF00DF00D + ii; | 172 (*args_ptr)[ii].value_uint32 = 0xF00DF00D + ii; |
167 } | 173 } |
168 | 174 |
169 // Add command and save args in test_command_args_ until the test completes. | 175 // Add command and save args in test_command_args_ until the test completes. |
170 AddCommandWithExpect( | 176 AddCommandWithExpect( |
171 _return, test_command_next_id_++, arg_count, &(*args_ptr)[0]); | 177 _return, test_command_next_id_++, arg_count, &(*args_ptr)[0]); |
172 test_command_args_.insert(test_command_args_.end(), args_ptr); | 178 test_command_args_.insert(test_command_args_.end(), args_ptr); |
173 } | 179 } |
174 | 180 |
175 void TestCommandWrappingFull(int32 cmd_size, int32 start_commands) { | 181 void TestCommandWrappingFull(int32_t cmd_size, int32_t start_commands) { |
176 const int32 num_args = cmd_size - 1; | 182 const int32_t num_args = cmd_size - 1; |
177 EXPECT_EQ(kTotalNumCommandEntries % cmd_size, 0); | 183 EXPECT_EQ(kTotalNumCommandEntries % cmd_size, 0); |
178 | 184 |
179 std::vector<CommandBufferEntry> args(num_args); | 185 std::vector<CommandBufferEntry> args(num_args); |
180 for (int32 ii = 0; ii < num_args; ++ii) { | 186 for (int32_t ii = 0; ii < num_args; ++ii) { |
181 args[ii].value_uint32 = ii + 1; | 187 args[ii].value_uint32 = ii + 1; |
182 } | 188 } |
183 | 189 |
184 // Initially insert commands up to start_commands and Finish(). | 190 // Initially insert commands up to start_commands and Finish(). |
185 for (int32 ii = 0; ii < start_commands; ++ii) { | 191 for (int32_t ii = 0; ii < start_commands; ++ii) { |
186 AddCommandWithExpect( | 192 AddCommandWithExpect( |
187 error::kNoError, ii + kUnusedCommandId, num_args, &args[0]); | 193 error::kNoError, ii + kUnusedCommandId, num_args, &args[0]); |
188 } | 194 } |
189 helper_->Finish(); | 195 helper_->Finish(); |
190 | 196 |
191 EXPECT_EQ(GetParser()->put(), | 197 EXPECT_EQ(GetParser()->put(), |
192 (start_commands * cmd_size) % kTotalNumCommandEntries); | 198 (start_commands * cmd_size) % kTotalNumCommandEntries); |
193 EXPECT_EQ(GetParser()->get(), | 199 EXPECT_EQ(GetParser()->get(), |
194 (start_commands * cmd_size) % kTotalNumCommandEntries); | 200 (start_commands * cmd_size) % kTotalNumCommandEntries); |
195 | 201 |
196 // Lock flushing to force the buffer to get full. | 202 // Lock flushing to force the buffer to get full. |
197 command_buffer_->LockFlush(); | 203 command_buffer_->LockFlush(); |
198 | 204 |
199 // Add enough commands to over fill the buffer. | 205 // Add enough commands to over fill the buffer. |
200 for (int32 ii = 0; ii < kTotalNumCommandEntries / cmd_size + 2; ++ii) { | 206 for (int32_t ii = 0; ii < kTotalNumCommandEntries / cmd_size + 2; ++ii) { |
201 AddCommandWithExpect(error::kNoError, | 207 AddCommandWithExpect(error::kNoError, |
202 start_commands + ii + kUnusedCommandId, | 208 start_commands + ii + kUnusedCommandId, |
203 num_args, | 209 num_args, |
204 &args[0]); | 210 &args[0]); |
205 } | 211 } |
206 | 212 |
207 // Flush all commands. | 213 // Flush all commands. |
208 command_buffer_->UnlockFlush(); | 214 command_buffer_->UnlockFlush(); |
209 helper_->Finish(); | 215 helper_->Finish(); |
210 | 216 |
(...skipping 20 matching lines...) Expand all Loading... |
231 if (put >= parser_put) { | 237 if (put >= parser_put) { |
232 // we're on the top side, check we are below the limit. | 238 // we're on the top side, check we are below the limit. |
233 EXPECT_GE(kTotalNumCommandEntries, limit); | 239 EXPECT_GE(kTotalNumCommandEntries, limit); |
234 } else { | 240 } else { |
235 // we're on the bottom side, check we are below get. | 241 // we're on the bottom side, check we are below get. |
236 EXPECT_GT(parser_get, limit); | 242 EXPECT_GT(parser_get, limit); |
237 } | 243 } |
238 } | 244 } |
239 } | 245 } |
240 | 246 |
241 int32 GetGetOffset() { | 247 int32_t GetGetOffset() { return command_buffer_->GetLastState().get_offset; } |
242 return command_buffer_->GetLastState().get_offset; | |
243 } | |
244 | 248 |
245 int32 GetPutOffset() { | 249 int32_t GetPutOffset() { return command_buffer_->GetPutOffset(); } |
246 return command_buffer_->GetPutOffset(); | |
247 } | |
248 | 250 |
249 int32 GetHelperGetOffset() { return helper_->get_offset(); } | 251 int32_t GetHelperGetOffset() { return helper_->get_offset(); } |
250 | 252 |
251 int32 GetHelperPutOffset() { return helper_->put_; } | 253 int32_t GetHelperPutOffset() { return helper_->put_; } |
252 | 254 |
253 uint32 GetHelperFlushGeneration() { return helper_->flush_generation(); } | 255 uint32_t GetHelperFlushGeneration() { return helper_->flush_generation(); } |
254 | 256 |
255 error::Error GetError() { | 257 error::Error GetError() { |
256 return command_buffer_->GetLastState().error; | 258 return command_buffer_->GetLastState().error; |
257 } | 259 } |
258 | 260 |
259 CommandBufferOffset get_helper_put() { return helper_->put_; } | 261 CommandBufferOffset get_helper_put() { return helper_->put_; } |
260 | 262 |
261 scoped_ptr<AsyncAPIMock> api_mock_; | 263 scoped_ptr<AsyncAPIMock> api_mock_; |
262 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; | 264 scoped_refptr<TransferBufferManagerInterface> transfer_buffer_manager_; |
263 scoped_ptr<CommandBufferServiceLocked> command_buffer_; | 265 scoped_ptr<CommandBufferServiceLocked> command_buffer_; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 // Check that the commands did happen. | 487 // Check that the commands did happen. |
486 Mock::VerifyAndClearExpectations(api_mock_.get()); | 488 Mock::VerifyAndClearExpectations(api_mock_.get()); |
487 | 489 |
488 // Check the error status. | 490 // Check the error status. |
489 EXPECT_EQ(error::kNoError, GetError()); | 491 EXPECT_EQ(error::kNoError, GetError()); |
490 } | 492 } |
491 | 493 |
492 // Checks the case where the command inserted exactly matches the space left in | 494 // Checks the case where the command inserted exactly matches the space left in |
493 // the command buffer. | 495 // the command buffer. |
494 TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) { | 496 TEST_F(CommandBufferHelperTest, TestCommandWrappingExactMultiple) { |
495 const int32 kCommandSize = kTotalNumCommandEntries / 2; | 497 const int32_t kCommandSize = kTotalNumCommandEntries / 2; |
496 const size_t kNumArgs = kCommandSize - 1; | 498 const size_t kNumArgs = kCommandSize - 1; |
497 static_assert(kTotalNumCommandEntries % kCommandSize == 0, | 499 static_assert(kTotalNumCommandEntries % kCommandSize == 0, |
498 "kTotalNumCommandEntries should be a multiple of kCommandSize"); | 500 "kTotalNumCommandEntries should be a multiple of kCommandSize"); |
499 CommandBufferEntry args1[kNumArgs]; | 501 CommandBufferEntry args1[kNumArgs]; |
500 for (size_t ii = 0; ii < kNumArgs; ++ii) { | 502 for (size_t ii = 0; ii < kNumArgs; ++ii) { |
501 args1[ii].value_uint32 = ii + 1; | 503 args1[ii].value_uint32 = ii + 1; |
502 } | 504 } |
503 | 505 |
504 for (unsigned int i = 0; i < 5; ++i) { | 506 for (unsigned int i = 0; i < 5; ++i) { |
505 AddCommandWithExpect( | 507 AddCommandWithExpect( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 // Checks that the InsertToken/WaitForToken work. | 567 // Checks that the InsertToken/WaitForToken work. |
566 TEST_F(CommandBufferHelperTest, TestToken) { | 568 TEST_F(CommandBufferHelperTest, TestToken) { |
567 CommandBufferEntry args[2]; | 569 CommandBufferEntry args[2]; |
568 args[0].value_uint32 = 3; | 570 args[0].value_uint32 = 3; |
569 args[1].value_float = 4.f; | 571 args[1].value_float = 4.f; |
570 | 572 |
571 // Add a first command. | 573 // Add a first command. |
572 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 3, 2, args); | 574 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 3, 2, args); |
573 // keep track of the buffer position. | 575 // keep track of the buffer position. |
574 CommandBufferOffset command1_put = get_helper_put(); | 576 CommandBufferOffset command1_put = get_helper_put(); |
575 int32 token = helper_->InsertToken(); | 577 int32_t token = helper_->InsertToken(); |
576 | 578 |
577 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 579 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
578 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 580 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
579 Return(error::kNoError))); | 581 Return(error::kNoError))); |
580 // Add another command. | 582 // Add another command. |
581 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 4, 2, args); | 583 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 4, 2, args); |
582 helper_->WaitForToken(token); | 584 helper_->WaitForToken(token); |
583 // check that the get pointer is beyond the first command. | 585 // check that the get pointer is beyond the first command. |
584 EXPECT_LE(command1_put, GetGetOffset()); | 586 EXPECT_LE(command1_put, GetGetOffset()); |
585 helper_->Finish(); | 587 helper_->Finish(); |
586 | 588 |
587 // Check that the commands did happen. | 589 // Check that the commands did happen. |
588 Mock::VerifyAndClearExpectations(api_mock_.get()); | 590 Mock::VerifyAndClearExpectations(api_mock_.get()); |
589 | 591 |
590 // Check the error status. | 592 // Check the error status. |
591 EXPECT_EQ(error::kNoError, GetError()); | 593 EXPECT_EQ(error::kNoError, GetError()); |
592 } | 594 } |
593 | 595 |
594 // Checks WaitForToken doesn't Flush if token is already read. | 596 // Checks WaitForToken doesn't Flush if token is already read. |
595 TEST_F(CommandBufferHelperTest, TestWaitForTokenFlush) { | 597 TEST_F(CommandBufferHelperTest, TestWaitForTokenFlush) { |
596 CommandBufferEntry args[2]; | 598 CommandBufferEntry args[2]; |
597 args[0].value_uint32 = 3; | 599 args[0].value_uint32 = 3; |
598 args[1].value_float = 4.f; | 600 args[1].value_float = 4.f; |
599 | 601 |
600 // Add a first command. | 602 // Add a first command. |
601 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 3, 2, args); | 603 AddCommandWithExpect(error::kNoError, kUnusedCommandId + 3, 2, args); |
602 int32 token = helper_->InsertToken(); | 604 int32_t token = helper_->InsertToken(); |
603 | 605 |
604 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 606 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
605 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 607 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
606 Return(error::kNoError))); | 608 Return(error::kNoError))); |
607 | 609 |
608 int flush_count = command_buffer_->FlushCount(); | 610 int flush_count = command_buffer_->FlushCount(); |
609 | 611 |
610 // Test that waiting for pending token causes a Flush. | 612 // Test that waiting for pending token causes a Flush. |
611 helper_->WaitForToken(token); | 613 helper_->WaitForToken(token); |
612 EXPECT_EQ(command_buffer_->FlushCount(), flush_count + 1); | 614 EXPECT_EQ(command_buffer_->FlushCount(), flush_count + 1); |
(...skipping 19 matching lines...) Expand all Loading... |
632 } | 634 } |
633 | 635 |
634 TEST_F(CommandBufferHelperTest, FreeRingBuffer) { | 636 TEST_F(CommandBufferHelperTest, FreeRingBuffer) { |
635 EXPECT_TRUE(helper_->HaveRingBuffer()); | 637 EXPECT_TRUE(helper_->HaveRingBuffer()); |
636 | 638 |
637 // Test freeing ring buffer. | 639 // Test freeing ring buffer. |
638 helper_->FreeRingBuffer(); | 640 helper_->FreeRingBuffer(); |
639 EXPECT_FALSE(helper_->HaveRingBuffer()); | 641 EXPECT_FALSE(helper_->HaveRingBuffer()); |
640 | 642 |
641 // Test that InsertToken allocates a new one | 643 // Test that InsertToken allocates a new one |
642 int32 token = helper_->InsertToken(); | 644 int32_t token = helper_->InsertToken(); |
643 EXPECT_TRUE(helper_->HaveRingBuffer()); | 645 EXPECT_TRUE(helper_->HaveRingBuffer()); |
644 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) | 646 EXPECT_CALL(*api_mock_.get(), DoCommand(cmd::kSetToken, 1, _)) |
645 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), | 647 .WillOnce(DoAll(Invoke(api_mock_.get(), &AsyncAPIMock::SetToken), |
646 Return(error::kNoError))); | 648 Return(error::kNoError))); |
647 helper_->WaitForToken(token); | 649 helper_->WaitForToken(token); |
648 helper_->FreeRingBuffer(); | 650 helper_->FreeRingBuffer(); |
649 EXPECT_FALSE(helper_->HaveRingBuffer()); | 651 EXPECT_FALSE(helper_->HaveRingBuffer()); |
650 | 652 |
651 // Test that WaitForAvailableEntries allocates a new one | 653 // Test that WaitForAvailableEntries allocates a new one |
652 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 0, NULL); | 654 AddCommandWithExpect(error::kNoError, kUnusedCommandId, 0, NULL); |
(...skipping 20 matching lines...) Expand all Loading... |
673 command_buffer_->SetParseError(error::kGenericError); | 675 command_buffer_->SetParseError(error::kGenericError); |
674 EXPECT_TRUE(helper_->IsContextLost()); | 676 EXPECT_TRUE(helper_->IsContextLost()); |
675 } | 677 } |
676 | 678 |
677 // Checks helper's 'flush generation' updates. | 679 // Checks helper's 'flush generation' updates. |
678 TEST_F(CommandBufferHelperTest, TestFlushGeneration) { | 680 TEST_F(CommandBufferHelperTest, TestFlushGeneration) { |
679 // Explicit flushing only. | 681 // Explicit flushing only. |
680 helper_->SetAutomaticFlushes(false); | 682 helper_->SetAutomaticFlushes(false); |
681 | 683 |
682 // Generation should change after Flush() but not before. | 684 // Generation should change after Flush() but not before. |
683 uint32 gen1, gen2, gen3; | 685 uint32_t gen1, gen2, gen3; |
684 | 686 |
685 gen1 = GetHelperFlushGeneration(); | 687 gen1 = GetHelperFlushGeneration(); |
686 AddUniqueCommandWithExpect(error::kNoError, 2); | 688 AddUniqueCommandWithExpect(error::kNoError, 2); |
687 gen2 = GetHelperFlushGeneration(); | 689 gen2 = GetHelperFlushGeneration(); |
688 helper_->Flush(); | 690 helper_->Flush(); |
689 gen3 = GetHelperFlushGeneration(); | 691 gen3 = GetHelperFlushGeneration(); |
690 EXPECT_EQ(gen2, gen1); | 692 EXPECT_EQ(gen2, gen1); |
691 EXPECT_NE(gen3, gen2); | 693 EXPECT_NE(gen3, gen2); |
692 | 694 |
693 // Generation should change after Finish() but not before. | 695 // Generation should change after Finish() but not before. |
(...skipping 12 matching lines...) Expand all Loading... |
706 | 708 |
707 // Check the error status. | 709 // Check the error status. |
708 EXPECT_EQ(error::kNoError, GetError()); | 710 EXPECT_EQ(error::kNoError, GetError()); |
709 } | 711 } |
710 | 712 |
711 TEST_F(CommandBufferHelperTest, TestOrderingBarrierFlushGeneration) { | 713 TEST_F(CommandBufferHelperTest, TestOrderingBarrierFlushGeneration) { |
712 // Explicit flushing only. | 714 // Explicit flushing only. |
713 helper_->SetAutomaticFlushes(false); | 715 helper_->SetAutomaticFlushes(false); |
714 | 716 |
715 // Generation should change after OrderingBarrier() but not before. | 717 // Generation should change after OrderingBarrier() but not before. |
716 uint32 gen1, gen2, gen3; | 718 uint32_t gen1, gen2, gen3; |
717 | 719 |
718 gen1 = GetHelperFlushGeneration(); | 720 gen1 = GetHelperFlushGeneration(); |
719 AddUniqueCommandWithExpect(error::kNoError, 2); | 721 AddUniqueCommandWithExpect(error::kNoError, 2); |
720 gen2 = GetHelperFlushGeneration(); | 722 gen2 = GetHelperFlushGeneration(); |
721 helper_->OrderingBarrier(); | 723 helper_->OrderingBarrier(); |
722 gen3 = GetHelperFlushGeneration(); | 724 gen3 = GetHelperFlushGeneration(); |
723 EXPECT_EQ(gen2, gen1); | 725 EXPECT_EQ(gen2, gen1); |
724 EXPECT_NE(gen3, gen2); | 726 EXPECT_NE(gen3, gen2); |
725 | 727 |
726 helper_->Finish(); | 728 helper_->Finish(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 helper_->OrderingBarrier(); | 764 helper_->OrderingBarrier(); |
763 flush_count2 = command_buffer_->FlushCount(); | 765 flush_count2 = command_buffer_->FlushCount(); |
764 helper_->OrderingBarrier(); | 766 helper_->OrderingBarrier(); |
765 flush_count3 = command_buffer_->FlushCount(); | 767 flush_count3 = command_buffer_->FlushCount(); |
766 | 768 |
767 EXPECT_EQ(flush_count2, flush_count1 + 1); | 769 EXPECT_EQ(flush_count2, flush_count1 + 1); |
768 EXPECT_EQ(flush_count3, flush_count2 + 1); | 770 EXPECT_EQ(flush_count3, flush_count2 + 1); |
769 } | 771 } |
770 | 772 |
771 } // namespace gpu | 773 } // namespace gpu |
OLD | NEW |