From 18ff505317e01ac8924b71351556b295648e9bc0 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Sun, 5 Aug 2018 14:51:18 +1000 Subject: [PATCH] rename util namespace to cruft --- CMakeLists.txt | 9 +-------- command_buffer.cpp | 16 ++++++++-------- command_buffer.hpp | 14 +++++++------- device.cpp | 4 ++-- device_memory.cpp | 2 +- device_memory.hpp | 2 +- fence.cpp | 6 +++--- instance.cpp | 4 ++-- instance.hpp | 4 ++-- ostream.cpp | 8 ++++---- pipeline_cache.cpp | 2 +- shader_module.cpp | 2 +- tools/hello.cpp | 22 +++++++++++----------- tools/info.cpp | 2 +- traits.hpp | 2 +- 15 files changed, 46 insertions(+), 53 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06810b3..c31ee56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,7 +97,7 @@ list (APPEND sources ##----------------------------------------------------------------------------- add_library (cruft-vk STATIC ${sources}) -target_link_libraries (cruft-vk cruft-util vulkan) +target_link_libraries (cruft-vk cruft vulkan) ############################################################################### @@ -128,13 +128,6 @@ foreach (src ${shaders}) endforeach () -############################################################################### -get_directory_property (HAS_PARENT PARENT_DIRECTORY) -if (HAS_PARENT) - set (CRUFT_VK_FOUND 1 PARENT_SCOPE) -endif () - - ############################################################################### foreach (t info hello) add_executable (vk_${t} "tools/${t}.cpp") diff --git a/command_buffer.cpp b/command_buffer.cpp index effe16c..65696f3 100644 --- a/command_buffer.cpp +++ b/command_buffer.cpp @@ -108,18 +108,18 @@ command_buffer::reset (const event &ev, VkPipelineStageFlags flags) //----------------------------------------------------------------------------- void -command_buffer::wait (util::view events, +command_buffer::wait (cruft::view events, VkPipelineStageFlags src_mask, VkPipelineStageFlags dst_mask, - util::view VkMemoryBarriers, - util::view VkBufferMemoryBarriers, - util::view VkImageMemoryBarriers) + cruft::view VkMemoryBarriers, + cruft::view VkBufferMemoryBarriers, + cruft::view VkImageMemoryBarriers) { vkCmdWaitEvents ( native (), - util::cast::lossless (events.size ()), &events.cbegin ()->native (), + cruft::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 ()); + cruft::cast::lossless (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (), + cruft::cast::lossless (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (), + cruft::cast::lossless (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ()); } diff --git a/command_buffer.hpp b/command_buffer.hpp index 7d4a694..67dbb42 100644 --- a/command_buffer.hpp +++ b/command_buffer.hpp @@ -34,20 +34,20 @@ namespace cruft::vk { void set (const event&, VkPipelineStageFlags); void reset (const event&, VkPipelineStageFlags); - void wait (util::view, + void wait (cruft::view, VkPipelineStageFlags src_mask, VkPipelineStageFlags dst_mask, - util::view, - util::view, - util::view); + cruft::view, + cruft::view, + cruft::view); void pipeline_barrier ( VkPipelineStageFlags src_mask, VkPipelineStageFlags dst_mask, VkDependencyFlags, - util::view, - util::view, - util::view); + cruft::view, + cruft::view, + cruft::view); }; } diff --git a/device.cpp b/device.cpp index 78bf6f9..34c60c3 100644 --- a/device.cpp +++ b/device.cpp @@ -40,7 +40,7 @@ device::flush (const VkMappedMemoryRange *first, { CHECK_LE (first, last); - auto err = vkFlushMappedMemoryRanges (native (), util::cast::lossless (last - first), first); + auto err = vkFlushMappedMemoryRanges (native (), cruft::cast::lossless (last - first), first); error::try_code (err); } @@ -52,7 +52,7 @@ device::invalidate (const VkMappedMemoryRange *first, { CHECK_LE (first, last); - auto err = vkInvalidateMappedMemoryRanges (native (), util::cast::lossless (last - first), first); + auto err = vkInvalidateMappedMemoryRanges (native (), cruft::cast::lossless (last - first), first); error::try_code (err); } diff --git a/device_memory.cpp b/device_memory.cpp index f3dc4bc..f50c455 100644 --- a/device_memory.cpp +++ b/device_memory.cpp @@ -26,7 +26,7 @@ cruft::vk::map_t::~map_t () cruft::vk::map_t& cruft::vk::map_t::operator= (std::nullptr_t ptr) { - util::view::operator= (ptr); + cruft::view::operator= (ptr); return *this; } diff --git a/device_memory.hpp b/device_memory.hpp index d1e6093..57e5cb2 100644 --- a/device_memory.hpp +++ b/device_memory.hpp @@ -20,7 +20,7 @@ namespace cruft::vk { /////////////////////////////////////////////////////////////////////////// - struct map_t : public util::view { + struct map_t : public cruft::view { public: using view::view; diff --git a/fence.cpp b/fence.cpp index c413765..d292554 100644 --- a/fence.cpp +++ b/fence.cpp @@ -34,7 +34,7 @@ fence::reset (const device &dev, fence *first, fence *last) CHECK_LE (first, last); cruft::vk::error::try_func ( - vkResetFences, dev.native (), util::cast::lossless (last - first), &first->native () + vkResetFences, dev.native (), cruft::cast::lossless (last - first), &first->native () ); } @@ -47,7 +47,7 @@ fence::wait (const device &d, fence *first, fence *last, uint64_t timeout) cruft::vk::error::try_func ( vkWaitForFences, - d.native (), util::cast::lossless (last - first), &first->native (), VK_FALSE, timeout + d.native (), cruft::cast::lossless (last - first), &first->native (), VK_FALSE, timeout ); } @@ -60,6 +60,6 @@ fence::wait_all (const device &d, fence *first, fence *last, uint64_t timeout) cruft::vk::error::try_func ( vkWaitForFences, - d.native (), util::cast::lossless (last - first), &first->native (), VK_TRUE, timeout + d.native (), cruft::cast::lossless (last - first), &first->native (), VK_TRUE, timeout ); } diff --git a/instance.cpp b/instance.cpp index 1cf2575..3ae8353 100644 --- a/instance.cpp +++ b/instance.cpp @@ -49,8 +49,8 @@ instance::instance (): //----------------------------------------------------------------------------- -instance::instance (const util::view layers, - const util::view extensions): +instance::instance (const cruft::view layers, + const cruft::view extensions): instance (VkInstanceCreateInfo { .sType = cruft::vk::structure_type_v, .pNext = nullptr, diff --git a/instance.hpp b/instance.hpp index 0937f0c..bf254aa 100644 --- a/instance.hpp +++ b/instance.hpp @@ -34,8 +34,8 @@ namespace cruft::vk { }; instance (); - instance (util::view layers, - util::view extensions); + instance (cruft::view layers, + cruft::view extensions); instance (const create_info_t &info); template diff --git a/ostream.cpp b/ostream.cpp index 9461c1c..5e6d5d3 100644 --- a/ostream.cpp +++ b/ostream.cpp @@ -47,7 +47,7 @@ operator<< (std::ostream &os, VkQueueFlags val) if (val & VK_QUEUE_TRANSFER_BIT) names[cursor++] = "TRANSFER"; if (val & VK_QUEUE_SPARSE_BINDING_BIT) names[cursor++] = "SPARSE_BINDING"; - return os << "[ " << util::make_infix (util::make_view (names, names + cursor)) << " ]"; + return os << "[ " << cruft::make_infix (cruft::make_view (names, names + cursor)) << " ]"; } #endif @@ -81,7 +81,7 @@ cruft::vk::operator<< (std::ostream &os, const instance &i) const auto &extensions = i.extensions (); std::copy (std::cbegin (extensions), std::cend (extensions), - util::infix_iterator (os, ", ")); + cruft::infix_iterator (os, ", ")); return os << " ] }"; } @@ -160,10 +160,10 @@ std::ostream& cruft::vk::operator<< (std::ostream &os, const physical_device &d) { return os << "physical_device { " - << "extensions: [ " << util::make_infix (d.extensions ()) << " ]" + << "extensions: [ " << cruft::make_infix (d.extensions ()) << " ]" << ", properties: " << d.properties () << ", features: " << d.features () - << ", queues: [ " << util::make_infix (d.queue_families ()) << " ]" + << ", queues: [ " << cruft::make_infix (d.queue_families ()) << " ]" << " }"; } diff --git a/pipeline_cache.cpp b/pipeline_cache.cpp index dae4a5b..5757518 100644 --- a/pipeline_cache.cpp +++ b/pipeline_cache.cpp @@ -23,7 +23,7 @@ pipeline_cache::merge (const device &dev, const pipeline_cache *last) { CHECK_GE (last, first); - auto err = vkMergePipelineCaches (dev.native (), native (), util::cast::lossless (last - first), &first->native ()); + auto err = vkMergePipelineCaches (dev.native (), native (), cruft::cast::lossless (last - first), &first->native ()); error::try_code (err); } diff --git a/shader_module.cpp b/shader_module.cpp index c73712f..0fd5ab9 100644 --- a/shader_module.cpp +++ b/shader_module.cpp @@ -21,7 +21,7 @@ struct cruft::vk::shader_module::cookie : public create_t { public: cookie (const std::experimental::filesystem::path &src): create_t {}, - m_bytes (util::slurp (src)) + m_bytes (cruft::slurp (src)) { CHECK_MOD (m_bytes.size (), 4); diff --git a/tools/hello.cpp b/tools/hello.cpp index 2ddb57a..0725a9a 100644 --- a/tools/hello.cpp +++ b/tools/hello.cpp @@ -60,8 +60,8 @@ vk_debug_callback (VkDebugReportFlagsEXT flags, /////////////////////////////////////////////////////////////////////////////// struct vertex_t { - util::point2f position; - util::srgba3f colour; + cruft::point2f position; + cruft::srgba3f colour; }; @@ -177,7 +177,7 @@ namespace glfw { public: using native_t = GLFWwindow*; - window (util::extent2i resolution, const char *name): + window (cruft::extent2i resolution, const char *name): m_native (glfwCreateWindow (resolution.w, resolution.h, name, nullptr, nullptr)) { if (!m_native) @@ -299,7 +299,7 @@ main (void) LOG_INFO ("intialising glfw"); glfw::instance glfw_instance; - util::extent2i resolution { 800, 600 }; + cruft::extent2i resolution { 800, 600 }; glfw::window window (resolution, "vkcruft-hello"); @@ -312,8 +312,8 @@ main (void) //------------------------------------------------------------------------- cruft::vk::instance instance ( - util::make_view (layers), - util::make_view (extensions.data (), extensions.data () + extensions.size ()) + cruft::make_view (layers), + cruft::make_view (extensions.data (), extensions.data () + extensions.size ()) ); load_traits (instance); @@ -356,13 +356,13 @@ main (void) auto queues = pdevice.queue_families (); int graphics_queue_id = -1, present_queue_id = -1; - for (int i = 0, last = util::cast::lossless (queues.size ()); i != last; ++i) + for (int i = 0, last = cruft::cast::lossless (queues.size ()); i != last; ++i) if (queues[i].queueCount > 0 && queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { graphics_queue_id = i; break; } - for (uint32_t i = 0, last = util::cast::narrow (queues.size ()); i != last; ++i) { + for (uint32_t i = 0, last = cruft::cast::narrow (queues.size ()); i != last; ++i) { if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR, pdevice.native (), i, surface)) { present_queue_id = i; @@ -425,12 +425,12 @@ main (void) VkSurfaceFormatKHR surface_format { VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR }; VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR; VkExtent2D present_extent { - .width = util::clamp ( + .width = cruft::clamp ( unsigned (resolution.w), surface_capabilities.minImageExtent.width, surface_capabilities.maxImageExtent.width ), - .height = util::clamp ( + .height = cruft::clamp ( unsigned (resolution.h), surface_capabilities.minImageExtent.height, surface_capabilities.maxImageExtent.height @@ -772,7 +772,7 @@ main (void) alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; alloc_info.commandPool = command_pool->native (); alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - alloc_info.commandBufferCount = util::cast::lossless (command_buffers.size()); + alloc_info.commandBufferCount = cruft::cast::lossless (command_buffers.size()); cruft::vk::error::try_code ( vkAllocateCommandBuffers (ldevice.native (), &alloc_info, command_buffers.data ()) ); diff --git a/tools/info.cpp b/tools/info.cpp index 639637c..740af7e 100644 --- a/tools/info.cpp +++ b/tools/info.cpp @@ -21,7 +21,7 @@ int main (int, char**) { std::cout << "available_layers: [ " - << util::make_infix (cruft::vk::instance::available_layers ()) + << cruft::make_infix (cruft::vk::instance::available_layers ()) << " ]\n"; cruft::vk::instance instance; diff --git a/traits.hpp b/traits.hpp index 8f720b1..8490e20 100644 --- a/traits.hpp +++ b/traits.hpp @@ -456,7 +456,7 @@ namespace cruft::vk { struct life_traits { static constexpr auto& create = vkGetDeviceQueue; - static constexpr auto destroy = ::util::variadic::ignore< + static constexpr auto destroy = ::cruft::variadic::ignore< native_t>, native_t, const VkAllocationCallbacks*