aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBas Nieuwenhuizen <[email protected]>2019-09-20 13:49:44 +0200
committerBas Nieuwenhuizen <[email protected]>2019-09-27 15:05:21 +0200
commit9e822957cd2c5d92b2b57c663aa153976119197d (patch)
tree8e2850e07ebc3661b7d1783d22de1fb289339726 /src
parentb48fe29e3c31b1f6d1d9f2ce81741095b2de824d (diff)
turnip: Always use UINT formats for copies.
Looks like r16_unorm might have precision issues. dEQP-VK.api.copy_and_blit.core.image_to_image.all_formats.color.r16_unorm.r16_unorm.general_general fails, but the dumped images in the xml are the same so I'd guess the low bits are the issue. r8_unorm and r16_uint work. Reviewed-by: Kristian H. Kristensen <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/freedreno/vulkan/tu_meta_copy.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/freedreno/vulkan/tu_meta_copy.c b/src/freedreno/vulkan/tu_meta_copy.c
index f000c947b96..5e915e97836 100644
--- a/src/freedreno/vulkan/tu_meta_copy.c
+++ b/src/freedreno/vulkan/tu_meta_copy.c
@@ -89,6 +89,32 @@ tu_dma_prepare(struct tu_cmd_buffer *cmdbuf)
tu_cs_emit(&cmdbuf->cs, 0x10000000);
}
+/* Always use UINT formats to avoid precision issues.
+ *
+ * Example failure it avoids:
+ * - dEQP-VK.api.copy_and_blit.core.image_to_image.all_formats.color.r16_unorm.r16_unorm.general_general
+ */
+static VkFormat
+tu_canonical_copy_format(VkFormat format)
+{
+ switch (vk_format_get_blocksizebits(format)) {
+ case 8:
+ return VK_FORMAT_R8_UINT;
+ case 16:
+ return VK_FORMAT_R16_UINT;
+ case 32:
+ return VK_FORMAT_R32_UINT;
+ case 64:
+ return VK_FORMAT_R32G32_UINT;
+ case 96:
+ return VK_FORMAT_R32G32B32_UINT;
+ case 128:
+ return VK_FORMAT_R32G32B32A32_UINT;
+ default:
+ unreachable("unhandled format size");
+ }
+}
+
static void
tu_copy_buffer(struct tu_cmd_buffer *cmdbuf,
struct tu_bo *src_bo,
@@ -357,7 +383,7 @@ tu_copy_buffer_to_image(struct tu_cmd_buffer *cmdbuf,
tu_cs_emit_pkt7(&cmdbuf->cs, CP_SET_MARKER, 1);
tu_cs_emit(&cmdbuf->cs, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));
- VkFormat format = dst_image->vk_format;
+ VkFormat format = tu_canonical_copy_format(dst_image->vk_format);
const enum a6xx_color_fmt rb_fmt = tu6_get_native_format(format)->rb;
const uint32_t blit_cntl = blit_control(rb_fmt) | 0x20000000;
@@ -547,7 +573,7 @@ tu_copy_image_to_buffer(struct tu_cmd_buffer *cmdbuf,
tu_cs_emit_pkt7(&cmdbuf->cs, CP_SET_MARKER, 1);
tu_cs_emit(&cmdbuf->cs, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));
- VkFormat format = src_image->vk_format;
+ VkFormat format = tu_canonical_copy_format(src_image->vk_format);
const enum a6xx_color_fmt rb_fmt = tu6_get_native_format(format)->rb;
unsigned dst_pixel_stride = copy_info->bufferRowLength
@@ -743,7 +769,7 @@ tu_copy_image_to_image(struct tu_cmd_buffer *cmdbuf,
tu_cs_emit_pkt7(&cmdbuf->cs, CP_SET_MARKER, 1);
tu_cs_emit(&cmdbuf->cs, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));
- VkFormat format = src_image->vk_format;
+ VkFormat format = tu_canonical_copy_format(src_image->vk_format);
const enum a6xx_color_fmt rb_fmt = tu6_get_native_format(format)->rb;
const uint32_t blit_cntl = blit_control(rb_fmt) | 0x20000000;