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

Unified Diff: gpu/command_buffer/service/sync_point_manager.h

Issue 1568563002: Added a way for sync point clients to issue out of order waits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow WaitOutOfOrder if no client order data Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: gpu/command_buffer/service/sync_point_manager.h
diff --git a/gpu/command_buffer/service/sync_point_manager.h b/gpu/command_buffer/service/sync_point_manager.h
index cecf9febcb4dd17e094a8b83acff499262d3b394..97cdc6f7b7f14ed696bc9d8b34d3570598534dba 100644
--- a/gpu/command_buffer/service/sync_point_manager.h
+++ b/gpu/command_buffer/service/sync_point_manager.h
@@ -42,6 +42,7 @@ class GPU_EXPORT SyncPointOrderData
uint32_t GenerateUnprocessedOrderNumber(SyncPointManager* sync_point_manager);
void BeginProcessingOrderNumber(uint32_t order_num);
+ void PauseProcessingOrderNumber(uint32_t order_num);
void FinishProcessingOrderNumber(uint32_t order_num);
uint32_t processed_order_num() const {
@@ -59,6 +60,11 @@ class GPU_EXPORT SyncPointOrderData
return current_order_num_;
}
+ bool IsProcessingOrderNumber() {
+ DCHECK(processing_thread_checker_.CalledOnValidThread());
+ return !paused_ && current_order_num_ > processed_order_num();
+ }
+
private:
friend class base::RefCountedThreadSafe<SyncPointOrderData>;
friend class SyncPointClientState;
@@ -97,6 +103,9 @@ class GPU_EXPORT SyncPointOrderData
// Current IPC order number being processed (only used on processing thread).
uint32_t current_order_num_;
+ // Whether or not the current order number is being processed or paused.
+ bool paused_;
+
// This lock protects destroyed_, processed_order_num_,
// unprocessed_order_num_, and order_fence_queue_. All order numbers (n) in
// order_fence_queue_ must follow the invariant:
@@ -140,7 +149,6 @@ class GPU_EXPORT SyncPointClientState
private:
friend class base::RefCountedThreadSafe<SyncPointClientState>;
friend class SyncPointClient;
- friend class SyncPointClientWaiter;
friend class SyncPointOrderData;
struct ReleaseCallback {
@@ -213,11 +221,30 @@ class GPU_EXPORT SyncPointClient {
scoped_refptr<base::SingleThreadTaskRunner> runner,
const base::Closure& wait_complete_callback);
+ // Unordered waits are waits which do not occur within the global order number
+ // processing order (IE. Not between the corresponding
+ // SyncPointOrderData::BeginProcessingOrderNumber() and
+ // SyncPointOrderData::FinishProcessingOrderNumber() calls). Because fence
+ // sync releases must occur within a corresponding order number, these waits
+ // cannot deadlock because they can never depend on any fence sync releases.
+ // This is useful for IPC messages that may be processed out of order with
+ // respect to regular command buffer processing.
+ bool WaitOutOfOrder(SyncPointClientState* release_state,
+ uint64_t release_count,
+ const base::Closure& wait_complete_callback);
+
+ bool WaitOutOfOrderNonThreadSafe(
+ SyncPointClientState* release_state,
+ uint64_t release_count,
+ scoped_refptr<base::SingleThreadTaskRunner> runner,
+ const base::Closure& wait_complete_callback);
+
void ReleaseFenceSync(uint64_t release);
private:
friend class SyncPointManager;
+ SyncPointClient();
SyncPointClient(SyncPointManager* sync_point_manager,
scoped_refptr<SyncPointOrderData> order_data,
CommandBufferNamespace namespace_id,
@@ -236,32 +263,6 @@ class GPU_EXPORT SyncPointClient {
DISALLOW_COPY_AND_ASSIGN(SyncPointClient);
};
-// A SyncPointClientWaiter is a Sync Point Client which can only wait and on
-// fence syncs and not release any fence syncs itself. Because they cannot
-// release any fence syncs they do not need an associated order number since
-// deadlocks cannot happen. Note that it is important that this class does
-// not exist in the same execution context as a SyncPointClient, or else a
-// deadlock could occur. Basically, SyncPointClientWaiter::Wait() should never
-// be called between SyncPointOrderData::BeginProcessingOrderNumber() and
-// SyncPointOrderData::FinishProcessingOrderNumber() on the same thread.
-class GPU_EXPORT SyncPointClientWaiter {
- public:
- SyncPointClientWaiter() {}
- ~SyncPointClientWaiter() {}
-
- bool Wait(SyncPointClientState* release_state,
- uint64_t release_count,
- const base::Closure& wait_complete_callback);
-
- bool WaitNonThreadSafe(SyncPointClientState* release_state,
- uint64_t release_count,
- scoped_refptr<base::SingleThreadTaskRunner> runner,
- const base::Closure& wait_complete_callback);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(SyncPointClientWaiter);
-};
-
// This class manages the sync points, which allow cross-channel
// synchronization.
class GPU_EXPORT SyncPointManager {
@@ -275,6 +276,10 @@ class GPU_EXPORT SyncPointManager {
CommandBufferNamespace namespace_id,
uint64_t client_id);
+ // Creates a sync point client which cannot process order numbers but can only
+ // Wait out of order.
+ scoped_ptr<SyncPointClient> CreateSyncPointClientWaiter();
+
// Finds the state of an already created sync point client.
scoped_refptr<SyncPointClientState> GetSyncPointClientState(
CommandBufferNamespace namespace_id, uint64_t client_id);
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.cc ('k') | gpu/command_buffer/service/sync_point_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698