Don't go through LUT - memory latency penalties are the big issue

these days for performance so this is actually anti-performance
This commit is contained in:
twinaphex 2014-06-15 05:42:21 +02:00
parent 9dd20698d5
commit c8f3ef33da
3 changed files with 6 additions and 51 deletions

View File

@ -28,7 +28,6 @@ static retro_rumble_interface rumble;
static bool overscan;
static double last_sound_rate;
static MDFN_PixelFormat last_pixel_format;
static MDFN_Surface *surf;
@ -440,7 +439,6 @@ bool retro_load_game(const struct retro_game_info *info)
return false;
MDFN_PixelFormat pix_fmt(MDFN_COLORSPACE_RGB, 16, 8, 0, 24);
memset(&last_pixel_format, 0, sizeof(MDFN_PixelFormat));
is_pal = (CalcDiscSCEx() == REGION_EU);
mednafen_psx_fb_height = is_pal ? 576 : 480;
@ -554,11 +552,10 @@ static void update_input(void)
static uint64_t video_frames, audio_frames;
#define SOUND_CHANNELS 2
void retro_run(void)
{
MDFNGI *curgame = game;
input_poll_cb();
update_input();
@ -579,13 +576,6 @@ void retro_run(void)
spec.VideoFormatChanged = false;
spec.SoundFormatChanged = false;
if (memcmp(&last_pixel_format, &spec.surface->format, sizeof(MDFN_PixelFormat)))
{
spec.VideoFormatChanged = TRUE;
last_pixel_format = spec.surface->format;
}
if (spec.SoundRate != last_sound_rate)
{
spec.SoundFormatChanged = true;
@ -612,7 +602,7 @@ void retro_run(void)
#endif
int16_t *interbuf = (int16_t*)&IntermediateBuffer;
int16_t *const SoundBuf = interbuf + spec.SoundBufSizeALMS * curgame->soundchan;
int16_t *const SoundBuf = interbuf + spec.SoundBufSizeALMS * SOUND_CHANNELS;
int32_t SoundBufSize = spec.SoundBufSize - spec.SoundBufSizeALMS;
const int32_t SoundBufMaxSize = spec.SoundBufMaxSize - spec.SoundBufSizeALMS;

View File

@ -1081,8 +1081,8 @@ INLINE void PS_GPU::ReorderRGB_Var(uint32_t out_Rshift, uint32_t out_Gshift, uin
srcpix = src[(fb_x >> 1) + 0] | (src[((fb_x >> 1) + 1) & 0x7FF] << 16);
srcpix >>= (fb_x & 1) * 8;
dest[x] = (((srcpix >> 0) << out_Rshift) & (0xFF << out_Rshift)) | (((srcpix >> 8) << out_Gshift) & (0xFF << out_Gshift)) |
(((srcpix >> 16) << out_Bshift) & (0xFF << out_Bshift));
dest[x] = (((srcpix >> 0) << RED_SHIFT) & (0xFF << RED_SHIFT)) | (((srcpix >> 8) << GREEN_SHIFT) & (0xFF << GREEN_SHIFT)) |
(((srcpix >> 16) << BLUE_SHIFT) & (0xFF << BLUE_SHIFT));
fb_x = (fb_x + 3) & 0x7FF;
}
@ -1092,11 +1092,7 @@ INLINE void PS_GPU::ReorderRGB_Var(uint32_t out_Rshift, uint32_t out_Gshift, uin
for(int32 x = dx_start; x < dx_end; x++)
{
uint32_t srcpix = src[fb_x >> 1];
dest[x] = OutputLUT[srcpix & 0x7FFF];
//dest[x] = ShiftHelper(srcpix, out_Rshift + 3 - 0, (0xF8 << out_Rshift)) |
// ShiftHelper(srcpix, out_Gshift + 3 - 5, (0xF8 << out_Gshift)) |
// ShiftHelper(srcpix, out_Bshift + 3 - 10, (0xF8 << out_Bshift));
dest[x] = MAKECOLOR((((srcpix >> 0) & 0x1F) << 3), (((srcpix >> 5) & 0x1F) << 3), (((srcpix >> 10) & 0x1F) << 3), 0);
fb_x = (fb_x + 2) & 0x7FF;
}
@ -1104,13 +1100,6 @@ INLINE void PS_GPU::ReorderRGB_Var(uint32_t out_Rshift, uint32_t out_Gshift, uin
}
template<uint32_t out_Rshift, uint32_t out_Gshift, uint32_t out_Bshift>
void PS_GPU::ReorderRGB(bool bpp24, const uint16_t *src, uint32_t *dest, const int32 dx_start, const int32 dx_end, int32 fb_x)
{
ReorderRGB_Var(out_Rshift, out_Gshift, out_Bshift, bpp24, src, dest, dx_start, dx_end, fb_x);
}
pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp)
{
static const uint32_t DotClockRatios[5] = { 10, 8, 5, 4, 7 };
@ -1389,16 +1378,7 @@ pscpu_timestamp_t PS_GPU::Update(const pscpu_timestamp_t sys_timestamp)
memset(dest, 0, dx_start * sizeof(int32));
//printf("%d %d %d - %d %d\n", scanline, dx_start, dx_end, HorizStart, HorizEnd);
if(surface->format.Rshift == 0 && surface->format.Gshift == 8 && surface->format.Bshift == 16)
ReorderRGB<0, 8, 16>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
else if(surface->format.Rshift == 8 && surface->format.Gshift == 16 && surface->format.Bshift == 24)
ReorderRGB<8, 16, 24>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
else if(surface->format.Rshift == 16 && surface->format.Gshift == 8 && surface->format.Bshift == 0)
ReorderRGB<16, 8, 0>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
else if(surface->format.Rshift == 24 && surface->format.Gshift == 16 && surface->format.Bshift == 8)
ReorderRGB<24, 16, 8>(DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
else
ReorderRGB_Var(surface->format.Rshift, surface->format.Gshift, surface->format.Bshift, DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
ReorderRGB_Var(RED_SHIFT, GREEN_SHIFT, BLUE_SHIFT, DisplayMode & 0x10, src, dest, dx_start, dx_end, fb_x);
for(x = dx_end; x < dmw; x++)
dest[x] = 0;
@ -1461,20 +1441,6 @@ void PS_GPU::StartFrame(EmulateSpecStruct *espec_arg)
DisplayRect = &espec->DisplayRect;
LineWidths = espec->LineWidths;
skip = espec->skip;
if(espec->VideoFormatChanged)
{
int rc;
for(rc = 0; rc < 0x8000; rc++)
{
uint32_t r, g, b;
r = ((rc >> 0) & 0x1F) << 3;
g = ((rc >> 5) & 0x1F) << 3;
b = ((rc >> 10) & 0x1F) << 3;
OutputLUT[rc] = espec->surface->format.MakeColor(r, g, b, 0);
}
}
}
}

View File

@ -297,7 +297,6 @@ class PS_GPU
bool HardwarePALType;
int LineVisFirst, LineVisLast;
uint32 OutputLUT[32768];
void ReorderRGB_Var(uint32 out_Rshift, uint32 out_Gshift, uint32 out_Bshift, bool bpp24, const uint16 *src, uint32 *dest, const int32 dx_start, const int32 dx_end, int32 fb_x);
template<uint32 out_Rshift, uint32 out_Gshift, uint32 out_Bshift>