Implement Vulkan surface snapshot (#4314)

This commit is contained in:
Adrian Cojocaru
2026-06-06 02:06:40 +03:00
committed by GitHub
parent 8a393c5b2c
commit 9fa80b37d2
9 changed files with 147 additions and 8 deletions

View File

@@ -55,7 +55,8 @@ public:
const vk::UniqueSurfaceKHR& getPlatformSurface() const { return surface; }
const vk::UniqueSwapchainKHR& getSwapchain() const { return swapchain; }
const vk::UniqueFramebuffer& getFramebuffer() const override;
const vk::UniqueFramebuffer& getFramebuffer() const override { return swapchainFramebuffers[acquiredImageIndex]; }
vk::Format getColorFormat() const { return colorFormat; }
uint32_t getImageCount() const { return static_cast<uint32_t>(swapchainFramebuffers.size()); };
uint32_t getAcquiredImageIndex() const { return acquiredImageIndex; };
@@ -76,6 +77,9 @@ public:
void init(uint32_t w, uint32_t h);
void recreateSwapchain();
void enableSurfaceRead(bool value = true);
std::shared_ptr<PremultipliedImage> readImage();
protected:
vk::UniqueSurfaceKHR surface;
vk::UniqueSwapchainKHR swapchain;
@@ -99,6 +103,7 @@ protected:
vk::Format depthFormat{vk::Format::eUndefined};
int32_t surfaceTransformPollingInterval{-1};
bool surfaceRead{false};
};
class Renderable : public gfx::Renderable {

View File

@@ -87,6 +87,7 @@ public:
const vk::Sampler& getVulkanSampler();
void copyImage(vk::Image image, Size imageSize, uint16_t xOffset = 0, uint16_t yOffset = 0);
void blitImage(vk::Image image, Size imageSize, uint16_t xOffset = 0, uint16_t yOffset = 0);
std::shared_ptr<PremultipliedImage> readImage();
private: