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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.cc

Issue 8198017: Allow FlushSyncs to short circuit (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 83
84 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers 84 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers
85 // here. This is so the reply can be delayed if the scheduler is unscheduled. 85 // here. This is so the reply can be delayed if the scheduler is unscheduled.
86 bool handled = true; 86 bool handled = true;
87 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message) 87 IPC_BEGIN_MESSAGE_MAP(GpuCommandBufferStub, message)
88 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize, 88 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Initialize,
89 OnInitialize); 89 OnInitialize);
90 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent, 90 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_SetParent,
91 OnSetParent); 91 OnSetParent);
92 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState); 92 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetState, OnGetState);
93 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_Flush, OnFlush); 93 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetStateFast,
94 OnGetStateFast);
94 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush); 95 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_AsyncFlush, OnAsyncFlush);
95 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled); 96 IPC_MESSAGE_HANDLER(GpuCommandBufferMsg_Rescheduled, OnRescheduled);
96 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer, 97 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_CreateTransferBuffer,
97 OnCreateTransferBuffer); 98 OnCreateTransferBuffer);
98 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer, 99 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_RegisterTransferBuffer,
99 OnRegisterTransferBuffer); 100 OnRegisterTransferBuffer);
100 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer, 101 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_DestroyTransferBuffer,
101 OnDestroyTransferBuffer); 102 OnDestroyTransferBuffer);
102 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer, 103 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuCommandBufferMsg_GetTransferBuffer,
103 OnGetTransferBuffer); 104 OnGetTransferBuffer);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 void GpuCommandBufferStub::OnParseError() { 303 void GpuCommandBufferStub::OnParseError() {
303 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError"); 304 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnParseError");
304 gpu::CommandBuffer::State state = command_buffer_->GetState(); 305 gpu::CommandBuffer::State state = command_buffer_->GetState();
305 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed( 306 IPC::Message* msg = new GpuCommandBufferMsg_Destroyed(
306 route_id_, state.context_lost_reason); 307 route_id_, state.context_lost_reason);
307 msg->set_unblock(true); 308 msg->set_unblock(true);
308 Send(msg); 309 Send(msg);
309 } 310 }
310 311
311 void GpuCommandBufferStub::OnFlush(int32 put_offset, 312 void GpuCommandBufferStub::OnGetStateFast(IPC::Message* reply_message) {
312 int32 last_known_get, 313 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnGetStateFast");
313 uint32 flush_count,
314 IPC::Message* reply_message) {
315 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnFlush");
316 gpu::CommandBuffer::State state = command_buffer_->GetState(); 314 gpu::CommandBuffer::State state = command_buffer_->GetState();
317 if (flush_count - last_flush_count_ >= 0x8000000U) { 315 if (state.error == gpu::error::kLostContext &&
318 // We received this message out-of-order. This should not happen but is here 316 gfx::GLContext::LosesAllContextsOnContextLost())
319 // to catch regressions. Ignore the message. 317 channel_->LoseAllContexts();
320 NOTREACHED() << "Received an AsyncFlush message out-of-order";
321 GpuCommandBufferMsg_Flush::WriteReplyParams(reply_message, state);
322 Send(reply_message);
323 } else {
324 last_flush_count_ = flush_count;
325 318
326 // Reply immediately if the client was out of date with the current get 319 GpuCommandBufferMsg_GetStateFast::WriteReplyParams(reply_message, state);
327 // offset. 320 Send(reply_message);
328 bool reply_immediately = state.get_offset != last_known_get;
329 if (reply_immediately) {
330 GpuCommandBufferMsg_Flush::WriteReplyParams(reply_message, state);
331 Send(reply_message);
332 }
333
334 // Process everything up to the put offset.
335 state = command_buffer_->FlushSync(put_offset, last_known_get);
336
337 // Lose all contexts if the context was lost.
338 if (state.error == gpu::error::kLostContext &&
339 gfx::GLContext::LosesAllContextsOnContextLost()) {
340 channel_->LoseAllContexts();
341 }
342
343 // Then if the client was up-to-date with the get offset, reply to the
344 // synchronpous IPC only after processing all commands are processed. This
345 // prevents the client from "spinning" when it fills up the command buffer.
346 // Otherwise, since the state has changed since the immediate reply, send
347 // an asyncronous state update back to the client.
348 if (!reply_immediately) {
349 GpuCommandBufferMsg_Flush::WriteReplyParams(reply_message, state);
350 Send(reply_message);
351 } else {
352 ReportState();
353 }
354 }
355 } 321 }
356 322
357 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset, uint32 flush_count) { 323 void GpuCommandBufferStub::OnAsyncFlush(int32 put_offset,
358 TRACE_EVENT0("gpu", "GpuCommandBufferStub::OnAsyncFlush"); 324 uint32 flush_count) {
325 TRACE_EVENT1("gpu", "GpuCommandBufferStub::OnAsyncFlush",
326 "put_offset", put_offset);
359 if (flush_count - last_flush_count_ < 0x8000000U) { 327 if (flush_count - last_flush_count_ < 0x8000000U) {
360 last_flush_count_ = flush_count; 328 last_flush_count_ = flush_count;
361 command_buffer_->Flush(put_offset); 329 command_buffer_->Flush(put_offset);
362 } else { 330 } else {
363 // We received this message out-of-order. This should not happen but is here 331 // We received this message out-of-order. This should not happen but is here
364 // to catch regressions. Ignore the message. 332 // to catch regressions. Ignore the message.
365 NOTREACHED() << "Received a Flush message out-of-order"; 333 NOTREACHED() << "Received a Flush message out-of-order";
366 } 334 }
367 335
368 ReportState(); 336 ReportState();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 channel_->AddRoute(decoder_route_id, decoder); 491 channel_->AddRoute(decoder_route_id, decoder);
524 decoder->Initialize(profile, reply_message); 492 decoder->Initialize(profile, reply_message);
525 } 493 }
526 494
527 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 495 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
528 channel_->RemoveRoute(decoder_route_id); 496 channel_->RemoveRoute(decoder_route_id);
529 video_decoders_.Remove(decoder_route_id); 497 video_decoders_.Remove(decoder_route_id);
530 } 498 }
531 499
532 #endif // defined(ENABLE_GPU) 500 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698