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