Skip to content

Commit

Permalink
SKETCH: adds more log debug messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ericoporto committed Feb 4, 2023
1 parent 448c34c commit 1aaeef9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Engine/ac/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ void render_to_screen()
gfxDriver->SetVsync((scsystem.vsync > 0) && (!scsystem.windowed));

bool succeeded = false;
Debug::Printf("render_to_screen: will while (!succeeded<%d> && !want_exit<%d> && !abort_engine<%d>)", succeeded, want_exit, abort_engine);
while (!succeeded && !want_exit && !abort_engine)
{
try
Expand All @@ -953,18 +954,22 @@ void render_to_screen()
// For software renderer, need to blacken upper part of the game frame when shaking screen moves image down
if (play.shake_screen_yoff > 0)
{
Debug::Printf("render_to_screen: gfxDriver->ClearRectangle()");
const Rect &viewport = play.GetMainViewport();
gfxDriver->ClearRectangle(viewport.Left, viewport.Top, viewport.GetWidth() - 1, play.shake_screen_yoff, nullptr);
}
Debug::Printf("render_to_screen: gfxDriver->Render()");
gfxDriver->Render(0, play.shake_screen_yoff, (GraphicFlip)play.screen_flipped);
}
succeeded = true;
}
catch (Ali3DFullscreenLostException e)
{
Debug::Printf("Renderer exception: %s", e.Message.GetCStr());
Debug::Printf("render_to_screen: will while (game_update_suspend<%d> && !want_exit<%d> && !abort_engine<%d>)", game_update_suspend, want_exit, abort_engine);
do
{
Debug::Printf("render_to_screen: sys_evt_process_pending()");
sys_evt_process_pending();
platform->Delay(300);
} while (game_update_suspend && (!want_exit) && (!abort_engine));
Expand Down
7 changes: 6 additions & 1 deletion Engine/ac/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,19 +1330,24 @@ void display_switch_in_resume()
ch->resume();
}
}
Debug::Printf("display_switch_in_resume: video_resume()");
video_resume();

// release render targets if switching back to the full screen mode;
// unfortunately, otherwise Direct3D fails to reset device when restoring fullscreen.
if (gfxDriver && gfxDriver->GetDisplayMode().IsRealFullscreen())
release_drawobj_rendertargets();
// clear the screen if necessary
if (gfxDriver && gfxDriver->UsesMemoryBackBuffer())
if (gfxDriver && gfxDriver->UsesMemoryBackBuffer()) {
Debug::Printf("display_switch_in_resume: before gfxDriver->ClearRectangle(0, 0, %d, %d)", game.GetGameRes().Width - 1, game.GetGameRes().Height - 1);
gfxDriver->ClearRectangle(0, 0, game.GetGameRes().Width - 1, game.GetGameRes().Height - 1, nullptr);
Debug::Printf("display_switch_in_resume: after gfxDriver->ClearRectangle(0, 0, %d, %d)", game.GetGameRes().Width - 1, game.GetGameRes().Height - 1);
}

// TODO: find out if anything has to be done here for SDL backend

platform->ResumeApplication();
Debug::Printf("display_switch_in_resume: game_update_suspend = false");
game_update_suspend = false;
}

Expand Down
9 changes: 9 additions & 0 deletions Engine/platform/windows/gfx/ali3dd3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,25 +409,34 @@ void D3DGraphicsDriver::SetGamma(int newGamma)
void D3DGraphicsDriver::ResetDeviceIfNecessary()
{
HRESULT hr = direct3ddevice->TestCooperativeLevel();

Debug::Printf("ResetDeviceIfNecessary: %x = direct3ddevice->TestCooperativeLevel()", hr);
if (hr == D3DERR_DEVICELOST)
{
Debug::Printf("ResetDeviceIfNecessary: throw Ali3DFullscreenLostException()");
throw Ali3DFullscreenLostException();
}

if (hr == D3DERR_DEVICENOTRESET)
{
hr = ResetD3DDevice();
Debug::Printf("ResetDeviceIfNecessary: after %x (0x%08X) = ResetD3DDevice()", hr, hr);
if (hr != D3D_OK)
{
Debug::Printf("ResetDeviceIfNecessary: throw Ali3DException()");
Debug::Printf("threw IDirect3DDevice9::Reset: failed: error code: 0x%08X", hr);
throw Ali3DException(String::FromFormat("IDirect3DDevice9::Reset: failed: error code: 0x%08X", hr));
}

Debug::Printf("ResetDeviceIfNecessary: InitializeD3DState()");
InitializeD3DState();
Debug::Printf("ResetDeviceIfNecessary: CreateVirtualScreen()");
CreateVirtualScreen();
direct3ddevice->SetGammaRamp(0, D3DSGR_NO_CALIBRATION, &currentgammaramp);
}
else if (hr != D3D_OK)
{
Debug::Printf("threw IDirect3DDevice9::TestCooperativeLevel: failed: error code: 0x%08X", hr);
throw Ali3DException(String::FromFormat("IDirect3DDevice9::TestCooperativeLevel: failed: error code: 0x%08X", hr));
}
}
Expand Down

0 comments on commit 1aaeef9

Please sign in to comment.