From 917036cec6008219ecd2982445ff7fe2eb86eed3 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Tue, 19 Dec 2017 13:26:36 -0500 Subject: [PATCH] Updated bufferProducerGraphicBuffer struct. --- nx/include/switch/gfx/buffer_producer.h | 15 ++++++++++- nx/source/gfx/nvgfx.c | 33 ++++++++++++++++--------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/nx/include/switch/gfx/buffer_producer.h b/nx/include/switch/gfx/buffer_producer.h index 35d90d32..82cf436e 100644 --- a/nx/include/switch/gfx/buffer_producer.h +++ b/nx/include/switch/gfx/buffer_producer.h @@ -26,7 +26,20 @@ typedef struct { } PACKED bufferProducerQueueBufferOutput; typedef struct { - u32 unk[0x16c>>2]; + u32 magic; + u32 width; + u32 height; + u32 stride; + u32 format; + u32 usage; + + u32 pid; + u32 refcount; + + u32 numFds; + u32 numInts; + + u32 data[0x144>>2];//Actual size is numFds*4 + numInts*4. } PACKED bufferProducerGraphicBuffer; //From Android window.h. diff --git a/nx/source/gfx/nvgfx.c b/nx/source/gfx/nvgfx.c index 7f8ec8b1..666afd7b 100644 --- a/nx/source/gfx/nvgfx.c +++ b/nx/source/gfx/nvgfx.c @@ -49,12 +49,21 @@ static u64 g_nvgfx_gpfifo_pos = 0; //Some of this struct is based on tegra_dc_ext_flip_windowattr. //TODO: How much of this struct do official apps really set? Most of it seems to be used as-is from the bufferProducerRequestBuffer() output. static bufferProducerGraphicBuffer g_gfxprod_BufferInitData = { -.unk = { -0x47424652, -1280, 720, -1280, -0x1, 0xb00, 0x2a, 0x0, -0x0, 0x51, 0xffffffff, +.magic = 0x47424652,//"RFBG"/'GBFR' +.width = 1280, +.height = 720, +.stride = 1280, +.format = 0x1, +.usage = 0xb00, + +.pid = 0x2a, //Official sw sets this to the output of "getpid()", which calls a func which is hard-coded for returning 0x2a. +.refcount = 0x0, //Official sw sets this to the output of "android_atomic_inc()". + +.numFds = 0x0, +.numInts = sizeof(g_gfxprod_BufferInitData.data)>>2,//0x51 + +.data = { +0xffffffff, 0x0, //nvmap handle 0x0, 0xdaffcaff, 0x2a, 0x0, 0xb00, 0x1, 0x1, 1280, @@ -134,7 +143,7 @@ Result nvgfxInitialize(void) { u32 pos=0, i=0; s32 tmp=0; u32 tmpval=0; - u64 *ptr64 = (u64*)g_gfxprod_BufferInitData.unk; + u64 *ptr64 = (u64*)g_gfxprod_BufferInitData.data; if(g_nvgfxInitialized)return 0; u32 framebuf_nvmap_handle = 0;//Special handle ID for framebuf/windowbuf. @@ -313,11 +322,11 @@ Result nvgfxInitialize(void) { //The above gets a nvmap_handle, but normally it's the same value passed to nvioctlNvmap_GetId(). - g_gfxprod_BufferInitData.unk[0x7] = i; - g_gfxprod_BufferInitData.unk[0xb] = tmpval; - g_gfxprod_BufferInitData.unk[0x1d] = tmpval; - g_gfxprod_BufferInitData.unk[0x1e] = g_nvgfx_singleframebuf_size*i; - ptr64[0x164>>3] = svcGetSystemTick(); + g_gfxprod_BufferInitData.refcount = i; + g_gfxprod_BufferInitData.data[0x1] = tmpval; + g_gfxprod_BufferInitData.data[0x13] = tmpval; + g_gfxprod_BufferInitData.data[0x14] = g_nvgfx_singleframebuf_size*i; + ptr64[0x13c>>3] = svcGetSystemTick(); rc = bufferProducerGraphicBufferInit(i, &g_gfxprod_BufferInitData); if (R_FAILED(rc)) break; }