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:
authorRain156 <77776581+Rain156@users.noreply.github.com>2026-11-24 21:17:26 +0800
committerRain156 <77776581+Rain156@users.noreply.github.com>2026-11-24 21:17:26 +0800
commitbe767b6889cb373cc695b67367644ea4370f8e9c (patch)
treea32475517a57f94577a90c64dd9027e64c6e4816 /runtime/src/vulkan_scratch.h
parent3c7927ea266c8dcb798de3462e9d4f4af2cdfc82 (diff)
parent6aa8eb11c66e66cf38a8f789c76bf7c7200a842d (diff)
Integrate #682 for the Windows first-run UI
Diffstat (limited to 'runtime/src/vulkan_scratch.h')
-rw-r--r--runtime/src/vulkan_scratch.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/runtime/src/vulkan_scratch.h b/runtime/src/vulkan_scratch.h
index 4a8a59ddd..c12d909e6 100644
--- a/runtime/src/vulkan_scratch.h
+++ b/runtime/src/vulkan_scratch.h
@@ -3,6 +3,8 @@
3// it. The replay stages copies Vulkan cannot do in one command through them (vulkan_replay.h, depth <-> colour 3// it. The replay stages copies Vulkan cannot do in one command through them (vulkan_replay.h, depth <-> colour
4// copies). Single-threaded: the caller holds the context's lock. The same life cycle as the depth24 converter's own 4// copies). Single-threaded: the caller holds the context's lock. The same life cycle as the depth24 converter's own
5// scratch (vulkan_depth24.h), which also needs descriptor pools and exists only on GPUs without D24. 5// scratch (vulkan_depth24.h), which also needs descriptor pools and exists only on GPUs without D24.
6// The chunks are transfer sources and destinations; `extra_usage` adds what another user needs (the expanded indices
7// of quad lists, quad_index_expand.h: an index buffer written through its device address).
6#pragma once 8#pragma once
7 9
8#ifndef VK_NO_PROTOTYPES 10#ifndef VK_NO_PROTOTYPES
@@ -23,8 +25,8 @@ public:
23 // A device-local allocation for a chunk; null on failure. 25 // A device-local allocation for a chunk; null on failure.
24 using Allocate = std::function<VkDeviceMemory(const VkMemoryRequirements&)>; 26 using Allocate = std::function<VkDeviceMemory(const VkMemoryRequirements&)>;
25 27
26 ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate) 28 ScratchBuffers(PFN_vkGetDeviceProcAddr get, VkDevice device, Allocate allocate, VkBufferUsageFlags extra_usage = 0)
27 : device_(device), allocate_(std::move(allocate)) { 29 : device_(device), allocate_(std::move(allocate)), extra_usage_(extra_usage) {
28 loaded_ = vk_.load(get, device); 30 loaded_ = vk_.load(get, device);
29 } 31 }
30 32
@@ -148,7 +150,7 @@ private:
148 bool make_chunk(std::uint64_t size, Chunk& out) { 150 bool make_chunk(std::uint64_t size, Chunk& out) {
149 VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO}; 151 VkBufferCreateInfo info{VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO};
150 info.size = size; 152 info.size = size;
151 info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT; 153 info.usage = VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | extra_usage_;
152 if (vk_.vkCreateBuffer(device_, &info, nullptr, &out.buffer) != VK_SUCCESS) return false; 154 if (vk_.vkCreateBuffer(device_, &info, nullptr, &out.buffer) != VK_SUCCESS) return false;
153 VkMemoryRequirements requirements{}; 155 VkMemoryRequirements requirements{};
154 vk_.vkGetBufferMemoryRequirements(device_, out.buffer, &requirements); 156 vk_.vkGetBufferMemoryRequirements(device_, out.buffer, &requirements);
@@ -172,6 +174,7 @@ private:
172 174
173 VkDevice device_; 175 VkDevice device_;
174 Allocate allocate_; 176 Allocate allocate_;
177 VkBufferUsageFlags extra_usage_ = 0;
175 Functions vk_; 178 Functions vk_;
176 bool loaded_ = false; 179 bool loaded_ = false;
177 Batch current_; // handed out, not yet submitted 180 Batch current_; // handed out, not yet submitted