mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-17 20:52:36 +01:00
DX11/DX12: Fix detecting depth capabilities for BGFX_CAPS_FORMAT_TEXTURE_MSAA (#3562)
This commit is contained in:
@@ -1372,7 +1372,8 @@ namespace bgfx { namespace d3d11
|
|||||||
{
|
{
|
||||||
uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||||
|
|
||||||
const DXGI_FORMAT fmt = bimg::isDepth(bimg::TextureFormat::Enum(ii) )
|
const bool isDepthFormat = bimg::isDepth(bimg::TextureFormat::Enum(ii));
|
||||||
|
const DXGI_FORMAT fmt = isDepthFormat
|
||||||
? s_textureFormat[ii].m_fmtDsv
|
? s_textureFormat[ii].m_fmtDsv
|
||||||
: s_textureFormat[ii].m_fmt
|
: s_textureFormat[ii].m_fmt
|
||||||
;
|
;
|
||||||
@@ -1464,6 +1465,30 @@ namespace bgfx { namespace d3d11
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDepthFormat)
|
||||||
|
{
|
||||||
|
const DXGI_FORMAT fmtDepthSampling = s_textureFormat[ii].m_fmtSrv;
|
||||||
|
if (DXGI_FORMAT_UNKNOWN != fmtDepthSampling)
|
||||||
|
{
|
||||||
|
D3D11_FEATURE_DATA_FORMAT_SUPPORT dataSampling;
|
||||||
|
dataSampling.InFormat = fmtDepthSampling;
|
||||||
|
hr = m_device->CheckFeatureSupport(D3D11_FEATURE_FORMAT_SUPPORT, &dataSampling, sizeof(dataSampling));
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
support |= 0 != (dataSampling.OutFormatSupport & (0
|
||||||
|
| D3D11_FORMAT_SUPPORT_MULTISAMPLE_LOAD
|
||||||
|
))
|
||||||
|
? BGFX_CAPS_FORMAT_TEXTURE_MSAA
|
||||||
|
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BX_TRACE("CheckFeatureSupport depth srv failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) )
|
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) )
|
||||||
{
|
{
|
||||||
D3D11_FEATURE_DATA_FORMAT_SUPPORT2 data2;
|
D3D11_FEATURE_DATA_FORMAT_SUPPORT2 data2;
|
||||||
|
|||||||
@@ -1641,7 +1641,8 @@ namespace bgfx { namespace d3d12
|
|||||||
{
|
{
|
||||||
uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
uint16_t support = BGFX_CAPS_FORMAT_TEXTURE_NONE;
|
||||||
|
|
||||||
const DXGI_FORMAT fmt = bimg::isDepth(bimg::TextureFormat::Enum(ii) )
|
const bool isDepthFormat = bimg::isDepth(bimg::TextureFormat::Enum(ii));
|
||||||
|
const DXGI_FORMAT fmt = isDepthFormat
|
||||||
? s_textureFormat[ii].m_fmtDsv
|
? s_textureFormat[ii].m_fmtDsv
|
||||||
: s_textureFormat[ii].m_fmt
|
: s_textureFormat[ii].m_fmt
|
||||||
;
|
;
|
||||||
@@ -1718,6 +1719,30 @@ namespace bgfx { namespace d3d12
|
|||||||
BX_TRACE("CheckFeatureSupport failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
BX_TRACE("CheckFeatureSupport failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isDepthFormat)
|
||||||
|
{
|
||||||
|
const DXGI_FORMAT fmtDepthSampling = s_textureFormat[ii].m_fmtSrv;
|
||||||
|
if (DXGI_FORMAT_UNKNOWN != fmtDepthSampling)
|
||||||
|
{
|
||||||
|
D3D12_FEATURE_DATA_FORMAT_SUPPORT dataSampling;
|
||||||
|
dataSampling.Format = fmtDepthSampling;
|
||||||
|
hr = m_device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &dataSampling, sizeof(dataSampling));
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
support |= 0 != (dataSampling.Support1 & (0
|
||||||
|
| D3D12_FORMAT_SUPPORT1_MULTISAMPLE_LOAD
|
||||||
|
))
|
||||||
|
? BGFX_CAPS_FORMAT_TEXTURE_MSAA
|
||||||
|
: BGFX_CAPS_FORMAT_TEXTURE_NONE
|
||||||
|
;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
BX_TRACE("CheckFeatureSupport depth srv failed with %x for format %s.", hr, getName(TextureFormat::Enum(ii)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) )
|
if (0 != (support & BGFX_CAPS_FORMAT_TEXTURE_IMAGE_READ) )
|
||||||
{
|
{
|
||||||
// clear image flag for additional testing
|
// clear image flag for additional testing
|
||||||
|
|||||||
Reference in New Issue
Block a user