prevent missing polygons with AMD GPU

This commit is contained in:
= 2020-04-09 19:48:36 +01:00 committed by RadWolfie
parent 30dbba8d37
commit 8850b52d88
3 changed files with 21 additions and 5 deletions

View File

@ -1662,6 +1662,17 @@ VOID EmuD3DInit()
std::cout << "Host D3DCaps : " << g_D3DCaps << "\n";
std::cout << "----------------------------------------\n";
}
// AMD compatibility workaround since VS model 3.0 doesn't work as intended with Direct3D9.
{
D3DADAPTER_IDENTIFIER9 adapter_info;
HRESULT status = g_pDirect3D->GetAdapterIdentifier(g_EmuCDPD.Adapter, 0, &adapter_info);
// 1002 and 1022 are vendor ids of AMD gpus
if (status == D3D_OK && (adapter_info.VendorId == 0x1002 || adapter_info.VendorId == 0x1022)) {
g_vs_model = vs_model_2_a;
EmuLog(LOG_LEVEL::WARNING, "AMD GPU Detected, falling back to shader model 2.X to prevent missing polygons");
}
}
}
// cleanup Direct3D

View File

@ -6,6 +6,8 @@
#include <sstream>
extern const char* g_vs_model = vs_model_3_0;
// HLSL generation
void OutputHlsl(std::stringstream& hlsl, VSH_IMD_OUTPUT& dest)
{
@ -247,9 +249,8 @@ extern HRESULT EmuCompileShader
EmuLog(LOG_LEVEL::DEBUG, DebugPrependLineNumbers(hlsl_str).c_str());
EmuLog(LOG_LEVEL::DEBUG, "-----------------------");
// Level 0 for fastest runtime compilation
// TODO Can we recompile an optimized shader in the background?
UINT flags1 = D3DCOMPILE_OPTIMIZATION_LEVEL0;
UINT flags1 = D3DCOMPILE_OPTIMIZATION_LEVEL3 | D3DCOMPILE_AVOID_FLOW_CONTROL;
hRet = D3DCompile(
hlsl_str.c_str(),
@ -258,7 +259,7 @@ extern HRESULT EmuCompileShader
nullptr, // pDefines
nullptr, // pInclude // TODO precompile x_* HLSL functions?
"main", // shader entry poiint
"vs_3_0", // shader profile
g_vs_model, // shader profile
flags1, // flags1
0, // flags2
ppHostShader, // out
@ -275,7 +276,7 @@ extern HRESULT EmuCompileShader
nullptr, // pDefines
nullptr, // pInclude // TODO precompile x_* HLSL functions?
"main", // shader entry poiint
"vs_3_0", // shader profile
g_vs_model, // shader profile
flags1, // flags1
0, // flags2
ppHostShader, // out

View File

@ -10,6 +10,10 @@ enum class ShaderType {
Unsupported,
};
static const char* vs_model_2_a = "vs_2_a";
static const char* vs_model_3_0 = "vs_3_0";
extern const char* g_vs_model;
extern ShaderType EmuGetShaderInfo(IntermediateVertexShader* pIntermediateShader);
extern HRESULT EmuCompileShader