chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
12 / 12
100.0%
Branches:
8 / 18
44.4%
Functions:
4 / 4
100.0%

scene/tables/bounds.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstdint>
5 #include <optional>
6 #include <span>
7 #include <string_view>
8 #include <vector>
9
10 #include "chrono_batch_render/bvh/kernels/bvh.h"
11 #include "chrono_batch_render/device/buffer.h"
12 #include "chrono_batch_render/device/program.h"
13 #include "chrono_batch_render/device/ref.h"
14 #include "chrono_batch_render/scene/records/bounds.h"
15 #include "chrono_batch_render/scene/tables/instances.h"
16 #include "chrono_batch_render/scene/tables/storage.h"
17 #include "chrono_batch_render/scene/tables/table.h"
18 #include "chrono_batch_render/stage/structure/structure.h"
19
20 namespace chrono::batch_render {
21
22 class BoundsTable : public RenderTable {
23 public:
24 353 BoundsTable(Structure& structure, const RenderTables& tables, const InstanceTable& instances)
25
2/8
✓ Branch 1 taken 353 times.
✓ Branch 5 taken 353 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
1059 : m_structure(structure), m_tables(tables), m_instances(instances) {}
26
27 928 std::string_view Name() const override {
28 928 return "bounds";
29 }
30
31 std::span<const ColumnRef> Inputs() const override;
32
33 2589 std::span<const TableId> TableInputs() const override {
34 2589 static constexpr TableId kTables[] = {
35 TableId::Transforms, TableId::Imageables, TableId::Meshes,
36 TableId::MeshPoints, TableId::Points, TableId::PointsMoved,
37 TableId::Curves, TableId::CurvesMoved, TableId::Instances};
38 2589 return kTables;
39 }
40
41 void Prepare() override;
42 void Run(const ChangeSet& changes, TableVersions& versions) override;
43
44 void Describe(RenderTables& tables) const override;
45
46 213 const Ref<device::Buffer>& PrimBounds() const {
47
2/2
✓ Branch 1 taken 113 times.
✓ Branch 4 taken 100 times.
213 return m_primBounds.Buffer();
48 }
49
50 928 void Hold(std::vector<Ref<const RefCounted>>& held) const override {
51
4/8
✓ Branch 0 taken 1856 times.
✓ Branch 1 taken 928 times.
✓ Branch 2 taken 1854 times.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
2784 HoldBuffers(held, {m_boxes.Buffer(), m_primBounds.Buffer()});
52 1856 }
53
54 std::optional<BvhBox> World(uint32_t world) const;
55 device::Download ReadWorldAsync(uint32_t world) const;
56 device::Download ReadWorldsAsync() const;
57
58 private:
59 void Relayout();
60
61 Structure& m_structure;
62 const RenderTables& m_tables;
63 const InstanceTable& m_instances;
64 device::Program& Kernels();
65
66 Ref<device::Program> m_program;
67 Ref<device::Buffer> m_origins;
68 Ref<device::Buffer> m_extents;
69 DeviceTable<BvhBox> m_boxes{"world bounds"};
70 DeviceTable<BoundableBox> m_primBounds{"prim bounds"};
71 Ref<device::Buffer> m_instancerExtents;
72 uint64_t m_epoch = ~uint64_t(0);
73 };
74
75 }
76