Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PointerShaderUniforms.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
7
8#include <cstddef>
9
10namespace PhosphorPointerShaders {
11
14constexpr size_t kPointerTailOffset = 672;
15
17 "BaseUniforms must remain 672 bytes: the pointer tail is pinned at UBO offset 672");
18
30struct alignas(16) PointerUniformsTail
31{
33 float uPointerVelocity[4]; // vec4: 16 bytes at tail offset 0, UBO offset 672
34
37 float uPointerPress[4]; // vec4: 16 bytes at tail offset 16, UBO offset 688
38
40 float uPointerRelease[4]; // vec4: 16 bytes at tail offset 32, UBO offset 704
41
44 float uPointerState[4]; // vec4: 16 bytes at tail offset 48, UBO offset 720
45
47 float uCursorRect[4]; // vec4: 16 bytes at tail offset 64, UBO offset 736
48
50 float uPointerFlags[4]; // vec4: 16 bytes at tail offset 80, UBO offset 752
51
53 float uPointerTrail[32][4]; // vec4[32]: 512 bytes at tail offset 96, UBO offset 768
54}; // total 608 bytes, UBO total 1280 bytes
55
56static_assert(sizeof(PointerUniformsTail) == 608, "PointerUniformsTail must be exactly 608 bytes (pointer UBO tail)");
57static_assert(sizeof(PhosphorShaders::BaseUniforms) + sizeof(PointerUniformsTail) == 1280,
58 "BaseUniforms + PointerUniformsTail must total 1280 bytes (pointer UBO contract)");
59
60static_assert(offsetof(PointerUniformsTail, uPointerVelocity) == 0,
61 "PointerUniformsTail::uPointerVelocity must remain at tail offset 0 (UBO 672)");
62static_assert(offsetof(PointerUniformsTail, uPointerPress) == 16,
63 "PointerUniformsTail::uPointerPress must remain at tail offset 16 (UBO 688)");
64static_assert(offsetof(PointerUniformsTail, uPointerRelease) == 32,
65 "PointerUniformsTail::uPointerRelease must remain at tail offset 32 (UBO 704)");
66static_assert(offsetof(PointerUniformsTail, uPointerState) == 48,
67 "PointerUniformsTail::uPointerState must remain at tail offset 48 (UBO 720)");
68static_assert(offsetof(PointerUniformsTail, uCursorRect) == 64,
69 "PointerUniformsTail::uCursorRect must remain at tail offset 64 (UBO 736)");
70static_assert(offsetof(PointerUniformsTail, uPointerFlags) == 80,
71 "PointerUniformsTail::uPointerFlags must remain at tail offset 80 (UBO 752)");
72static_assert(offsetof(PointerUniformsTail, uPointerTrail) == 96,
73 "PointerUniformsTail::uPointerTrail must remain at tail offset 96 (UBO 768)");
74
75} // namespace PhosphorPointerShaders
Definition PointerFrameState.h:16
constexpr size_t kPointerTailOffset
Byte offset of the pointer tail inside the UBO: it is appended directly after PhosphorShaders::BaseUn...
Definition PointerShaderUniforms.h:14
C++ mirror of the POINTER contract's UBO tail.
Definition PointerShaderUniforms.h:31
float uPointerFlags[4]
.x = 1 when uCursorSprite is bound, .yzw reserved 0.
Definition PointerShaderUniforms.h:50
float uCursorRect[4]
Cursor sprite rect in canvas px (x, y, w, h), hotspot applied.
Definition PointerShaderUniforms.h:47
float uPointerState[4]
.x pressed-button bitmask (1 left, 2 right, 4 middle), .y seconds since the last motion,...
Definition PointerShaderUniforms.h:44
float uPointerPress[4]
.xy canvas px of the last press, .z seconds since (1e6 when none), .w button (1 left,...
Definition PointerShaderUniforms.h:37
float uPointerRelease[4]
Same shape for the last release.
Definition PointerShaderUniforms.h:40
float uPointerVelocity[4]
.xy device px/s, .z speed (length), .w unused.
Definition PointerShaderUniforms.h:33
float uPointerTrail[32][4]
Newest first: .xy canvas px, .z age seconds, .w speed at the sample.
Definition PointerShaderUniforms.h:53
GPU uniform buffer layout following std140 rules (base region).
Definition BaseUniforms.h:37