From 513926521d08ad6864a544c0604c755c66d2a553 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 21 Apr 2018 19:17:39 -0500 Subject: [PATCH] Don't set GFX_MULTI_FORMAT if not needed. The BuildPixel calls cost ~3% performance. --- gtk/configure.ac | 2 +- gtk/src/gtk_display.cpp | 1 - libretro/libretro.cpp | 13 ++++++------- port.h | 7 +++++-- unix/configure | 24 +++++++++++++----------- unix/configure.ac | 2 ++ 6 files changed, 27 insertions(+), 22 deletions(-) diff --git a/gtk/configure.ac b/gtk/configure.ac index 4cd190bf..e88bc77a 100644 --- a/gtk/configure.ac +++ b/gtk/configure.ac @@ -359,7 +359,7 @@ NASM="not_found" ZSNESC4=no ZSNESFX=no -CFLAGS="$CFLAGS -DCORRECT_VRAM_READS" +CFLAGS="$CFLAGS -DPIXEL_FORMAT=RGB555 -DCORRECT_VRAM_READS" CORRECT_VRAM_READS=1 if test yes = "$with_debugger"; then diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp index 27a38490..6fe10dde 100644 --- a/gtk/src/gtk_display.cpp +++ b/gtk/src/gtk_display.cpp @@ -1832,7 +1832,6 @@ void S9xInitDisplay (int argc, char **argv) { Settings.SupportHiRes = TRUE; - S9xSetRenderPixelFormat (RGB555); S9xBlit2xSaIFilterInit (); #ifdef USE_HQ2X S9xBlitHQ2xFilterInit (); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 86914ab7..4219f8fc 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -546,15 +546,14 @@ bool retro_load_game(const struct retro_game_info *game) rom_loaded = Memory.LoadROMMem((const uint8_t*)game->data ,game->size); } - int pixel_format = RGB555; - if(environ_cb) { - pixel_format = RGB565; - enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; - if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) - pixel_format = RGB555; + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; + + if(!environ_cb || !environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) + { + return false } + S9xGraphicsDeinit(); - S9xSetRenderPixelFormat(pixel_format); S9xGraphicsInit(); if (!rom_loaded && log_cb) diff --git a/port.h b/port.h index 5e4d3f7a..16932b22 100644 --- a/port.h +++ b/port.h @@ -211,8 +211,6 @@ #include #endif -#define GFX_MULTI_FORMAT - #ifdef __WIN32__ //#define RIGHTSHIFT_IS_SAR #define RIGHTSHIFT_int8_IS_SAR @@ -220,6 +218,7 @@ #define RIGHTSHIFT_int32_IS_SAR #ifndef __WIN32_LIBSNES__ #define SNES_JOY_READ_CALLBACKS +#define GFX_MULTI_FORMAT #endif //__WIN32_LIBSNES__ #endif @@ -228,6 +227,10 @@ #define PIXEL_FORMAT RGB555 #endif +#ifndef PIXEL_FORMAT +#define PIXEL_FORMAT RGB565 +#endif + #ifndef snes9x_types_defined #define snes9x_types_defined typedef unsigned char bool8; diff --git a/unix/configure b/unix/configure index 14be08d5..94726515 100755 --- a/unix/configure +++ b/unix/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.ac Revision: 1.54.1 . +# From configure.ac Revision: 1.55 . # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for Snes9x 1.54.1. +# Generated by GNU Autoconf 2.69 for Snes9x 1.55. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -578,8 +578,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='Snes9x' PACKAGE_TARNAME='snes9x' -PACKAGE_VERSION='1.54.1' -PACKAGE_STRING='Snes9x 1.54.1' +PACKAGE_VERSION='1.55' +PACKAGE_STRING='Snes9x 1.55' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1279,7 +1279,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures Snes9x 1.54.1 to adapt to many kinds of systems. +\`configure' configures Snes9x 1.55 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1349,7 +1349,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of Snes9x 1.54.1:";; + short | recursive ) echo "Configuration of Snes9x 1.55:";; esac cat <<\_ACEOF @@ -1466,7 +1466,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -Snes9x configure 1.54.1 +Snes9x configure 1.55 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1869,7 +1869,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by Snes9x $as_me 1.54.1, which was +It was created by Snes9x $as_me 1.55, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -6306,9 +6306,11 @@ else S9XDEFS="$S9XDEFS -DNOSOUND" fi +S9XDEFS="$S9XDEFS -DGFX_MULTI_FORMAT" + # Output. -S9XFLGS="$CXXFLAGS $CPPFLAGS $LDFLAGS $S9XFLGS" +S9XFLGS="$CXXFLAGS $CPPFLAGS $S9XFLGS" S9XLIBS="$LIBS $S9XLIBS" S9XFLGS="`echo \"$S9XFLGS\" | sed -e 's/ */ /g'`" @@ -6901,7 +6903,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by Snes9x $as_me 1.54.1, which was +This file was extended by Snes9x $as_me 1.55, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6954,7 +6956,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -Snes9x config.status 1.54.1 +Snes9x config.status 1.55 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/unix/configure.ac b/unix/configure.ac index daa68ec2..cde86b4d 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -446,6 +446,8 @@ else S9XDEFS="$S9XDEFS -DNOSOUND" fi +S9XDEFS="$S9XDEFS -DGFX_MULTI_FORMAT" + # Output. S9XFLGS="$CXXFLAGS $CPPFLAGS $S9XFLGS"