mirror of
https://github.com/switchbrew/libnx.git
synced 2025-06-22 21:02:39 +02:00
gfx: use new NvFence waiting code
This commit is contained in:
parent
a70acdd445
commit
60cbb68f46
@ -3,6 +3,5 @@
|
|||||||
|
|
||||||
Result nvgfxInitialize(void);
|
Result nvgfxInitialize(void);
|
||||||
void nvgfxExit(void);
|
void nvgfxExit(void);
|
||||||
Result nvgfxEventWait(u32 syncpt_id, u32 threshold, s32 timeout);
|
|
||||||
Result nvgfxSubmitGpfifo(void);
|
Result nvgfxSubmitGpfifo(void);
|
||||||
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size, u32 *handle);
|
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size, u32 *handle);
|
||||||
|
@ -96,9 +96,6 @@ static BqGraphicBuffer g_gfx_BufferInitData = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NvMultiFence debugfence;
|
|
||||||
Result debugfenceresult;
|
|
||||||
|
|
||||||
static Result _gfxDequeueBuffer(void) {
|
static Result _gfxDequeueBuffer(void) {
|
||||||
if (g_gfxCurrentProducerBuffer >= 0)
|
if (g_gfxCurrentProducerBuffer >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
@ -115,15 +112,9 @@ static Result _gfxDequeueBuffer(void) {
|
|||||||
g_gfx_ProducerSlotsRequested |= BIT(slot);
|
g_gfx_ProducerSlotsRequested |= BIT(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugfence = fence;
|
rc = nvMultiFenceWait(&fence, -1);
|
||||||
for (u32 i = 0; i < fence.num_fences; i ++) {
|
if (R_FAILED(rc))
|
||||||
if ((s32)fence.fences[i].id >= 0) {
|
return rc;
|
||||||
// todo: figure out why fencewait sucks
|
|
||||||
/*rc =*/ debugfenceresult = nvgfxEventWait(fence.fences[i].id, fence.fences[i].value, 0);
|
|
||||||
//if (R_FAILED(rc))
|
|
||||||
// break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) {
|
if (R_SUCCEEDED(rc)) {
|
||||||
g_gfxCurrentProducerBuffer = slot;
|
g_gfxCurrentProducerBuffer = slot;
|
||||||
@ -220,6 +211,8 @@ Result gfxInitDefault(void) {
|
|||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvInitialize();
|
if (R_SUCCEEDED(rc)) rc = nvInitialize();
|
||||||
|
|
||||||
|
if (R_SUCCEEDED(rc)) rc = nvFenceInit();
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvgfxInitialize();
|
if (R_SUCCEEDED(rc)) rc = nvgfxInitialize();
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvgfxGetFramebuffer(&g_gfxFramebuf, &g_gfxFramebufSize, &g_gfxFramebufHandle);
|
if (R_SUCCEEDED(rc)) rc = nvgfxGetFramebuffer(&g_gfxFramebuf, &g_gfxFramebufSize, &g_gfxFramebufHandle);
|
||||||
@ -236,6 +229,7 @@ Result gfxInitDefault(void) {
|
|||||||
}
|
}
|
||||||
bqDisconnect(&g_gfxBinderSession, NATIVE_WINDOW_API_CPU);
|
bqDisconnect(&g_gfxBinderSession, NATIVE_WINDOW_API_CPU);
|
||||||
nvgfxExit();
|
nvgfxExit();
|
||||||
|
nvFenceExit();
|
||||||
nvExit();
|
nvExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,6 +272,7 @@ void gfxExit(void)
|
|||||||
}
|
}
|
||||||
bqDisconnect(&g_gfxBinderSession, NATIVE_WINDOW_API_CPU);
|
bqDisconnect(&g_gfxBinderSession, NATIVE_WINDOW_API_CPU);
|
||||||
nvgfxExit();
|
nvgfxExit();
|
||||||
|
nvFenceExit();
|
||||||
nvExit();
|
nvExit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ typedef struct {
|
|||||||
|
|
||||||
static bool g_nvgfxInitialized;
|
static bool g_nvgfxInitialized;
|
||||||
static u32 g_nvgfx_fd_nvmap;
|
static u32 g_nvgfx_fd_nvmap;
|
||||||
static u32 g_nvgfx_fd_nvhostctrl;
|
|
||||||
|
|
||||||
u32 g_nvgfx_totalframebufs = 2;
|
u32 g_nvgfx_totalframebufs = 2;
|
||||||
|
|
||||||
@ -76,7 +75,6 @@ Result nvgfxInitialize(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvOpen(&g_nvgfx_fd_nvmap, "/dev/nvmap");
|
if (R_SUCCEEDED(rc)) rc = nvOpen(&g_nvgfx_fd_nvmap, "/dev/nvmap");
|
||||||
if (R_SUCCEEDED(rc)) rc = nvOpen(&g_nvgfx_fd_nvhostctrl, "/dev/nvhost-ctrl");
|
|
||||||
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_fb_obj, g_nvgfx_totalframebufs*g_gfx_singleframebuf_size);
|
if (R_SUCCEEDED(rc)) rc = nvmapobjInitialize(&nvmap_fb_obj, g_nvgfx_totalframebufs*g_gfx_singleframebuf_size);
|
||||||
if (R_SUCCEEDED(rc)) rc = nvmapobjSetup(&nvmap_fb_obj, 0, 0x1, 0x20000, 0);
|
if (R_SUCCEEDED(rc)) rc = nvmapobjSetup(&nvmap_fb_obj, 0, 0x1, 0x20000, 0);
|
||||||
|
|
||||||
@ -97,10 +95,6 @@ Result nvgfxInitialize(void) {
|
|||||||
|
|
||||||
if (R_FAILED(rc)) {
|
if (R_FAILED(rc)) {
|
||||||
nvmapobjClose(&nvmap_fb_obj);
|
nvmapobjClose(&nvmap_fb_obj);
|
||||||
if (g_nvgfx_fd_nvhostctrl != -1) {
|
|
||||||
nvClose(g_nvgfx_fd_nvhostctrl);
|
|
||||||
g_nvgfx_fd_nvhostctrl = -1;
|
|
||||||
}
|
|
||||||
if (g_nvgfx_fd_nvmap != -1) {
|
if (g_nvgfx_fd_nvmap != -1) {
|
||||||
nvClose(g_nvgfx_fd_nvmap);
|
nvClose(g_nvgfx_fd_nvmap);
|
||||||
g_nvgfx_fd_nvmap = -1;
|
g_nvgfx_fd_nvmap = -1;
|
||||||
@ -118,10 +112,6 @@ void nvgfxExit(void) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
nvmapobjClose(&nvmap_fb_obj);
|
nvmapobjClose(&nvmap_fb_obj);
|
||||||
if (g_nvgfx_fd_nvhostctrl != -1) {
|
|
||||||
nvClose(g_nvgfx_fd_nvhostctrl);
|
|
||||||
g_nvgfx_fd_nvhostctrl = -1;
|
|
||||||
}
|
|
||||||
if (g_nvgfx_fd_nvmap != -1) {
|
if (g_nvgfx_fd_nvmap != -1) {
|
||||||
nvClose(g_nvgfx_fd_nvmap);
|
nvClose(g_nvgfx_fd_nvmap);
|
||||||
g_nvgfx_fd_nvmap = -1;
|
g_nvgfx_fd_nvmap = -1;
|
||||||
@ -130,18 +120,6 @@ void nvgfxExit(void) {
|
|||||||
g_nvgfxInitialized = false;
|
g_nvgfxInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result nvgfxEventWait(u32 syncpt_id, u32 threshold, s32 timeout)
|
|
||||||
{
|
|
||||||
Result rc;
|
|
||||||
|
|
||||||
do {
|
|
||||||
u32 event_res;
|
|
||||||
rc = nvioctlNvhostCtrl_EventWait(g_nvgfx_fd_nvhostctrl, syncpt_id, threshold, timeout, 0, &event_res);
|
|
||||||
} while (rc == MAKERESULT(Module_LibnxNvidia, LibnxNvidiaError_Timeout)); // todo: Fix timeout error
|
|
||||||
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size, u32 *handle)
|
Result nvgfxGetFramebuffer(u8 **buffer, size_t *size, u32 *handle)
|
||||||
{
|
{
|
||||||
if (!g_nvgfxInitialized)
|
if (!g_nvgfxInitialized)
|
||||||
|
Loading…
Reference in New Issue
Block a user