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: Limit GetValidSize max height and width. #12198

Merged
merged 1 commit into from
Jan 20, 2025
Merged
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
13 changes: 12 additions & 1 deletion pcsx2/GS/Renderers/HW/GSRendererHW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,17 @@ GSVector2i GSRendererHW::GetValidSize(const GSTextureCache::Source* tex)
}
}

// Make sure sizes are within max limit of 2048,
// this shouldn't happen but if it does it needs to be addressed,
// clamp the size so at least it doesn't cause a crash.
constexpr int valid_max_size = 2048;
if ((width > valid_max_size) || (height > valid_max_size))
{
Console.Warning("Warning: GetValidSize out of bounds, X:%d Y:%d", width, height);
width = std::min(width, valid_max_size);
height = std::min(height, valid_max_size);
}

return GSVector2i(width, height);
}

Expand Down Expand Up @@ -2728,7 +2739,7 @@ void GSRendererHW::Draw()
}

rt = g_texture_cache->CreateTarget(FRAME_TEX0, t_size, GetValidSize(src), (scale_draw < 0 && is_possible_mem_clear != ClearType::NormalClear) ? src->m_from_target->GetScale() : target_scale, GSTextureCache::RenderTarget, true,
fm, false, force_preload, preserve_rt_color | possible_shuffle, m_r, src);
fm, false, force_preload, preserve_rt_color || possible_shuffle, m_r, src);
if (!rt) [[unlikely]]
{
GL_INS("ERROR: Failed to create FRAME target, skipping.");
Expand Down
Loading