| OLD | NEW |
| 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 #ifndef GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 5 #ifndef GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 6 #define GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 6 #define GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 // IPC::Listener implementation: | 93 // IPC::Listener implementation: |
| 94 bool OnMessageReceived(const IPC::Message& message) override; | 94 bool OnMessageReceived(const IPC::Message& message) override; |
| 95 void OnChannelError() override; | 95 void OnChannelError() override; |
| 96 | 96 |
| 97 // CommandBuffer implementation: | 97 // CommandBuffer implementation: |
| 98 State GetLastState() override; | 98 State GetLastState() override; |
| 99 int32_t GetLastToken() override; | 99 int32_t GetLastToken() override; |
| 100 void Flush(int32_t put_offset) override; | 100 void Flush(int32_t put_offset) override; |
| 101 void OrderingBarrier(int32_t put_offset) override; | 101 void OrderingBarrier(int32_t put_offset) override; |
| 102 void WaitForTokenInRange(int32_t start, int32_t end) override; | 102 State WaitForTokenInRange(int32_t start, int32_t end) override; |
| 103 void WaitForGetOffsetInRange(int32_t start, int32_t end) override; | 103 State WaitForGetOffsetInRange(int32_t start, int32_t end) override; |
| 104 void SetGetBuffer(int32_t shm_id) override; | 104 void SetGetBuffer(int32_t shm_id) override; |
| 105 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, | 105 scoped_refptr<gpu::Buffer> CreateTransferBuffer(size_t size, |
| 106 int32_t* id) override; | 106 int32_t* id) override; |
| 107 void DestroyTransferBuffer(int32_t id) override; | 107 void DestroyTransferBuffer(int32_t id) override; |
| 108 | 108 |
| 109 // gpu::GpuControl implementation: | 109 // gpu::GpuControl implementation: |
| 110 void SetGpuControlClient(GpuControlClient* client) override; | 110 void SetGpuControlClient(GpuControlClient* client) override; |
| 111 gpu::Capabilities GetCapabilities() override; | 111 gpu::Capabilities GetCapabilities() override; |
| 112 int32_t CreateImage(ClientBuffer buffer, | 112 int32_t CreateImage(ClientBuffer buffer, |
| 113 size_t width, | 113 size_t width, |
| 114 size_t height, | 114 size_t height, |
| 115 unsigned internal_format) override; | 115 unsigned internal_format) override; |
| 116 void DestroyImage(int32_t id) override; | 116 void DestroyImage(int32_t id) override; |
| 117 int32_t CreateGpuMemoryBufferImage(size_t width, | 117 int32_t CreateGpuMemoryBufferImage(size_t width, |
| 118 size_t height, | 118 size_t height, |
| 119 unsigned internal_format, | 119 unsigned internal_format, |
| 120 unsigned usage) override; | 120 unsigned usage) override; |
| 121 void SignalQuery(uint32_t query, const base::Closure& callback) override; | 121 void SignalQuery(uint32_t query, const base::Closure& callback) override; |
| 122 void SetLock(base::Lock* lock) override; | 122 void SetLock(base::Lock* lock) override; |
| 123 void EnsureWorkVisible() override; | 123 void EnsureWorkVisible() override; |
| 124 gpu::CommandBufferNamespace GetNamespaceID() const override; | 124 gpu::CommandBufferNamespace GetNamespaceID() const override; |
| 125 gpu::CommandBufferId GetCommandBufferID() const override; | 125 gpu::CommandBufferId GetCommandBufferID() const override; |
| 126 int32_t GetExtraCommandBufferData() const override; | 126 int32_t GetExtraCommandBufferData() const override; |
| 127 uint64_t GenerateFenceSyncRelease() override; | 127 uint64_t GenerateFenceSyncRelease() override; |
| 128 bool IsFenceSyncRelease(uint64_t release) override; | 128 bool IsFenceSyncRelease(uint64_t release) override; |
| 129 bool IsFenceSyncFlushed(uint64_t release) override; | 129 bool IsFenceSyncFlushed(uint64_t release) override; |
| 130 bool IsFenceSyncFlushReceived(uint64_t release) override; | 130 bool IsFenceSyncFlushReceived(uint64_t release) override; |
| 131 bool IsFenceSyncReleased(uint64_t release) override; |
| 131 void SignalSyncToken(const gpu::SyncToken& sync_token, | 132 void SignalSyncToken(const gpu::SyncToken& sync_token, |
| 132 const base::Closure& callback) override; | 133 const base::Closure& callback) override; |
| 133 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; | 134 bool CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) override; |
| 134 | 135 |
| 135 void TakeFrontBuffer(const gpu::Mailbox& mailbox); | 136 void TakeFrontBuffer(const gpu::Mailbox& mailbox); |
| 136 void ReturnFrontBuffer(const gpu::Mailbox& mailbox, | 137 void ReturnFrontBuffer(const gpu::Mailbox& mailbox, |
| 137 const gpu::SyncToken& sync_token, | 138 const gpu::SyncToken& sync_token, |
| 138 bool is_lost); | 139 bool is_lost); |
| 139 | 140 |
| 140 void AddDeletionObserver(DeletionObserver* observer); | 141 void AddDeletionObserver(DeletionObserver* observer); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params); | 204 const GpuCommandBufferMsg_SwapBuffersCompleted_Params& params); |
| 204 void OnUpdateVSyncParameters(base::TimeTicks timebase, | 205 void OnUpdateVSyncParameters(base::TimeTicks timebase, |
| 205 base::TimeDelta interval); | 206 base::TimeDelta interval); |
| 206 | 207 |
| 207 // Updates the highest verified release fence sync. | 208 // Updates the highest verified release fence sync. |
| 208 void UpdateVerifiedReleases(uint32_t verified_flush); | 209 void UpdateVerifiedReleases(uint32_t verified_flush); |
| 209 void CleanupFlushedReleases(uint32_t highest_verified_flush_id); | 210 void CleanupFlushedReleases(uint32_t highest_verified_flush_id); |
| 210 | 211 |
| 211 // Try to read an updated copy of the state from shared memory, and calls | 212 // Try to read an updated copy of the state from shared memory, and calls |
| 212 // OnGpuStateError() if the new state has an error. | 213 // OnGpuStateError() if the new state has an error. |
| 213 void TryUpdateState(); | 214 State TryUpdateState(); |
| 215 // Like above but calls the error handler and disconnects channel by posting |
| 216 // a task. |
| 217 State TryUpdateStateThreadSafe(); |
| 214 // Like the above but does not call the error event handler if the new state | 218 // Like the above but does not call the error event handler if the new state |
| 215 // has an error. | 219 // has an error. |
| 216 void TryUpdateStateDontReportError(); | 220 State TryUpdateStateDontReportError(); |
| 217 // Sets the state, and calls OnGpuStateError() if the new state has an error. | 221 // Sets the state, and calls OnGpuStateError() if the new state has an error. |
| 218 void SetStateFromSyncReply(const gpu::CommandBuffer::State& state); | 222 void SetStateFromSyncReply(const gpu::CommandBuffer::State& state); |
| 219 | 223 |
| 220 // Loses the context after we received an invalid reply from the GPU | 224 // Loses the context after we received an invalid reply from the GPU |
| 221 // process. | 225 // process. |
| 222 void OnGpuSyncReplyError(); | 226 void OnGpuSyncReplyError(); |
| 223 | 227 |
| 224 // Loses the context when receiving a message from the GPU process. | 228 // Loses the context when receiving a message from the GPU process. |
| 225 void OnGpuAsyncMessageError(gpu::error::ContextLostReason reason, | 229 void OnGpuAsyncMessageError(gpu::error::ContextLostReason reason, |
| 226 gpu::error::Error error); | 230 gpu::error::Error error); |
| 227 | 231 |
| 228 // Loses the context after we receive an error state from the GPU process. | 232 // Loses the context after we receive an error state from the GPU process. |
| 229 void OnGpuStateError(); | 233 void OnGpuStateError(); |
| 230 | 234 |
| 231 // Sets an error on the last_state_ and loses the context due to client-side | 235 // Sets an error on the last_state_ and loses the context due to client-side |
| 232 // errors. | 236 // errors. |
| 233 void OnClientError(gpu::error::Error error); | 237 void OnClientError(gpu::error::Error error); |
| 234 | 238 |
| 235 // Helper methods, don't call these directly. | 239 // Helper methods, don't call these directly. |
| 236 void DisconnectChannelInFreshCallStack(); | 240 void DisconnectChannelInFreshCallStack(); |
| 237 void LockAndDisconnectChannel(); | 241 void LockAndDisconnectChannel(); |
| 238 void DisconnectChannel(); | 242 void DisconnectChannel(); |
| 239 | 243 |
| 240 // The shared memory area used to update state. | 244 // The shared memory area used to update state. |
| 241 gpu::CommandBufferSharedState* shared_state() const; | 245 gpu::CommandBufferSharedState* shared_state() const; |
| 242 | 246 |
| 247 // Lock to access shared state e.g. sync token release count across multiple |
| 248 // threads. This allows tracking command buffer progress from another thread. |
| 249 base::Lock state_lock_; |
| 250 |
| 243 // There should be a lock_ if this is going to be used across multiple | 251 // There should be a lock_ if this is going to be used across multiple |
| 244 // threads, or we guarantee it is used by a single thread by using a thread | 252 // threads, or we guarantee it is used by a single thread by using a thread |
| 245 // checker if no lock_ is set. | 253 // checker if no lock_ is set. |
| 246 base::Lock* lock_; | 254 base::Lock* lock_; |
| 247 base::ThreadChecker lockless_thread_checker_; | 255 base::ThreadChecker lockless_thread_checker_; |
| 248 | 256 |
| 249 // Client that wants to listen for important events on the GpuControl. | 257 // Client that wants to listen for important events on the GpuControl. |
| 250 gpu::GpuControlClient* gpu_control_client_; | 258 gpu::GpuControlClient* gpu_control_client_; |
| 251 | 259 |
| 252 // Unowned list of DeletionObservers. | 260 // Unowned list of DeletionObservers. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 | 301 |
| 294 base::WeakPtr<CommandBufferProxyImpl> weak_this_; | 302 base::WeakPtr<CommandBufferProxyImpl> weak_this_; |
| 295 scoped_refptr<base::SequencedTaskRunner> callback_thread_; | 303 scoped_refptr<base::SequencedTaskRunner> callback_thread_; |
| 296 | 304 |
| 297 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); | 305 DISALLOW_COPY_AND_ASSIGN(CommandBufferProxyImpl); |
| 298 }; | 306 }; |
| 299 | 307 |
| 300 } // namespace gpu | 308 } // namespace gpu |
| 301 | 309 |
| 302 #endif // GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ | 310 #endif // GPU_IPC_CLIENT_COMMAND_BUFFER_PROXY_IMPL_H_ |
| OLD | NEW |