gpu-alloc icon indicating copy to clipboard operation
gpu-alloc copied to clipboard

Thoughts on potential dx12 support?

Open Elabajaba opened this issue 2 years ago • 3 comments

I've implemented dx12 suballocations in wgpu, but I was unable to use this crate for it due to the differences between vk and dx12's memory allocation strategies. Dx12 has you allocate an ID3D12Heap, but then you pass that into CreatePlacedResource which gives you an ID3D12Resource that you can then map/unmap/etc, vs Vulkan where you can do all that with just a DeviceMemory.

I haven't dug into what kind of changes enabling the dx12 method would entail, beyond the surface level of changing the MemoryDevice trait, but my initial impression is that it's probably better to just use a separate dx12 allocator instead of trying to duct tape dx12 support onto gpu-alloc.

I was wondering what your thoughts were on this, how difficult it might be, and if you even had any interest in including dx12 support in gpu-alloc?

Elabajaba avatar Nov 04 '22 01:11 Elabajaba

As I understand it, gpu-alloc should not create ID3D12Resources. It should only work on the level of ID3D12Heap. gpu-alloc allocation routine would simply return ID3D12Heap + offset + size for allocation requests and then user would create ID3D12Resources using CreatePlacedResource as needed, possibly suballocating from returned range.

zakarumych avatar Nov 07 '22 09:11 zakarumych

gpu-alloc mapping API should be changed to reflect that mapping of ranges from ID3D12Heap is now allowed directly. Or maybe allow it using internal overlapping ID3D12Resources objects?

zakarumych avatar Nov 07 '22 09:11 zakarumych

I made a gist of some of the current issues I've run into trying to use this with dx12, which include creating the allocator not mapping well to dx12, and the fact that gpu_alloc's map/unmap_memory and memory_range stuff don't seem to be useful currently for dx12.

Elabajaba avatar Nov 07 '22 22:11 Elabajaba