GCC Code Coverage Report


ernie/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
1 / 1
100.0%
Branches:
-
-%
Functions:
-
-%

render/renderer.h
Line Branch Exec Source
1 // SPDX-License-Identifier: BSD-3-Clause
2 /// @file renderer.h
3 /// @brief Rendering a scene's render settings to an image in one call.
4 ///
5 /// Renderer renderer;
6 /// Tensor image = renderer.Render(scene); // height x width x 4 bytes of LdrColor
7 #pragma once
8
9 #include "ernie/export.h"
10 #include "ernie/scene/scene.h"
11 #include "ernie/util/tensor.h"
12
13 #include <memory>
14 #include <string>
15
16 namespace ernie {
17
18 class DeviceContext;
19
20 3 struct RendererOptions {
21 /// The device: its UUID in hex, or part of its name; empty for the best scoring one.
22 std::string device;
23 /// The Khronos validation layer with synchronization validation, when installed.
24 bool validation = false;
25 };
26
27 /// @brief A device and what it keeps of the scene it last rendered, so rendering the same scene
28 /// again costs only what changed in it.
29 class ERNIE_API Renderer {
30 public:
31 /// @throws std::runtime_error without a device that can ray trace.
32 explicit Renderer(const RendererOptions& options = {});
33 ~Renderer();
34 Renderer(const Renderer&) = delete;
35 Renderer& operator=(const Renderer&) = delete;
36
37 /// @brief Renders the camera of the scene's first `RenderSettings` at its resolution, as
38 /// Minimal sees it: albedo lit from the eye.
39 /// @return LdrColor, height x width x 4 bytes (RGBA8, display encoded) on the host.
40 /// @throws std::invalid_argument when the scene has no render settings or they name no camera.
41 Tensor Render(const Scene& scene);
42
43 /// @return Its device, for Ernie's own tests and tools.
44 DeviceContext& Context();
45
46 private:
47 struct Device;
48 std::unique_ptr<Device> device_;
49 };
50
51 } // namespace ernie
52