Add multi-monitor support via packed atlas frames
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 27s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 28s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 28s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 20s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / module (push) Failing after 16s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 19s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 20s
build / host-linux (push) Failing after 19s
build / host-windows-cross (push) Failing after 17s
build / obs (clang) (push) Failing after 18s
build / docs (push) Failing after 7s
build / obs (gcc) (push) Failing after 20s
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Failing after 27s
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Failing after 28s
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 28s
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 21s
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Failing after 20s
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Failing after 21s
build / module (push) Failing after 16s
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Failing after 19s
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Failing after 20s
build / host-linux (push) Failing after 19s
build / host-windows-cross (push) Failing after 17s
build / obs (clang) (push) Failing after 18s
build / docs (push) Failing after 7s
build / obs (gcc) (push) Failing after 20s
build / host-windows-native (push) Canceled after 0s
build / idd (push) Canceled after 0s
Capture every guest display into a single frame and compose it back into the guest's desktop on the client, so one Looking Glass session can carry a multi-monitor guest instead of one instance per display. KVMFR gains a per-frame display layout (version 24). A frame with displayCount == 0 is a conventional single-display frame and behaves exactly as before, so existing capture backends are unaffected. - common: shared display layout and a shelf packer that minimises atlas area, plus atlas/desktop coordinate mapping helpers and unit tests - host: capture interface and host app carry the layout; a layout change invalidates the format so clients re-read it - host/XCB: enumerate RandR monitors and repack the root window into the atlas directly in shared memory - client/EGL: compose the atlas into the presented view as its own pass, leaving post processing, HDR, cursor and damage handling unchanged Also fixes the XCB backend writing a single row per frame instead of the whole image.
This commit is contained in:
1 parent
4ef6672e64
commit
dfe8edfbc2
18 files changed
+1363
-5
No files matched your search
@@ -28,7 +28,7 @@
|
||||
#include "types.h"
|
||||
|
||||
#define KVMFR_MAGIC "KVMFR---"
|
||||
#define KVMFR_VERSION 23
|
||||
#define KVMFR_VERSION 24
|
||||
|
||||
// Fallback used by producers that cannot report the source display's SDR
|
||||
// white level. IDD frames override this with IDDCX_METADATA2::SdrWhiteLevel.
|
||||
@@ -36,6 +36,9 @@
|
||||
|
||||
#define KVMFR_MAX_DAMAGE_RECTS 64
|
||||
|
||||
// The maximum number of guest displays that may be packed into a single frame.
|
||||
#define KVMFR_MAX_DISPLAYS 8
|
||||
|
||||
#define LGMP_Q_POINTER 1
|
||||
#define LGMP_Q_FRAME 2
|
||||
|
||||
@@ -176,6 +179,48 @@ enum
|
||||
|
||||
typedef uint32_t KVMFRFrameFlags;
|
||||
|
||||
enum
|
||||
{
|
||||
KVMFR_DISPLAY_FLAG_PRIMARY = 0x1 // the guest's primary display
|
||||
};
|
||||
|
||||
typedef uint32_t KVMFRDisplayFlags;
|
||||
|
||||
/* Describes one guest display packed into a multi-display (atlas) frame.
|
||||
*
|
||||
* A display occupies the axis-aligned rectangle (atlasX, atlasY, atlasWidth,
|
||||
* atlasHeight) inside the frame data, and belongs at (desktopX, desktopY) on
|
||||
* the guest's virtual desktop. The two rectangles always have the same size:
|
||||
* packing relocates a display but never scales it.
|
||||
*
|
||||
* The producer normalises the virtual desktop so that the top-left of the
|
||||
* bounding box of all displays is (0, 0), making desktopX/desktopY
|
||||
* non-negative. They remain signed so a consumer can safely offset them.
|
||||
*
|
||||
* `rotation` is the orientation the guest has applied to this display. The
|
||||
* packed pixels are already in their final, rotated orientation, so it is
|
||||
* informational only; consumers do not need to rotate to compose the desktop.
|
||||
*/
|
||||
typedef struct KVMFRDisplay
|
||||
{
|
||||
uint32_t id; // producer-assigned stable identifier
|
||||
KVMFRDisplayFlags flags; // bit field combination of KVMFR_DISPLAY_FLAG_*
|
||||
|
||||
uint32_t atlasX; // x offset of this display within the frame
|
||||
uint32_t atlasY; // y offset of this display within the frame
|
||||
uint32_t atlasWidth; // width of this display within the frame
|
||||
uint32_t atlasHeight; // height of this display within the frame
|
||||
|
||||
int32_t desktopX; // x position on the guest's virtual desktop
|
||||
int32_t desktopY; // y position on the guest's virtual desktop
|
||||
uint32_t desktopWidth; // width on the guest's virtual desktop
|
||||
uint32_t desktopHeight; // height on the guest's virtual desktop
|
||||
|
||||
FrameRotation rotation; // the guest's rotation for this display
|
||||
char name[32]; // friendly output name, NUL terminated
|
||||
}
|
||||
KVMFRDisplay;
|
||||
|
||||
typedef struct KVMFRFrame
|
||||
{
|
||||
uint32_t formatVer; // the frame format version number
|
||||
@@ -211,6 +256,22 @@ typedef struct KVMFRFrame
|
||||
// White level in nits for SDR content composited into an HDR frame, such as
|
||||
// the hardware cursor. Valid for all frames; SDR modes normally report 80.
|
||||
uint32_t sdrWhiteLevel;
|
||||
|
||||
/* Multi-display layout.
|
||||
*
|
||||
* A displayCount of zero means this is a conventional single-display frame
|
||||
* and `displays` carries no meaning: the frame is the whole guest screen,
|
||||
* exactly as in KVMFR versions before 24.
|
||||
*
|
||||
* Otherwise the frame is an atlas holding `displayCount` displays, and
|
||||
* screenWidth/screenHeight describe the guest's virtual desktop rather than
|
||||
* the packed frame. frameWidth/frameHeight remain the dimensions of the
|
||||
* packed frame itself, so a consumer with no multi-display support still
|
||||
* renders something coherent (the raw atlas) rather than reading out of
|
||||
* bounds. Damage rectangles are always expressed in packed frame space.
|
||||
*/
|
||||
uint32_t displayCount;
|
||||
KVMFRDisplay displays[KVMFR_MAX_DISPLAYS];
|
||||
}
|
||||
KVMFRFrame;
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_COMMON_DISPLAYS_
|
||||
#define _H_LG_COMMON_DISPLAYS_
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "KVMFR.h"
|
||||
#include "types.h"
|
||||
|
||||
/* The largest atlas edge the packer will produce. Chosen to stay within the
|
||||
* GL_MAX_TEXTURE_SIZE of every GPU the client supports; 16384 is the common
|
||||
* limit on current hardware and 8192 on older parts, so we stay at 16384 and
|
||||
* let the client reject anything its driver cannot honour. */
|
||||
#define LG_DISPLAY_MAX_ATLAS_EDGE 16384
|
||||
|
||||
/* One guest display as reported by a capture backend, before packing. */
|
||||
typedef struct LGDisplayInfo
|
||||
{
|
||||
uint32_t id; // backend-assigned stable identifier
|
||||
bool primary; // true if this is the guest's primary display
|
||||
int32_t x, y; // position on the guest virtual desktop
|
||||
uint32_t width, height; // size on the guest virtual desktop
|
||||
FrameRotation rotation; // the guest's rotation for this display
|
||||
char name[32]; // friendly output name
|
||||
}
|
||||
LGDisplayInfo;
|
||||
|
||||
/**
|
||||
* Pack a set of guest displays into a single atlas frame.
|
||||
*
|
||||
* Displays are placed without scaling or rotation, so each keeps its exact
|
||||
* pixel dimensions. The packer chooses a layout that minimises the atlas area
|
||||
* (and therefore the shared memory and copy cost per frame), falling back to a
|
||||
* simple vertical stack if no better arrangement fits.
|
||||
*
|
||||
* Virtual desktop coordinates are normalised so the bounding box of all
|
||||
* displays starts at (0, 0), and returned via desktopWidth/desktopHeight.
|
||||
*
|
||||
* `out` must have room for `count` entries and `count` must not exceed
|
||||
* KVMFR_MAX_DISPLAYS. Entries in `out` are written in the same order as `in`,
|
||||
* so a backend can keep its own indexing.
|
||||
*
|
||||
* `alignment` rounds the atlas width up to a multiple of that many pixels, so
|
||||
* a backend can satisfy a row-pitch requirement. Pass 1 for no alignment.
|
||||
*
|
||||
* Returns false if the inputs are invalid or no layout fits within
|
||||
* LG_DISPLAY_MAX_ATLAS_EDGE.
|
||||
*/
|
||||
bool lgDisplaysPack(
|
||||
const LGDisplayInfo * in,
|
||||
unsigned count,
|
||||
unsigned alignment,
|
||||
KVMFRDisplay * out,
|
||||
unsigned * atlasWidth,
|
||||
unsigned * atlasHeight,
|
||||
unsigned * desktopWidth,
|
||||
unsigned * desktopHeight);
|
||||
|
||||
/**
|
||||
* Returns the index of the display in `displays` containing the virtual
|
||||
* desktop point (x, y), or -1 if the point falls in a gap between displays.
|
||||
*/
|
||||
int lgDisplaysFindAtPoint(const KVMFRDisplay * displays, unsigned count,
|
||||
int32_t x, int32_t y);
|
||||
|
||||
/**
|
||||
* Translate a point from guest virtual desktop space into packed atlas space.
|
||||
* Returns false if the point does not fall inside any display.
|
||||
*/
|
||||
bool lgDisplaysDesktopToAtlas(const KVMFRDisplay * displays, unsigned count,
|
||||
int32_t dx, int32_t dy, int32_t * ax, int32_t * ay);
|
||||
|
||||
/**
|
||||
* Translate a point from packed atlas space into guest virtual desktop space.
|
||||
* Returns false if the point falls in atlas padding owned by no display.
|
||||
*/
|
||||
bool lgDisplaysAtlasToDesktop(const KVMFRDisplay * displays, unsigned count,
|
||||
int32_t ax, int32_t ay, int32_t * dx, int32_t * dy);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user