rename util namespace to cruft
This commit is contained in:
parent
825cbd8e28
commit
18ff505317
@ -97,7 +97,7 @@ list (APPEND sources
|
|||||||
|
|
||||||
##-----------------------------------------------------------------------------
|
##-----------------------------------------------------------------------------
|
||||||
add_library (cruft-vk STATIC ${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 ()
|
endforeach ()
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
|
||||||
get_directory_property (HAS_PARENT PARENT_DIRECTORY)
|
|
||||||
if (HAS_PARENT)
|
|
||||||
set (CRUFT_VK_FOUND 1 PARENT_SCOPE)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
foreach (t info hello)
|
foreach (t info hello)
|
||||||
add_executable (vk_${t} "tools/${t}.cpp")
|
add_executable (vk_${t} "tools/${t}.cpp")
|
||||||
|
@ -108,18 +108,18 @@ command_buffer::reset (const event &ev, VkPipelineStageFlags flags)
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
command_buffer::wait (util::view<const event*> events,
|
command_buffer::wait (cruft::view<const event*> events,
|
||||||
VkPipelineStageFlags src_mask,
|
VkPipelineStageFlags src_mask,
|
||||||
VkPipelineStageFlags dst_mask,
|
VkPipelineStageFlags dst_mask,
|
||||||
util::view<const VkMemoryBarrier*> VkMemoryBarriers,
|
cruft::view<const VkMemoryBarrier*> VkMemoryBarriers,
|
||||||
util::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
|
cruft::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
|
||||||
util::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
|
cruft::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
|
||||||
{
|
{
|
||||||
vkCmdWaitEvents (
|
vkCmdWaitEvents (
|
||||||
native (),
|
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,
|
src_mask, dst_mask,
|
||||||
util::cast::lossless<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
|
cruft::cast::lossless<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
|
||||||
util::cast::lossless<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
|
cruft::cast::lossless<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
|
||||||
util::cast::lossless<uint32_t> (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ());
|
cruft::cast::lossless<uint32_t> (VkImageMemoryBarriers.size ()), VkImageMemoryBarriers.cbegin ());
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,20 @@ namespace cruft::vk {
|
|||||||
void set (const event&, VkPipelineStageFlags);
|
void set (const event&, VkPipelineStageFlags);
|
||||||
void reset (const event&, VkPipelineStageFlags);
|
void reset (const event&, VkPipelineStageFlags);
|
||||||
|
|
||||||
void wait (util::view<const event*>,
|
void wait (cruft::view<const event*>,
|
||||||
VkPipelineStageFlags src_mask,
|
VkPipelineStageFlags src_mask,
|
||||||
VkPipelineStageFlags dst_mask,
|
VkPipelineStageFlags dst_mask,
|
||||||
util::view<const VkMemoryBarrier*>,
|
cruft::view<const VkMemoryBarrier*>,
|
||||||
util::view<const VkBufferMemoryBarrier*>,
|
cruft::view<const VkBufferMemoryBarrier*>,
|
||||||
util::view<const VkImageMemoryBarrier*>);
|
cruft::view<const VkImageMemoryBarrier*>);
|
||||||
|
|
||||||
void pipeline_barrier (
|
void pipeline_barrier (
|
||||||
VkPipelineStageFlags src_mask,
|
VkPipelineStageFlags src_mask,
|
||||||
VkPipelineStageFlags dst_mask,
|
VkPipelineStageFlags dst_mask,
|
||||||
VkDependencyFlags,
|
VkDependencyFlags,
|
||||||
util::view<const VkMemoryBarrier*>,
|
cruft::view<const VkMemoryBarrier*>,
|
||||||
util::view<const VkBufferMemoryBarrier*>,
|
cruft::view<const VkBufferMemoryBarrier*>,
|
||||||
util::view<const VkImageMemoryBarrier*>);
|
cruft::view<const VkImageMemoryBarrier*>);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ device::flush (const VkMappedMemoryRange *first,
|
|||||||
{
|
{
|
||||||
CHECK_LE (first, last);
|
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);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ device::invalidate (const VkMappedMemoryRange *first,
|
|||||||
{
|
{
|
||||||
CHECK_LE (first, last);
|
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);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ cruft::vk::map_t::~map_t ()
|
|||||||
cruft::vk::map_t&
|
cruft::vk::map_t&
|
||||||
cruft::vk::map_t::operator= (std::nullptr_t ptr)
|
cruft::vk::map_t::operator= (std::nullptr_t ptr)
|
||||||
{
|
{
|
||||||
util::view<std::byte*>::operator= (ptr);
|
cruft::view<std::byte*>::operator= (ptr);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
namespace cruft::vk {
|
namespace cruft::vk {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
struct map_t : public util::view<std::byte*> {
|
struct map_t : public cruft::view<std::byte*> {
|
||||||
public:
|
public:
|
||||||
using view::view;
|
using view::view;
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ fence::reset (const device &dev, fence *first, fence *last)
|
|||||||
CHECK_LE (first, last);
|
CHECK_LE (first, last);
|
||||||
|
|
||||||
cruft::vk::error::try_func (
|
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 (
|
cruft::vk::error::try_func (
|
||||||
vkWaitForFences,
|
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 (
|
cruft::vk::error::try_func (
|
||||||
vkWaitForFences,
|
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
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ instance::instance ():
|
|||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
instance::instance (const util::view<const char **> layers,
|
instance::instance (const cruft::view<const char **> layers,
|
||||||
const util::view<const char **> extensions):
|
const cruft::view<const char **> extensions):
|
||||||
instance (VkInstanceCreateInfo {
|
instance (VkInstanceCreateInfo {
|
||||||
.sType = cruft::vk::structure_type_v<VkInstanceCreateInfo>,
|
.sType = cruft::vk::structure_type_v<VkInstanceCreateInfo>,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
|
@ -34,8 +34,8 @@ namespace cruft::vk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
instance ();
|
instance ();
|
||||||
instance (util::view<const char**> layers,
|
instance (cruft::view<const char**> layers,
|
||||||
util::view<const char**> extensions);
|
cruft::view<const char**> extensions);
|
||||||
instance (const create_info_t &info);
|
instance (const create_info_t &info);
|
||||||
|
|
||||||
template <typename FunctionT>
|
template <typename FunctionT>
|
||||||
|
@ -47,7 +47,7 @@ operator<< (std::ostream &os, VkQueueFlags val)
|
|||||||
if (val & VK_QUEUE_TRANSFER_BIT) names[cursor++] = "TRANSFER";
|
if (val & VK_QUEUE_TRANSFER_BIT) names[cursor++] = "TRANSFER";
|
||||||
if (val & VK_QUEUE_SPARSE_BINDING_BIT) names[cursor++] = "SPARSE_BINDING";
|
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
|
#endif
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ cruft::vk::operator<< (std::ostream &os, const instance &i)
|
|||||||
const auto &extensions = i.extensions ();
|
const auto &extensions = i.extensions ();
|
||||||
std::copy (std::cbegin (extensions),
|
std::copy (std::cbegin (extensions),
|
||||||
std::cend (extensions),
|
std::cend (extensions),
|
||||||
util::infix_iterator<std::string> (os, ", "));
|
cruft::infix_iterator<std::string> (os, ", "));
|
||||||
|
|
||||||
return os << " ] }";
|
return os << " ] }";
|
||||||
}
|
}
|
||||||
@ -160,10 +160,10 @@ std::ostream&
|
|||||||
cruft::vk::operator<< (std::ostream &os, const physical_device &d)
|
cruft::vk::operator<< (std::ostream &os, const physical_device &d)
|
||||||
{
|
{
|
||||||
return os << "physical_device { "
|
return os << "physical_device { "
|
||||||
<< "extensions: [ " << util::make_infix (d.extensions ()) << " ]"
|
<< "extensions: [ " << cruft::make_infix (d.extensions ()) << " ]"
|
||||||
<< ", properties: " << d.properties ()
|
<< ", properties: " << d.properties ()
|
||||||
<< ", features: " << d.features ()
|
<< ", features: " << d.features ()
|
||||||
<< ", queues: [ " << util::make_infix (d.queue_families ()) << " ]"
|
<< ", queues: [ " << cruft::make_infix (d.queue_families ()) << " ]"
|
||||||
<< " }";
|
<< " }";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ pipeline_cache::merge (const device &dev,
|
|||||||
const pipeline_cache *last)
|
const pipeline_cache *last)
|
||||||
{
|
{
|
||||||
CHECK_GE (last, first);
|
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);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ struct cruft::vk::shader_module::cookie : public create_t {
|
|||||||
public:
|
public:
|
||||||
cookie (const std::experimental::filesystem::path &src):
|
cookie (const std::experimental::filesystem::path &src):
|
||||||
create_t {},
|
create_t {},
|
||||||
m_bytes (util::slurp<uint32_t> (src))
|
m_bytes (cruft::slurp<uint32_t> (src))
|
||||||
{
|
{
|
||||||
CHECK_MOD (m_bytes.size (), 4);
|
CHECK_MOD (m_bytes.size (), 4);
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ vk_debug_callback (VkDebugReportFlagsEXT flags,
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
struct vertex_t {
|
struct vertex_t {
|
||||||
util::point2f position;
|
cruft::point2f position;
|
||||||
util::srgba3f colour;
|
cruft::srgba3f colour;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ namespace glfw {
|
|||||||
public:
|
public:
|
||||||
using native_t = GLFWwindow*;
|
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))
|
m_native (glfwCreateWindow (resolution.w, resolution.h, name, nullptr, nullptr))
|
||||||
{
|
{
|
||||||
if (!m_native)
|
if (!m_native)
|
||||||
@ -299,7 +299,7 @@ main (void)
|
|||||||
LOG_INFO ("intialising glfw");
|
LOG_INFO ("intialising glfw");
|
||||||
glfw::instance glfw_instance;
|
glfw::instance glfw_instance;
|
||||||
|
|
||||||
util::extent2i resolution { 800, 600 };
|
cruft::extent2i resolution { 800, 600 };
|
||||||
glfw::window window (resolution, "vkcruft-hello");
|
glfw::window window (resolution, "vkcruft-hello");
|
||||||
|
|
||||||
|
|
||||||
@ -312,8 +312,8 @@ main (void)
|
|||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
cruft::vk::instance instance (
|
cruft::vk::instance instance (
|
||||||
util::make_view (layers),
|
cruft::make_view (layers),
|
||||||
util::make_view (extensions.data (), extensions.data () + extensions.size ())
|
cruft::make_view (extensions.data (), extensions.data () + extensions.size ())
|
||||||
);
|
);
|
||||||
|
|
||||||
load_traits (instance);
|
load_traits (instance);
|
||||||
@ -356,13 +356,13 @@ main (void)
|
|||||||
auto queues = pdevice.queue_families ();
|
auto queues = pdevice.queue_families ();
|
||||||
int graphics_queue_id = -1, present_queue_id = -1;
|
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) {
|
if (queues[i].queueCount > 0 && queues[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) {
|
||||||
graphics_queue_id = i;
|
graphics_queue_id = i;
|
||||||
break;
|
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,
|
if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR,
|
||||||
pdevice.native (), i, surface)) {
|
pdevice.native (), i, surface)) {
|
||||||
present_queue_id = i;
|
present_queue_id = i;
|
||||||
@ -425,12 +425,12 @@ main (void)
|
|||||||
VkSurfaceFormatKHR surface_format { VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR };
|
VkSurfaceFormatKHR surface_format { VK_FORMAT_B8G8R8A8_UNORM, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR };
|
||||||
VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
VkPresentModeKHR present_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||||
VkExtent2D present_extent {
|
VkExtent2D present_extent {
|
||||||
.width = util::clamp (
|
.width = cruft::clamp (
|
||||||
unsigned (resolution.w),
|
unsigned (resolution.w),
|
||||||
surface_capabilities.minImageExtent.width,
|
surface_capabilities.minImageExtent.width,
|
||||||
surface_capabilities.maxImageExtent.width
|
surface_capabilities.maxImageExtent.width
|
||||||
),
|
),
|
||||||
.height = util::clamp (
|
.height = cruft::clamp (
|
||||||
unsigned (resolution.h),
|
unsigned (resolution.h),
|
||||||
surface_capabilities.minImageExtent.height,
|
surface_capabilities.minImageExtent.height,
|
||||||
surface_capabilities.maxImageExtent.height
|
surface_capabilities.maxImageExtent.height
|
||||||
@ -772,7 +772,7 @@ main (void)
|
|||||||
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
|
||||||
alloc_info.commandPool = command_pool->native ();
|
alloc_info.commandPool = command_pool->native ();
|
||||||
alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
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 (
|
cruft::vk::error::try_code (
|
||||||
vkAllocateCommandBuffers (ldevice.native (), &alloc_info, command_buffers.data ())
|
vkAllocateCommandBuffers (ldevice.native (), &alloc_info, command_buffers.data ())
|
||||||
);
|
);
|
||||||
|
@ -21,7 +21,7 @@ int
|
|||||||
main (int, char**)
|
main (int, char**)
|
||||||
{
|
{
|
||||||
std::cout << "available_layers: [ "
|
std::cout << "available_layers: [ "
|
||||||
<< util::make_infix (cruft::vk::instance::available_layers ())
|
<< cruft::make_infix (cruft::vk::instance::available_layers ())
|
||||||
<< " ]\n";
|
<< " ]\n";
|
||||||
|
|
||||||
cruft::vk::instance instance;
|
cruft::vk::instance instance;
|
||||||
|
@ -456,7 +456,7 @@ namespace cruft::vk {
|
|||||||
struct life_traits<VkQueue> {
|
struct life_traits<VkQueue> {
|
||||||
static constexpr auto& create = vkGetDeviceQueue;
|
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<owner_t<queue>>,
|
||||||
native_t<queue>,
|
native_t<queue>,
|
||||||
const VkAllocationCallbacks*
|
const VkAllocationCallbacks*
|
||||||
|
Loading…
Reference in New Issue
Block a user