gsdx:dx: Allow selection of external shader/shader config

shaders/GSdx.fx is now the default location and is no longer hardcoded.
The external shader and external shader config can now be selected. (The
OpenGL renderer already has this feature.)

Note: It is still possible to not use a config file, just use an invalid
value for shaderfx_conf.
This commit is contained in:
Jonathan Li 2015-08-29 17:50:10 +01:00
parent df98c766e5
commit c0137227e6
2 changed files with 23 additions and 7 deletions

View File

@ -754,16 +754,24 @@ void GSDevice11::InitExternalFX()
if (!ExShader_Compiled)
{
try {
std::ifstream fshader("shaders/GSdx.fx");
std::string config_name(theApp.GetConfig("shaderfx_conf", "shaders/GSdx_FX_Settings.ini"));
std::ifstream fconfig(config_name);
std::stringstream shader;
if (fconfig.good())
shader << fconfig.rdbuf() << "\n";
else
fprintf(stderr, "GSdx: External shader config '%s' not loaded.\n", config_name.c_str());
std::string shader_name(theApp.GetConfig("shaderfx_glsl", "shaders/GSdx.fx"));
std::ifstream fshader(shader_name);
if (fshader.good())
{
std::stringstream shader;
shader << fshader.rdbuf();
CompileShader(shader.str().c_str(), shader.str().length(), "shaders/GSdx.fx", "ps_main", NULL, &m_shaderfx.ps);
CompileShader(shader.str().c_str(), shader.str().length(), shader_name.c_str(), "ps_main", NULL, &m_shaderfx.ps);
}
else
{
fprintf(stderr, "GSdx: Failed to load 'shaders/GSdx.fx'. External Shader will be disabled!\n");
fprintf(stderr, "GSdx: External shader '%s' not loaded and will be disabled!\n", shader_name.c_str());
}
}
catch (GSDXRecoverableError) {

View File

@ -939,16 +939,24 @@ void GSDevice9::InitExternalFX()
if (!ExShader_Compiled)
{
try {
std::ifstream fshader("shaders/GSdx.fx");
std::string config_name(theApp.GetConfig("shaderfx_conf", "shaders/GSdx_FX_Settings.ini"));
std::ifstream fconfig(config_name);
std::stringstream shader;
if (fconfig.good())
shader << fconfig.rdbuf() << "\n";
else
fprintf(stderr, "GSdx: External shader config '%s' not loaded.\n", config_name.c_str());
std::string shader_name(theApp.GetConfig("shaderfx_glsl", "shaders/GSdx.fx"));
std::ifstream fshader(shader_name);
if (fshader.good())
{
std::stringstream shader;
shader << fshader.rdbuf();
CompileShader(shader.str().c_str(), shader.str().length(), "ps_main", NULL, &m_shaderfx.ps);
}
else
{
fprintf(stderr, "GSdx: Failed to load 'shaders/GSdx.fx'. External Shader will be disabled!\n");
fprintf(stderr, "GSdx: External shader '%s' not loaded and will be disabled!\n", shader_name.c_str());
}
}
catch (GSDXRecoverableError) {