chrono_batch_render/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
14 / 14
100.0%
Branches:
11 / 25
44.0%
Functions:
3 / 3, 2 excl
100.0%

scene/tables/lights.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 <vector>
8
9 #include "chrono_batch_render/device/buffer.h"
10 #include "chrono_batch_render/device/program.h"
11 #include "chrono_batch_render/device/ref.h"
12 #include "chrono_batch_render/scene/tables/instances.h"
13 #include "chrono_batch_render/scene/tables/kernels/lights.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 class LightTable : public RenderTable {
21 public:
22 353 LightTable(Structure& structure, const RenderTables& tables, const InstanceTable& instances)
23
2/16
✓ 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.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
1059 : m_structure(structure), m_tables(tables), m_instances(instances) {}
24
25 928 std::string_view Name() const override {
26 928 return "lights";
27 }
28
29 std::span<const ColumnRef> Inputs() const override;
30
31 2545 std::span<const TableId> TableInputs() const override {
32 2545 static constexpr TableId kTables[] = {TableId::Transforms, TableId::Imageables,
33 TableId::Textures, TableId::Instances};
34 2545 return kTables;
35 }
36
37 void Prepare() override;
38 void Run(const ChangeSet& changes, TableVersions& versions) override;
39
40 const Ref<device::Buffer>& Layout() const {
41
1/1
✓ Branch 1 taken 1 time.
1 return m_layout;
42 }
43
44 const Ref<device::Buffer>& Records() const {
45
1/1
✓ Branch 1 taken 17 times.
17 return m_records;
46 }
47
48 const Ref<device::Buffer>& MinimalLights() const {
49
1/1
✓ Branch 1 taken 4 times.
4 return m_minimal;
50 }
51
52 30 std::span<const uint32_t> Counts() const {
53
5/5
✓ Branch 1 taken 1 time.
✓ Branch 5 taken 1 time.
✓ Branch 8 taken 1 time.
✓ Branch 11 taken 1 time.
✓ Branch 14 taken 1 time.
30 return m_counts;
54 }
55
56 1 uint32_t Written() const {
57
1/1
✓ Branch 1 taken 1 time.
1 return m_written;
58 }
59
60 const Ref<device::Buffer>& Spectra();
61
62 void Describe(RenderTables& tables) const override;
63 void Hold(std::vector<Ref<const RefCounted>>& held) const override;
64
65 private:
66 bool Restructured(const ChangeSet& changes) const;
67 void Relayout();
68 void WriteCollectionsAndShapes();
69 device::Program& Kernels();
70
71 Structure& m_structure;
72 const RenderTables& m_tables;
73 Ref<device::Program> m_program;
74 Ref<device::Buffer> m_layout;
75 Ref<device::Buffer> m_minimal;
76 Ref<device::Buffer> m_records;
77 Ref<device::Buffer> m_cdf;
78 Ref<device::Buffer> m_maps;
79 Ref<device::Buffer> m_spectra;
80 DeviceTable<CollectionRecord> m_collections{"collection records"};
81 DeviceTable<LightShapeRecord> m_shapes{"light shape records"};
82 std::set<uint32_t> m_lights;
83 std::set<uint32_t> m_worldPrims;
84 std::map<uint32_t, std::set<uint32_t>> m_shownIn;
85 uint64_t m_compositions = ~uint64_t(0);
86 std::vector<uint32_t> m_counts;
87 uint32_t m_worlds = 0;
88 uint32_t m_domes = 0;
89 uint64_t m_seen = 0;
90 const InstanceTable& m_instances;
91 uint32_t m_written = 0;
92 };
93
94 }
95