chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
14 / 14
100.0%
Branches:
14 / 18
77.8%
Functions:
-
-%

device/kernels/shared.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #ifdef __SLANG__
5
6 #define CHRONO_BATCH_RENDER_SHARED
7 #define CHRONO_BATCH_RENDER_CHECK_SIZE(type, bytes)
8 #define CHRONO_BATCH_RENDER_ENUM(name) enum class name : uint
9
10 #else
11
12 #include <algorithm>
13 #include <cmath>
14 #include <cstdint>
15 #include <cstring>
16
17 #define CHRONO_BATCH_RENDER_SHARED inline
18 #define CHRONO_BATCH_RENDER_CHECK_SIZE(type, bytes) \
19 static_assert(sizeof(type) == (bytes), #type " keeps its shared layout")
20 #define CHRONO_BATCH_RENDER_ENUM(name) enum class name : uint32_t
21
22 namespace chrono::batch_render {
23
24 using uint = uint32_t;
25
26 1142737 constexpr uint64_t RoundUp(uint64_t value, uint64_t multiple) {
27
8/10
✓ Branch 0 taken 297 times.
✓ Branch 1 taken 29 times.
✓ Branch 1 taken 7172 times.
✓ Branch 1 taken 26929 times.
✓ Branch 2 taken 30 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 832 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 7 times.
1105373 return (value + multiple - 1) / multiple * multiple;
28 }
29
30 using std::ceil;
31 using std::clamp;
32 using std::floor;
33 using std::log2;
34 using std::max;
35 using std::min;
36 using std::pow;
37
38 template <class T> struct Ptr {
39 uint64_t address = 0;
40 };
41
42 111292 inline float asfloat(uint bits) {
43 111292 float value;
44 109240 std::memcpy(&value, &bits, sizeof(value));
45 109240 return value;
46 }
47
48 65825 inline uint asuint(float value) {
49 65825 uint bits;
50
3/4
<unknown function 26>:
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
<unknown function 42>:
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 63505 times.
65826 std::memcpy(&bits, &value, sizeof(bits));
51
3/4
<unknown function 26>:
✗ Branch 0 not taken.
✓ Branch 1 taken 256 times.
<unknown function 42>:
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 63505 times.
65825 return bits;
52 }
53
54 }
55
56 #endif
57