diff options
author | dyen <dyen@chromium.org> | 2016-02-23 18:46:02 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-24 02:47:24 +0000 |
commit | 7e9fd7734fc93011d9058d90646b02345424e252 (patch) | |
tree | 178198636ba2ac98e2fd9713428a899751deec66 | |
parent | 5cbaa77d1bf5dc22647a93919149106deabf4723 (diff) | |
download | chromium_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}
-rw-r--r-- | cc/layers/heads_up_display_layer_impl.cc | 1 | ||||
-rw-r--r-- | cc/layers/texture_layer_impl.cc | 1 | ||||
-rw-r--r-- | cc/quads/draw_quad.h | 6 | ||||
-rw-r--r-- | cc/resources/resource_provider.cc | 50 |
4 files changed, 42 insertions, 16 deletions
diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 55e13e7..6606c0f 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -207,6 +207,7 @@ void HeadsUpDisplayLayerImpl::UpdateHudTexture( resource_provider->CopyToResource(resources_.back()->id(), static_cast<const uint8_t*>(pixels), internal_content_bounds_); + resource_provider->GenerateSyncTokenForResource(resources_.back()->id()); } void HeadsUpDisplayLayerImpl::ReleaseResources() { diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index 0d2f4e7..8b1a8cb 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -131,6 +131,7 @@ bool TextureLayerImpl::WillDraw(DrawMode draw_mode, resource_provider->CopyToResource(texture_copy_->id(), pixels, texture_mailbox_.size_in_pixels()); + resource_provider->GenerateSyncTokenForResource(texture_copy_->id()); valid_texture_copy_ = true; } diff --git a/cc/quads/draw_quad.h b/cc/quads/draw_quad.h index bf824c1..8cf0eee 100644 --- a/cc/quads/draw_quad.h +++ b/cc/quads/draw_quad.h @@ -124,6 +124,12 @@ class CC_EXPORT DrawQuad { return ids + count; } + const ResourceId* const_begin() const { return ids; } + const ResourceId* const_end() const { + DCHECK_LE(count, kMaxResourceIdCount); + return ids + count; + } + uint32_t count; ResourceId ids[kMaxResourceIdCount]; }; 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; } } |