GSdx-d3d: Add macro to support ScalingFactor in shaders.

This commit is contained in:
KrossX 2018-10-12 08:06:17 +02:00 committed by lightningterror
parent 5ef53b4587
commit df307bed02
5 changed files with 26 additions and 7 deletions

View File

@ -171,10 +171,9 @@ bool GSDevice11::Create(const std::shared_ptr<GSWnd> &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<GSWnd> &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));

View File

@ -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;

View File

@ -27,6 +27,9 @@
class GSDeviceDX : public GSDevice
{
protected:
int m_upscale_multiplier;
public:
#pragma pack(push, 1)

View File

@ -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},
};

View File

@ -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));