mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-18 03:55:19 -04:00
Show a better message when unable to create backbuffer or depth format for direct3d9 backend
This commit is contained in:
parent
2d5885577b
commit
457e10ebb6
@ -303,7 +303,7 @@ static DWORD d3d9_formatMappings[2] = { D3DFVF_XYZ | D3DFVF_DIFFUSE, D3DFVF_XYZ
|
|||||||
static IDirect3D9* d3d;
|
static IDirect3D9* d3d;
|
||||||
static IDirect3DDevice9* device;
|
static IDirect3DDevice9* device;
|
||||||
static DWORD createFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
static DWORD createFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
|
||||||
static D3DFORMAT gfx_viewFormat, gfx_depthFormat;
|
static D3DFORMAT viewFormat, depthFormat;
|
||||||
static float totalMem;
|
static float totalMem;
|
||||||
|
|
||||||
static void D3D9_RestoreRenderStates(void);
|
static void D3D9_RestoreRenderStates(void);
|
||||||
@ -327,33 +327,37 @@ static void D3D9_FreeResource(GfxResourceID* resource) {
|
|||||||
Platform_Log2("D3D9 resource has %i outstanding references! ID 0x%x", &refCount, &addr);
|
Platform_Log2("D3D9 resource has %i outstanding references! ID 0x%x", &refCount, &addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void D3D9_FindCompatibleFormat(void) {
|
static void FindCompatibleViewFormat(void) {
|
||||||
static D3DFORMAT depthFormats[6] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1 };
|
static const D3DFORMAT formats[4] = { D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
|
||||||
static D3DFORMAT viewFormats[4] = { D3DFMT_X8R8G8B8, D3DFMT_R8G8B8, D3DFMT_R5G6B5, D3DFMT_X1R5G5B5 };
|
|
||||||
cc_result res;
|
cc_result res;
|
||||||
int i, count = Array_Elems(viewFormats);
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < Array_Elems(formats); i++) {
|
||||||
gfx_viewFormat = viewFormats[i];
|
viewFormat = formats[i];
|
||||||
res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, gfx_viewFormat, gfx_viewFormat, true);
|
res = IDirect3D9_CheckDeviceType(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, true);
|
||||||
if (!res) break;
|
if (!res) return;
|
||||||
}
|
}
|
||||||
if (i == count) Logger_Abort("Unable to create a back buffer with sufficient precision.");
|
Logger_Abort("Failed to create back buffer. Graphics drivers may not be installed.");
|
||||||
|
}
|
||||||
|
|
||||||
count = Array_Elems(depthFormats);
|
static void FindCompatibleDepthFormat(void) {
|
||||||
for (i = 0; i < count; i++) {
|
static const D3DFORMAT formats[6] = { D3DFMT_D32, D3DFMT_D24X8, D3DFMT_D24S8, D3DFMT_D24X4S4, D3DFMT_D16, D3DFMT_D15S1 };
|
||||||
gfx_depthFormat = depthFormats[i];
|
cc_result res;
|
||||||
res = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, gfx_viewFormat, gfx_viewFormat, gfx_depthFormat);
|
int i;
|
||||||
if (!res) break;
|
|
||||||
|
for (i = 0; i < Array_Elems(formats); i++) {
|
||||||
|
depthFormat = formats[i];
|
||||||
|
res = IDirect3D9_CheckDepthStencilMatch(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, viewFormat, viewFormat, depthFormat);
|
||||||
|
if (!res) return;
|
||||||
}
|
}
|
||||||
if (i == count) Logger_Abort("Unable to create a depth buffer with sufficient precision.");
|
Logger_Abort("Failed to create depth buffer. Graphics drivers may not be installed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void D3D9_FillPresentArgs(int width, int height, D3DPRESENT_PARAMETERS* args) {
|
static void D3D9_FillPresentArgs(int width, int height, D3DPRESENT_PARAMETERS* args) {
|
||||||
args->AutoDepthStencilFormat = gfx_depthFormat;
|
args->AutoDepthStencilFormat = depthFormat;
|
||||||
args->BackBufferWidth = width;
|
args->BackBufferWidth = width;
|
||||||
args->BackBufferHeight = height;
|
args->BackBufferHeight = height;
|
||||||
args->BackBufferFormat = gfx_viewFormat;
|
args->BackBufferFormat = viewFormat;
|
||||||
args->BackBufferCount = 1;
|
args->BackBufferCount = 1;
|
||||||
args->EnableAutoDepthStencil = true;
|
args->EnableAutoDepthStencil = true;
|
||||||
args->PresentationInterval = gfx_vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
args->PresentationInterval = gfx_vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||||
@ -369,7 +373,8 @@ void Gfx_Init(void) {
|
|||||||
HWND winHandle = (HWND)WindowInfo.Handle;
|
HWND winHandle = (HWND)WindowInfo.Handle;
|
||||||
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
d3d = Direct3DCreate9(D3D_SDK_VERSION);
|
||||||
|
|
||||||
D3D9_FindCompatibleFormat();
|
FindCompatibleViewFormat();
|
||||||
|
FindCompatibleDepthFormat();
|
||||||
D3DPRESENT_PARAMETERS args = { 0 };
|
D3DPRESENT_PARAMETERS args = { 0 };
|
||||||
D3D9_FillPresentArgs(640, 480, &args);
|
D3D9_FillPresentArgs(640, 480, &args);
|
||||||
|
|
||||||
@ -960,7 +965,7 @@ static const int D3D9_DepthBufferBts(D3DFORMAT format) {
|
|||||||
void Gfx_GetApiInfo(String* lines) {
|
void Gfx_GetApiInfo(String* lines) {
|
||||||
D3DADAPTER_IDENTIFIER9 adapter = { 0 };
|
D3DADAPTER_IDENTIFIER9 adapter = { 0 };
|
||||||
int pointerSize = sizeof(void*) * 8;
|
int pointerSize = sizeof(void*) * 8;
|
||||||
int depthBits = D3D9_DepthBufferBts(gfx_depthFormat);
|
int depthBits = D3D9_DepthBufferBts(depthFormat);
|
||||||
float curMem;
|
float curMem;
|
||||||
|
|
||||||
IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &adapter);
|
IDirect3D9_GetAdapterIdentifier(d3d, D3DADAPTER_DEFAULT, 0, &adapter);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user