Skip to content

Commit

Permalink
enhancement: Show SDL2 render thread option in the GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Nov 12, 2023
1 parent b3168c1 commit 7f3379c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/osdep/amiberry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2508,6 +2508,17 @@ void set_logfile_enabled(bool enabled)
amiberry_options.write_logfile = enabled;
}

bool get_sdl2_thread_enabled()
{
return amiberry_options.use_sdl2_render_thread;
}

void set_sdl2_thread_enabled(bool enabled)
{
amiberry_options.use_sdl2_render_thread = enabled;
sdl2_thread_changed = true;
}

// Returns 1 if savedatapath is overridden
// if force_internal == true, the non-overridden whdbootpath based save-data path will be returned
int get_savedatapath(char* out, int size, const int force_internal)
Expand Down
11 changes: 9 additions & 2 deletions src/osdep/amiberry_gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ static int deskhz;

#ifdef AMIBERRY
bool vsync_changed = false;
bool sdl2_thread_changed = false;
#endif

// Check if the requested Amiga resolution can be displayed with the current Screen mode as a direct multiple
Expand Down Expand Up @@ -1003,7 +1004,7 @@ int check_prefs_changed_gfx()
c |= currprefs.multithreaded_drawing != changed_prefs.multithreaded_drawing ? (512) : 0;
#endif

if (display_change_requested || c)
if (display_change_requested || c || sdl2_thread_changed)
{
bool setpause = false;
bool dontcapture = false;
Expand Down Expand Up @@ -1128,7 +1129,13 @@ int check_prefs_changed_gfx()
currprefs.rtgallowscaling = changed_prefs.rtgallowscaling;
currprefs.rtgscaleaspectratio = changed_prefs.rtgscaleaspectratio;
currprefs.rtgvblankrate = changed_prefs.rtgvblankrate;


if (sdl2_thread_changed)
{
graphics_leave();
graphics_init(true);
sdl2_thread_changed = false;
}
bool unacquired = false;
for (int monid = MAX_AMIGAMONITORS - 1; monid >= 0; monid--) {
if (!monitors[monid])
Expand Down
1 change: 1 addition & 0 deletions src/osdep/amiberry_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ void SDL2_toggle_vsync(bool vsync);
extern void auto_crop_image();

extern SDL_GameControllerButton vkbd_button;
extern bool sdl2_thread_changed;
5 changes: 3 additions & 2 deletions src/osdep/gui/Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ static NavigationMap navMap[] =

// active move left move right move up move down
// PanelDisplay
{ "cboFullscreen", "Display", "chkHorizontal", "sldBrightness", "cboScreenmode" },
{ "cboFullscreen", "Display", "chkHorizontal", "chkSdl2Thread", "cboScreenmode" },
{ "cboScreenmode", "Display", "chkVertical", "cboFullscreen", "sldWidth" },
{ "sldWidth", "", "", "cboScreenmode", "sldHeight" },
{ "sldHeight", "", "", "sldWidth", "chkAutoCrop" },
Expand All @@ -285,7 +285,8 @@ static NavigationMap navMap[] =
{ "chkFlickerFixer", "Display", "optIDouble", "chkAspect", "chkFrameskip" },
{ "chkFrameskip", "Display", "optIDouble2", "chkFlickerFixer", "sldBrightness" },
{ "sldRefresh", "", "", "chkFlickerFixer", "sldBrightness" },
{ "sldBrightness", "", "", "chkFrameskip", "cboFullscreen" },
{ "sldBrightness", "", "", "chkFrameskip", "chkSdl2Thread" },
{ "chkSdl2Thread", "Display", "optIDouble2", "sldBrightness", "cboFullscreen" },

{ "chkHorizontal", "cboScreenmode", "", "optIDouble3", "chkVertical" },
{ "chkVertical", "cboScreenmode", "", "chkHorizontal", "optSingle" },
Expand Down
20 changes: 19 additions & 1 deletion src/osdep/gui/PanelDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ static gcn::Label* lblBrightness;
static gcn::Slider* sldBrightness;
static gcn::Label* lblBrightnessValue;

static gcn::CheckBox* chkSdl2Thread;

class AmigaScreenActionListener : public gcn::ActionListener
{
public:
Expand Down Expand Up @@ -237,7 +239,10 @@ class AmigaScreenActionListener : public gcn::ActionListener

else if (actionEvent.getSource() == chkFilterLowRes)
changed_prefs.gfx_lores_mode = chkFilterLowRes->isSelected() ? 1 : 0;


else if (actionEvent.getSource() == chkSdl2Thread)
set_sdl2_thread_enabled(chkSdl2Thread->isSelected());

RefreshPanelDisplay();
}
};
Expand Down Expand Up @@ -470,6 +475,10 @@ void InitPanelDisplay(const config_category& category)
lblBrightnessValue = new gcn::Label("0.0");
lblBrightnessValue->setAlignment(gcn::Graphics::LEFT);

chkSdl2Thread = new gcn::CheckBox("Use SDL2 multi-threaded rendering");
chkSdl2Thread->setId("chkSdl2Thread");
chkSdl2Thread->addActionListener(amigaScreenActionListener);

lblScreenmode = new gcn::Label("Screen mode:");
lblScreenmode->setAlignment(gcn::Graphics::RIGHT);
cboScreenmode = new gcn::DropDown(&fullscreen_modes_list);
Expand Down Expand Up @@ -634,6 +643,9 @@ void InitPanelDisplay(const config_category& category)
category.panel->add(lblBrightness, DISTANCE_BORDER, posY);
category.panel->add(sldBrightness, lblBrightness->getX() + lblBrightness->getWidth() + DISTANCE_NEXT_X, posY);
category.panel->add(lblBrightnessValue, sldBrightness->getX() + sldBrightness->getWidth() + 8, posY);
posY += lblBrightness->getHeight() + DISTANCE_NEXT_Y;

category.panel->add(chkSdl2Thread, DISTANCE_BORDER, posY);

RefreshPanelDisplay();
}
Expand Down Expand Up @@ -696,6 +708,7 @@ void ExitPanelDisplay()
delete lblResolution;
delete cboResolution;
delete chkFilterLowRes;
delete chkSdl2Thread;
}

void RefreshPanelDisplay()
Expand Down Expand Up @@ -773,6 +786,8 @@ void RefreshPanelDisplay()
chkAspect->setSelected(changed_prefs.gfx_correct_aspect);
chkFilterLowRes->setSelected(changed_prefs.gfx_lores_mode);

chkSdl2Thread->setSelected(get_sdl2_thread_enabled());

if (changed_prefs.gfx_apmode[0].gfx_fullscreen == GFX_WINDOW)
{
cboScreenmode->setSelected(0);
Expand Down Expand Up @@ -941,6 +956,9 @@ bool HelpPanelDisplay(std::vector<std::string>& helptext)
helptext.emplace_back(" ");
helptext.emplace_back("\"Brightness\" - Allows adjustment of the output image brightness, from -200 to 200.");
helptext.emplace_back(" ");
helptext.emplace_back("\"Use SDL2 multi-threaded rendering\" - Enables multi-threaded drawing using SDL2.");
helptext.emplace_back("Provides a performance benefit, however not all systems support it.");
helptext.emplace_back("Disable this if you notice problems, like a black screen when starting emulation.");
helptext.emplace_back(" ");
helptext.emplace_back("\"Line Mode\" - These options define how the Amiga screen is drawn.");
helptext.emplace_back(" ");
Expand Down
2 changes: 2 additions & 0 deletions src/osdep/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ extern int get_savedatapath(char* out, int size, const int force_internal);
extern void get_whdbootpath(char* out, int size);
extern void set_whdbootpath(char* newpath);

extern bool get_sdl2_thread_enabled();
extern void set_sdl2_thread_enabled(bool enabled);
extern bool get_logfile_enabled();
extern void set_logfile_enabled(bool enabled);
extern void get_logfile_path(char* out, int size);
Expand Down

0 comments on commit 7f3379c

Please sign in to comment.