Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS/HW: Added new Half-Pixel Offset option Bilinear Scaled (Testing Only) #9276

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pcsx2-qt/Settings/GraphicsSettingsWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,11 @@
<string>Special (Texture - Aggressive)</string>
</property>
</item>
<item>
<property name="text">
<string>Bilinear Scaled (Vertex)</string>
</property>
</item>
</widget>
</item>
<item row="1" column="0">
Expand Down
22 changes: 21 additions & 1 deletion pcsx2/GS/Renderers/Common/GSRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,27 @@ float GSRenderer::GetModXYOffset()
{
float mod_xy = 0.0f;

if (GSConfig.UserHacks_HalfPixelOffset == 1)
// Scaled Bilinear HPO depending on the gradient.
if (GSConfig.UserHacks_HalfPixelOffset == 4)
{
const GSVector2 pos_range(m_vt.m_max.p.x - m_vt.m_min.p.x, m_vt.m_max.p.y - m_vt.m_min.p.y);
const GSVector2 uv_range(m_vt.m_max.t.x - m_vt.m_min.t.x, m_vt.m_max.t.y - m_vt.m_min.t.y);
const GSVector2 grad(uv_range / pos_range);
const float avg_grad = (grad.x + grad.y) / 2;

if (avg_grad >= 0.5f && m_draw_env->CTXT[m_draw_env->PRIM.CTXT].TEX1.MMIN == 1)
{
mod_xy = GetUpscaleMultiplier();
switch (static_cast<int>(std::round(mod_xy)))
{
case 2: case 4: case 6: case 8: mod_xy += (mod_xy / 2.0f) * avg_grad; break;
case 3: case 7: mod_xy += (mod_xy / 2.0f) * avg_grad; break;
case 5: mod_xy += (mod_xy / 2.0f) * avg_grad; break;
default: mod_xy = 0.0f; break;
}
}
}
else if (GSConfig.UserHacks_HalfPixelOffset == 1)
{
mod_xy = GetUpscaleMultiplier();
switch (static_cast<int>(std::round(mod_xy)))
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ void GSRendererHW::ConvertSpriteTextureShuffle(bool& write_ba, bool& read_ba)

GSVector4 GSRendererHW::RealignTargetTextureCoordinate(const GSTextureCache::Source* tex)
{
if (GSConfig.UserHacks_HalfPixelOffset <= 1 || GetUpscaleMultiplier() == 1.0f)
if (GSConfig.UserHacks_HalfPixelOffset <= 1 || GSConfig.UserHacks_HalfPixelOffset >= 4 || GetUpscaleMultiplier() == 1.0f)
return GSVector4(0.0f);

const GSVertex* v = &m_vertex.buff[0];
Expand Down
2 changes: 1 addition & 1 deletion pcsx2/ImGui/FullscreenUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3225,7 +3225,7 @@ void FullscreenUI::DrawGraphicsSettingsPage()
static constexpr const char* s_cpu_clut_render_options[] = {"0 (Disabled)", "1 (Normal)", "2 (Aggressive)"};
static constexpr const char* s_texture_inside_rt_options[] = {"Disabled", "Inside Target", "Merge Targets"};
static constexpr const char* s_half_pixel_offset_options[] = {
"Off (Default)", "Normal (Vertex)", "Special (Texture)", "Special (Texture - Aggressive)"};
"Off (Default)", "Normal (Vertex)", "Special (Texture)", "Special (Texture - Aggressive)", "Bilinear Scaled (Vertex)"};
static constexpr const char* s_round_sprite_options[] = {"Off (Default)", "Half", "Full"};
static constexpr const char* s_auto_flush_options[] = {
"Disabled (Default)", "Enabled (Sprites Only)", "Enabled (All Primitives)"};
Expand Down