Commit 5866d63f authored by Vasiliy Telezhnikov's avatar Vasiliy Telezhnikov Committed by Commit Bot

Move (Begin/End)BatchReadAccessSharedImage to GLRenderer

GLRenderer/Webview use (Begin/End)BatchReadAccessSharedImage commands
to mark begin/end frame in SharedImageBatchAccessManager. Currently it's
tied to ScopedBatchedReturnResources which issues
EndBatchReadAccessSharedImage after DrawAndSwap was done and so the
command won't be flushed till next frame which leaves SharedImage in
state where EndRead was called, but no fence was produced.

To fix it and avoid extra flush move it to GLRenderer BeginDrawingFrame
and FinishDrawingFrame, so it will be flushed with SwapBuffers call.

Change-Id: I4452213c3081a700a991349d40aa65ea00a49dbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2302414Reviewed-by: default avatarJonathan Backer <backer@chromium.org>
Commit-Queue: Vasiliy Telezhnikov <vasilyt@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790618}
parent 78c0d5df
......@@ -785,17 +785,11 @@ void DisplayResourceProvider::TryFlushBatchedResources() {
void DisplayResourceProvider::SetBatchReturnResources(bool batch) {
if (batch) {
DCHECK_GE(batch_return_resources_lock_count_, 0);
if (!scoped_batch_read_access_) {
scoped_batch_read_access_ =
std::make_unique<ScopedBatchReadAccess>(ContextGL());
}
batch_return_resources_lock_count_++;
} else {
DCHECK_GT(batch_return_resources_lock_count_, 0);
batch_return_resources_lock_count_--;
if (batch_return_resources_lock_count_ == 0) {
DCHECK(scoped_batch_read_access_);
scoped_batch_read_access_.reset();
TryFlushBatchedResources();
}
}
......@@ -1119,16 +1113,4 @@ void DisplayResourceProvider::ChildResource::UpdateSyncToken(
synchronization_state_ = sync_token.HasData() ? NEEDS_WAIT : SYNCHRONIZED;
}
DisplayResourceProvider::ScopedBatchReadAccess::ScopedBatchReadAccess(
gpu::gles2::GLES2Interface* gl)
: gl_(gl) {
if (gl_)
gl_->BeginBatchReadAccessSharedImageCHROMIUM();
}
DisplayResourceProvider::ScopedBatchReadAccess::~ScopedBatchReadAccess() {
if (gl_)
gl_->EndBatchReadAccessSharedImageCHROMIUM();
}
} // namespace viz
......@@ -494,18 +494,6 @@ class VIZ_SERVICE_EXPORT DisplayResourceProvider
gpu::SyncToken sync_token_;
};
// Class to do Scoped Begin/End read access on a batch of shared images.
class ScopedBatchReadAccess {
public:
explicit ScopedBatchReadAccess(gpu::gles2::GLES2Interface* gl);
~ScopedBatchReadAccess();
private:
gpu::gles2::GLES2Interface* gl_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(ScopedBatchReadAccess);
};
using ChildMap = std::unordered_map<int, Child>;
using ResourceMap = std::unordered_map<ResourceId, ChildResource>;
......@@ -583,7 +571,6 @@ class VIZ_SERVICE_EXPORT DisplayResourceProvider
#endif
bool enable_shared_images_;
std::unique_ptr<ScopedBatchReadAccess> scoped_batch_read_access_;
// Indicates that gpu thread is available and calls like
// ReleaseImageContexts() are expected to finish in finite time. It's always
......
......@@ -510,6 +510,9 @@ void GLRenderer::BeginDrawingFrame() {
->ClientBecameBusy();
}
// Begin batching read of shared images.
gl_->BeginBatchReadAccessSharedImageCHROMIUM();
scoped_refptr<ResourceFence> read_lock_fence;
if (use_sync_query_) {
read_lock_fence = sync_queries_.StartNewFrame();
......@@ -2853,6 +2856,9 @@ void GLRenderer::FinishDrawingFrame() {
TRACE_COUNTER1(TRACE_DISABLED_BY_DEFAULT("viz.triangles"), "Triangles Drawn",
num_triangles_drawn_);
// Mark the end of batched read of shared images.
gl_->EndBatchReadAccessSharedImageCHROMIUM();
}
bool GLRenderer::OverdrawTracingEnabled() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment