12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #ifndef GAMINGCORE_VULKAN_WRAPPER_HPP
- #define GAMINGCORE_VULKAN_WRAPPER_HPP
- #include <core/Meta.hpp>
- #include <vulkan/vulkan.h>
- namespace Core::Vulkan {
- bool init();
- void render();
- void destroy();
- template<typename T>
- struct BaseWrapper {
- VkDevice device = VK_NULL_HANDLE;
- T handle = VK_NULL_HANDLE;
- BaseWrapper() = default;
- BaseWrapper(const BaseWrapper&) = delete;
- BaseWrapper(BaseWrapper&& o) : BaseWrapper() {
- swap(o);
- }
- BaseWrapper& operator=(const BaseWrapper&) = delete;
- BaseWrapper& operator=(BaseWrapper&& o) {
- swap(o);
- o = BaseWrapper();
- }
- void swap(BaseWrapper& o) {
- Core::swap(device, o.device);
- Core::swap(handle, o.handle);
- }
- operator T() {
- return handle;
- }
- operator T*() {
- return &handle;
- }
- operator const T*() const {
- return &handle;
- }
- };
- struct ImageView : public BaseWrapper<VkImageView> {
- ImageView() = default;
- ImageView(ImageView&&) = default;
- ~ImageView();
- };
- struct Framebuffer : public BaseWrapper<VkFramebuffer> {
- Framebuffer() = default;
- Framebuffer(Framebuffer&&) = default;
- ~Framebuffer();
- };
- struct Semaphore : public BaseWrapper<VkSemaphore> {
- Semaphore() = default;
- Semaphore(Semaphore&&) = default;
- ~Semaphore();
- bool init(VkDevice d);
- };
- struct Fence : public BaseWrapper<VkFence> {
- Fence() = default;
- Fence(Fence&&) = default;
- ~Fence();
- bool init(VkDevice d);
- };
- struct Swapchain : public BaseWrapper<VkSwapchainKHR> {
- Swapchain() = default;
- Swapchain(Swapchain&&) = default;
- ~Swapchain();
- };
- struct ShaderModule : public BaseWrapper<VkShaderModule> {
- ShaderModule() = default;
- ShaderModule(ShaderModule&&) = default;
- ~ShaderModule();
- bool init(VkDevice d, const char* path);
- };
- struct PipelineLayout : public BaseWrapper<VkPipelineLayout> {
- PipelineLayout() = default;
- PipelineLayout(PipelineLayout&&) = default;
- ~PipelineLayout();
- bool init(VkDevice d);
- };
- }
- #endif
|