From 94c2c4c46046070b6dad1a7ef1ebbd14f5f36f0c Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sat, 27 Oct 2018 15:33:55 -0500 Subject: [PATCH] Remove 24-bit PBO format. It's actually useless. --- gtk/src/gtk_config.cpp | 3 +- gtk/src/gtk_display_driver_opengl.cpp | 55 +++++---------------------- gtk/src/gtk_display_driver_opengl.h | 14 ------- gtk/src/gtk_preferences.cpp | 8 ++-- gtk/src/snes9x.ui | 5 +-- 5 files changed, 18 insertions(+), 67 deletions(-) diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index 069a36a6..c4a4c3cd 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -596,7 +596,8 @@ Snes9xConfig::set_option (const char *name, const char *value) { #ifdef USE_OPENGL pbo_format = atoi (value); - pbo_format = CLAMP (pbo_format, 0, 2); + if (pbo_format != 32) + pbo_format = 16; #endif } else if (!strcasecmp (name, "npot_textures")) diff --git a/gtk/src/gtk_display_driver_opengl.cpp b/gtk/src/gtk_display_driver_opengl.cpp index 8eaaf986..167e287d 100644 --- a/gtk/src/gtk_display_driver_opengl.cpp +++ b/gtk/src/gtk_display_driver_opengl.cpp @@ -115,7 +115,7 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset) if (using_pbos) { - if (config->pbo_format == PBO_FMT_16) + if (config->pbo_format == 16) { glBindBuffer (GL_PIXEL_UNPACK_BUFFER, pbo); @@ -147,42 +147,7 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset) glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); } - else if (config->pbo_format == PBO_FMT_24) - { - glPixelStorei (GL_UNPACK_ALIGNMENT, 1); - glBindBuffer (GL_PIXEL_UNPACK_BUFFER, pbo); - glBufferData (GL_PIXEL_UNPACK_BUFFER, - width * height * 3, - NULL, - GL_STREAM_DRAW); - pboMemory = glMapBuffer (GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY); - - /* Pixel swizzling in software */ - S9xSetEndianess (ENDIAN_SWAPPED); - S9xConvert (final_buffer, - pboMemory, - final_pitch, - width * 3, - width, - height, - 24); - - glUnmapBuffer (GL_PIXEL_UNPACK_BUFFER); - - glPixelStorei (GL_UNPACK_ROW_LENGTH, width); - glTexSubImage2D (GL_TEXTURE_2D, - 0, - 0, - 0, - width, - height, - GL_RGB, - GL_UNSIGNED_BYTE, - BUFFER_OFFSET (0)); - - glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); - } - else /* PBO_FMT_32 */ + else /* 32-bit color */ { glBindBuffer (GL_PIXEL_UNPACK_BUFFER, pbo); glBufferData (GL_PIXEL_UNPACK_BUFFER, @@ -211,7 +176,7 @@ S9xOpenGLDisplayDriver::update (int width, int height, int yoffset) width, height, GL_BGRA, - PBO_BGRA_NATIVE_ORDER, + GL_UNSIGNED_BYTE, BUFFER_OFFSET (0)); glBindBuffer (GL_PIXEL_UNPACK_BUFFER, 0); @@ -322,16 +287,16 @@ S9xOpenGLDisplayDriver::update_texture_size (int width, int height) { glBindTexture (GL_TEXTURE_2D, texmap); - if (using_pbos) + if (using_pbos && config->pbo_format == 32) { glTexImage2D (GL_TEXTURE_2D, 0, - config->pbo_format == PBO_FMT_16 ? GL_RGB565 : 4, + 4, width, height, 0, - PBO_GET_FORMAT (config->pbo_format), - PBO_GET_PACKING (config->pbo_format), + GL_BGRA, + GL_UNSIGNED_BYTE, NULL); } else @@ -592,12 +557,12 @@ S9xOpenGLDisplayDriver::opengl_defaults (void) glBindTexture (GL_TEXTURE_2D, texmap); glTexImage2D (GL_TEXTURE_2D, 0, - config->pbo_format == PBO_FMT_16 ? GL_RGB565 : 4, + config->pbo_format == 16 ? GL_RGB565 : 4, texture_width, texture_height, 0, - PBO_GET_FORMAT (config->pbo_format), - PBO_GET_PACKING (config->pbo_format), + config->pbo_format == 16 ? GL_RGB : GL_BGRA, + config->pbo_format == 16 ? GL_UNSIGNED_SHORT_5_6_5 : GL_UNSIGNED_BYTE, NULL); glBindBuffer (GL_PIXEL_UNPACK_BUFFER, pbo); diff --git a/gtk/src/gtk_display_driver_opengl.h b/gtk/src/gtk_display_driver_opengl.h index 1382f3aa..e29fd7a8 100644 --- a/gtk/src/gtk_display_driver_opengl.h +++ b/gtk/src/gtk_display_driver_opengl.h @@ -16,22 +16,8 @@ #include "shaders/glsl.h" -#define PBO_FMT_16 0 -#define PBO_FMT_24 1 -#define PBO_FMT_32 2 - #define BUFFER_OFFSET(i) ((char *) NULL + (i)) -#ifdef __BIG_ENDIAN__ -/* We have to reverse the bytes on MSB systems. This can be slow */ -/* GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367 */ -#define PBO_BGRA_NATIVE_ORDER 0x8367 -#else -#define PBO_BGRA_NATIVE_ORDER GL_UNSIGNED_BYTE -#endif -#define PBO_GET_FORMAT(x) (((x) == PBO_FMT_32) ? GL_BGRA : GL_RGB) -#define PBO_GET_PACKING(x) (((x) == PBO_FMT_16) ? GL_UNSIGNED_SHORT_5_6_5 : (((x) == PBO_FMT_24) ? GL_UNSIGNED_BYTE : PBO_BGRA_NATIVE_ORDER)) - class S9xOpenGLDisplayDriver : public S9xDisplayDriver { public: diff --git a/gtk/src/gtk_preferences.cpp b/gtk/src/gtk_preferences.cpp index 01951ce6..0b90154b 100644 --- a/gtk/src/gtk_preferences.cpp +++ b/gtk/src/gtk_preferences.cpp @@ -771,7 +771,7 @@ Snes9xPreferences::move_settings_to_dialog (void) set_check ("sync_to_vblank", config->sync_to_vblank); set_check ("sync_every_frame", config->sync_every_frame); set_check ("use_pbos", config->use_pbos); - set_combo ("pixel_format", config->pbo_format); + set_combo ("pixel_format", config->pbo_format == 16 ? 0 : 1); set_check ("npot_textures", config->npot_textures); set_check ("use_shaders", config->use_shaders); set_entry_text ("fragment_shader", config->fragment_shader); @@ -914,10 +914,12 @@ Snes9xPreferences::get_settings_from_dialog (void) #endif #ifdef USE_OPENGL + int pbo_format = get_combo ("pixel_format") == 1 ? 32 : 16; + if (config->sync_to_vblank != get_check ("sync_to_vblank") || config->npot_textures != get_check ("npot_textures") || config->use_pbos != get_check ("use_pbos") || - config->pbo_format != get_combo ("pixel_format") || + config->pbo_format != pbo_format || config->use_shaders != get_check ("use_shaders") || get_check ("use_shaders")) { @@ -932,7 +934,7 @@ Snes9xPreferences::get_settings_from_dialog (void) strncpy (config->fragment_shader, get_entry_text ("fragment_shader"), PATH_MAX); - config->pbo_format = get_combo ("pixel_format"); + config->pbo_format = pbo_format; #endif char safety_sram_directory [PATH_MAX]; diff --git a/gtk/src/snes9x.ui b/gtk/src/snes9x.ui index f88cf5e2..f8adb49a 100644 --- a/gtk/src/snes9x.ui +++ b/gtk/src/snes9x.ui @@ -1131,10 +1131,7 @@ - 16-bit (GL_BGRA) - - - 24-bit (GL_RGB) + 16-bit (GL_RGB) 32-bit (GL_BGRA)