Commit cecab592 by Geoff Lang Committed by Commit Bot

Don't use native D3D11.1 formats unless they support enough samples.

The MSDN documentation states that BGRA4, RGB5A1 and RGB565 should all support 4 samples with DXGI 1.2 and D3D11.1 but some drivers appear to not have full support. Fall back to RGBA8 render targets when the driver cannot support at least 4 samples for ES3 feature levels. BUG=761489 Change-Id: I6bcd417700f1188945e8032ca6a64c4fbb2bc8a8 Reviewed-on: https://chromium-review.googlesource.com/652828Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 8cf8f7b0
......@@ -401,6 +401,30 @@ int GetAdjustedInstanceCount(const gl::Program *program, int instanceCount)
const uint32_t ScratchMemoryBufferLifetime = 1000;
void PopulateFormatDeviceCaps(ID3D11Device *device,
DXGI_FORMAT format,
UINT *outSupport,
UINT *outMaxSamples)
{
if (FAILED(device->CheckFormatSupport(format, outSupport)))
{
*outSupport = 0;
}
*outMaxSamples = 0;
for (UINT sampleCount = 2; sampleCount <= D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT; sampleCount *= 2)
{
UINT qualityCount = 0;
if (FAILED(device->CheckMultisampleQualityLevels(format, sampleCount, &qualityCount)) ||
qualityCount == 0)
{
break;
}
*outMaxSamples = sampleCount;
}
}
} // anonymous namespace
Renderer11::Renderer11(egl::Display *display)
......@@ -900,30 +924,21 @@ void Renderer11::populateRenderer11DeviceCaps()
if (getWorkarounds().disableB5G6R5Support)
{
mRenderer11DeviceCaps.B5G6R5support = 0;
mRenderer11DeviceCaps.B5G6R5maxSamples = 0;
}
else
{
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G6R5_UNORM,
&(mRenderer11DeviceCaps.B5G6R5support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B5G6R5support = 0;
}
}
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B4G4R4A4_UNORM,
&(mRenderer11DeviceCaps.B4G4R4A4support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B4G4R4A4support = 0;
PopulateFormatDeviceCaps(mDevice, DXGI_FORMAT_B5G6R5_UNORM,
&mRenderer11DeviceCaps.B5G6R5support,
&mRenderer11DeviceCaps.B5G6R5maxSamples);
}
hr = mDevice->CheckFormatSupport(DXGI_FORMAT_B5G5R5A1_UNORM,
&(mRenderer11DeviceCaps.B5G5R5A1support));
if (FAILED(hr))
{
mRenderer11DeviceCaps.B5G5R5A1support = 0;
}
PopulateFormatDeviceCaps(mDevice, DXGI_FORMAT_B4G4R4A4_UNORM,
&mRenderer11DeviceCaps.B4G4R4A4support,
&mRenderer11DeviceCaps.B4G4R4A4maxSamples);
PopulateFormatDeviceCaps(mDevice, DXGI_FORMAT_B5G5R5A1_UNORM,
&mRenderer11DeviceCaps.B5G5R5A1support,
&mRenderer11DeviceCaps.B5G5R5A1maxSamples);
IDXGIAdapter2 *dxgiAdapter2 = d3d11::DynamicCastComObject<IDXGIAdapter2>(mDxgiAdapter);
mRenderer11DeviceCaps.supportsDXGI1_2 = (dxgiAdapter2 != nullptr);
......
......@@ -50,8 +50,11 @@ struct Renderer11DeviceCaps
bool supportsClearView; // Support for ID3D11DeviceContext1::ClearView
bool supportsConstantBufferOffsets; // Support for Constant buffer offset
UINT B5G6R5support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G6R5_UNORM
UINT B5G6R5maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B5G6R5_UNORM
UINT B4G4R4A4support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B4G4R4A4_UNORM
UINT B4G4R4A4maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B4G4R4A4_UNORM
UINT B5G5R5A1support; // Bitfield of D3D11_FORMAT_SUPPORT values for DXGI_FORMAT_B5G5R5A1_UNORM
UINT B5G5R5A1maxSamples; // Maximum number of samples supported by DXGI_FORMAT_B5G5R5A1_UNORM
Optional<LARGE_INTEGER> driverVersion; // Four-part driver version number.
};
......
......@@ -34,10 +34,15 @@ inline bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &devic
UINT mustSupport = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE |
D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | D3D11_FORMAT_SUPPORT_MIP |
D3D11_FORMAT_SUPPORT_RENDER_TARGET;
UINT minimumRequiredSamples = 0;
if (d3d11_gl::GetMaximumClientVersion(deviceCaps.featureLevel).major > 2)
{
mustSupport |= D3D11_FORMAT_SUPPORT_TEXTURE3D;
// RGBA4, RGB5A1 and RGB565 are all required multisampled renderbuffer formats in ES3 and
// need to support a minimum of 4 samples.
minimumRequiredSamples = 4;
}
bool fullSupport = false;
......@@ -46,15 +51,18 @@ inline bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &devic
// All hardware that supports DXGI_FORMAT_B5G6R5_UNORM should support autogen mipmaps, but
// check anyway.
mustSupport |= D3D11_FORMAT_SUPPORT_MIP_AUTOGEN;
fullSupport = ((deviceCaps.B5G6R5support & mustSupport) == mustSupport);
fullSupport = ((deviceCaps.B5G6R5support & mustSupport) == mustSupport) &&
deviceCaps.B5G6R5maxSamples >= minimumRequiredSamples;
}
else if (format == DXGI_FORMAT_B4G4R4A4_UNORM)
{
fullSupport = ((deviceCaps.B4G4R4A4support & mustSupport) == mustSupport);
fullSupport = ((deviceCaps.B4G4R4A4support & mustSupport) == mustSupport) &&
deviceCaps.B4G4R4A4maxSamples >= minimumRequiredSamples;
}
else if (format == DXGI_FORMAT_B5G5R5A1_UNORM)
{
fullSupport = ((deviceCaps.B5G5R5A1support & mustSupport) == mustSupport);
fullSupport = ((deviceCaps.B5G5R5A1support & mustSupport) == mustSupport) &&
deviceCaps.B5G5R5A1maxSamples >= minimumRequiredSamples;
}
else
{
......
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