void gpuFlush() { GPU_FinishDrawing(); GPUCMD_Finalize(); GPUCMD_FlushAndRun(NULL); gpuSafeWait(GSPEVENT_P3D); GPUCMD_SetBufferOffset(0); }
int sf2d_init_advanced(int gpucmd_size, int temppool_size) { if (sf2d_initialized) return 0; gpu_fb_addr = vramMemAlign(400*240*8, 0x100); gpu_depth_fb_addr = vramMemAlign(400*240*8, 0x100); gpu_cmd = linearAlloc(gpucmd_size * 4); pool_addr = linearAlloc(temppool_size); pool_size = temppool_size; gpu_cmd_size = gpucmd_size; //gfxInitDefault(); GPU_Init(NULL); //gfxSet3D(false); GPU_Reset(NULL, gpu_cmd, gpucmd_size); //Setup the shader dvlb = DVLB_ParseFile((u32 *)shader_vsh_shbin, shader_vsh_shbin_size); shaderProgramInit(&shader); shaderProgramSetVsh(&shader, &dvlb->DVLE[0]); //Get shader uniform descriptors projection_desc = shaderInstanceGetUniformLocation(shader.vertexShader, "projection"); shaderProgramUse(&shader); matrix_init_orthographic(ortho_matrix_top, 0.0f, 400.0f, 0.0f, 240.0f, 0.0f, 1.0f); matrix_init_orthographic(ortho_matrix_bot, 0.0f, 320.0f, 0.0f, 240.0f, 0.0f, 1.0f); matrix_gpu_set_uniform(ortho_matrix_top, projection_desc); //Register the apt callback hook //aptHook(&apt_hook_cookie, apt_hook_func, NULL); vblank_wait = 1; current_fps = 0.0f; frames = 0; last_time = osGetTime(); cur_screen = GFX_TOP; cur_side = GFX_LEFT; GPUCMD_Finalize(); GPUCMD_FlushAndRun(); gspWaitForP3D(); sf2d_pool_reset(); sf2d_initialized = 1; return 1; }
static void reset_gpu_apt_resume() { GPU_Reset(NULL, gpu_cmd, gpu_cmd_size); // Only required for custom GPU cmd sizes shaderProgramUse(&shader); if (cur_screen == GFX_TOP) { matrix_gpu_set_uniform(ortho_matrix_top, projection_desc); } else { matrix_gpu_set_uniform(ortho_matrix_bot, projection_desc); } GPUCMD_Finalize(); GPUCMD_FlushAndRun(); gspWaitForP3D(); }
void gpuFrameEnd(void) { // Finish rendering GPU_FinishDrawing(); GPUCMD_Finalize(); GPUCMD_FlushAndRun(NULL); gspWaitForP3D(); // Wait for the rendering to complete // Transfer the GPU output to the framebuffer GX_SetDisplayTransfer(NULL, colorBuf, GX_BUFFER_DIM(240, 400), (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_BUFFER_DIM(240, 400), DISPLAY_TRANSFER_FLAGS); gspWaitForPPF(); // Wait for the transfer to complete // Reset the command buffer GPUCMD_SetBufferOffset(0); };
void sf2d_end_frame() { GPU_FinishDrawing(); GPUCMD_Finalize(); GPUCMD_FlushAndRun(); gspWaitForP3D(); //Copy the GPU rendered FB to the screen FB if (cur_screen == GFX_TOP) { GX_DisplayTransfer(gpu_fb_addr, GX_BUFFER_DIM(240, 400), (u32 *)gfxGetFramebuffer(GFX_TOP, cur_side, NULL, NULL), GX_BUFFER_DIM(240, 400), 0x1000); } else { GX_DisplayTransfer(gpu_fb_addr, GX_BUFFER_DIM(240, 320), (u32 *)gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), GX_BUFFER_DIM(240, 320), 0x1000); } gspWaitForPPF(); //Clear the screen GX_MemoryFill(gpu_fb_addr, clear_color, &gpu_fb_addr[0x2EE00], 0x201, gpu_depth_fb_addr, 0x00000000, &gpu_depth_fb_addr[0x2EE00], 0x201); gspWaitForPSC0(); }