pvr: improve buffer copy format selection

Take the source and destination address alignment into account when selecting
the pixel format / texel width. This avoids the transfer job code having to
handle an unaligned copy and, as a result, trying to encode a value that is too
large for the maxclip_x field in PBESTATE_REG_WORD1.

Fixes the following test cases:
  dEQP-GLES2.functional.vertex_arrays.single_attribute.offset.buffer_4_32_fixed2_vec2_dynamic_draw_quads_256
  dEQP-GLES2.functional.vertex_arrays.single_attribute.offset.buffer_4_8_fixed2_vec2_dynamic_draw_quads_256

Signed-off-by: Oskar Rundgren <oskar.rundgren@imgtec.com>
Acked-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/31679>
This commit is contained in:
Oskar Rundgren 2024-06-28 23:22:37 +01:00 committed by Marge Bot
parent 1d0f23752c
commit 703f3e902c

View file

@ -1246,6 +1246,8 @@ static VkResult pvr_cmd_copy_buffer_region(struct pvr_cmd_buffer *cmd_buffer,
while (offset < size) {
const VkDeviceSize remaining_size = size - offset;
struct pvr_transfer_cmd *transfer_cmd;
uint32_t src_align = (src_addr.addr + offset + src_offset) & 0xF;
uint32_t dst_align = (dst_addr.addr + offset + src_offset) & 0xF;
uint32_t texel_width;
VkDeviceSize texels;
VkFormat vk_format;
@ -1256,7 +1258,9 @@ static VkResult pvr_cmd_copy_buffer_region(struct pvr_cmd_buffer *cmd_buffer,
if (is_fill) {
vk_format = VK_FORMAT_R32_UINT;
texel_width = 4U;
} else if (remaining_size >= 16U) {
} else if (remaining_size >= 16U && (src_align % 16U) == 0 &&
(dst_align % 16U) == 0) {
/* Only if address is 128bpp aligned */
vk_format = VK_FORMAT_R32G32B32A32_UINT;
texel_width = 16U;
} else if (remaining_size >= 4U) {