feat: accept sRGB compositor frames

This commit is contained in:
XxJSONDeruloxX committed 2026-10-15 16:55:42 -04:00
1 parent 0a6e08d923
commit 828374f236
3 files changed
+11 -5

No files matched your search

+3 -1
View File
@@ -7,6 +7,7 @@
#define DROIDDECK_XR_FRAME_SOCKET "droiddeck-xr-frames"
#define DROIDDECK_XR_FRAME_MAX_BYTES (64u * 1024u * 1024u)
#define DROIDDECK_XR_COLOR_LINEAR_RGBA8 1u
#define DROIDDECK_XR_COLOR_SRGB_RGBA8 2u
struct DroidDeckXrFrameHeader {
uint32_t magic, version, width, height;
@@ -24,7 +25,8 @@ inline bool xr_frame_valid(const DroidDeckXrFrameHeader &header) {
if (header.magic != DROIDDECK_XR_FRAME_MAGIC || header.version != DROIDDECK_XR_FRAME_VERSION
|| !header.frame_id || header.width < 2 || (header.width & 1u) || !header.height
|| header.width > 8192 || header.height > 4096 || bytes > DROIDDECK_XR_FRAME_MAX_BYTES
|| header.bytes != bytes || header.color_space != DROIDDECK_XR_COLOR_LINEAR_RGBA8 || header.captured_ns <= 0) return false;
|| header.bytes != bytes || (header.color_space != DROIDDECK_XR_COLOR_LINEAR_RGBA8
&& header.color_space != DROIDDECK_XR_COLOR_SRGB_RGBA8) || header.captured_ns <= 0) return false;
for (int eye = 0; eye < 2; eye++) {
for (const auto &row : header.eye_pose[eye]) for (float value : row) if (!std::isfinite(value)) return false;
for (const auto &row : header.projection[eye]) for (float value : row) if (!std::isfinite(value)) return false;
+3
View File
@@ -41,6 +41,8 @@ int main(int argc, char **argv) {
assert(mkdtemp(directory));
std::string socketPath = std::string(directory) + "/frames";
auto valid = Header(); assert(xr_frame_valid(valid));
valid.color_space = DROIDDECK_XR_COLOR_SRGB_RGBA8; assert(xr_frame_valid(valid));
auto unknownColor = valid; unknownColor.color_space = 3; assert(!xr_frame_valid(unknownColor));
auto invalid = valid; invalid.version++; assert(!xr_frame_valid(invalid));
invalid = valid; invalid.width = 3; assert(!xr_frame_valid(invalid));
invalid = valid; invalid.bytes--; assert(!xr_frame_valid(invalid));
@@ -82,6 +84,7 @@ int main(int argc, char **argv) {
pixels.assign(valid.bytes, 99);
DroidDeckXrPixels taken; assert(receiver.Take(&taken));
assert(taken.header.frame_id == 1 && taken.pixels[0] == 17 && taken.header.eye_pose[0][0][3] == -0.032f);
assert(taken.header.color_space == DROIDDECK_XR_COLOR_SRGB_RGBA8);
assert(!receiver.Take(&taken));
for (uint64_t id = 2; id <= 100; id++) {
auto header = Header(id); header.eye_pose[0][0][3] = static_cast<float>(id);