Open devshgraphicsprogramming opened 2 years ago
Additional Comments based on talk with @devshgraphicsprogramming
Additional Comments based on talk with @devshgraphicsprogramming
* Pack buffers with similar usages together into seperate classes (same for images), new BufferAPI allows suballocating buffers from a big IDeviceMemoryAllocation * We convert assets in several passes : for example 1. batch splitting (figure out all the dependants) and assign to their classes 2. Create GPU resources 3. ????
buffers are packed together already, notice that ICPUBuffer
does not produce a IGPUBuffer
it produces an SBufferOffset<IGPUBuffer>
, but obvs we cant fuse different usage buffers together.
IDeviceMemoryAllocation fusing is what could allow us to put multiple buffers (and images) with different usages in the same memory allocation.
Description
Need an asset converter that works.
Description of the related problem
Current converted not suitable for Vulkan, does not:
Perf/Efficiency:
Ergonomics and Correctness:
Solution proposal
dynamic_refctd_array<IAsset>
of root assets + conversion options argument (currentSParams
)unordered_map<cpu_asset_type_and_metadata,gpu_asset_type_and_metadata>
to store all assets to convert, the key metadata will probably just be the promoted format if any, the value metadata will contain modifiers like additional usages etc.dynamic_refctd_array<IReferenceCounted>
wrapped in a utility structSpecial concerns:
Additional context
Hash certain objects to not create needless copies
You can hash samplers, and descriptor set layouts, pipeline layouts (via hash consing).
This will reduce the number of samplers and layouts created (important cause VK has limits on this shit).
You can apply this regardless of if the
assetManager
has been provided as an external cache (also useful to make it work on hashes of the samplers and layouts).CPU Asset Usages are hints
When creating a Buffer or Image (or in the future ImageView) remember that usages are hints, you need to patch them up during DAG traversal (add usages which are implied by the DAG if they're not there already).
You cannot however, "narrow down the usages" if a user has explicitly stated that a Buffer has a usage, it must have that usage.
This allows us to handle promotion and de-aliasing better, as de-aliased buffers and images are an extra copy and not the original, hence they need not have any of the usages explicitly enumerated by the original, only the implicit ones from the views that actually use them.
Controlling Options
General Options:
nullptr
for the associated retval slot)Patching-up BufferViews and VertexAttribute Bindings
After converting an entire buffer range due to a promotion, the relative offset may change due to shrinking and/or having a larger format.
This is also a concern for strides for vertex buffer bindings in graphics pipelines and acceleration structures.