D3D9: Fall back to just creating a depth surface instead of a depth texture if the latter one isn't supported by the hardware.

This is a workaround for issue 3256.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6737 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX
2011-01-04 12:56:52 +00:00
parent efe555fc16
commit 599020ef99
4 changed files with 59 additions and 27 deletions

View File

@ -82,6 +82,22 @@ LPDIRECT3DVERTEXDECLARATION9 m_VtxDecl;
LPDIRECT3DPIXELSHADER9 m_PixelShader;
LPDIRECT3DVERTEXSHADER9 m_VertexShader;
// Z buffer formats to be used for EFB depth surface
D3DFORMAT DepthFormats[] = {
FOURCC_INTZ,
FOURCC_DF24,
FOURCC_RAWZ,
FOURCC_DF16,
D3DFMT_D24X8,
D3DFMT_D24X4S4,
D3DFMT_D24S8,
D3DFMT_D24FS8,
D3DFMT_D32, // too much precision, but who cares
D3DFMT_D16, // much lower precision, but better than nothing
D3DFMT_D15S1,
};
void Enumerate();
int GetNumAdapters() { return numAdapters; }
@ -469,6 +485,24 @@ bool CheckDepthStencilSupport(D3DFORMAT target_format, D3DFORMAT depth_format)
return D3D_OK == D3D->CheckDepthStencilMatch(cur_adapter, D3DDEVTYPE_HAL, D3DFMT_X8R8G8B8, target_format, depth_format);
}
D3DFORMAT GetSupportedDepthTextureFormat()
{
for (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
if (D3D::CheckTextureSupport(D3DUSAGE_DEPTHSTENCIL, DepthFormats[i]))
return DepthFormats[i];
return D3DFMT_UNKNOWN;
}
D3DFORMAT GetSupportedDepthSurfaceFormat(D3DFORMAT target_format)
{
for (int i = 0; i < sizeof(DepthFormats)/sizeof(D3DFORMAT); ++i)
if (D3D::CheckDepthStencilSupport(target_format, DepthFormats[i]))
return DepthFormats[i];
return D3DFMT_UNKNOWN;
}
const char *VertexShaderVersionString()
{
static const char *versions[5] = {"ERROR", "vs_1_4", "vs_2_0", "vs_3_0", "vs_4_0"};