Index: gpu/ipc/in_process_command_buffer.h |
diff --git a/gpu/ipc/in_process_command_buffer.h b/gpu/ipc/in_process_command_buffer.h |
index ac4ef0238789e68f2f57d017adcac7823fe738ad..67d88c2aca36138fa381fedba5956f5a9965332b 100644 |
--- a/gpu/ipc/in_process_command_buffer.h |
+++ b/gpu/ipc/in_process_command_buffer.h |
@@ -25,9 +25,12 @@ |
#include "base/threading/thread.h" |
#include "gpu/command_buffer/client/gpu_control.h" |
#include "gpu/command_buffer/common/command_buffer.h" |
+#include "gpu/command_buffer/service/command_executor.h" |
+#include "gpu/command_buffer/service/context_group.h" |
#include "gpu/command_buffer/service/gpu_preferences.h" |
#include "gpu/config/gpu_driver_bug_workarounds.h" |
#include "gpu/gpu_export.h" |
+#include "gpu/ipc/service/image_transport_surface_delegate.h" |
#include "ui/gfx/gpu_memory_buffer.h" |
#include "ui/gfx/native_widget_types.h" |
#include "ui/gl/gl_surface.h" |
@@ -48,9 +51,11 @@ class Size; |
} |
namespace gpu { |
+ |
class SyncPointClient; |
class SyncPointOrderData; |
class SyncPointManager; |
+struct GpuProcessHostedCALayerTreeParamsMac; |
namespace gles2 { |
struct ContextCreationAttribHelper; |
@@ -72,7 +77,8 @@ class TransferBufferManagerInterface; |
// However, the behavior for accessing one context (i.e. one instance of this |
// class) from different client threads is undefined. |
class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
- public GpuControl { |
+ public GpuControl, |
+ public ImageTransportSurfaceDelegate { |
public: |
class Service; |
explicit InProcessCommandBuffer(const scoped_refptr<Service>& service); |
@@ -130,6 +136,25 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
const base::Closure& callback) override; |
bool CanWaitUnverifiedSyncToken(const SyncToken* sync_token) override; |
+ // ImageTransportSurfaceDelegate implementation: |
+ void DidSwapBuffersComplete(SwapBuffersCompleteParams params) override; |
+ const gles2::FeatureInfo* GetFeatureInfo() const override; |
+ void SetLatencyInfoCallback(const LatencyInfoCallback& callback) override; |
+ void UpdateVSyncParameters(base::TimeTicks timebase, |
+ base::TimeDelta interval) override; |
+ |
+ using SwapBuffersCompletionCallback = base::Callback<void( |
+ const std::vector<ui::LatencyInfo>& latency_info, |
+ gfx::SwapResult result, |
+ const gpu::GpuProcessHostedCALayerTreeParamsMac* params_mac)>; |
+ void SetSwapBuffersCompletionCallback( |
+ const SwapBuffersCompletionCallback& callback); |
+ |
+ using UpdateVSyncParametersCallback = |
+ base::Callback<void(base::TimeTicks timebase, base::TimeDelta interval)>; |
+ void SetUpdateVSyncParametersCallback( |
+ const UpdateVSyncParametersCallback& callback); |
+ |
// The serializer interface to the GPU service (i.e. thread). |
class Service { |
public: |
@@ -155,11 +180,13 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
virtual SyncPointManager* sync_point_manager() = 0; |
const GpuPreferences& gpu_preferences(); |
const GpuDriverBugWorkarounds& gpu_driver_bug_workarounds(); |
- scoped_refptr<gl::GLShareGroup> share_group(); |
+ // scoped_refptr<gl::GLShareGroup> share_group(); |
scoped_refptr<gles2::MailboxManager> mailbox_manager(); |
gpu::gles2::ProgramCache* program_cache(); |
+ virtual const scoped_refptr<gl::GLShareGroup>& GetShareGroup() const = 0; |
+ virtual bool BlockThreadOnWaitSyncToken() const = 0; |
- private: |
+ protected: |
const GpuPreferences gpu_preferences_; |
const GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
scoped_refptr<gl::GLShareGroup> share_group_; |
@@ -194,17 +221,21 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
bool InitializeOnGpuThread(const InitializeOnGpuThreadParams& params); |
void Destroy(); |
bool DestroyOnGpuThread(); |
- void FlushOnGpuThread(int32_t put_offset, uint32_t order_num); |
+ void FlushOnGpuThread(int32_t put_offset); |
void ScheduleDelayedWorkOnGpuThread(); |
bool MakeCurrent(); |
base::Closure WrapCallback(const base::Closure& callback); |
State GetStateFast(); |
- void QueueTask(const base::Closure& task) { service_->ScheduleTask(task); } |
+ void QueueTask(bool out_of_order, const base::Closure& task); |
+ void ProcessTasksOnGpuThread(); |
void CheckSequencedThread(); |
void FenceSyncReleaseOnGpuThread(uint64_t release); |
bool WaitFenceSyncOnGpuThread(gpu::CommandBufferNamespace namespace_id, |
gpu::CommandBufferId command_buffer_id, |
uint64_t release); |
+ void OnWaitFenceSyncCompleted(CommandBufferNamespace namespace_id, |
+ CommandBufferId command_buffer_id, |
+ uint64_t release); |
void DescheduleUntilFinishedOnGpuThread(); |
void RescheduleAfterFinishedOnGpuThread(); |
void SignalSyncTokenOnGpuThread(const SyncToken& sync_token, |
@@ -216,7 +247,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
const gfx::Size& size, |
gfx::BufferFormat format, |
uint32_t internalformat, |
- uint32_t order_num, |
+ // uint32_t order_num, |
uint64_t fence_sync); |
void DestroyImageOnGpuThread(int32_t id); |
void SetGetBufferOnGpuThread(int32_t shm_id, base::WaitableEvent* completion); |
@@ -230,6 +261,7 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
const CommandBufferId command_buffer_id_; |
+ bool waiting_for_sync_point_ = false; |
// Members accessed on the gpu thread (possibly with the exception of |
// creation): |
scoped_refptr<base::SingleThreadTaskRunner> origin_task_runner_; |
@@ -265,6 +297,10 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
scoped_refptr<Service> service_; |
State state_after_last_flush_; |
base::Lock state_after_last_flush_lock_; |
+ |
+ // The group of contexts that share namespaces with this context. |
+ scoped_refptr<gles2::ContextGroup> context_group_; |
+ |
scoped_refptr<gl::GLShareGroup> gl_share_group_; |
base::WaitableEvent fence_sync_wait_event_; |
@@ -272,6 +308,18 @@ class GPU_EXPORT InProcessCommandBuffer : public CommandBuffer, |
// the client thread. |
std::unique_ptr<base::SequenceChecker> sequence_checker_; |
+ base::Lock task_queue_lock_; |
+ struct GpuTask { |
+ GpuTask(const base::Closure& callback, uint32_t order_number); |
+ ~GpuTask(); |
+ base::Closure callback; |
+ uint32_t order_number; |
+ }; |
+ std::queue<std::unique_ptr<GpuTask>> task_queue_; |
+ |
+ SwapBuffersCompletionCallback swap_buffers_completion_callback_; |
+ UpdateVSyncParametersCallback update_vsync_parameters_completion_callback_; |
+ |
base::WeakPtr<InProcessCommandBuffer> client_thread_weak_ptr_; |
base::WeakPtr<InProcessCommandBuffer> gpu_thread_weak_ptr_; |
base::WeakPtrFactory<InProcessCommandBuffer> client_thread_weak_ptr_factory_; |
@@ -298,6 +346,8 @@ class GPU_EXPORT GpuInProcessThread |
scoped_refptr<gles2::FramebufferCompletenessCache> |
framebuffer_completeness_cache() override; |
SyncPointManager* sync_point_manager() override; |
+ const scoped_refptr<gl::GLShareGroup>& GetShareGroup() const override; |
+ bool BlockThreadOnWaitSyncToken() const override; |
private: |
~GpuInProcessThread() override; |