D3D12: Bucket descriptor allocation by powers of two

WebGPU currently allows as many as 108 view descriptors per bind
group. This is too many to have one descriptor allocator per size,
so we need to bucket them by size.

Bug: dawn:443, dawn:488
Change-Id: I4fc8cf7cd0dc8292bb6a8488fd2ceb7575e1e5f7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24787
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Bryan Bernhart <bryan.bernhart@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2020-07-17 01:11:16 +00:00
committed by Commit Bot service account
parent e8e089ad28
commit cb2938a1af
4 changed files with 86 additions and 17 deletions

View File

@@ -31,6 +31,22 @@ uint32_t Log2(uint64_t value);
bool IsPowerOfTwo(uint64_t n);
uint64_t RoundUp(uint64_t n, uint64_t m);
constexpr uint32_t ConstexprLog2(uint64_t v) {
return v <= 1 ? 0 : 1 + ConstexprLog2(v / 2);
}
constexpr uint32_t ConstexprLog2Ceil(uint64_t v) {
return v <= 1 ? 0 : ConstexprLog2(v - 1) + 1;
}
inline uint32_t Log2Ceil(uint32_t v) {
return v <= 1 ? 0 : Log2(v - 1) + 1;
}
inline uint32_t Log2Ceil(uint64_t v) {
return v <= 1 ? 0 : Log2(v - 1) + 1;
}
uint64_t NextPowerOfTwo(uint64_t n);
bool IsPtrAligned(const void* ptr, size_t alignment);
void* AlignVoidPtr(void* ptr, size_t alignment);