From 3b0a5ab7dd1ef00fa9adfa7130d831365188bceb Mon Sep 17 00:00:00 2001 From: Stephen Seo Date: Wed, 20 Mar 2024 16:12:23 +0900 Subject: [PATCH] WIP Vulkan compute: Fix buffer data "filter_size" integer must be odd. This is how it is defined for the OpenCL implementation. --- src/blue_noise.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/blue_noise.cpp b/src/blue_noise.cpp index 4de76d8..2e1292e 100644 --- a/src/blue_noise.cpp +++ b/src/blue_noise.cpp @@ -676,8 +676,14 @@ image::Bl dither::blue_noise(int width, int height, int threads, vkMapMemory(device, staging_buffer_mem, 0, other_size, 0, &data_ptr); std::memcpy(data_ptr, &width, sizeof(int)); std::memcpy(((char *)data_ptr) + sizeof(int), &height, sizeof(int)); - std::memcpy(((char *)data_ptr) + sizeof(int) * 2, &filter_size, - sizeof(int)); + if (filter_size % 2 == 0) { + int filter_size_odd = filter_size + 1; + std::memcpy(((char *)data_ptr) + sizeof(int) * 2, &filter_size_odd, + sizeof(int)); + } else { + std::memcpy(((char *)data_ptr) + sizeof(int) * 2, &filter_size, + sizeof(int)); + } vkUnmapMemory(device, staging_buffer_mem); if (!vulkan_create_buffer(device, phys_device, other_size,