Skip to content

Commit 66c7ba8

Browse files
committed
Fix garbage frame scan-out during WAD loading
Implement stable black frame solution that presents known frames before blocking WAD load operations to prevent garbage scan-out on both TV and GamePad displays. Changes: - Add I_PresentBlackFrame() helper function in i_video.c - Call I_PresentBlackFrame() before IWAD loading (D_AddFile) - Call I_PresentBlackFrame() before PWAD loading (W_ParseCommandLine) - Present two frames to ensure both TV and GamePad buffers are valid - Only affects Wii U builds via __WIIU__ preprocessor guards This solution addresses the root cause: during WAD loading the main thread blocks, no SDL_RenderPresent() calls occur, and GX2's scan-outs begin scanning uninitialised back buffers. By presenting stable black frames before the blocking operations, both displays show clean content during loading transitions.
1 parent 4a4be45 commit 66c7ba8

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/doom/d_main.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,10 @@ void D_DoomMain (void)
16881688
modifiedgame = false;
16891689

16901690
DEH_printf("W_Init: Init WADfiles.\n");
1691+
#ifdef __WIIU__
1692+
// Present stable black frame before blocking WAD load to prevent garbage scan-out
1693+
I_PresentBlackFrame();
1694+
#endif // __WIIU__
16911695
D_AddFile(iwadfile);
16921696
numiwadlumps = numlumps;
16931697

@@ -1834,6 +1838,10 @@ void D_DoomMain (void)
18341838
DEH_ParseCommandLine();
18351839

18361840
// Load PWAD files.
1841+
#ifdef __WIIU__
1842+
// Present stable black frame before blocking PWAD load to prevent garbage scan-out
1843+
I_PresentBlackFrame();
1844+
#endif // __WIIU__
18371845
modifiedgame = W_ParseCommandLine();
18381846

18391847
//!

src/i_video.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ int WIDESCREENDELTA; // [crispy] horizontal widescreen offset
6060
static SDL_Window *screen;
6161
static SDL_Renderer *renderer;
6262

63+
// Helper function to present a stable black frame during blocking operations
64+
void I_PresentBlackFrame(void) {
65+
if (renderer != NULL) {
66+
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255);
67+
SDL_RenderClear(renderer);
68+
SDL_RenderPresent(renderer);
69+
SDL_RenderPresent(renderer); // second call ensures both TV and GamePad buffers are valid
70+
}
71+
}
72+
6373
// Window title
6474

6575
static const char *window_title = "";

src/i_video.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ typedef boolean (*grabmouse_callback_t)(void);
5151
// determines the hardware configuration
5252
// and sets up the video mode
5353
void I_InitGraphics (void);
54+
void I_PresentBlackFrame(void);
5455

5556
void I_GraphicsCheckCommandLine(void);
5657

0 commit comments

Comments
 (0)