From 7c826e57e8da1872b3c3bc8ba495887d046af263 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Sun, 19 Nov 2017 20:47:03 -0500 Subject: [PATCH] Changed g_nvgfx_totalframebufs to 2. Removed the gfxFlushBuffers() call in _gfxInit() and added a dcache-flush in nvmapobjInitialize(). Moved the nvgfxGetFramebuffer() call. Added a delay in _gfxInit(). Changed the initial g_gfxCurrentBuffer value, which is then updated by _gfxDequeueBuffer() later. Adjusted the code for updating g_gfxCurrentBuffer. For the gfxproducerDequeueBuffer() call, changed the value for the async param from 1 to 0. --- nx/source/gfx/gfx.c | 14 ++++++++------ nx/source/gfx/nvgfx.c | 4 +++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/nx/source/gfx/gfx.c b/nx/source/gfx/gfx.c index 3f727837..35a5ffed 100644 --- a/nx/source/gfx/gfx.c +++ b/nx/source/gfx/gfx.c @@ -48,9 +48,9 @@ static Result _gfxGetNativeWindowID(u8 *buf, u64 size, s32 *out_ID) { static Result _gfxDequeueBuffer() { Result rc=0; - rc = gfxproducerDequeueBuffer(1, 1280, 720, 0, 0x300, &g_gfxCurrentProducerBuffer); + rc = gfxproducerDequeueBuffer(/*1*/0, 1280, 720, 0, 0x300, &g_gfxCurrentProducerBuffer); - if (R_SUCCEEDED(rc)) g_gfxCurrentBuffer = (g_gfxCurrentBuffer+1) & (g_nvgfx_totalframebufs-1); + if (R_SUCCEEDED(rc)) g_gfxCurrentBuffer = /*(g_gfxCurrentBuffer+1)*/(g_gfxCurrentProducerBuffer) & (g_nvgfx_totalframebufs-1); return rc; } @@ -80,7 +80,7 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L g_gfxNativeWindow_ID = 0; g_gfxDisplayVsyncEvent = INVALID_HANDLE; - g_gfxCurrentBuffer = 0; + g_gfxCurrentBuffer = -1; g_gfxCurrentProducerBuffer = 0; g_gfxFramebuf = NULL; g_gfxFramebufSize = 0; @@ -111,6 +111,8 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L if (R_SUCCEEDED(rc)) rc = nvgfxInitialize(); + if (R_SUCCEEDED(rc)) rc = nvgfxGetFramebuffer(&g_gfxFramebuf, &g_gfxFramebufSize); + if (R_SUCCEEDED(rc)) { for(i=0; i<2; i++) { rc = _gfxDequeueBuffer(); @@ -130,9 +132,9 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L if (R_SUCCEEDED(rc)) rc = _gfxDequeueBuffer(); - if (R_SUCCEEDED(rc)) rc = nvgfxGetFramebuffer(&g_gfxFramebuf, &g_gfxFramebufSize); - - if (R_SUCCEEDED(rc)) gfxFlushBuffers(); + if (R_SUCCEEDED(rc)) { //Workaround a gfx display issue. + for(i=0; i<2; i++)gfxWaitForVsync(); + } if (R_FAILED(rc)) { nvgfxExit(); diff --git a/nx/source/gfx/nvgfx.c b/nx/source/gfx/nvgfx.c index 5749e2ec..05b28446 100644 --- a/nx/source/gfx/nvgfx.c +++ b/nx/source/gfx/nvgfx.c @@ -87,6 +87,8 @@ Result nvmapobjInitialize(nvmapobj *obj, size_t size) { if (obj->mem==NULL) rc = MAKERESULT(MODULE_LIBNX, LIBNX_OUTOFMEM); if (R_SUCCEEDED(rc)) memset(obj->mem, 0, size); + if (R_SUCCEEDED(rc)) armDCacheFlush(obj->mem, size); + if (R_SUCCEEDED(rc)) obj->initialized = 1; return rc; @@ -139,7 +141,7 @@ Result nvgfxInitialize(void) { g_nvgfx_nvhostctrl_eventhandle = INVALID_HANDLE; - g_nvgfx_totalframebufs = 4; + g_nvgfx_totalframebufs = 2;//4; memset(nvmap_objs, 0, sizeof(nvmap_objs));