Homebrew Bottom screen Flickering using libctru

Peanut42

Active Member
OP
Newcomer
Joined
Jun 27, 2015
Messages
44
Trophies
0
XP
194
Country
Mexico
Hi

Another difficult question, I have some flickering in my Paddle Puffle game. Especially when drawing to the bottom screen. I'm using libctru and a loop like this:

Code:
while (aptMainLoop () && !done) {
     last_time = svcGetSystemTick ();
     hidScanInput ();
     keys = hidKeysDown ();
     
     if (keys & KEY_START) {
       done = 1;
     }
     
     // Draw all the stuff to the top screen here
     
     //Wait for VBlank
     gspWaitForVBlank();
     
     gfxFlushBuffers();
     gfxSwapBuffers();
     
     // Draw all stuff to the bottom screen here
    
     // Here is the flickering !!!
     now_time = svcGetSystemTick ();
     if (now_time < last_time + FPS) svcSleepThread (last_time + FPS - now_time);
}

Some suggestions to avoid the bottom screen flickering?
 

nop90

Well-Known Member
Member
Joined
Jan 11, 2014
Messages
1,556
Trophies
0
Location
Rome
XP
3,136
Country
Italy
There is something broken in ctrulib HW rendering, and if you're using the ctulib console, it uses HW rendering.

I had similar problems till last week, then there was a rollback on the ctrulib github to solve some HW rendering problems.

I installed that version and most of the problems are now solved (sometime the flickering starts again, but very seldom).

Try to update yout ctrulib to fix the problem.

P.S. : I don't know if the latest commit works fine, i'm abroad with a very bad connection.
 

Rinnegatamante

Well-Known Member
Member
Joined
Nov 24, 2014
Messages
3,162
Trophies
2
Age
29
Location
Bologna
Website
rinnegatamante.it
XP
4,858
Country
Italy

Peanut42

Active Member
OP
Newcomer
Joined
Jun 27, 2015
Messages
44
Trophies
0
XP
194
Country
Mexico
Why you draw bottom screen after flushing and swapping buffers?

That's my point, I don't know if flush buffers pushes both buffers. I found functions named gspWaitForVBlank0, gspWaitForVBlank1 and gspWaitForVBlank. The macro "gspWaitForVBlank" is an alias for "gspWaitForVBlank0". Don't know what exactly do gspWaitForVBlank1.

After drawing both screens, should I flush buffers, Wait for VBlank (for both? the 0 and 1) and swapbuffers?
The bottom screen uses doble buffering too?
 

MRJPGames

Pretty great guy
Member
Joined
Aug 17, 2013
Messages
1,199
Trophies
1
Location
The Netherlands
Website
fizazy.com
XP
1,686
Country
Netherlands
That's my point, I don't know if flush buffers pushes both buffers. I found functions named gspWaitForVBlank0, gspWaitForVBlank1 and gspWaitForVBlank. The macro "gspWaitForVBlank" is an alias for "gspWaitForVBlank0". Don't know what exactly do gspWaitForVBlank1.

After drawing both screens, should I flush buffers, Wait for VBlank (for both? the 0 and 1) and swapbuffers?
The bottom screen uses doble buffering too?
gfxFlushBuffers();
gfxSwapBuffers();
gspWaitForEvent(GSPEVENT_VBlank0, false);
The order I use.
 
D

Deleted User

Guest
There is something broken in ctrulib HW rendering, and if you're using the ctulib console, it uses HW rendering.

I had similar problems till last week, then there was a rollback on the ctrulib github to solve some HW rendering problems.

I installed that version and most of the problems are now solved (sometime the flickering starts again, but very seldom).

Try to update yout ctrulib to fix the problem.

P.S. : I don't know if the latest commit works fine, i'm abroad with a very bad connection.
Just an FYI, the ctrulib console does NOT use HW rendering, it draws directly to the framebuffer in software.
 

NoiseCommander3DS

Member
Newcomer
Joined
May 2, 2024
Messages
11
Trophies
0
Age
43
XP
46
Country
Germany
I am running into this issue as well, the bottom screen flickers.
No matter what order I do swap, flush, wait in.

You can see it in this video


I use the software frame-buffer because my code needs to write individual pixel values.
 

ghjfdtg

Well-Known Member
Member
Joined
Jul 13, 2014
Messages
1,390
Trophies
1
XP
3,383
Country
Make sure you use double buffering on both screens and make sure you use gfxGetFramebuffer() each frame to get the correct buffer to transfer or render to. Also keep in mind with double buffering you alternate between 2 buffers so you can't draw on top of the previous frame unless you use a render buffer and transfer it to the frame buffer each frame.
 
  • Like
Reactions: NoiseCommander3DS

NoiseCommander3DS

Member
Newcomer
Joined
May 2, 2024
Messages
11
Trophies
0
Age
43
XP
46
Country
Germany
It's a bit voodoo-ish to me but it seems that not clearing the lower frame-buffer before drawing into it caused the flickering.
It's not flickering any more, but filling all pixels on both screen seems to be fairly slow (makes sense since it is software rendering as I understand it. I use memset()).
I believe gfxInitDefault(); enables double buffering. At least I noticed no difference after enabling it with gfxSetDoubleBuffering().
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: @Sonic Angel Knight, it's kinda like that