Commit 922160ed authored by Alexandros Frantzis's avatar Alexandros Frantzis Committed by Commit Bot

gfx: Add GpuFence::Wait() method

Provide a GpuFence::Wait() method to hide the implementation details of
waiting for a GpuFence object.

Bug: 828393
Change-Id: I2153ebcb4b8cca6bb43c827fb0a9740f6a6cc221
Reviewed-on: https://chromium-review.googlesource.com/1021513Reviewed-by: default avatarDavid Reveman <reveman@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559292}
parent e7f10708
...@@ -567,6 +567,10 @@ source_set("memory_buffer_sources") { ...@@ -567,6 +567,10 @@ source_set("memory_buffer_sources") {
deps += [ "//third_party/libdrm" ] deps += [ "//third_party/libdrm" ]
} }
if (is_linux || is_android) {
deps += [ "//third_party/libsync" ]
}
if (is_mac) { if (is_mac) {
sources += [ sources += [
"mac/io_surface.cc", "mac/io_surface.cc",
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
#include "base/logging.h" #include "base/logging.h"
#if defined(OS_LINUX) || defined(OS_ANDROID)
#include <sync/sync.h>
#endif
namespace gfx { namespace gfx {
GpuFence::GpuFence(const GpuFenceHandle& handle) : type_(handle.type) { GpuFence::GpuFence(const GpuFenceHandle& handle) : type_(handle.type) {
...@@ -51,4 +55,22 @@ GpuFence* GpuFence::FromClientGpuFence(ClientGpuFence gpu_fence) { ...@@ -51,4 +55,22 @@ GpuFence* GpuFence::FromClientGpuFence(ClientGpuFence gpu_fence) {
return reinterpret_cast<GpuFence*>(gpu_fence); return reinterpret_cast<GpuFence*>(gpu_fence);
} }
void GpuFence::Wait() {
switch (type_) {
case GpuFenceHandleType::kEmpty:
break;
case GpuFenceHandleType::kAndroidNativeFenceSync:
#if defined(OS_LINUX) || defined(OS_ANDROID)
static const int kInfiniteSyncWaitTimeout = -1;
DCHECK_GE(owned_fd_.get(), 0);
if (sync_wait(owned_fd_.get(), kInfiniteSyncWaitTimeout) < 0) {
LOG(FATAL) << "Failed while waiting for gpu fence fd";
}
#else
NOTREACHED();
#endif
break;
}
}
} // namespace gfx } // namespace gfx
...@@ -32,6 +32,9 @@ class GFX_EXPORT GpuFence { ...@@ -32,6 +32,9 @@ class GFX_EXPORT GpuFence {
ClientGpuFence AsClientGpuFence(); ClientGpuFence AsClientGpuFence();
static GpuFence* FromClientGpuFence(ClientGpuFence gpu_fence); static GpuFence* FromClientGpuFence(ClientGpuFence gpu_fence);
// Wait for the GpuFence to become ready.
void Wait();
private: private:
gfx::GpuFenceHandleType type_; gfx::GpuFenceHandleType type_;
#if defined(OS_POSIX) #if defined(OS_POSIX)
......
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