Commit 704e8e0c authored by Peng Huang's avatar Peng Huang Committed by Commit Bot

Vulkan: Add Compositing.DirectRenderer.Vulkan.DrawFrameUs

Bug: 1016321
Change-Id: I50d285da5cfb1b3e8f8738c5fa16f5e85ebb2671
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1872456Reviewed-by: default avatarkylechar <kylechar@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: Peng Huang <penghuang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#708036}
parent 27853d5c
...@@ -580,12 +580,20 @@ bool Display::DrawAndSwap() { ...@@ -580,12 +580,20 @@ bool Display::DrawAndSwap() {
renderer_->DecideRenderPassAllocationsForFrame(frame.render_pass_list); renderer_->DecideRenderPassAllocationsForFrame(frame.render_pass_list);
renderer_->DrawFrame(&frame.render_pass_list, device_scale_factor_, renderer_->DrawFrame(&frame.render_pass_list, device_scale_factor_,
current_surface_size, sdr_white_level_); current_surface_size, sdr_white_level_);
if (software_renderer_) { switch (output_surface_->type()) {
UMA_HISTOGRAM_COUNTS_1M("Compositing.DirectRenderer.Software.DrawFrameUs", case OutputSurface::Type::kSoftware:
draw_timer->Elapsed().InMicroseconds()); UMA_HISTOGRAM_COUNTS_1M(
} else { "Compositing.DirectRenderer.Software.DrawFrameUs",
UMA_HISTOGRAM_COUNTS_1M("Compositing.DirectRenderer.GL.DrawFrameUs", draw_timer->Elapsed().InMicroseconds());
draw_timer->Elapsed().InMicroseconds()); break;
case OutputSurface::Type::kOpenGL:
UMA_HISTOGRAM_COUNTS_1M("Compositing.DirectRenderer.GL.DrawFrameUs",
draw_timer->Elapsed().InMicroseconds());
break;
case OutputSurface::Type::kVulkan:
UMA_HISTOGRAM_COUNTS_1M("Compositing.DirectRenderer.VK.DrawFrameUs",
draw_timer->Elapsed().InMicroseconds());
break;
} }
PresentationGroupTiming presentation_group_timing; PresentationGroupTiming presentation_group_timing;
......
...@@ -27,16 +27,16 @@ OutputSurface::Capabilities::Capabilities() = default; ...@@ -27,16 +27,16 @@ OutputSurface::Capabilities::Capabilities() = default;
OutputSurface::Capabilities::Capabilities(const Capabilities& capabilities) = OutputSurface::Capabilities::Capabilities(const Capabilities& capabilities) =
default; default;
OutputSurface::OutputSurface() = default; OutputSurface::OutputSurface(Type type) : type_(type) {}
OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider)
: context_provider_(std::move(context_provider)) { : context_provider_(std::move(context_provider)), type_(Type::kOpenGL) {
DCHECK(context_provider_); DCHECK(context_provider_);
} }
OutputSurface::OutputSurface( OutputSurface::OutputSurface(
std::unique_ptr<SoftwareOutputDevice> software_device) std::unique_ptr<SoftwareOutputDevice> software_device)
: software_device_(std::move(software_device)) { : software_device_(std::move(software_device)), type_(Type::kSoftware) {
DCHECK(software_device_); DCHECK(software_device_);
} }
......
...@@ -42,6 +42,11 @@ class SkiaOutputSurface; ...@@ -42,6 +42,11 @@ class SkiaOutputSurface;
// can provide platform-specific behaviour. // can provide platform-specific behaviour.
class VIZ_SERVICE_EXPORT OutputSurface { class VIZ_SERVICE_EXPORT OutputSurface {
public: public:
enum Type {
kSoftware = 0,
kOpenGL = 1,
kVulkan = 2,
};
struct Capabilities { struct Capabilities {
Capabilities(); Capabilities();
Capabilities(const Capabilities& capabilities); Capabilities(const Capabilities& capabilities);
...@@ -87,7 +92,7 @@ class VIZ_SERVICE_EXPORT OutputSurface { ...@@ -87,7 +92,7 @@ class VIZ_SERVICE_EXPORT OutputSurface {
}; };
// Constructor for skia-based compositing. // Constructor for skia-based compositing.
OutputSurface(); explicit OutputSurface(Type type);
// Constructor for GL-based compositing. // Constructor for GL-based compositing.
explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); explicit OutputSurface(scoped_refptr<ContextProvider> context_provider);
// Constructor for software compositing. // Constructor for software compositing.
...@@ -96,6 +101,7 @@ class VIZ_SERVICE_EXPORT OutputSurface { ...@@ -96,6 +101,7 @@ class VIZ_SERVICE_EXPORT OutputSurface {
virtual ~OutputSurface(); virtual ~OutputSurface();
const Capabilities& capabilities() const { return capabilities_; } const Capabilities& capabilities() const { return capabilities_; }
Type type() const { return type_; }
// Obtain the 3d context or the software device associated with this output // Obtain the 3d context or the software device associated with this output
// surface. Either of these may return a null pointer, but not both. // surface. Either of these may return a null pointer, but not both.
...@@ -229,6 +235,7 @@ class VIZ_SERVICE_EXPORT OutputSurface { ...@@ -229,6 +235,7 @@ class VIZ_SERVICE_EXPORT OutputSurface {
std::unique_ptr<SoftwareOutputDevice> software_device_; std::unique_ptr<SoftwareOutputDevice> software_device_;
private: private:
const Type type_;
SkMatrix44 color_matrix_; SkMatrix44 color_matrix_;
DISALLOW_COPY_AND_ASSIGN(OutputSurface); DISALLOW_COPY_AND_ASSIGN(OutputSurface);
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
namespace viz { namespace viz {
SkiaOutputSurface::SkiaOutputSurface() = default; SkiaOutputSurface::SkiaOutputSurface(OutputSurface::Type type)
: OutputSurface(type) {}
SkiaOutputSurface::~SkiaOutputSurface() = default; SkiaOutputSurface::~SkiaOutputSurface() = default;
......
...@@ -39,7 +39,7 @@ struct RenderPassGeometry; ...@@ -39,7 +39,7 @@ struct RenderPassGeometry;
class VIZ_SERVICE_EXPORT SkiaOutputSurface : public OutputSurface, class VIZ_SERVICE_EXPORT SkiaOutputSurface : public OutputSurface,
public ExternalUseClient { public ExternalUseClient {
public: public:
SkiaOutputSurface(); explicit SkiaOutputSurface(OutputSurface::Type type);
~SkiaOutputSurface() override; ~SkiaOutputSurface() override;
SkiaOutputSurface* AsSkiaOutputSurface() override; SkiaOutputSurface* AsSkiaOutputSurface() override;
......
...@@ -92,6 +92,12 @@ gpu::ContextUrl& GetActiveUrl() { ...@@ -92,6 +92,12 @@ gpu::ContextUrl& GetActiveUrl() {
return *active_url; return *active_url;
} }
OutputSurface::Type GetOutputSurfaceType(SkiaOutputSurfaceDependency* deps) {
// TODO(penghuang): Support more types.
return deps->IsUsingVulkan() ? OutputSurface::Type::kVulkan
: OutputSurface::Type::kOpenGL;
}
} // namespace } // namespace
SkiaOutputSurfaceImpl::ScopedPaint::ScopedPaint( SkiaOutputSurfaceImpl::ScopedPaint::ScopedPaint(
...@@ -124,7 +130,8 @@ SkiaOutputSurfaceImpl::SkiaOutputSurfaceImpl( ...@@ -124,7 +130,8 @@ SkiaOutputSurfaceImpl::SkiaOutputSurfaceImpl(
util::PassKey<SkiaOutputSurfaceImpl> /* pass_key */, util::PassKey<SkiaOutputSurfaceImpl> /* pass_key */,
std::unique_ptr<SkiaOutputSurfaceDependency> deps, std::unique_ptr<SkiaOutputSurfaceDependency> deps,
const RendererSettings& renderer_settings) const RendererSettings& renderer_settings)
: dependency_(std::move(deps)), : SkiaOutputSurface(GetOutputSurfaceType(deps.get())),
dependency_(std::move(deps)),
is_using_vulkan_(dependency_->IsUsingVulkan()), is_using_vulkan_(dependency_->IsUsingVulkan()),
renderer_settings_(renderer_settings) { renderer_settings_(renderer_settings) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_); DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
......
...@@ -28,7 +28,8 @@ namespace viz { ...@@ -28,7 +28,8 @@ namespace viz {
FakeSkiaOutputSurface::FakeSkiaOutputSurface( FakeSkiaOutputSurface::FakeSkiaOutputSurface(
scoped_refptr<ContextProvider> context_provider) scoped_refptr<ContextProvider> context_provider)
: context_provider_(std::move(context_provider)) { : SkiaOutputSurface(SkiaOutputSurface::Type::kOpenGL),
context_provider_(std::move(context_provider)) {
texture_deleter_ = texture_deleter_ =
std::make_unique<TextureDeleter>(base::ThreadTaskRunnerHandle::Get()); std::make_unique<TextureDeleter>(base::ThreadTaskRunnerHandle::Get());
} }
......
...@@ -22269,6 +22269,22 @@ uploading your change for review. ...@@ -22269,6 +22269,22 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Compositing.DirectRenderer.VK.DrawFrameUs"
units="microseconds" expires_after="2020-03-29">
<owner>penghuang@chromium.org</owner>
<summary>
Time spent drawing of composited layers by SkiaRenderer with Vulkan backend,
in microseconds. This is logged once per frame, when a frame should be
drawn.
Warning: This metric may include reports from clients with low-resolution
clocks (i.e. on Windows, ref. |TimeTicks::IsHighResolution()|). Such reports
will cause this metric to have an abnormal distribution. When considering
revising this histogram, see UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES for the
solution.
</summary>
</histogram>
<histogram name="Compositing.Display.Draw.Occlusion.Calculation.Time" <histogram name="Compositing.Display.Draw.Occlusion.Calculation.Time"
units="microseconds" expires_after="M82"> units="microseconds" expires_after="M82">
<owner>yiyix@chromium.org</owner> <owner>yiyix@chromium.org</owner>
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