Bug 1893364 - Add more profiler markers around video overlay handing r=gfx-reviewers,jrmuizel

Differential Revision: https://phabricator.services.mozilla.com/D208577
This commit is contained in:
sotaro 2024-04-25 04:12:07 +00:00
Родитель af2207ae5b
Коммит e68cd79db8
3 изменённых файлов: 51 добавлений и 6 удалений

Просмотреть файл

@ -14,6 +14,7 @@
#include "mozilla/layers/GpuProcessD3D11TextureMap.h"
#include "mozilla/layers/TextureD3D11.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/SharedThreadPool.h"
namespace mozilla {
@ -236,6 +237,14 @@ RefPtr<TextureHost> TextureHostWrapperD3D11::CreateFromBufferTexture(
colorDepth != gfx::ColorDepth::COLOR_8 ||
colorRange != gfx::ColorRange::LIMITED ||
chromaSubsampling != gfx::ChromaSubsampling::HALF_WIDTH_AND_HEIGHT) {
if (profiler_thread_is_being_profiled_for_markers()) {
nsPrintfCString str(
"Unsupported size(%dx%d) colorDepth %hhu colorRange %hhu "
"chromaSubsampling %hhu",
size.width, size.height, uint8_t(colorDepth), uint8_t(colorRange),
uint8_t(chromaSubsampling));
PROFILER_MARKER_TEXT("TextureHostWrapperD3D11", GRAPHICS, {}, str);
}
return nullptr;
}

Просмотреть файл

@ -18,6 +18,7 @@
#include "mozilla/layers/RemoteTextureMap.h"
#include "mozilla/layers/WebRenderBridgeParent.h"
#include "mozilla/layers/WebRenderTextureHost.h"
#include "mozilla/ProfilerMarkers.h"
#include "mozilla/StaticPrefs_webgl.h"
#include "nsAString.h"
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
@ -311,12 +312,15 @@ TextureHost* WebRenderImageHost::GetAsTextureHostForComposite(
// Convert YUV BufferTextureHost to TextureHostWrapperD3D11 if possible
if (texture->AsBufferTextureHost()) {
auto identifier = aAsyncImageManager->GetTextureFactoryIdentifier();
const bool convertToNV12 =
const bool tryConvertToNV12 =
StaticPrefs::gfx_video_convert_yuv_to_nv12_image_host_win() &&
identifier.mSupportsD3D11NV12 &&
KnowsCompositor::SupportsD3D11(identifier) &&
texture->GetFormat() == gfx::SurfaceFormat::YUV;
if (convertToNV12) {
if (tryConvertToNV12) {
PROFILER_MARKER_TEXT("WebRenderImageHost", GRAPHICS, {},
"Try ConvertToNV12"_ns);
if (!mTextureAllocator) {
mTextureAllocator = new TextureWrapperD3D11Allocator();
}
@ -326,6 +330,13 @@ TextureHost* WebRenderImageHost::GetAsTextureHostForComposite(
if (textureWrapper) {
texture = textureWrapper;
}
} else if (profiler_thread_is_being_profiled_for_markers() &&
StaticPrefs::gfx_video_convert_yuv_to_nv12_image_host_win() &&
texture->GetFormat() == gfx::SurfaceFormat::YUV) {
nsPrintfCString str("No ConvertToNV12 D3D11 %d NV12 %d",
KnowsCompositor::SupportsD3D11(identifier),
identifier.mSupportsD3D11NV12);
PROFILER_MARKER_TEXT("WebRenderImageHost", GRAPHICS, {}, str);
}
}
#endif

Просмотреть файл

@ -1355,7 +1355,7 @@ bool DCSurfaceVideo::CalculateSwapChainSize(gfx::Matrix& aTransform) {
MOZ_ASSERT(mDCLayerTree->GetVideoProcessor());
const UINT vendorId = GetVendorId(mDCLayerTree->GetVideoDevice());
const bool driverSupportsTrueHDR =
const bool driverSupportsAutoHDR =
GetVpAutoHDRSupported(vendorId, mDCLayerTree->GetVideoContext(),
mDCLayerTree->GetVideoProcessor());
const bool contentIsHDR = false; // XXX for now, only non-HDR is supported.
@ -1364,9 +1364,18 @@ bool DCSurfaceVideo::CalculateSwapChainSize(gfx::Matrix& aTransform) {
const bool powerIsCharging = RenderThread::Get()->GetPowerIsCharging();
bool useVpAutoHDR = gfx::gfxVars::WebRenderOverlayVpAutoHDR() &&
!contentIsHDR && monitorIsHDR && driverSupportsTrueHDR &&
!contentIsHDR && monitorIsHDR && driverSupportsAutoHDR &&
powerIsCharging && !mVpAutoHDRFailed;
if (profiler_thread_is_being_profiled_for_markers()) {
nsPrintfCString str(
"useVpAutoHDR %d gfxVars %d contentIsHDR %d monitor %d driver %d "
"charging %d failed %d",
useVpAutoHDR, gfx::gfxVars::WebRenderOverlayVpAutoHDR(), contentIsHDR,
monitorIsHDR, driverSupportsAutoHDR, powerIsCharging, mVpAutoHDRFailed);
PROFILER_MARKER_TEXT("DCSurfaceVideo", GRAPHICS, {}, str);
}
if (!mVideoSwapChain || mSwapChainSize != swapChainSize || mIsDRM != isDRM ||
mUseVpAutoHDR != useVpAutoHDR) {
needsToPresent = true;
@ -1791,8 +1800,22 @@ bool DCSurfaceVideo::CallVideoProcessorBlt() {
const UINT vendorId = GetVendorId(videoDevice);
const auto powerIsCharging = RenderThread::Get()->GetPowerIsCharging();
if (gfx::gfxVars::WebRenderOverlayVpSuperResolution() &&
!mVpSuperResolutionFailed && powerIsCharging) {
const bool useSuperResolution =
gfx::gfxVars::WebRenderOverlayVpSuperResolution() && powerIsCharging &&
!mVpSuperResolutionFailed;
if (profiler_thread_is_being_profiled_for_markers()) {
nsPrintfCString str(
"useSuperResolution %d gfxVars %d charging %d failed %d",
useSuperResolution, gfx::gfxVars::WebRenderOverlayVpSuperResolution(),
powerIsCharging, mVpSuperResolutionFailed);
PROFILER_MARKER_TEXT("DCSurfaceVideo", GRAPHICS, {}, str);
}
if (useSuperResolution) {
PROFILER_MARKER_TEXT("DCSurfaceVideo", GRAPHICS, {},
"SetVpSuperResolution"_ns);
hr = SetVpSuperResolution(vendorId, videoContext, videoProcessor, true);
if (FAILED(hr)) {
if (hr != E_NOTIMPL) {
@ -1803,6 +1826,8 @@ bool DCSurfaceVideo::CallVideoProcessorBlt() {
}
if (mUseVpAutoHDR) {
PROFILER_MARKER_TEXT("DCSurfaceVideo", GRAPHICS, {}, "SetVpAutoHDR"_ns);
hr = SetVpAutoHDR(vendorId, videoContext, videoProcessor, true);
if (FAILED(hr)) {
gfxCriticalNoteOnce << "SetVpAutoHDR failed: " << gfx::hexa(hr);