Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: gpu/command_buffer/client/cmd_buffer_helper_test.cc

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: jbauman's review Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 last_flush_ = put_offset; 61 last_flush_ = put_offset;
62 } 62 }
63 } 63 }
64 64
65 void LockFlush() { flush_locked_ = true; } 65 void LockFlush() { flush_locked_ = true; }
66 66
67 void UnlockFlush() { flush_locked_ = false; } 67 void UnlockFlush() { flush_locked_ = false; }
68 68
69 int FlushCount() { return flush_count_; } 69 int FlushCount() { return flush_count_; }
70 70
71 void WaitForGetOffsetInRange(int32_t start, int32_t end) override { 71 State WaitForGetOffsetInRange(int32_t start, int32_t end) override {
72 // Flush only if it's required to unblock this Wait. 72 // Flush only if it's required to unblock this Wait.
73 if (last_flush_ != -1 && 73 if (last_flush_ != -1 &&
74 !CommandBuffer::InRange(start, end, previous_put_offset_)) { 74 !CommandBuffer::InRange(start, end, previous_put_offset_)) {
75 previous_put_offset_ = last_flush_; 75 previous_put_offset_ = last_flush_;
76 CommandBufferService::Flush(last_flush_); 76 CommandBufferService::Flush(last_flush_);
77 last_flush_ = -1; 77 last_flush_ = -1;
78 } 78 }
79 CommandBufferService::WaitForGetOffsetInRange(start, end); 79 return CommandBufferService::WaitForGetOffsetInRange(start, end);
80 } 80 }
81 81
82 private: 82 private:
83 bool flush_locked_; 83 bool flush_locked_;
84 int last_flush_; 84 int last_flush_;
85 int previous_put_offset_; 85 int previous_put_offset_;
86 int flush_count_; 86 int flush_count_;
87 DISALLOW_COPY_AND_ASSIGN(CommandBufferServiceLocked); 87 DISALLOW_COPY_AND_ASSIGN(CommandBufferServiceLocked);
88 }; 88 };
89 89
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // we're on the bottom side, check we are below get. 240 // we're on the bottom side, check we are below get.
241 EXPECT_GT(parser_get, limit); 241 EXPECT_GT(parser_get, limit);
242 } 242 }
243 } 243 }
244 } 244 }
245 245
246 int32_t GetGetOffset() { return command_buffer_->GetLastState().get_offset; } 246 int32_t GetGetOffset() { return command_buffer_->GetLastState().get_offset; }
247 247
248 int32_t GetPutOffset() { return command_buffer_->GetPutOffset(); } 248 int32_t GetPutOffset() { return command_buffer_->GetPutOffset(); }
249 249
250 int32_t GetHelperGetOffset() { return helper_->get_offset(); } 250 int32_t GetHelperGetOffset() { return helper_->cached_get_offset_; }
251 251
252 int32_t GetHelperPutOffset() { return helper_->put_; } 252 int32_t GetHelperPutOffset() { return helper_->put_; }
253 253
254 uint32_t GetHelperFlushGeneration() { return helper_->flush_generation(); } 254 uint32_t GetHelperFlushGeneration() { return helper_->flush_generation(); }
255 255
256 error::Error GetError() { 256 error::Error GetError() {
257 return command_buffer_->GetLastState().error; 257 return command_buffer_->GetLastState().error;
258 } 258 }
259 259
260 CommandBufferOffset get_helper_put() { return helper_->put_; } 260 CommandBufferOffset get_helper_put() { return helper_->put_; }
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 helper_->OrderingBarrier(); 763 helper_->OrderingBarrier();
764 flush_count2 = command_buffer_->FlushCount(); 764 flush_count2 = command_buffer_->FlushCount();
765 helper_->OrderingBarrier(); 765 helper_->OrderingBarrier();
766 flush_count3 = command_buffer_->FlushCount(); 766 flush_count3 = command_buffer_->FlushCount();
767 767
768 EXPECT_EQ(flush_count2, flush_count1 + 1); 768 EXPECT_EQ(flush_count2, flush_count1 + 1);
769 EXPECT_EQ(flush_count3, flush_count2 + 1); 769 EXPECT_EQ(flush_count3, flush_count2 + 1);
770 } 770 }
771 771
772 } // namespace gpu 772 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/client/cmd_buffer_helper.cc ('k') | gpu/command_buffer/client/context_support.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698