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

Side by Side Diff: gpu/command_buffer/service/command_buffer_service.cc

Issue 2440093003: WIP GPU scheduler + delayed activation / tile draw
Patch Set: SignalSyncToken -> IsFenceSyncReleased 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 #include "gpu/command_buffer/service/command_buffer_service.h" 5 #include "gpu/command_buffer/service/command_buffer_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 24 matching lines...) Expand all
35 std::unique_ptr<char[]> memory_; 35 std::unique_ptr<char[]> memory_;
36 size_t size_; 36 size_t size_;
37 DISALLOW_COPY_AND_ASSIGN(MemoryBufferBacking); 37 DISALLOW_COPY_AND_ASSIGN(MemoryBufferBacking);
38 }; 38 };
39 39
40 } // anonymous namespace 40 } // anonymous namespace
41 41
42 CommandBufferService::CommandBufferService( 42 CommandBufferService::CommandBufferService(
43 TransferBufferManagerInterface* transfer_buffer_manager) 43 TransferBufferManagerInterface* transfer_buffer_manager)
44 : ring_buffer_id_(-1), 44 : ring_buffer_id_(-1),
45 shared_state_(NULL), 45 shared_state_(nullptr),
46 num_entries_(0), 46 num_entries_(0),
47 get_offset_(0), 47 get_offset_(0),
48 put_offset_(0), 48 put_offset_(0),
49 transfer_buffer_manager_(transfer_buffer_manager), 49 transfer_buffer_manager_(transfer_buffer_manager),
50 token_(0), 50 token_(0),
51 release_count_(0),
51 generation_(0), 52 generation_(0),
52 error_(error::kNoError), 53 error_(error::kNoError),
53 context_lost_reason_(error::kUnknown) { 54 context_lost_reason_(error::kUnknown) {}
54 }
55 55
56 CommandBufferService::~CommandBufferService() { 56 CommandBufferService::~CommandBufferService() {}
57 }
58 57
59 CommandBufferService::State CommandBufferService::GetLastState() { 58 CommandBufferService::State CommandBufferService::GetLastState() {
60 State state; 59 State state;
61 state.get_offset = get_offset_; 60 state.get_offset = get_offset_;
62 state.token = token_; 61 state.token = token_;
62 state.release_count = release_count_;
63 state.error = error_; 63 state.error = error_;
64 state.context_lost_reason = context_lost_reason_; 64 state.context_lost_reason = context_lost_reason_;
65 state.generation = ++generation_; 65 state.generation = ++generation_;
66 66
67 return state; 67 return state;
68 } 68 }
69 69
70 int32_t CommandBufferService::GetLastToken() { 70 int32_t CommandBufferService::GetLastToken() {
71 return GetLastState().token; 71 return GetLastState().token;
72 } 72 }
73 73
74 void CommandBufferService::UpdateState() { 74 void CommandBufferService::UpdateState() {
75 if (shared_state_) { 75 if (shared_state_) {
76 CommandBufferService::State state = GetLastState(); 76 CommandBufferService::State state = GetLastState();
77 shared_state_->Write(state); 77 shared_state_->Write(state);
78 } 78 }
79 } 79 }
80 80
81 void CommandBufferService::WaitForTokenInRange(int32_t start, int32_t end) { 81 CommandBuffer::State CommandBufferService::WaitForTokenInRange(int32_t start,
82 int32_t end) {
82 DCHECK(error_ != error::kNoError || InRange(start, end, token_)); 83 DCHECK(error_ != error::kNoError || InRange(start, end, token_));
84 return GetLastState();
83 } 85 }
84 86
85 void CommandBufferService::WaitForGetOffsetInRange(int32_t start, int32_t end) { 87 CommandBuffer::State CommandBufferService::WaitForGetOffsetInRange(
88 int32_t start,
89 int32_t end) {
86 DCHECK(error_ != error::kNoError || InRange(start, end, get_offset_)); 90 DCHECK(error_ != error::kNoError || InRange(start, end, get_offset_));
91 return GetLastState();
87 } 92 }
88 93
89 void CommandBufferService::Flush(int32_t put_offset) { 94 void CommandBufferService::Flush(int32_t put_offset) {
90 if (put_offset < 0 || put_offset >= num_entries_) { 95 if (put_offset < 0 || put_offset >= num_entries_) {
91 error_ = gpu::error::kOutOfBounds; 96 error_ = gpu::error::kOutOfBounds;
92 return; 97 return;
93 } 98 }
94 99
95 put_offset_ = put_offset; 100 put_offset_ = put_offset;
96 101
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory()); 134 static_cast<CommandBufferSharedState*>(shared_state_buffer_->GetMemory());
130 135
131 UpdateState(); 136 UpdateState();
132 } 137 }
133 138
134 void CommandBufferService::SetGetOffset(int32_t get_offset) { 139 void CommandBufferService::SetGetOffset(int32_t get_offset) {
135 DCHECK(get_offset >= 0 && get_offset < num_entries_); 140 DCHECK(get_offset >= 0 && get_offset < num_entries_);
136 get_offset_ = get_offset; 141 get_offset_ = get_offset;
137 } 142 }
138 143
144 void CommandBufferService::SetReleaseCount(uint64_t release_count) {
145 DCHECK(release_count >= release_count_);
146 release_count_ = release_count;
147 UpdateState();
148 }
149
139 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size, 150 scoped_refptr<Buffer> CommandBufferService::CreateTransferBuffer(size_t size,
140 int32_t* id) { 151 int32_t* id) {
141 static int32_t next_id = 1; 152 static int32_t next_id = 1;
142 *id = next_id++; 153 *id = next_id++;
143 auto result = CreateTransferBufferWithId(size, *id); 154 auto result = CreateTransferBufferWithId(size, *id);
144 if (!result) 155 if (!result)
145 *id = -1; 156 *id = -1;
146 return result; 157 return result;
147 } 158 }
148 159
(...skipping 25 matching lines...) Expand all
174 if (!RegisterTransferBuffer(id, 185 if (!RegisterTransferBuffer(id,
175 base::MakeUnique<MemoryBufferBacking>(size))) { 186 base::MakeUnique<MemoryBufferBacking>(size))) {
176 if (error_ == error::kNoError) 187 if (error_ == error::kNoError)
177 error_ = gpu::error::kOutOfBounds; 188 error_ = gpu::error::kOutOfBounds;
178 return NULL; 189 return NULL;
179 } 190 }
180 191
181 return GetTransferBuffer(id); 192 return GetTransferBuffer(id);
182 } 193 }
183 194
184
185 void CommandBufferService::SetToken(int32_t token) { 195 void CommandBufferService::SetToken(int32_t token) {
186 token_ = token; 196 token_ = token;
187 UpdateState(); 197 UpdateState();
188 } 198 }
189 199
190 void CommandBufferService::SetParseError(error::Error error) { 200 void CommandBufferService::SetParseError(error::Error error) {
191 if (error_ == error::kNoError) { 201 if (error_ == error::kNoError) {
192 error_ = error; 202 error_ = error;
193 if (!parse_error_callback_.is_null()) 203 if (!parse_error_callback_.is_null())
194 parse_error_callback_.Run(); 204 parse_error_callback_.Run();
(...skipping 18 matching lines...) Expand all
213 const GetBufferChangedCallback& callback) { 223 const GetBufferChangedCallback& callback) {
214 get_buffer_change_callback_ = callback; 224 get_buffer_change_callback_ = callback;
215 } 225 }
216 226
217 void CommandBufferService::SetParseErrorCallback( 227 void CommandBufferService::SetParseErrorCallback(
218 const base::Closure& callback) { 228 const base::Closure& callback) {
219 parse_error_callback_ = callback; 229 parse_error_callback_ = callback;
220 } 230 }
221 231
222 } // namespace gpu 232 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/command_buffer_service.h ('k') | gpu/command_buffer/service/command_executor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698