MCPcopy Create free account
hub / github.com/devkitPro/libctru / gspPresentBuffer

Function gspPresentBuffer

libctru/source/services/gspgpu.c:240–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240bool gspPresentBuffer(unsigned screen, unsigned swap, const void* fb_a, const void* fb_b, u32 stride, u32 mode)
241{
242 GSPGPU_FramebufferInfo info;
243 info.active_framebuf = swap;
244 info.framebuf0_vaddr = (u32*)fb_a;
245 info.framebuf1_vaddr = (u32*)fb_b;
246 info.framebuf_widthbytesize = stride;
247 info.format = mode;
248 info.framebuf_dispselect = swap;
249 info.unk = 0;
250
251 s32* fbInfoHeader = (s32*)((u8*)gspSharedMem + 0x200 + gspThreadId*0x80 + screen*0x40);
252 GSPGPU_FramebufferInfo* fbInfos = (GSPGPU_FramebufferInfo*)&fbInfoHeader[1];
253 unsigned pos = 1 - (*fbInfoHeader & 0xff);
254 fbInfos[pos] = info;
255 __dsb();
256
257 union
258 {
259 s32 header;
260 struct { u8 swap, update; };
261 } u;
262
263 bool ret;
264 do
265 {
266 u.header = __ldrex(fbInfoHeader);
267 ret = u.update != 0;
268
269 u.swap = pos;
270 u.update = 1;
271 } while (__strex(fbInfoHeader, u.header));
272
273 return ret;
274}
275
276bool gspIsPresentPending(unsigned screen)
277{

Callers 1

gfxPresentFramebufferFunction · 0.85

Calls 3

__dsbFunction · 0.85
__ldrexFunction · 0.85
__strexFunction · 0.85

Tested by

no test coverage detected