mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-12 22:56:09 +00:00
D3D12: Align UBO sizes to 256B.
D3D debug layer uses the descriptor size (width) to validate CBV bounds when directly allocating UBOs. This causes validation failure when the buffer size is misaligned (ie. not a multiple of 256B) even through the underlying resource heap size is always 64KB aligned. This change always aligns the buffer size to be 256B to avoid such validation error should sub-allocation fail. BUG=dawn:506 Change-Id: Ic9072934cac65cfd25d0e2a20cb364bd3ca88e3b Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26820 Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Bryan Bernhart <bryan.bernhart@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
95e715873d
commit
ac3765e663
@@ -98,14 +98,6 @@ bool IsAligned(uint32_t value, size_t alignment) {
|
||||
return (value & (alignment32 - 1)) == 0;
|
||||
}
|
||||
|
||||
uint32_t Align(uint32_t value, size_t alignment) {
|
||||
ASSERT(alignment <= UINT32_MAX);
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
uint32_t alignment32 = static_cast<uint32_t>(alignment);
|
||||
return (value + (alignment32 - 1)) & ~(alignment32 - 1);
|
||||
}
|
||||
|
||||
uint16_t Float32ToFloat16(float fp32) {
|
||||
uint32_t fp32i = BitCast<uint32_t>(fp32);
|
||||
uint32_t sign16 = (fp32i & 0x80000000) >> 16;
|
||||
|
||||
@@ -51,7 +51,15 @@ uint64_t NextPowerOfTwo(uint64_t n);
|
||||
bool IsPtrAligned(const void* ptr, size_t alignment);
|
||||
void* AlignVoidPtr(void* ptr, size_t alignment);
|
||||
bool IsAligned(uint32_t value, size_t alignment);
|
||||
uint32_t Align(uint32_t value, size_t alignment);
|
||||
|
||||
template <typename T>
|
||||
T Align(T value, size_t alignment) {
|
||||
ASSERT(value <= std::numeric_limits<T>::max() - (alignment - 1));
|
||||
ASSERT(IsPowerOfTwo(alignment));
|
||||
ASSERT(alignment != 0);
|
||||
T alignmentT = static_cast<T>(alignment);
|
||||
return (value + (alignmentT - 1)) & ~(alignmentT - 1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
DAWN_FORCE_INLINE T* AlignPtr(T* ptr, size_t alignment) {
|
||||
|
||||
Reference in New Issue
Block a user