-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dx12: Add dynamically sized CPU descriptor heaps #2110
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One nit, otherwise good to sail!
} | ||
} | ||
|
||
// Fixed-size (64) free-list allocator for CPU descriptors. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's have this defined as a constant here
|
||
pub fn alloc_handle(&mut self) -> d3d12::D3D12_CPU_DESCRIPTOR_HANDLE { | ||
// Find first free slot | ||
let slot = (0..64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add TODO to use https://doc.rust-lang.org/std/intrinsics/fn.ctlz.html (or actually do it behind the
nightly` feature ;) )
fca3ccf
to
6911688
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love those trailing zeroes:) A few more concerns below:
// | ||
// 0 - Occupied | ||
// 1 - free | ||
occupancy: u64, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be renamed into availability
to avoid confusion
} | ||
} | ||
|
||
pub fn full(&self) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given that this is not an accessor, I don't think it's idiomatic to omit the verb here. Should be is_full()
to mimic is_empty()
in standard collections
assert!(!self.full()); | ||
|
||
// Find first free slot. | ||
let slot = self.occupancy.trailing_zeros() as usize; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nice! What's the result if we were running it on !0
? should we perhaps move the assert down here checking for slot < HEAP_SIZE_FIXED
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!0 returns 0.
yes, that assert check looks a bit nicer.
Greatness here! |
2110: dx12: Add dynamically sized CPU descriptor heaps r=kvark a=msiglreith Dynamic allocator for CPU descriptor heaps. We currently have 2 ways of allocating CPU descriptors: from a device global heap and command local linear allocators. This PR cleans up the two paths a bit and fixes the current size limitation for the first kind by dynamically creating new small fixed size CPU heaps. Freeing currently not support but that's not an regression as we didn't support it before either. Small 'regression' concerning `fill_buffer` which was implemented incorrectly as far as I can see. Probably would work only on AMD. This breaks the fill reftests. Fixes #1915 PR checklist: - [x] tested quad, relevant CTS and a few vulkan samples with the following backends: dx12 Co-authored-by: msiglreith <m.siglreith@gmail.com>
Dynamic allocator for CPU descriptor heaps. We currently have 2 ways of allocating CPU descriptors: from a device global heap and command local linear allocators. This PR cleans up the two paths a bit and fixes the current size limitation for the first kind by dynamically creating new small fixed size CPU heaps.
Freeing currently not support but that's not an regression as we didn't support it before either.
Small 'regression' concerning
fill_buffer
which was implemented incorrectly as far as I can see. Probably would work only on AMD. This breaks the fill reftests.Fixes #1945
PR checklist: