From 1eb63dd19a71a8b848c3357989fc1fe863ce6f68 Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Sat, 10 Sep 2022 01:17:16 +0200 Subject: [PATCH] nvk: use remaps for image copies This helps us to get around hardware limitations on the width. Signed-off-by: Karol Herbst Part-of: --- src/nouveau/vulkan/nvk_cmd_copy.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/nouveau/vulkan/nvk_cmd_copy.c b/src/nouveau/vulkan/nvk_cmd_copy.c index 5608799..4315e4a 100644 --- a/src/nouveau/vulkan/nvk_cmd_copy.c +++ b/src/nouveau/vulkan/nvk_cmd_copy.c @@ -31,7 +31,7 @@ struct nouveau_copy_buffer { struct nouveau_copy { struct nouveau_copy_buffer src; struct nouveau_copy_buffer dst; - struct { + struct nouveau_copy_remap { uint8_t comp_size; uint8_t dst[4]; } remap; @@ -97,6 +97,28 @@ nouveau_copy_rect_image( return buf; } +static struct nouveau_copy_remap +nouveau_copy_remap_format(VkFormat format) +{ + /* Pick an arbitrary component size. It doesn't matter what size we + * pick since we're just doing a copy, as long as it's no more than 4B + * and divides the format size. + */ + unsigned comp_size = vk_format_get_blocksize(format); + if (comp_size % 3 == 0) { + comp_size /= 3; + assert(util_is_power_of_two_nonzero(comp_size) && comp_size <= 4); + } else { + assert(util_is_power_of_two_nonzero(comp_size) && comp_size <= 16); + comp_size = MIN2(comp_size, 4); + } + + return (struct nouveau_copy_remap) { + .comp_size = comp_size, + .dst = { 0, 1, 2, 3 }, + }; +} + static uint32_t to_90b5_remap_comp_size(uint8_t comp_size) { @@ -372,6 +394,7 @@ nvk_CmdCopyBufferToImage2(VkCommandBuffer commandBuffer, } break; default: + copy.remap = nouveau_copy_remap_format(dst->vk.format); break; } @@ -441,6 +464,7 @@ nvk_CmdCopyImageToBuffer2(VkCommandBuffer commandBuffer, } break; default: + copy.remap = nouveau_copy_remap_format(src->vk.format); break; } @@ -518,6 +542,7 @@ nvk_CmdCopyImage2(VkCommandBuffer commandBuffer, } break; default: + copy.remap = nouveau_copy_remap_format(src->vk.format); break; } -- 2.7.4