diff --git a/nx/source/gfx/gfx.c b/nx/source/gfx/gfx.c index 19afa156..3f727837 100644 --- a/nx/source/gfx/gfx.c +++ b/nx/source/gfx/gfx.c @@ -17,6 +17,8 @@ static size_t g_gfxFramebufSingleSize = 0x3c0000; extern u32 __nx_applet_type; +extern u32 g_nvgfx_totalframebufs; + static u32 g_gfxQueueBufferData[0x5c>>2] = { 0x54, 0x0, 0x0, 0x0, //u64 timestamp @@ -48,7 +50,7 @@ static Result _gfxDequeueBuffer() { rc = gfxproducerDequeueBuffer(1, 1280, 720, 0, 0x300, &g_gfxCurrentProducerBuffer); - if (R_SUCCEEDED(rc)) g_gfxCurrentBuffer = (g_gfxCurrentBuffer+1) & 3; + if (R_SUCCEEDED(rc)) g_gfxCurrentBuffer = (g_gfxCurrentBuffer+1) & (g_nvgfx_totalframebufs-1); return rc; } diff --git a/nx/source/gfx/nvgfx.c b/nx/source/gfx/nvgfx.c index eaf1ede3..5749e2ec 100644 --- a/nx/source/gfx/nvgfx.c +++ b/nx/source/gfx/nvgfx.c @@ -33,6 +33,8 @@ static u8 *g_nvgfx_nvhost_userdata; static size_t g_nvgfx_nvhost_userdata_size; static u32 g_nvgfx_nvhostctrl_eventres; +u32 g_nvgfx_totalframebufs = 0; + static nvmapobj nvmap_objs[18]; static u64 nvmap_obj6_mapbuffer_xdb_offset; @@ -49,7 +51,7 @@ static u32 g_gfxprod_BufferInitData[0x178>>2] = { 0x0, 0xdaffcaff, 0x2a, 0x0, 0xb00, 0x1, 0x1, 1280, 0x3c0000, 0x1, 0x0, 1280, -720, 0x532120, 0x1, 0x3, //0x52* field is flags +720, 0x532120/* & ~0x20*/, 0x1, 0x3, //0x52* field is flags 0x1400, 0x0, //nvmap handle 0x0, @@ -137,6 +139,8 @@ Result nvgfxInitialize(void) { g_nvgfx_nvhostctrl_eventhandle = INVALID_HANDLE; + g_nvgfx_totalframebufs = 4; + memset(nvmap_objs, 0, sizeof(nvmap_objs)); memset(&g_nvgfx_gpu_characteristics, 0, sizeof(gpu_characteristics)); @@ -158,7 +162,7 @@ Result nvgfxInitialize(void) { if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[3], 0x10000); if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[4], 0x59000); if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[5], 0x1000000); - if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[6], 0x4000000); + if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[6], g_nvgfx_totalframebufs*0x3c0000); if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[7], 0x1000000); if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[8], 0x800000); if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[9], 0x100000); @@ -273,7 +277,7 @@ Result nvgfxInitialize(void) { //Skip init for 0x10000000-byte nvmap obj done by certain official sw. if (R_SUCCEEDED(rc)) { - for(pos=0; pos<4; pos++) { + for(pos=0; pos