GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
24 / 24
100.0%
Branches:
23 / 46
50.0%
Functions:
3 / 3
100.0%

render/rt/ray_tracer.cpp
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file ray_tracer.cpp
3 /// @brief Keeping the acceleration structures up to date each frame.
4 #include "ernie/render/rt/ray_tracer.h"
5
6 #include "ernie/shaders/device/buffer_ref.h"
7 #include "ernie/shaders/rt/ray_tracer.h"
8 #include "ernie/shaders/scene/geometry.h"
9 #include "ernie/shaders/scene/shapes.h"
10 #include "ernie/util/profiler.h"
11
12 #include <array>
13
14 namespace ernie {
15
16 15 RayTracer::RayTracer(DeviceContext& context, Arenas& arenas, const ShaderCompiler& compiler,
17 15 const GeometryPool& geometry)
18
1/2
✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
15 : geometry_(geometry), bottoms_(context, arenas, geometry), tops_(context, compiler) {}
19
20 34 std::span<const ShaderModule> RayTracer::Modules() {
21 34 static const std::array modules{shaders::kBufferRef, shaders::kGeometry, shaders::kShapes,
22
7/14
✓ Branch 0 taken 17 times.
✓ Branch 1 taken 17 times.
✓ Branch 3 taken 17 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 17 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 17 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 17 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 17 times.
✗ Branch 16 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
34 shaders::kRayTracer};
23 34 return modules;
24 }
25
26 27 void RayTracer::AddBuild(graph::Graph& graph, const GeometryPool::Changes& changes,
27 const TransformGraph& transforms, const InstanceTable& instances) {
28 27 ERNIE_ZONE("Update the ray tracer");
29
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 const graph::Graph::ScopeGuard scope = graph.Scope("Ray tracer");
30
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 bottoms_.Apply(changes);
31
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 bottoms_.AddBuilds(graph);
32
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 const graph::Acceleration top = tops_.AddBuild(graph, transforms, instances, bottoms_);
33
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 const DeviceColumn& records = geometry_.Records();
34
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 const DeviceColumn& colours = instances.Colours();
35
2/4
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 27 times.
✗ Branch 5 not taken.
27 graph.Board().Put(
36
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 TraceScene{.parameters = {.scene = tops_.Structure()->Address(),
37
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .records = ToBufferRef<shaders::GeometryRecord>(records)},
38 .top = top,
39
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .records = graph.Import(records),
40
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .instances = instances.Count(),
41
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .colours = graph.Import(colours),
42
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .colourBuffer = ToBufferRef<float>(colours),
43
1/2
✓ Branch 1 taken 27 times.
✗ Branch 2 not taken.
27 .origin = transforms.Origin()});
44 27 }
45
46 } // namespace ernie
47