chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
9 / 9
100.0%
Branches:
8 / 15
53.3%
Functions:
3 / 3, 2 excl
100.0%

scene/tables/subsets.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 #pragma once
3
4 #include <cstdint>
5 #include <set>
6 #include <span>
7 #include <string_view>
8 #include <unordered_map>
9 #include <vector>
10
11 #include "chrono_batch_render/device/program.h"
12 #include "chrono_batch_render/device/ref.h"
13 #include "chrono_batch_render/scene/records/meshes.h"
14 #include "chrono_batch_render/scene/tables/storage.h"
15 #include "chrono_batch_render/scene/tables/table.h"
16 #include "chrono_batch_render/stage/structure/structure.h"
17
18 namespace chrono::batch_render {
19
20 353 struct SubsetStats {
21 uint32_t meshes = 0;
22 uint32_t subsets = 0;
23 bool rebuilt = false;
24 };
25
26 class SubsetTable : public RenderTable {
27 public:
28
1/3
✓ Branch 1 taken 353 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
353 explicit SubsetTable(Structure& structure) : m_structure(structure) {}
29
30 928 std::string_view Name() const override {
31 928 return "subsets";
32 }
33
34 std::span<const ColumnRef> Inputs() const override;
35 void Describe(RenderTables& tables) const override;
36 void Prepare() override;
37 void Run(const ChangeSet& changes, TableVersions& versions) override;
38
39 928 void Hold(std::vector<Ref<const RefCounted>>& held) const override {
40
4/8
✓ Branch 0 taken 928 times.
✓ Branch 1 taken 928 times.
✓ Branch 2 taken 927 times.
✓ Branch 3 taken 1 time.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
1856 HoldBuffers(held, {m_records.Buffer()});
41 1856 }
42
43 const SubsetStats& Stats() const {
44 return m_stats;
45 }
46
47 4 const SubsetRecord& Record(uint32_t meshRow) const {
48
3/4
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 time.
✓ Branch 3 taken 3 times.
8 return m_records.Row(meshRow);
49 }
50
51 private:
52 device::Program& Kernels();
53 void Rebuild();
54
55 Structure& m_structure;
56 Ref<device::Program> m_program;
57 RecordTable<SubsetRecord> m_records{"subset records"};
58 std::set<uint32_t> m_subsets;
59 std::unordered_map<uint32_t, SubsetRecord> m_written;
60 uint64_t m_seen = 0;
61 bool m_built = false;
62 SubsetStats m_stats;
63 };
64
65 }
66