From 6d7c2aba9fac21b6fc11efb617b03ed1e67a4b90 Mon Sep 17 00:00:00 2001 From: Ivan Gagis's Bot Date: Mon, 23 Nov 2026 03:40:43 +0200 Subject: [PATCH] fix C4244 narrowing conversion warnings on 32-bit (Win32) On 32-bit targets size_t and unsigned int are 32-bit while VkDeviceSize is 64-bit, so passing buffer sizes of type VkDeviceSize to host-side calls (std::vector constructor, std::memcpy) triggers C4244, which the CI build turns into an error. Change the local size variables to size_t at the declaration site. The Vulkan API calls (VkBufferCreateInfo::size, vkMapMemory) accept the wider VkDeviceSize, so the values are simply widened there, and the host-side calls receive size_t directly. --- src/ruis/render/vulkan/context.cpp | 4 +++- src/ruis/render/vulkan/factory.cpp | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ruis/render/vulkan/context.cpp b/src/ruis/render/vulkan/context.cpp index d3dfd13..d5ce288 100644 --- a/src/ruis/render/vulkan/context.cpp +++ b/src/ruis/render/vulkan/context.cpp @@ -1068,7 +1068,9 @@ rasterimage::image_variant context::readback_framebuffer_color(const ruis::rende const auto w = uint32_t(color.dims().x()); const auto h = uint32_t(color.dims().y()); const size_t row_bytes = size_t(w) * 4; // RGBA8 - const VkDeviceSize total_bytes = row_bytes * h; + // size_t (not VkDeviceSize): used both for the Vulkan API (which widens it) + // and for host-side allocations/copies, avoiding narrowing conversions on 32-bit targets + const size_t total_bytes = row_bytes * h; // create a host-visible staging buffer for the readback VkBuffer staging_buffer = VK_NULL_HANDLE; diff --git a/src/ruis/render/vulkan/factory.cpp b/src/ruis/render/vulkan/factory.cpp index 41dbfa2..4098b9e 100644 --- a/src/ruis/render/vulkan/factory.cpp +++ b/src/ruis/render/vulkan/factory.cpp @@ -389,7 +389,10 @@ void factory::one_shot(std::function cmd) const void factory::upload_texture(texture_2d* t) const { - const auto total_size = t->staging_size(); + // the cast produces a size_t (not VkDeviceSize): used both for the Vulkan API + // (which widens it) and for host-side copies, avoiding narrowing conversions + // on 32-bit targets + const auto total_size = size_t(t->staging_size()); if (total_size == 0) { return; }