vulkan: captureScreenshot improvements.

- Don't create several persistent screen-sized images and buffers for screenshots, only create one temporary buffer during a frame that requests a screenshot.
- Attempt to handle more out-of-memory situations.
- Make sure the final screenshot is opaque.
- Swap R and B channels in the screenshot ImageData when the backbuffer is BGRA.
This commit is contained in:
Sasha Szpakowski
2024-03-16 23:51:40 -03:00
parent 89f43ff48d
commit 48aefd91fa
2 changed files with 92 additions and 133 deletions
-2
View File
@@ -355,7 +355,6 @@ private:
VkCompositeAlphaFlagBitsKHR chooseCompositeAlpha(const VkSurfaceCapabilitiesKHR &capabilities);
void createSwapChain();
void createImageViews();
void createScreenshotCallbackBuffers();
VkFramebuffer createFramebuffer(FramebufferConfiguration &configuration);
VkFramebuffer getFramebuffer(FramebufferConfiguration &configuration);
void createDefaultShaders();
@@ -449,7 +448,6 @@ private:
// We need a vector for each frame in flight.
std::vector<std::vector<std::function<void()>>> cleanUpFunctions;
std::vector<std::vector<std::function<void()>>> readbackCallbacks;
std::vector<ScreenshotReadbackBuffer> screenshotReadbackBuffers;
std::set<StrongRef<Shader>> usedShadersInFrame;
RenderpassState renderPassState;
};