Commit ca612692 authored by Zhenyao Mo's avatar Zhenyao Mo Committed by Commit Bot

Add pixel format support flags on Windows.

The flags are queried through ID3D11Device::CheckFormatSupport().

Hopefully they can be used to bypass YUY2 related tests on AMD
where creating a YUY2 swap chain fails.

Also, they can be useful diagnosing swap chain related issues
from user machines, i.e., whether we assumed certain capabilities
without checking.

BUG=967860
TEST=bots
R=sunnyps@chromium.org,piman@chromium.org

Change-Id: I5dff9069b2fc53851cbffc5263bd4a2e0e03582f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1637195Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Reviewed-by: default avatarSunny Sachanandani <sunnyps@chromium.org>
Commit-Queue: Zhenyao Mo <zmo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665218}
parent bd7533d4
...@@ -184,6 +184,15 @@ std::unique_ptr<base::ListValue> BasicGpuInfoAsListValue( ...@@ -184,6 +184,15 @@ std::unique_ptr<base::ListValue> BasicGpuInfoAsListValue(
basic_info->Append(NewDescriptionValuePair( basic_info->Append(NewDescriptionValuePair(
"Direct composition", "Direct composition",
std::make_unique<base::Value>(gpu_info.direct_composition))); std::make_unique<base::Value>(gpu_info.direct_composition)));
basic_info->Append(NewDescriptionValuePair(
"BGRA format support",
base::StringPrintf("0x%08x", gpu_info.bgra_format_support)));
basic_info->Append(NewDescriptionValuePair(
"YUY2 format support",
base::StringPrintf("0x%08x", gpu_info.yuy2_format_support)));
basic_info->Append(NewDescriptionValuePair(
"NV12 format support",
base::StringPrintf("0x%08x", gpu_info.nv12_format_support)));
basic_info->Append(NewDescriptionValuePair( basic_info->Append(NewDescriptionValuePair(
"Supports overlays", "Supports overlays",
std::make_unique<base::Value>(gpu_info.supports_overlays))); std::make_unique<base::Value>(gpu_info.supports_overlays)));
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include <stdint.h> #include <stdint.h>
#include "base/strings/stringprintf.h"
#include "gpu/config/gpu_info.h" #include "gpu/config/gpu_info.h"
namespace { namespace {
...@@ -236,6 +237,9 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -236,6 +237,9 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
bool can_support_threaded_texture_mailbox; bool can_support_threaded_texture_mailbox;
#if defined(OS_WIN) #if defined(OS_WIN)
bool direct_composition; bool direct_composition;
uint32_t bgra_format_support;
uint32_t yuy2_format_support;
uint32_t nv12_format_support;
bool supports_overlays; bool supports_overlays;
OverlaySupport yuy2_overlay_support; OverlaySupport yuy2_overlay_support;
OverlaySupport nv12_overlay_support; OverlaySupport nv12_overlay_support;
...@@ -301,6 +305,12 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { ...@@ -301,6 +305,12 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const {
// TODO(kbr): add dx_diagnostics on Windows. // TODO(kbr): add dx_diagnostics on Windows.
#if defined(OS_WIN) #if defined(OS_WIN)
enumerator->AddBool("directComposition", direct_composition); enumerator->AddBool("directComposition", direct_composition);
enumerator->AddString("bgraFormatSupport",
base::StringPrintf("0x%08x", bgra_format_support));
enumerator->AddString("yuy2FormatSupport",
base::StringPrintf("0x%08x", yuy2_format_support));
enumerator->AddString("nv12FormatSupport",
base::StringPrintf("0x%08x", nv12_format_support));
enumerator->AddBool("supportsOverlays", supports_overlays); enumerator->AddBool("supportsOverlays", supports_overlays);
enumerator->AddString("yuy2OverlaySupport", enumerator->AddString("yuy2OverlaySupport",
OverlaySupportToString(yuy2_overlay_support)); OverlaySupportToString(yuy2_overlay_support));
......
...@@ -310,6 +310,10 @@ struct GPU_EXPORT GPUInfo { ...@@ -310,6 +310,10 @@ struct GPU_EXPORT GPUInfo {
#if defined(OS_WIN) #if defined(OS_WIN)
// True if we use direct composition surface on Windows. // True if we use direct composition surface on Windows.
bool direct_composition = false; bool direct_composition = false;
// The information returned by ID3D11Device::CheckFormatSupport().
uint32_t bgra_format_support = 0;
uint32_t yuy2_format_support = 0;
uint32_t nv12_format_support = 0;
// True if we use direct composition surface overlays on Windows. // True if we use direct composition surface overlays on Windows.
bool supports_overlays = false; bool supports_overlays = false;
......
...@@ -144,6 +144,12 @@ struct GpuInfo { ...@@ -144,6 +144,12 @@ struct GpuInfo {
[EnableIf=is_win] [EnableIf=is_win]
bool direct_composition; bool direct_composition;
[EnableIf=is_win] [EnableIf=is_win]
uint32 bgra_format_support;
[EnableIf=is_win]
uint32 yuy2_format_support;
[EnableIf=is_win]
uint32 nv12_format_support;
[EnableIf=is_win]
bool supports_overlays; bool supports_overlays;
[EnableIf=is_win] [EnableIf=is_win]
OverlaySupport yuy2_overlay_support; OverlaySupport yuy2_overlay_support;
......
...@@ -363,6 +363,9 @@ bool StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo>::Read( ...@@ -363,6 +363,9 @@ bool StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo>::Read(
#if defined(OS_WIN) #if defined(OS_WIN)
out->direct_composition = data.direct_composition(); out->direct_composition = data.direct_composition();
out->bgra_format_support = data.bgra_format_support();
out->yuy2_format_support = data.yuy2_format_support();
out->nv12_format_support = data.nv12_format_support();
out->supports_overlays = data.supports_overlays(); out->supports_overlays = data.supports_overlays();
#endif #endif
......
...@@ -322,6 +322,18 @@ struct StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo> { ...@@ -322,6 +322,18 @@ struct StructTraits<gpu::mojom::GpuInfoDataView, gpu::GPUInfo> {
return input.direct_composition; return input.direct_composition;
} }
static uint32_t bgra_format_support(const gpu::GPUInfo& input) {
return input.bgra_format_support;
}
static uint32_t yuy2_format_support(const gpu::GPUInfo& input) {
return input.yuy2_format_support;
}
static uint32_t nv12_format_support(const gpu::GPUInfo& input) {
return input.nv12_format_support;
}
static bool supports_overlays(const gpu::GPUInfo& input) { static bool supports_overlays(const gpu::GPUInfo& input) {
return input.supports_overlays; return input.supports_overlays;
} }
......
...@@ -155,6 +155,9 @@ TEST_F(StructTraitsTest, GpuInfo) { ...@@ -155,6 +155,9 @@ TEST_F(StructTraitsTest, GpuInfo) {
const bool passthrough_cmd_decoder = true; const bool passthrough_cmd_decoder = true;
#if defined(OS_WIN) #if defined(OS_WIN)
const bool direct_composition = true; const bool direct_composition = true;
const uint32_t bgra_format_support = 0x33fef3f3;
const uint32_t yuy2_format_support = 0x3a820320;
const uint32_t nv12_format_support = 0xfa82c320;
const bool supports_overlays = true; const bool supports_overlays = true;
const OverlaySupport yuy2_overlay_support = OverlaySupport::kScaling; const OverlaySupport yuy2_overlay_support = OverlaySupport::kScaling;
const OverlaySupport nv12_overlay_support = OverlaySupport::kNone; const OverlaySupport nv12_overlay_support = OverlaySupport::kNone;
...@@ -199,6 +202,9 @@ TEST_F(StructTraitsTest, GpuInfo) { ...@@ -199,6 +202,9 @@ TEST_F(StructTraitsTest, GpuInfo) {
input.passthrough_cmd_decoder = passthrough_cmd_decoder; input.passthrough_cmd_decoder = passthrough_cmd_decoder;
#if defined(OS_WIN) #if defined(OS_WIN)
input.direct_composition = direct_composition; input.direct_composition = direct_composition;
input.bgra_format_support = bgra_format_support;
input.yuy2_format_support = yuy2_format_support;
input.nv12_format_support = nv12_format_support;
input.supports_overlays = supports_overlays; input.supports_overlays = supports_overlays;
input.yuy2_overlay_support = yuy2_overlay_support; input.yuy2_overlay_support = yuy2_overlay_support;
input.nv12_overlay_support = nv12_overlay_support; input.nv12_overlay_support = nv12_overlay_support;
...@@ -259,6 +265,9 @@ TEST_F(StructTraitsTest, GpuInfo) { ...@@ -259,6 +265,9 @@ TEST_F(StructTraitsTest, GpuInfo) {
EXPECT_EQ(passthrough_cmd_decoder, output.passthrough_cmd_decoder); EXPECT_EQ(passthrough_cmd_decoder, output.passthrough_cmd_decoder);
#if defined(OS_WIN) #if defined(OS_WIN)
EXPECT_EQ(direct_composition, output.direct_composition); EXPECT_EQ(direct_composition, output.direct_composition);
EXPECT_EQ(bgra_format_support, output.bgra_format_support);
EXPECT_EQ(yuy2_format_support, output.yuy2_format_support);
EXPECT_EQ(nv12_format_support, output.nv12_format_support);
EXPECT_EQ(supports_overlays, output.supports_overlays); EXPECT_EQ(supports_overlays, output.supports_overlays);
EXPECT_EQ(yuy2_overlay_support, output.yuy2_overlay_support); EXPECT_EQ(yuy2_overlay_support, output.yuy2_overlay_support);
EXPECT_EQ(nv12_overlay_support, output.nv12_overlay_support); EXPECT_EQ(nv12_overlay_support, output.nv12_overlay_support);
......
...@@ -92,6 +92,15 @@ void InitializePlatformOverlaySettings(GPUInfo* gpu_info) { ...@@ -92,6 +92,15 @@ void InitializePlatformOverlaySettings(GPUInfo* gpu_info) {
DCHECK(gpu_info); DCHECK(gpu_info);
gpu_info->direct_composition = gpu_info->direct_composition =
gl::DirectCompositionSurfaceWin::IsDirectCompositionSupported(); gl::DirectCompositionSurfaceWin::IsDirectCompositionSupported();
gpu_info->bgra_format_support = static_cast<uint32_t>(
gl::DirectCompositionSurfaceWin::GetFormatSupportFlags(
DXGI_FORMAT_B8G8R8A8_UNORM));
gpu_info->yuy2_format_support = static_cast<uint32_t>(
gl::DirectCompositionSurfaceWin::GetFormatSupportFlags(
DXGI_FORMAT_YUY2));
gpu_info->nv12_format_support = static_cast<uint32_t>(
gl::DirectCompositionSurfaceWin::GetFormatSupportFlags(
DXGI_FORMAT_NV12));
gpu_info->supports_overlays = gpu_info->supports_overlays =
gl::DirectCompositionSurfaceWin::AreOverlaysSupported(); gl::DirectCompositionSurfaceWin::AreOverlaysSupported();
gpu_info->nv12_overlay_support = FlagsToOverlaySupport( gpu_info->nv12_overlay_support = FlagsToOverlaySupport(
......
...@@ -276,6 +276,18 @@ UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) { ...@@ -276,6 +276,18 @@ UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) {
return g_yuy2_overlay_support_flags; return g_yuy2_overlay_support_flags;
} }
// static
UINT DirectCompositionSurfaceWin::GetFormatSupportFlags(DXGI_FORMAT format) {
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device =
QueryD3D11DeviceObjectFromANGLE();
if (!d3d11_device)
return 0;
UINT support_flags = 0;
if (FAILED(d3d11_device->CheckFormatSupport(format, &support_flags)))
return 0;
return support_flags;
}
// static // static
gfx::Size DirectCompositionSurfaceWin::GetOverlayMonitorSize() { gfx::Size DirectCompositionSurfaceWin::GetOverlayMonitorSize() {
return g_overlay_monitor_size; return g_overlay_monitor_size;
......
...@@ -69,6 +69,9 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL { ...@@ -69,6 +69,9 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL {
// DXGI_OVERLAY_SUPPORT_FLAG_SCALING bits. // DXGI_OVERLAY_SUPPORT_FLAG_SCALING bits.
static UINT GetOverlaySupportFlags(DXGI_FORMAT format); static UINT GetOverlaySupportFlags(DXGI_FORMAT format);
// Returns queried flags from ID3D11Device::CheckFormatSupport().
static UINT GetFormatSupportFlags(DXGI_FORMAT format);
// Returns true if there is an HDR capable display connected. // Returns true if there is an HDR capable display connected.
static bool IsHDRSupported(); static bool IsHDRSupported();
......
...@@ -67,18 +67,6 @@ void DestroySurface(scoped_refptr<DirectCompositionSurfaceWin> surface) { ...@@ -67,18 +67,6 @@ void DestroySurface(scoped_refptr<DirectCompositionSurfaceWin> surface) {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
bool CheckFormatSupport(DXGI_FORMAT format) {
Microsoft::WRL::ComPtr<ID3D11Device> d3d11_device =
QueryD3D11DeviceObjectFromANGLE();
if (!d3d11_device)
return false;
UINT support_flags = 0;
if (FAILED(d3d11_device->CheckFormatSupport(format, &support_flags)))
return false;
LOG(ERROR) << "support_flag = 0x" << std::hex << support_flags;
return true;
}
Microsoft::WRL::ComPtr<ID3D11Texture2D> CreateNV12Texture( Microsoft::WRL::ComPtr<ID3D11Texture2D> CreateNV12Texture(
const Microsoft::WRL::ComPtr<ID3D11Device>& d3d11_device, const Microsoft::WRL::ComPtr<ID3D11Device>& d3d11_device,
const gfx::Size& size, const gfx::Size& size,
...@@ -928,11 +916,6 @@ TEST_F(DirectCompositionPixelTest, NV12SwapChain) { ...@@ -928,11 +916,6 @@ TEST_F(DirectCompositionPixelTest, NV12SwapChain) {
// are supported. // are supported.
DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(true); DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(true);
// TODO(zmo): These are to collect format supports on Win10/AMD bot,
// and should be removed after the info is obtained.
EXPECT_TRUE(CheckFormatSupport(DXGI_FORMAT_NV12));
EXPECT_TRUE(CheckFormatSupport(DXGI_FORMAT_YUY2));
gfx::Size window_size(100, 100); gfx::Size window_size(100, 100);
gfx::Size texture_size(50, 50); gfx::Size texture_size(50, 50);
// Pass content rect with odd with and height. Surface should round up // Pass content rect with odd with and height. Surface should round up
......
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