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(description, "Expose a scene environment, camera or material GPU buffer without flattening the scene.")
50 halp_meta(authors, "ossia team")
51 halp_meta(
52 manual_url,
53 "https://ossia.io/score-docs/processes/extract-scene-buffer.html")
54 halp_meta(uuid, "5f2b8e1c-4a7d-4e9b-b0f1-3c6e8d2a5b74")
55
56 enum Kind
57 {
58 Environment,
59 Camera,
60 Material
61 };
62
63 struct ins
64 {
65 struct
66 {
67 halp_meta(name, "Scene In");
68 ossia::scene_spec scene;
69 uint8_t dirty{0};
70 } scene_in;
71
72 struct : halp::combobox_t<"Kind", Kind>
73 {
74 struct range
75 {
76 std::string_view values[3]{"Environment", "Camera", "Material"};
77 int init{0};
78 };
79 } kind;
80
81 // Index inside scene.state->cameras / ->materials. Ignored when
82 // Kind == Environment (the environment is a singleton on scene_state).
83 halp::spinbox_i32<"Index", halp::irange{0, 1024, 0}> index;
84 } inputs;
85
86 struct outs
87 {
88 halp::gpu_buffer_output<"Buffer"> buffer;
89 } outputs;
90
91 // Execution-thread tick. No heavy work here — just snapshot the
92 // current scene ref + control values. Slot resolution needs the
93 // registry (render thread) so it happens in update().
94 void operator()();
95
96 // Render-thread hooks. update() resolves the slot ref against the
97 // renderer's GpuResourceRegistry, validates via isLive(), and
98 // publishes the buffer handle + offset + size on the outlet. init()
99 // and release() are no-ops for now — the node owns no GPU state.
100 void init(score::gfx::RenderList& r, QRhiResourceUpdateBatch& res);
101 void update(
102 score::gfx::RenderList& r, QRhiResourceUpdateBatch& res,
104 void release(score::gfx::RenderList& r);
105};
106
107}
Definition Camera.hpp:64
Definition ExtractSceneBuffer.hpp:44
List of nodes to be rendered to an output.
Definition RenderList.hpp:33
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
Definition ExtractSceneBuffer.hpp:64
Definition ExtractSceneBuffer.hpp:87
Definition MIDISync.hpp:128
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:236