upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_present.h
diff options
context:
space:
mode:
authorMatheus Gomes <39656344+matheuskshn@users.noreply.github.com>2026-11-22 13:33:33 -0300
committerMatheus Gomes <39656344+matheuskshn@users.noreply.github.com>2026-11-22 13:33:33 -0300
commit989877d1e07f90df2c6d98b0242cb9fb85075ea8 (patch)
tree2ff5b62117cae701f965de6c62979c9b6f59c218 /runtime/src/vulkan_present.h
parent4eb6155d3ac4f9d3fadb0d095c4ce13e76783615 (diff)
fix(vulkan): fail capture readback when the fence wait fails
Only copy the mapped capture buffer after a successful fence wait. Inject a failure in the synchronization test and verify that the caller's pixel and metadata outputs are unmodified.
Diffstat (limited to 'runtime/src/vulkan_present.h')
-rw-r--r--runtime/src/vulkan_present.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/runtime/src/vulkan_present.h b/runtime/src/vulkan_present.h
index d9f53baa5..958252131 100644
--- a/runtime/src/vulkan_present.h
+++ b/runtime/src/vulkan_present.h
@@ -225,11 +225,12 @@ public:
225 } 225 }
226 226
227 // The last presented frame as the swapchain stores it (4 bytes a texel, rows tightly packed, format() order). 227 // The last presented frame as the swapchain stores it (4 bytes a texel, rows tightly packed, format() order).
228 // Waits for the frame to finish. False when nothing was presented since enable_capture(). 228 // Waits for the frame to finish. False if no captured frame is available or the wait fails.
229 bool read_back(std::vector<std::uint8_t>& pixels, VkExtent2D* extent, VkFormat* format) { 229 bool read_back(std::vector<std::uint8_t>& pixels, VkExtent2D* extent, VkFormat* format) {
230 if (!capture_ || !capture_ptr_ || !captured_) return false; 230 if (!capture_ || !capture_ptr_ || !captured_) return false;
231 const Frame& frame = frames_[(frame_index_ + frames_.size() - 1) % frames_.size()]; 231 const Frame& frame = frames_[(frame_index_ + frames_.size() - 1) % frames_.size()];
232 vkWaitForFences_(context_.device(), 1, &frame.done, VK_TRUE, UINT64_MAX); 232 if (vkWaitForFences_(context_.device(), 1, &frame.done, VK_TRUE, UINT64_MAX) != VK_SUCCESS)
233 return false;
233 pixels.assign(capture_ptr_, capture_ptr_ + std::size_t(captured_extent_.width) * captured_extent_.height * 4); 234 pixels.assign(capture_ptr_, capture_ptr_ + std::size_t(captured_extent_.width) * captured_extent_.height * 4);
234 if (extent) *extent = captured_extent_; 235 if (extent) *extent = captured_extent_;
235 if (format) *format = captured_format_; 236 if (format) *format = captured_format_;