Skip to content

Commit b74d056

Browse files
GS/HW: Limit GetValidSize height and width.
Max texture size limit is 2048. This should never happen but if it does clamp it
1 parent 23fd57f commit b74d056

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

pcsx2/GS/Renderers/HW/GSRendererHW.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,17 @@ GSVector2i GSRendererHW::GetValidSize(const GSTextureCache::Source* tex)
949949
}
950950
}
951951

952+
// Make sure sizes are within max limit of 2048,
953+
// this shouldn't happen but if it does it needs to be addressed,
954+
// clamp the size so at least it doesn't cause a crash.
955+
constexpr int valid_max_size = 2048;
956+
if ((width > valid_max_size) || (height > valid_max_size))
957+
{
958+
Console.Warning("Warning: GetValidSize out of bounds, X:%d Y:%d", width, height);
959+
width = std::min(width, valid_max_size);
960+
height = std::min(height, valid_max_size);
961+
}
962+
952963
return GSVector2i(width, height);
953964
}
954965

@@ -2728,7 +2739,7 @@ void GSRendererHW::Draw()
27282739
}
27292740

27302741
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,
2731-
fm, false, force_preload, preserve_rt_color | possible_shuffle, m_r, src);
2742+
fm, false, force_preload, preserve_rt_color || possible_shuffle, m_r, src);
27322743
if (!rt) [[unlikely]]
27332744
{
27342745
GL_INS("ERROR: Failed to create FRAME target, skipping.");

0 commit comments

Comments
 (0)