summaryrefslogtreecommitdiffstats
path: root/cc/resources
diff options
context:
space:
mode:
authordyen <dyen@chromium.org>2016-02-23 18:46:02 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-24 02:47:24 +0000
commit7e9fd7734fc93011d9058d90646b02345424e252 (patch)
tree178198636ba2ac98e2fd9713428a899751deec66 /cc/resources
parent5cbaa77d1bf5dc22647a93919149106deabf4723 (diff)
downloadchromium_src-7e9fd7734fc93011d9058d90646b02345424e252.zip
chromium_src-7e9fd7734fc93011d9058d90646b02345424e252.tar.gz
chromium_src-7e9fd7734fc93011d9058d90646b02345424e252.tar.bz2
Added sync token generation for more resources.
As an optimization, resource sync token generation should be done as early as possible and ideally within the same GL command buffer stream as the commands which modify the resource. Sync token generation has been moved for the direct renderer case after it has added all the render pass commands. It has also been added for the HUD resource. R=piman@chromium.org BUG=584381 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1717443002 Cr-Commit-Position: refs/heads/master@{#377196}
Diffstat (limited to 'cc/resources')
-rw-r--r--cc/resources/resource_provider.cc50
1 files changed, 34 insertions, 16 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 8913b0c..2878e30 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -1575,12 +1575,12 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
return;
ReturnedResourceArray to_return;
+ to_return.reserve(unused.size());
+ std::vector<GLbyte*> unverified_sync_tokens;
- GLES2Interface* gl = ContextGL();
bool need_sync_token = false;
- for (size_t i = 0; i < unused.size(); ++i) {
- ResourceId local_id = unused[i];
-
+ GLES2Interface* gl = ContextGL();
+ for (ResourceId local_id : unused) {
ResourceMap::iterator it = resources_.find(local_id);
CHECK(it != resources_.end());
Resource& resource = it->second;
@@ -1627,11 +1627,11 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
ReturnedResource returned;
returned.id = child_id;
- returned.sync_token = resource.mailbox().sync_token();
+ if (resource.needs_sync_token())
+ need_sync_token = true;
+ else
+ returned.sync_token = resource.mailbox().sync_token();
- need_sync_token |=
- (Resource::LOCALLY_USED == resource.synchronization_state() &&
- IsGpuResourceType(resource.type));
returned.count = resource.imported_count;
returned.lost = is_lost;
to_return.push_back(returned);
@@ -1640,17 +1640,35 @@ void ResourceProvider::DeleteAndReturnUnusedResourcesToChild(
child_info->child_to_parent_map.erase(child_id);
resource.imported_count = 0;
DeleteResourceInternal(it, style);
+
+ // Before returning any sync tokens, they must be verified. Note that we
+ // need to verify the sync token inside of the "to_return" array.
+ if (to_return.back().sync_token.HasData() &&
+ !to_return.back().sync_token.verified_flush()) {
+ unverified_sync_tokens.push_back(to_return.back().sync_token.GetData());
+ }
}
+
+ gpu::SyncToken new_sync_token;
if (need_sync_token && child_info->needs_sync_tokens) {
DCHECK(gl);
- const GLuint64 fence_sync = gl->InsertFenceSyncCHROMIUM();
- gl->ShallowFlushCHROMIUM();
-
- gpu::SyncToken sync_token;
- gl->GenSyncTokenCHROMIUM(fence_sync, sync_token.GetData());
- for (size_t i = 0; i < to_return.size(); ++i) {
- if (!to_return[i].sync_token.HasData())
- to_return[i].sync_token = sync_token;
+ const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
+ gl->OrderingBarrierCHROMIUM();
+ gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, new_sync_token.GetData());
+ unverified_sync_tokens.push_back(new_sync_token.GetData());
+ }
+
+ if (!unverified_sync_tokens.empty()) {
+ DCHECK(gl);
+ gl->VerifySyncTokensCHROMIUM(unverified_sync_tokens.data(),
+ unverified_sync_tokens.size());
+ }
+
+ if (new_sync_token.HasData()) {
+ DCHECK(need_sync_token && child_info->needs_sync_tokens);
+ for (ReturnedResource& returned_resource : to_return) {
+ if (!returned_resource.sync_token.HasData())
+ returned_resource.sync_token = new_sync_token;
}
}