Merge pull request #8047 from stenzek/d3d-feature-level-10

D3D11: Fix Dolphin crashing on feature level 10.0 devices
This commit is contained in:
Connor McLaughlin 2019-04-28 17:07:37 +10:00 committed by GitHub
commit f7199397a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 38 deletions

View File

@ -33,29 +33,6 @@ static ComPtr<ID3D11Debug> s_debug;
static constexpr D3D_FEATURE_LEVEL s_supported_feature_levels[] = {
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_1, D3D_FEATURE_LEVEL_10_0};
static bool SupportsS3TCTextures()
{
UINT bc1_support, bc2_support, bc3_support;
if (FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC1_UNORM, &bc1_support)) ||
FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC2_UNORM, &bc2_support)) ||
FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC3_UNORM, &bc3_support)))
{
return false;
}
return ((bc1_support & bc2_support & bc3_support) & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0;
}
static bool SupportsBPTCTextures()
{
// Currently, we only care about BC7. This could be extended to BC6H in the future.
UINT bc7_support;
if (FAILED(device->CheckFormatSupport(DXGI_FORMAT_BC7_UNORM, &bc7_support)))
return false;
return (bc7_support & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0;
}
bool Create(u32 adapter_index, bool enable_debug_layer)
{
PFN_D3D11_CREATE_DEVICE d3d11_create_device;
@ -145,17 +122,6 @@ bool Create(u32 adapter_index, bool enable_debug_layer)
g_Config.backend_info.bSupportsLogicOp = false;
}
g_Config.backend_info.bSupportsST3CTextures = SupportsS3TCTextures();
g_Config.backend_info.bSupportsBPTCTextures = SupportsBPTCTextures();
// Features only supported with a FL11.0+ device.
const bool shader_model_5_supported = feature_level >= D3D_FEATURE_LEVEL_11_0;
g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;
g_Config.backend_info.bSupportsBBox = shader_model_5_supported;
g_Config.backend_info.bSupportsFragmentStoresAndAtomics = shader_model_5_supported;
g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported;
g_Config.backend_info.bSupportsSSAA = shader_model_5_supported;
stateman = std::make_unique<StateManager>();
return true;
}
@ -241,6 +207,16 @@ std::vector<u32> GetAAModes(u32 adapter_index)
return aa_modes;
}
bool SupportsTextureFormat(DXGI_FORMAT format)
{
UINT support;
if (FAILED(device->CheckFormatSupport(format, &support)))
return false;
return (support & D3D11_FORMAT_SUPPORT_TEXTURE2D) != 0;
}
} // namespace D3D
} // namespace DX11

View File

@ -40,6 +40,9 @@ void Destroy();
// Returns a list of supported AA modes for the current device.
std::vector<u32> GetAAModes(u32 adapter_index);
// Checks for support of the given texture format.
bool SupportsTextureFormat(DXGI_FORMAT format);
} // namespace D3D
} // namespace DX11

View File

@ -87,6 +87,25 @@ void VideoBackend::FillBackendInfo()
g_Config.backend_info.Adapters = D3DCommon::GetAdapterNames();
g_Config.backend_info.AAModes = D3D::GetAAModes(g_Config.iAdapter);
// Override optional features if we are actually booting.
if (D3D::device)
{
g_Config.backend_info.bSupportsST3CTextures =
D3D::SupportsTextureFormat(DXGI_FORMAT_BC1_UNORM) &&
D3D::SupportsTextureFormat(DXGI_FORMAT_BC2_UNORM) &&
D3D::SupportsTextureFormat(DXGI_FORMAT_BC3_UNORM);
g_Config.backend_info.bSupportsBPTCTextures = D3D::SupportsTextureFormat(DXGI_FORMAT_BC7_UNORM);
// Features only supported with a FL11.0+ device.
const bool shader_model_5_supported = D3D::feature_level >= D3D_FEATURE_LEVEL_11_0;
g_Config.backend_info.bSupportsEarlyZ = shader_model_5_supported;
g_Config.backend_info.bSupportsBBox = shader_model_5_supported;
g_Config.backend_info.bSupportsFragmentStoresAndAtomics = shader_model_5_supported;
g_Config.backend_info.bSupportsGSInstancing = shader_model_5_supported;
g_Config.backend_info.bSupportsSSAA = shader_model_5_supported;
g_Config.backend_info.bSupportsGPUTextureDecoding = shader_model_5_supported;
}
}
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)

View File

@ -410,10 +410,13 @@ std::string GenerateFormatConversionShader(EFBReinterpretType convtype, u32 samp
{
std::stringstream ss;
EmitSamplerDeclarations(ss, 0, 1, samples > 1);
EmitPixelMainDeclaration(ss, 1, 0, "float4",
GetAPIType() == APIType::D3D ?
"in float4 ipos : SV_Position, in uint isample : SV_SampleIndex, " :
"");
EmitPixelMainDeclaration(
ss, 1, 0, "float4",
GetAPIType() == APIType::D3D ?
(g_ActiveConfig.bSSAA ?
"in float4 ipos : SV_Position, in uint isample : SV_SampleIndex, " :
"in float4 ipos : SV_Position, ") :
"");
ss << "{\n";
ss << " int layer = int(v_tex0.z);\n";
if (GetAPIType() == APIType::D3D)