53 lines
1.9 KiB
C++
53 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include <Orange/Core/Types.h>
|
|
#include <Orange/Core/Span.h>
|
|
#include <Orange/Core/Result.h>
|
|
|
|
#include <vulkan/vulkan_core.h>
|
|
|
|
namespace orange
|
|
{
|
|
class BufferPool
|
|
{
|
|
private:
|
|
VkBuffer m_buffer;
|
|
VkDeviceAddress m_va;
|
|
};
|
|
|
|
template <typename T>
|
|
using VulkanResult = Result<T, VkResult, VK_SUCCESS, VK_ERROR_UNKNOWN, VK_ERROR_UNKNOWN>;
|
|
|
|
class RenderContext
|
|
{
|
|
public:
|
|
~RenderContext();
|
|
|
|
static VulkanResult<RenderContext> Create(const char *appName);
|
|
|
|
VkInstance Instance() const { return m_instance; }
|
|
VkPhysicalDevice PhysicalDevice() const { return m_physicalDevice; }
|
|
VkDevice Device() const { return m_device; }
|
|
VkQueue Queue() const { return m_queue; }
|
|
VkCommandPool CommandPool() const { return m_commandPool; }
|
|
|
|
VulkanResult<VkFence> CreateFence(bool signalled);
|
|
VulkanResult<VkSemaphore> CreateSemaphore();
|
|
VulkanResult<VoidResult> BeginCommandBuffer(VkCommandBuffer buffer);
|
|
VulkanResult<VoidResult> EndCommandBuffer(VkCommandBuffer buffer);
|
|
|
|
VulkanResult<VkShaderModule> CreateShader(Span<const uint32_t> code);
|
|
protected:
|
|
friend VulkanResult<RenderContext>;
|
|
RenderContext(VkInstance instance, VkPhysicalDevice physicalDevice, VkDevice device,
|
|
VkQueue queue, VkCommandPool commandPool)
|
|
: m_instance{ instance }, m_physicalDevice{ physicalDevice }, m_device{ device }
|
|
, m_queue{ queue }, m_commandPool{ commandPool } {}
|
|
private:
|
|
VkInstance m_instance = VK_NULL_HANDLE;
|
|
VkPhysicalDevice m_physicalDevice = VK_NULL_HANDLE;
|
|
VkDevice m_device = VK_NULL_HANDLE;
|
|
VkQueue m_queue = VK_NULL_HANDLE;
|
|
VkCommandPool m_commandPool = VK_NULL_HANDLE;
|
|
};
|
|
} |