chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
27 / 32
84.4%
Branches:
17 / 21
81.0%
Functions:
4 / 5
80.0%

scene/tables/procedural.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #include "chrono_batch_render/scene/tables/procedural.h"
3
4 #include <string>
5
6 #include "chrono_batch_render/bvh/kernels/bvh.h"
7 #include "chrono_batch_render/device/device.h"
8
9 namespace chrono::batch_render {
10
11 129 void ProceduralBlas::Allocate(device::Device& device, bvh::Builder& builder, uint32_t count,
12 std::string_view label) {
13 129 capacity = count;
14
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 94 times.
129 blas = nullptr;
15
2/2
✓ Branch 0 taken 35 times.
✓ Branch 1 taken 94 times.
129 boxes = nullptr;
16 129 fresh = true;
17
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 8 times.
129 if (count == 0) {
18 return;
19 }
20
1/1
✓ Branch 1 taken 121 times.
242 boxes = device.CreateBuffer({.bytes = uint64_t(count) * sizeof(BvhBox),
21 .usage = device::BufferUsage::AccelBuildInput,
22
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 121 times.
121 .label = std::string(label)});
23 121 blas = builder.CreateBlas(
24
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 121 times.
121 device::AccelBoxes{.boxes = boxes->Slice(0), .count = count, .refittable = true});
25 242 }
26
27 215 void ProceduralBlas::Bound(ColumnStore& store) {
28
2/2
✓ Branch 0 taken 86 times.
✓ Branch 1 taken 129 times.
215 if (bounds.count == 0) {
29 86 bounds = store.Arrays(ColumnType::Float3Array).Allocate(2);
30 }
31 215 }
32
33 ✗ void ProceduralBlas::Release(ColumnStore& store) {
34
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ if (bounds.count > 0) {
35 ✗ store.Arrays(ColumnType::Float3Array).Free(bounds);
36 ✗ bounds = {};
37 }
38 ✗ }
39
40 205 bool ProceduralBlas::Rebuilds(uint32_t maxRefits) {
41
4/4
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 157 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 45 times.
205 if (fresh || refits >= maxRefits) {
42 160 fresh = false;
43 160 refits = 0;
44 160 return true;
45 }
46 45 ++refits;
47 45 return false;
48 }
49
50 283 void ProceduralBlas::Hold(std::vector<Ref<const RefCounted>>& held) const {
51
2/2
✓ Branch 0 taken 275 times.
✓ Branch 1 taken 8 times.
283 if (blas) {
52 275 held.emplace_back(blas);
53 275 held.emplace_back(boxes);
54 }
55 283 }
56
57 }
58