static void rmenu_ctx_ps3_swap_buffers(void) { gfx_ctx_swap_buffers(); #ifdef HAVE_SYSUTILS cellSysutilCheckCallback(); #endif }
static bool vg_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg) { unsigned width, height; vg_t *vg = (vg_t*)data; static struct retro_perf_counter vg_fr = {0}; static struct retro_perf_counter vg_image = {0}; rarch_perf_init(&vg_fr, "vg_fr"); retro_perf_start(&vg_fr); video_driver_get_size(&width, &height); if (frame_width != vg->mRenderWidth || frame_height != vg->mRenderHeight || vg->should_resize) { vg->mRenderWidth = frame_width; vg->mRenderHeight = frame_height; vg_calculate_quad(vg); matrix_3x3_quad_to_quad( vg->x1, vg->y1, vg->x2, vg->y1, vg->x2, vg->y2, vg->x1, vg->y2, /* needs to be flipped, Khronos loves their bottom-left origin */ 0, frame_height, frame_width, frame_height, frame_width, 0, 0, 0, &vg->mTransformMatrix); vgSeti(VG_MATRIX_MODE, VG_MATRIX_IMAGE_USER_TO_SURFACE); vgLoadMatrix(vg->mTransformMatrix.data); vg->should_resize = false; } vgSeti(VG_SCISSORING, VG_FALSE); vgClear(0, 0, width, height); vgSeti(VG_SCISSORING, VG_TRUE); rarch_perf_init(&vg_image, "vg_image"); retro_perf_start(&vg_image); vg_copy_frame(vg, frame, frame_width, frame_height, pitch); retro_perf_stop(&vg_image); vgDrawImage(vg->mImage); #if 0 if (msg && vg->mFontsOn) vg_draw_message(vg, msg); #endif gfx_ctx_update_window_title(vg); retro_perf_stop(&vg_fr); gfx_ctx_swap_buffers(vg); return true; }
static bool xdk_d3d_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { if (!frame) return true; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; bool menu_enabled = g_console.menu_enable; bool fps_enable = g_console.fps_info_enable; if (d3d->last_width != width || d3d->last_height != height) //240*160 { D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0); memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch); d3d->lpTexture->UnlockRect(0); float tex_w = width; // / 512.0f; float tex_h = height; // / 512.0f; DrawVerticeFormats verts[] = { { -1.0f, -1.0f, 1.0f, 0.0f, tex_h }, { 1.0f, -1.0f, 1.0f, tex_w, tex_h }, { -1.0f, 1.0f, 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, 1.0f, tex_w, 0.0f }, }; // Align texels and vertices (D3D9 quirk). for (unsigned i = 0; i < 4; i++) { verts[i].x -= 0.5f / 512.0f; verts[i].y += 0.5f / 512.0f; } BYTE *verts_ptr; d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0); memcpy(verts_ptr, verts, sizeof(verts)); d3d->vertex_buf->Unlock(); d3d->last_width = width; d3d->last_height = height; } if (d3d->should_resize) xdk_d3d_set_viewport(false); d3d->frame_count++; d3d->d3d_render_device->SetTexture(0, d3d->lpTexture); D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, 0); for (unsigned y = 0; y < height; y++) { const uint8_t *in = (const uint8_t*)frame + y * pitch; uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch; memcpy(out, in, width * sizeof(uint16_t)); } d3d->lpTexture->UnlockRect(0); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); D3DXMATRIX p_out; D3DXMatrixIdentity(&p_out); d3d->d3d_render_device->SetTransform(D3DTS_WORLD, &p_out); d3d->d3d_render_device->SetTransform(D3DTS_VIEW, &p_out); d3d->d3d_render_device->SetTransform(D3DTS_PROJECTION, &p_out); d3d->d3d_render_device->SetVertexShader(D3DFVF_XYZ | D3DFVF_TEX1); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); d3d->d3d_render_device->BeginScene(); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); d3d->d3d_render_device->EndScene(); if(fps_enable) { static MEMORYSTATUS stat; GlobalMemoryStatus(&stat); d3d->d3d_render_device->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &d3d->pFrontBuffer); d3d->d3d_render_device->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &d3d->pBackBuffer); //Output memory usage char buf[128], buf2[128], buf_fps_last[128]; bool ret = false; sprintf(buf, "%.2f MB free / %.2f MB total", stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f)); rarch_convert_char_to_wchar(strw_buffer, buf, sizeof(strw_buffer)); d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 ); d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 50 ); if(ret = gfx_window_title(buf2, sizeof(buf2)) || sizeof(buf_fps_last)) { if(ret) { sprintf(buf_fps_last, buf2); rarch_convert_char_to_wchar(strw_buffer, buf2, sizeof(strw_buffer)); } else if(buf_fps_last) rarch_convert_char_to_wchar(strw_buffer, buf_fps_last, sizeof(strw_buffer)); d3d->debug_font->TextOut(d3d->pFrontBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 70 ); d3d->debug_font->TextOut(d3d->pBackBuffer, strw_buffer, (unsigned)-1, font_x + 30, font_y + 70 ); d3d->pFrontBuffer->Release(); d3d->pBackBuffer->Release(); } } if(!d3d->block_swap) gfx_ctx_swap_buffers(); return true; }
static bool xdk_d3d_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { if (!frame) return true; xdk_d3d_video_t *d3d = (xdk_d3d_video_t*)data; #ifdef HAVE_FBO D3DSurface* pRenderTarget0; #endif bool menu_enabled = g_console.menu_enable; if (d3d->last_width != width || d3d->last_height != height) { D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); memset(d3dlr.pBits, 0, 512 * d3dlr.Pitch); d3d->lpTexture->UnlockRect(0); float tex_w = width / 512.0f; float tex_h = height / 512.0f; DrawVerticeFormats verts[] = { { -1.0f, -1.0f, 0.0f, tex_h }, { 1.0f, -1.0f, tex_w, tex_h }, { -1.0f, 1.0f, 0.0f, 0.0f }, { 1.0f, 1.0f, tex_w, 0.0f }, }; // Align texels and vertices (D3D9 quirk). for (unsigned i = 0; i < 4; i++) { verts[i].x -= 0.5f / 512.0f; verts[i].y += 0.5f / 512.0f; } void *verts_ptr; d3d->vertex_buf->Lock(0, 0, &verts_ptr, 0); memcpy(verts_ptr, verts, sizeof(verts)); d3d->vertex_buf->Unlock(); d3d->last_width = width; d3d->last_height = height; } #ifdef HAVE_FBO if (d3d->fbo_enabled) { d3d->d3d_render_device->GetRenderTarget(0, &pRenderTarget0); d3d->d3d_render_device->SetRenderTarget(0, d3d->lpSurface); } #endif if (d3d->should_resize) xdk_d3d_set_viewport(false); d3d->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, 0xff000000, 1.0f, 0); d3d->frame_count++; d3d->d3d_render_device->SetTexture(0, d3d->lpTexture); #ifdef HAVE_HLSL hlsl_use(1); #endif #ifdef HAVE_FBO if(d3d->fbo_enabled) { #ifdef HAVE_HLSL hlsl_set_params(width, height, 512, 512, g_settings.video.fbo_scale_x * width, g_settings.video.fbo_scale_y * height, d3d->frame_count); #endif D3DVIEWPORT vp = {0}; vp.Width = g_settings.video.fbo_scale_x * width; vp.Height = g_settings.video.fbo_scale_y * height; vp.X = 0; vp.Y = 0; vp.MinZ = 0.0f; vp.MaxZ = 1.0f; d3d->d3d_render_device->SetViewport(&vp); } else #endif { #ifdef HAVE_HLSL hlsl_set_params(width, height, 512, 512, d3d->d3dpp.BackBufferWidth, d3d->d3dpp.BackBufferHeight, d3d->frame_count); #endif } D3DLOCKED_RECT d3dlr; d3d->lpTexture->LockRect(0, &d3dlr, NULL, D3DLOCK_NOSYSLOCK); for (unsigned y = 0; y < height; y++) { const uint8_t *in = (const uint8_t*)frame + y * pitch; uint8_t *out = (uint8_t*)d3dlr.pBits + y * d3dlr.Pitch; memcpy(out, in, width * sizeof(uint16_t)); } d3d->lpTexture->UnlockRect(0); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetVertexDeclaration(d3d->v_decl); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, 0, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); #ifdef HAVE_FBO if(d3d->fbo_enabled) { d3d->d3d_render_device->Resolve(D3DRESOLVE_RENDERTARGET0, NULL, d3d->lpTexture_ot, NULL, 0, 0, NULL, 0, 0, NULL); d3d->d3d_render_device->SetRenderTarget(0, pRenderTarget0); pRenderTarget0->Release(); d3d->d3d_render_device->SetTexture(0, &d3d->lpTexture_ot_as16srgb); #ifdef HAVE_HLSL hlsl_use(2); hlsl_set_params(g_settings.video.fbo_scale_x * width, g_settings.video.fbo_scale_y * height, g_settings.video.fbo_scale_x * 512, g_settings.video.fbo_scale_y * 512, d3d->d3dpp.BackBufferWidth, d3d->d3dpp.BackBufferHeight, d3d->frame_count); #endif xdk_d3d_set_viewport(false); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MINFILTER, g_settings.video.second_pass_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_MAGFILTER, g_settings.video.second_pass_smooth ? D3DTEXF_LINEAR : D3DTEXF_POINT); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER); d3d->d3d_render_device->SetVertexDeclaration(d3d->v_decl); d3d->d3d_render_device->SetStreamSource(0, d3d->vertex_buf, 0, sizeof(DrawVerticeFormats)); d3d->d3d_render_device->DrawPrimitive(D3DPT_TRIANGLESTRIP, 0, 2); } #endif /* XBox 360 specific font code */ if (msg && !menu_enabled) { if(IS_TIMER_EXPIRED(d3d)) { xdk360_console_format(msg); SET_TIMER_EXPIRATION(d3d, 30); } xdk360_console_draw(); } if(!d3d->block_swap) gfx_ctx_swap_buffers(); return true; }
static bool gl_frame(void *data, const void *frame, unsigned width, unsigned height, unsigned pitch, const char *msg) { gl_t *gl = (gl_t*)data; gl_shader_use(1); gl->frame_count++; glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); #ifdef HAVE_FBO // Render to texture in first pass. if (gl->fbo_inited) { // Recompute FBO geometry. // When width/height changes or window sizes change, we have to recalcuate geometry of our FBO. gl_compute_fbo_geometry(gl, width, height, gl->vp_out_width, gl->vp_out_height); gl_start_frame_fbo(gl); } #endif if (gl->should_resize) { gl->should_resize = false; gfx_ctx_set_resize(gl->win_width, gl->win_height); // On resize, we might have to recreate our FBOs due to "Viewport" scale, and set a new viewport. gl_update_resize(gl); } if (frame) // Can be NULL for frame dupe / NULL render. { gl_update_input_size(gl, width, height, pitch); gl_copy_frame(gl, frame, width, height, pitch); } struct gl_tex_info tex_info = {0}; tex_info.tex = gl->texture[gl->tex_index]; tex_info.input_size[0] = width; tex_info.input_size[1] = height; tex_info.tex_size[0] = gl->tex_w; tex_info.tex_size[1] = gl->tex_h; memcpy(tex_info.coord, gl->tex_coords, sizeof(gl->tex_coords)); glClear(GL_COLOR_BUFFER_BIT); gl_shader_set_params(width, height, gl->tex_w, gl->tex_h, gl->vp_width, gl->vp_height, gl->frame_count, &tex_info, gl->prev_info, NULL, 0); glDrawArrays(GL_QUADS, 0, 4); #ifdef HAVE_FBO if (gl->fbo_inited) gl_frame_fbo(gl, &tex_info); #endif gl_next_texture_index(gl, &tex_info); if (msg) { gl_render_msg(gl, msg); gl_render_msg_post(gl); } #ifndef RARCH_CONSOLE gfx_ctx_update_window_title(false); #endif #ifdef RARCH_CONSOLE if (!gl->block_swap) #endif gfx_ctx_swap_buffers(); #ifdef HAVE_CG_MENU if (gl->menu_render) gl_render_menu(gl); #endif return true; }
void menu_loop(void) { HRESULT hr; xdk360_video_t *d3d9 = (xdk360_video_t*)driver.video_data; g_console.menu_enable = true; d3d9->block_swap = true; g_console.input_loop = INPUT_LOOP_MENU; do { if(g_console.emulator_initialized) { rarch_render_cached_frame(); } else { d3d9->d3d_render_device->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_ARGB(0, 0, 0, 0), 1.0f, 0); d3d9->frame_count++; } XINPUT_STATE state; XInputGetState(0, &state); g_console.menu_enable = !((state.Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB) && (state.Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB) && (g_console.emulator_initialized) && IS_TIMER_EXPIRED(d3d9)); g_console.mode_switch = g_console.menu_enable ? MODE_MENU : MODE_EMULATION; switch(g_console.input_loop) { case INPUT_LOOP_MENU: app.RunFrame(); /* Update XUI */ if(state.Gamepad.wButtons & XINPUT_GAMEPAD_B && hCur != app.hMainScene) XuiSceneNavigateBack(hCur, app.hMainScene, XUSER_INDEX_ANY); break; case INPUT_LOOP_RESIZE_MODE: ingame_menu_resize(); break; default: break; } hr = app.Render(); /* Render XUI */ hr = XuiTimersRun(); /* Update XUI timers */ if(g_console.mode_switch == MODE_EMULATION && !g_console.frame_advance_enable) { SET_TIMER_EXPIRATION(d3d9, 30); } const char *message = msg_queue_pull(g_extern.msg_queue); if (message) { if(IS_TIMER_EXPIRED(d3d9)) { xdk360_console_format(message); SET_TIMER_EXPIRATION(d3d9, 30); } xdk360_console_draw(); } gfx_ctx_swap_buffers(); }while(g_console.menu_enable); d3d9->block_swap = false; g_console.ingame_menu_enable = false; }