Implement RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER - faster blitting for video driver backends that support it, i.e. Vulkan

This commit is contained in:
twinaphex
2016-02-19 05:17:47 +01:00
parent d1edfad75f
commit 592e315c3c
2 changed files with 198 additions and 45 deletions

View File

@@ -780,6 +780,12 @@ void FCEUD_Update(uint8 *XBuf, int32 *Buffer, int Count)
static void retro_run_blit(uint8_t *gfx)
{
unsigned x, y;
#ifdef PSP
static unsigned int __attribute__((aligned(16))) d_list[32];
void* const texture_vram_p = NULL;
#endif
uint16_t *fceu_video_out_ptr = NULL;
struct retro_framebuffer fb = {0};
unsigned incr = 0;
unsigned width = 256;
unsigned height = 240;
@@ -798,8 +804,7 @@ static void retro_run_blit(uint8_t *gfx)
}
#ifdef PSP
static unsigned int __attribute__((aligned(16))) d_list[32];
void* const texture_vram_p = (void*) (0x44200000 - (256 * 256)); // max VRAM address - frame size
texture_vram_p = (void*) (0x44200000 - (256 * 256)); // max VRAM address - frame size
sceKernelDcacheWritebackRange(retro_palette,256 * 2);
sceKernelDcacheWritebackRange(XBuf, 256*240 );
@@ -827,23 +832,34 @@ static void retro_run_blit(uint8_t *gfx)
video_cb(texture_vram_p, width, height, 256);
#else
fb.width = width;
fb.height = height;
fb.access_flags = RETRO_MEMORY_ACCESS_WRITE;
fceu_video_out_ptr = fceu_video_out;
if (environ_cb(RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER, &fb) && fb.format == RETRO_PIXEL_FORMAT_RGB565)
{
fceu_video_out_ptr = (uint16_t*)fb.data;
pitch = fb.pitch >> 1;
}
if (use_raw_palette)
{
extern uint8 PPU[4];
int deemp = (PPU[1] >> 5) << 2;
for (y = 0; y < height; y++, gfx += incr)
for ( x = 0; x < width; x++, gfx++)
fceu_video_out[y * width + x] = retro_palette[*gfx & 0x3F] | deemp;
fceu_video_out_ptr[y * width + x] = retro_palette[*gfx & 0x3F] | deemp;
}
else
{
for (y = 0; y < height; y++, gfx += incr)
for ( x = 0; x < width; x++, gfx++)
fceu_video_out[y * width + x] = retro_palette[*gfx];
fceu_video_out_ptr[y * width + x] = retro_palette[*gfx];
}
video_cb(fceu_video_out, width, height, pitch);
video_cb(fceu_video_out_ptr, width, height, pitch);
#endif
}