Loading...
Searching...
No Matches
ExtractSceneBuffer.hpp
1#pragma once
2#include <halp/buffer.hpp>
3#include <halp/controls.hpp>
4#include <halp/meta.hpp>
5
6#include <ossia/dataflow/geometry_port.hpp>
7
8#include <Gfx/Graph/GpuResourceRegistry.hpp>
9
10#include <cstdint>
11
12class QRhiResourceUpdateBatch;
13
14namespace score::gfx
15{
16class RenderList;
17struct Edge;
18}
19
20namespace Threedim
21{
22
23// Scene-level buffer extractor: takes a scene_spec, picks one of the GPU arena
24// slots stamped on the scene's components, and republishes the backing
25// {QRhiBuffer*, byte_offset, byte_size} triple on a halp::gpu_buffer outlet.
26//
27// Unlike Threedim::ExtractBuffer2, which extracts from a flattened geometry's
28// aux list downstream of a ScenePreprocessor, this works directly on a raw
29// scene_spec -- for a compute shader that wants a producer's Raw arena slot
30// without a preprocessor flatten, or a pipeline that has no preprocessor at all.
31//
32// Source resolution uses each component's `raw_slot`:
33// Environment scene.state->environment.raw_slot
34// Camera(N) (*scene.state->cameras)[N]->raw_slot
35// Material(N) (*scene.state->materials)[N]->raw_slot
36//
37// The registry's isLive() check guards every read; a stale ref clears the outlet
38// rather than handing a dangling QRhiBuffer* downstream.
39//
40// Lights are not exposed because the light tree is not a flat scene_state.lights
41// vector -- lights live as scene_payload children. Extract them downstream of a
42// ScenePreprocessor with ExtractBuffer2("scene_lights").
44{
45public:
46 halp_meta(name, "Extract Scene Buffer")
47 halp_meta(category, "Visuals/3D/Scene")
48 halp_meta(c_name, "extract_scene_buffer")
49 halp_meta(authors, "ossia team")
50 halp_meta(
51 manual_url,
52 "https://ossia.io/score-docs/processes/extract-scene-buffer.html")
53 halp_meta(uuid, "5f2b8e1c-4a7d-4e9b-b0f1-3c6e8d2a5b74")
54
55 enum Kind
56 {
57 Environment,
58 Camera,
59 Material
60 };
61
62 struct ins
63 {
64 struct
65 {
66 halp_meta(name, "Scene In");
67 ossia::scene_spec scene;
68 uint8_t dirty{0};
69 } scene_in;
70
71 struct : halp::combobox_t<"Kind", Kind>
72 {
73 struct range
74 {
75 std::string_view values[3]{"Environment", "Camera", "Material"};
76 int init{0};
77 };
78 } kind;
79
80 // Index inside scene.state->cameras / ->materials. Ignored when
81 // Kind == Environment (the environment is a singleton on scene_state).
82 halp::spinbox_i32<"Index", halp::irange{0, 1024, 0}> index;
83 } inputs;
84
85 struct outs
86 {
87 halp::gpu_buffer_output<"Buffer"> buffer;
88 } outputs;
89
90 // Execution-thread tick. No heavy work here — just snapshot the
91 // current scene ref + control values. Slot resolution needs the
92 // registry (render thread) so it happens in update().
93 void operator()();
94
95 // Render-thread hooks. update() resolves the slot ref against the
96 // renderer's GpuResourceRegistry, validates via isLive(), and
97 // publishes the buffer handle + offset + size on the outlet. init()
98 // and release() are no-ops for now — the node owns no GPU state.
99 void init(score::gfx::RenderList& r, QRhiResourceUpdateBatch& res);
100 void update(
101 score::gfx::RenderList& r, QRhiResourceUpdateBatch& res,
103 void release(score::gfx::RenderList& r);
104};
105
106}
Definition Camera.hpp:40
Definition ExtractSceneBuffer.hpp:44
List of nodes to be rendered to an output.
Definition RenderList.hpp:30
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition ExtractSceneBuffer.hpp:63
Definition ExtractSceneBuffer.hpp:86
Definition MIDISync.hpp:126
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:103