From 1d3ff4d4091a8c91cecdf3f1892ed0d1e1bf01cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st> Date: Sat, 23 Jul 2022 23:49:37 +0300 Subject: [PATCH] Fix incompatible pointer/integer conversion errors on 32 bit Clang 15 made "incompatible pointer to integer conversion" an error instead of a plain warning. This fixes errors like these: ../src/vulkan/gpu_pass.c:208:59: error: incompatible integer to pointer conversion passing 'VkPipeline' (aka 'unsigned long long') to parameter of type 'const void *' [-Wint-conversion] vk_dev_callback(vk, (vk_cb) destroy_pipeline, vk, *out_pipe); ^~~~~~~~~ ../src/vulkan/command.h:36:52: note: passing argument to parameter 'arg' here const void *priv, const void *arg); ^ ../src/vulkan/gpu_pass.c:209:19: error: incompatible pointer to integer conversion assigning to 'VkPipeline' (aka 'unsigned long long') from 'void *' [-Wint-conversion] *out_pipe = NULL; ^ ~~~~ --- src/vulkan/gpu_pass.c | 6 +++--- src/vulkan/malloc.c | 2 +- src/vulkan/swapchain.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vulkan/gpu_pass.c b/src/vulkan/gpu_pass.c index 2fd7819c2..4b80f949d 100644 --- a/src/vulkan/gpu_pass.c +++ b/src/vulkan/gpu_pass.c @@ -191,8 +191,8 @@ static VkResult vk_recreate_pipelines(struct vk_ctx *vk, pl_pass pass, // The old pipeline might still be in use, so we have to destroy it // asynchronously with a device idle callback if (*out_pipe) { - vk_dev_callback(vk, (vk_cb) destroy_pipeline, vk, *out_pipe); - *out_pipe = NULL; + vk_dev_callback(vk, (vk_cb) destroy_pipeline, vk, (void*)(uintptr_t)*out_pipe); + *out_pipe = VK_NULL_HANDLE; } VkPipelineCreateFlags flags = 0; @@ -612,7 +612,7 @@ no_descriptors: ; // Create the graphics/compute pipeline VkPipeline *pipe = has_spec ? &pass_vk->base : &pass_vk->pipe; - VK(vk_recreate_pipelines(vk, pass, has_spec, NULL, pipe)); + VK(vk_recreate_pipelines(vk, pass, has_spec, VK_NULL_HANDLE, pipe)); pl_log_cpu_time(gpu->log, after_compilation, clock(), "creating pipeline"); if (!has_spec) { diff --git a/src/vulkan/malloc.c b/src/vulkan/malloc.c index 3f5fea809..6981f114a 100644 --- a/src/vulkan/malloc.c +++ b/src/vulkan/malloc.c @@ -864,7 +864,7 @@ static bool vk_malloc_import(struct vk_malloc *ma, struct vk_memslice *out, goto error; } - VkDeviceMemory vkmem = NULL; + VkDeviceMemory vkmem = VK_NULL_HANDLE; VK(vk->AllocateMemory(vk->dev, &ainfo, PL_VK_ALLOC, &vkmem)); slab = pl_alloc_ptr(NULL, slab); diff --git a/src/vulkan/swapchain.c b/src/vulkan/swapchain.c index 6bdd73b62..f29437821 100644 --- a/src/vulkan/swapchain.c +++ b/src/vulkan/swapchain.c @@ -597,7 +597,7 @@ static bool vk_sw_recreate(pl_swapchain sw, int w, int h) // If needed, allocate some more semaphores while (num_images > p->sems.num) { - VkSemaphore sem_in = NULL, sem_out = NULL; + VkSemaphore sem_in = VK_NULL_HANDLE, sem_out = VK_NULL_HANDLE; static const VkSemaphoreCreateInfo seminfo = { .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO, }; -- GitLab