object: rename id' as
native'
This commit is contained in:
parent
14f79cabb9
commit
54e1255f9d
@ -29,7 +29,7 @@ using cruft::vk::command_buffer;
|
|||||||
void
|
void
|
||||||
command_buffer::reset (VkCommandBufferResetFlags flags)
|
command_buffer::reset (VkCommandBufferResetFlags flags)
|
||||||
{
|
{
|
||||||
auto err = vkResetCommandBuffer (id (), flags);
|
auto err = vkResetCommandBuffer (native (), flags);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ command_buffer::reset (VkCommandBufferResetFlags flags)
|
|||||||
void
|
void
|
||||||
command_buffer::begin (const VkCommandBufferBeginInfo &info)
|
command_buffer::begin (const VkCommandBufferBeginInfo &info)
|
||||||
{
|
{
|
||||||
auto err = vkBeginCommandBuffer (id (), &info);
|
auto err = vkBeginCommandBuffer (native (), &info);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ command_buffer::begin (const VkCommandBufferBeginInfo &info)
|
|||||||
void
|
void
|
||||||
command_buffer::begin (const VkRenderPassBeginInfo &info, VkSubpassContents contents)
|
command_buffer::begin (const VkRenderPassBeginInfo &info, VkSubpassContents contents)
|
||||||
{
|
{
|
||||||
vkCmdBeginRenderPass (id (), &info, contents);
|
vkCmdBeginRenderPass (native (), &info, contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ command_buffer::begin (const VkRenderPassBeginInfo &info, VkSubpassContents cont
|
|||||||
void
|
void
|
||||||
command_buffer::end (void)
|
command_buffer::end (void)
|
||||||
{
|
{
|
||||||
auto err = vkEndCommandBuffer (id ());
|
auto err = vkEndCommandBuffer (native ());
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ command_buffer::end (void)
|
|||||||
void
|
void
|
||||||
command_buffer::end_pass (void)
|
command_buffer::end_pass (void)
|
||||||
{
|
{
|
||||||
vkCmdEndRenderPass (id ());
|
vkCmdEndRenderPass (native ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ template <size_t N>
|
|||||||
void
|
void
|
||||||
command_buffer::execute (const command_buffer (&buffers)[N])
|
command_buffer::execute (const command_buffer (&buffers)[N])
|
||||||
{
|
{
|
||||||
vkCmdExecuteCOmmands (id (), N, buffers);
|
vkCmdExecuteCOmmands (native (), N, buffers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ command_buffer::execute (const command_buffer (&buffers)[N])
|
|||||||
void
|
void
|
||||||
command_buffer::next_subpass (const VkSubpassContents contents)
|
command_buffer::next_subpass (const VkSubpassContents contents)
|
||||||
{
|
{
|
||||||
vkCmdNextSubpass (id (), contents);
|
vkCmdNextSubpass (native (), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ command_buffer::next_subpass (const VkSubpassContents contents)
|
|||||||
void
|
void
|
||||||
command_buffer::bind (VkPipelineBindPoint point, const pipeline &p)
|
command_buffer::bind (VkPipelineBindPoint point, const pipeline &p)
|
||||||
{
|
{
|
||||||
vkCmdBindPipeline (id (), point, p.id ());
|
vkCmdBindPipeline (native (), point, p.native ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ command_buffer::bind (VkPipelineBindPoint point, const pipeline &p)
|
|||||||
void
|
void
|
||||||
command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
||||||
{
|
{
|
||||||
vkCmdSetEvent (id (), ev.id (), flags);
|
vkCmdSetEvent (native (), ev.native (), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ command_buffer::set (const event &ev, VkPipelineStageFlags flags)
|
|||||||
void
|
void
|
||||||
command_buffer::reset (const event &ev, VkPipelineStageFlags flags)
|
command_buffer::reset (const event &ev, VkPipelineStageFlags flags)
|
||||||
{
|
{
|
||||||
vkCmdResetEvent (id (), ev.id (), flags);
|
vkCmdResetEvent (native (), ev.native (), flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -118,8 +118,8 @@ command_buffer::wait (util::view<const event*> events,
|
|||||||
util::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
|
util::view<const VkBufferMemoryBarrier*> VkBufferMemoryBarriers,
|
||||||
util::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
|
util::view<const VkImageMemoryBarrier*> VkImageMemoryBarriers)
|
||||||
{
|
{
|
||||||
vkCmdWaitEvents (id (),
|
vkCmdWaitEvents (native (),
|
||||||
trunc_cast<uint32_t> (events.size ()), &events.cbegin ()->id (),
|
trunc_cast<uint32_t> (events.size ()), &events.cbegin ()->native (),
|
||||||
src_mask, dst_mask,
|
src_mask, dst_mask,
|
||||||
trunc_cast<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
|
trunc_cast<uint32_t> (VkMemoryBarriers.size ()), VkMemoryBarriers.cbegin (),
|
||||||
trunc_cast<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
|
trunc_cast<uint32_t> (VkBufferMemoryBarriers.size ()), VkBufferMemoryBarriers.cbegin (),
|
||||||
|
@ -26,6 +26,6 @@ using cruft::vk::command_pool;
|
|||||||
void
|
void
|
||||||
command_pool::reset (const device &dev, VkCommandPoolResetFlags flags)
|
command_pool::reset (const device &dev, VkCommandPoolResetFlags flags)
|
||||||
{
|
{
|
||||||
auto err = vkResetCommandPool (dev.id (), id (), flags);
|
auto err = vkResetCommandPool (dev.native (), native (), flags);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ device::flush (const VkMappedMemoryRange *first,
|
|||||||
{
|
{
|
||||||
CHECK_LE (first, last);
|
CHECK_LE (first, last);
|
||||||
|
|
||||||
auto err = vkFlushMappedMemoryRanges (id (), trunc_cast<uint32_t> (last - first), first);
|
auto err = vkFlushMappedMemoryRanges (native (), trunc_cast<uint32_t> (last - first), first);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ device::invalidate (const VkMappedMemoryRange *first,
|
|||||||
{
|
{
|
||||||
CHECK_LE (first, last);
|
CHECK_LE (first, last);
|
||||||
|
|
||||||
auto err = vkInvalidateMappedMemoryRanges (id (), trunc_cast<uint32_t> (last - first), first);
|
auto err = vkInvalidateMappedMemoryRanges (native (), trunc_cast<uint32_t> (last - first), first);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ device_memory::map (const device &dev,
|
|||||||
{
|
{
|
||||||
void *res;
|
void *res;
|
||||||
|
|
||||||
auto err = vkMapMemory (dev.id (), id (), offset, size, flags, &res);
|
auto err = vkMapMemory (dev.native (), native (), offset, size, flags, &res);
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
@ -42,7 +42,7 @@ device_memory::map (const device &dev,
|
|||||||
void
|
void
|
||||||
device_memory::unmap (const device &dev)
|
device_memory::unmap (const device &dev)
|
||||||
{
|
{
|
||||||
vkUnmapMemory (dev.id (), id ());
|
vkUnmapMemory (dev.native (), native ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -51,6 +51,6 @@ VkDeviceSize
|
|||||||
device_memory::commitment (const device &dev) const
|
device_memory::commitment (const device &dev) const
|
||||||
{
|
{
|
||||||
VkDeviceSize size;
|
VkDeviceSize size;
|
||||||
vkGetDeviceMemoryCommitment (dev.id (), id (), &size);
|
vkGetDeviceMemoryCommitment (dev.native (), native (), &size);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ using cruft::vk::event;
|
|||||||
bool
|
bool
|
||||||
event::is_set (const device &dev) const
|
event::is_set (const device &dev) const
|
||||||
{
|
{
|
||||||
auto res = vkGetEventStatus (dev.id (), id ());
|
auto res = vkGetEventStatus (dev.native (), native ());
|
||||||
error::try_code (res);
|
error::try_code (res);
|
||||||
return res == VK_EVENT_SET;
|
return res == VK_EVENT_SET;
|
||||||
}
|
}
|
||||||
@ -36,7 +36,7 @@ event::is_set (const device &dev) const
|
|||||||
void
|
void
|
||||||
event::set (const device &dev)
|
event::set (const device &dev)
|
||||||
{
|
{
|
||||||
auto err = vkSetEvent (dev.id (), id ());
|
auto err = vkSetEvent (dev.native (), native ());
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +45,6 @@ event::set (const device &dev)
|
|||||||
void
|
void
|
||||||
event::reset (const device &dev)
|
event::reset (const device &dev)
|
||||||
{
|
{
|
||||||
auto err = vkResetEvent (dev.id (), id ());
|
auto err = vkResetEvent (dev.native (), native ());
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
10
fence.cpp
10
fence.cpp
@ -29,7 +29,7 @@ using cruft::vk::fence;
|
|||||||
bool
|
bool
|
||||||
fence::is_ready (const device &dev)
|
fence::is_ready (const device &dev)
|
||||||
{
|
{
|
||||||
auto res = vkGetFenceStatus (dev.id (), id ());
|
auto res = vkGetFenceStatus (dev.native (), native ());
|
||||||
error::try_code (res);
|
error::try_code (res);
|
||||||
return res == VK_SUCCESS;
|
return res == VK_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -42,7 +42,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.id (), trunc_cast<uint32_t> (last - first), &first->id ()
|
vkResetFences, dev.native (), trunc_cast<uint32_t> (last - first), &first->native ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,7 +54,8 @@ fence::wait (const device &d, fence *first, fence *last, uint64_t timeout)
|
|||||||
CHECK_LE (first, last);
|
CHECK_LE (first, last);
|
||||||
|
|
||||||
cruft::vk::error::try_func (
|
cruft::vk::error::try_func (
|
||||||
vkWaitForFences, d.id (), trunc_cast<uint32_t> (last - first), &first->id (), VK_FALSE, timeout
|
vkWaitForFences,
|
||||||
|
d.native (), trunc_cast<uint32_t> (last - first), &first->native (), VK_FALSE, timeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ fence::wait_all (const device &d, fence *first, fence *last, uint64_t timeout)
|
|||||||
CHECK_LE (first, last);
|
CHECK_LE (first, last);
|
||||||
|
|
||||||
cruft::vk::error::try_func (
|
cruft::vk::error::try_func (
|
||||||
vkWaitForFences, d.id (), trunc_cast<uint32_t> (last - first), &first->id (), VK_TRUE, timeout
|
vkWaitForFences,
|
||||||
|
d.native (), trunc_cast<uint32_t> (last - first), &first->native (), VK_TRUE, timeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ namespace cruft::vk {
|
|||||||
T
|
T
|
||||||
proc (const char *name)
|
proc (const char *name)
|
||||||
{
|
{
|
||||||
auto ret = vkGetInstanceProcAddr (id (), name);
|
auto ret = vkGetInstanceProcAddr (native (), name);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
throw vk::invalid_argument ("invalid procedure name");
|
throw vk::invalid_argument ("invalid procedure name");
|
||||||
|
|
||||||
|
28
object.cpp
28
object.cpp
@ -29,37 +29,37 @@ using cruft::vk::enumerated;
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename T>
|
template <typename T>
|
||||||
object<T>::object (id_t _id):
|
object<T>::object (native_t _native):
|
||||||
m_id (_id)
|
m_native (_native)
|
||||||
{
|
{
|
||||||
CHECK_NEQ (m_id, VK_NULL_HANDLE);
|
CHECK_NEQ (m_native, VK_NULL_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
object<T>::object (object &&rhs):
|
object<T>::object (object &&rhs):
|
||||||
m_id (VK_NULL_HANDLE)
|
m_native (VK_NULL_HANDLE)
|
||||||
{
|
{
|
||||||
std::swap (m_id, rhs.m_id);
|
std::swap (m_native, rhs.m_native);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const typename object<T>::id_t&
|
const typename object<T>::native_t&
|
||||||
object<T>::id (void) const&
|
object<T>::native (void) const&
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_native;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
typename object<T>::id_t&
|
typename object<T>::native_t&
|
||||||
object<T>::id (void) &
|
object<T>::native (void) &
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_native;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -79,12 +79,12 @@ std::vector<T>
|
|||||||
cruft::vk::enumerated<T>::find (const instance &parent) {
|
cruft::vk::enumerated<T>::find (const instance &parent) {
|
||||||
// find the total number of objects
|
// find the total number of objects
|
||||||
uint32_t expected = 0;
|
uint32_t expected = 0;
|
||||||
error::try_code (enum_traits<T>::enumerate (parent.id (), &expected, nullptr));
|
error::try_code (enum_traits<T>::enumerate (parent.native (), &expected, nullptr));
|
||||||
|
|
||||||
// allocate an array of handles and fetch them
|
// allocate an array of handles and fetch them
|
||||||
uint32_t found = expected;
|
uint32_t found = expected;
|
||||||
typename T::id_t handles[expected];
|
typename T::native_t handles[expected];
|
||||||
error::try_code (enum_traits<T>::enumerate (parent.id (), &found, handles));
|
error::try_code (enum_traits<T>::enumerate (parent.native (), &found, handles));
|
||||||
|
|
||||||
// return an collection of objects from the handles
|
// return an collection of objects from the handles
|
||||||
return std::vector<T> (handles, handles + found);
|
return std::vector<T> (handles, handles + found);
|
||||||
|
62
object.hpp
62
object.hpp
@ -29,23 +29,24 @@ namespace cruft::vk {
|
|||||||
/// management.
|
/// management.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct object {
|
struct object {
|
||||||
using id_t = typename id_traits<T>::id_t;
|
using native_t = id_t<T>;
|
||||||
|
|
||||||
object (id_t);
|
object (native_t);
|
||||||
object (object&&);
|
object (object&&);
|
||||||
|
|
||||||
object (const object&) = delete;
|
object (const object&) = delete;
|
||||||
|
|
||||||
const id_t& id (void) const&;
|
const native_t& native (void) const&;
|
||||||
id_t& id (void) &;
|
native_t& native (void) &;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
id_t m_id;
|
native_t m_native;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename SelfT>
|
template <typename SelfT>
|
||||||
struct root : public object<SelfT> {
|
struct root : public object<SelfT> {
|
||||||
using id_t = typename object<SelfT>::id_t;
|
using native_t = typename object<SelfT>::native_t;
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
root (Args &&...args):
|
root (Args &&...args):
|
||||||
@ -54,15 +55,15 @@ namespace cruft::vk {
|
|||||||
|
|
||||||
~root ()
|
~root ()
|
||||||
{
|
{
|
||||||
life_traits<SelfT>::destroy (this->id (), nullptr);
|
life_traits<SelfT>::destroy (this->native (), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
static id_t
|
static native_t
|
||||||
make (Args &&...args)
|
make (Args &&...args)
|
||||||
{
|
{
|
||||||
id_t id;
|
native_t id;
|
||||||
auto res = life_traits<SelfT>::create (std::forward<Args> (args)..., &id);
|
auto res = life_traits<SelfT>::create (std::forward<Args> (args)..., &id);
|
||||||
error::try_code (res);
|
error::try_code (res);
|
||||||
return id;
|
return id;
|
||||||
@ -75,7 +76,7 @@ namespace cruft::vk {
|
|||||||
/// another object.
|
/// another object.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct descendant : public object<T> {
|
struct descendant : public object<T> {
|
||||||
using id_t = typename object<T>::id_t;
|
using native_t = typename object<T>::native_t;
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
descendant (Args &&...args):
|
descendant (Args &&...args):
|
||||||
@ -84,16 +85,16 @@ namespace cruft::vk {
|
|||||||
|
|
||||||
~descendant ()
|
~descendant ()
|
||||||
{
|
{
|
||||||
life_traits<T>::destroy (this->id (), nullptr);
|
life_traits<T>::destroy (this->native (), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename Base, typename ...Args>
|
template <typename Base, typename ...Args>
|
||||||
static
|
static
|
||||||
id_t make (Base &&base, Args &&...args)
|
native_t make (Base &&base, Args &&...args)
|
||||||
{
|
{
|
||||||
id_t id;
|
native_t id;
|
||||||
auto res = life_traits<T>::create (base.id (), std::forward<Args> (args)..., &id);
|
auto res = life_traits<T>::create (base.native (), std::forward<Args> (args)..., &id);
|
||||||
error::try_code (res);
|
error::try_code (res);
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -116,30 +117,45 @@ namespace cruft::vk {
|
|||||||
/// the parent object.
|
/// the parent object.
|
||||||
template <typename SelfT, typename OwnerT>
|
template <typename SelfT, typename OwnerT>
|
||||||
struct owned : public object<SelfT> {
|
struct owned : public object<SelfT> {
|
||||||
using id_t = typename object<SelfT>::id_t;
|
using native_t = typename object<SelfT>::native_t;
|
||||||
using owner_t = OwnerT;
|
using owner_t = OwnerT;
|
||||||
|
|
||||||
using object<SelfT>::object;
|
using object<SelfT>::object;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
owned (Args &&...args):
|
owned (OwnerT &owner, Args &&...args):
|
||||||
object<SelfT> (make (std::forward<Args> (args)...))
|
object<SelfT> (
|
||||||
|
error::try_query (
|
||||||
|
life_traits<SelfT>::create,
|
||||||
|
owner.native (),
|
||||||
|
std::forward<Args> (args)...
|
||||||
|
)
|
||||||
|
)
|
||||||
{ ; }
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
owned (owned &&rhs):
|
||||||
|
object<SelfT> (std::move (rhs))
|
||||||
|
{ ; }
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
~owned ()
|
~owned ()
|
||||||
{
|
{
|
||||||
CHECK_EQ (this->id (), VK_NULL_HANDLE);
|
CHECK_EQ (this->native (), VK_NULL_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
destroy (OwnerT &parent)
|
destroy (OwnerT &owner)
|
||||||
{
|
{
|
||||||
life_traits<SelfT>::destroy (parent.id (), this->id (), nullptr);
|
life_traits<SelfT>::destroy (owner.native (), this->native (), nullptr);
|
||||||
this->m_id = VK_NULL_HANDLE;
|
this->m_native = VK_NULL_HANDLE;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -152,6 +168,6 @@ namespace cruft::vk {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,11 +28,11 @@ std::set<std::string>
|
|||||||
physical_device::extensions (void) const
|
physical_device::extensions (void) const
|
||||||
{
|
{
|
||||||
uint32_t expected = 0;
|
uint32_t expected = 0;
|
||||||
error::try_code (vkEnumerateDeviceExtensionProperties (id (), nullptr, &expected, nullptr));
|
error::try_code (vkEnumerateDeviceExtensionProperties (native (), nullptr, &expected, nullptr));
|
||||||
|
|
||||||
VkExtensionProperties props[expected];
|
VkExtensionProperties props[expected];
|
||||||
uint32_t found = expected;
|
uint32_t found = expected;
|
||||||
error::try_code (vkEnumerateDeviceExtensionProperties (id (), nullptr, &found, props));
|
error::try_code (vkEnumerateDeviceExtensionProperties (native (), nullptr, &found, props));
|
||||||
|
|
||||||
std::set<std::string> ext;
|
std::set<std::string> ext;
|
||||||
for (const auto &i: props)
|
for (const auto &i: props)
|
||||||
@ -45,7 +45,7 @@ VkPhysicalDeviceProperties
|
|||||||
physical_device::properties (void) const
|
physical_device::properties (void) const
|
||||||
{
|
{
|
||||||
VkPhysicalDeviceProperties props;
|
VkPhysicalDeviceProperties props;
|
||||||
vkGetPhysicalDeviceProperties (id (), &props);
|
vkGetPhysicalDeviceProperties (native (), &props);
|
||||||
return props;
|
return props;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ VkPhysicalDeviceFeatures
|
|||||||
physical_device::features (void) const
|
physical_device::features (void) const
|
||||||
{
|
{
|
||||||
VkPhysicalDeviceFeatures feat;
|
VkPhysicalDeviceFeatures feat;
|
||||||
vkGetPhysicalDeviceFeatures (id (), &feat);
|
vkGetPhysicalDeviceFeatures (native (), &feat);
|
||||||
return feat;
|
return feat;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ VkSurfaceCapabilitiesKHR
|
|||||||
physical_device::surface_capabilities (surface &_surface) const
|
physical_device::surface_capabilities (surface &_surface) const
|
||||||
{
|
{
|
||||||
return error::try_query (
|
return error::try_query (
|
||||||
vkGetPhysicalDeviceSurfaceCapabilitiesKHR, id (), _surface.id ()
|
vkGetPhysicalDeviceSurfaceCapabilitiesKHR, native (), _surface.native ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ VkPhysicalDeviceMemoryProperties
|
|||||||
physical_device::memory_properties (void) const
|
physical_device::memory_properties (void) const
|
||||||
{
|
{
|
||||||
return error::try_query (
|
return error::try_query (
|
||||||
vkGetPhysicalDeviceMemoryProperties, id ()
|
vkGetPhysicalDeviceMemoryProperties, native ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,10 +85,10 @@ std::vector<VkQueueFamilyProperties>
|
|||||||
physical_device::queue_families (void) const
|
physical_device::queue_families (void) const
|
||||||
{
|
{
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties (id (), &count, nullptr);
|
vkGetPhysicalDeviceQueueFamilyProperties (native (), &count, nullptr);
|
||||||
|
|
||||||
std::vector<VkQueueFamilyProperties> values (count);
|
std::vector<VkQueueFamilyProperties> values (count);
|
||||||
vkGetPhysicalDeviceQueueFamilyProperties (id (), &count, values.data ());
|
vkGetPhysicalDeviceQueueFamilyProperties (native (), &count, values.data ());
|
||||||
|
|
||||||
values.resize (count);
|
values.resize (count);
|
||||||
return values;
|
return values;
|
||||||
@ -101,7 +101,7 @@ physical_device::surface_formats (surface &_surface)
|
|||||||
{
|
{
|
||||||
return error::try_array (
|
return error::try_array (
|
||||||
vkGetPhysicalDeviceSurfaceFormatsKHR,
|
vkGetPhysicalDeviceSurfaceFormatsKHR,
|
||||||
id (), _surface.id ()
|
native (), _surface.native ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ physical_device::present_modes (surface &_surface)
|
|||||||
{
|
{
|
||||||
return error::try_array (
|
return error::try_array (
|
||||||
vkGetPhysicalDeviceSurfacePresentModesKHR,
|
vkGetPhysicalDeviceSurfacePresentModesKHR,
|
||||||
id (), _surface.id ()
|
native (), _surface.native ()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ using cruft::vk::queue;
|
|||||||
void
|
void
|
||||||
queue::wait_idle (void)
|
queue::wait_idle (void)
|
||||||
{
|
{
|
||||||
auto err = vkQueueWaitIdle (id ());
|
auto err = vkQueueWaitIdle (native ());
|
||||||
error::try_code (err);
|
error::try_code (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ create_shader (cruft::vk::device &dev, const std::experimental::filesystem::path
|
|||||||
|
|
||||||
VkShaderModule value;
|
VkShaderModule value;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateShaderModule (dev.id (), &create_info, nullptr, &value)
|
vkCreateShaderModule (dev.native (), &create_info, nullptr, &value)
|
||||||
);
|
);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
@ -121,21 +121,20 @@ main (void)
|
|||||||
;
|
;
|
||||||
debug_info.pfnCallback = vk_debug_callback;
|
debug_info.pfnCallback = vk_debug_callback;
|
||||||
|
|
||||||
auto func = (decltype(&vkCreateDebugReportCallbackEXT))vkGetInstanceProcAddr (instance.id (),"vkCreateDebugReportCallbackEXT");
|
auto func = (decltype(&vkCreateDebugReportCallbackEXT))vkGetInstanceProcAddr (instance.native (),"vkCreateDebugReportCallbackEXT");
|
||||||
|
|
||||||
cruft::vk::error::try_func (
|
cruft::vk::error::try_func (
|
||||||
*func, instance.id (), &debug_info, nullptr, &callback
|
*func, instance.native (), &debug_info, nullptr, &callback
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pdevices = cruft::vk::physical_device::find (instance);
|
auto pdevices = cruft::vk::physical_device::find (instance);
|
||||||
auto &pdevice = pdevices[0];
|
auto &pdevice = pdevices[0];
|
||||||
|
|
||||||
cruft::vk::surface surface {
|
VkSurfaceKHR surface_handle = cruft::vk::error::try_query (
|
||||||
cruft::vk::error::try_query (
|
glfwCreateWindowSurface, instance.native (), window, nullptr
|
||||||
glfwCreateWindowSurface, instance.id (), window, nullptr
|
);
|
||||||
)
|
cruft::vk::surface surface { surface_handle };
|
||||||
};
|
|
||||||
|
|
||||||
auto surface_capabilities = pdevice.surface_capabilities (surface);
|
auto surface_capabilities = pdevice.surface_capabilities (surface);
|
||||||
auto surface_formats = pdevice.surface_formats (surface);
|
auto surface_formats = pdevice.surface_formats (surface);
|
||||||
@ -152,7 +151,7 @@ main (void)
|
|||||||
|
|
||||||
for (int i = 0, last = queues.size (); i != last; ++i) {
|
for (int i = 0, last = queues.size (); i != last; ++i) {
|
||||||
if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR,
|
if (cruft::vk::error::try_query (vkGetPhysicalDeviceSurfaceSupportKHR,
|
||||||
pdevice.id (), i, surface.id ())) {
|
pdevice.native (), i, surface.native ())) {
|
||||||
present_queue_id = i;
|
present_queue_id = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -229,7 +228,7 @@ main (void)
|
|||||||
.sType = cruft::vk::structure_type_v<VkSwapchainCreateInfoKHR>,
|
.sType = cruft::vk::structure_type_v<VkSwapchainCreateInfoKHR>,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.flags = {},
|
.flags = {},
|
||||||
.surface = surface.id (),
|
.surface = surface.native (),
|
||||||
.minImageCount = image_count,
|
.minImageCount = image_count,
|
||||||
.imageFormat = surface_format.format,
|
.imageFormat = surface_format.format,
|
||||||
.imageColorSpace = surface_format.colorSpace,
|
.imageColorSpace = surface_format.colorSpace,
|
||||||
@ -248,15 +247,15 @@ main (void)
|
|||||||
|
|
||||||
VkSwapchainKHR swapchain;
|
VkSwapchainKHR swapchain;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateSwapchainKHR (ldevice.id (), &swap_create_info, nullptr, &swapchain)
|
vkCreateSwapchainKHR (ldevice.native (), &swap_create_info, nullptr, &swapchain)
|
||||||
);
|
);
|
||||||
|
|
||||||
uint32_t swap_image_count = 0;
|
uint32_t swap_image_count = 0;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkGetSwapchainImagesKHR (ldevice.id (), swapchain, &swap_image_count, nullptr)
|
vkGetSwapchainImagesKHR (ldevice.native (), swapchain, &swap_image_count, nullptr)
|
||||||
);
|
);
|
||||||
std::vector<VkImage> swap_images = cruft::vk::error::try_array (
|
std::vector<VkImage> swap_images = cruft::vk::error::try_array (
|
||||||
vkGetSwapchainImagesKHR, ldevice.id (), swapchain
|
vkGetSwapchainImagesKHR, ldevice.native (), swapchain
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<VkImageView> swap_image_views (swap_image_count);
|
std::vector<VkImageView> swap_image_views (swap_image_count);
|
||||||
@ -286,13 +285,14 @@ main (void)
|
|||||||
|
|
||||||
VkImageView v;
|
VkImageView v;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateImageView (ldevice.id (), &create_info, nullptr, &v)
|
vkCreateImageView (ldevice.native (), &create_info, nullptr, &v)
|
||||||
);
|
);
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
});
|
});
|
||||||
|
|
||||||
auto graphics_queue = ldevice.queue (graphics_queue_id);
|
auto _graphics_queue = ldevice.queue (graphics_queue_id);
|
||||||
|
auto graphics_queue = &_graphics_queue;
|
||||||
auto present_queue = ldevice.queue (present_queue_id);
|
auto present_queue = ldevice.queue (present_queue_id);
|
||||||
|
|
||||||
auto vert_module = create_shader (ldevice, "./hello.vert.spv");
|
auto vert_module = create_shader (ldevice, "./hello.vert.spv");
|
||||||
@ -305,11 +305,11 @@ main (void)
|
|||||||
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
buffer_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
|
|
||||||
VkBuffer vertex_buffer = cruft::vk::error::try_query (
|
VkBuffer vertex_buffer = cruft::vk::error::try_query (
|
||||||
vkCreateBuffer, ldevice.id (), &buffer_info, nullptr
|
vkCreateBuffer, ldevice.native (), &buffer_info, nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
auto memory_requirements = cruft::vk::error::try_query (
|
auto memory_requirements = cruft::vk::error::try_query (
|
||||||
vkGetBufferMemoryRequirements, ldevice.id (), vertex_buffer
|
vkGetBufferMemoryRequirements, ldevice.native (), vertex_buffer
|
||||||
);
|
);
|
||||||
|
|
||||||
auto memory_properties = pdevice.memory_properties ();
|
auto memory_properties = pdevice.memory_properties ();
|
||||||
@ -327,18 +327,18 @@ main (void)
|
|||||||
} ();
|
} ();
|
||||||
|
|
||||||
auto vertex_memory = cruft::vk::error::try_query (
|
auto vertex_memory = cruft::vk::error::try_query (
|
||||||
vkAllocateMemory, ldevice.id (), &allocate_info, nullptr
|
vkAllocateMemory, ldevice.native (), &allocate_info, nullptr
|
||||||
);
|
);
|
||||||
|
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkBindBufferMemory (ldevice.id (), vertex_buffer, vertex_memory, 0)
|
vkBindBufferMemory (ldevice.native (), vertex_buffer, vertex_memory, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
auto data = cruft::vk::error::try_query (
|
auto data = cruft::vk::error::try_query (
|
||||||
vkMapMemory, ldevice.id (), vertex_memory, 0, buffer_info.size, 0
|
vkMapMemory, ldevice.native (), vertex_memory, 0, buffer_info.size, 0
|
||||||
);
|
);
|
||||||
memcpy (data, std::data (VERTICES), sizeof (VERTICES));
|
memcpy (data, std::data (VERTICES), sizeof (VERTICES));
|
||||||
vkUnmapMemory (ldevice.id (), vertex_memory);
|
vkUnmapMemory (ldevice.native (), vertex_memory);
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo vert_stage_info {};
|
VkPipelineShaderStageCreateInfo vert_stage_info {};
|
||||||
vert_stage_info.sType = cruft::vk::structure_type_v<VkPipelineShaderStageCreateInfo>;
|
vert_stage_info.sType = cruft::vk::structure_type_v<VkPipelineShaderStageCreateInfo>;
|
||||||
@ -455,7 +455,7 @@ main (void)
|
|||||||
|
|
||||||
VkPipelineLayout pipeline_layout;
|
VkPipelineLayout pipeline_layout;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreatePipelineLayout (ldevice.id (), &pipeline_layout_info, nullptr, &pipeline_layout)
|
vkCreatePipelineLayout (ldevice.native (), &pipeline_layout_info, nullptr, &pipeline_layout)
|
||||||
);
|
);
|
||||||
|
|
||||||
VkAttachmentDescription color_attachment {};
|
VkAttachmentDescription color_attachment {};
|
||||||
@ -486,7 +486,7 @@ main (void)
|
|||||||
|
|
||||||
VkRenderPass render_pass;
|
VkRenderPass render_pass;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateRenderPass (ldevice.id (), &render_pass_info, nullptr, &render_pass)
|
vkCreateRenderPass (ldevice.native (), &render_pass_info, nullptr, &render_pass)
|
||||||
);
|
);
|
||||||
|
|
||||||
VkGraphicsPipelineCreateInfo pipeline_info {};
|
VkGraphicsPipelineCreateInfo pipeline_info {};
|
||||||
@ -509,7 +509,7 @@ main (void)
|
|||||||
VkPipeline graphics_pipeline;
|
VkPipeline graphics_pipeline;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateGraphicsPipelines (
|
vkCreateGraphicsPipelines (
|
||||||
ldevice.id (), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &graphics_pipeline
|
ldevice.native (), VK_NULL_HANDLE, 1, &pipeline_info, nullptr, &graphics_pipeline
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -530,7 +530,7 @@ main (void)
|
|||||||
framebuffer_info.layers = 1;
|
framebuffer_info.layers = 1;
|
||||||
|
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateFramebuffer (ldevice.id (), &framebuffer_info, nullptr, &swapchain_framebuffers[i])
|
vkCreateFramebuffer (ldevice.native (), &framebuffer_info, nullptr, &swapchain_framebuffers[i])
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ main (void)
|
|||||||
|
|
||||||
VkCommandPool command_pool;
|
VkCommandPool command_pool;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateCommandPool (ldevice.id (), &pool_info, nullptr, &command_pool)
|
vkCreateCommandPool (ldevice.native (), &pool_info, nullptr, &command_pool)
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<VkCommandBuffer> command_buffers (swapchain_framebuffers.size ());
|
std::vector<VkCommandBuffer> command_buffers (swapchain_framebuffers.size ());
|
||||||
@ -550,7 +550,7 @@ main (void)
|
|||||||
alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
|
||||||
alloc_info.commandBufferCount = (uint32_t) command_buffers.size();
|
alloc_info.commandBufferCount = (uint32_t) command_buffers.size();
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkAllocateCommandBuffers (ldevice.id (), &alloc_info, command_buffers.data ())
|
vkAllocateCommandBuffers (ldevice.native (), &alloc_info, command_buffers.data ())
|
||||||
);
|
);
|
||||||
|
|
||||||
for (size_t i = 0; i < command_buffers.size (); ++i) {
|
for (size_t i = 0; i < command_buffers.size (); ++i) {
|
||||||
@ -591,16 +591,16 @@ main (void)
|
|||||||
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
|
||||||
VkSemaphore image_semaphore, render_semaphore;
|
VkSemaphore image_semaphore, render_semaphore;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateSemaphore (ldevice.id (), &semaphore_info, nullptr, &image_semaphore)
|
vkCreateSemaphore (ldevice.native (), &semaphore_info, nullptr, &image_semaphore)
|
||||||
);
|
);
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkCreateSemaphore (ldevice.id (), &semaphore_info, nullptr, &render_semaphore)
|
vkCreateSemaphore (ldevice.native (), &semaphore_info, nullptr, &render_semaphore)
|
||||||
);
|
);
|
||||||
|
|
||||||
uint32_t image_index;
|
uint32_t image_index;
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkAcquireNextImageKHR (
|
vkAcquireNextImageKHR (
|
||||||
ldevice.id (), swapchain,
|
ldevice.native (), swapchain,
|
||||||
std::numeric_limits<uint64_t>::max (),
|
std::numeric_limits<uint64_t>::max (),
|
||||||
image_semaphore, VK_NULL_HANDLE,
|
image_semaphore, VK_NULL_HANDLE,
|
||||||
&image_index
|
&image_index
|
||||||
@ -622,7 +622,7 @@ main (void)
|
|||||||
submit_info.pSignalSemaphores = signal_semaphores;
|
submit_info.pSignalSemaphores = signal_semaphores;
|
||||||
|
|
||||||
cruft::vk::error::try_code (
|
cruft::vk::error::try_code (
|
||||||
vkQueueSubmit (graphics_queue.id (), 1, &submit_info, VK_NULL_HANDLE)
|
vkQueueSubmit (graphics_queue->native (), 1, &submit_info, VK_NULL_HANDLE)
|
||||||
);
|
);
|
||||||
|
|
||||||
VkSubpassDependency dependency {};
|
VkSubpassDependency dependency {};
|
||||||
@ -645,14 +645,14 @@ main (void)
|
|||||||
present_info.pImageIndices = &image_index;
|
present_info.pImageIndices = &image_index;
|
||||||
present_info.pResults = nullptr;
|
present_info.pResults = nullptr;
|
||||||
|
|
||||||
cruft::vk::error::try_func (vkQueuePresentKHR, present_queue.id (), &present_info);
|
cruft::vk::error::try_func (vkQueuePresentKHR, present_queue.native (), &present_info);
|
||||||
|
|
||||||
LOG_INFO ("entering runloop");
|
LOG_INFO ("entering runloop");
|
||||||
while (!glfwWindowShouldClose (window)) {
|
while (!glfwWindowShouldClose (window)) {
|
||||||
glfwPollEvents ();
|
glfwPollEvents ();
|
||||||
}
|
}
|
||||||
|
|
||||||
cruft::vk::error::try_func (vkDeviceWaitIdle, ldevice.id ());
|
cruft::vk::error::try_func (vkDeviceWaitIdle, ldevice.native ());
|
||||||
|
|
||||||
LOG_INFO ("terminating glfw");
|
LOG_INFO ("terminating glfw");
|
||||||
glfwDestroyWindow (window);
|
glfwDestroyWindow (window);
|
||||||
|
Loading…
Reference in New Issue
Block a user