mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
fixes for firegl
This commit is contained in:
parent
daf12a57de
commit
1bacaf9abc
@ -951,10 +951,31 @@ HRESULT CALLBACK EnumDevicesCallback(LPSTR pDeviceDescription, LPSTR pDeviceName
|
|||||||
return DDENUMRET_OK;
|
return DDENUMRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
HRESULT WINAPI EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
#define MAX_DISPLAY_MODES 100
|
||||||
DWORD *pDDBDMask = (DWORD*)lpContext;
|
typedef struct {
|
||||||
|
DWORD maxWidth,maxHeight;
|
||||||
|
DWORD supportedBitDepths; // uses DDBD_* flags
|
||||||
|
LPDDSURFACEDESC2 pDDSD_Arr;
|
||||||
|
DWORD cNumSurfDescs;
|
||||||
|
} DisplayModeInfo;
|
||||||
|
|
||||||
|
HRESULT WINAPI EnumDisplayModesCallBack(LPDDSURFACEDESC2 lpDDSurfaceDesc,LPVOID lpContext) {
|
||||||
|
DisplayModeInfo *pDMI = (DisplayModeInfo *) lpContext;
|
||||||
|
|
||||||
|
// ignore everything over specified dimensions
|
||||||
|
if((lpDDSurfaceDesc->dwWidth > pDMI->maxWidth) ||
|
||||||
|
(lpDDSurfaceDesc->dwHeight > pDMI->maxHeight))
|
||||||
|
return DDENUMRET_OK;
|
||||||
|
|
||||||
|
// ignore refresh rates under 60Hz (and special values of 0 & 1)
|
||||||
|
if((lpDDSurfaceDesc->dwRefreshRate>1) && (lpDDSurfaceDesc->dwRefreshRate<60))
|
||||||
|
return DDENUMRET_OK;
|
||||||
|
|
||||||
|
assert(pDMI->cNumSurfDescs < MAX_DISPLAY_MODES);
|
||||||
|
memcpy( &(pDMI->pDDSD_Arr[pDMI->cNumSurfDescs]), lpDDSurfaceDesc, sizeof(DDSURFACEDESC2) );
|
||||||
|
pDMI->cNumSurfDescs++;
|
||||||
|
pDMI->supportedBitDepths |= BitDepth_2_DDBDMask(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
|
||||||
|
|
||||||
*pDDBDMask |= BitDepth_2_DDBDMask(lpDDSurfaceDesc->ddpfPixelFormat.dwRGBBitCount);
|
|
||||||
return DDENUMRET_OK;
|
return DDENUMRET_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -997,12 +1018,12 @@ dx_setup() {
|
|||||||
|
|
||||||
HINSTANCE DDHinst = LoadLibrary( "ddraw.dll" );
|
HINSTANCE DDHinst = LoadLibrary( "ddraw.dll" );
|
||||||
if(DDHinst == 0) {
|
if(DDHinst == 0) {
|
||||||
wdxdisplay_cat.fatal() << "config() - DDRAW.DLL doesn't exist!" << endl;
|
wdxdisplay_cat.fatal() << "error: DDRAW.DLL doesn't exist!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(NULL == GetProcAddress( DDHinst, "DirectDrawCreateEx" )) {
|
if(NULL == GetProcAddress( DDHinst, "DirectDrawCreateEx" )) {
|
||||||
wdxdisplay_cat.fatal() << "config() - Panda currently requires at least DirectX 7.0!" << endl;
|
wdxdisplay_cat.fatal() << "Panda currently requires at least DirectX 7.0!" << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1041,14 +1062,13 @@ dx_setup() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// imperfect method to ID NVid, could also scan desc str, but that isnt fullproof either
|
// imperfect method to ID NVid, could also scan desc str, but that isnt fullproof either
|
||||||
BOOL bIsNvidia = (dddi.dwVendorId==4318) || (dddi.dwVendorId==4818);
|
BOOL bIsNvidia = (dddi.dwVendorId==0x10DE) || (dddi.dwVendorId==0x12D2);
|
||||||
|
|
||||||
// Query DirectDraw for access to Direct3D
|
// Query DirectDraw for access to Direct3D
|
||||||
|
|
||||||
hr = pDD->QueryInterface( IID_IDirect3D7, (VOID**)&pD3DI );
|
hr = pDD->QueryInterface( IID_IDirect3D7, (VOID**)&pD3DI );
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "QI for D3D failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - QI for D3D failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1061,7 +1081,7 @@ dx_setup() {
|
|||||||
hr = pD3DI->EnumDevices(EnumDevicesCallback,d3ddevs);
|
hr = pD3DI->EnumDevices(EnumDevicesCallback,d3ddevs);
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal()
|
||||||
<< "config() - EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
|
<< "EnumDevices failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1090,14 +1110,19 @@ dx_setup() {
|
|||||||
// CREATE FULL SCREEN BUFFERS
|
// CREATE FULL SCREEN BUFFERS
|
||||||
// Store the rectangle which contains the renderer
|
// Store the rectangle which contains the renderer
|
||||||
|
|
||||||
DWORD dwSupportedBitDepthMask=0x0; // uses DDBD_...
|
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_search);
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_search);
|
||||||
ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
ddsd_search.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
||||||
ddsd_search.dwWidth=dwRenderWidth; ddsd_search.dwHeight=dwRenderHeight;
|
ddsd_search.dwWidth=dwRenderWidth; ddsd_search.dwHeight=dwRenderHeight;
|
||||||
|
|
||||||
if(FAILED(hr= pDD->EnumDisplayModes(0x0,&ddsd_search,&dwSupportedBitDepthMask,EnumDisplayModesCallBack))) {
|
DDSURFACEDESC2 DDSD_Arr[MAX_DISPLAY_MODES];
|
||||||
wdxdisplay_cat.fatal()
|
DisplayModeInfo DMI;
|
||||||
<< "EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
|
ZeroMemory(&DDSD_Arr,sizeof(DDSD_Arr));
|
||||||
|
ZeroMemory(&DMI,sizeof(DMI));
|
||||||
|
DMI.maxWidth=dwRenderWidth; DMI.maxHeight=dwRenderHeight;
|
||||||
|
DMI.pDDSD_Arr=DDSD_Arr;
|
||||||
|
|
||||||
|
if(FAILED(hr= pDD->EnumDisplayModes(DDEDM_REFRESHRATES,&ddsd_search,&DMI,EnumDisplayModesCallBack))) {
|
||||||
|
wdxdisplay_cat.fatal() << "EnumDisplayModes failed, result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1116,7 +1141,7 @@ dx_setup() {
|
|||||||
ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; //set internally by DX anyway, dont think this any different than 0x0
|
ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY; //set internally by DX anyway, dont think this any different than 0x0
|
||||||
|
|
||||||
if(FAILED( hr = pDD->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
|
if(FAILED( hr = pDD->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
|
||||||
wdxdisplay_cat.debug() << "GetAvailableVidMem failed : result = " << ConvD3DErrorToString(hr) << endl;
|
wdxdisplay_cat.error() << "GetAvailableVidMem failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1125,11 +1150,11 @@ dx_setup() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// note: this chooses 32bpp, which may not be preferred over 16 for memory & speed reasons
|
// note: this chooses 32bpp, which may not be preferred over 16 for memory & speed reasons
|
||||||
if((dwSupportedBitDepthMask & DDBD_32) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_32)) {
|
if((DMI.supportedBitDepths & DDBD_32) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_32)) {
|
||||||
dwFullScreenBitDepth=32; // go for 32bpp if its avail
|
dwFullScreenBitDepth=32; // go for 32bpp if its avail
|
||||||
} else if((dwSupportedBitDepthMask & DDBD_24) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_24)) {
|
} else if((DMI.supportedBitDepths & DDBD_24) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_24)) {
|
||||||
dwFullScreenBitDepth=24; // go for 24bpp if its avail
|
dwFullScreenBitDepth=24; // go for 24bpp if its avail
|
||||||
} else if((dwSupportedBitDepthMask & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)) {
|
} else if((DMI.supportedBitDepths & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)) {
|
||||||
dwFullScreenBitDepth=16; // do 16bpp
|
dwFullScreenBitDepth=16; // do 16bpp
|
||||||
} else {
|
} else {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal()
|
||||||
@ -1137,6 +1162,8 @@ dx_setup() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(dwFree>0) { // assume buggy drivers (this means you, FireGL2) may return zero for dwTotal, so ignore value if its 0
|
||||||
|
|
||||||
// hack: figuring out exactly what res to use is tricky, instead I will
|
// hack: figuring out exactly what res to use is tricky, instead I will
|
||||||
// just use 640x480 if we have < 3 meg avail
|
// just use 640x480 if we have < 3 meg avail
|
||||||
|
|
||||||
@ -1164,7 +1191,7 @@ dx_setup() {
|
|||||||
if(memleft < RESERVEDTEXVIDMEM) {
|
if(memleft < RESERVEDTEXVIDMEM) {
|
||||||
dwFullScreenBitDepth=16;
|
dwFullScreenBitDepth=16;
|
||||||
wdxdisplay_cat.debug() << "using 16bpp rendertargets to save tex vidmem\n";
|
wdxdisplay_cat.debug() << "using 16bpp rendertargets to save tex vidmem\n";
|
||||||
assert((dwSupportedBitDepthMask & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)); // probably a safe assumption
|
assert((DMI.supportedBitDepths & DDBD_16) && (d3ddevs[DeviceIdx].dwDeviceRenderBitDepth & DDBD_16)); // probably a safe assumption
|
||||||
rendertargetmem=dwRenderWidth*dwRenderHeight*(dwFullScreenBitDepth>>3);
|
rendertargetmem=dwRenderWidth*dwRenderHeight*(dwFullScreenBitDepth>>3);
|
||||||
memleft = dwFree-rendertargetmem*2;
|
memleft = dwFree-rendertargetmem*2;
|
||||||
|
|
||||||
@ -1173,7 +1200,7 @@ dx_setup() {
|
|||||||
wdxdisplay_cat.debug() << " XXXXXX WARNING: cant reserve 2MB of tex vidmem. only " << memleft << " bytes available. Need to rewrite wdxdisplay to try lower resolutions XXXXXXXXXXXXXXXXXXXX\n";
|
wdxdisplay_cat.debug() << " XXXXXX WARNING: cant reserve 2MB of tex vidmem. only " << memleft << " bytes available. Need to rewrite wdxdisplay to try lower resolutions XXXXXXXXXXXXXXXXXXXX\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// extern bool dx_preserve_fpu_state;
|
// extern bool dx_preserve_fpu_state;
|
||||||
DWORD SCL_FPUFlag = DDSCL_FPUSETUP;
|
DWORD SCL_FPUFlag = DDSCL_FPUSETUP;
|
||||||
@ -1184,8 +1211,7 @@ dx_setup() {
|
|||||||
DWORD SCL_FLAGS = SCL_FPUFlag | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT;
|
DWORD SCL_FLAGS = SCL_FPUFlag | DDSCL_FULLSCREEN | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT;
|
||||||
|
|
||||||
if(FAILED(hr = pDD->SetCooperativeLevel(_mwindow, SCL_FLAGS))) {
|
if(FAILED(hr = pDD->SetCooperativeLevel(_mwindow, SCL_FLAGS))) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "SetCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - SetCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1193,21 +1219,19 @@ dx_setup() {
|
|||||||
// so we do it, it really shouldnt be necessary if drivers werent buggy
|
// so we do it, it really shouldnt be necessary if drivers werent buggy
|
||||||
if(FAILED(hr = pDD->SetCooperativeLevel(_mwindow, SCL_FLAGS))) {
|
if(FAILED(hr = pDD->SetCooperativeLevel(_mwindow, SCL_FLAGS))) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal()
|
||||||
<< "config() - SetCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
<< "SetCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED(hr = pDD->TestCooperativeLevel())) {
|
if(FAILED(hr = pDD->TestCooperativeLevel())) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - TestCooperativeLevel failed : result = " << ConvD3DErrorToString(hr) << endl;
|
wdxdisplay_cat.fatal() << "Full screen app failed to get exclusive mode on init, exiting..\n";
|
||||||
wdxdisplay_cat.fatal()
|
|
||||||
<< "config() - Full screen app failed to get exclusive mode on init, exiting..\n";
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED( hr = pDD->SetDisplayMode( dwRenderWidth, dwRenderHeight,
|
if(FAILED( hr = pDD->SetDisplayMode( dwRenderWidth, dwRenderHeight,
|
||||||
dwFullScreenBitDepth, 0L, 0L ))) {
|
dwFullScreenBitDepth, 0L, 0L ))) {
|
||||||
wdxdisplay_cat.fatal() << "CreateFullscreenBuffers() - Can't set display mode : result = " << ConvD3DErrorToString(hr) << endl;
|
wdxdisplay_cat.fatal() << "failed to reset display mode to ("<<dwRenderWidth<<"x"<<dwRenderHeight<<"x"<<dwFullScreenBitDepth<<"): result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,7 +1239,6 @@ dx_setup() {
|
|||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd34);
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd34);
|
||||||
pDD->GetDisplayMode(&ddsd34);
|
pDD->GetDisplayMode(&ddsd34);
|
||||||
wdxdisplay_cat.debug() << "set displaymode to " << ddsd34.dwWidth << "x" << ddsd34.dwHeight << " at "<< ddsd34.ddpfPixelFormat.dwRGBBitCount << "bpp, " << ddsd34.dwRefreshRate<< "Hz\n";
|
wdxdisplay_cat.debug() << "set displaymode to " << ddsd34.dwWidth << "x" << ddsd34.dwHeight << " at "<< ddsd34.ddpfPixelFormat.dwRGBBitCount << "bpp, " << ddsd34.dwRefreshRate<< "Hz\n";
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
if(FAILED( hr = pDD->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
|
if(FAILED( hr = pDD->GetAvailableVidMem(&ddsCaps,&dwTotal,&dwFree))) {
|
||||||
@ -1224,6 +1247,7 @@ dx_setup() {
|
|||||||
}
|
}
|
||||||
wdxdisplay_cat.debug() << "after FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
wdxdisplay_cat.debug() << "after FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
// Setup to create the primary surface w/backbuffer
|
// Setup to create the primary surface w/backbuffer
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd)
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd)
|
||||||
@ -1402,9 +1426,16 @@ dx_setup() {
|
|||||||
|
|
||||||
resized(dwRenderWidth,dwRenderHeight); // update panda channel/display rgn info
|
resized(dwRenderWidth,dwRenderHeight); // update panda channel/display rgn info
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
if(!(_props._mask & W_DEPTH)) {
|
||||||
|
wdxdisplay_cat.info() << "no zbuffer requested, skipping zbuffer creation\n";
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// Check if the device supports z-bufferless hidden surface removal. If so,
|
// Check if the device supports z-bufferless hidden surface removal. If so,
|
||||||
// we don't really need a z-buffer
|
// we don't really need a z-buffer
|
||||||
if(!(d3ddevs[DeviceIdx].dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )) {
|
if((!(d3ddevs[DeviceIdx].dpcTriCaps.dwRasterCaps & D3DPRASTERCAPS_ZBUFFERLESSHSR )) &&
|
||||||
|
(_props._mask & W_DEPTH)) {
|
||||||
|
|
||||||
// Get z-buffer dimensions from the render target
|
// Get z-buffer dimensions from the render target
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd);
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd);
|
||||||
@ -1421,8 +1452,7 @@ dx_setup() {
|
|||||||
// buffer depth (as some cards unfornately require this).
|
// buffer depth (as some cards unfornately require this).
|
||||||
if(FAILED(pD3DI->EnumZBufferFormats( IID_IDirect3DHALDevice, EnumZBufFmtsCallback,
|
if(FAILED(pD3DI->EnumZBufferFormats( IID_IDirect3DHALDevice, EnumZBufFmtsCallback,
|
||||||
(VOID*)&ZBufPixFmts ))) {
|
(VOID*)&ZBufPixFmts ))) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "EnumZBufferFormats failed " << endl;
|
||||||
<< "config() - EnumZBufferFormats failed " << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1437,23 +1467,33 @@ dx_setup() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// int want_depth_bits = _props._want_depth_bits; should we pay attn to these at some point?
|
||||||
|
// int want_color_bits = _props._want_color_bits;
|
||||||
|
bool bWantStencil = ((_props._mask & W_STENCIL)!=0);
|
||||||
|
|
||||||
LPDDPIXELFORMAT pCurPixFmt,pz16=NULL,pz24=NULL,pz32=NULL;
|
LPDDPIXELFORMAT pCurPixFmt,pz16=NULL,pz24=NULL,pz32=NULL;
|
||||||
for(i=0,pCurPixFmt=ZBufPixFmts;i<cNumZBufFmts;i++,pCurPixFmt++) {
|
for(i=0,pCurPixFmt=ZBufPixFmts;i<cNumZBufFmts;i++,pCurPixFmt++) {
|
||||||
|
if(bWantStencil==((pCurPixFmt->dwFlags & DDPF_STENCILBUFFER)!=0)) {
|
||||||
switch(pCurPixFmt->dwRGBBitCount) {
|
switch(pCurPixFmt->dwRGBBitCount) {
|
||||||
case 16:
|
case 16:
|
||||||
if(!(pCurPixFmt->dwFlags & DDPF_STENCILBUFFER))
|
|
||||||
pz16=pCurPixFmt;
|
pz16=pCurPixFmt;
|
||||||
break;
|
break;
|
||||||
case 24:
|
case 24:
|
||||||
assert(!(pCurPixFmt->dwFlags & DDPF_STENCILBUFFER)); // shouldnt be stencil at 24bpp
|
|
||||||
pz24=pCurPixFmt;
|
pz24=pCurPixFmt;
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
if(!(pCurPixFmt->dwFlags & DDPF_STENCILBUFFER))
|
|
||||||
pz32=pCurPixFmt;
|
pz32=pCurPixFmt;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if((pz16==NULL)&&(pz24==NULL)&&(pz32==NULL)) {
|
||||||
|
if(bWantStencil)
|
||||||
|
wdxdisplay_cat.fatal() << "stencil buffer requested, device has no stencil capability\n";
|
||||||
|
else wdxdisplay_cat.fatal() << "failed to find adequate zbuffer capability\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if(bIsNvidia) {
|
if(bIsNvidia) {
|
||||||
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_pri)
|
DX_DECLARE_CLEAN(DDSURFACEDESC2,ddsd_pri)
|
||||||
@ -1468,11 +1508,9 @@ dx_setup() {
|
|||||||
ddsd.ddpfPixelFormat = *pz24; //take the no-stencil version of the 32-bit Zbuf
|
ddsd.ddpfPixelFormat = *pz24; //take the no-stencil version of the 32-bit Zbuf
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// pick the largest non-stencil zbuffer format avail (wont support stenciling
|
// pick the highest res zbuffer format avail. Note: this is choosing to waste vid-memory
|
||||||
// until we definitely need it). Note: this is choosing to waste memory
|
// and possibly perf for more accuracy, less z-fighting at long distance (std 16bpp would
|
||||||
// and possibly perf for more accuracy at long distance (std 16bpp would be smaller/
|
// be smaller// maybe faster)
|
||||||
// maybe faster)
|
|
||||||
|
|
||||||
|
|
||||||
if(pz32!=NULL) {
|
if(pz32!=NULL) {
|
||||||
ddsd.ddpfPixelFormat = *pz32;
|
ddsd.ddpfPixelFormat = *pz32;
|
||||||
@ -1481,7 +1519,7 @@ dx_setup() {
|
|||||||
} else if(pz16!=NULL) {
|
} else if(pz16!=NULL) {
|
||||||
ddsd.ddpfPixelFormat = *pz16;
|
ddsd.ddpfPixelFormat = *pz16;
|
||||||
} else {
|
} else {
|
||||||
wdxdisplay_cat.fatal() << "config() - could find a valid zbuffer format!\n";
|
wdxdisplay_cat.fatal() << "could not find a valid zbuffer format!\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1490,14 +1528,12 @@ dx_setup() {
|
|||||||
|
|
||||||
// Create and attach a z-buffer
|
// Create and attach a z-buffer
|
||||||
if(FAILED( hr = pDD->CreateSurface( &ddsd, &pZDDSurf, NULL ) )) {
|
if(FAILED( hr = pDD->CreateSurface( &ddsd, &pZDDSurf, NULL ) )) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "CreateSurface failed for Z buffer: result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - CreateSurface failed for Z buffer: result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(FAILED( hr = pBackDDSurf->AddAttachedSurface( pZDDSurf ) )) {
|
if(FAILED( hr = pBackDDSurf->AddAttachedSurface( pZDDSurf ) )) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "AddAttachedSurface failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - AddAttachedSurface failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1510,8 +1546,7 @@ dx_setup() {
|
|||||||
// becomes the render target for the newly created device.
|
// becomes the render target for the newly created device.
|
||||||
hr = pD3DI->CreateDevice(d3ddevs[DeviceIdx].deviceGUID, pBackDDSurf, &pD3DDevice );
|
hr = pD3DI->CreateDevice(d3ddevs[DeviceIdx].deviceGUID, pBackDDSurf, &pD3DDevice );
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "CreateDevice failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - CreateDevice failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1519,8 +1554,7 @@ dx_setup() {
|
|||||||
D3DVIEWPORT7 vp = { 0, 0, _props._xsize, _props._ysize, 0.0f, 1.0f};
|
D3DVIEWPORT7 vp = { 0, 0, _props._xsize, _props._ysize, 0.0f, 1.0f};
|
||||||
hr = pD3DDevice->SetViewport( &vp );
|
hr = pD3DDevice->SetViewport( &vp );
|
||||||
if(hr != DD_OK) {
|
if(hr != DD_OK) {
|
||||||
wdxdisplay_cat.fatal()
|
wdxdisplay_cat.fatal() << "SetViewport failed : result = " << ConvD3DErrorToString(hr) << endl;
|
||||||
<< "config() - SetViewport failed : result = " << ConvD3DErrorToString(hr) << endl;
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,6 +264,11 @@ static DWORD GetAvailVidMem(void) {
|
|||||||
} else {
|
} else {
|
||||||
if(wgldisplay_cat.is_debug())
|
if(wgldisplay_cat.is_debug())
|
||||||
wgldisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
wgldisplay_cat.debug() << "before FullScreen switch: GetAvailableVidMem returns Total: " << dwTotal/1000000.0 << " Free: " << dwFree/1000000.0 << endl;
|
||||||
|
if(dwTotal==0) {
|
||||||
|
if(wgldisplay_cat.is_debug())
|
||||||
|
wgldisplay_cat.debug() << "GetAvailVidMem returns bogus total of 0, assuming we have plenty of vidmem\n";
|
||||||
|
dwTotal=dwFree=0x7FFFFFFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pDD2->Release(); // bye-bye ddraw
|
pDD2->Release(); // bye-bye ddraw
|
||||||
|
Loading…
x
Reference in New Issue
Block a user