Lluvia
Device.h
Go to the documentation of this file.
1 
8 #ifndef LLUVIA_CORE_VULKAN_DEVICE_H_
9 #define LLUVIA_CORE_VULKAN_DEVICE_H_
10 
11 #include <memory>
12 
14 #include "lluvia/core/types.h"
16 
17 namespace ll {
18 
19 class ImageDescriptor;
20 class CommandBuffer;
21 
22 namespace vulkan {
23 
24  ll::vec3ui computeOptimalLocalShape(ll::ComputeDimension dimension, uint32_t maxInvocations, const ll::vec3ui& maxSize);
25 
26  // forward declaration
27  class Instance;
28 
29  class Device : public std::enable_shared_from_this<ll::vulkan::Device> {
30 
31  public:
32  Device() = delete;
33  Device(const Device& device) = delete;
34  Device(Device&& device) = delete;
35 
36  Device(const vk::Device& device,
37  const vk::PhysicalDevice& physicalDevice,
38  const uint32_t computeQueueFamilyIndex,
39  const std::shared_ptr<ll::vulkan::Instance>& instance);
41 
42  Device& operator=(const Device& device) = delete;
43  Device& operator=(Device&& device) = delete;
44 
45  vk::Device& get() noexcept;
46  vk::PhysicalDevice& getPhysicalDevice() noexcept;
47  const vk::PhysicalDeviceLimits& getPhysicalDeviceLimits() noexcept;
48  vk::CommandPool& getCommandPool() noexcept;
49  uint32_t getComputeFamilyQueueIndex() const noexcept;
50 
51  ll::vec3ui getComputeLocalShape(ll::ComputeDimension dimension) const noexcept;
52 
53  bool isImageDescriptorSupported(const ll::ImageDescriptor& descriptor) const noexcept;
54 
55  std::unique_ptr<ll::CommandBuffer> createCommandBuffer();
56 
57  void run(const ll::CommandBuffer& cmdBuffer);
58 
59  private:
60  vk::Device m_device;
61  vk::PhysicalDevice m_physicalDevice;
62  vk::PhysicalDeviceLimits m_physicalDeviceLimits;
63  vk::CommandPool m_commandPool;
64 
65  vk::Queue m_queue;
66  uint32_t m_computeQueueFamilyIndex;
67 
68  // cached local compute shapes for each compute dimension
69  ll::vec3ui m_localComputeShapeD1;
70  ll::vec3ui m_localComputeShapeD2;
71  ll::vec3ui m_localComputeShapeD3;
72 
73  // reference to the instance this device was created from
74  std::shared_ptr<ll::vulkan::Instance> m_instance;
75  };
76 
77 } // namespace vulkan
78 } // namespace ll
79 
80 #endif // LLUVIA_CORE_VULKAN_DEVICE_H_
Class for command buffer.
Definition: CommandBuffer.h:63
Stores all relevant information for creating ll::Image objects.
Definition: ImageDescriptor.h:189
Definition: Device.h:29
vk::Device & get() noexcept
Device & operator=(const Device &device)=delete
Device(const Device &device)=delete
bool isImageDescriptorSupported(const ll::ImageDescriptor &descriptor) const noexcept
Device(const vk::Device &device, const vk::PhysicalDevice &physicalDevice, const uint32_t computeQueueFamilyIndex, const std::shared_ptr< ll::vulkan::Instance > &instance)
void run(const ll::CommandBuffer &cmdBuffer)
const vk::PhysicalDeviceLimits & getPhysicalDeviceLimits() noexcept
ll::vec3ui getComputeLocalShape(ll::ComputeDimension dimension) const noexcept
Device(Device &&device)=delete
std::unique_ptr< ll::CommandBuffer > createCommandBuffer()
uint32_t getComputeFamilyQueueIndex() const noexcept
vk::PhysicalDevice & getPhysicalDevice() noexcept
Device & operator=(Device &&device)=delete
vk::CommandPool & getCommandPool() noexcept
Definition: Instance.h:19
ll::vec3ui computeOptimalLocalShape(ll::ComputeDimension dimension, uint32_t maxInvocations, const ll::vec3ui &maxSize)
Definition: Buffer.h:28
ComputeDimension
Supported compute dimensions.
Definition: ComputeDimension.h:21
Common types.