rename util namespace to cruft

This commit is contained in:
Danny Robson 2018-08-05 14:51:18 +10:00
parent 825cbd8e28
commit 18ff505317
15 changed files with 46 additions and 53 deletions

View File

@ -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")

View File

@ -108,18 +108,18 @@ command_buffer::reset (const event &ev, VkPipelineStageFlags flags)
//-----------------------------------------------------------------------------
void
command_buffer::wait (util::view<const event*> events,
command_buffer::wait (cruft::view<const event*> events,
VkPipelineStageFlags src_mask,
VkPipelineStageFlags dst_mask,
util::view<const VkMemoryBarrier*> VkMemoryBarriers,
util::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
util::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
cruft::view<const VkMemoryBarrier*> VkMemoryBarriers,
cruft::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
cruft::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
{
vkCmdWaitEvents (
native (),
util::cast::lossless<uint32_t> (events.size ()), &events.cbegin ()->native (),
cruft::cast::lossless<uint32_t> (events.size ()), &events.cbegin ()->native (),
src_mask, dst_mask,
util::cast::lossless<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
util::cast::lossless<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
util::cast::lossless<uint32_t> (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ());
cruft::cast::lossless<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
cruft::cast::lossless<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
cruft::cast::lossless<uint32_t> (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ());
}

View File

@ -34,20 +34,20 @@ namespace cruft::vk {
void set (const event&, VkPipelineStageFlags);
void reset (const event&, VkPipelineStageFlags);
void wait (util::view<const event*>,
void wait (cruft::view<const event*>,
VkPipelineStageFlags src_mask,
VkPipelineStageFlags dst_mask,
util::view<const VkMemoryBarrier*>,
util::view<const VkBufferMemoryBarrier*>,
util::view<const VkImageMemoryBarrier*>);
cruft::view<const VkMemoryBarrier*>,
cruft::view<const VkBufferMemoryBarrier*>,
cruft::view<const VkImageMemoryBarrier*>);
void pipeline_barrier (
VkPipelineStageFlags src_mask,
VkPipelineStageFlags dst_mask,
VkDependencyFlags,
util::view<const VkMemoryBarrier*>,
util::view<const VkBufferMemoryBarrier*>,
util::view<const VkImageMemoryBarrier*>);
cruft::view<const VkMemoryBarrier*>,
cruft::view<const VkBufferMemoryBarrier*>,
cruft::view<const VkImageMemoryBarrier*>);
};
}

View File

@ -40,7 +40,7 @@ device::flush (const VkMappedMemoryRange *first,
{
CHECK_LE (first, last);
auto err = vkFlushMappedMemoryRanges (native (), util::cast::lossless<uint32_t> (last - first), first);
auto err = vkFlushMappedMemoryRanges (native (), cruft::cast::lossless<uint32_t> (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<uint32_t> (last - first), first);
auto err = vkInvalidateMappedMemoryRanges (native (), cruft::cast::lossless<uint32_t> (last - first), first);
error::try_code (err);
}

View File

@ -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<std::byte*>::operator= (ptr);
cruft::view<std::byte*>::operator= (ptr);
return *this;
}

View File

@ -20,7 +20,7 @@
namespace cruft::vk {
///////////////////////////////////////////////////////////////////////////
struct map_t : public util::view<std::byte*> {
struct map_t : public cruft::view<std::byte*> {
public:
using view::view;

View File

@ -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<uint32_t> (last - first), &first->native ()
vkResetFences, dev.native (), cruft::cast::lossless<uint32_t> (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<uint32_t> (last - first), &first->native (), VK_FALSE, timeout
d.native (), cruft::cast::lossless<uint32_t> (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<uint32_t> (last - first), &first->native (), VK_TRUE, timeout
d.native (), cruft::cast::lossless<uint32_t> (last - first), &first->native (), VK_TRUE, timeout
);
}

View File

@ -49,8 +49,8 @@ instance::instance ():
//-----------------------------------------------------------------------------
instance::instance (const util::view<const char **> layers,
const util::view<const char **> extensions):
instance::instance (const cruft::view<const char **> layers,
const cruft::view<const char **> extensions):
instance (VkInstanceCreateInfo {
.sType = cruft::vk::structure_type_v<VkInstanceCreateInfo>,
.pNext = nullptr,

View File

@ -34,8 +34,8 @@ namespace cruft::vk {
};
instance ();
instance (util::view<const char**> layers,
util::view<const char**> extensions);
instance (cruft::view<const char**> layers,
cruft::view<const char**> extensions);
instance (const create_info_t &info);
template <typename FunctionT>

View File

@ -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<std::string> (os, ", "));
cruft::infix_iterator<std::string> (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 ()) << " ]"
<< " }";
}

View File

@ -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<uint32_t> (last - first), &first->native ());
auto err = vkMergePipelineCaches (dev.native (), native (), cruft::cast::lossless<uint32_t> (last - first), &first->native ());
error::try_code (err);
}

View File

@ -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<uint32_t> (src))
m_bytes (cruft::slurp<uint32_t> (src))
{
CHECK_MOD (m_bytes.size (), 4);

View File

@ -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<int> (queues.size ()); i != last; ++i)
for (int i = 0, last = cruft::cast::lossless<int> (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<uint32_t> (queues.size ()); i != last; ++i) {
for (uint32_t i = 0, last = cruft::cast::narrow<uint32_t> (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<uint32_t> (command_buffers.size());
alloc_info.commandBufferCount = cruft::cast::lossless<uint32_t> (command_buffers.size());
cruft::vk::error::try_code (
vkAllocateCommandBuffers (ldevice.native (), &alloc_info, command_buffers.data ())
);

View File

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

View File

@ -456,7 +456,7 @@ namespace cruft::vk {
struct life_traits<VkQueue> {
static constexpr auto& create = vkGetDeviceQueue;
static constexpr auto destroy = ::util::variadic::ignore<
static constexpr auto destroy = ::cruft::variadic::ignore<
native_t<owner_t<queue>>,
native_t<queue>,
const VkAllocationCallbacks*