mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-19 11:49:09 +00:00
Fix crashes when changing graphics state
This commit is contained in:
@ -1207,6 +1207,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
|
||||
|
||||
// Main loop
|
||||
if (gClient && !gClient->GetDone()) {
|
||||
if (gPendingActivate)
|
||||
gClient->WindowActivate(gPendingActivateFlag);
|
||||
gClient->SetMessagePumpProc(PumpMessageQueueProc);
|
||||
gClient.Start();
|
||||
|
||||
|
@ -2239,25 +2239,23 @@ bool plDXPipeline::IResetDevice()
|
||||
IFindDepthFormat(fSettings.fPresentParams);
|
||||
}
|
||||
HRESULT hr = fD3DDevice->Reset(&fSettings.fPresentParams);
|
||||
int count = 0;
|
||||
while( FAILED(hr) )
|
||||
{
|
||||
if(count++ == 25)
|
||||
{
|
||||
IPrintDeviceInitError();
|
||||
IResetToDefaults(&fSettings.fPresentParams);
|
||||
// The device is inited the first time on the client loader thread, but this is the main thread
|
||||
// we expect to get one failure... So let's try recreating the device on the main thread.
|
||||
if (FAILED(hr)) {
|
||||
IReleaseDeviceObjects();
|
||||
for (int i = 0; true; ++i) {
|
||||
if (!ICreateDeviceObjects())
|
||||
break;
|
||||
::Sleep(250);
|
||||
// Old magic number from reset land
|
||||
if (i == 25) {
|
||||
IPrintDeviceInitError();
|
||||
IResetToDefaults(&fSettings.fPresentParams);
|
||||
}
|
||||
}
|
||||
// Still not ready? This is bad.
|
||||
// Until we called Reset(), we could make any D3D call we wanted,
|
||||
// and it would turn into a no-op. But once we call Reset(), until
|
||||
// the device really is reset, anything but TestCoop/Reset/Release
|
||||
// has just become illegal. We've already released everything, Reset
|
||||
// just failed, not much to do but wait and try again.
|
||||
::Sleep(250);
|
||||
hr = fD3DDevice->Reset(&fSettings.fPresentParams);
|
||||
}
|
||||
fSettings.fCurrFVFFormat = 0;
|
||||
fSettings.fCurrVertexShader = NULL;
|
||||
fSettings.fCurrVertexShader = nullptr;
|
||||
fManagedAlloced = false;
|
||||
ICreateDynDeviceObjects();
|
||||
IInitDeviceState();
|
||||
|
Reference in New Issue
Block a user