From 3d2e7e647c3b7b720d2792ff054a6ea42a900cec Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Tue, 16 Jan 2018 15:12:54 +1100 Subject: [PATCH] util: move cast functions into util::cast --- command_buffer.cpp | 13 +++++++------ device.cpp | 4 ++-- device_memory.cpp | 9 +++++++++ device_memory.hpp | 4 ++++ fence.cpp | 6 +++--- pipeline_cache.cpp | 2 +- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/command_buffer.cpp b/command_buffer.cpp index 96ce101..cabb25c 100644 --- a/command_buffer.cpp +++ b/command_buffer.cpp @@ -123,10 +123,11 @@ command_buffer::wait (util::view events, util::view VkBufferMemoryBarriers, util::view VkImageMemoryBarriers) { - vkCmdWaitEvents (native (), - trunc_cast (events.size ()), &events.cbegin ()->native (), - src_mask, dst_mask, - trunc_cast (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (), - trunc_cast (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (), - trunc_cast (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ()); + vkCmdWaitEvents ( + native (), + util::cast::lossless (events.size ()), &events.cbegin ()->native (), + src_mask, dst_mask, + util::cast::lossless (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (), + util::cast::lossless (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (), + util::cast::lossless (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ()); } diff --git a/device.cpp b/device.cpp index 483ea08..e606607 100644 --- a/device.cpp +++ b/device.cpp @@ -48,7 +48,7 @@ device::flush (const VkMappedMemoryRange *first, { CHECK_LE (first, last); - auto err = vkFlushMappedMemoryRanges (native (), trunc_cast (last - first), first); + auto err = vkFlushMappedMemoryRanges (native (), util::cast::lossless (last - first), first); error::try_code (err); } @@ -60,7 +60,7 @@ device::invalidate (const VkMappedMemoryRange *first, { CHECK_LE (first, last); - auto err = vkInvalidateMappedMemoryRanges (native (), trunc_cast (last - first), first); + auto err = vkInvalidateMappedMemoryRanges (native (), util::cast::lossless (last - first), first); error::try_code (err); } diff --git a/device_memory.cpp b/device_memory.cpp index 7d18d87..0b3fb9b 100644 --- a/device_memory.cpp +++ b/device_memory.cpp @@ -30,6 +30,15 @@ cruft::vk::map_t::~map_t () } +//----------------------------------------------------------------------------- +cruft::vk::map_t& +cruft::vk::map_t::operator= (std::nullptr_t ptr) +{ + util::view::operator= (ptr); + return *this; +} + + //----------------------------------------------------------------------------- void cruft::vk::map_t::destroy (device &_device, device_memory &_memory) diff --git a/device_memory.hpp b/device_memory.hpp index 90ade3d..c4599a1 100644 --- a/device_memory.hpp +++ b/device_memory.hpp @@ -32,8 +32,12 @@ namespace cruft::vk { public: using view::view; + map_t (const map_t&) = delete; ~map_t (); + map_t& operator= (const map_t&) = delete; + map_t& operator= (std::nullptr_t); + void destroy (device&, device_memory&); }; diff --git a/fence.cpp b/fence.cpp index b0733ef..07f5267 100644 --- a/fence.cpp +++ b/fence.cpp @@ -42,7 +42,7 @@ fence::reset (const device &dev, fence *first, fence *last) CHECK_LE (first, last); cruft::vk::error::try_func ( - vkResetFences, dev.native (), trunc_cast (last - first), &first->native () + vkResetFences, dev.native (), util::cast::lossless (last - first), &first->native () ); } @@ -55,7 +55,7 @@ fence::wait (const device &d, fence *first, fence *last, uint64_t timeout) cruft::vk::error::try_func ( vkWaitForFences, - d.native (), trunc_cast (last - first), &first->native (), VK_FALSE, timeout + d.native (), util::cast::lossless (last - first), &first->native (), VK_FALSE, timeout ); } @@ -68,6 +68,6 @@ fence::wait_all (const device &d, fence *first, fence *last, uint64_t timeout) cruft::vk::error::try_func ( vkWaitForFences, - d.native (), trunc_cast (last - first), &first->native (), VK_TRUE, timeout + d.native (), util::cast::lossless (last - first), &first->native (), VK_TRUE, timeout ); } diff --git a/pipeline_cache.cpp b/pipeline_cache.cpp index 469931a..8099bd4 100644 --- a/pipeline_cache.cpp +++ b/pipeline_cache.cpp @@ -31,7 +31,7 @@ pipeline_cache::merge (const device &dev, const pipeline_cache *last) { CHECK_GE (last, first); - auto err = vkMergePipelineCaches (dev.native (), native (), trunc_cast (last - first), &first->native ()); + auto err = vkMergePipelineCaches (dev.native (), native (), util::cast::lossless (last - first), &first->native ()); error::try_code (err); }