From bf06f27a0e5ce660edce91ecb79c160be646b040 Mon Sep 17 00:00:00 2001 From: fincs Date: Wed, 31 Mar 2021 14:49:07 +0200 Subject: [PATCH] Add gspIsPresentPending --- libctru/include/3ds/services/gspgpu.h | 6 ++++++ libctru/source/services/gspgpu.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/libctru/include/3ds/services/gspgpu.h b/libctru/include/3ds/services/gspgpu.h index 95805a5..5f377b9 100644 --- a/libctru/include/3ds/services/gspgpu.h +++ b/libctru/include/3ds/services/gspgpu.h @@ -104,6 +104,12 @@ bool gspHasGpuRight(void); */ void gspPresentBuffer(unsigned screen, unsigned swap, const void* fb_a, const void* fb_b, u32 stride, u32 mode); +/** + * @brief Returns true if a prior \ref gspPresentBuffer command is still pending to be processed by GSP. + * @param screen Screen ID (see \ref GSP_SCREEN_TOP and \ref GSP_SCREEN_BOTTOM) + */ +bool gspIsPresentPending(unsigned screen); + /** * @brief Configures a callback to run when a GSPGPU event occurs. * @param id ID of the event. diff --git a/libctru/source/services/gspgpu.c b/libctru/source/services/gspgpu.c index f2b6d2f..44ce39d 100644 --- a/libctru/source/services/gspgpu.c +++ b/libctru/source/services/gspgpu.c @@ -257,6 +257,12 @@ void gspPresentBuffer(unsigned screen, unsigned swap, const void* fb_a, const vo } while (__strex(fbInfoHeader, u.header)); } +bool gspIsPresentPending(unsigned screen) +{ + s32* fbInfoHeader = (s32*)((u8*)gspSharedMem + 0x200 + gspThreadId*0x80 + screen*0x40); + return (*fbInfoHeader & 0xff00) != 0; +} + void gspSetEventCallback(GSPGPU_Event id, ThreadFunc cb, void* data, bool oneShot) { if(id>= GSPGPU_EVENT_MAX)return;