mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-13 15:16:16 +00:00
Add end2end test for all vertex formats
BUG=dawn:41 Change-Id: I37bde37843522a8d7c8b3bea1cb24c0971efd8e2 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6340 Reviewed-by: Kai Ninomiya <kainino@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Shaobo Yan <shaobo.yan@intel.com>
This commit is contained in:
committed by
Commit Bot service account
parent
a32e3bd014
commit
9286adcb0f
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "common/Assert.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(DAWN_COMPILER_MSVC)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
@@ -77,3 +79,29 @@ uint32_t Align(uint32_t value, size_t alignment) {
|
||||
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;
|
||||
uint32_t mantissaAndExponent = fp32i & 0x7FFFFFFF;
|
||||
|
||||
if (mantissaAndExponent > 0x47FFEFFF) { // Infinity
|
||||
return static_cast<uint16_t>(sign16 | 0x7FFF);
|
||||
} else if (mantissaAndExponent < 0x38800000) { // Denormal
|
||||
uint32_t mantissa = (mantissaAndExponent & 0x007FFFFF) | 0x00800000;
|
||||
int32_t exponent = 113 - (mantissaAndExponent >> 23);
|
||||
|
||||
if (exponent < 24) {
|
||||
mantissaAndExponent = mantissa >> exponent;
|
||||
} else {
|
||||
mantissaAndExponent = 0;
|
||||
}
|
||||
|
||||
return static_cast<uint16_t>(
|
||||
sign16 | (mantissaAndExponent + 0x00000FFF + ((mantissaAndExponent >> 13) & 1)) >> 13);
|
||||
} else {
|
||||
return static_cast<uint16_t>(sign16 | (mantissaAndExponent + 0xC8000000 + 0x00000FFF +
|
||||
((mantissaAndExponent >> 13) & 1)) >>
|
||||
13);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user