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

Unified Diff: gpu/command_buffer/service/mailbox_manager_sync.cc

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Some fixes Created 5 years, 3 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/mailbox_manager_sync.cc
diff --git a/gpu/command_buffer/service/mailbox_manager_sync.cc b/gpu/command_buffer/service/mailbox_manager_sync.cc
index be12b3a8fe86cbe3408c57cbfb65ca6411ddaec2..209e28245bcdc4bde0a75e16faa605b5bc8e980b 100644
--- a/gpu/command_buffer/service/mailbox_manager_sync.cc
+++ b/gpu/command_buffer/service/mailbox_manager_sync.cc
@@ -24,23 +24,24 @@ namespace {
base::LazyInstance<base::Lock> g_lock = LAZY_INSTANCE_INITIALIZER;
-typedef std::map<uint32, linked_ptr<gfx::GLFence>> SyncPointToFenceMap;
-base::LazyInstance<SyncPointToFenceMap> g_sync_point_to_fence =
+typedef std::pair<int, std::pair<uint32, uint32>> SyncToken;
piman 2015/09/10 23:55:32 Can you use SyncToken from gles2_cmd_format.h inst
+typedef std::map<SyncToken, linked_ptr<gfx::GLFence>> SyncTokenToFenceMap;
+base::LazyInstance<SyncTokenToFenceMap> g_sync_point_to_fence =
LAZY_INSTANCE_INITIALIZER;
#if !defined(OS_MACOSX)
-base::LazyInstance<std::queue<SyncPointToFenceMap::iterator>> g_sync_points =
+base::LazyInstance<std::queue<SyncTokenToFenceMap::iterator>> g_sync_points =
LAZY_INSTANCE_INITIALIZER;
#endif
-void CreateFenceLocked(uint32 sync_point) {
+void CreateFenceLocked(int channel_client_id, uint32 route_id, uint32 release) {
g_lock.Get().AssertAcquired();
if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL)
return;
#if !defined(OS_MACOSX)
- std::queue<SyncPointToFenceMap::iterator>& sync_points = g_sync_points.Get();
- SyncPointToFenceMap& sync_point_to_fence = g_sync_point_to_fence.Get();
- if (sync_point) {
+ std::queue<SyncTokenToFenceMap::iterator>& sync_points = g_sync_points.Get();
+ SyncTokenToFenceMap& sync_point_to_fence = g_sync_point_to_fence.Get();
+ if (release) {
while (!sync_points.empty() &&
sync_points.front()->second->HasCompleted()) {
sync_point_to_fence.erase(sync_points.front());
@@ -49,8 +50,10 @@ void CreateFenceLocked(uint32 sync_point) {
// Need to use EGL fences since we are likely not in a single share group.
linked_ptr<gfx::GLFence> fence(make_linked_ptr(new gfx::GLFenceEGL));
if (fence.get()) {
- std::pair<SyncPointToFenceMap::iterator, bool> result =
- sync_point_to_fence.insert(std::make_pair(sync_point, fence));
+ const SyncToken sync_token =
+ std::make_pair(channel_client_id, std::make_pair(route_id, release));
+ std::pair<SyncTokenToFenceMap::iterator, bool> result =
+ sync_point_to_fence.insert(std::make_pair(sync_token, fence));
DCHECK(result.second);
sync_points.push(result.first);
}
@@ -59,13 +62,20 @@ void CreateFenceLocked(uint32 sync_point) {
#endif
}
-void AcquireFenceLocked(uint32 sync_point) {
+void AcquireFenceLocked(int channel_client_id,
+ uint32 route_id,
+ uint32 release) {
+#if !defined(OS_MACOSX)
g_lock.Get().AssertAcquired();
- SyncPointToFenceMap::iterator fence_it =
- g_sync_point_to_fence.Get().find(sync_point);
+ const SyncToken sync_token =
+ std::make_pair(channel_client_id, std::make_pair(route_id, release));
+
+ SyncTokenToFenceMap::iterator fence_it =
+ g_sync_point_to_fence.Get().find(sync_token);
if (fence_it != g_sync_point_to_fence.Get().end()) {
fence_it->second->ServerWait();
}
+#endif
}
static const unsigned kNewTextureVersion = 1;
@@ -294,22 +304,26 @@ void MailboxManagerSync::UpdateDefinitionLocked(
gl_image ? image_buffer : NULL));
}
-void MailboxManagerSync::PushTextureUpdates(uint32 sync_point) {
+void MailboxManagerSync::PushTextureUpdates(int channel_client_id,
+ uint32 route_id,
+ uint32 release) {
base::AutoLock lock(g_lock.Get());
for (TextureToGroupMap::iterator it = texture_to_group_.begin();
it != texture_to_group_.end(); it++) {
UpdateDefinitionLocked(it->first, &it->second);
}
- CreateFenceLocked(sync_point);
+ CreateFenceLocked(channel_client_id, route_id, release);
}
-void MailboxManagerSync::PullTextureUpdates(uint32 sync_point) {
+void MailboxManagerSync::PullTextureUpdates(int channel_client_id,
+ uint32 route_id,
+ uint32 release) {
using TextureUpdatePair = std::pair<Texture*, TextureDefinition>;
std::vector<TextureUpdatePair> needs_update;
{
base::AutoLock lock(g_lock.Get());
- AcquireFenceLocked(sync_point);
+ AcquireFenceLocked(channel_client_id, route_id, release);
for (TextureToGroupMap::iterator it = texture_to_group_.begin();
it != texture_to_group_.end(); it++) {

Powered by Google App Engine
This is Rietveld 408576698