Browse Source

Use Wrapper for most wrappers.

master
Draklaw 4 years ago
parent
commit
b8a15406da
  1. 20
      src/vk/Buffer.cpp
  2. 27
      src/vk/Buffer.h
  3. 6
      src/vk/CommandBuffer.cpp
  4. 28
      src/vk/CommandBuffer.h
  5. 6
      src/vk/CommandPool.cpp
  6. 26
      src/vk/CommandPool.h
  7. 6
      src/vk/DescriptorPool.cpp
  8. 26
      src/vk/DescriptorPool.h
  9. 6
      src/vk/DescriptorSetLayout.cpp
  10. 26
      src/vk/DescriptorSetLayout.h
  11. 6
      src/vk/Fence.cpp
  12. 26
      src/vk/Fence.h
  13. 6
      src/vk/Framebuffer.cpp
  14. 26
      src/vk/Framebuffer.h
  15. 6
      src/vk/ImageView.cpp
  16. 26
      src/vk/ImageView.h
  17. 8
      src/vk/Pipeline.cpp
  18. 26
      src/vk/Pipeline.h
  19. 6
      src/vk/PipelineLayout.cpp
  20. 26
      src/vk/PipelineLayout.h
  21. 6
      src/vk/RenderPass.cpp
  22. 18
      src/vk/RenderPass.h
  23. 6
      src/vk/Semaphore.cpp
  24. 26
      src/vk/Semaphore.h
  25. 6
      src/vk/ShaderModule.cpp
  26. 30
      src/vk/ShaderModule.h

20
src/vk/Buffer.cpp

@ -21,7 +21,7 @@ Buffer::Buffer(
VkDeviceSize size, VkDeviceSize size,
VkBufferUsageFlags usage VkBufferUsageFlags usage
) )
: m_context(&context) : Wrapper(context)
{ {
assert(*m_context); assert(*m_context);
@ -51,13 +51,8 @@ Buffer::Buffer(
allocate_and_bind_memory(memory_properties); allocate_and_bind_memory(memory_properties);
} }
Buffer::Buffer(Buffer&& other) noexcept Buffer::Buffer(Buffer&& other) noexcept {
: m_context(other.m_context) swap(other);
, m_buffer(other.m_buffer)
, m_memory(std::move(other.m_memory))
{
other.m_context = nullptr;
other.m_buffer = VK_NULL_HANDLE;
} }
Buffer::~Buffer() noexcept { Buffer::~Buffer() noexcept {
@ -68,12 +63,9 @@ Buffer::~Buffer() noexcept {
} }
Buffer& Buffer::operator=(Buffer&& other) noexcept { Buffer& Buffer::operator=(Buffer&& other) noexcept {
if(&other != this) { swap(other);
using std::swap; if(other)
swap(m_context, other.m_context); other.destroy();
swap(m_buffer, other.m_buffer);
swap(m_memory, other.m_memory);
}
return *this; return *this;
} }

27
src/vk/Buffer.h

@ -3,6 +3,7 @@
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Memory.h> #include <vk/Memory.h>
#include <vk/Wrapper.h>
#include <core/utils.h> #include <core/utils.h>
@ -15,7 +16,7 @@
namespace vk { namespace vk {
class Buffer { class Buffer: public Wrapper {
public: public:
Buffer() noexcept; Buffer() noexcept;
Buffer( Buffer(
@ -29,11 +30,11 @@ public:
VkBufferUsageFlags usage, VkBufferUsageFlags usage,
VkMemoryPropertyFlags memory_properties VkMemoryPropertyFlags memory_properties
); );
Buffer(const Buffer&) = delete; Buffer(const Buffer&) = default;
Buffer(Buffer&& other) noexcept; Buffer(Buffer&& other) noexcept;
~Buffer() noexcept; ~Buffer() noexcept;
Buffer& operator=(const Buffer&) = delete; Buffer& operator=(const Buffer&) = default;
Buffer& operator=(Buffer&& other) noexcept; Buffer& operator=(Buffer&& other) noexcept;
inline explicit operator bool() const { inline explicit operator bool() const {
@ -44,14 +45,6 @@ public:
return m_buffer == VK_NULL_HANDLE; return m_buffer == VK_NULL_HANDLE;
} }
inline Context* context() noexcept {
return m_context;
}
inline const Context* context() const noexcept {
return m_context;
}
inline operator VkBuffer() const noexcept { inline operator VkBuffer() const noexcept {
return m_buffer; return m_buffer;
} }
@ -76,10 +69,20 @@ public:
void upload(size_t size, void* src_buffer, uint32_t dst_queue_family); void upload(size_t size, void* src_buffer, uint32_t dst_queue_family);
inline void swap(Buffer& other) noexcept {
using std::swap;
Wrapper::swap(other);
swap(m_buffer, other.m_buffer);
swap(m_memory, other.m_memory);
}
friend inline void swap(Buffer& buffer_0, Buffer& buffer_1) noexcept {
buffer_0.swap(buffer_1);
}
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkBuffer m_buffer = VK_NULL_HANDLE; VkBuffer m_buffer = VK_NULL_HANDLE;
MemoryBlock m_memory; MemoryBlock m_memory;
}; };

6
src/vk/CommandBuffer.cpp

@ -13,7 +13,7 @@ CommandBuffer::CommandBuffer() noexcept {
} }
CommandBuffer::CommandBuffer(Context& context, VkCommandPool command_pool, VkCommandBufferLevel level) CommandBuffer::CommandBuffer(Context& context, VkCommandPool command_pool, VkCommandBufferLevel level)
: m_context(&context) : Wrapper(context)
, m_command_pool(command_pool) , m_command_pool(command_pool)
{ {
assert(m_context); assert(m_context);
@ -35,7 +35,7 @@ CommandBuffer::CommandBuffer(Context& context, VkCommandPool command_pool, VkCom
CommandBuffer::CommandBuffer(CommandBuffer&& other) noexcept CommandBuffer::CommandBuffer(CommandBuffer&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
CommandBuffer::~CommandBuffer() noexcept { CommandBuffer::~CommandBuffer() noexcept {
@ -45,7 +45,7 @@ CommandBuffer::~CommandBuffer() noexcept {
CommandBuffer& CommandBuffer::operator=(CommandBuffer&& other) noexcept { CommandBuffer& CommandBuffer::operator=(CommandBuffer&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

28
src/vk/CommandBuffer.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,15 +10,15 @@
namespace vk { namespace vk {
class CommandBuffer { class CommandBuffer: public Wrapper {
public: public:
CommandBuffer() noexcept; CommandBuffer() noexcept;
CommandBuffer(Context& context, VkCommandPool command_pool, VkCommandBufferLevel level=VK_COMMAND_BUFFER_LEVEL_PRIMARY); CommandBuffer(Context& context, VkCommandPool command_pool, VkCommandBufferLevel level=VK_COMMAND_BUFFER_LEVEL_PRIMARY);
CommandBuffer(const CommandBuffer&) = delete; CommandBuffer(const CommandBuffer&) = default;
CommandBuffer(CommandBuffer&& other) noexcept; CommandBuffer(CommandBuffer&& other) noexcept;
~CommandBuffer() noexcept; ~CommandBuffer() noexcept;
CommandBuffer& operator=(const CommandBuffer&) = delete; CommandBuffer& operator=(const CommandBuffer&) = default;
CommandBuffer& operator=(CommandBuffer&& other) noexcept; CommandBuffer& operator=(CommandBuffer&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -28,14 +29,6 @@ public:
return m_command_buffer == VK_NULL_HANDLE; return m_command_buffer == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline const VkCommandPool command_pool() const noexcept { inline const VkCommandPool command_pool() const noexcept {
return m_command_pool; return m_command_pool;
} }
@ -52,17 +45,20 @@ public:
return m_command_buffer; return m_command_buffer;
} }
friend inline void swap(CommandBuffer& command_buffer_0, CommandBuffer& command_buffer_1) noexcept { inline void swap(CommandBuffer& other) noexcept {
using std::swap; using std::swap;
swap(command_buffer_0.m_context, command_buffer_1.m_context); Wrapper::swap(other);
swap(command_buffer_0.m_command_pool, command_buffer_1.m_command_pool); swap(m_command_pool, other.m_command_pool);
swap(command_buffer_0.m_command_buffer, command_buffer_1.m_command_buffer); swap(m_command_buffer, other.m_command_buffer);
}
friend inline void swap(CommandBuffer& command_buffer_0, CommandBuffer& command_buffer_1) noexcept {
command_buffer_0.swap(command_buffer_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkCommandPool m_command_pool = VK_NULL_HANDLE; VkCommandPool m_command_pool = VK_NULL_HANDLE;
VkCommandBuffer m_command_buffer = VK_NULL_HANDLE; VkCommandBuffer m_command_buffer = VK_NULL_HANDLE;
}; };

6
src/vk/CommandPool.cpp

@ -13,7 +13,7 @@ CommandPool::CommandPool() noexcept {
} }
CommandPool::CommandPool(Context& context, uint32_t queue_family, VkCommandPoolCreateFlags flags) CommandPool::CommandPool(Context& context, uint32_t queue_family, VkCommandPoolCreateFlags flags)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -33,7 +33,7 @@ CommandPool::CommandPool(Context& context, uint32_t queue_family, VkCommandPoolC
CommandPool::CommandPool(CommandPool&& other) noexcept CommandPool::CommandPool(CommandPool&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
CommandPool::~CommandPool() noexcept { CommandPool::~CommandPool() noexcept {
@ -43,7 +43,7 @@ CommandPool::~CommandPool() noexcept {
CommandPool& CommandPool::operator=(CommandPool&& other) noexcept { CommandPool& CommandPool::operator=(CommandPool&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/CommandPool.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,15 +10,15 @@
namespace vk { namespace vk {
class CommandPool { class CommandPool: public Wrapper {
public: public:
CommandPool() noexcept; CommandPool() noexcept;
CommandPool(Context& context, uint32_t queue_family, VkCommandPoolCreateFlags flags=0); CommandPool(Context& context, uint32_t queue_family, VkCommandPoolCreateFlags flags=0);
CommandPool(const CommandPool&) = delete; CommandPool(const CommandPool&) = default;
CommandPool(CommandPool&& other) noexcept; CommandPool(CommandPool&& other) noexcept;
~CommandPool() noexcept; ~CommandPool() noexcept;
CommandPool& operator=(const CommandPool&) = delete; CommandPool& operator=(const CommandPool&) = default;
CommandPool& operator=(CommandPool&& other) noexcept; CommandPool& operator=(CommandPool&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -28,14 +29,6 @@ public:
return m_command_pool == VK_NULL_HANDLE; return m_command_pool == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkCommandPool() noexcept { inline operator VkCommandPool() noexcept {
return m_command_pool; return m_command_pool;
} }
@ -44,16 +37,19 @@ public:
return m_command_pool; return m_command_pool;
} }
friend inline void swap(CommandPool& command_pool_0, CommandPool& command_pool_1) noexcept { inline void swap(CommandPool& other) noexcept {
using std::swap; using std::swap;
swap(command_pool_0.m_context, command_pool_1.m_context); Wrapper::swap(other);
swap(command_pool_0.m_command_pool, command_pool_1.m_command_pool); swap(m_command_pool, other.m_command_pool);
}
friend inline void swap(CommandPool& command_pool_0, CommandPool& command_pool_1) noexcept {
command_pool_0.swap(command_pool_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkCommandPool m_command_pool = VK_NULL_HANDLE; VkCommandPool m_command_pool = VK_NULL_HANDLE;
}; };

6
src/vk/DescriptorPool.cpp

@ -18,7 +18,7 @@ DescriptorPool::DescriptorPool(
Array<const VkDescriptorPoolSize> pool_sizes, Array<const VkDescriptorPoolSize> pool_sizes,
VkDescriptorPoolCreateFlags flags VkDescriptorPoolCreateFlags flags
) )
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -40,7 +40,7 @@ DescriptorPool::DescriptorPool(
DescriptorPool::DescriptorPool(DescriptorPool&& other) noexcept DescriptorPool::DescriptorPool(DescriptorPool&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
DescriptorPool::~DescriptorPool() noexcept { DescriptorPool::~DescriptorPool() noexcept {
@ -50,7 +50,7 @@ DescriptorPool::~DescriptorPool() noexcept {
DescriptorPool& DescriptorPool::operator=(DescriptorPool&& other) noexcept { DescriptorPool& DescriptorPool::operator=(DescriptorPool&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/DescriptorPool.h

@ -4,6 +4,7 @@
#include <core/utils.h> #include <core/utils.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -11,7 +12,7 @@
namespace vk { namespace vk {
class DescriptorPool { class DescriptorPool: public Wrapper {
public: public:
DescriptorPool() noexcept; DescriptorPool() noexcept;
DescriptorPool( DescriptorPool(
@ -20,11 +21,11 @@ public:
Array<const VkDescriptorPoolSize> pool_sizes, Array<const VkDescriptorPoolSize> pool_sizes,
VkDescriptorPoolCreateFlags flags=0 VkDescriptorPoolCreateFlags flags=0
); );
DescriptorPool(const DescriptorPool&) = delete; DescriptorPool(const DescriptorPool&) = default;
DescriptorPool(DescriptorPool&& other) noexcept; DescriptorPool(DescriptorPool&& other) noexcept;
~DescriptorPool() noexcept; ~DescriptorPool() noexcept;
DescriptorPool& operator=(const DescriptorPool&) = delete; DescriptorPool& operator=(const DescriptorPool&) = default;
DescriptorPool& operator=(DescriptorPool&& other) noexcept; DescriptorPool& operator=(DescriptorPool&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -35,14 +36,6 @@ public:
return m_descriptor_pool == VK_NULL_HANDLE; return m_descriptor_pool == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkDescriptorPool() noexcept { inline operator VkDescriptorPool() noexcept {
return m_descriptor_pool; return m_descriptor_pool;
} }
@ -51,16 +44,19 @@ public:
return m_descriptor_pool; return m_descriptor_pool;
} }
friend inline void swap(DescriptorPool& descriptor_pool_0, DescriptorPool& descriptor_pool_1) noexcept { inline void swap(DescriptorPool& other) noexcept {
using std::swap; using std::swap;
swap(descriptor_pool_0.m_context, descriptor_pool_1.m_context); Wrapper::swap(other);
swap(descriptor_pool_0.m_descriptor_pool, descriptor_pool_1.m_descriptor_pool); swap(m_descriptor_pool, other.m_descriptor_pool);
}
friend inline void swap(DescriptorPool& descriptor_pool_0, DescriptorPool& descriptor_pool_1) noexcept {
descriptor_pool_0.swap(descriptor_pool_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkDescriptorPool m_descriptor_pool = VK_NULL_HANDLE; VkDescriptorPool m_descriptor_pool = VK_NULL_HANDLE;
}; };

6
src/vk/DescriptorSetLayout.cpp

@ -13,7 +13,7 @@ DescriptorSetLayout::DescriptorSetLayout() noexcept {
} }
DescriptorSetLayout::DescriptorSetLayout(Context& context, Array<const VkDescriptorSetLayoutBinding> bindings) DescriptorSetLayout::DescriptorSetLayout(Context& context, Array<const VkDescriptorSetLayoutBinding> bindings)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -33,7 +33,7 @@ DescriptorSetLayout::DescriptorSetLayout(Context& context, Array<const VkDescrip
DescriptorSetLayout::DescriptorSetLayout(DescriptorSetLayout&& other) noexcept DescriptorSetLayout::DescriptorSetLayout(DescriptorSetLayout&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
DescriptorSetLayout::~DescriptorSetLayout() noexcept { DescriptorSetLayout::~DescriptorSetLayout() noexcept {
@ -43,7 +43,7 @@ DescriptorSetLayout::~DescriptorSetLayout() noexcept {
DescriptorSetLayout& DescriptorSetLayout::operator=(DescriptorSetLayout&& other) noexcept { DescriptorSetLayout& DescriptorSetLayout::operator=(DescriptorSetLayout&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/DescriptorSetLayout.h

@ -4,6 +4,7 @@
#include <core/utils.h> #include <core/utils.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -11,15 +12,15 @@
namespace vk { namespace vk {
class DescriptorSetLayout { class DescriptorSetLayout: public Wrapper {
public: public:
DescriptorSetLayout() noexcept; DescriptorSetLayout() noexcept;
DescriptorSetLayout(Context& context, Array<const VkDescriptorSetLayoutBinding> bindings); DescriptorSetLayout(Context& context, Array<const VkDescriptorSetLayoutBinding> bindings);
DescriptorSetLayout(const DescriptorSetLayout&) = delete; DescriptorSetLayout(const DescriptorSetLayout&) = default;
DescriptorSetLayout(DescriptorSetLayout&& other) noexcept; DescriptorSetLayout(DescriptorSetLayout&& other) noexcept;
~DescriptorSetLayout() noexcept; ~DescriptorSetLayout() noexcept;
DescriptorSetLayout& operator=(const DescriptorSetLayout&) = delete; DescriptorSetLayout& operator=(const DescriptorSetLayout&) = default;
DescriptorSetLayout& operator=(DescriptorSetLayout&& other) noexcept; DescriptorSetLayout& operator=(DescriptorSetLayout&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -30,14 +31,6 @@ public:
return m_descriptor_set_layout == VK_NULL_HANDLE; return m_descriptor_set_layout == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkDescriptorSetLayout() noexcept { inline operator VkDescriptorSetLayout() noexcept {
return m_descriptor_set_layout; return m_descriptor_set_layout;
} }
@ -46,16 +39,19 @@ public:
return m_descriptor_set_layout; return m_descriptor_set_layout;
} }
friend inline void swap(DescriptorSetLayout& descriptor_set_layout_0, DescriptorSetLayout& descriptor_set_layout_1) noexcept { inline void swap(DescriptorSetLayout& other) noexcept {
using std::swap; using std::swap;
swap(descriptor_set_layout_0.m_context, descriptor_set_layout_1.m_context); Wrapper::swap(other);
swap(descriptor_set_layout_0.m_descriptor_set_layout, descriptor_set_layout_1.m_descriptor_set_layout); swap(m_descriptor_set_layout, other.m_descriptor_set_layout);
}
friend inline void swap(DescriptorSetLayout& descriptor_set_layout_0, DescriptorSetLayout& descriptor_set_layout_1) noexcept {
descriptor_set_layout_0.swap(descriptor_set_layout_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkDescriptorSetLayout m_descriptor_set_layout = VK_NULL_HANDLE; VkDescriptorSetLayout m_descriptor_set_layout = VK_NULL_HANDLE;
}; };

6
src/vk/Fence.cpp

@ -13,7 +13,7 @@ Fence::Fence() noexcept {
} }
Fence::Fence(Context& context, VkFenceCreateFlags flags) Fence::Fence(Context& context, VkFenceCreateFlags flags)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -32,7 +32,7 @@ Fence::Fence(Context& context, VkFenceCreateFlags flags)
Fence::Fence(Fence&& other) noexcept Fence::Fence(Fence&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
Fence::~Fence() noexcept { Fence::~Fence() noexcept {
@ -42,7 +42,7 @@ Fence::~Fence() noexcept {
Fence& Fence::operator=(Fence&& other) noexcept { Fence& Fence::operator=(Fence&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/Fence.h

@ -4,6 +4,7 @@
#include <core/ArrayView.h> #include <core/ArrayView.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -11,15 +12,15 @@
namespace vk { namespace vk {
class Fence { class Fence: public Wrapper {
public: public:
Fence() noexcept; Fence() noexcept;
Fence(Context& context, VkFenceCreateFlags flags=0); Fence(Context& context, VkFenceCreateFlags flags=0);
Fence(const Fence&) = delete; Fence(const Fence&) = default;
Fence(Fence&& other) noexcept; Fence(Fence&& other) noexcept;
~Fence() noexcept; ~Fence() noexcept;
Fence& operator=(const Fence&) = delete; Fence& operator=(const Fence&) = default;
Fence& operator=(Fence&& other) noexcept; Fence& operator=(Fence&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -30,14 +31,6 @@ public:
return m_fence == VK_NULL_HANDLE; return m_fence == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkFence() noexcept { inline operator VkFence() noexcept {
return m_fence; return m_fence;
} }
@ -50,16 +43,19 @@ public:
void reset(); void reset();
void wait(uint64_t timeout=UINT64_MAX) const; void wait(uint64_t timeout=UINT64_MAX) const;
friend inline void swap(Fence& fence_0, Fence& fence_1) noexcept { inline void swap(Fence& other) noexcept {
using std::swap; using std::swap;
swap(fence_0.m_context, fence_1.m_context); Wrapper::swap(other);
swap(fence_0.m_fence, fence_1.m_fence); swap(m_fence, other.m_fence);
}
friend inline void swap(Fence& fence_0, Fence& fence_1) noexcept {
fence_0.swap(fence_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkFence m_fence = VK_NULL_HANDLE; VkFence m_fence = VK_NULL_HANDLE;
}; };

6
src/vk/Framebuffer.cpp

@ -18,7 +18,7 @@ Framebuffer::Framebuffer(
Array<VkImageView> attachments, Array<VkImageView> attachments,
uint32_t width, uint32_t height, uint32_t layers uint32_t width, uint32_t height, uint32_t layers
) )
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
assert(render_pass); assert(render_pass);
@ -52,7 +52,7 @@ Framebuffer::Framebuffer(
Framebuffer::Framebuffer(Framebuffer&& other) noexcept Framebuffer::Framebuffer(Framebuffer&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
Framebuffer::~Framebuffer() noexcept { Framebuffer::~Framebuffer() noexcept {
@ -62,7 +62,7 @@ Framebuffer::~Framebuffer() noexcept {
Framebuffer& Framebuffer::operator=(Framebuffer&& other) noexcept { Framebuffer& Framebuffer::operator=(Framebuffer&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/Framebuffer.h

@ -4,6 +4,7 @@
#include <core/utils.h> #include <core/utils.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -11,7 +12,7 @@
namespace vk { namespace vk {
class Framebuffer { class Framebuffer: public Wrapper {
public: public:
Framebuffer() noexcept; Framebuffer() noexcept;
Framebuffer( Framebuffer(
@ -26,11 +27,11 @@ public:
Array<VkImageView> attachments, Array<VkImageView> attachments,
VkExtent2D extent, uint32_t layers=1 VkExtent2D extent, uint32_t layers=1
); );
Framebuffer(const Framebuffer&) = delete; Framebuffer(const Framebuffer&) = default;
Framebuffer(Framebuffer&& other) noexcept; Framebuffer(Framebuffer&& other) noexcept;
~Framebuffer() noexcept; ~Framebuffer() noexcept;
Framebuffer& operator=(const Framebuffer&) = delete; Framebuffer& operator=(const Framebuffer&) = default;
Framebuffer& operator=(Framebuffer&& other) noexcept; Framebuffer& operator=(Framebuffer&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -41,14 +42,6 @@ public:
return m_framebuffer == VK_NULL_HANDLE; return m_framebuffer == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkFramebuffer() noexcept { inline operator VkFramebuffer() noexcept {
return m_framebuffer; return m_framebuffer;
} }
@ -57,16 +50,19 @@ public:
return m_framebuffer; return m_framebuffer;
} }
friend inline void swap(Framebuffer& framebuffer_0, Framebuffer& framebuffer_1) noexcept { inline void swap(Framebuffer& other) noexcept {
using std::swap; using std::swap;
swap(framebuffer_0.m_context, framebuffer_1.m_context); Wrapper::swap(other);
swap(framebuffer_0.m_framebuffer, framebuffer_1.m_framebuffer); swap(m_framebuffer, other.m_framebuffer);
}
friend inline void swap(Framebuffer& framebuffer_0, Framebuffer& framebuffer_1) noexcept {
framebuffer_0.swap(framebuffer_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkFramebuffer m_framebuffer = VK_NULL_HANDLE; VkFramebuffer m_framebuffer = VK_NULL_HANDLE;
}; };

6
src/vk/ImageView.cpp

@ -13,7 +13,7 @@ ImageView::ImageView() noexcept {
} }
ImageView::ImageView(Context& context, const VkImageViewCreateInfo& create_info) ImageView::ImageView(Context& context, const VkImageViewCreateInfo& create_info)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -28,7 +28,7 @@ ImageView::ImageView(Context& context, const VkImageViewCreateInfo& create_info)
ImageView::ImageView(ImageView&& other) noexcept ImageView::ImageView(ImageView&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
ImageView::~ImageView() noexcept { ImageView::~ImageView() noexcept {
@ -38,7 +38,7 @@ ImageView::~ImageView() noexcept {
ImageView& ImageView::operator=(ImageView&& other) noexcept { ImageView& ImageView::operator=(ImageView&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/ImageView.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,15 +10,15 @@
namespace vk { namespace vk {
class ImageView { class ImageView: public Wrapper {
public: public:
ImageView() noexcept; ImageView() noexcept;
ImageView(Context& context, const VkImageViewCreateInfo& create_info); ImageView(Context& context, const VkImageViewCreateInfo& create_info);
ImageView(const ImageView&) = delete; ImageView(const ImageView&) = default;
ImageView(ImageView&& other) noexcept; ImageView(ImageView&& other) noexcept;
~ImageView() noexcept; ~ImageView() noexcept;
ImageView& operator=(const ImageView&) = delete; ImageView& operator=(const ImageView&) = default;
ImageView& operator=(ImageView&& other) noexcept; ImageView& operator=(ImageView&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -28,14 +29,6 @@ public:
return m_image_view == VK_NULL_HANDLE; return m_image_view == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkImageView() noexcept { inline operator VkImageView() noexcept {
return m_image_view; return m_image_view;
} }
@ -44,16 +37,19 @@ public:
return m_image_view; return m_image_view;
} }
friend inline void swap(ImageView& image_view_0, ImageView& image_view_1) noexcept { inline void swap(ImageView& other) noexcept {
using std::swap; using std::swap;
swap(image_view_0.m_context, image_view_1.m_context); Wrapper::swap(other);
swap(image_view_0.m_image_view, image_view_1.m_image_view); swap(m_image_view, other.m_image_view);
}
friend inline void swap(ImageView& image_view_0, ImageView& image_view_1) noexcept {
image_view_0.swap(image_view_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkImageView m_image_view = VK_NULL_HANDLE; VkImageView m_image_view = VK_NULL_HANDLE;
}; };

8
src/vk/Pipeline.cpp

@ -13,7 +13,7 @@ Pipeline::Pipeline() noexcept {
} }
Pipeline::Pipeline(Context& context, VkPipeline pipeline) Pipeline::Pipeline(Context& context, VkPipeline pipeline)
: m_context(&context) : Wrapper(context)
, m_pipeline(pipeline) , m_pipeline(pipeline)
{ {
assert(m_context); assert(m_context);
@ -21,7 +21,7 @@ Pipeline::Pipeline(Context& context, VkPipeline pipeline)
} }
Pipeline::Pipeline(Context& context, VkGraphicsPipelineCreateInfo create_info) Pipeline::Pipeline(Context& context, VkGraphicsPipelineCreateInfo create_info)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -37,7 +37,7 @@ Pipeline::Pipeline(Context& context, VkGraphicsPipelineCreateInfo create_info)
Pipeline::Pipeline(Pipeline&& other) noexcept Pipeline::Pipeline(Pipeline&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
Pipeline::~Pipeline() noexcept { Pipeline::~Pipeline() noexcept {
@ -47,7 +47,7 @@ Pipeline::~Pipeline() noexcept {
Pipeline& Pipeline::operator=(Pipeline&& other) noexcept { Pipeline& Pipeline::operator=(Pipeline&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/Pipeline.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,16 +10,16 @@
namespace vk { namespace vk {
class Pipeline { class Pipeline: public Wrapper {
public: public:
Pipeline() noexcept; Pipeline() noexcept;
Pipeline(Context& context, VkPipeline pipeline); Pipeline(Context& context, VkPipeline pipeline);
Pipeline(Context& context, VkGraphicsPipelineCreateInfo create_info); Pipeline(Context& context, VkGraphicsPipelineCreateInfo create_info);
Pipeline(const Pipeline&) = delete; Pipeline(const Pipeline&) = default;
Pipeline(Pipeline&& other) noexcept; Pipeline(Pipeline&& other) noexcept;
~Pipeline() noexcept; ~Pipeline() noexcept;
Pipeline& operator=(const Pipeline&) = delete; Pipeline& operator=(const Pipeline&) = default;
Pipeline& operator=(Pipeline&& other) noexcept; Pipeline& operator=(Pipeline&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -29,14 +30,6 @@ public:
return m_pipeline == VK_NULL_HANDLE; return m_pipeline == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkPipeline() noexcept { inline operator VkPipeline() noexcept {
return m_pipeline; return m_pipeline;
} }
@ -45,16 +38,19 @@ public:
return m_pipeline; return m_pipeline;
} }
friend inline void swap(Pipeline& pipeline_0, Pipeline& pipeline_1) noexcept { inline void swap(Pipeline& other) noexcept {
using std::swap; using std::swap;
swap(pipeline_0.m_context, pipeline_1.m_context); Wrapper::swap(other);
swap(pipeline_0.m_pipeline, pipeline_1.m_pipeline); swap(m_pipeline, other.m_pipeline);
}
friend inline void swap(Pipeline& pipeline_0, Pipeline& pipeline_1) noexcept {
pipeline_0.swap(pipeline_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkPipeline m_pipeline = VK_NULL_HANDLE; VkPipeline m_pipeline = VK_NULL_HANDLE;
}; };

6
src/vk/PipelineLayout.cpp

@ -17,7 +17,7 @@ PipelineLayout::PipelineLayout(
Array<const VkDescriptorSetLayout> set_layouts, Array<const VkDescriptorSetLayout> set_layouts,
Array<const VkPushConstantRange> push_constant_ranges Array<const VkPushConstantRange> push_constant_ranges
) )
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -39,7 +39,7 @@ PipelineLayout::PipelineLayout(
PipelineLayout::PipelineLayout(PipelineLayout&& other) noexcept PipelineLayout::PipelineLayout(PipelineLayout&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
PipelineLayout::~PipelineLayout() noexcept { PipelineLayout::~PipelineLayout() noexcept {
@ -49,7 +49,7 @@ PipelineLayout::~PipelineLayout() noexcept {
PipelineLayout& PipelineLayout::operator=(PipelineLayout&& other) noexcept { PipelineLayout& PipelineLayout::operator=(PipelineLayout&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/PipelineLayout.h

@ -4,6 +4,7 @@
#include <core/utils.h> #include <core/utils.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -11,7 +12,7 @@
namespace vk { namespace vk {
class PipelineLayout { class PipelineLayout: public Wrapper {
public: public:
PipelineLayout() noexcept; PipelineLayout() noexcept;
PipelineLayout( PipelineLayout(
@ -19,11 +20,11 @@ public:
Array<const VkDescriptorSetLayout> set_layouts, Array<const VkDescriptorSetLayout> set_layouts,
Array<const VkPushConstantRange> push_constant_ranges={} Array<const VkPushConstantRange> push_constant_ranges={}
); );
PipelineLayout(const PipelineLayout&) = delete; PipelineLayout(const PipelineLayout&) = default;
PipelineLayout(PipelineLayout&& other) noexcept; PipelineLayout(PipelineLayout&& other) noexcept;
~PipelineLayout() noexcept; ~PipelineLayout() noexcept;
PipelineLayout& operator=(const PipelineLayout&) = delete; PipelineLayout& operator=(const PipelineLayout&) = default;
PipelineLayout& operator=(PipelineLayout&& other) noexcept; PipelineLayout& operator=(PipelineLayout&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -34,14 +35,6 @@ public:
return m_pipeline_layout == VK_NULL_HANDLE; return m_pipeline_layout == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkPipelineLayout() noexcept { inline operator VkPipelineLayout() noexcept {
return m_pipeline_layout; return m_pipeline_layout;
} }
@ -50,16 +43,19 @@ public:
return m_pipeline_layout; return m_pipeline_layout;
} }
friend inline void swap(PipelineLayout& pipeline_layout_0, PipelineLayout& pipeline_layout_1) noexcept { inline void swap(PipelineLayout& other) noexcept {
using std::swap; using std::swap;
swap(pipeline_layout_0.m_context, pipeline_layout_1.m_context); Wrapper::swap(other);
swap(pipeline_layout_0.m_pipeline_layout, pipeline_layout_1.m_pipeline_layout); swap(m_pipeline_layout, other.m_pipeline_layout);
}
friend inline void swap(PipelineLayout& pipeline_layout_0, PipelineLayout& pipeline_layout_1) noexcept {
pipeline_layout_0.swap(pipeline_layout_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkPipelineLayout m_pipeline_layout = VK_NULL_HANDLE; VkPipelineLayout m_pipeline_layout = VK_NULL_HANDLE;
}; };

6
src/vk/RenderPass.cpp

@ -13,7 +13,7 @@ RenderPass::RenderPass() noexcept {
} }
RenderPass::RenderPass(Context& context, const VkRenderPassCreateInfo& create_info) RenderPass::RenderPass(Context& context, const VkRenderPassCreateInfo& create_info)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -28,7 +28,7 @@ RenderPass::RenderPass(Context& context, const VkRenderPassCreateInfo& create_in
RenderPass::RenderPass(RenderPass&& other) noexcept RenderPass::RenderPass(RenderPass&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
RenderPass::~RenderPass() noexcept { RenderPass::~RenderPass() noexcept {
@ -38,7 +38,7 @@ RenderPass::~RenderPass() noexcept {
RenderPass& RenderPass::operator=(RenderPass&& other) noexcept { RenderPass& RenderPass::operator=(RenderPass&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

18
src/vk/RenderPass.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,15 +10,15 @@
namespace vk { namespace vk {
class RenderPass { class RenderPass: public Wrapper {
public: public:
RenderPass() noexcept; RenderPass() noexcept;
RenderPass(Context& context, const VkRenderPassCreateInfo& create_info); RenderPass(Context& context, const VkRenderPassCreateInfo& create_info);
RenderPass(const RenderPass&) = delete; RenderPass(const RenderPass&) = default;
RenderPass(RenderPass&& other) noexcept; RenderPass(RenderPass&& other) noexcept;
~RenderPass() noexcept; ~RenderPass() noexcept;
RenderPass& operator=(const RenderPass&) = delete; RenderPass& operator=(const RenderPass&) = default;
RenderPass& operator=(RenderPass&& other) noexcept; RenderPass& operator=(RenderPass&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -36,16 +37,19 @@ public:
return m_render_pass; return m_render_pass;
} }
friend inline void swap(RenderPass& render_pass_0, RenderPass& render_pass_1) noexcept { inline void swap(RenderPass& other) noexcept {
using std::swap; using std::swap;
swap(render_pass_0.m_context, render_pass_1.m_context); Wrapper::swap(other);
swap(render_pass_0.m_render_pass, render_pass_1.m_render_pass); swap(m_render_pass, other.m_render_pass);
}
friend inline void swap(RenderPass& render_pass_0, RenderPass& render_pass_1) noexcept {
render_pass_0.swap(render_pass_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkRenderPass m_render_pass = VK_NULL_HANDLE; VkRenderPass m_render_pass = VK_NULL_HANDLE;
}; };

6
src/vk/Semaphore.cpp

@ -13,7 +13,7 @@ Semaphore::Semaphore() noexcept {
} }
Semaphore::Semaphore(Context& context) Semaphore::Semaphore(Context& context)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -31,7 +31,7 @@ Semaphore::Semaphore(Context& context)
Semaphore::Semaphore(Semaphore&& other) noexcept Semaphore::Semaphore(Semaphore&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
Semaphore::~Semaphore() noexcept { Semaphore::~Semaphore() noexcept {
@ -41,7 +41,7 @@ Semaphore::~Semaphore() noexcept {
Semaphore& Semaphore::operator=(Semaphore&& other) noexcept { Semaphore& Semaphore::operator=(Semaphore&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

26
src/vk/Semaphore.h

@ -2,6 +2,7 @@
#pragma once #pragma once
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
@ -9,15 +10,15 @@
namespace vk { namespace vk {
class Semaphore { class Semaphore: public Wrapper {
public: public:
Semaphore() noexcept; Semaphore() noexcept;
Semaphore(Context& context); Semaphore(Context& context);
Semaphore(const Semaphore&) = delete; Semaphore(const Semaphore&) = default;
Semaphore(Semaphore&& other) noexcept; Semaphore(Semaphore&& other) noexcept;
~Semaphore() noexcept; ~Semaphore() noexcept;
Semaphore& operator=(const Semaphore&) = delete; Semaphore& operator=(const Semaphore&) = default;
Semaphore& operator=(Semaphore&& other) noexcept; Semaphore& operator=(Semaphore&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -28,14 +29,6 @@ public:
return m_semaphore == VK_NULL_HANDLE; return m_semaphore == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkSemaphore() noexcept { inline operator VkSemaphore() noexcept {
return m_semaphore; return m_semaphore;
} }
@ -44,16 +37,19 @@ public:
return m_semaphore; return m_semaphore;
} }
friend inline void swap(Semaphore& semaphore_0, Semaphore& semaphore_1) noexcept { inline void swap(Semaphore& other) noexcept {
using std::swap; using std::swap;
swap(semaphore_0.m_context, semaphore_1.m_context); Wrapper::swap(other);
swap(semaphore_0.m_semaphore, semaphore_1.m_semaphore); swap(m_semaphore, other.m_semaphore);
}
friend inline void swap(Semaphore& semaphore_0, Semaphore& semaphore_1) noexcept {
semaphore_0.swap(semaphore_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkSemaphore m_semaphore = VK_NULL_HANDLE; VkSemaphore m_semaphore = VK_NULL_HANDLE;
}; };

6
src/vk/ShaderModule.cpp

@ -13,7 +13,7 @@ ShaderModule::ShaderModule() noexcept {
} }
ShaderModule::ShaderModule(Context& context, const std::vector<char>& code) ShaderModule::ShaderModule(Context& context, const std::vector<char>& code)
: m_context(&context) : Wrapper(context)
{ {
assert(m_context); assert(m_context);
@ -37,7 +37,7 @@ ShaderModule::ShaderModule(Context& context, const char* path)
ShaderModule::ShaderModule(ShaderModule&& other) noexcept ShaderModule::ShaderModule(ShaderModule&& other) noexcept
{ {
swap(*this, other); swap(other);
} }
ShaderModule::~ShaderModule() noexcept { ShaderModule::~ShaderModule() noexcept {
@ -47,7 +47,7 @@ ShaderModule::~ShaderModule() noexcept {
ShaderModule& ShaderModule::operator=(ShaderModule&& other) noexcept { ShaderModule& ShaderModule::operator=(ShaderModule&& other) noexcept {
swap(*this, other); swap(other);
if(other) if(other)
other.destroy(); other.destroy();
return *this; return *this;

30
src/vk/ShaderModule.h

@ -1,26 +1,27 @@
// Copyright 2022 Simon Boyé // Copyright 2022 Simon Boyé
#pragma once #pragma once
#include <core/utils.h>
#include <vk/forward.h> #include <vk/forward.h>
#include <vk/Wrapper.h>
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <vector>
namespace vk { namespace vk {
class ShaderModule { class ShaderModule: public Wrapper {
public: public:
ShaderModule() noexcept; ShaderModule() noexcept;
ShaderModule(Context& context, const std::vector<char>& code); ShaderModule(Context& context, const std::vector<char>& code);
ShaderModule(Context& context, const char* path); ShaderModule(Context& context, const char* path);
ShaderModule(const ShaderModule&) = delete; ShaderModule(const ShaderModule&) = default;
ShaderModule(ShaderModule&& other) noexcept; ShaderModule(ShaderModule&& other) noexcept;
~ShaderModule() noexcept; ~ShaderModule() noexcept;
ShaderModule& operator=(const ShaderModule&) = delete; ShaderModule& operator=(const ShaderModule&) = default;
ShaderModule& operator=(ShaderModule&& other) noexcept; ShaderModule& operator=(ShaderModule&& other) noexcept;
explicit inline operator bool() const noexcept { explicit inline operator bool() const noexcept {
@ -31,14 +32,6 @@ public:
return m_shader_module == VK_NULL_HANDLE; return m_shader_module == VK_NULL_HANDLE;
} }
inline const Context* context() const noexcept {
return m_context;
}
inline Context* context() noexcept {
return m_context;
}
inline operator VkShaderModule() noexcept { inline operator VkShaderModule() noexcept {
return m_shader_module; return m_shader_module;
} }
@ -47,16 +40,19 @@ public:
return m_shader_module; return m_shader_module;
} }
friend inline void swap(ShaderModule& shader_module_0, ShaderModule& shader_module_1) noexcept { inline void swap(ShaderModule& other) noexcept {
using std::swap; using std::swap;
swap(shader_module_0.m_context, shader_module_1.m_context); Wrapper::swap(other);
swap(shader_module_0.m_shader_module, shader_module_1.m_shader_module); swap(m_shader_module, other.m_shader_module);
}
friend inline void swap(ShaderModule& shader_module_0, ShaderModule& shader_module_1) noexcept {
shader_module_0.swap(shader_module_1);
} }
void destroy() noexcept; void destroy() noexcept;
private: private:
Context* m_context = nullptr;
VkShaderModule m_shader_module = VK_NULL_HANDLE; VkShaderModule m_shader_module = VK_NULL_HANDLE;
}; };

Loading…
Cancel
Save