Allocate and upload data to the GPU - #3510
Conversation
| .flags = 0, | ||
| .physicalDevice = physicalDevice, | ||
| .device = device, | ||
| .preferredLargeHeapBlockSize = 128 << 9, // TODO: What does this do? |
There was a problem hiding this comment.
Why this blizzard way of saying 65536?
There was a problem hiding this comment.
Based on my extended research, I think this controls the size of actual allocation (size of object rounded up) when allocation crosses the threshold that classifies it as large allocation.
Or more precisely, the overshoot of that allocation when allocating above 1GB, eg. If I alloc 1.1GB, with defaults it gets rounded to 1.25GB (block of 0.25GB)
There was a problem hiding this comment.
But why allocate more than needed?
There was a problem hiding this comment.
For same reason GPA does it. I have no idea.
I think this eases the consequences of deallocaitng and allocating again with just a bit different size (or reallocating or whatever).
If you perfect fit it, you can only use it for identical or smaller object.
And allocation calls are bad too, so I would assume they preallocate blocks instead of just calling driver for every object.
This required several more changes to get working: - support for push constants (I decided to only make the size configurable, we don't need multiple with offset for now, and as far as I can tell there is not going to be much of a performance impact from this, and from always specifying all stage flags) - support for vertex/index buffers (this was easy after #3510) - Configuration of input assembly stage (fixing two TODOs from the code) - To make it easier to introduce the new configs, I decided to finally use a struct parameter for pipeline creation which holds all the vulkan stuff - empty star VAO is not easily convertible to vulkan (vulkan does not like empty stuff at all) - some small fixes Apart from the push constant config, everything else takes the exact same lines of code as the previous OpenGL config. However a most of the drawing logic (uniforms, bindings, draw command) is currently duplicated. But I don't think it's worth creating a unified API for these things, as we are going to get rid of OpenGL once the vulkan rewrite is complete. progress towards #102 <img width="2377" height="857" alt="Screenshot at 2026-08-16 09-32-41" src="https://github.com/user-attachments/assets/a760176d-f273-4d77-b7a0-e0d4909a6f58" />
Upload happens using a staging buffer on a separate command buffer which gets submitted (and synchronized) before the other command buffers.
I also had to add a garbage collection thing for triple buffering, and I also hardcoded the number of frames to 2, any more than that and we have too much latency anyways.
progress towards #102