mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-21 20:42:44 +02:00
Implemented interface for accessing framebuf. Adjustments for gfx init/exit. Removed 0x77 memset for framebuf in nvgfx init.
This commit is contained in:
parent
0d3da1d900
commit
a85ee0458d
@ -1,5 +1,8 @@
|
|||||||
/// Do not use viInitialize/viExit when using these.
|
/// Do not use viInitialize/viExit when using these.
|
||||||
void gfxInitDefault(void);
|
void gfxInitDefault(void);
|
||||||
void gfxExit(void);
|
void gfxExit(void);
|
||||||
|
|
||||||
void gfxWaitForVsync();
|
void gfxWaitForVsync();
|
||||||
void gfxSwapBuffers();
|
void gfxSwapBuffers();
|
||||||
|
u8* gfxGetFramebuffer(u16* width, u16* height);
|
||||||
|
void gfxFlushBuffers(void);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
Result nvgfxInitialize(void);
|
Result nvgfxInitialize(void);
|
||||||
void nvgfxExit(void);
|
void nvgfxExit(void);
|
||||||
Result nvgfxEventInit(void);
|
Result nvgfxEventInit(void);
|
||||||
|
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size);
|
||||||
|
@ -10,6 +10,9 @@ static u64 g_gfxNativeWindow_Size;
|
|||||||
static s32 g_gfxNativeWindow_ID;
|
static s32 g_gfxNativeWindow_ID;
|
||||||
static binderSession g_gfxBinderSession;
|
static binderSession g_gfxBinderSession;
|
||||||
static s32 g_gfxCurrentBuffer = 0;
|
static s32 g_gfxCurrentBuffer = 0;
|
||||||
|
static u8 *g_gfxFramebuf;
|
||||||
|
static size_t g_gfxFramebufSize;
|
||||||
|
static size_t g_gfxFramebufSingleSize = 0x3c0000;
|
||||||
|
|
||||||
extern u32 __nx_applet_type;
|
extern u32 __nx_applet_type;
|
||||||
|
|
||||||
@ -69,6 +72,8 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
g_gfxNativeWindow_ID = 0;
|
g_gfxNativeWindow_ID = 0;
|
||||||
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
||||||
g_gfxCurrentBuffer = 0;
|
g_gfxCurrentBuffer = 0;
|
||||||
|
g_gfxFramebuf = NULL;
|
||||||
|
g_gfxFramebufSize = 0;
|
||||||
|
|
||||||
rc = viInitialize(servicetype);
|
rc = viInitialize(servicetype);
|
||||||
if (R_FAILED(rc)) return rc;
|
if (R_FAILED(rc)) return rc;
|
||||||
@ -115,6 +120,10 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = _gfxDequeueBuffer();
|
if (R_SUCCEEDED(rc)) rc = _gfxDequeueBuffer();
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) rc = nvgfxGetFramebuffer(&g_gfxFramebuf, &g_gfxFramebufSize);
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) gfxFlushBuffers();
|
||||||
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
nvgfxExit();
|
nvgfxExit();
|
||||||
gfxproducerExit();
|
gfxproducerExit();
|
||||||
@ -123,6 +132,16 @@ static Result _gfxInit(viServiceType servicetype, const char *DisplayName, u32 L
|
|||||||
viCloseLayer(&g_gfxLayer);
|
viCloseLayer(&g_gfxLayer);
|
||||||
viCloseDisplay(&g_gfxDisplay);
|
viCloseDisplay(&g_gfxDisplay);
|
||||||
viExit();
|
viExit();
|
||||||
|
|
||||||
|
if(g_gfxDisplayVsyncEvent != INVALID_HANDLE) {
|
||||||
|
svcCloseHandle(g_gfxDisplayVsyncEvent);
|
||||||
|
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_gfxNativeWindow_ID = 0;
|
||||||
|
g_gfxCurrentBuffer = 0;
|
||||||
|
g_gfxFramebuf = NULL;
|
||||||
|
g_gfxFramebufSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) g_gfxInitialized = 1;
|
if (R_SUCCEEDED(rc)) g_gfxInitialized = 1;
|
||||||
@ -176,6 +195,10 @@ void gfxExit(void) {
|
|||||||
|
|
||||||
g_gfxInitialized = 0;
|
g_gfxInitialized = 0;
|
||||||
g_gfxNativeWindow_ID = 0;
|
g_gfxNativeWindow_ID = 0;
|
||||||
|
|
||||||
|
g_gfxCurrentBuffer = 0;
|
||||||
|
g_gfxFramebuf = NULL;
|
||||||
|
g_gfxFramebufSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxWaitForVsync() {
|
void gfxWaitForVsync() {
|
||||||
@ -195,3 +218,14 @@ void gfxSwapBuffers() {
|
|||||||
if (R_FAILED(rc)) fatalSimple(rc);
|
if (R_FAILED(rc)) fatalSimple(rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u8* gfxGetFramebuffer(u16* width, u16* height) {
|
||||||
|
if(width) *width = 1280;
|
||||||
|
if(height) *height = 720;
|
||||||
|
|
||||||
|
return &g_gfxFramebuf[g_gfxCurrentBuffer*g_gfxFramebufSingleSize];
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxFlushBuffers(void) {
|
||||||
|
armDCacheFlush(&g_gfxFramebuf[g_gfxCurrentBuffer*g_gfxFramebufSingleSize], g_gfxFramebufSingleSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -169,8 +169,6 @@ Result nvgfxInitialize(void) {
|
|||||||
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[15], 0x6000);
|
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[15], 0x6000);
|
||||||
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[16], 0x1000);
|
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_objs[16], 0x1000);
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) memset(nvmap_objs[6].mem, 0x77, nvmap_objs[6].mem_size);
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) { //Unknown what size/etc is used officially.
|
if (R_SUCCEEDED(rc)) { //Unknown what size/etc is used officially.
|
||||||
g_nvgfx_nvhost_userdata_size = 0x1000;
|
g_nvgfx_nvhost_userdata_size = 0x1000;
|
||||||
g_nvgfx_nvhost_userdata = memalign(0x1000, g_nvgfx_nvhost_userdata_size);
|
g_nvgfx_nvhost_userdata = memalign(0x1000, g_nvgfx_nvhost_userdata_size);
|
||||||
@ -454,3 +452,12 @@ Result nvgfxEventInit(void) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size) {
|
||||||
|
if(!g_nvgfxInitialized)return MAKERESULT(MODULE_LIBNX, LIBNX_NOTINITIALIZED);
|
||||||
|
|
||||||
|
if(buffer) *buffer = nvmap_objs[6].mem;
|
||||||
|
if(size) *size = nvmap_objs[6].mem_size;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user