diff --git a/plugins/GSdx/GSDevice11.cpp b/plugins/GSdx/GSDevice11.cpp index b17b58b605..9aa3817fc1 100644 --- a/plugins/GSdx/GSDevice11.cpp +++ b/plugins/GSdx/GSDevice11.cpp @@ -171,10 +171,9 @@ bool GSDevice11::Create(const std::shared_ptr &wnd) dxd->Release(); } - bool native_resolution = theApp.GetConfigI("upscale_multiplier") == 1; bool spritehack_enabled = theApp.GetConfigB("UserHacks") && theApp.GetConfigI("UserHacks_SpriteHack"); - m_hack_topleft_offset = (!nvidia_gpu || native_resolution || spritehack_enabled) ? 0.0f : -0.01f; + m_hack_topleft_offset = (!nvidia_gpu || m_upscale_multiplier == 1 || spritehack_enabled) ? 0.0f : -0.01f; } D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS options; @@ -214,9 +213,19 @@ bool GSDevice11::Create(const std::shared_ptr &wnd) 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); + std::string convert_mstr[1]; + + convert_mstr[0] = format("%d", m_upscale_multiplier); + + D3D_SHADER_MACRO convert_macro[] = + { + {"PS_SCALE_FACTOR", convert_mstr[0].c_str()}, + {NULL, NULL}, + }; + for(size_t i = 0; i < countof(m_convert.ps); i++) { - CompileShader(shader.data(), shader.size(), "convert.fx", nullptr, format("ps_main%d", i).c_str(), nullptr, &m_convert.ps[i]); + CompileShader(shader.data(), shader.size(), "convert.fx", nullptr, format("ps_main%d", i).c_str(), convert_macro, &m_convert.ps[i]); } memset(&dsd, 0, sizeof(dsd)); diff --git a/plugins/GSdx/GSDeviceDX.cpp b/plugins/GSdx/GSDeviceDX.cpp index d01109ac70..89d003f912 100644 --- a/plugins/GSdx/GSDeviceDX.cpp +++ b/plugins/GSdx/GSDeviceDX.cpp @@ -30,6 +30,7 @@ bool GSDeviceDX::s_old_d3d_compiler_dll; GSDeviceDX::GSDeviceDX() { + m_upscale_multiplier = theApp.GetConfigI("upscale_multiplier"); m_msaa = theApp.GetConfigB("UserHacks") ? theApp.GetConfigI("UserHacks_MSAA") : 0; m_msaa_desc.Count = 1; diff --git a/plugins/GSdx/GSDeviceDX.h b/plugins/GSdx/GSDeviceDX.h index def1ae880f..0cdaa7ff9a 100644 --- a/plugins/GSdx/GSDeviceDX.h +++ b/plugins/GSdx/GSDeviceDX.h @@ -27,6 +27,9 @@ class GSDeviceDX : public GSDevice { +protected: + int m_upscale_multiplier; + public: #pragma pack(push, 1) diff --git a/plugins/GSdx/GSTextureFX11.cpp b/plugins/GSdx/GSTextureFX11.cpp index 656b157f9e..8748da7317 100644 --- a/plugins/GSdx/GSTextureFX11.cpp +++ b/plugins/GSdx/GSTextureFX11.cpp @@ -209,7 +209,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe if(i == m_ps.end()) { - std::string str[21]; + std::string str[22]; str[0] = format("%d", sel.fst); str[1] = format("%d", sel.wms); @@ -232,6 +232,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe str[18] = format("%d", sel.shuffle); str[19] = format("%d", sel.read_ba); str[20] = format("%d", sel.fmt >> 2); + str[21] = format("%d", m_upscale_multiplier); D3D_SHADER_MACRO macro[] = { @@ -256,6 +257,7 @@ void GSDevice11::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSe {"PS_SHUFFLE", str[18].c_str() }, {"PS_READ_BA", str[19].c_str() }, {"PS_PAL_FMT", str[20].c_str() }, + {"PS_SCALE_FACTOR", str[21].c_str() }, {NULL, NULL}, }; diff --git a/plugins/GSdx/res/convert.fx b/plugins/GSdx/res/convert.fx index c384f5ceaa..bd9a15c501 100644 --- a/plugins/GSdx/res/convert.fx +++ b/plugins/GSdx/res/convert.fx @@ -1,6 +1,10 @@ #ifdef SHADER_MODEL // make safe to include in resource file to enforce dependency #if SHADER_MODEL >= 0x400 +#ifndef PS_SCALE_FACTOR +#define PS_SCALE_FACTOR 1 +#endif + struct VS_INPUT { float4 p : POSITION; @@ -314,9 +318,9 @@ PS_OUTPUT ps_main17(PS_INPUT input) int txN = tb.x | (int(input.p.x) & 7); int txH = tb.x | ((int(input.p.x) + 4) & 7); - //txN *= ScalingFactor.x; - //txH *= ScalingFactor.x; - //ty *= ScalingFactor.y; + txN *= PS_SCALE_FACTOR; + txH *= PS_SCALE_FACTOR; + ty *= PS_SCALE_FACTOR; // TODO investigate texture gather float4 cN = Texture.Load(int3(txN, ty, 0));