From 4e77c36c30ddeee43aeea2fad2106edb9489bab6 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Fri, 29 Dec 2017 22:04:15 -0500 Subject: [PATCH] Perf adjustments for gfxGetFramebufferDisplayOffset(). --- nx/include/switch/gfx/gfx.h | 11 +++++++---- nx/source/gfx/gfx.c | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/nx/include/switch/gfx/gfx.h b/nx/include/switch/gfx/gfx.h index 5925eb54..8874e1c2 100644 --- a/nx/include/switch/gfx/gfx.h +++ b/nx/include/switch/gfx/gfx.h @@ -53,13 +53,16 @@ void gfxFlushBuffers(void); /// Use this to get the pixel-offset in the framebuffer. Returned value is in pixels, not bytes. /// This implements tegra blocklinear, with hard-coded constants etc. static inline u32 gfxGetFramebufferDisplayOffset(u32 x, u32 y) { - u32 width=0, height=0; + u32 width, height; u32 tilepos, tmp_pos; - gfxGetFramebufferResolution(&width, NULL); - gfxGetFramebuffer(NULL, &height); + extern size_t g_gfx_framebuf_width; + extern size_t g_gfx_framebuf_display_height; - if (x >= width || y >= height) return (gfxGetFramebufferSize()-4)/4;//Return the last pixel-offset in the buffer, the data located here is not displayed due to alignment. + width = g_gfx_framebuf_width; + height = g_gfx_framebuf_display_height; + + //if (x >= width || y >= height) return (gfxGetFramebufferSize()-4)/4;//Return the last pixel-offset in the buffer, the data located here is not displayed due to alignment. (Disabled for perf) y = height-1-y; diff --git a/nx/source/gfx/gfx.c b/nx/source/gfx/gfx.c index 9f8a5e7b..c0fbcc28 100644 --- a/nx/source/gfx/gfx.c +++ b/nx/source/gfx/gfx.c @@ -21,9 +21,9 @@ static bufferProducerQueueBufferOutput g_gfx_QueueBuffer_QueueBufferOutput; static bool g_gfxDoubleBuf = 1; -static size_t g_gfx_framebuf_width=0, g_gfx_framebuf_aligned_width=0; -static size_t g_gfx_framebuf_height=0, g_gfx_framebuf_aligned_height=0; -static size_t g_gfx_framebuf_display_width=0, g_gfx_framebuf_display_height=0; +size_t g_gfx_framebuf_width=0, g_gfx_framebuf_aligned_width=0; +size_t g_gfx_framebuf_height=0, g_gfx_framebuf_aligned_height=0; +size_t g_gfx_framebuf_display_width=0, g_gfx_framebuf_display_height=0; size_t g_gfx_singleframebuf_size=0; static appletHookCookie g_gfx_autoresolution_applethookcookie;