From 2022d545dc7e742360bffee4c209ac70dcf26d1c Mon Sep 17 00:00:00 2001 From: yellows8 Date: Thu, 22 Feb 2018 21:49:55 -0500 Subject: [PATCH] Store pixel-format in a global instead of hard-coding it and added a disabled func for setting it. Added a pixel-format comment to gfx.h. --- nx/include/switch/gfx/gfx.h | 2 ++ nx/source/gfx/gfx.c | 9 ++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nx/include/switch/gfx/gfx.h b/nx/include/switch/gfx/gfx.h index 8a39503c..a7555f03 100644 --- a/nx/include/switch/gfx/gfx.h +++ b/nx/include/switch/gfx/gfx.h @@ -22,6 +22,8 @@ typedef enum GfxMode_LinearDouble ///< Double-buffering with linear framebuffer, which is transferred to the actual framebuffer by \ref gfxFlushBuffers(). } GfxMode; +/// Framebuffer pixel-format is RGBA8888, there's no known way to change this. + /** * @brief Initializes the graphics subsystem. * @warning Do not use \ref viInitialize when using this function. diff --git a/nx/source/gfx/gfx.c b/nx/source/gfx/gfx.c index 8bfa2208..c93e2b53 100644 --- a/nx/source/gfx/gfx.c +++ b/nx/source/gfx/gfx.c @@ -34,6 +34,8 @@ static GfxMode g_gfxMode = GfxMode_LinearDouble; static u8 *g_gfxFramebufLinear; +static s32 g_gfxPixelFormat = 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; @@ -136,7 +138,7 @@ static Result _gfxDequeueBuffer(void) { memcpy(&tmp_fence, fence, sizeof(bufferProducerFence));//Offical sw waits on the fence from the previous DequeueBuffer call. Using the fence from the current DequeueBuffer call results in nvgfxEventWait() failing. - rc = bufferProducerDequeueBuffer(async, g_gfx_framebuf_width, g_gfx_framebuf_height, 0, 0x300, &g_gfxCurrentProducerBuffer, fence); + rc = bufferProducerDequeueBuffer(async, g_gfx_framebuf_width, g_gfx_framebuf_height, g_gfxPixelFormat, 0x300, &g_gfxCurrentProducerBuffer, fence); //Only run nvgfxEventWait when the fence is valid and the id is not NO_FENCE. if (R_SUCCEEDED(rc) && tmp_fence.is_valid && tmp_fence.nv_fences[0].id!=0xffffffff) rc = nvgfxEventWait(tmp_fence.nv_fences[0].id, tmp_fence.nv_fences[0].value, -1); @@ -181,6 +183,7 @@ static Result _gfxInit(ViServiceType servicetype, const char *DisplayName, u32 L g_gfx_drawflip = true; g_gfxQueueBufferData.transform = NATIVE_WINDOW_TRANSFORM_FLIP_V; + g_gfxPixelFormat = 0; memset(g_gfx_ProducerSlotsRequested, 0, sizeof(g_gfx_ProducerSlotsRequested)); memset(&g_gfx_DequeueBuffer_fence, 0, sizeof(g_gfx_DequeueBuffer_fence)); @@ -551,6 +554,10 @@ void gfxConfigureTransform(u32 transform) { g_gfxQueueBufferData.transform = transform; } +/*void gfxSetPixelFormat(s32 format) { + g_gfxPixelFormat = format; +}*/ + void gfxFlushBuffers(void) { u32 *actual_framebuf = (u32*)&g_gfxFramebuf[g_gfxCurrentBuffer*g_gfx_singleframebuf_size];