Fixed flickering
This commit is contained in:
@@ -15,8 +15,6 @@ errorret_t assetAlphaImageLoad(void *data, void *output) {
|
|||||||
assertNotNull(data, "Data pointer cannot be NULL.");
|
assertNotNull(data, "Data pointer cannot be NULL.");
|
||||||
assertNotNull(output, "Output 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;
|
assetalphaimage_t *dataPtr = (assetalphaimage_t *)data;
|
||||||
texture_t *outputPtr = (texture_t *)output;
|
texture_t *outputPtr = (texture_t *)output;
|
||||||
|
|
||||||
|
|||||||
@@ -51,9 +51,9 @@ void debugFlush() {
|
|||||||
GXRModeObj *rmode = NULL;
|
GXRModeObj *rmode = NULL;
|
||||||
void *framebuffer;
|
void *framebuffer;
|
||||||
|
|
||||||
if(DISPLAY.frameBuffer) {
|
if(DISPLAY.frameBuffer[0]) {
|
||||||
console_init(
|
console_init(
|
||||||
DISPLAY.frameBuffer,
|
DISPLAY.frameBuffer[0],
|
||||||
20,
|
20,
|
||||||
20,
|
20,
|
||||||
DISPLAY.screenMode->fbWidth,
|
DISPLAY.screenMode->fbWidth,
|
||||||
|
|||||||
@@ -25,22 +25,9 @@
|
|||||||
|
|
||||||
display_t DISPLAY = { 0 };
|
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) {
|
errorret_t displayInit(void) {
|
||||||
|
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||||
|
|
||||||
#if DISPLAY_SDL2
|
#if DISPLAY_SDL2
|
||||||
uint32_t flags = SDL_INIT_VIDEO;
|
uint32_t flags = SDL_INIT_VIDEO;
|
||||||
#if INPUT_GAMEPAD == 1
|
#if INPUT_GAMEPAD == 1
|
||||||
@@ -93,47 +80,66 @@ errorret_t displayInit(void) {
|
|||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
#elif DOLPHIN
|
#elif DOLPHIN
|
||||||
|
|
||||||
VIDEO_Init();
|
VIDEO_Init();
|
||||||
DISPLAY.screenMode = VIDEO_GetPreferredMode(NULL);
|
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)
|
SYS_AllocateFramebuffer(DISPLAY.screenMode)
|
||||||
);
|
);
|
||||||
VIDEO_Configure(DISPLAY.screenMode);
|
VIDEO_Configure(DISPLAY.screenMode);
|
||||||
|
|
||||||
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer);
|
VIDEO_SetNextFramebuffer(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer]);
|
||||||
VIDEO_SetPostRetraceCallback(copy_buffers);
|
// VIDEO_SetPostRetraceCallback(copy_buffers);
|
||||||
VIDEO_SetBlack(FALSE);
|
VIDEO_SetBlack(FALSE);
|
||||||
VIDEO_Flush();
|
VIDEO_Flush();
|
||||||
// VIDEO_WaitVSync();
|
VIDEO_WaitVSync();
|
||||||
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
||||||
|
|
||||||
DISPLAY.fifoBuffer = MEM_K0_TO_K1(memalign(32, FIFO_SIZE));
|
DISPLAY.fifoBuffer = memalign(32, DISPLAY_FIFO_SIZE);
|
||||||
memoryZero(DISPLAY.fifoBuffer, 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
|
// This seems to be mostly related to interlacing vs progressive
|
||||||
GX_SetDispCopyYScale(
|
GX_SetViewport(
|
||||||
(f32)DISPLAY.screenMode->xfbHeight /
|
0, 0,
|
||||||
(f32)DISPLAY.screenMode->efbHeight
|
DISPLAY.screenMode->fbWidth, DISPLAY.screenMode->efbHeight,
|
||||||
|
0, 1
|
||||||
);
|
);
|
||||||
GX_SetScissor(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
|
float_t yscale = GX_GetYScaleFactor(
|
||||||
GX_SetDispCopySrc(0,0,DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->efbHeight);
|
DISPLAY.screenMode->efbHeight, DISPLAY.screenMode->xfbHeight
|
||||||
GX_SetDispCopyDst(DISPLAY.screenMode->fbWidth,DISPLAY.screenMode->xfbHeight);
|
);
|
||||||
GX_SetCopyFilter(DISPLAY.screenMode->aa,DISPLAY.screenMode->sample_pattern,
|
uint32_t xfbHeight = GX_SetDispCopyYScale(yscale);
|
||||||
GX_TRUE,DISPLAY.screenMode->vfilter);
|
GX_SetScissor(
|
||||||
GX_SetFieldMode(DISPLAY.screenMode->field_rendering, (
|
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) ?
|
(DISPLAY.screenMode->viHeight == 2 * DISPLAY.screenMode->xfbHeight) ?
|
||||||
GX_ENABLE : GX_DISABLE
|
GX_ENABLE :
|
||||||
));
|
GX_DISABLE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
// Setup cull modes
|
// Setup cull modes
|
||||||
GX_SetCullMode(GX_CULL_NONE);
|
GX_SetCullMode(GX_CULL_NONE);
|
||||||
|
GX_CopyDisp(DISPLAY.frameBuffer[DISPLAY.whichFrameBuffer], GX_TRUE);
|
||||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||||
|
|
||||||
//?
|
|
||||||
GX_CopyDisp(DISPLAY.frameBuffer, GX_TRUE);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
quadInit();
|
quadInit();
|
||||||
@@ -209,10 +215,14 @@ errorret_t displayUpdate(void) {
|
|||||||
}
|
}
|
||||||
#elif DOLPHIN
|
#elif DOLPHIN
|
||||||
GX_DrawDone();
|
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();
|
VIDEO_WaitVSync();
|
||||||
// if(DISPLAY.screenMode->viTVMode & VI_NON_INTERLACE) VIDEO_WaitVSync();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For now, we just return an OK error.
|
// For now, we just return an OK error.
|
||||||
|
|||||||
@@ -17,7 +17,8 @@ typedef struct {
|
|||||||
SDL_GLContext glContext;
|
SDL_GLContext glContext;
|
||||||
|
|
||||||
#elif DOLPHIN
|
#elif DOLPHIN
|
||||||
void *frameBuffer;
|
void *frameBuffer[2];// Double-Bufferred
|
||||||
|
int whichFrameBuffer;
|
||||||
GXRModeObj *screenMode;
|
GXRModeObj *screenMode;
|
||||||
void *fifoBuffer;
|
void *fifoBuffer;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#elif DOLPHIN
|
#elif DOLPHIN
|
||||||
// Dolphin.
|
// Dolphin.
|
||||||
|
#define DISPLAY_FIFO_SIZE (256*1024)
|
||||||
#else
|
#else
|
||||||
#error "Need to specify display backend."
|
#error "Need to specify display backend."
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "display/mesh/quad.h"
|
#include "display/mesh/quad.h"
|
||||||
#include "display/texture.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)
|
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user