From cf8182c3b4dad23ccb3fc8b80f42d944a30e0f4f Mon Sep 17 00:00:00 2001 From: Thomas Choquet Date: Tue, 24 Feb 2026 22:20:08 +0900 Subject: [PATCH] add getter for swapchain pixel format --- include/Graphics/Swapchain.hpp | 1 + src/Metal/MetalSwapchain.hpp | 2 ++ src/Metal/MetalSwapchain.mm | 3 ++- src/Vulkan/VulkanSwapchain.cpp | 1 + src/Vulkan/VulkanSwapchain.hpp | 2 ++ 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/Graphics/Swapchain.hpp b/include/Graphics/Swapchain.hpp index f080c6e..30be572 100644 --- a/include/Graphics/Swapchain.hpp +++ b/include/Graphics/Swapchain.hpp @@ -40,6 +40,7 @@ class Swapchain virtual uint32_t width() const = 0; virtual uint32_t height() const = 0; + virtual PixelFormat pixelFormat() const = 0; virtual std::shared_ptr nextDrawable() = 0; diff --git a/src/Metal/MetalSwapchain.hpp b/src/Metal/MetalSwapchain.hpp index 68000b6..25e241d 100644 --- a/src/Metal/MetalSwapchain.hpp +++ b/src/Metal/MetalSwapchain.hpp @@ -32,6 +32,7 @@ class MetalSwapchain : public Swapchain inline uint32_t width() const override { return m_width; } inline uint32_t height() const override { return m_height; } + inline PixelFormat pixelFormat() const override { return m_pixelFormat; }; std::shared_ptr nextDrawable() override; @@ -41,6 +42,7 @@ class MetalSwapchain : public Swapchain uint32_t m_width; uint32_t m_height; CAMetalLayer* m_mtlLayer; + PixelFormat m_pixelFormat; public: MetalSwapchain& operator=(const MetalSwapchain&) = delete; diff --git a/src/Metal/MetalSwapchain.mm b/src/Metal/MetalSwapchain.mm index 953c87e..b7dbcd0 100644 --- a/src/Metal/MetalSwapchain.mm +++ b/src/Metal/MetalSwapchain.mm @@ -22,7 +22,8 @@ MetalSwapchain::MetalSwapchain(const MetalDevice& device, const Swapchain::Descriptor& desc) : m_width(desc.width) - , m_height(desc.height) { @autoreleasepool + , m_height(desc.height) + , m_pixelFormat(desc.pixelFormat) { @autoreleasepool { assert(desc.surface); auto* mtlSurface = dynamic_cast(desc.surface); diff --git a/src/Vulkan/VulkanSwapchain.cpp b/src/Vulkan/VulkanSwapchain.cpp index ac6cf59..6ff8c94 100644 --- a/src/Vulkan/VulkanSwapchain.cpp +++ b/src/Vulkan/VulkanSwapchain.cpp @@ -23,6 +23,7 @@ namespace gfx VulkanSwapchain::VulkanSwapchain(const VulkanDevice* device, const Descriptor& desc) : m_device(device) + , m_pixelFormat(desc.pixelFormat) { assert(desc.surface); const vk::SurfaceKHR& vkSurface = dynamic_cast(*desc.surface).vkSurface(); diff --git a/src/Vulkan/VulkanSwapchain.hpp b/src/Vulkan/VulkanSwapchain.hpp index 4ba18df..4ad6748 100644 --- a/src/Vulkan/VulkanSwapchain.hpp +++ b/src/Vulkan/VulkanSwapchain.hpp @@ -33,6 +33,7 @@ class VulkanSwapchain : public Swapchain inline uint32_t width() const override { return m_extent.width; } inline uint32_t height() const override { return m_extent.height; } + inline PixelFormat pixelFormat() const override { return m_pixelFormat; }; std::shared_ptr nextDrawable() override; @@ -41,6 +42,7 @@ class VulkanSwapchain : public Swapchain private: const VulkanDevice* m_device; vk::Extent2D m_extent; + PixelFormat m_pixelFormat; vk::SwapchainKHR* m_vkSwapchain; std::vector> m_swapchainImages;