Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp
- index 9b1f1bfe6..ff978fd1b 100644
- --- a/plugins/GSdx/GSDevice11.cpp
- +++ b/plugins/GSdx/GSDevice11.cpp
- @@ -186,7 +186,8 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd> &wnd)
- };
- std::vector<char> shader;
- - theApp.LoadResource(IDR_CONVERT_FX, shader);
- +
- + if(!theApp.LoadFile("convert.fx", shader)) theApp.LoadResource(IDR_CONVERT_FX, shader);
- CompileShader(shader.data(), shader.size(), "convert.fx", nullptr, "vs_main", nullptr, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il);
- for(size_t i = 0; i < countof(m_convert.ps); i++)
- @@ -217,7 +218,7 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd> &wnd)
- hr = m_dev->CreateBuffer(&bd, NULL, &m_merge.cb);
- - theApp.LoadResource(IDR_MERGE_FX, shader);
- + if(!theApp.LoadFile("merge.fx", shader)) theApp.LoadResource(IDR_MERGE_FX, shader);
- for(size_t i = 0; i < countof(m_merge.ps); i++)
- {
- CompileShader(shader.data(), shader.size(), "merge.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_merge.ps[i]);
- @@ -246,7 +247,7 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd> &wnd)
- hr = m_dev->CreateBuffer(&bd, NULL, &m_interlace.cb);
- - theApp.LoadResource(IDR_INTERLACE_FX, shader);
- + if(!theApp.LoadFile("interlace.fx", shader)) theApp.LoadResource(IDR_INTERLACE_FX, shader);
- for(size_t i = 0; i < countof(m_interlace.ps); i++)
- {
- CompileShader(shader.data(), shader.size(), "interlace.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_interlace.ps[i]);
- @@ -280,7 +281,7 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd> &wnd)
- hr = m_dev->CreateBuffer(&bd, NULL, &m_shadeboost.cb);
- - theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
- + if(!theApp.LoadFile("shadeboost.fx", shader)) theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
- CompileShader(shader.data(), shader.size(), "shadeboost.fx", nullptr, "ps_main", macro, &m_shadeboost.ps);
- // External fx shader
- @@ -834,7 +835,7 @@ void GSDevice11::InitFXAA()
- {
- try {
- std::vector<char> shader;
- - theApp.LoadResource(IDR_FXAA_FX, shader);
- + if(!theApp.LoadFile("fxaa.fx", shader)) theApp.LoadResource(IDR_FXAA_FX, shader);
- CompileShader(shader.data(), shader.size(), "fxaa.fx", nullptr, "ps_main", nullptr, &m_fxaa.ps);
- }
- catch (GSDXRecoverableError) {
- diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp
- index cbc806910..304e011ae 100644
- --- a/plugins/GSdx/GSDevice9.cpp
- +++ b/plugins/GSdx/GSDevice9.cpp
- @@ -291,7 +291,7 @@ bool GSDevice9::Create(const std::shared_ptr<GSWnd> &wnd)
- };
- std::vector<char> shader;
- - theApp.LoadResource(IDR_CONVERT_FX, shader);
- + if(!theApp.LoadFile("convert.fx", shader)) theApp.LoadResource(IDR_CONVERT_FX, shader);
- CompileShader(shader.data(), shader.size(), "convert.fx", "vs_main", nullptr, &m_convert.vs, il_convert, countof(il_convert), &m_convert.il);
- for(size_t i = 0; i < countof(m_convert.ps); i++)
- @@ -325,7 +325,7 @@ bool GSDevice9::Create(const std::shared_ptr<GSWnd> &wnd)
- // merge
- - theApp.LoadResource(IDR_MERGE_FX, shader);
- + if(!theApp.LoadFile("merge.fx", shader)) theApp.LoadResource(IDR_MERGE_FX, shader);
- for(size_t i = 0; i < countof(m_merge.ps); i++)
- {
- CompileShader(shader.data(), shader.size(), "merge.fx", format("ps_main%d", i), nullptr, &m_merge.ps[i]);
- @@ -342,7 +342,7 @@ bool GSDevice9::Create(const std::shared_ptr<GSWnd> &wnd)
- // interlace
- - theApp.LoadResource(IDR_INTERLACE_FX, shader);
- + if(!theApp.LoadFile("interlace.fx", shader)) theApp.LoadResource(IDR_INTERLACE_FX, shader);
- for(size_t i = 0; i < countof(m_interlace.ps); i++)
- {
- CompileShader(shader.data(), shader.size(), "interlace.fx", format("ps_main%d", i), nullptr, &m_interlace.ps[i]);
- @@ -368,7 +368,7 @@ bool GSDevice9::Create(const std::shared_ptr<GSWnd> &wnd)
- {NULL, NULL},
- };
- - theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
- + if(!theApp.LoadFile("shadeboost.fx", shader)) theApp.LoadResource(IDR_SHADEBOOST_FX, shader);
- CompileShader(shader.data(), shader.size(), "shadeboost.fx", "ps_main", macro, &m_shadeboost.ps);
- // create shader layout
- @@ -997,7 +997,7 @@ void GSDevice9::InitFXAA()
- {
- try {
- std::vector<char> shader;
- - theApp.LoadResource(IDR_FXAA_FX, shader);
- + if(!theApp.LoadFile("fxaa.fx", shader)) theApp.LoadResource(IDR_FXAA_FX, shader);
- CompileShader(shader.data(), shader.size(), "fxaa.fx", "ps_main", nullptr, &m_fxaa.ps);
- }
- catch (GSDXRecoverableError) {
- diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp
- index edef23e95..4e44614d5 100644
- --- a/plugins/GSdx/GSDeviceOGL.cpp
- +++ b/plugins/GSdx/GSDeviceOGL.cpp
- @@ -384,7 +384,7 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd> &wnd)
- m_misc_cb_cache.ScalingFactor = GSVector4i(theApp.GetConfigI("upscale_multiplier"));
- m_convert.cb->cache_upload(&m_misc_cb_cache);
- - theApp.LoadResource(IDR_CONVERT_GLSL, shader);
- + if(!theApp.LoadFile("convert.glsl", m_shader_tfx_fs)) theApp.LoadResource(IDR_CONVERT_GLSL, shader);
- vs = m_shader->Compile("convert.glsl", "vs_main", GL_VERTEX_SHADER, shader.data());
- @@ -416,7 +416,7 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd> &wnd)
- m_merge_obj.cb = new GSUniformBufferOGL("Merge UBO", g_merge_cb_index, sizeof(MergeConstantBuffer));
- - theApp.LoadResource(IDR_MERGE_GLSL, shader);
- + if(!theApp.LoadFile("merge.glsl", m_shader_tfx_fs)) theApp.LoadResource(IDR_MERGE_GLSL, shader);
- for(size_t i = 0; i < countof(m_merge_obj.ps); i++) {
- ps = m_shader->Compile("merge.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, shader.data());
- @@ -433,7 +433,7 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd> &wnd)
- m_interlace.cb = new GSUniformBufferOGL("Interlace UBO", g_interlace_cb_index, sizeof(InterlaceConstantBuffer));
- - theApp.LoadResource(IDR_INTERLACE_GLSL, shader);
- + if(!theApp.LoadFile("interlace.glsl", m_shader_tfx_fs)) theApp.LoadResource(IDR_INTERLACE_GLSL, shader);
- for(size_t i = 0; i < countof(m_interlace.ps); i++) {
- ps = m_shader->Compile("interlace.glsl", format("ps_main%d", i), GL_FRAGMENT_SHADER, shader.data());
- @@ -455,7 +455,7 @@ bool GSDeviceOGL::Create(const std::shared_ptr<GSWnd> &wnd)
- + format("#define SB_BRIGHTNESS %d.0\n", ShadeBoost_Brightness)
- + format("#define SB_CONTRAST %d.0\n", ShadeBoost_Contrast);
- - theApp.LoadResource(IDR_SHADEBOOST_GLSL, shader);
- + if(!theApp.LoadFile("shadeboost.glsl", m_shader_tfx_fs)) theApp.LoadResource(IDR_SHADEBOOST_GLSL, shader);
- ps = m_shader->Compile("shadeboost.glsl", "ps_main", GL_FRAGMENT_SHADER, shader.data(), shade_macro);
- m_shadeboost.ps = m_shader->LinkPipeline("ShadeBoost pipe", vs, 0, ps);
- @@ -577,8 +577,8 @@ void GSDeviceOGL::CreateTextureFX()
- m_vs_cb = new GSUniformBufferOGL("HW VS UBO", g_vs_cb_index, sizeof(VSConstantBuffer));
- m_ps_cb = new GSUniformBufferOGL("HW PS UBO", g_ps_cb_index, sizeof(PSConstantBuffer));
- - theApp.LoadResource(IDR_TFX_VGS_GLSL, m_shader_tfx_vgs);
- - theApp.LoadResource(IDR_TFX_FS_GLSL, m_shader_tfx_fs);
- + if(!theApp.LoadFile("tfx_vgs.glsl", m_shader_tfx_vgs)) theApp.LoadResource(IDR_TFX_VGS_GLSL, m_shader_tfx_vgs);
- + if(!theApp.LoadFile("tfx_fs.glsl", m_shader_tfx_fs)) theApp.LoadResource(IDR_TFX_FS_GLSL, m_shader_tfx_fs);
- // warning 1 sampler by image unit. So you cannot reuse m_ps_ss...
- m_palette_ss = CreateSampler(PSSamplerSelector(0));
- @@ -1497,7 +1497,7 @@ void GSDeviceOGL::DoFXAA(GSTexture* sTex, GSTexture* dTex)
- fxaa_macro += "#extension GL_ARB_gpu_shader5 : enable\n";
- std::vector<char> shader;
- - theApp.LoadResource(IDR_FXAA_FX, shader);
- + if(!theApp.LoadFile("fxaa.fx", shader)) theApp.LoadResource(IDR_FXAA_FX, shader);
- GLuint ps = m_shader->Compile("fxaa.fx", "ps_main", GL_FRAGMENT_SHADER, shader.data(), fxaa_macro);
- m_fxaa.ps = m_shader->LinkPipeline("FXAA pipe", m_convert.vs, 0, ps);
- diff --git a/plugins/GSdx/GSRendererCL.cpp b/plugins/GSdx/GSRendererCL.cpp
- index 839f3932a..b6f1d98ac 100644
- --- a/plugins/GSdx/GSRendererCL.cpp
- +++ b/plugins/GSdx/GSRendererCL.cpp
- @@ -1931,7 +1931,7 @@ GSRendererCL::CL::CL()
- std::vector<char> buff;
- - if(theApp.LoadResource(IDR_TFX_CL, buff))
- + if(theApp.LoadFile("tfx.cl", m_common_header) || theApp.LoadResource(IDR_TFX_CL, buff))
- {
- kernel_str = std::string(buff.data(), buff.size());
- }
- diff --git a/plugins/GSdx/GSShaderOGL.cpp b/plugins/GSdx/GSShaderOGL.cpp
- index 5d8b53a1c..a89951193 100644
- --- a/plugins/GSdx/GSShaderOGL.cpp
- +++ b/plugins/GSdx/GSShaderOGL.cpp
- @@ -33,7 +33,7 @@ GSShaderOGL::GSShaderOGL(bool debug) :
- m_pipeline(0),
- m_debug_shader(debug)
- {
- - theApp.LoadResource(IDR_COMMON_GLSL, m_common_header);
- + if(!theApp.LoadFile("common_header.glsl", m_common_header)) theApp.LoadResource(IDR_COMMON_GLSL, m_common_header);
- // Create a default pipeline
- m_pipeline = LinkPipeline("HW pipe", 0, 0, 0);
- diff --git a/plugins/GSdx/GSTextureFX11.cpp b/plugins/GSdx/GSTextureFX11.cpp
- index 6f549621b..0d5097a90 100644
- --- a/plugins/GSdx/GSTextureFX11.cpp
- +++ b/plugins/GSdx/GSTextureFX11.cpp
- @@ -133,7 +133,7 @@ void GSDevice11::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
- GSVertexShader11 vs;
- std::vector<char> shader;
- - theApp.LoadResource(IDR_TFX_FX, shader);
- + if(!theApp.LoadFile("tfx.fx", shader)) theApp.LoadResource(IDR_TFX_FX, shader);
- CompileShader(shader.data(), shader.size(), "tfx.fx", nullptr, "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
- m_vs[sel] = vs;
- @@ -185,7 +185,7 @@ void GSDevice11::SetupGS(GSSelector sel, const GSConstantBuffer* cb)
- };
- std::vector<char> shader;
- - theApp.LoadResource(IDR_TFX_FX, shader);
- + if(!theApp.LoadFile("tfx.fx", shader)) theApp.LoadResource(IDR_TFX_FX, shader);
- CompileShader(shader.data(), shader.size(), "tfx.fx", nullptr, "gs_main", macro, &gs);
- m_gs[sel] = gs;
- @@ -262,7 +262,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe
- CComPtr<ID3D11PixelShader> ps;
- std::vector<char> shader;
- - theApp.LoadResource(IDR_TFX_FX, shader);
- + if(!theApp.LoadFile("tfx.fx", shader)) theApp.LoadResource(IDR_TFX_FX, shader);
- CompileShader(shader.data(), shader.size(), "tfx.fx", nullptr, "ps_main", macro, &ps);
- m_ps[sel] = ps;
- diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp
- index 586286bf2..bf6d0c342 100644
- --- a/plugins/GSdx/GSTextureFX9.cpp
- +++ b/plugins/GSdx/GSTextureFX9.cpp
- @@ -97,7 +97,7 @@ void GSDevice9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
- GSVertexShader9 vs;
- std::vector<char> shader;
- - theApp.LoadResource(IDR_TFX_FX, shader);
- + if(!theApp.LoadFile("tfx.fx", shader)) theApp.LoadResource(IDR_TFX_FX, shader);
- CompileShader(shader.data(), shader.size(), "tfx.fx", "vs_main", macro, &vs.vs, layout, countof(layout), &vs.il);
- m_vs[sel] = vs;
- @@ -184,7 +184,7 @@ void GSDevice9::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSel
- CComPtr<IDirect3DPixelShader9> ps;
- std::vector<char> shader;
- - theApp.LoadResource(IDR_TFX_FX, shader);
- + if(!theApp.LoadFile("tfx.fx", shader)) theApp.LoadResource(IDR_TFX_FX, shader);
- CompileShader(shader.data(), shader.size(), "tfx.fx", "ps_main", macro, &ps);
- m_ps[sel] = ps;
- diff --git a/plugins/GSdx/GSdx.cpp b/plugins/GSdx/GSdx.cpp
- index 9ef606a84..3b41436a6 100644
- --- a/plugins/GSdx/GSdx.cpp
- +++ b/plugins/GSdx/GSdx.cpp
- @@ -174,6 +174,24 @@ int GSdxApp::GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName,
- }
- #endif
- +bool GSdxApp::LoadFile(const char* fn, std::vector<char>& buff)
- +{
- + std::ifstream file(fn, std::ios::binary | std::ios::ate);
- +
- + if(file.is_open()) {
- + size_t fsize = (size_t)file.tellg();
- +
- + if(fsize) {
- + buff.resize(fsize);
- + file.seekg(0, std::ios::beg);
- + file.read(&buff[0], fsize);
- + return true;
- + }
- + }
- +
- + return false;
- +}
- +
- GSdxApp theApp;
- GSdxApp::GSdxApp()
- diff --git a/plugins/GSdx/GSdx.h b/plugins/GSdx/GSdx.h
- index 4cc159592..cce24c324 100644
- --- a/plugins/GSdx/GSdx.h
- +++ b/plugins/GSdx/GSdx.h
- @@ -54,6 +54,7 @@ public:
- #endif
- bool LoadResource(int id, std::vector<char>& buff, const char* type = nullptr);
- + bool LoadFile( const char* fn, std::vector<char>& buff);
- void SetConfig(const char* entry, const char* value);
- void SetConfig(const char* entry, int value);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement