Experimentation using Vulkan.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

71 lines
1.8 KiB

// Copyright 2022 Simon Boyé
#pragma once
#include <vk/forward.h>
#include <vulkan/vulkan.h>
namespace vk {
class CommandBuffer {
public:
CommandBuffer() noexcept;
CommandBuffer(Context& context, VkCommandPool command_pool, VkCommandBufferLevel level=VK_COMMAND_BUFFER_LEVEL_PRIMARY);
CommandBuffer(const CommandBuffer&) = delete;
CommandBuffer(CommandBuffer&& other) noexcept;
~CommandBuffer() noexcept;
CommandBuffer& operator=(const CommandBuffer&) = delete;
CommandBuffer& operator=(CommandBuffer&& other) noexcept;
explicit inline operator bool() const noexcept {
return !is_null();
}
inline bool is_null() const noexcept {
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 {
return m_command_pool;
}
inline VkCommandPool command_pool() noexcept {
return m_command_pool;
}
inline operator VkCommandBuffer() noexcept {
return m_command_buffer;
}
inline VkCommandBuffer command_buffer() noexcept {
return m_command_buffer;
}
friend inline void swap(CommandBuffer& command_buffer_0, CommandBuffer& command_buffer_1) noexcept {
using std::swap;
swap(command_buffer_0.m_context, command_buffer_1.m_context);
swap(command_buffer_0.m_command_pool, command_buffer_1.m_command_pool);
swap(command_buffer_0.m_command_buffer, command_buffer_1.m_command_buffer);
}
void destroy() noexcept;
private:
Context* m_context = nullptr;
VkCommandPool m_command_pool = VK_NULL_HANDLE;
VkCommandBuffer m_command_buffer = VK_NULL_HANDLE;
};
}