Windows: Try falling back to even older direct3d9 versions

This commit is contained in:
UnknownShadow200 2025-01-23 06:56:30 +11:00
parent f07112e21c
commit d21e9a4b5f

View File

@ -64,18 +64,16 @@ static void LoadD3D9Library(void) {
} }
static void CreateD3D9Instance(void) { static void CreateD3D9Instance(void) {
d3d = _Direct3DCreate9(D3D_SDK_VERSION); int ver = D3D_SDK_VERSION;
/* Try to create a 9.0b instance if creating a 9.0c instance fails */ while (ver > 0) {
if (!d3d) d3d = _Direct3DCreate9(D3D_SDK_VERSION - 1); d3d = _Direct3DCreate9(ver);
if (!d3d) Process_Abort("Direct3DCreate9 returned NULL"); if (d3d) return;
/* Normal Direct3D9 supports POOL_MANAGED textures */ /* Try an earlier d3d9 version instance if creating a 9.0c instance fails */
/* (Direct3D9Ex does not support them however) */ /* (e.g. if system only has 9.0b) */
Gfx.ManagedTextures = true; ver--;
}
fallbackRendering = Options_GetBool("fallback-rendering", false); Process_Abort("Direct3DCreate9 returned NULL");
if (!fallbackRendering) return;
Platform_LogConst("WARNING: Using fallback rendering mode, which will reduce performance");
} }
static void FindCompatibleViewFormat(void) { static void FindCompatibleViewFormat(void) {
@ -178,11 +176,18 @@ void Gfx_Create(void) {
FindCompatibleViewFormat(); FindCompatibleViewFormat();
FindCompatibleDepthFormat(); FindCompatibleDepthFormat();
depthBits = D3D9_DepthBufferBits(); depthBits = D3D9_DepthBufferBits();
TryCreateDevice();
customMipmapsLevels = true; customMipmapsLevels = true;
Gfx.Created = true; Gfx.Created = true;
Gfx.BackendType = CC_GFX_BACKEND_D3D9; Gfx.BackendType = CC_GFX_BACKEND_D3D9;
TryCreateDevice(); /* Normal Direct3D9 supports POOL_MANAGED textures */
/* (Direct3D9Ex does not support them however) */
Gfx.ManagedTextures = true;
fallbackRendering = Options_GetBool("fallback-rendering", false);
if (!fallbackRendering) return;
Platform_LogConst("WARNING: Using fallback rendering mode, which will reduce performance");
} }
cc_bool Gfx_TryRestoreContext(void) { cc_bool Gfx_TryRestoreContext(void) {