Gtk: Remove some superfluous graphics options.

PBOs aren't generally faster any more.
NPOT textures are widely supported.
Giving control over to Gtk while waiting for a swap doesn't really work
that well, so the sync control extension options are removed.

This means the OpenGL and Vulkan backends are in parity with regard to
options.
This commit is contained in:
BearOso 2023-01-23 15:34:52 -06:00
parent 10a2cd19d1
commit fa03a2c5b2
11 changed files with 37 additions and 329 deletions

View File

@ -139,13 +139,9 @@ int Snes9xConfig::load_defaults()
Settings.Rewinding = false;
sync_to_vblank = true;
use_pbos = true;
pbo_format = 0;
npot_textures = true;
use_shaders = false;
shader_filename.clear();
use_glfinish = false;
use_sync_control = false;
reduce_input_lag = false;
/* Snes9x Variables */
Settings.MouseMaster = true;
@ -245,12 +241,8 @@ int Snes9xConfig::save_config_file()
section = "OpenGL";
outbool("VSync", sync_to_vblank);
outbool("glFinish", use_glfinish);
outbool("SyncControl", use_sync_control);
outbool("UseNonPowerOfTwoTextures", npot_textures);
outbool("ReduceInputLag", reduce_input_lag);
outbool("EnableCustomShaders", use_shaders);
outbool("UsePixelBufferObjects", use_pbos);
outint("PixelBufferObjectBitDepth", pbo_format);
outstring("ShaderFile", shader_filename);
section = "Sound";
@ -472,11 +464,7 @@ int Snes9xConfig::load_config_file()
section = "OpenGL";
inbool("VSync", sync_to_vblank);
inbool("glFinish", use_glfinish);
inbool("SyncControl", use_sync_control);
inbool("UsePixelBufferObjects", use_pbos);
inint("PixelBufferObjectBitDepth", pbo_format);
inbool("UseNonPowerOfTwoTextures", npot_textures);
inbool("ReduceInputLag", reduce_input_lag);
inbool("EnableCustomShaders", use_shaders);
instr("ShaderFile", shader_filename);
@ -642,9 +630,6 @@ int Snes9xConfig::load_config_file()
scale_method = 0;
#endif /* USE_XBRZ */
if (pbo_format != 32)
pbo_format = 16;
if (Settings.SkipFrames == THROTTLE_SOUND_SYNC)
Settings.SoundSync = true;
else

View File

@ -150,13 +150,9 @@ class Snes9xConfig
XRRCrtcInfo *xrr_crtc_info;
bool sync_to_vblank;
bool use_pbos;
int pbo_format;
bool npot_textures;
bool use_shaders;
std::string shader_filename;
bool use_glfinish;
bool use_sync_control;
bool reduce_input_lag;
JoyDevices joysticks;
int joystick_threshold;

View File

@ -89,7 +89,7 @@ S9xOpenGLDisplayDriver::S9xOpenGLDisplayDriver(Snes9xWindow *window, Snes9xConfi
void S9xOpenGLDisplayDriver::update(uint16_t *buffer, int width, int height, int stride_in_pixels)
{
Gtk::Allocation allocation = drawing_area->get_allocation();
if (output_window_width != allocation.get_width() ||
output_window_height != allocation.get_height())
{
@ -119,61 +119,8 @@ void S9xOpenGLDisplayDriver::update(uint16_t *buffer, int width, int height, int
update_texture_size(width, height);
if (using_pbos)
{
void *pbo_memory = NULL;
GLbitfield bits = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT;
if (config->pbo_format == 16)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, width * height * 2, NULL, GL_STREAM_DRAW);
if (version >= 30)
pbo_memory = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, width * height * 2, bits);
else
pbo_memory = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
for (int y = 0; y < height; y++)
{
uint16 *dst = (uint16_t *)pbo_memory + (width * y);
uint16 *src = &buffer[y * stride_in_pixels];
memcpy(dst, src, width * 2);
}
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB,
GL_UNSIGNED_SHORT_5_6_5, BUFFER_OFFSET(0));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
else /* 32-bit color */
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
glBufferData(GL_PIXEL_UNPACK_BUFFER, width * height * 4, NULL, GL_STREAM_DRAW);
if (version >= 30)
pbo_memory = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, width * height * 4, bits);
else
pbo_memory = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
/* Pixel swizzling in software */
S9xConvert(buffer, pbo_memory, stride_in_pixels * 2, width * 4, width, height, 32);
glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER);
glPixelStorei(GL_UNPACK_ROW_LENGTH, width);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, BUFFER_OFFSET(0));
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
}
else
{
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride_in_pixels);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer);
}
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride_in_pixels);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer);
if (using_glsl_shaders)
{
@ -213,30 +160,15 @@ void S9xOpenGLDisplayDriver::update_texture_size(int width, int height)
{
glBindTexture(GL_TEXTURE_2D, texmap);
if (using_pbos && config->pbo_format == 32)
{
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
width,
height,
0,
GL_BGRA,
GL_UNSIGNED_BYTE,
NULL);
}
else
{
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB565,
width,
height,
0,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5,
NULL);
}
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB565,
width,
height,
0,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5,
NULL);
coords[9] = 1.0f;
coords[10] = 1.0f;
@ -306,15 +238,6 @@ bool S9xOpenGLDisplayDriver::load_shaders(const char *shader_file)
bool S9xOpenGLDisplayDriver::opengl_defaults()
{
npot = false;
using_pbos = false;
if (config->use_pbos)
{
if (version >= 15)
using_pbos = true;
else
config->use_pbos = false;
}
using_glsl_shaders = false;
glsl_shader = NULL;
@ -330,10 +253,7 @@ bool S9xOpenGLDisplayDriver::opengl_defaults()
texture_width = 1024;
texture_height = 1024;
if (config->npot_textures)
{
npot = true;
}
npot = true;
if (legacy)
{
@ -402,45 +322,18 @@ bool S9xOpenGLDisplayDriver::opengl_defaults()
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
if (config->use_pbos)
{
glGenBuffers(1, &pbo);
glGenTextures(1, &texmap);
glGenTextures(1, &texmap);
glBindTexture(GL_TEXTURE_2D, texmap);
glTexImage2D(GL_TEXTURE_2D,
0,
config->pbo_format == 16 ? GL_RGB565 : GL_RGBA,
texture_width,
texture_height,
0,
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);
glBufferData(GL_PIXEL_UNPACK_BUFFER,
texture_width * texture_height * 3,
NULL,
GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
else
{
glGenTextures(1, &texmap);
glBindTexture(GL_TEXTURE_2D, texmap);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB565,
texture_width,
texture_height,
0,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5,
NULL);
}
glBindTexture(GL_TEXTURE_2D, texmap);
glTexImage2D(GL_TEXTURE_2D,
0,
GL_RGB565,
texture_width,
texture_height,
0,
GL_RGB,
GL_UNSIGNED_SHORT_5_6_5,
NULL);
glClearColor(0.0, 0.0, 0.0, 0.0);
@ -535,7 +428,7 @@ void S9xOpenGLDisplayDriver::swap_buffers()
{
context->swap_buffers();
if (config->use_glfinish && !config->use_sync_control)
if (config->reduce_input_lag)
{
usleep(0);
glFinish();
@ -555,12 +448,6 @@ void S9xOpenGLDisplayDriver::deinit()
delete glsl_shader;
}
if (using_pbos)
{
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
glDeleteBuffers(1, &pbo);
}
glDeleteTextures(1, &texmap);
}

View File

@ -52,13 +52,11 @@ class S9xOpenGLDisplayDriver : public S9xDisplayDriver
GLint texture_width;
GLint texture_height;
GLuint texmap;
GLuint pbo;
bool legacy;
bool core;
int version;
bool npot;
bool using_pbos;
bool initialized;
bool using_glsl_shaders;

View File

@ -287,6 +287,9 @@ void S9xVulkanDisplayDriver::update(uint16_t *buffer, int width, int height, int
if (!context)
return;
if (gui_config->reduce_input_lag)
device.waitIdle();
auto viewport = S9xApplyAspect(width, height, current_width, current_height);
if (shaderchain)

View File

@ -18,8 +18,6 @@ GTKGLXContext::GTKGLXContext()
version_major = -1;
version_minor = -1;
use_oml_sync_control = false;
ust = msc = sbc = 0;
}
GTKGLXContext::~GTKGLXContext()
@ -93,9 +91,6 @@ bool GTKGLXContext::create_context()
return false;
}
if (strstr(extensions, "GLX_OML_sync_control") && gui_config->use_sync_control)
use_oml_sync_control = true;
return true;
}
@ -116,24 +111,11 @@ void GTKGLXContext::resize()
void GTKGLXContext::swap_buffers()
{
if (use_oml_sync_control)
glXGetSyncValuesOML(display, xid, &ust, &msc, &sbc);
glXSwapBuffers(display, xid);
}
bool GTKGLXContext::ready()
{
if (use_oml_sync_control)
{
int64 ust, msc, sbc;
glXGetSyncValuesOML(display, xid, &ust, &msc, &sbc);
if (sbc != this->sbc || msc - this->msc > 2)
return true;
return false;
}
return true;
}

View File

@ -32,9 +32,6 @@ class GTKGLXContext : public OpenGLContext
int version_major;
int version_minor;
bool use_oml_sync_control;
int64_t ust, msc, sbc;
};
#endif

View File

@ -466,11 +466,7 @@ void Snes9xPreferences::move_settings_to_dialog()
set_check ("bilinear_filter", Settings.BilinearFilter);
set_check ("sync_to_vblank", config->sync_to_vblank);
set_check ("use_glfinish", config->use_glfinish);
set_check ("use_sync_control", config->use_sync_control);
set_check ("use_pbos", config->use_pbos);
set_combo ("pixel_format", config->pbo_format == 16 ? 0 : 1);
set_check ("npot_textures", config->npot_textures);
set_check ("reduce_input_lag", config->reduce_input_lag);
set_check ("use_shaders", config->use_shaders);
set_entry_text ("fragment_shader", config->shader_filename.c_str ());
@ -628,13 +624,7 @@ void Snes9xPreferences::get_settings_from_dialog()
Settings.InterpolationMethod = get_combo("sound_filter");
#endif
int pbo_format = get_combo("pixel_format") == 1 ? 32 : 16;
if (config->sync_to_vblank != get_check("sync_to_vblank") ||
config->use_sync_control != get_check("use_sync_control") ||
config->npot_textures != get_check("npot_textures") ||
config->use_pbos != get_check("use_pbos") ||
config->pbo_format != pbo_format ||
config->use_shaders != get_check("use_shaders") ||
(config->shader_filename.compare(get_entry_text("fragment_shader"))))
{
@ -642,13 +632,9 @@ void Snes9xPreferences::get_settings_from_dialog()
}
config->sync_to_vblank = get_check("sync_to_vblank");
config->use_pbos = get_check("use_pbos");
config->npot_textures = get_check("npot_textures");
config->use_shaders = get_check("use_shaders");
config->use_glfinish = get_check("use_glfinish");
config->use_sync_control = get_check("use_sync_control");
config->reduce_input_lag = get_check("reduce_input_lag");
config->shader_filename = get_entry_text ("fragment_shader");
config->pbo_format = pbo_format;
std::string new_sram_directory = get_entry_text("sram_directory");
config->savestate_directory = get_entry_text("savestate_directory");

View File

@ -53,8 +53,6 @@ WaylandEGLContext::WaylandEGLContext()
egl_context = NULL;
egl_config = NULL;
egl_window = NULL;
use_sync_control = false;
ust = msc = sbc = 0;
idle_inhibit_manager = NULL;
idle_inhibitor = NULL;
}
@ -188,13 +186,6 @@ bool WaylandEGLContext::create_context()
}
}
if (gui_config->use_sync_control && epoxy_has_egl_extension(egl_display, "EGL_CHROMIUM_sync_control"))
{
eglGetSyncValuesCHROMIUM = (PEGLGETSYNCVALUESCHROMIUM)eglGetProcAddress("eglGetSyncValuesCHROMIUM");
if (eglGetSyncValuesCHROMIUM)
use_sync_control = true;
}
wl_surface_set_buffer_scale(child, scale);
gdk_window_invalidate_rect(gdk_window, NULL, false);
@ -216,24 +207,12 @@ void WaylandEGLContext::resize()
void WaylandEGLContext::swap_buffers()
{
if (use_sync_control)
eglGetSyncValuesCHROMIUM(egl_display, egl_surface, &ust, &msc, &sbc);
eglSwapBuffers(egl_display, egl_surface);
wl_surface_commit(child);
}
bool WaylandEGLContext::ready()
{
if (use_sync_control)
{
EGLuint64KHR ust, msc, sbc;
eglGetSyncValuesCHROMIUM(egl_display, egl_surface, &ust, &msc, &sbc);
if (sbc != this->sbc || msc - this->msc > 2)
return true;
return false;
}
return true;
}

View File

@ -45,11 +45,6 @@ class WaylandEGLContext : public OpenGLContext
wl_egl_window *egl_window;
typedef EGLBoolean (*PEGLGETSYNCVALUESCHROMIUM)(EGLDisplay, EGLSurface, EGLuint64KHR *, EGLuint64KHR *, EGLuint64KHR *);
PEGLGETSYNCVALUESCHROMIUM eglGetSyncValuesCHROMIUM;
bool use_sync_control;
EGLuint64KHR ust, msc, sbc;
struct zwp_idle_inhibit_manager_v1 *idle_inhibit_manager;
struct zwp_idle_inhibitor_v1 *idle_inhibitor;
};

View File

@ -3826,8 +3826,8 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="use_glfinish">
<property name="label" translatable="yes">Reduce input lag with glFinish</property>
<object class="GtkCheckButton" id="reduce_input_lag">
<property name="label" translatable="yes">Reduce input lag</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
@ -3840,106 +3840,6 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="use_sync_control">
<property name="label" translatable="yes">Reduce input lag with sync control</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">More modern method for syncing the program with the video output to reduce input latency. Allows GUI events to occur in the meantime</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="npot_textures">
<property name="label" translatable="yes">Allow non-power-of-two textures</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Prevents edge artifacts, but can slow performance</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="use_pbos">
<property name="label" translatable="yes">Use pixel-buffer objects</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip_text" translatable="yes">Can be faster or slower depending on drivers</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">10</property>
<child>
<object class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip_text" translatable="yes">Different formats can yield highly different performance</property>
<property name="spacing">10</property>
<child>
<object class="GtkLabel" id="label116">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Pixel-buffer format:</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="pixel_format">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="model">liststore8</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext8"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
@ -3995,7 +3895,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">6</property>
<property name="position">2</property>
</packing>
</child>
</object>