diff options
author | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 23:37:14 +0000 |
---|---|---|
committer | piman@google.com <piman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-28 23:37:14 +0000 |
commit | ef16c174a500a841cf6a120dc4ef9fca89fac9f9 (patch) | |
tree | 8491a815c314e161a462f42c41c374403ce6ec8c /ppapi | |
parent | d0a7409f5ad0c075d5208ea0eb93ff07868c6168 (diff) | |
download | chromium_src-ef16c174a500a841cf6a120dc4ef9fca89fac9f9.zip chromium_src-ef16c174a500a841cf6a120dc4ef9fca89fac9f9.tar.gz chromium_src-ef16c174a500a841cf6a120dc4ef9fca89fac9f9.tar.bz2 |
Rework FlushSync to return early if commands have been processed since the last update
BUG=80480
TEST=
Review URL: http://codereview.chromium.org/6883179
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@83442 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/c/dev/ppb_context_3d_trusted_dev.h | 16 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 3 | ||||
-rw-r--r-- | ppapi/proxy/ppb_context_3d_proxy.cc | 40 | ||||
-rw-r--r-- | ppapi/proxy/ppb_context_3d_proxy.h | 3 |
4 files changed, 48 insertions, 14 deletions
diff --git a/ppapi/c/dev/ppb_context_3d_trusted_dev.h b/ppapi/c/dev/ppb_context_3d_trusted_dev.h index afc860f..ce4d8d6 100644 --- a/ppapi/c/dev/ppb_context_3d_trusted_dev.h +++ b/ppapi/c/dev/ppb_context_3d_trusted_dev.h @@ -11,9 +11,9 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/c/pp_stdint.h" -#define PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE_0_3 "PPB_Context3DTrusted(Dev);0.3" +#define PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE_0_4 "PPB_Context3DTrusted(Dev);0.4" #define PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE \ - PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE_0_3 + PPB_CONTEXT_3D_TRUSTED_DEV_INTERFACE_0_4 typedef enum { kNoError, @@ -44,6 +44,11 @@ struct PP_Context3DTrustedState { // Error status. PPB_Context3DTrustedError error; + + // Generation index of this state. The generation index is incremented every + // time a new state is retrieved from the command processor, so that + // consistency can be kept even if IPC messages are processed out-of-order. + uint32_t generation; }; struct PPB_Context3DTrusted_Dev { @@ -89,6 +94,13 @@ struct PPB_Context3DTrusted_Dev { int32_t id, int* shm_handle, uint32_t* shm_size); + + // Like FlushSync, but returns before processing commands if the get offset is + // different than last_known_get. Allows synchronization with the command + // processor without forcing immediate command execution. + struct PP_Context3DTrustedState (*FlushSyncFast)(PP_Resource context, + int32_t put_offset, + int32_t last_known_get); }; #endif // PPAPI_C_DEV_PPB_CONTEXT_3D_TRUSTED_DEV_H_ diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index 32dfdf2..6bbd8bd 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -316,9 +316,10 @@ IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBContext3D_GetState, pp::proxy::HostResource /* context */, gpu::CommandBuffer::State /* state */) -IPC_SYNC_MESSAGE_ROUTED2_1(PpapiHostMsg_PPBContext3D_Flush, +IPC_SYNC_MESSAGE_ROUTED3_1(PpapiHostMsg_PPBContext3D_Flush, pp::proxy::HostResource /* context */, int32 /* put_offset */, + int32 /* last_known_get */, gpu::CommandBuffer::State /* state */) IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBContext3D_AsyncFlush, diff --git a/ppapi/proxy/ppb_context_3d_proxy.cc b/ppapi/proxy/ppb_context_3d_proxy.cc index 396ccf6..fce162b 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.cc +++ b/ppapi/proxy/ppb_context_3d_proxy.cc @@ -155,6 +155,7 @@ gpu::CommandBuffer::State GPUStateFromPPState( state.put_offset = s.put_offset; state.token = s.token; state.error = static_cast<gpu::error::Error>(s.error); + state.generation = s.generation; return state; } @@ -181,7 +182,7 @@ class PepperCommandBuffer : public gpu::CommandBuffer { virtual gpu::Buffer GetRingBuffer(); virtual State GetState(); virtual void Flush(int32 put_offset); - virtual State FlushSync(int32 put_offset); + virtual State FlushSync(int32 put_offset, int32 last_known_get); virtual void SetGetOffset(int32 get_offset); virtual int32 CreateTransferBuffer(size_t size, int32 id_request); virtual int32 RegisterTransferBuffer(base::SharedMemory* shared_memory, @@ -194,6 +195,7 @@ class PepperCommandBuffer : public gpu::CommandBuffer { private: bool Send(IPC::Message* msg); + void UpdateState(const gpu::CommandBuffer::State& state); int32 num_entries_; scoped_ptr<base::SharedMemory> ring_buffer_; @@ -268,8 +270,10 @@ gpu::Buffer PepperCommandBuffer::GetRingBuffer() { gpu::CommandBuffer::State PepperCommandBuffer::GetState() { // Send will flag state with lost context if IPC fails. if (last_state_.error == gpu::error::kNoError) { - Send(new PpapiHostMsg_PPBContext3D_GetState( - INTERFACE_ID_PPB_CONTEXT_3D, resource_, &last_state_)); + gpu::CommandBuffer::State state; + if (Send(new PpapiHostMsg_PPBContext3D_GetState( + INTERFACE_ID_PPB_CONTEXT_3D, resource_, &state))) + UpdateState(state); } return last_state_; @@ -289,11 +293,19 @@ void PepperCommandBuffer::Flush(int32 put_offset) { Send(message); } -gpu::CommandBuffer::State PepperCommandBuffer::FlushSync(int32 put_offset) { - // Send will flag state with lost context if IPC fails. - if (last_state_.error == gpu::error::kNoError) { - Send(new PpapiHostMsg_PPBContext3D_Flush( - INTERFACE_ID_PPB_CONTEXT_3D, resource_, put_offset, &last_state_)); +gpu::CommandBuffer::State PepperCommandBuffer::FlushSync( + int32 put_offset, int32 last_known_get) { + if (last_known_get == last_state_.get_offset) { + // Send will flag state with lost context if IPC fails. + if (last_state_.error == gpu::error::kNoError) { + gpu::CommandBuffer::State state; + if (Send(new PpapiHostMsg_PPBContext3D_Flush( + INTERFACE_ID_PPB_CONTEXT_3D, resource_, put_offset, + last_known_get, &state))) + UpdateState(state); + } + } else { + Flush(put_offset); } return last_state_; @@ -400,6 +412,13 @@ bool PepperCommandBuffer::Send(IPC::Message* msg) { return false; } +void PepperCommandBuffer::UpdateState(const gpu::CommandBuffer::State& state) { + // Handle wraparound. It works as long as we don't have more than 2B state + // updates in flight across which reordering occurs. + if (state.generation - last_state_.generation < 0x80000000U) + last_state_ = state; +} + Context3D::Context3D(const HostResource& resource) : PluginResource(resource), draw_(NULL), @@ -571,9 +590,10 @@ void PPB_Context3D_Proxy::OnMsgGetState(const HostResource& context, void PPB_Context3D_Proxy::OnMsgFlush(const HostResource& context, int32 put_offset, + int32 last_known_get, gpu::CommandBuffer::State* state) { - PP_Context3DTrustedState pp_state = - ppb_context_3d_trusted()->FlushSync(context.host_resource(), put_offset); + PP_Context3DTrustedState pp_state = ppb_context_3d_trusted()->FlushSyncFast( + context.host_resource(), put_offset, last_known_get); *state = GPUStateFromPPState(pp_state); } diff --git a/ppapi/proxy/ppb_context_3d_proxy.h b/ppapi/proxy/ppb_context_3d_proxy.h index 117dbe0..3e2f953 100644 --- a/ppapi/proxy/ppb_context_3d_proxy.h +++ b/ppapi/proxy/ppb_context_3d_proxy.h @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -100,6 +100,7 @@ class PPB_Context3D_Proxy : public InterfaceProxy { gpu::CommandBuffer::State* state); void OnMsgFlush(const HostResource& context, int32 put_offset, + int32 last_known_get, gpu::CommandBuffer::State* state); void OnMsgAsyncFlush(const HostResource& context, int32 put_offset); |