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; }