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

Allocator type is quite large

Open i509VCB opened this issue 2 years ago • 2 comments

The allocator type is quite large. This is due to holding a ash::Device.

Summary of -Z print-type-sizes (cargo +nightly rustc -- -Z print-type-sizes):

print-type-size type: `gpu_allocator::vulkan::Allocator`: 1552 bytes, alignment: 8 bytes
print-type-size     field `.device`: 1488 bytes
print-type-size     field `.buffer_image_granularity`: 8 bytes
print-type-size     field `.memory_types`: 24 bytes
print-type-size     field `.memory_heaps`: 24 bytes
print-type-size     field `.debug_settings`: 6 bytes
print-type-size     end padding: 2 bytes

A possible solution could be to hold an ash::vk::Device handle and then load the function pointers the allocator uses.

i509VCB avatar Mar 23 '23 00:03 i509VCB

Happy to accommodate and wrap this in an Arc as suggested in https://github.com/ash-rs/ash/issues/731#issuecomment-1493382084 - we do that internally in our codebase as well and have a device: device.as_ref().clone() with comment on AllocatorCreateDesc to duplicate the function pointers. Let's settle https://github.com/ash-rs/ash/issues/731 before definitively doing so though.

MarijnS95 avatar Apr 02 '23 16:04 MarijnS95