Fixed flickering
Some checks failed
Build Dusk / run-tests (push) Successful in 1m42s
Build Dusk / build-psp (push) Has been cancelled
Build Dusk / build-linux (push) Has been cancelled
Build Dusk / build-dolphin (push) Has been cancelled

This commit is contained in:
2026-02-06 13:31:15 -06:00
parent aa5b41fe31
commit 097c8c00f9
6 changed files with 57 additions and 47 deletions

View File

@@ -15,8 +15,6 @@ errorret_t assetAlphaImageLoad(void *data, void *output) {
assertNotNull(data, "Data pointer cannot be NULL.");
assertNotNull(output, "Output pointer cannot be NULL.");
debugPrint("Loading ASSET_TYPE_ALPHA_IMAGE asset.\n");
assetalphaimage_t *dataPtr = (assetalphaimage_t *)data;
texture_t *outputPtr = (texture_t *)output;

View File

@@ -51,9 +51,9 @@ void debugFlush() {
GXRModeObj *rmode = NULL;
void *framebuffer;
if(DISPLAY.frameBuffer) {
if(DISPLAY.frameBuffer[0]) {
console_init(
DISPLAY.frameBuffer,
DISPLAY.frameBuffer[0],
20,
20,
DISPLAY.screenMode->fbWidth,

View File

@@ -25,22 +25,9 @@
display_t DISPLAY = { 0 };
#if DOLPHIN
static vu8 readyForCopy;
#define FIFO_SIZE (256*1024)
static void copy_buffers(u32 count __attribute__ ((unused)))
{
if (readyForCopy==GX_TRUE) {
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(DISPLAY.frameBuffer,GX_TRUE);
GX_Flush();
readyForCopy = GX_FALSE;
}
}
#endif
errorret_t displayInit(void) {
memoryZero(&DISPLAY, sizeof(DISPLAY));
#if DISPLAY_SDL2
uint32_t flags = SDL_INIT_VIDEO;
#if INPUT_GAMEPAD == 1
@@ -93,47 +80,66 @@ errorret_t displayInit(void) {
glEnableClientState(GL_VERTEX_ARRAY);
#elif DOLPHIN
VIDEO_Init();
DISPLAY.screenMode = VIDEO_GetPreferredMode(NULL);
DISPLAY.frameBuffer = MEM_K0_TO_K1(
DISPLAY.frameBuffer[0] = MEM_K0_TO_K1(
SYS_AllocateFramebuffer(DISPLAY.screenMode)
);
DISPLAY.frameBuffer[1] = MEM_K0_TO_K1(
SYS_AllocateFramebuffer(DISPLAY.screenMode)
);
VIDEO_Configure(DISPLAY.screenMode);
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer);
VIDEO_SetPostRetraceCallback(copy_buffers);
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
// VIDEO_SetPostRetraceCallback(copy_buffers);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
// VIDEO_WaitVSync();
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
VIDEO_WaitVSync();
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
DISPLAY.fifoBuffer = MEM_K0_TO_K1(memalign(32, FIFO_SIZE));
memoryZero(DISPLAY.fifoBuffer, FIFO_SIZE);
DISPLAY.fifoBuffer = memalign(32, DISPLAY_FIFO_SIZE);
memoryZero(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
GX_Init(DISPLAY.fifoBuffer, FIFO_SIZE);
GX_Init(DISPLAY.fifoBuffer, DISPLAY_FIFO_SIZE);
// This seems to be mostly related to interlacing vs progressive
GX_SetDispCopyYScale(
(f32)DISPLAY.screenMode->xfbHeight /
(f32)DISPLAY.screenMode->efbHeight
GX_SetViewport(
0, 0,
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight,
0, 1
);
float_t yscale = GX_GetYScaleFactor(
DISPLAY.screenMode->efbHeight, DISPLAY.screenMode->xfbHeight
);
uint32_t xfbHeight = GX_SetDispCopyYScale(yscale);
GX_SetScissor(
0, 0,
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
);
GX_SetDispCopySrc(
0, 0,
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight
);
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth, xfbHeight);
GX_SetCopyFilter(
DISPLAY.screenMode->aa,
DISPLAY.screenMode->sample_pattern,
GX_TRUE,
DISPLAY.screenMode->vfilter
);
GX_SetFieldMode(
DISPLAY.screenMode->field_rendering,
(
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
GX_ENABLE :
GX_DISABLE
)
);
GX_SetScissor(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
GX_SetDispCopySrc(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->xfbHeight);
GX_SetCopyFilter(DISPLAY.screenMode->aa,DISPLAY.screenMode->sample_pattern,
GX_TRUE,DISPLAY.screenMode->vfilter);
GX_SetFieldMode(DISPLAY.screenMode->field_rendering, (
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
GX_ENABLE : GX_DISABLE
));
// Setup cull modes
GX_SetCullMode(GX_CULL_NONE);
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
GX_SetDispCopyGamma(GX_GM_1_0);
//?
GX_CopyDisp(DISPLAY.frameBuffer, GX_TRUE);
#endif
quadInit();
@@ -209,10 +215,14 @@ errorret_t displayUpdate(void) {
}
#elif DOLPHIN
GX_DrawDone();
readyForCopy = GX_TRUE;
DISPLAY.whichFrameBuffer ^= 1;
GX_SetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetColorUpdate(GX_TRUE);
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
VIDEO_Flush();
VIDEO_WaitVSync();
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
#endif
// For now, we just return an OK error.

View File

@@ -17,7 +17,8 @@ typedef struct {
SDL_GLContext glContext;
#elif DOLPHIN
void *frameBuffer;
void *frameBuffer[2];// Double-Bufferred
int whichFrameBuffer;
GXRModeObj *screenMode;
void *fifoBuffer;

View File

@@ -20,6 +20,7 @@
#endif
#elif DOLPHIN
// Dolphin.
#define DISPLAY_FIFO_SIZE (256*1024)
#else
#error "Need to specify display backend."
#endif

View File

@@ -9,7 +9,7 @@
#include "display/mesh/quad.h"
#include "display/texture.h"
#define SPRITEBATCH_SPRITES_MAX 1
#define SPRITEBATCH_SPRITES_MAX 32
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)