Esempio n. 1
0
static bool psp_frame(void *data, const void *frame,
      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
   static char fps_txt[128], fps_text_buf[128];
   psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
   static uint64_t currentTick,lastTick;
   static float fps=0.0;
   static int frames;
#endif

   if (!width || !height)
      return false;

   if (((uint32_t)frame&0x04000000) || (frame == RETRO_HW_FRAME_BUFFER_VALID))
      psp->hw_render = true;
   else if (frame)
      psp->hw_render = false;

   if (!psp->hw_render)
      sceGuSync(0, 0); /* let the core decide when to sync when HW_RENDER */

   pspDebugScreenSetBase(psp->draw_buffer);

   pspDebugScreenSetXY(0,0);

   video_monitor_get_fps(fps_txt, sizeof(fps_txt),
         g_settings.fps_show ? fps_text_buf : NULL,
         g_settings.fps_show ? sizeof(fps_text_buf) : 0);

   if(g_settings.fps_show)
   {
      pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
      pspDebugScreenPuts(fps_text_buf);
      pspDebugScreenSetXY(0,1);
   }

   if (msg)
      pspDebugScreenPuts(msg);

   if ((psp->vsync)&&(psp->vblank_not_reached))
      sceDisplayWaitVblankStart();

   psp->vblank_not_reached = true;

#ifdef DISPLAY_FPS
   frames++;
   sceRtcGetCurrentTick(&currentTick);
   uint32_t diff = currentTick - lastTick;
   if(diff > 1000000)
   {
      fps = (float)frames * 1000000.0 / diff;
      lastTick = currentTick;
      frames = 0;
   }

   pspDebugScreenSetXY(0,0);
   pspDebugScreenPrintf("%f", fps);
#endif

   psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
   g_extern.frame_count++;


   RARCH_PERFORMANCE_INIT(psp_frame_run);
   RARCH_PERFORMANCE_START(psp_frame_run);

   if (psp->should_resize)
      psp_update_viewport(psp);

   psp_set_tex_coords(psp->frame_coords, width, height);

   sceGuStart(GU_DIRECT, psp->main_dList);

   sceGuTexFilter(psp->tex_filter, psp->tex_filter);
   sceGuClear(GU_COLOR_BUFFER_BIT);

   /* frame in VRAM ? texture/palette was 
    * set in core so draw directly */
   if (psp->hw_render) 
      sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | 
            GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL,
            (void*)(psp->frame_coords));
   else
   {
      if (frame)
      {
         sceKernelDcacheWritebackRange(frame,pitch * height);
         sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2,
               0, width, height, pitch >> psp->bpp_log2,
               (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
      }
      sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
      sceGuCallList(psp->frame_dList);
   }

   sceGuFinish();

   RARCH_PERFORMANCE_STOP(psp_frame_run);

   if(psp->menu.active)
   {
      sceGuSendList(GU_TAIL, psp->menu.dList, &(psp->menu.context_storage));
      sceGuSync(0, 0);
   }

   return true;
}
Esempio n. 2
0
static bool psp_frame(void *data, const void *frame,
                      unsigned width, unsigned height, unsigned pitch, const char *msg)
{
    static char fps_txt[128], fps_text_buf[128];
    psp1_video_t *psp = (psp1_video_t*)data;

#ifdef DISPLAY_FPS
    static uint64_t currentTick,lastTick;
    static float fps=0.0;
    static int frames;
#endif

    if (!width || !height)
        return false;

    sceGuSync(0, 0);

    pspDebugScreenSetBase(psp->draw_buffer);

    pspDebugScreenSetXY(0,0);

    if(g_settings.fps_show)
    {
        gfx_get_fps(fps_txt, sizeof(fps_txt), fps_text_buf, sizeof(fps_text_buf));
        pspDebugScreenSetXY(68 - strlen(fps_text_buf) - 1,0);
        pspDebugScreenPuts(fps_text_buf);
        pspDebugScreenSetXY(0,1);
    }
    else
        gfx_get_fps(fps_txt, sizeof(fps_txt), NULL, 0);

    if (msg)
        pspDebugScreenPuts(msg);

    if (psp->vsync)
        sceDisplayWaitVblankStart();



#ifdef DISPLAY_FPS
    frames++;
    sceRtcGetCurrentTick(&currentTick);
    uint32_t diff = currentTick - lastTick;
    if(diff > 1000000)
    {
        fps = (float)frames * 1000000.0 / diff;
        lastTick = currentTick;
        frames = 0;
    }

    pspDebugScreenSetXY(0,0);
    pspDebugScreenPrintf("%f", fps);
#endif

    psp->draw_buffer = FROM_GU_POINTER(sceGuSwapBuffers());
    g_extern.frame_count++;

    psp->frame_coords->v0.x = (SCEGU_SCR_WIDTH - width * SCEGU_SCR_HEIGHT / height) / 2;
//   psp->frame_coords->v0.y = 0;
//   psp->frame_coords->v0.u = 0;
//   psp->frame_coords->v0.v = 0;

    psp->frame_coords->v1.x = (SCEGU_SCR_WIDTH + width * SCEGU_SCR_HEIGHT / height) / 2;
//   psp->frame_coords->v1.y = SCEGU_SCR_HEIGHT;
    psp->frame_coords->v1.u = width;
    psp->frame_coords->v1.v = height;

    sceGuStart(GU_DIRECT, psp->main_dList);

    if ((uint32_t)frame&0x04000000) // frame in VRAM ? texture/palette was set in core so draw directly
    {
        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuDrawArray(GU_SPRITES, GU_TEXTURE_16BIT | GU_COLOR_4444 | GU_VERTEX_16BIT | GU_TRANSFORM_2D, 2, NULL, (void*)(psp->frame_coords));
    }
    else
    {
        if (frame!=NULL)
        {
            sceKernelDcacheWritebackRange(frame,pitch * height);
            sceGuCopyImage(GU_PSM_5650, ((u32)frame & 0xF) >> psp->bpp_log2, 0, width, height, pitch >> psp->bpp_log2, (void*)((u32)frame & ~0xF), 0, 0, width, psp->texture);
        }

        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuTexImage(0, next_pow2(width), next_pow2(height), width, psp->texture);
        sceGuCallList(psp->frame_dList);
    }