fixed handling of lost d3d device
This commit is contained in:
parent
ba7070f6e8
commit
7bd6d4649e
@ -1,11 +1,13 @@
|
|||||||
#include <rw.h>
|
#include <rw.h>
|
||||||
#include "skeleton.h"
|
#include "skeleton.h"
|
||||||
|
|
||||||
|
|
||||||
namespace sk {
|
namespace sk {
|
||||||
|
|
||||||
Globals globals;
|
Globals globals;
|
||||||
Args args;
|
Args args;
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
InitRW(void)
|
InitRW(void)
|
||||||
{
|
{
|
||||||
@ -22,13 +24,15 @@ InitRW(void)
|
|||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
if(Engine::getSubSystemInfo(&info, i))
|
if(Engine::getSubSystemInfo(&info, i))
|
||||||
printf("subsystem: %s\n", info.name);
|
printf("subsystem: %s\n", info.name);
|
||||||
|
Engine::setSubSystem(n-1);
|
||||||
|
|
||||||
int want = -1;
|
int want = -1;
|
||||||
VideoMode mode;
|
VideoMode mode;
|
||||||
n = Engine::getNumVideoModes();
|
n = Engine::getNumVideoModes();
|
||||||
for(i = 0; i < n; i++)
|
for(i = 0; i < n; i++)
|
||||||
if(Engine::getVideoModeInfo(&mode, i)){
|
if(Engine::getVideoModeInfo(&mode, i)){
|
||||||
if(mode.width == 640 && mode.height == 480 && mode.depth == 32)
|
// if(mode.width == 640 && mode.height == 480 && mode.depth == 32)
|
||||||
|
if(mode.width == 1920 && mode.height == 1080 && mode.depth == 32)
|
||||||
want = i;
|
want = i;
|
||||||
printf("mode: %dx%dx%d %d\n", mode.width, mode.height, mode.depth, mode.flags);
|
printf("mode: %dx%dx%d %d\n", mode.width, mode.height, mode.depth, mode.flags);
|
||||||
}
|
}
|
||||||
|
@ -898,8 +898,7 @@ destroyNativeRaster(void *object, int32 offset, int32)
|
|||||||
Raster *raster = (Raster*)object;
|
Raster *raster = (Raster*)object;
|
||||||
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, offset);
|
D3dRaster *natras = PLUGINOFFSET(D3dRaster, raster, offset);
|
||||||
#ifdef RW_D3D9
|
#ifdef RW_D3D9
|
||||||
if(raster->type == Raster::CAMERATEXTURE)
|
destroyD3D9Raster(raster);
|
||||||
removeVidmemRaster(raster);
|
|
||||||
#endif
|
#endif
|
||||||
if(natras->texture)
|
if(natras->texture)
|
||||||
deleteObject(natras->texture);
|
deleteObject(natras->texture);
|
||||||
|
@ -244,6 +244,18 @@ resetD3d9Device(void)
|
|||||||
d3ddevice->SetMaterial(&d3dmaterial);
|
d3ddevice->SetMaterial(&d3dmaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
destroyD3D9Raster(Raster *raster)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
if(raster->type == Raster::CAMERATEXTURE)
|
||||||
|
removeVidmemRaster(raster);
|
||||||
|
// Make sure we're not still referencing this raster
|
||||||
|
for(i = 0; i < MAXNUMSTAGES; i++)
|
||||||
|
if(rwStateCache.texstage[i].raster == raster)
|
||||||
|
rwStateCache.texstage[i].raster = nil;
|
||||||
|
}
|
||||||
|
|
||||||
// RW render state
|
// RW render state
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -744,12 +756,14 @@ clearCamera(Camera *cam, RGBA *col, uint32 mode)
|
|||||||
Raster *ras = cam->frameBuffer;
|
Raster *ras = cam->frameBuffer;
|
||||||
if(!icon &&
|
if(!icon &&
|
||||||
(r.right != d3d9Globals.present.BackBufferWidth || r.bottom != d3d9Globals.present.BackBufferHeight)){
|
(r.right != d3d9Globals.present.BackBufferWidth || r.bottom != d3d9Globals.present.BackBufferHeight)){
|
||||||
releaseVidmemRasters();
|
|
||||||
|
|
||||||
d3d9Globals.present.BackBufferWidth = r.right;
|
d3d9Globals.present.BackBufferWidth = r.right;
|
||||||
d3d9Globals.present.BackBufferHeight = r.bottom;
|
d3d9Globals.present.BackBufferHeight = r.bottom;
|
||||||
// TODO: check result
|
|
||||||
|
releaseVidmemRasters();
|
||||||
d3d::d3ddevice->Reset(&d3d9Globals.present);
|
d3d::d3ddevice->Reset(&d3d9Globals.present);
|
||||||
|
// important that we get all raster back before restoring state
|
||||||
|
recreateVidmemRasters();
|
||||||
resetD3d9Device();
|
resetD3d9Device();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -763,7 +777,19 @@ showRaster(Raster *raster)
|
|||||||
|
|
||||||
// not used but we want cameras to have rasters
|
// not used but we want cameras to have rasters
|
||||||
assert(raster);
|
assert(raster);
|
||||||
d3ddevice->Present(nil, nil, 0, nil);
|
HRESULT res = d3ddevice->Present(nil, nil, 0, nil);
|
||||||
|
|
||||||
|
if(res == D3DERR_DEVICELOST){
|
||||||
|
res = d3ddevice->TestCooperativeLevel();
|
||||||
|
// lost while being minimized, not reset once we're back
|
||||||
|
if(res == D3DERR_DEVICENOTRESET){
|
||||||
|
releaseVidmemRasters();
|
||||||
|
d3d::d3ddevice->Reset(&d3d9Globals.present);
|
||||||
|
// important that we get all raster back before restoring state
|
||||||
|
recreateVidmemRasters();
|
||||||
|
resetD3d9Device();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool32
|
static bool32
|
||||||
@ -960,6 +986,8 @@ startD3D(void)
|
|||||||
|
|
||||||
// Use window size in windowed mode, otherwise get size from video mode
|
// Use window size in windowed mode, otherwise get size from video mode
|
||||||
if(d3d9Globals.modes[d3d9Globals.currentMode].flags & VIDEOMODEEXCLUSIVE){
|
if(d3d9Globals.modes[d3d9Globals.currentMode].flags & VIDEOMODEEXCLUSIVE){
|
||||||
|
// this will be much better for restoring after iconification
|
||||||
|
SetWindowLong(d3d9Globals.window, GWL_STYLE, WS_POPUP);
|
||||||
width = d3d9Globals.modes[d3d9Globals.currentMode].mode.Width;
|
width = d3d9Globals.modes[d3d9Globals.currentMode].mode.Width;
|
||||||
height = d3d9Globals.modes[d3d9Globals.currentMode].mode.Height;
|
height = d3d9Globals.modes[d3d9Globals.currentMode].mode.Height;
|
||||||
}else{
|
}else{
|
||||||
|
@ -44,6 +44,7 @@ struct D3d9Globals
|
|||||||
extern D3d9Globals d3d9Globals;
|
extern D3d9Globals d3d9Globals;
|
||||||
|
|
||||||
int findFormatDepth(uint32 format);
|
int findFormatDepth(uint32 format);
|
||||||
|
void destroyD3D9Raster(Raster *raster);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void rasterCreate(Raster *raster);
|
void rasterCreate(Raster *raster);
|
||||||
|
@ -27,6 +27,8 @@ void genIm3DEnd(void);
|
|||||||
void initFont(void);
|
void initFont(void);
|
||||||
void printScreen(const char *s, float x, float y);
|
void printScreen(const char *s, float x, float y);
|
||||||
|
|
||||||
|
//#include <Windows.h>
|
||||||
|
|
||||||
void
|
void
|
||||||
Init(void)
|
Init(void)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user