diff options
| author | DadaCap <167002618+DadaCap@users.noreply.github.com> | 2026-11-24 21:09:02 +0100 |
|---|---|---|
| committer | DadaCap <167002618+DadaCap@users.noreply.github.com> | 2026-11-24 21:09:02 +0100 |
| commit | bc245e5046124941bbdc7bb5c3bd7c739da4e03e (patch) | |
| tree | 5b780fbcbc1dd131ee635980dfe3e996ac72928f /runtime/src/vulkan_scratch.h | |
| parent | 30450e0e96e1df700bbfa9505433c9b9940e8694 (diff) | |
| parent | 58be9cdf8df9a31bc7f6c068991f1aed381f7f4d (diff) | |
Merge remote-tracking branch 'origin/main' into vcc-tuple-resync
Co-Authored-By: Claude Opus 5.5 <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; |