Commit 06838799 authored by Sean Gilhuly's avatar Sean Gilhuly Committed by Commit Bot

Submit presentation feedback with Skia Dawn

On Windows, create a VsyncProviderWin in SkiaOutputDeviceDawn. Then
following each swap buffers, use the current timestamp snapped to the
next vsync interval as the presentation time.

Bug: 1021566
Change-Id: Id7e1fb3ec4c4d63517e556be6e36a824356e7e7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2154596Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Commit-Queue: Sean Gilhuly <sgilhuly@chromium.org>
Cr-Commit-Position: refs/heads/master@{#760569}
parent 4f4d3af5
......@@ -51,10 +51,16 @@ wgpu::Device DawnContextProvider::CreateDevice(dawn_native::BackendType type) {
DawnProcTable backend_procs = dawn_native::GetProcs();
dawnProcSetProcs(&backend_procs);
// Disable validation in non-DCHECK builds.
dawn_native::DeviceDescriptor descriptor;
#if !DCHECK_IS_ON()
descriptor.forceEnabledToggles = {"skip_validation"};
#endif
std::vector<dawn_native::Adapter> adapters = instance_.GetAdapters();
for (dawn_native::Adapter adapter : adapters) {
if (adapter.GetBackendType() == type)
return adapter.CreateDevice();
return adapter.CreateDevice(&descriptor);
}
return nullptr;
}
......
......@@ -7,9 +7,13 @@
#include "base/logging.h"
#include "build/build_config.h"
#include "components/viz/common/gpu/dawn_context_provider.h"
#include "ui/gfx/presentation_feedback.h"
#include "ui/gfx/vsync_provider.h"
#if defined(OS_WIN)
#include <dawn_native/D3D12Backend.h>
#include "ui/gl/vsync_provider_win.h"
#elif defined(OS_LINUX)
#include <dawn_native/VulkanBackend.h>
#endif
......@@ -46,6 +50,10 @@ SkiaOutputDeviceDawn::SkiaOutputDeviceDawn(
capabilities_.gr_backend_format =
context_provider_->GetGrContext()->defaultBackendFormat(
kSurfaceColorType, GrRenderable::kYes);
#if defined(OS_WIN)
vsync_provider_ = std::make_unique<gl::VSyncProviderWin>(widget_);
#endif
}
SkiaOutputDeviceDawn::~SkiaOutputDeviceDawn() = default;
......@@ -76,11 +84,28 @@ bool SkiaOutputDeviceDawn::Reshape(const gfx::Size& size,
void SkiaOutputDeviceDawn::SwapBuffers(
BufferPresentedCallback feedback,
std::vector<ui::LatencyInfo> latency_info) {
StartSwapBuffers(std::move(feedback));
StartSwapBuffers({});
swap_chain_.Present();
FinishSwapBuffers(gfx::SwapResult::SWAP_ACK,
gfx::Size(size_.width(), size_.height()),
std::move(latency_info));
base::TimeTicks timestamp = base::TimeTicks::Now();
base::TimeTicks vsync_timebase;
base::TimeDelta vsync_interval;
uint32_t flags = 0;
// TODO(sgilhuly): Add an async path for getting vsync parameters. The sync
// path is sufficient for VSyncProviderWin.
if (vsync_provider_ && vsync_provider_->GetVSyncParametersIfAvailable(
&vsync_timebase, &vsync_interval)) {
// Assume the buffer will be presented at the next vblank.
timestamp = timestamp.SnappedToNextTick(vsync_timebase, vsync_interval);
// kHWClock allows future timestamps to be accepted.
flags =
gfx::PresentationFeedback::kVSync | gfx::PresentationFeedback::kHWClock;
}
std::move(feedback).Run(
gfx::PresentationFeedback(timestamp, vsync_interval, flags));
}
SkSurface* SkiaOutputDeviceDawn::BeginPaint(
......
......@@ -51,6 +51,7 @@ class SkiaOutputDeviceDawn : public SkiaOutputDevice {
wgpu::SwapChain swap_chain_;
wgpu::Texture texture_;
sk_sp<SkSurface> sk_surface_;
std::unique_ptr<gfx::VSyncProvider> vsync_provider_;
gfx::Size size_;
sk_sp<SkColorSpace> sk_color_space_;
......
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