Loading...
Searching...
No Matches
CommonUBOs.hpp
1#pragma once
2
3#include <cstdint>
4
5namespace score::gfx
6{
7#pragma pack(push, 1)
21struct alignas(4) ProcessUBO
22{
23 float time{};
24 float timeDelta{};
25 float progress{};
26 float sampleRate{};
27
28 int32_t passIndex{};
29 int32_t frameIndex{};
30
31 float renderSize[2]{2048, 2048};
32 float date[4]{0.f, 0.f, 0.f, 0.f};
33
34 // Mirrors gl_NumWorkGroups for CSF compute shaders. Populated by
35 // RenderedCSFNode just before dispatch so the libisf-injected
36 // `#define gl_NumWorkGroups isf_process_uniforms.NUMWORKGROUPS_`
37 // resolves to real dispatch counts on every backend (especially D3D
38 // where SPIRV-Cross refuses to emit the built-in directly).
39 // std140 packs uvec3 into a vec4 slot — the trailing word is padding.
40 uint32_t numWorkgroups[3]{};
41 uint32_t _numWorkgroups_pad{};
42};
43
48{
49 // clang-format off
50 float mvp[16]{};
51 float mv[16]{};
52 float model[16]{
53 1., 0., 0., 0.,
54 0., 1., 0., 0.,
55 0., 0., 1., 0.,
56 0., 0., 0., 1.,
57 };
58 float view[16]{};
59 float projection[16]{};
60 // std140 mat3: three column vectors, each padded to vec4 alignment.
61 // Column c lives at modelNormal[c * 4 + row]; the 4th float of each
62 // column is padding. Writing 9 contiguous floats here garbles columns
63 // 1 and 2 as read by the shader.
64 float modelNormal[12]{};
65 float fov = 90.f;
66 // NB: must NOT be named `near`/`far` — those are legacy macros defined by
67 // <windows.h>; naming members after them forces an #undef that then breaks
68 // any Windows system header (mmeapi.h, combaseapi.h) included afterwards.
69 float znear = 0.001f;
70 float zfar = 10000.f;
71 // clang-format on
72};
73
74static_assert(
75 sizeof(ModelCameraUBO)
76 == sizeof(float) * (16 + 16 + 16 + 16 + 16 + 12 + 1 + 1 + 1));
77
82{
83 float clipSpaceCorrMatrix[16]{};
84
85 float renderSize[2]{};
86
87 // MSAA sample count of the bound output target. Mirrors
88 // RenderList::samples(); shaders need it because gl_NumSamples is
89 // stripped by glslang under SPIR-V. The trailing pad keeps the UBO
90 // aligned to a vec4 boundary (std140-friendly).
91 int32_t sampleCount{1};
92 int32_t _pad0{0};
93};
94
99{
100 float scale[2]{1.f, 1.f};
101 float textureSize[2]{1.f, 1.f};
102};
103
104#pragma pack(pop)
105}
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
UBO shared across all entities shown with the same camera.
Definition CommonUBOs.hpp:48
float zfar
idem.
Definition CommonUBOs.hpp:70
float znear
Used by non-matrix projections (fulldome, …) for reverse-Z depth.
Definition CommonUBOs.hpp:69
UBO shared across all entities shown on the same output.
Definition CommonUBOs.hpp:82
UBO specific to individual processes / nodes.
Definition CommonUBOs.hpp:22
UBO shared across all video objects.
Definition CommonUBOs.hpp:99