gsdx-ogl: add a gui option (linux) to select external shader

Note: of course it requires a glsl shader ;)

On windows, you can set the path on the ini file. Here an example with linux path:
shaderfx_conf = /home/gregory/playstation/emulateur/pcsx2_merge/bin/GSdx_FX_Settings.ini
shaderfx_glsl = /home/gregory/playstation/emulateur/pcsx2_merge/bin/shader.fx
This commit is contained in:
Gregory Hainaut 2014-11-09 16:39:49 +01:00
parent 920ac6695f
commit ff39dffe23
2 changed files with 69 additions and 47 deletions

View File

@ -947,12 +947,12 @@ void GSDeviceOGL::DoExternalFX(GSTexture* st, GSTexture* dt)
{
// Lazy compile
if (!m_shaderfx.ps) {
std::ifstream fconfig("bin/GSdx_FX_Settings.ini");
std::ifstream fconfig(theApp.GetConfig("shaderfx_conf", "dummy.ini"));
std::stringstream config;
if (fconfig.good())
config << fconfig.rdbuf();
std::ifstream fshader("bin/shader.fx");
std::ifstream fshader(theApp.GetConfig("shaderfx_glsl", "dummy.glsl"));
std::stringstream shader;
if (!fshader.good())
return;

View File

@ -24,16 +24,11 @@
#include "GSdx.h"
#include "GSLinuxLogo.h"
GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_check, *fxaa_check;
GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
GtkWidget *resx_spin, *resy_spin;
GtkWidget* CreateRenderComboBox()
{
GtkWidget *render_combo_box;
int renderer_box_position = 0;
render_combo_box = gtk_combo_box_new_text ();
for(size_t i = 6; i < theApp.m_gs_renderers.size(); i++)
@ -100,10 +95,10 @@ GtkWidget* CreateInterlaceComboBox()
}
GtkWidget* CreateMsaaComboBox()
{
{
GtkWidget *combo_box;
combo_box = gtk_combo_box_new_text ();
// For now, let's just put in the same vaues that show up in the windows combo box.
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Custom");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "2x");
@ -120,7 +115,7 @@ GtkWidget* CreateFilterComboBox()
{
GtkWidget *combo_box;
combo_box = gtk_combo_box_new_text ();
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Off");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Normal");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "Forced");
@ -165,7 +160,13 @@ bool RunLinuxDialog()
GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame;
GtkWidget *interlace_combo_box, *threads_spin;
GtkWidget *interlace_label, *threads_label, *native_label, *fsaa_label, *rexy_label, *render_label, *filter_label;
GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
GtkWidget *shader, *shader_conf, *shader_label, *shader_conf_label;
GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_check, *fxaa_check, *shaderfx_check;
GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
GtkWidget *resx_spin, *resy_spin;
GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
GtkWidget *hack_alpha_check, *hack_date_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check, *hack_logz_check;
GtkWidget *hack_tco_label, *hack_tco_entry;
@ -174,10 +175,10 @@ bool RunLinuxDialog()
GtkWidget *notebook, *page_label[2];
int return_value;
GdkPixbuf* logo_pixmap;
GtkWidget *logo_image;
/* Create the widgets */
dialog = gtk_dialog_new_with_buttons (
"GSdx Config",
@ -193,7 +194,7 @@ bool RunLinuxDialog()
main_box = gtk_vbox_new(false, 5);
central_box = gtk_vbox_new(false, 5);
advance_box = gtk_vbox_new(false, 5);
// The Internal resolution frame and container.
res_box = gtk_vbox_new(false, 5);
res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)");
@ -203,33 +204,33 @@ bool RunLinuxDialog()
shader_box = gtk_vbox_new(false, 5);
shader_frame = gtk_frame_new("Custom Shader Settings");
gtk_container_add(GTK_CONTAINER(shader_frame), shader_box);
shader_table = gtk_table_new(5,2, false);
shader_table = gtk_table_new(8,2, false);
gtk_container_add(GTK_CONTAINER(shader_box), shader_table);
// The hardware mode frame, container, and table.
hw_box = gtk_vbox_new(false, 5);
hw_frame = gtk_frame_new ("Hardware Mode Settings");
gtk_container_add(GTK_CONTAINER(hw_frame), hw_box);
hw_table = gtk_table_new(5,2, false);
gtk_container_add(GTK_CONTAINER(hw_box), hw_table);
// The software mode frame and container. (It doesn't have enough in it for a table.)
sw_box = gtk_vbox_new(false, 5);
sw_frame = gtk_frame_new ("Software Mode Settings");
gtk_container_add(GTK_CONTAINER(sw_frame), sw_box);
// The hack frame and container.
hack_box = gtk_hbox_new(false, 5);
hack_frame = gtk_frame_new ("Hacks");
gtk_container_add(GTK_CONTAINER(hack_frame), hack_box);
hack_table = gtk_table_new(3,3, false);
gtk_container_add(GTK_CONTAINER(hack_box), hack_table);
// Grab a logo, to make things look nice.
logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL);
logo_image = gtk_image_new_from_pixbuf(logo_pixmap);
gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0);
// Create the renderer combo box and label, and stash them in a box.
render_label = gtk_label_new ("Renderer:");
render_combo_box = CreateRenderComboBox();
@ -237,7 +238,7 @@ bool RunLinuxDialog()
// Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely.
gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5);
// Create the interlace combo box and label, and stash them in a box.
interlace_label = gtk_label_new ("Interlacing (F5):");
interlace_combo_box = CreateInterlaceComboBox();
@ -251,7 +252,7 @@ bool RunLinuxDialog()
filter_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0);
// Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.)
threads_label = gtk_label_new("Extra rendering threads:");
threads_spin = gtk_spin_button_new_with_range(0,100,1);
@ -266,13 +267,13 @@ bool RunLinuxDialog()
native_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5);
fsaa_label = gtk_label_new("Or Use Scaling:");
fsaa_combo_box = CreateMsaaComboBox();
fsaa_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5);
rexy_label = gtk_label_new("Custom Resolution:");
resx_spin = gtk_spin_button_new_with_range(256,8192,1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024));
@ -283,6 +284,12 @@ bool RunLinuxDialog()
gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5);
gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5);
// shader fx entry
shader = gtk_file_chooser_button_new("Select an external shader", GTK_FILE_CHOOSER_ACTION_OPEN);
shader_conf = gtk_file_chooser_button_new("Then select a config", GTK_FILE_CHOOSER_ACTION_OPEN);
shader_label = gtk_label_new("External shader glsl");
shader_conf_label = gtk_label_new("External shader conf");
// Create our hack settings.
hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack");
hack_date_check = gtk_check_button_new_with_label("Date Hack");
@ -316,19 +323,21 @@ bool RunLinuxDialog()
// Create our checkboxes.
shadeboost_check = gtk_check_button_new_with_label("Shade boost");
paltex_check = gtk_check_button_new_with_label("Allow 8 bits textures");
fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)");
aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
fxaa_check = gtk_check_button_new_with_label("Fxaa shader");
paltex_check = gtk_check_button_new_with_label("Allow 8 bits textures");
fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)");
aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
fxaa_check = gtk_check_button_new_with_label("Fxaa shader");
shaderfx_check = gtk_check_button_new_with_label("External shader");
// Set the checkboxes.
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shaderfx_check), theApp.GetConfig("shaderfx", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_date_check), theApp.GetConfig("UserHacks_DateGL4", 0));
@ -354,7 +363,11 @@ bool RunLinuxDialog()
GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation");
gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT);
gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50));
// external shader entry
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader), theApp.GetConfig("shaderfx_glsl", "dummy.glsl").c_str());
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader_conf), theApp.GetConfig("shaderfx_conf", "dummy.ini").c_str());
// Populate all those boxes we created earlier with widgets.
gtk_container_add(GTK_CONTAINER(res_box), native_box);
gtk_container_add(GTK_CONTAINER(res_box), fsaa_box);
@ -365,14 +378,19 @@ bool RunLinuxDialog()
// Tables are strange. The numbers are for their position: left, right, top, bottom.
gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shaderfx_check, 0, 1, 5, 6);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_label, 0, 1, 6, 7);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shader, 1, 2, 6, 7);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf_label, 0, 1, 7, 8);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf, 1, 2, 7, 8);
// Tables are strange. The numbers are for their position: left, right, top, bottom.
gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2);
@ -433,7 +451,7 @@ override_GL_ARB_shading_language_420pack = -1
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, page_label[0]);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, page_label[1]);
// Put everything in the big box.
gtk_container_add(GTK_CONTAINER(main_box), renderer_box);
gtk_container_add(GTK_CONTAINER(main_box), interlace_box);
@ -443,7 +461,7 @@ override_GL_ARB_shading_language_420pack = -1
gtk_container_add(GTK_CONTAINER(central_box), shader_frame);
gtk_container_add(GTK_CONTAINER(central_box), hw_frame);
gtk_container_add(GTK_CONTAINER(central_box), sw_frame);
gtk_container_add(GTK_CONTAINER(advance_box), hack_frame);
gtk_container_add(GTK_CONTAINER(advance_box), gl_frame);
@ -455,12 +473,12 @@ override_GL_ARB_shading_language_420pack = -1
if (return_value == GTK_RESPONSE_ACCEPT)
{
int mode_height = 0, mode_width = 0;
mode_width = theApp.GetConfig("ModeWidth", 640);
mode_height = theApp.GetConfig("ModeHeight", 480);
theApp.SetConfig("ModeHeight", mode_height);
theApp.SetConfig("ModeWidth", mode_width);
// Get all the settings from the dialog box.
if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) {
// Note the value are based on m_gs_renderers vector on GSdx.cpp
@ -486,8 +504,12 @@ override_GL_ARB_shading_language_420pack = -1
theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check)));
theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check)));
theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check)));
theApp.SetConfig("shaderfx", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shaderfx_check)));
theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)));
theApp.SetConfig("shaderfx_glsl", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader)));
theApp.SetConfig("shaderfx_conf", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader_conf)));
theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation)));
theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness)));
theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast)));
@ -495,7 +517,7 @@ override_GL_ARB_shading_language_420pack = -1
theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1);
theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin)));
theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin)));
theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin)));
theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check)));
theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check)));
@ -519,7 +541,7 @@ override_GL_ARB_shading_language_420pack = -1
// NOT supported yet
theApp.SetConfig("msaa", 0);
// Let's just be windowed for the moment.
theApp.SetConfig("windowed", 1);