[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 5 | #ifndef GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 6 | #define GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 7 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 8 | #include <stddef.h> |
| 9 | #include <stdint.h> |
| 10 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 11 | #include <map> |
mostynb | 6682b1c4 | 2016-04-19 10:17:30 | [diff] [blame] | 12 | #include <memory> |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 13 | #include <queue> |
| 14 | #include <string> |
| 15 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 16 | #include "base/callback.h" |
[email protected] | 3541d30 | 2012-05-17 06:53:35 | [diff] [blame] | 17 | #include "base/compiler_specific.h" |
Klaus Weidner | e66cc7d | 2017-12-09 17:26:30 | [diff] [blame] | 18 | #include "base/containers/flat_map.h" |
[email protected] | 14c1c23 | 2013-06-11 17:52:44 | [diff] [blame] | 19 | #include "base/containers/hash_tables.h" |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 20 | #include "base/macros.h" |
[email protected] | 3541d30 | 2012-05-17 06:53:35 | [diff] [blame] | 21 | #include "base/memory/ref_counted.h" |
Alexandr Ilin | 15bb703 | 2018-07-13 10:09:06 | [diff] [blame] | 22 | #include "base/memory/shared_memory_mapping.h" |
| 23 | #include "base/memory/unsafe_shared_memory_region.h" |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 24 | #include "base/memory/weak_ptr.h" |
[email protected] | 9df3488 | 2013-04-26 05:13:58 | [diff] [blame] | 25 | #include "base/observer_list.h" |
gab | 10ae436 | 2016-11-02 23:34:53 | [diff] [blame] | 26 | #include "base/single_thread_task_runner.h" |
dyen | 4d075d2 | 2016-04-29 01:53:57 | [diff] [blame] | 27 | #include "base/threading/thread_checker.h" |
[email protected] | 01952a6 | 2014-05-02 05:22:01 | [diff] [blame] | 28 | #include "gpu/command_buffer/client/gpu_control.h" |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 29 | #include "gpu/command_buffer/common/command_buffer.h" |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 30 | #include "gpu/command_buffer/common/command_buffer_id.h" |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 31 | #include "gpu/command_buffer/common/command_buffer_shared.h" |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 32 | #include "gpu/command_buffer/common/context_result.h" |
[email protected] | f44d555 | 2013-10-29 04:56:29 | [diff] [blame] | 33 | #include "gpu/command_buffer/common/gpu_memory_allocation.h" |
sunnyps | 8f9139e | 2017-05-12 17:53:25 | [diff] [blame] | 34 | #include "gpu/command_buffer/common/scheduling_priority.h" |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 35 | #include "gpu/gpu_export.h" |
piman | ac97d0cd | 2016-05-16 23:11:06 | [diff] [blame] | 36 | #include "gpu/ipc/common/surface_handle.h" |
[email protected] | d84effeb | 2012-06-25 17:03:10 | [diff] [blame] | 37 | #include "ipc/ipc_listener.h" |
achaulk | ec8c2db | 2015-05-29 16:35:03 | [diff] [blame] | 38 | #include "ui/gfx/swap_result.h" |
piman | ac97d0cd | 2016-05-16 23:11:06 | [diff] [blame] | 39 | #include "ui/gl/gpu_preference.h" |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 40 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 41 | struct GPUCommandBufferConsoleMessage; |
piman | ac97d0cd | 2016-05-16 23:11:06 | [diff] [blame] | 42 | class GURL; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 43 | |
Peng Huang | 6bf9277 | 2017-11-30 18:57:08 | [diff] [blame] | 44 | namespace gfx { |
Klaus Weidner | e66cc7d | 2017-12-09 17:26:30 | [diff] [blame] | 45 | struct GpuFenceHandle; |
Peng Huang | 6bf9277 | 2017-11-30 18:57:08 | [diff] [blame] | 46 | struct PresentationFeedback; |
| 47 | } |
| 48 | |
[email protected] | 1738e54 | 2013-03-06 13:16:39 | [diff] [blame] | 49 | namespace gpu { |
Antoine Labour | feab239 | 2017-12-21 20:28:39 | [diff] [blame] | 50 | struct ContextCreationAttribs; |
[email protected] | 1738e54 | 2013-03-06 13:16:39 | [diff] [blame] | 51 | struct Mailbox; |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 52 | struct SwapBuffersCompleteParams; |
dyen | 6f3b439c | 2015-10-22 20:17:23 | [diff] [blame] | 53 | struct SyncToken; |
[email protected] | 1738e54 | 2013-03-06 13:16:39 | [diff] [blame] | 54 | } |
| 55 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 56 | namespace gpu { |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 57 | class GpuChannelHost; |
Antoine Labour | 5ac65db | 2017-12-19 18:02:58 | [diff] [blame] | 58 | class GpuMemoryBufferManager; |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 59 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 60 | // Client side proxy that forwards messages synchronously to a |
| 61 | // CommandBufferStub. |
Uzair Jaleel | 52c44f3 | 2017-08-01 08:21:15 | [diff] [blame] | 62 | class GPU_EXPORT CommandBufferProxyImpl : public gpu::CommandBuffer, |
| 63 | public gpu::GpuControl, |
| 64 | public IPC::Listener { |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 65 | public: |
[email protected] | 9df3488 | 2013-04-26 05:13:58 | [diff] [blame] | 66 | class DeletionObserver { |
| 67 | public: |
| 68 | // Called during the destruction of the CommandBufferProxyImpl. |
| 69 | virtual void OnWillDeleteImpl() = 0; |
| 70 | |
| 71 | protected: |
Chris Watkins | 8103077 | 2017-12-07 01:20:56 | [diff] [blame] | 72 | virtual ~DeletionObserver() = default; |
[email protected] | 9df3488 | 2013-04-26 05:13:58 | [diff] [blame] | 73 | }; |
| 74 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 75 | typedef base::Callback<void(const std::string& msg, int id)> |
| 76 | GpuConsoleMessageCallback; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 77 | |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 78 | CommandBufferProxyImpl( |
| 79 | scoped_refptr<GpuChannelHost> channel, |
Antoine Labour | 5ac65db | 2017-12-19 18:02:58 | [diff] [blame] | 80 | GpuMemoryBufferManager* gpu_memory_buffer_manager, |
piman | ac97d0cd | 2016-05-16 23:11:06 | [diff] [blame] | 81 | int32_t stream_id, |
piman | ac97d0cd | 2016-05-16 23:11:06 | [diff] [blame] | 82 | scoped_refptr<base::SingleThreadTaskRunner> task_runner); |
dcheng | e933b3eb | 2014-10-21 11:44:09 | [diff] [blame] | 83 | ~CommandBufferProxyImpl() override; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 84 | |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 85 | // Connect to a command buffer in the GPU process. |
Antoine Labour | feab239 | 2017-12-21 20:28:39 | [diff] [blame] | 86 | ContextResult Initialize(gpu::SurfaceHandle surface_handle, |
| 87 | CommandBufferProxyImpl* share_group, |
| 88 | gpu::SchedulingPriority stream_priority, |
| 89 | const gpu::ContextCreationAttribs& attribs, |
| 90 | const GURL& active_url); |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 91 | |
[email protected] | d84effeb | 2012-06-25 17:03:10 | [diff] [blame] | 92 | // IPC::Listener implementation: |
dcheng | e933b3eb | 2014-10-21 11:44:09 | [diff] [blame] | 93 | bool OnMessageReceived(const IPC::Message& message) override; |
| 94 | void OnChannelError() override; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 95 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 96 | // CommandBuffer implementation: |
dcheng | e933b3eb | 2014-10-21 11:44:09 | [diff] [blame] | 97 | State GetLastState() override; |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 98 | void Flush(int32_t put_offset) override; |
| 99 | void OrderingBarrier(int32_t put_offset) override; |
sunnyps | 12856605 | 2016-12-09 21:06:43 | [diff] [blame] | 100 | State WaitForTokenInRange(int32_t start, int32_t end) override; |
Antoine Labour | d346994 | 2017-05-16 21:23:42 | [diff] [blame] | 101 | State WaitForGetOffsetInRange(uint32_t set_get_buffer_count, |
| 102 | int32_t start, |
| 103 | int32_t end) override; |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 104 | void SetGetBuffer(int32_t shm_id) override; |
dcheng | e933b3eb | 2014-10-21 11:44:09 | [diff] [blame] | 105 | scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 106 | int32_t* id) override; |
| 107 | void DestroyTransferBuffer(int32_t id) override; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 108 | |
[email protected] | 744e079 | 2013-09-27 01:18:35 | [diff] [blame] | 109 | // gpu::GpuControl implementation: |
danakj | 1005777 | 2016-04-12 19:35:44 | [diff] [blame] | 110 | void SetGpuControlClient(GpuControlClient* client) override; |
Zhenyao Mo | eb86a171 | 2017-10-06 14:17:52 | [diff] [blame] | 111 | const gpu::Capabilities& GetCapabilities() const override; |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 112 | int32_t CreateImage(ClientBuffer buffer, |
| 113 | size_t width, |
| 114 | size_t height, |
| 115 | unsigned internal_format) override; |
| 116 | void DestroyImage(int32_t id) override; |
Jonathan Backer | bd345c1f | 2018-02-14 21:44:23 | [diff] [blame] | 117 | void SignalQuery(uint32_t query, base::OnceClosure callback) override; |
Klaus Weidner | e66cc7d | 2017-12-09 17:26:30 | [diff] [blame] | 118 | void CreateGpuFence(uint32_t gpu_fence_id, ClientGpuFence source) override; |
| 119 | void GetGpuFence(uint32_t gpu_fence_id, |
| 120 | base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)> |
| 121 | callback) override; |
| 122 | |
jbauman | 6875d4e0 | 2015-02-12 00:44:59 | [diff] [blame] | 123 | void SetLock(base::Lock* lock) override; |
dyen | 293de3c | 2016-01-05 02:08:05 | [diff] [blame] | 124 | void EnsureWorkVisible() override; |
dyen | 12e4596 | 2015-09-18 00:13:51 | [diff] [blame] | 125 | gpu::CommandBufferNamespace GetNamespaceID() const override; |
lukasza | 2573ce7d | 2016-02-16 19:17:22 | [diff] [blame] | 126 | gpu::CommandBufferId GetCommandBufferID() const override; |
Sunny Sachanandani | 9b8fb34 | 2017-08-26 00:49:56 | [diff] [blame] | 127 | void FlushPendingWork() override; |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 128 | uint64_t GenerateFenceSyncRelease() override; |
sunnyps | 12856605 | 2016-12-09 21:06:43 | [diff] [blame] | 129 | bool IsFenceSyncReleased(uint64_t release) override; |
dyen | 6f3b439c | 2015-10-22 20:17:23 | [diff] [blame] | 130 | void SignalSyncToken(const gpu::SyncToken& sync_token, |
Jonathan Backer | bd345c1f | 2018-02-14 21:44:23 | [diff] [blame] | 131 | base::OnceClosure callback) override; |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 132 | void WaitSyncTokenHint(const gpu::SyncToken& sync_token) override; |
| 133 | bool CanWaitUnverifiedSyncToken(const gpu::SyncToken& sync_token) override; |
erikchen | 438b044 | 2016-05-11 18:33:30 | [diff] [blame] | 134 | void TakeFrontBuffer(const gpu::Mailbox& mailbox); |
| 135 | void ReturnFrontBuffer(const gpu::Mailbox& mailbox, |
| 136 | const gpu::SyncToken& sync_token, |
| 137 | bool is_lost); |
[email protected] | b47f1b6 | 2013-09-26 17:57:04 | [diff] [blame] | 138 | |
[email protected] | 9df3488 | 2013-04-26 05:13:58 | [diff] [blame] | 139 | void AddDeletionObserver(DeletionObserver* observer); |
| 140 | void RemoveDeletionObserver(DeletionObserver* observer); |
| 141 | |
[email protected] | bc390f1 | 2012-10-28 13:05:26 | [diff] [blame] | 142 | bool EnsureBackbuffer(); |
| 143 | |
danakj | 5c83e36 | 2015-02-20 16:51:35 | [diff] [blame] | 144 | using UpdateVSyncParametersCallback = |
| 145 | base::Callback<void(base::TimeTicks timebase, base::TimeDelta interval)>; |
| 146 | void SetUpdateVSyncParametersCallback( |
| 147 | const UpdateVSyncParametersCallback& callback); |
| 148 | |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 149 | int32_t route_id() const { return route_id_; } |
sunnyps | 4e9da31 | 2015-08-10 19:35:14 | [diff] [blame] | 150 | |
piman | 9fc22f3 | 2016-05-02 22:21:22 | [diff] [blame] | 151 | const scoped_refptr<GpuChannelHost>& channel() const { return channel_; } |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 152 | |
Alexandr Ilin | 15bb703 | 2018-07-13 10:09:06 | [diff] [blame] | 153 | const base::UnsafeSharedMemoryRegion& GetSharedStateRegion() const { |
| 154 | return shared_state_shm_; |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 155 | } |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 156 | uint32_t CreateStreamTexture(uint32_t texture_id); |
penghuang | a206fb49 | 2014-09-09 21:27:32 | [diff] [blame] | 157 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 158 | private: |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 159 | typedef std::map<int32_t, scoped_refptr<gpu::Buffer>> TransferBufferMap; |
Jonathan Backer | bd345c1f | 2018-02-14 21:44:23 | [diff] [blame] | 160 | typedef base::hash_map<uint32_t, base::OnceClosure> SignalTaskMap; |
[email protected] | 5ab44ef | 2012-06-19 00:03:51 | [diff] [blame] | 161 | |
jbauman | 6875d4e0 | 2015-02-12 00:44:59 | [diff] [blame] | 162 | void CheckLock() { |
dyen | 4d075d2 | 2016-04-29 01:53:57 | [diff] [blame] | 163 | if (lock_) { |
jbauman | 6875d4e0 | 2015-02-12 00:44:59 | [diff] [blame] | 164 | lock_->AssertAcquired(); |
dyen | 4d075d2 | 2016-04-29 01:53:57 | [diff] [blame] | 165 | } else { |
| 166 | DCHECK(lockless_thread_checker_.CalledOnValidThread()); |
| 167 | } |
jbauman | 6875d4e0 | 2015-02-12 00:44:59 | [diff] [blame] | 168 | } |
| 169 | |
Sunny Sachanandani | 9b8fb34 | 2017-08-26 00:49:56 | [diff] [blame] | 170 | void OrderingBarrierHelper(int32_t put_offset); |
| 171 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 172 | // Send an IPC message over the GPU channel. This is private to fully |
| 173 | // encapsulate the channel; all callers of this function must explicitly |
| 174 | // verify that the context has not been lost. |
| 175 | bool Send(IPC::Message* msg); |
| 176 | |
Alexandr Ilin | 15bb703 | 2018-07-13 10:09:06 | [diff] [blame] | 177 | std::pair<base::UnsafeSharedMemoryRegion, base::WritableSharedMemoryMapping> |
| 178 | AllocateAndMapSharedMemory(size_t size); |
Antoine Labour | 7590844d | 2017-11-29 17:49:18 | [diff] [blame] | 179 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 180 | // Message handlers: |
sievers | fbaa5dc | 2015-04-28 00:45:31 | [diff] [blame] | 181 | void OnDestroyed(gpu::error::ContextLostReason reason, |
| 182 | gpu::error::Error error); |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 183 | void OnConsoleMessage(const GPUCommandBufferConsoleMessage& message); |
Sunny Sachanandani | 249fd030 | 2017-09-23 02:30:11 | [diff] [blame] | 184 | void OnSignalAck(uint32_t id, const CommandBuffer::State& state); |
Christopher Cameron | 4bc282bb | 2017-12-03 11:24:05 | [diff] [blame] | 185 | void OnSwapBuffersCompleted(const SwapBuffersCompleteParams& params); |
Peng Huang | 6bf9277 | 2017-11-30 18:57:08 | [diff] [blame] | 186 | void OnBufferPresented(uint64_t swap_id, |
| 187 | const gfx::PresentationFeedback& feedback); |
Klaus Weidner | e66cc7d | 2017-12-09 17:26:30 | [diff] [blame] | 188 | void OnGetGpuFenceHandleComplete(uint32_t gpu_fence_id, |
| 189 | const gfx::GpuFenceHandle&); |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 190 | |
danakj | 90fcc5e | 2016-04-29 04:21:00 | [diff] [blame] | 191 | // Try to read an updated copy of the state from shared memory, and calls |
| 192 | // OnGpuStateError() if the new state has an error. |
| 193 | void TryUpdateState(); |
sunnyps | 12856605 | 2016-12-09 21:06:43 | [diff] [blame] | 194 | // Like above but calls the error handler and disconnects channel by posting |
| 195 | // a task. |
| 196 | void TryUpdateStateThreadSafe(); |
danakj | 90fcc5e | 2016-04-29 04:21:00 | [diff] [blame] | 197 | // Like the above but does not call the error event handler if the new state |
| 198 | // has an error. |
| 199 | void TryUpdateStateDontReportError(); |
| 200 | // Sets the state, and calls OnGpuStateError() if the new state has an error. |
Sunny Sachanandani | 249fd030 | 2017-09-23 02:30:11 | [diff] [blame] | 201 | void SetStateFromMessageReply(const CommandBuffer::State& state); |
piman | 79010e27 | 2016-01-14 19:40:55 | [diff] [blame] | 202 | |
| 203 | // Loses the context after we received an invalid reply from the GPU |
danakj | 90fcc5e | 2016-04-29 04:21:00 | [diff] [blame] | 204 | // process. |
| 205 | void OnGpuSyncReplyError(); |
piman | 79010e27 | 2016-01-14 19:40:55 | [diff] [blame] | 206 | |
danakj | 90fcc5e | 2016-04-29 04:21:00 | [diff] [blame] | 207 | // Loses the context when receiving a message from the GPU process. |
| 208 | void OnGpuAsyncMessageError(gpu::error::ContextLostReason reason, |
| 209 | gpu::error::Error error); |
| 210 | |
| 211 | // Loses the context after we receive an error state from the GPU process. |
| 212 | void OnGpuStateError(); |
| 213 | |
| 214 | // Sets an error on the last_state_ and loses the context due to client-side |
| 215 | // errors. |
| 216 | void OnClientError(gpu::error::Error error); |
| 217 | |
| 218 | // Helper methods, don't call these directly. |
| 219 | void DisconnectChannelInFreshCallStack(); |
| 220 | void LockAndDisconnectChannel(); |
| 221 | void DisconnectChannel(); |
piman | 79010e27 | 2016-01-14 19:40:55 | [diff] [blame] | 222 | |
[email protected] | 67c8078 | 2012-12-21 01:16:52 | [diff] [blame] | 223 | // The shared memory area used to update state. |
[email protected] | 1a8b20bf | 2014-04-03 12:12:04 | [diff] [blame] | 224 | gpu::CommandBufferSharedState* shared_state() const; |
[email protected] | 67c8078 | 2012-12-21 01:16:52 | [diff] [blame] | 225 | |
Alexandr Ilin | 15bb703 | 2018-07-13 10:09:06 | [diff] [blame] | 226 | // The shared memory region used to update state. |
| 227 | base::UnsafeSharedMemoryRegion shared_state_shm_; |
| 228 | base::WritableSharedMemoryMapping shared_state_mapping_; |
sunnyps | 12856605 | 2016-12-09 21:06:43 | [diff] [blame] | 229 | |
| 230 | // The last cached state received from the service. |
| 231 | State last_state_; |
| 232 | |
| 233 | // Lock to access shared state e.g. sync token release count across multiple |
| 234 | // threads. This allows tracking command buffer progress from another thread. |
| 235 | base::Lock last_state_lock_; |
| 236 | |
dyen | 4d075d2 | 2016-04-29 01:53:57 | [diff] [blame] | 237 | // There should be a lock_ if this is going to be used across multiple |
| 238 | // threads, or we guarantee it is used by a single thread by using a thread |
| 239 | // checker if no lock_ is set. |
Sunny Sachanandani | 57130e0 | 2017-06-07 00:08:56 | [diff] [blame] | 240 | base::Lock* lock_ = nullptr; |
dyen | 4d075d2 | 2016-04-29 01:53:57 | [diff] [blame] | 241 | base::ThreadChecker lockless_thread_checker_; |
jbauman | 6875d4e0 | 2015-02-12 00:44:59 | [diff] [blame] | 242 | |
danakj | 1005777 | 2016-04-12 19:35:44 | [diff] [blame] | 243 | // Client that wants to listen for important events on the GpuControl. |
Sunny Sachanandani | 57130e0 | 2017-06-07 00:08:56 | [diff] [blame] | 244 | gpu::GpuControlClient* gpu_control_client_ = nullptr; |
danakj | 1005777 | 2016-04-12 19:35:44 | [diff] [blame] | 245 | |
[email protected] | 9df3488 | 2013-04-26 05:13:58 | [diff] [blame] | 246 | // Unowned list of DeletionObservers. |
Trent Apted | a250ec3ab | 2018-08-19 08:52:19 | [diff] [blame] | 247 | base::ObserverList<DeletionObserver>::Unchecked deletion_observers_; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 248 | |
piman | 9fc22f3 | 2016-05-02 22:21:22 | [diff] [blame] | 249 | scoped_refptr<GpuChannelHost> channel_; |
Antoine Labour | 5ac65db | 2017-12-19 18:02:58 | [diff] [blame] | 250 | GpuMemoryBufferManager* gpu_memory_buffer_manager_; |
danakj | 1c7840a1 | 2017-10-18 02:28:17 | [diff] [blame] | 251 | bool disconnected_ = false; |
Sunny Sachanandani | 57130e0 | 2017-06-07 00:08:56 | [diff] [blame] | 252 | const int channel_id_; |
avi | a9aa7a8 | 2015-12-25 03:06:31 | [diff] [blame] | 253 | const int32_t route_id_; |
| 254 | const int32_t stream_id_; |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 255 | const gpu::CommandBufferId command_buffer_id_; |
Sunny Sachanandani | 9b8fb34 | 2017-08-26 00:49:56 | [diff] [blame] | 256 | uint32_t last_flush_id_ = 0; |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 257 | int32_t last_put_offset_ = -1; |
Antoine Labour | 1a9ef39 | 2017-08-24 19:40:33 | [diff] [blame] | 258 | bool has_buffer_ = false; |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 259 | |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 260 | // Next generated fence sync. |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 261 | uint64_t next_fence_sync_release_ = 1; |
| 262 | |
Sunny Sachanandani | 9b8fb34 | 2017-08-26 00:49:56 | [diff] [blame] | 263 | // Sync token waits that haven't been flushed yet. |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 264 | std::vector<SyncToken> pending_sync_token_fences_; |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 265 | |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 266 | // Last flushed fence sync release, same as last item in queue if not empty. |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 267 | uint64_t flushed_fence_sync_release_ = 0; |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 268 | |
| 269 | // Last verified fence sync. |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 270 | uint64_t verified_fence_sync_release_ = 0; |
dyen | 5c38a03 | 2015-10-07 18:58:31 | [diff] [blame] | 271 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 272 | GpuConsoleMessageCallback console_message_callback_; |
| 273 | |
[email protected] | 5ab44ef | 2012-06-19 00:03:51 | [diff] [blame] | 274 | // Tasks to be invoked in SignalSyncPoint responses. |
sunnyps | 7499629 | 2017-03-15 02:35:48 | [diff] [blame] | 275 | uint32_t next_signal_id_ = 0; |
[email protected] | 5ab44ef | 2012-06-19 00:03:51 | [diff] [blame] | 276 | SignalTaskMap signal_tasks_; |
| 277 | |
[email protected] | 6d66889 | 2013-12-04 21:37:12 | [diff] [blame] | 278 | gpu::Capabilities capabilities_; |
| 279 | |
danakj | 5c83e36 | 2015-02-20 16:51:35 | [diff] [blame] | 280 | UpdateVSyncParametersCallback update_vsync_parameters_completion_callback_; |
sievers | df212b3 | 2014-10-09 20:40:14 | [diff] [blame] | 281 | |
Klaus Weidner | e66cc7d | 2017-12-09 17:26:30 | [diff] [blame] | 282 | using GetGpuFenceTaskMap = |
| 283 | base::flat_map<uint32_t, |
| 284 | base::OnceCallback<void(std::unique_ptr<gfx::GpuFence>)>>; |
| 285 | GetGpuFenceTaskMap get_gpu_fence_tasks_; |
| 286 | |
danakj | 45cfd23 | 2017-10-18 19:31:31 | [diff] [blame] | 287 | scoped_refptr<base::SingleThreadTaskRunner> callback_thread_; |
Uzair Jaleel | 52c44f3 | 2017-08-01 08:21:15 | [diff] [blame] | 288 | base::WeakPtrFactory<CommandBufferProxyImpl> weak_ptr_factory_; |
piman | 79010e27 | 2016-01-14 19:40:55 | [diff] [blame] | 289 | |
[email protected] | 1c3c9f6 | 2012-03-28 04:01:55 | [diff] [blame] | 290 | DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 291 | }; |
| 292 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 293 | } // namespace gpu |
[email protected] | eb39819 | 2012-10-22 20:16:19 | [diff] [blame] | 294 | |
penghuang | 346a46f9 | 2016-03-31 21:37:52 | [diff] [blame] | 295 | #endif // GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |