chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
2 / 2
100.0%
Branches:
5 / 7
71.4%
Functions:
-
-%

stage/schema/primvars.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include "chrono_batch_render/device/kernels/shared.h"
5
6 namespace chrono::batch_render {
7
8 CHRONO_BATCH_RENDER_ENUM(PrimvarType) {
9 Float,
10 Float2,
11 Float3,
12 Float4,
13 Int,
14 Int2,
15 Int3,
16 Int4,
17 };
18
19 struct PrimvarEntry {
20 uint name;
21 uint type;
22 uint interpolation;
23 uint elementSize;
24 uint values;
25 uint valueCount;
26 uint indices;
27 uint indexCount;
28 };
29
30 CHRONO_BATCH_RENDER_CHECK_SIZE(PrimvarEntry, 32);
31
32 static const uint kPrimvarEntryWords = 8;
33
34 169 CHRONO_BATCH_RENDER_SHARED uint PrimvarComponents(PrimvarType type) {
35
5/7
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 1 time.
✓ Branch 1 taken 10 times.
✓ Branch 3 taken 54 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 54 times.
✗ Branch 8 not taken.
169 return uint(type) % 4 + 1;
36 }
37
38 CHRONO_BATCH_RENDER_SHARED bool PrimvarIsInt(PrimvarType type) {
39 return uint(type) >= uint(PrimvarType::Int);
40 }
41
42 #ifdef __SLANG__
43
44 bool FindPrimvarEntry(uint64_t table, uint words, uint name, out PrimvarEntry found) {
45 found = {};
46 if (words == 0) {
47 return false;
48 }
49 const Ptr<PrimvarEntry> entries = Ptr<PrimvarEntry>(table + sizeof(uint));
50 uint low = 0;
51 uint high = Ptr<uint>(table)[0];
52 while (low < high) {
53 const uint middle = (low + high) / 2;
54 const PrimvarEntry entry = entries[middle];
55 if (entry.name == name) {
56 found = entry;
57 return true;
58 }
59 if (entry.name < name) {
60 low = middle + 1;
61 } else {
62 high = middle;
63 }
64 }
65 return false;
66 }
67
68 #endif
69
70 }
71