From df985d03974e16d791d0bc936a6622cf06521dc3 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Sun, 13 Sep 2026 10:59:20 +0200 Subject: [PATCH] VulkanImage --- .../GraphicsInterface/GraphicsImage.hpp | 47 ++++++++++++ .../Include/GraphicsVulkan/VulkanImage.hpp | 75 +++++++++++++++++++ .../Graphics/GraphicsVulkan/VulkanImage.cpp | 58 ++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 Bigfoot/Libs/Graphics/GraphicsInterface/Include/GraphicsInterface/GraphicsImage.hpp create mode 100644 Bigfoot/Libs/Graphics/GraphicsVulkan/Include/GraphicsVulkan/VulkanImage.hpp create mode 100644 Bigfoot/Libs/Graphics/GraphicsVulkan/VulkanImage.cpp diff --git a/Bigfoot/Libs/Graphics/GraphicsInterface/Include/GraphicsInterface/GraphicsImage.hpp b/Bigfoot/Libs/Graphics/GraphicsInterface/Include/GraphicsInterface/GraphicsImage.hpp new file mode 100644 index 0000000..a575cb5 --- /dev/null +++ b/Bigfoot/Libs/Graphics/GraphicsInterface/Include/GraphicsInterface/GraphicsImage.hpp @@ -0,0 +1,47 @@ +/********************************************************************* + * \file GraphicsImage.hpp + * + * \author Romain BOULLARD + * \date September 2026 + *********************************************************************/ +#ifndef BIGFOOT_GRAPHICSINTERFACE_GRAPHICSIMAGE_HPP +#define BIGFOOT_GRAPHICSINTERFACE_GRAPHICSIMAGE_HPP +#include + +#include + +namespace Bigfoot +{ +class GraphicsImage +{ + public: + virtual ~GraphicsImage() = default; + + /** + * Get the pixel format of the image + * + * \return The image format + */ + [[nodiscard]] + virtual PixelFormat GetFormat() const = 0; + + /** + * Get the size of the image + * + * \return The image extent, in pixels + */ + [[nodiscard]] + virtual glm::uvec2 GetExtent() const = 0; + + GraphicsImage(const GraphicsImage& p_image) = delete; + GraphicsImage(GraphicsImage&& p_image) = delete; + + GraphicsImage& operator=(const GraphicsImage& p_image) = delete; + GraphicsImage& operator=(GraphicsImage&& p_image) = delete; + + protected: + GraphicsImage() = default; +}; +} // namespace Bigfoot + +#endif diff --git a/Bigfoot/Libs/Graphics/GraphicsVulkan/Include/GraphicsVulkan/VulkanImage.hpp b/Bigfoot/Libs/Graphics/GraphicsVulkan/Include/GraphicsVulkan/VulkanImage.hpp new file mode 100644 index 0000000..249f1df --- /dev/null +++ b/Bigfoot/Libs/Graphics/GraphicsVulkan/Include/GraphicsVulkan/VulkanImage.hpp @@ -0,0 +1,75 @@ +/********************************************************************* + * \file VulkanImage.hpp + * + * \author Romain BOULLARD + * \date September 2026 + *********************************************************************/ +#ifndef BIGFOOT_GRAPHICSVULKAN_VULKANIMAGE_HPP +#define BIGFOOT_GRAPHICSVULKAN_VULKANIMAGE_HPP +#include + +#include + +namespace Bigfoot::Vulkan +{ +class VulkanImage final: public GraphicsImage +{ + public: + /** + * Constructor + * + * \param p_image The underlying Vulkan image handle + * \param p_format The pixel format of the image + * \param p_extent The size of the image + */ + VulkanImage(vk::Image p_image, PixelFormat p_format, vk::Extent2D p_extent); + + VulkanImage(const VulkanImage& p_image) = delete; + VulkanImage(VulkanImage&& p_image) noexcept; + + VulkanImage& operator=(const VulkanImage& p_image) = delete; + VulkanImage& operator=(VulkanImage&& p_image) noexcept; + + /** + * Get the pixel format of the image + * + * \return The image format + */ + [[nodiscard]] + PixelFormat GetFormat() const override; + + /** + * Get the size of the image + * + * \return The image extent, in pixels + */ + [[nodiscard]] + glm::uvec2 GetExtent() const override; + + /** + * Get the underlying Vulkan image handle + * + * \return The vk::Image handle + */ + [[nodiscard]] + vk::Image GetHandle() const; + + private: + /** + * The vulkan image + */ + vk::Image m_image; + + /** + * The pixel format of the image + */ + PixelFormat m_format; + + /** + * The size of the image + */ + vk::Extent2D m_extent; +}; +} // namespace Bigfoot::Vulkan + +#endif diff --git a/Bigfoot/Libs/Graphics/GraphicsVulkan/VulkanImage.cpp b/Bigfoot/Libs/Graphics/GraphicsVulkan/VulkanImage.cpp new file mode 100644 index 0000000..b02cb46 --- /dev/null +++ b/Bigfoot/Libs/Graphics/GraphicsVulkan/VulkanImage.cpp @@ -0,0 +1,58 @@ +/********************************************************************* + * \file VulkanImage.cpp + * + * \author Romain BOULLARD + * \date September 2026 + *********************************************************************/ +#include + +namespace Bigfoot::Vulkan +{ +VulkanImage::VulkanImage(const vk::Image p_image, const PixelFormat p_format, const vk::Extent2D p_extent): + m_image(p_image), + m_format(p_format), + m_extent(p_extent) +{ +} + +/****************************************************************************************/ + +VulkanImage::VulkanImage(VulkanImage&& p_image) noexcept: + GraphicsImage(), + m_image(p_image.m_image), + m_format(p_image.m_format), + m_extent(p_image.m_extent) +{ +} + +/****************************************************************************************/ + +VulkanImage& VulkanImage::operator=(VulkanImage&& p_image) noexcept +{ + m_image = p_image.m_image; + m_format = p_image.m_format; + m_extent = p_image.m_extent; + return *this; +} + +/****************************************************************************************/ + +PixelFormat VulkanImage::GetFormat() const +{ + return m_format; +} + +/****************************************************************************************/ + +glm::uvec2 VulkanImage::GetExtent() const +{ + return {m_extent.width, m_extent.height}; +} + +/****************************************************************************************/ + +vk::Image VulkanImage::GetHandle() const +{ + return m_image; +} +} // namespace Bigfoot::Vulkan