rsx: Ensure blit targets do not straddle tile boundaries

This commit is contained in:
kd-11
2026-08-28 14:55:44 +03:00
committed by kd-11
parent 7a4c82aec9
commit 85bc1d7074
2 changed files with 24 additions and 3 deletions
+2 -1
View File
@@ -3484,7 +3484,8 @@ namespace rsx
dst_range,
dst.pitch,
src_dimensions,
static_cast<size2u>(dst_dimensions)
static_cast<size2u>(dst_dimensions),
dst_tile
);
if (props.use_dma_region)
+22 -2
View File
@@ -171,8 +171,10 @@ namespace rsx
address_range32 dst_range,
u32 dst_pitch,
const sizeu src_dimensions,
const sizeu dst_dimensions)
const sizeu dst_dimensions_,
const GCM_tile_reference& dst_tile)
{
auto dst_dimensions = dst_dimensions_;
if (get_location(dst_range.start) == CELL_GCM_LOCATION_LOCAL)
{
// Check if this is a blit to the output buffer
@@ -211,6 +213,23 @@ namespace rsx
}
}
// Check if we're writing into a tiled region.
if (dst_tile)
{
const auto tile_range = utils::address_range32::start_length(dst_tile.base_address, dst_tile.tile->size);
if (dst_range.inside(tile_range))
{
// Limit the height if we go beyond the limit
const auto proposed_range = utils::address_range32::start_length(dst_range.start, dst_dimensions.height * dst_pitch);
if (!proposed_range.inside(tile_range))
{
const auto max_height = utils::aligned_div((tile_range.end + 1u) - dst_range.start, dst_pitch);
const auto min_fitted_height = utils::aligned_div(dst_range.length(), dst_pitch);
dst_dimensions.height = std::clamp(dst_dimensions.height, min_fitted_height, max_height);
}
}
}
if (src_is_render_target)
{
// Attempt to optimize...
@@ -218,7 +237,8 @@ namespace rsx
{
// Optimizations table based on common width/height pairings. If we guess wrong, the upload resolver will fix it anyway
// TODO: Add more entries based on empirical data
const auto optimal_height = std::max(dst_dimensions.height, 720u);
const auto min_fitted_height = utils::aligned_div(dst_range.length(), dst_pitch);
const auto optimal_height = std::max(std::min(dst_dimensions.height, min_fitted_height), 720u);
return { false, 0, dst_dimensions.width, optimal_height };
}