rsx: Provide tile alignment utility (align to 64 * pitch blocks)

This commit is contained in:
kd-11 2024-02-06 01:28:07 +03:00 committed by kd-11
parent 823c72bf27
commit 95f9f04612
3 changed files with 18 additions and 0 deletions

View File

@ -38,4 +38,13 @@ namespace rsx
return {};
}
utils::address_range GCM_tile_reference::tile_align(const utils::address_range& range) const
{
const auto alignment = 64 * tile->pitch;
const u32 start_offset = rsx::align_down2(range.start - base_address, alignment);
const u32 end_offset = rsx::align2(range.end - base_address + 1, alignment);
return utils::address_range::start_length(start_offset + base_address, end_offset - start_offset);
}
}

View File

@ -25,6 +25,8 @@ namespace rsx
{
return !!tile;
}
utils::address_range tile_align(const rsx::address_range& range) const;
};
struct GCM_context

View File

@ -306,6 +306,13 @@ namespace rsx
return ((value + alignment - 1) / alignment) * alignment;
}
// General purpose downward alignment without power-of-2 constraint
template <typename T, typename U>
static inline T align_down2(T value, U alignment)
{
return (value / alignment) * alignment;
}
// Copy memory in inverse direction from source
// Used to scale negatively x axis while transfering image data
template <typename Ts = u8, typename Td = Ts>