mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 21:02:39 +02:00
viGetDisplayVsyncEvent: return an Event instead of a raw handle
This commit is contained in:
parent
88e9d3bb83
commit
b26bb6ce76
@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "../types.h"
|
#include "../types.h"
|
||||||
|
#include "../kernel/event.h"
|
||||||
#include "../services/sm.h"
|
#include "../services/sm.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -58,7 +59,7 @@ static inline Result viOpenDefaultDisplay(ViDisplay *display)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Result viGetDisplayResolution(ViDisplay *display, u64 *width, u64 *height);
|
Result viGetDisplayResolution(ViDisplay *display, u64 *width, u64 *height);
|
||||||
Result viGetDisplayVsyncEvent(ViDisplay *display, Handle *handle_out);
|
Result viGetDisplayVsyncEvent(ViDisplay *display, Event *event_out);
|
||||||
|
|
||||||
// Layer functions
|
// Layer functions
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
static bool g_gfxInitialized = 0;
|
static bool g_gfxInitialized = 0;
|
||||||
static ViDisplay g_gfxDisplay;
|
static ViDisplay g_gfxDisplay;
|
||||||
static Handle g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
static Event g_gfxDisplayVsyncEvent;
|
||||||
static ViLayer g_gfxLayer;
|
static ViLayer g_gfxLayer;
|
||||||
static Binder g_gfxBinderSession;
|
static Binder g_gfxBinderSession;
|
||||||
static s32 g_gfxCurrentBuffer = 0;
|
static s32 g_gfxCurrentBuffer = 0;
|
||||||
@ -149,7 +149,6 @@ Result gfxInitDefault(void) {
|
|||||||
|
|
||||||
if(g_gfxInitialized)return 0;
|
if(g_gfxInitialized)return 0;
|
||||||
|
|
||||||
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
|
||||||
g_gfxCurrentBuffer = -1;
|
g_gfxCurrentBuffer = -1;
|
||||||
g_gfxCurrentProducerBuffer = -1;
|
g_gfxCurrentProducerBuffer = -1;
|
||||||
g_gfx_ProducerConnected = 0;
|
g_gfx_ProducerConnected = 0;
|
||||||
@ -242,14 +241,10 @@ Result gfxInitDefault(void) {
|
|||||||
|
|
||||||
binderClose(&g_gfxBinderSession);
|
binderClose(&g_gfxBinderSession);
|
||||||
viCloseLayer(&g_gfxLayer);
|
viCloseLayer(&g_gfxLayer);
|
||||||
|
eventClose(&g_gfxDisplayVsyncEvent);
|
||||||
viCloseDisplay(&g_gfxDisplay);
|
viCloseDisplay(&g_gfxDisplay);
|
||||||
viExit();
|
viExit();
|
||||||
|
|
||||||
if(g_gfxDisplayVsyncEvent != INVALID_HANDLE) {
|
|
||||||
svcCloseHandle(g_gfxDisplayVsyncEvent);
|
|
||||||
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(g_gfxFramebufLinear);
|
free(g_gfxFramebufLinear);
|
||||||
g_gfxFramebufLinear = NULL;
|
g_gfxFramebufLinear = NULL;
|
||||||
|
|
||||||
@ -288,14 +283,10 @@ void gfxExit(void)
|
|||||||
|
|
||||||
binderClose(&g_gfxBinderSession);
|
binderClose(&g_gfxBinderSession);
|
||||||
viCloseLayer(&g_gfxLayer);
|
viCloseLayer(&g_gfxLayer);
|
||||||
|
eventClose(&g_gfxDisplayVsyncEvent);
|
||||||
viCloseDisplay(&g_gfxDisplay);
|
viCloseDisplay(&g_gfxDisplay);
|
||||||
viExit();
|
viExit();
|
||||||
|
|
||||||
if(g_gfxDisplayVsyncEvent != INVALID_HANDLE) {
|
|
||||||
svcCloseHandle(g_gfxDisplayVsyncEvent);
|
|
||||||
g_gfxDisplayVsyncEvent = INVALID_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
free(g_gfxFramebufLinear);
|
free(g_gfxFramebufLinear);
|
||||||
g_gfxFramebufLinear = NULL;
|
g_gfxFramebufLinear = NULL;
|
||||||
|
|
||||||
@ -399,27 +390,17 @@ Result _gfxGraphicBufferInit(s32 buf, u32 nvmap_id, u32 nvmap_handle) {
|
|||||||
g_gfx_BufferInitData.data.nvmap_handle0 = nvmap_id;
|
g_gfx_BufferInitData.data.nvmap_handle0 = nvmap_id;
|
||||||
g_gfx_BufferInitData.data.nvmap_handle1 = nvmap_handle;
|
g_gfx_BufferInitData.data.nvmap_handle1 = nvmap_handle;
|
||||||
g_gfx_BufferInitData.data.buffer_offset = g_gfx_singleframebuf_size*buf;
|
g_gfx_BufferInitData.data.buffer_offset = g_gfx_singleframebuf_size*buf;
|
||||||
g_gfx_BufferInitData.data.timestamp = svcGetSystemTick();
|
//g_gfx_BufferInitData.data.timestamp = svcGetSystemTick();
|
||||||
|
|
||||||
return bqSetPreallocatedBuffer(&g_gfxBinderSession, buf, &g_gfx_BufferInitData);
|
return bqSetPreallocatedBuffer(&g_gfxBinderSession, buf, &g_gfx_BufferInitData);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _waitevent(Handle handle) {
|
void gfxWaitForVsync(void) {
|
||||||
Result rc;
|
Result rc = eventWait(&g_gfxDisplayVsyncEvent, U64_MAX);
|
||||||
|
|
||||||
do {
|
|
||||||
rc = svcWaitSynchronizationSingle(handle, U64_MAX);
|
|
||||||
svcResetSignal(handle);
|
|
||||||
} while ((rc & 0x3FFFFF) == 0xFA01);
|
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGfxEventWait));
|
fatalSimple(MAKERESULT(Module_Libnx, LibnxError_BadGfxEventWait));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gfxWaitForVsync(void) {
|
|
||||||
_waitevent(g_gfxDisplayVsyncEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
void gfxSwapBuffers(void) {
|
void gfxSwapBuffers(void) {
|
||||||
Result rc=0;
|
Result rc=0;
|
||||||
|
|
||||||
|
@ -281,7 +281,7 @@ Result viGetDisplayResolution(ViDisplay *display, u64 *width, u64 *height)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result viGetDisplayVsyncEvent(ViDisplay *display, Handle *handle_out)
|
Result viGetDisplayVsyncEvent(ViDisplay *display, Event *event_out)
|
||||||
{
|
{
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
@ -315,7 +315,7 @@ Result viGetDisplayVsyncEvent(ViDisplay *display, Handle *handle_out)
|
|||||||
rc = resp->result;
|
rc = resp->result;
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
*handle_out = r.Handles[0];
|
eventLoadRemote(event_out, r.Handles[0], true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user