19 #ifndef INCLUDED_CSPAINT_DEVICE_H
20 #define INCLUDED_CSPAINT_DEVICE_H
28 #include <vulkan/vulkan.hpp>
30 #include <cspaint_fwd.h>
35 class device :
public std::enable_shared_from_this<device>
42 using handle = std::shared_ptr<device>;
47 vk::SharingMode mode = vk::SharingMode::eExclusive);
49 template <
typename T,
typename Alloc>
51 createBuffer(
const std::vector<T, Alloc> &vec, vk::BufferUsageFlagBits usage, vk::SharingMode = vk::SharingMode::eExclusive);
54 vk::SharingMode = vk::SharingMode::eExclusive);
57 vk::ImageUsageFlags imageUsage, vk::MemoryPropertyFlags memoryFlags, vk::ImageAspectFlags aspectFlags);
59 std::future<image_handle>
createTexture(
const void *data, uint64_t size, uint32_t width, uint32_t height, vk::Format imageFormat,
60 vk::MemoryPropertyFlags memoryFlags, vk::ImageAspectFlags aspectFlags);
62 template <
typename T,
typename Alloc>
63 std::future<image_handle>
createTexture(
const std::vector<T, Alloc> data, uint32_t width, uint32_t height,
64 vk::Format imageFormat, vk::MemoryPropertyFlags memoryFlags,
65 vk::ImageAspectFlags aspectFlags);
91 std::pair<vk::UniqueDevice, std::vector<vk::Queue>> createLogicalDevice(
const vk::QueueFamilyProperties &properties,
95 vk::PhysicalDevice m_device;
96 vk::UniqueDevice m_graphicsDevice;
97 vk::UniqueDevice m_transferDevice;
98 uint32_t m_graphicsCommandQueueFamily;
99 uint32_t m_transferCommandQueueFamily;
102 std::vector<vk::Queue> m_graphicsQueues;
103 std::vector<vk::Queue> m_transferQueues;
107 template <
typename T,
typename Alloc>
111 return createBuffer(
static_cast<const void *
>(vec.data()), vec.size() *
sizeof(T), usage, sharingMode);
114 template <
typename T,
typename Alloc>
115 std::future<CsPaint::image_handle>
117 vk::MemoryPropertyFlags memoryFlags, vk::ImageAspectFlags aspectFlags)
119 return createTexture(
static_cast<const void *
>(vec.data()), vec.size() *
sizeof(T), width, height, imageFormat, memoryFlags,
void operator=(const device &) = delete
std::shared_ptr< memorypool > memorypool_handle
Definition: cspaint_fwd.h:51
queue_handle transferQueue() const
std::shared_ptr< queue > queue_handle
Definition: cspaint_fwd.h:57
const vk::PhysicalDevice & physicalDevice() const
command_pool_handle graphicsCommandPool() const
std::shared_ptr< command_pool > command_pool_handle
Definition: cspaint_fwd.h:33
renderpass_handle createRenderPass() const
Definition: cspaint_buffer.h:26
command_pool_handle transferCommandPool() const
Definition: cspaint_device.h:35
std::shared_ptr< device > handle
Definition: cspaint_device.h:42
const vk::Device & graphicsDevice() const
std::shared_ptr< buffer > buffer_handle
Definition: cspaint_fwd.h:27
device(CsPaint::context_handle context_handle, vk::PhysicalDevice vk_device, private_tag=private_tag{})
std::future< image_handle > createTexture(const void *data, uint64_t size, uint32_t width, uint32_t height, vk::Format imageFormat, vk::MemoryPropertyFlags memoryFlags, vk::ImageAspectFlags aspectFlags)
buffer_handle createBuffer(uint64_t bufferSize, vk::BufferUsageFlagBits usage, vk::SharingMode mode=vk::SharingMode::eExclusive)
memorypool_handle memoryPool(vk::MemoryPropertyFlags memoryProperties)
shader_handle createShader(std::vector< char > input) const
descriptor_pool_handle createDescriptorPool(uint32_t size, vk::DescriptorType, uint32_t count)
std::shared_ptr< image > image_handle
Definition: cspaint_fwd.h:48
queue_handle graphicsQueue() const
image_handle createImage(uint32_t width, uint32_t height, vk::Format imageFormat, vk::ImageTiling imageTiling, vk::ImageUsageFlags imageUsage, vk::MemoryPropertyFlags memoryFlags, vk::ImageAspectFlags aspectFlags)
std::shared_ptr< context > context_handle
Definition: cspaint_fwd.h:36
std::shared_ptr< descriptor_pool > descriptor_pool_handle
Definition: cspaint_fwd.h:42
std::shared_ptr< renderpass > renderpass_handle
Definition: cspaint_fwd.h:60
std::shared_ptr< shader > shader_handle
Definition: cspaint_fwd.h:63