Unity to Godot Part 9: Buffers and decals
These last couple of weeks I've been in the graphics rabbit hole, digging and climbing and digging again. I've finished porting the particle systems, so the next target was decals (like blood, footsteps and text bubbles). The relevant code was ported, with some significant alterations, especially with regards to CPU/GPU buffers, which can now be resized (previously I was using fixed preallocated buffers). Resizing buffers is not that trivial, because resources that have been "built" using the old buffers need to be rebuilt when the buffer gets resized, as under the hood the GPU resource has to be reallocated.
To make matters (and graphics development) a bit more complicated, it's not crystal clear how Godot manages the opaque resource IDs (source code is there, but I've been too "lazy" to delve deep) so it's easy to get errors related to either leaking IDs or attempting to free invalid IDs. And an additional mini-frustration is that these errors are not easily "accessible"/visible while debugging C# code -- you can step over a C# call to a Godot C++ function, the error triggers in there but is not made visible anywhere, and at some point the buffers get flushed to console and we get notified.
I've also been porting/fixing somm atlas-related tools (e.g. generation of atlas specification from directories, distance field generation, fixups related to alpha channel, etc)