From e234129598017bd940130e4dde13faf64b11b509 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Mon, 25 Jun 2018 15:26:45 +0200 Subject: [PATCH] gfx: Add a buffer index to gfxGetFramebufferHandle(). --- nx/include/switch/display/gfx.h | 4 ++-- nx/source/display/gfx.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/nx/include/switch/display/gfx.h b/nx/include/switch/display/gfx.h index ad0aeeb8..2fde1044 100644 --- a/nx/include/switch/display/gfx.h +++ b/nx/include/switch/display/gfx.h @@ -73,8 +73,8 @@ void gfxWaitForVsync(void); /// Swaps the framebuffers (for double-buffering). void gfxSwapBuffers(void); -/// Get the current framebuffer nvmap handle, with optional output ptrs for the current offset in the buffer. -u32 gfxGetFramebufferHandle(u32* offset); +/// Get the specified framebuffer nvmap handle where index specifies the buffer number beginning with the back buffer, with optional output ptr for the offset in the buffer. +u32 gfxGetFramebufferHandle(u32 index, u32* offset); /// Get the current framebuffer address, with optional output ptrs for the display framebuffer width/height. The display width/height is adjusted by \ref gfxConfigureCrop and \ref gfxConfigureResolution. u8* gfxGetFramebuffer(u32* width, u32* height); diff --git a/nx/source/display/gfx.c b/nx/source/display/gfx.c index ade25ce3..b31a2caf 100644 --- a/nx/source/display/gfx.c +++ b/nx/source/display/gfx.c @@ -503,8 +503,11 @@ void gfxSwapBuffers(void) { if (R_FAILED(rc)) fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGfxDequeueBuffer)); } -u32 gfxGetFramebufferHandle(u32* offset) { - if (offset) *offset = g_gfxCurrentBuffer*g_gfx_singleframebuf_size; +u32 gfxGetFramebufferHandle(u32 index, u32* offset) { + if (offset) { + index = (g_gfxCurrentBuffer + index) & (g_nvgfx_totalframebufs-1); + *offset = index*g_gfx_singleframebuf_size; + } return g_gfxFramebufHandle; }