mirror of https://github.com/PCSX2/pcsx2.git
GS: Use global upscale multiplier
This commit is contained in:
parent
7b6db5ad7a
commit
a504b429bd
|
@ -38,7 +38,7 @@ GSState::GSState()
|
|||
{
|
||||
// m_nativeres seems to be a hack. Unfortunately it impacts draw call number which make debug painful in the replayer.
|
||||
// Let's keep it disabled to ease debug.
|
||||
m_nativeres = theApp.GetConfigI("upscale_multiplier") == 1;
|
||||
m_nativeres = GSConfig.UpscaleMultiplier == 1;
|
||||
m_mipmap = theApp.GetConfigB("mipmap");
|
||||
m_NTSC_Saturation = theApp.GetConfigB("NTSC_Saturation");
|
||||
if (theApp.GetConfigB("UserHacks"))
|
||||
|
@ -69,7 +69,7 @@ GSState::GSState()
|
|||
}
|
||||
#endif
|
||||
|
||||
m_crc_hack_level = theApp.GetConfigT<CRCHackLevel>("crc_hack_level");
|
||||
m_crc_hack_level = GSConfig.CRCHack;
|
||||
if (m_crc_hack_level == CRCHackLevel::Automatic)
|
||||
m_crc_hack_level = GSUtil::GetRecommendedCRCHackLevel(GSConfig.Renderer);
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@ GSDevice11::GSDevice11()
|
|||
m_state.topology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
|
||||
m_state.bf = -1;
|
||||
|
||||
m_upscale_multiplier = std::max(0, theApp.GetConfigI("upscale_multiplier"));
|
||||
|
||||
m_features.geometry_shader = true;
|
||||
m_features.image_load_store = false;
|
||||
m_features.texture_barrier = false;
|
||||
|
@ -108,7 +106,7 @@ bool GSDevice11::Create(HostDisplay* display)
|
|||
// HACK: check nVIDIA
|
||||
// Note: It can cause issues on several games such as SOTC, Fatal Frame, plus it adds border offset.
|
||||
const bool disable_safe_features = theApp.GetConfigB("UserHacks") && theApp.GetConfigB("UserHacks_Disable_Safe_Features");
|
||||
m_hack_topleft_offset = (m_upscale_multiplier != 1 && nvidia_vendor && !disable_safe_features) ? -0.01f : 0.0f;
|
||||
m_hack_topleft_offset = (GSConfig.UpscaleMultiplier != 1 && nvidia_vendor && !disable_safe_features) ? -0.01f : 0.0f;
|
||||
|
||||
// HACK: check AMD
|
||||
// Broken point sampler should be enabled only on AMD.
|
||||
|
@ -141,7 +139,7 @@ bool GSDevice11::Create(HostDisplay* display)
|
|||
}
|
||||
|
||||
ShaderMacro sm_convert(m_shader_cache.GetFeatureLevel());
|
||||
sm_convert.AddMacro("PS_SCALE_FACTOR", std::max(1, m_upscale_multiplier));
|
||||
sm_convert.AddMacro("PS_SCALE_FACTOR", std::max(1u, GSConfig.UpscaleMultiplier));
|
||||
|
||||
D3D_SHADER_MACRO* sm_convert_ptr = sm_convert.GetPtr();
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ private:
|
|||
static constexpr u32 SHADER_VERSION = 1;
|
||||
|
||||
float m_hack_topleft_offset;
|
||||
int m_upscale_multiplier;
|
||||
int m_d3d_texsize;
|
||||
|
||||
GSTexture* CreateSurface(GSTexture::Type type, int width, int height, int levels, GSTexture::Format format) final;
|
||||
|
|
|
@ -155,7 +155,7 @@ void GSDevice11::SetupPS(PSSelector sel, const GSHWDrawConfig::PSConstantBuffer*
|
|||
{
|
||||
ShaderMacro sm(m_shader_cache.GetFeatureLevel());
|
||||
|
||||
sm.AddMacro("PS_SCALE_FACTOR", std::max(1, m_upscale_multiplier));
|
||||
sm.AddMacro("PS_SCALE_FACTOR", std::max(1u, GSConfig.UpscaleMultiplier));
|
||||
sm.AddMacro("PS_FST", sel.fst);
|
||||
sm.AddMacro("PS_WMS", sel.wms);
|
||||
sm.AddMacro("PS_WMT", sel.wmt);
|
||||
|
|
|
@ -35,7 +35,6 @@ GSRendererHW::GSRendererHW()
|
|||
, m_lod(GSVector2i(0, 0))
|
||||
{
|
||||
m_mipmap = (m_hw_mipmap >= HWMipmapLevel::Basic);
|
||||
m_upscale_multiplier = std::max(0, theApp.GetConfigI("upscale_multiplier"));
|
||||
m_conservative_framebuffer = theApp.GetConfigB("conservative_framebuffer");
|
||||
|
||||
if (theApp.GetConfigB("UserHacks"))
|
||||
|
@ -60,13 +59,13 @@ GSRendererHW::GSRendererHW()
|
|||
m_userhacks_round_sprite_offset = 0;
|
||||
}
|
||||
|
||||
if (!m_upscale_multiplier) // Custom Resolution
|
||||
if (!GSConfig.UpscaleMultiplier) // Custom Resolution
|
||||
{
|
||||
m_custom_width = m_width = theApp.GetConfigI("resx");
|
||||
m_custom_height = m_height = theApp.GetConfigI("resy");
|
||||
}
|
||||
|
||||
if (m_upscale_multiplier == 1) // hacks are only needed for upscaling issues.
|
||||
if (GSConfig.UpscaleMultiplier == 1) // hacks are only needed for upscaling issues.
|
||||
{
|
||||
m_userhacks_round_sprite_offset = 0;
|
||||
m_userhacks_align_sprite_X = false;
|
||||
|
@ -78,7 +77,7 @@ GSRendererHW::GSRendererHW()
|
|||
|
||||
void GSRendererHW::SetScaling()
|
||||
{
|
||||
if (!m_upscale_multiplier)
|
||||
if (!GSConfig.UpscaleMultiplier)
|
||||
{
|
||||
CustomResolutionScaling();
|
||||
return;
|
||||
|
@ -130,13 +129,13 @@ void GSRendererHW::SetScaling()
|
|||
fb_height = fb_width < 1024 ? std::max(512, crtc_size.y) : 1024;
|
||||
}
|
||||
|
||||
const int upscaled_fb_w = fb_width * m_upscale_multiplier;
|
||||
const int upscaled_fb_h = fb_height * m_upscale_multiplier;
|
||||
const int upscaled_fb_w = fb_width * GSConfig.UpscaleMultiplier;
|
||||
const int upscaled_fb_h = fb_height * GSConfig.UpscaleMultiplier;
|
||||
const bool good_rt_size = m_width >= upscaled_fb_w && m_height >= upscaled_fb_h;
|
||||
|
||||
// No need to resize for native/custom resolutions as default size will be enough for native and we manually get RT Buffer size for custom.
|
||||
// don't resize until the display rectangle and register states are stabilized.
|
||||
if (m_upscale_multiplier <= 1 || good_rt_size)
|
||||
if (GSConfig.UpscaleMultiplier <= 1 || good_rt_size)
|
||||
return;
|
||||
|
||||
m_tc->RemovePartial();
|
||||
|
@ -269,12 +268,12 @@ bool GSRendererHW::CanUpscale()
|
|||
}
|
||||
|
||||
// upscale ratio depends on the display size, with no output it may not be set correctly (ps2 logo to game transition)
|
||||
return m_upscale_multiplier != 1 && m_regs->PMODE.EN != 0;
|
||||
return GSConfig.UpscaleMultiplier != 1 && m_regs->PMODE.EN != 0;
|
||||
}
|
||||
|
||||
int GSRendererHW::GetUpscaleMultiplier()
|
||||
{
|
||||
return m_upscale_multiplier;
|
||||
return GSConfig.UpscaleMultiplier;
|
||||
}
|
||||
|
||||
GSVector2i GSRendererHW::GetCustomResolution()
|
||||
|
|
|
@ -26,7 +26,6 @@ private:
|
|||
int m_height;
|
||||
int m_custom_width;
|
||||
int m_custom_height;
|
||||
int m_upscale_multiplier;
|
||||
int m_userhacks_ts_half_bottom;
|
||||
|
||||
bool m_conservative_framebuffer;
|
||||
|
|
|
@ -63,8 +63,6 @@ GSDeviceOGL::GSDeviceOGL()
|
|||
memset(&m_om_dss, 0, sizeof(m_om_dss));
|
||||
memset(&m_profiler, 0, sizeof(m_profiler));
|
||||
|
||||
m_upscale_multiplier = std::max(1, theApp.GetConfigI("upscale_multiplier"));
|
||||
|
||||
// Reset the debug file
|
||||
#ifdef ENABLE_OGL_DEBUG
|
||||
m_debug_gl_file = fopen("GS_opengl_debug.txt", "w");
|
||||
|
@ -239,8 +237,8 @@ bool GSDeviceOGL::Create(HostDisplay* display)
|
|||
GLint line_range[2] = {};
|
||||
glGetIntegerv(GL_ALIASED_POINT_SIZE_RANGE, point_range);
|
||||
glGetIntegerv(GL_ALIASED_LINE_WIDTH_RANGE, line_range);
|
||||
m_features.point_expand = (point_range[0] <= m_upscale_multiplier && point_range[1] >= m_upscale_multiplier);
|
||||
m_features.line_expand = (line_range[0] <= m_upscale_multiplier && line_range[1] >= m_upscale_multiplier);
|
||||
m_features.point_expand = (point_range[0] <= static_cast<GLint>(GSConfig.UpscaleMultiplier) && point_range[1] >= static_cast<GLint>(GSConfig.UpscaleMultiplier));
|
||||
m_features.line_expand = (line_range[0] <= static_cast<GLint>(GSConfig.UpscaleMultiplier) && line_range[1] >= static_cast<GLint>(GSConfig.UpscaleMultiplier));
|
||||
Console.WriteLn("Using %s for point expansion and %s for line expansion.",
|
||||
m_features.point_expand ? "hardware" : "geometry shaders", m_features.line_expand ? "hardware" : "geometry shaders");
|
||||
|
||||
|
@ -377,7 +375,7 @@ bool GSDeviceOGL::Create(HostDisplay* display)
|
|||
{
|
||||
const char* name = shaderName(static_cast<ShaderConvert>(i));
|
||||
const std::string macro_sel = (static_cast<ShaderConvert>(i) == ShaderConvert::RGBA_TO_8I) ?
|
||||
format("#define PS_SCALE_FACTOR %d\n", m_upscale_multiplier) :
|
||||
format("#define PS_SCALE_FACTOR %d\n", GSConfig.UpscaleMultiplier) :
|
||||
std::string();
|
||||
const std::string ps(GetShaderSource(name, GL_FRAGMENT_SHADER, m_shader_common_header, *shader, macro_sel));
|
||||
if (!m_shader_cache.GetProgram(&m_convert.ps[i], m_convert.vs, {}, ps))
|
||||
|
@ -1045,7 +1043,7 @@ std::string GSDeviceOGL::GetVSSource(VSSelector sel)
|
|||
+ format("#define VS_IIP %d\n", sel.iip)
|
||||
+ format("#define VS_POINT_SIZE %d\n", sel.point_size);
|
||||
if (sel.point_size)
|
||||
macro += format("#define VS_POINT_SIZE_VALUE %d\n", m_upscale_multiplier);
|
||||
macro += format("#define VS_POINT_SIZE_VALUE %d\n", GSConfig.UpscaleMultiplier);
|
||||
|
||||
std::string src = GenGlslHeader("vs_main", GL_VERTEX_SHADER, macro);
|
||||
src += m_shader_common_header;
|
||||
|
@ -1116,7 +1114,7 @@ std::string GSDeviceOGL::GetPSSource(PSSelector sel)
|
|||
+ format("#define PS_ALPHA_CLAMP %d\n", sel.alpha_clamp)
|
||||
+ format("#define PS_PABE %d\n", sel.pabe)
|
||||
+ format("#define PS_SCANMSK %d\n", sel.scanmsk)
|
||||
+ format("#define PS_SCALE_FACTOR %d\n", m_upscale_multiplier)
|
||||
+ format("#define PS_SCALE_FACTOR %d\n", GSConfig.UpscaleMultiplier)
|
||||
;
|
||||
|
||||
std::string src = GenGlslHeader("ps_main", GL_FRAGMENT_SHADER, macro);
|
||||
|
@ -1930,7 +1928,7 @@ void GSDeviceOGL::RenderHW(GSHWDrawConfig& config)
|
|||
glDisable(GL_PROGRAM_POINT_SIZE);
|
||||
GLState::point_size = point_size_enabled;
|
||||
}
|
||||
const float line_width = config.line_expand ? static_cast<float>(m_upscale_multiplier) : 1.0f;
|
||||
const float line_width = config.line_expand ? static_cast<float>(GSConfig.UpscaleMultiplier) : 1.0f;
|
||||
if (GLState::line_width != line_width)
|
||||
{
|
||||
GLState::line_width = line_width;
|
||||
|
|
|
@ -214,8 +214,6 @@ private:
|
|||
// Increment this constant whenever shaders change, to invalidate user's program binary cache.
|
||||
static constexpr u32 SHADER_VERSION = 1;
|
||||
|
||||
int m_upscale_multiplier;
|
||||
|
||||
static FILE* m_debug_gl_file;
|
||||
|
||||
bool m_disable_hw_gl_draw;
|
||||
|
|
|
@ -77,9 +77,6 @@ GSDeviceVK::GSDeviceVK()
|
|||
s_debug_scope_depth = 0;
|
||||
#endif
|
||||
|
||||
m_mipmap = theApp.GetConfigI("mipmap");
|
||||
m_upscale_multiplier = static_cast<u32>(std::max(1, theApp.GetConfigI("upscale_multiplier")));
|
||||
|
||||
std::memset(&m_pipeline_selector, 0, sizeof(m_pipeline_selector));
|
||||
}
|
||||
|
||||
|
@ -254,7 +251,7 @@ bool GSDeviceVK::CheckFeatures()
|
|||
}
|
||||
|
||||
// whether we can do point/line expand depends on the range of the device
|
||||
const float f_upscale = static_cast<float>(m_upscale_multiplier);
|
||||
const float f_upscale = static_cast<float>(GSConfig.UpscaleMultiplier);
|
||||
m_features.point_expand =
|
||||
(features.largePoints && limits.pointSizeRange[0] <= f_upscale && limits.pointSizeRange[1] >= f_upscale);
|
||||
m_features.line_expand =
|
||||
|
@ -1057,7 +1054,7 @@ VkShaderModule GSDeviceVK::GetUtilityVertexShader(const std::string& source, con
|
|||
std::stringstream ss;
|
||||
AddShaderHeader(ss);
|
||||
AddShaderStageMacro(ss, true, false, false);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", m_upscale_multiplier);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", GSConfig.UpscaleMultiplier);
|
||||
if (replace_main)
|
||||
ss << "#define " << replace_main << " main\n";
|
||||
ss << source;
|
||||
|
@ -1070,7 +1067,7 @@ VkShaderModule GSDeviceVK::GetUtilityFragmentShader(const std::string& source, c
|
|||
std::stringstream ss;
|
||||
AddShaderHeader(ss);
|
||||
AddShaderStageMacro(ss, false, false, true);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", m_upscale_multiplier);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", GSConfig.UpscaleMultiplier);
|
||||
if (replace_main)
|
||||
ss << "#define " << replace_main << " main\n";
|
||||
ss << source;
|
||||
|
@ -1725,7 +1722,7 @@ VkShaderModule GSDeviceVK::GetTFXVertexShader(GSHWDrawConfig::VSSelector sel)
|
|||
AddMacro(ss, "VS_IIP", sel.iip);
|
||||
AddMacro(ss, "VS_POINT_SIZE", sel.point_size);
|
||||
if (sel.point_size)
|
||||
AddMacro(ss, "VS_POINT_SIZE_VALUE", m_upscale_multiplier);
|
||||
AddMacro(ss, "VS_POINT_SIZE_VALUE", GSConfig.UpscaleMultiplier);
|
||||
ss << m_tfx_source;
|
||||
|
||||
VkShaderModule mod = g_vulkan_shader_cache->GetVertexShader(ss.str());
|
||||
|
@ -1808,7 +1805,7 @@ VkShaderModule GSDeviceVK::GetTFXFragmentShader(GSHWDrawConfig::PSSelector sel)
|
|||
AddMacro(ss, "PS_ZCLAMP", sel.zclamp);
|
||||
AddMacro(ss, "PS_PABE", sel.pabe);
|
||||
AddMacro(ss, "PS_SCANMSK", sel.scanmsk);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", m_upscale_multiplier);
|
||||
AddMacro(ss, "PS_SCALE_FACTOR", GSConfig.UpscaleMultiplier);
|
||||
AddMacro(ss, "PS_TEX_IS_FB", sel.tex_is_fb);
|
||||
ss << m_tfx_source;
|
||||
|
||||
|
@ -1854,7 +1851,7 @@ VkPipeline GSDeviceVK::CreateTFXPipeline(const PipelineSelector& p)
|
|||
gpb.SetPrimitiveTopology(topology_lookup[p.topology]);
|
||||
gpb.SetRasterizationState(VK_POLYGON_MODE_FILL, VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE);
|
||||
if (p.line_width)
|
||||
gpb.SetLineWidth(static_cast<float>(m_upscale_multiplier));
|
||||
gpb.SetLineWidth(static_cast<float>(GSConfig.UpscaleMultiplier));
|
||||
gpb.SetDynamicViewportAndScissorState();
|
||||
gpb.AddDynamicState(VK_DYNAMIC_STATE_BLEND_CONSTANTS);
|
||||
|
||||
|
@ -2702,7 +2699,7 @@ void GSDeviceVK::RenderHW(GSHWDrawConfig& config)
|
|||
}
|
||||
|
||||
// Align the render area to 128x128, hopefully avoiding render pass restarts for small render area changes (e.g. Ratchet and Clank).
|
||||
const int render_area_alignment = 128 * m_upscale_multiplier;
|
||||
const int render_area_alignment = 128 * GSConfig.UpscaleMultiplier;
|
||||
const GSVector2i rtsize(config.rt ? config.rt->GetSize() : config.ds->GetSize());
|
||||
const GSVector4i render_area(
|
||||
config.ps.hdr ? config.drawarea :
|
||||
|
|
|
@ -101,9 +101,6 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
u32 m_upscale_multiplier = 1;
|
||||
int m_mipmap = 0;
|
||||
|
||||
VkDescriptorSetLayout m_utility_ds_layout = VK_NULL_HANDLE;
|
||||
VkPipelineLayout m_utility_pipeline_layout = VK_NULL_HANDLE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue