Commit 1ca9e4ab authored by Klaus Weidner's avatar Klaus Weidner Committed by Commit Bot

GPU: Add SyncToken::ToDebugString()

This is intended as a convenience for debugging synchronization issues
related to sync tokens.

The output is in the format "a:b:c:d", i.e. "0:1:4:16", where a is
the namespace_id, b/c are the upper and lower half of the 64bit command
buffer ID (corresponding to channel and route ID for gpu/ipc/ usage),
and d is the release count.

Change-Id: I2cbc1ce9cff56d8b83bfa582ce4702f7459005c3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2324869
Commit-Queue: Kenneth Russell <kbr@chromium.org>
Auto-Submit: Klaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarKenneth Russell <kbr@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Reviewed-by: default avatarPiotr Bialecki <bialpio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794776}
parent 838d49c2
......@@ -172,7 +172,8 @@ bool ArImageTransport::ResizeSharedBuffer(vr::WebXrPresentationState* webxr,
buffer->mailbox_holder = mailbox_bridge_->CreateSharedImage(
buffer->gmb.get(), gfx::ColorSpace(), shared_image_usage);
DVLOG(2) << ": CreateSharedImage, mailbox="
<< buffer->mailbox_holder.mailbox.ToDebugString();
<< buffer->mailbox_holder.mailbox.ToDebugString() << ", SyncToken="
<< buffer->mailbox_holder.sync_token.ToDebugString();
auto img = base::MakeRefCounted<gl::GLImageAHardwareBuffer>(size);
......@@ -230,6 +231,8 @@ gpu::MailboxHolder ArImageTransport::TransferFrame(
// that it's transitioned through "processing" and "rendering" states back
// to "animating".
DCHECK(shared_buffer->mailbox_holder.sync_token.HasData());
DVLOG(2) << ": SyncToken="
<< shared_buffer->mailbox_holder.sync_token.ToDebugString();
return shared_buffer->mailbox_holder;
}
......
......@@ -4,6 +4,8 @@
#include "gpu/command_buffer/common/sync_token.h"
#include <sstream>
namespace gpu {
SyncToken::SyncToken()
......@@ -21,4 +23,19 @@ SyncToken::SyncToken(CommandBufferNamespace namespace_id,
SyncToken::SyncToken(const SyncToken& other) = default;
std::string SyncToken::ToDebugString() const {
// At the level of the generic command buffer code, the command buffer ID is
// an arbitrary 64-bit number. For the debug output, print its upper and lower
// 32bit words separately. This ensures more readable output for IDs allocated
// by gpu/ipc code which uses these words for channel and route IDs, but it's
// still a lossless representation if the IDs don't match this convention.
uint64_t id = command_buffer_id().GetUnsafeValue();
uint32_t channel_or_high = 0xffffffff & id;
uint32_t route_or_low = id >> 32;
std::ostringstream stream;
stream << static_cast<int>(namespace_id()) << ":" << channel_or_high << ":"
<< route_or_low << ":" << release_count();
return stream.str();
}
} // namespace gpu
......@@ -83,6 +83,8 @@ struct GPU_EXPORT SyncToken {
bool operator!=(const SyncToken& other) const { return !(*this == other); }
std::string ToDebugString() const;
private:
bool verified_flush_;
CommandBufferNamespace namespace_id_;
......
......@@ -216,8 +216,6 @@ IntSize XRWebGLDrawingBuffer::AdjustSize(const IntSize& new_size) {
void XRWebGLDrawingBuffer::UseSharedBuffer(
const gpu::MailboxHolder& buffer_mailbox_holder) {
DVLOG(3) << __FUNCTION__;
gpu::gles2::GLES2Interface* gl = drawing_buffer_->ContextGL();
// Ensure that the mailbox holder is ready to use, the following actions need
......@@ -228,6 +226,10 @@ void XRWebGLDrawingBuffer::UseSharedBuffer(
// recovery for cases where these assumptions may not be accurate.
DCHECK(buffer_mailbox_holder.sync_token.HasData());
DCHECK(!buffer_mailbox_holder.mailbox.IsZero());
DVLOG(3) << __func__
<< ": mailbox=" << buffer_mailbox_holder.mailbox.ToDebugString()
<< ", SyncToken="
<< buffer_mailbox_holder.sync_token.ToDebugString();
gl->WaitSyncTokenCHROMIUM(buffer_mailbox_holder.sync_token.GetConstData());
// Create a texture backed by the shared buffer image.
......
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