diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:48:12 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 18:48:12 -0500 |
| commit | fb2afdccc2314d7b5a59fac10e6d6df7f5df35ab (patch) | |
| tree | 9e0b7e2e39b42823f148d135ce781e57fab52155 /runtime/src/vulkan_scratch.h | |
| parent | 862890c893eb19eb39eb2fd95e7786e42ff4b18c (diff) | |
| parent | 864337351bc11a250db77c2fcdd3ba6f1d0f455f (diff) | |
Merge main into RT-QUEUE18 (#403)
Merged on top of the merge made for #396 (main 507029d1e plus RT-QUEUE35,
RT-ALLOC9 and RT-LIST139). No conflicts.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/vulkan_scratch.h')
| -rw-r--r-- | runtime/src/vulkan_scratch.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/src/vulkan_scratch.h b/runtime/src/vulkan_scratch.h index 4a8a59ddd..33d84bf72 100644 --- a/runtime/src/vulkan_scratch.h +++ b/runtime/src/vulkan_scratch.h | |||
| @@ -46,12 +46,16 @@ public: | |||
| 46 | constexpr VkDeviceSize alignment = 256, minimum = 4u << 20; | 46 | constexpr VkDeviceSize alignment = 256, minimum = 4u << 20; |
| 47 | if (!loaded_ || !bytes) return false; | 47 | if (!loaded_ || !bytes) return false; |
| 48 | for (auto& chunk : current_.chunks) { | 48 | for (auto& chunk : current_.chunks) { |
| 49 | const VkDeviceSize start = (chunk.used + alignment - 1) / alignment * alignment; | 49 | const VkDeviceSize rem = chunk.used % alignment; |
| 50 | if (start <= chunk.size && bytes <= chunk.size - start) { | 50 | const VkDeviceSize pad = rem ? alignment - rem : 0; |
| 51 | chunk.used = start + bytes; | 51 | if (pad <= chunk.size - chunk.used) { |
| 52 | buffer = chunk.buffer; | 52 | const VkDeviceSize start = chunk.used + pad; |
| 53 | offset = start; | 53 | if (bytes <= chunk.size - start) { |
| 54 | return true; | 54 | chunk.used = start + bytes; |
| 55 | buffer = chunk.buffer; | ||
| 56 | offset = start; | ||
| 57 | return true; | ||
| 58 | } | ||
| 55 | } | 59 | } |
| 56 | } | 60 | } |
| 57 | Chunk chunk; | 61 | Chunk chunk; |