diff options
author | dyen <dyen@chromium.org> | 2016-01-11 17:42:17 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-12 01:43:08 +0000 |
commit | bcd5048b5d3efa23b6742e8482c29c6dec82171d (patch) | |
tree | aac9698871000ccc9a012f6afd647de54b3afdce | |
parent | 55b3b326b591e5f176d4b7c753818f1328ff9b2b (diff) | |
download | chromium_src-bcd5048b5d3efa23b6742e8482c29c6dec82171d.zip chromium_src-bcd5048b5d3efa23b6742e8482c29c6dec82171d.tar.gz chromium_src-bcd5048b5d3efa23b6742e8482c29c6dec82171d.tar.bz2 |
Fixed an issue with verifying resource sync tokens.
The address of resource sync tokens were being stored in an array
before passing these addresses to VerifySyncTokensCHROMIUM(). There
were 2 problems with this:
1. We were storing the resource adress on the stack and not pushed
the one pushed into the TransferableResourceArray which is a
std::vector.
2. Even if we stored the address of the item within the vector,
the address could change as we push more items.
This could either be solved by storing the address within the vector
while simultaneously reserving the maximum amount of space used
which guarantees the address will not move, or storing the indexes
and getting the address after the vector is stable. I have opted
for the second option here.
I also fixed a small issue in VerifySyncTokensCHROMIUM() so that it
now handles invalid sync tokens being passed to be verified.
R=piman@chromium.org
BUG=514815
CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel
Review URL: https://codereview.chromium.org/1577103002
Cr-Commit-Position: refs/heads/master@{#368765}
-rw-r--r-- | cc/resources/resource_provider.cc | 14 | ||||
-rw-r--r-- | gpu/command_buffer/client/gles2_implementation.cc | 14 |
2 files changed, 19 insertions, 9 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index 6ef8d59..c1f4206 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -1149,7 +1149,7 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, bool need_sync_token = false; gpu::SyncToken new_sync_token; - std::vector<GLbyte*> unverified_sync_tokens; + std::vector<size_t> unverified_token_indexes; for (ResourceIdArray::const_iterator it = resources.begin(); it != resources.end(); ++it) { @@ -1160,14 +1160,22 @@ void ResourceProvider::PrepareSendToParent(const ResourceIdArray& resources, if (resource.mailbox_holder.sync_token.HasData() && !resource.mailbox_holder.sync_token.verified_flush()) { - unverified_sync_tokens.push_back( - resource.mailbox_holder.sync_token.GetData()); + unverified_token_indexes.push_back(list->size()); } ++resources_.find(*it)->second.exported_count; list->push_back(resource); } + // Fill out unverified sync tokens array. + std::vector<GLbyte*> unverified_sync_tokens; + unverified_sync_tokens.reserve(unverified_token_indexes.size() + 1); + for (auto it = unverified_token_indexes.begin(); + it != unverified_token_indexes.end(); ++it) { + unverified_sync_tokens.push_back( + list->at(*it).mailbox_holder.sync_token.GetData()); + } + if (need_sync_token && output_surface_->capabilities().delegated_sync_points_required) { const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); diff --git a/gpu/command_buffer/client/gles2_implementation.cc b/gpu/command_buffer/client/gles2_implementation.cc index 20ce878..1ae946d 100644 --- a/gpu/command_buffer/client/gles2_implementation.cc +++ b/gpu/command_buffer/client/gles2_implementation.cc @@ -5638,7 +5638,7 @@ void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens, SyncToken sync_token; memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); - if (!sync_token.verified_flush()) { + if (sync_token.HasData() && !sync_token.verified_flush()) { if (!gpu_control_->CanWaitUnverifiedSyncToken(&sync_token)) { SetGLError(GL_INVALID_VALUE, "glVerifySyncTokensCHROMIUM", "Cannot verify sync token using this context."); @@ -5661,11 +5661,13 @@ void GLES2Implementation::VerifySyncTokensCHROMIUM(GLbyte **sync_tokens, // We can automatically mark everything as verified now. for (GLsizei i = 0; i < count; ++i) { - SyncToken sync_token; - memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); - if (!sync_token.verified_flush()) { - sync_token.SetVerifyFlush(); - memcpy(sync_tokens[i], &sync_token, sizeof(sync_token)); + if (sync_tokens[i]) { + SyncToken sync_token; + memcpy(&sync_token, sync_tokens[i], sizeof(sync_token)); + if (sync_token.HasData() && !sync_token.verified_flush()) { + sync_token.SetVerifyFlush(); + memcpy(sync_tokens[i], &sync_token, sizeof(sync_token)); + } } } } |