upleb.uk

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

summaryrefslogtreecommitdiff
path: root/runtime/src/vulkan_scratch.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/src/vulkan_scratch.h')
-rw-r--r--runtime/src/vulkan_scratch.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/runtime/src/vulkan_scratch.h b/runtime/src/vulkan_scratch.h
index 58b9e6967..753701e1c 100644
--- a/runtime/src/vulkan_scratch.h
+++ b/runtime/src/vulkan_scratch.h
@@ -13,6 +13,8 @@
13#include <vulkan/vulkan.h> 13#include <vulkan/vulkan.h>
14#include "queue_families.h" 14#include "queue_families.h"
15 15
16#include "vulkan_device_fault.h"
17
16#include <algorithm> 18#include <algorithm>
17#include <cstdint> 19#include <cstdint>
18#include <functional> 20#include <functional>
@@ -27,14 +29,15 @@ public:
27 using Allocate = std::function<VkDeviceMemory(const VkMemoryRequirements&)>; 29 using Allocate = std::function<VkDeviceMemory(const VkMemoryRequirements&)>;
28 30
29 ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate, VkBufferUsageFlags extra_usage = 0, 31 ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate, VkBufferUsageFlags extra_usage = 0,
30 std::vector<std::uint32_t> families = {}) 32 std::vector<std::uint32_t> families = {}, DeviceFaultDiagnostics* diagnostics = nullptr)
31 : device_(device), allocate_(std::move(allocate)), extra_usage_(extra_usage), families_(std::move(families)) { 33 : device_(device), diagnostics_(diagnostics), allocate_(std::move(allocate)), extra_usage_(extra_usage),
34 families_(std::move(families)) {
32 loaded_ = vk_.load(get, device); 35 loaded_ = vk_.load(get, device);
33 } 36 }
34 37
35 ~ScratchBuffers() { 38 ~ScratchBuffers() {
36 if (!loaded_) return; 39 if (!loaded_) return;
37 vk_.vkDeviceWaitIdle(device_); 40 DeviceFaultDiagnostics::observe(diagnostics_, vk_.vkDeviceWaitIdle(device_), "vkDeviceWaitIdle");
38 release(current_); 41 release(current_);
39 for (auto& batch : retired_) release(batch); 42 for (auto& batch : retired_) release(batch);
40 for (auto& chunk : spare_) destroy(chunk); 43 for (auto& chunk : spare_) destroy(chunk);
@@ -105,7 +108,9 @@ public:
105 if (retired_[i].ticket != 0) { 108 if (retired_[i].ticket != 0) {
106 std::uint64_t done = 0; 109 std::uint64_t done = 0;
107 if (!retired_[i].timeline || 110 if (!retired_[i].timeline ||
108 vk_.vkGetSemaphoreCounterValue(device_, retired_[i].timeline, &done) != VK_SUCCESS || 111 DeviceFaultDiagnostics::observe(diagnostics_,
112 vk_.vkGetSemaphoreCounterValue(device_, retired_[i].timeline, &done),
113 "vkGetSemaphoreCounterValue (scratch)") != VK_SUCCESS ||
109 done < retired_[i].ticket) { 114 done < retired_[i].ticket) {
110 ++i; 115 ++i;
111 continue; 116 continue;
@@ -181,6 +186,7 @@ private:
181 } 186 }
182 187
183 VkDevice device_; 188 VkDevice device_;
189 DeviceFaultDiagnostics* diagnostics_;
184 Allocate allocate_; 190 Allocate allocate_;
185 VkBufferUsageFlags extra_usage_ = 0; 191 VkBufferUsageFlags extra_usage_ = 0;
186 std::vector<std::uint32_t> families_; 192 std::vector<std::uint32_t> families_;