[repos] lgprotocol: import shared protocol definitions
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled

Add LGProtocol as a pinned submodule and consume its KVMFR protocol
definitions throughout the client, host, IDD, OBS, and profiler.

Keep Looking Glass framebuffer helpers local while removing duplicated
protocol headers and migrating users to KVMFR-scoped types.
This commit is contained in:
Geoffrey McRae
2026-09-01 20:58:25 +10:00
parent 8e43d41873
commit 8fbe3e7454
94 changed files with 619 additions and 2062 deletions

View File

@@ -104,8 +104,8 @@ struct EGL_Cursor
_Atomic(float) mapHDRContentPeak;
bool colorTransformUpdate;
LGColorTransform pendingColorTransform;
LGColorTransform activeColorTransform;
KVMFRColorTransform pendingColorTransform;
KVMFRColorTransform activeColorTransform;
GLuint colorLUT;
struct CursorTex norm;
@@ -344,7 +344,7 @@ bool egl_cursorSetShape(EGL_Cursor * cursor, const LG_RendererCursor type,
}
void egl_cursorSetColorTransform(EGL_Cursor * cursor,
const LGColorTransform * transform)
const KVMFRColorTransform * transform)
{
LG_LOCK(cursor->lock);
cursor->pendingColorTransform = *transform;

View File

@@ -44,7 +44,7 @@ bool egl_cursorSetShape(
const uint8_t * data);
void egl_cursorSetColorTransform(EGL_Cursor * cursor,
const LGColorTransform * transform);
const KVMFRColorTransform * transform);
void egl_cursorSetSize(EGL_Cursor * cursor, const float x, const float y);

View File

@@ -29,7 +29,7 @@ struct DesktopDamage
{
LG_RendererFrameToken frameToken;
int count;
FrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
KVMFRFrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
};
typedef struct EGL_Damage EGL_Damage;

View File

@@ -380,9 +380,10 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
return true;
}
bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame,
bool egl_desktopUpdate(EGL_Desktop * desktop,
const KVMFRFrameBuffer * frame,
LG_RendererFrameToken frameToken, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{

View File

@@ -48,9 +48,9 @@ void egl_desktopSetNativeHDR(EGL_Desktop * desktop, bool nativeHDR,
void egl_desktopGetHDRMapping(EGL_Desktop * desktop, bool * enabled,
float * gain, float * contentPeak);
bool egl_desktopSetup (EGL_Desktop * desktop, const LG_RendererFormat format);
bool egl_desktopUpdate(EGL_Desktop * desktop, const FrameBuffer * frame,
bool egl_desktopUpdate(EGL_Desktop * desktop, const KVMFRFrameBuffer * frame,
LG_RendererFrameToken frameToken, int dmaFd,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle);
void egl_desktopRestart(EGL_Desktop * desktop);

View File

@@ -95,7 +95,8 @@ void egl_desktopRectsFree(EGL_DesktopRects ** rects_)
*rects_ = NULL;
}
inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect)
inline static void rectToVertices(GLfloat * vertex,
const KVMFRFrameDamageRect * rect)
{
vertex[0] = rect->x;
vertex[1] = rect->y;
@@ -108,7 +109,7 @@ inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect
}
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
const FrameDamageRect * data, int count, int width, int height)
const KVMFRFrameDamageRect * data, int count, int width, int height)
{
if (count == 0)
{
@@ -120,7 +121,7 @@ void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
GLfloat vertices[vertexCount];
if (count < 0)
{
FrameDamageRect full = {
KVMFRFrameDamageRect full = {
.x = 0, .y = 0, .width = width, .height = height,
};
rects->count = 1;
@@ -237,7 +238,8 @@ inline static void matrixMultiply(const double matrix[6], double * nx, double *
*ny = matrix[1] * x + matrix[3] * y + matrix[5];
}
struct Rect egl_desktopToScreen(const double matrix[6], const struct FrameDamageRect * rect)
struct Rect egl_desktopToScreen(const double matrix[6],
const struct KVMFRFrameDamageRect * rect)
{
double x1, y1, x2, y2;
matrixMultiply(matrix, &x1, &y1, rect->x, rect->y);
@@ -270,7 +272,8 @@ void egl_screenToDesktopMatrix(double matrix[6], int frameWidth, int frameHeight
matrix[5] = (inverted[1] * inverted[4] - inverted[0] * inverted[5]) / det;
}
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
bool egl_screenToDesktop(struct KVMFRFrameDamageRect * output,
const double matrix[6],
const struct Rect * rect, int width, int height)
{
double x1, y1, x2, y2;

View File

@@ -26,8 +26,8 @@
struct DamageRects
{
int count;
FrameDamageRect rects[];
int count;
KVMFRFrameDamageRect rects[];
};
typedef struct EGL_DesktopRects EGL_DesktopRects;
@@ -40,14 +40,16 @@ void egl_desktopRectsMatrix(float matrix[6], int width, int height, float transl
void egl_desktopToScreenMatrix(double matrix[6], int frameWidth, int frameHeight,
double translateX, double translateY, double scaleX, double scaleY, LG_RendererRotate rotate,
double windowWidth, double windowHeight);
struct Rect egl_desktopToScreen(const double matrix[6], const struct FrameDamageRect * rect);
struct Rect egl_desktopToScreen(const double matrix[6],
const struct KVMFRFrameDamageRect * rect);
void egl_screenToDesktopMatrix(double matrix[6], int frameWidth, int frameHeight,
double translateX, double translateY, double scaleX, double scaleY, LG_RendererRotate rotate,
double windowWidth, double windowHeight);
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
bool egl_screenToDesktop(struct KVMFRFrameDamageRect * output,
const double matrix[6],
const struct Rect * rect, int width, int height);
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
const FrameDamageRect * data, int count, int width, int height);
const KVMFRFrameDamageRect * data, int count, int width, int height);
void egl_desktopRectsRender(EGL_DesktopRects * rects);

View File

@@ -453,7 +453,7 @@ static void egl_addSwSurfaceDamage(
if (right <= x || bottom <= y)
return;
const FrameDamageRect rect = {
const KVMFRFrameDamageRect rect = {
.x = (uint32_t)x,
.y = (uint32_t)y,
.width = (uint32_t)(right - x),
@@ -697,7 +697,7 @@ static bool egl_onMouseShape(LG_Renderer * renderer, const LG_RendererCursor cur
}
static void egl_onMouseColorTransform(LG_Renderer * renderer,
const LGColorTransform * transform)
const KVMFRColorTransform * transform)
{
struct Inst * this = UPCAST(struct Inst, renderer);
egl_cursorSetColorTransform(this->cursor, transform);
@@ -832,8 +832,9 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
return egl_desktopSetup(this->desktop, format);
}
static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
int dmaFd, const FrameDamageRect * damageRects, int damageRectsCount,
static bool egl_onFrame(LG_Renderer * renderer,
const KVMFRFrameBuffer * frame, int dmaFd,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
LG_RendererFrameToken frameToken, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{
@@ -853,8 +854,9 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
const uint64_t elapsed = nanotime() - start;
/* Producer Copy already covers the interval before FrameBuffer::wp becomes
* ready. Exclude that overlapping wait from the client Import stage. */
/* Producer Copy already covers the interval before KVMFRFrameBuffer::wp
* becomes ready. Exclude that overlapping wait from the client Import
* stage. */
app_setFrameImportTiming(
elapsed > waitTimeNs ? elapsed - waitTimeNs : 0, waitTimeNs);
@@ -873,7 +875,7 @@ static bool egl_onFrame(LG_Renderer * renderer, const FrameBuffer * frame,
else
{
memcpy(damage->rects + damage->count, damageRects,
damageRectsCount * sizeof(FrameDamageRect));
damageRectsCount * sizeof(KVMFRFrameDamageRect));
damage->count += damageRectsCount;
}
damage->frameToken = frameToken;
@@ -1327,8 +1329,8 @@ inline static EGLint egl_bufferAge(struct Inst * this)
return result;
}
static FrameDamageRect egl_expandDesktopDamage(
const struct Inst * this, const FrameDamageRect * rect)
static KVMFRFrameDamageRect egl_expandDesktopDamage(
const struct Inst * this, const KVMFRFrameDamageRect * rect)
{
int width, height;
egl_getDesktopSize(this, &width, &height);
@@ -1342,7 +1344,7 @@ static FrameDamageRect egl_expandDesktopDamage(
const uint32_t bottom = (uint32_t)min((uint64_t)height,
(uint64_t)rect->y + rect->height + DESKTOP_DAMAGE_MARGIN);
return (FrameDamageRect) {
return (KVMFRFrameDamageRect) {
.x = x,
.y = y,
.width = right > x ? right - x : 0,
@@ -1381,10 +1383,10 @@ static int egl_mergeSurfaceDamage(struct Rect * damage, int count)
if (count <= 1)
return count;
FrameDamageRect rects[count];
KVMFRFrameDamageRect rects[count];
for (int i = 0; i < count; ++i)
{
rects[i] = (FrameDamageRect) {
rects[i] = (KVMFRFrameDamageRect) {
.x = damage[i].x,
.y = damage[i].y,
.width = damage[i].w,
@@ -1422,7 +1424,7 @@ static void egl_requeueDesktopDamage(
else
{
memcpy(pending->rects + pending->count, damage->rects,
damage->count * sizeof(FrameDamageRect));
damage->count * sizeof(KVMFRFrameDamageRect));
pending->count += damage->count;
}
@@ -1505,7 +1507,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
struct DamageRects * accumulated = (struct DamageRects *)alloca(
sizeof(struct DamageRects) +
MAX_ACCUMULATED_DAMAGE * sizeof(struct FrameDamageRect)
MAX_ACCUMULATED_DAMAGE * sizeof(struct KVMFRFrameDamageRect)
);
accumulated->count = 0;
@@ -1533,7 +1535,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
for (int j = 0; j < damage->count; ++j)
{
const FrameDamageRect rect =
const KVMFRFrameDamageRect rect =
egl_expandDesktopDamage(this, damage->rects + j);
if (rect.width && rect.height)
accumulated->rects[accumulated->count++] = rect;
@@ -1732,7 +1734,7 @@ static bool egl_render(LG_Renderer * renderer, LG_RendererRotate rotate,
for (int i = 0; i < desktopDamage->count; ++i)
{
const FrameDamageRect rect =
const KVMFRFrameDamageRect rect =
egl_expandDesktopDamage(this, desktopDamage->rects + i);
if (rect.width && rect.height)
damage[damageIdx++] = egl_desktopToScreen(matrix, &rect);

View File

@@ -140,7 +140,7 @@ void egl_hdrOverlaySetState(EGL_HDROverlay * this, bool active, bool pq,
}
static int convertDamage(EGL_HDROverlay * this, const struct Rect * damage,
int damageCount, FrameDamageRect * output)
int damageCount, KVMFRFrameDamageRect * output)
{
int count = 0;
for (int i = 0; i < damageCount; ++i)
@@ -152,7 +152,7 @@ static int convertDamage(EGL_HDROverlay * this, const struct Rect * damage,
if (x2 <= x1 || y2 <= y1)
continue;
output[count++] = (FrameDamageRect)
output[count++] = (KVMFRFrameDamageRect)
{
.x = x1,
.y = this->height - y2,
@@ -185,7 +185,7 @@ bool egl_hdrOverlayBegin(EGL_HDROverlay * this,
}
else
{
FrameDamageRect rects[damageCount];
KVMFRFrameDamageRect rects[damageCount];
const int count = convertDamage(this, damage, damageCount, rects);
egl_stateScissor(true);
@@ -227,7 +227,7 @@ void egl_hdrOverlayEnd(EGL_HDROverlay * this,
}
else
{
FrameDamageRect rects[damageCount];
KVMFRFrameDamageRect rects[damageCount];
const int count = convertDamage(this, damage, damageCount, rects);
egl_stateScissor(true);

View File

@@ -160,8 +160,8 @@ bool egl_textureUpdateRect(EGL_Texture * this,
}
bool egl_textureUpdateFromFrame(EGL_Texture * this,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs)
{
const struct EGL_TexUpdate update =
@@ -184,7 +184,7 @@ bool egl_textureUpdateFromFrame(EGL_Texture * this,
}
bool egl_textureUpdateFromDMA(EGL_Texture * this,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const int dmaFd, uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle)
{

View File

@@ -67,9 +67,9 @@ typedef struct EGL_TexUpdate
/* EGL_TEXTYPE_FRAMEBUFFER */
struct
{
const FrameBuffer * frame;
const FrameDamageRect * rects;
int rectCount;
const KVMFRFrameBuffer * frame;
const KVMFRFrameDamageRect * rects;
int rectCount;
};
/* EGL_TEXTYPE_DMABUF */
@@ -141,12 +141,12 @@ bool egl_textureUpdateRect(EGL_Texture * texture,
const uint8_t * buffer, bool topDown);
bool egl_textureUpdateFromFrame(EGL_Texture * texture,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const FrameDamageRect * damageRects, int damageRectsCount,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameDamageRect * damageRects, int damageRectsCount,
uint64_t * waitTimeNs);
bool egl_textureUpdateFromDMA(EGL_Texture * texture,
const FrameBuffer * frame, LG_RendererFrameToken frameToken,
const KVMFRFrameBuffer * frame, LG_RendererFrameToken frameToken,
const int dmaFd, uint64_t * waitTimeNs, LG_FrameReleaseFn releaseFn,
void * releaseOpaque, uint64_t releaseHandle);

View File

@@ -31,20 +31,20 @@ extern const EGL_TextureOps EGL_TextureBufferStream;
// internal functions
static uint64_t egl_texBufferDamageArea(const FrameDamageRect * rect)
static uint64_t egl_texBufferDamageArea(const KVMFRFrameDamageRect * rect)
{
return (uint64_t)rect->width * rect->height;
}
static FrameDamageRect egl_texBufferDamageUnion(
const FrameDamageRect * a, const FrameDamageRect * b)
static KVMFRFrameDamageRect egl_texBufferDamageUnion(
const KVMFRFrameDamageRect * a, const KVMFRFrameDamageRect * b)
{
const uint32_t left = min(a->x, b->x);
const uint32_t top = min(a->y, b->y);
const uint32_t right = max(a->x + a->width, b->x + b->width);
const uint32_t bottom = max(a->y + a->height, b->y + b->height);
return (FrameDamageRect)
return (KVMFRFrameDamageRect)
{
.x = left,
.y = top,
@@ -53,8 +53,8 @@ static FrameDamageRect egl_texBufferDamageUnion(
};
}
static bool egl_texBufferDamageTouches(const FrameDamageRect * a,
const FrameDamageRect * b)
static bool egl_texBufferDamageTouches(const KVMFRFrameDamageRect * a,
const KVMFRFrameDamageRect * b)
{
return a->x <= b->x + b->width && b->x <= a->x + a->width &&
a->y <= b->y + b->height && b->y <= a->y + a->height;
@@ -78,7 +78,7 @@ static void egl_texBufferDamageAdd(TextureBuffer * this, int index,
return;
}
FrameDamageRect rect =
KVMFRFrameDamageRect rect =
{
.x = update->x,
.y = update->y,
@@ -108,9 +108,9 @@ static void egl_texBufferDamageAdd(TextureBuffer * this, int index,
uint64_t bestCost = UINT64_MAX;
for (int i = 0; i < damage->count; ++i)
{
const FrameDamageRect merged =
const KVMFRFrameDamageRect merged =
egl_texBufferDamageUnion(&rect, &damage->rects[i]);
const uint64_t cost = egl_texBufferDamageArea(&merged) -
const uint64_t cost = egl_texBufferDamageArea(&merged) -
egl_texBufferDamageArea(&damage->rects[i]);
if (cost < bestCost)
{
@@ -479,8 +479,8 @@ EGL_TexStatus egl_texBufferStreamProcess(EGL_Texture * texture,
else
for (int i = 0; i < damage->count; ++i)
{
const FrameDamageRect * rect = &damage->rects[i];
const uintptr_t offset =
const KVMFRFrameDamageRect * rect = &damage->rects[i];
const uintptr_t offset =
(uintptr_t)rect->y * texture->format.pitch +
(uintptr_t)rect->x * texture->format.bpp;
glTexSubImage2D(GL_TEXTURE_2D,

View File

@@ -22,7 +22,7 @@
#include "texture.h"
#include "texture_util.h"
#include "common/LGMPConfig.h"
#include <LGProtocol/LGMPConfig.h>
#include "common/locking.h"
#define EGL_TEX_BUFFER_MAX LGMP_Q_FRAME_BUFFER_LEN
@@ -30,9 +30,9 @@
typedef struct EGL_TexBufferDamage
{
bool full;
int count;
FrameDamageRect rects[EGL_TEX_BUFFER_DAMAGE_MAX];
bool full;
int count;
KVMFRFrameDamageRect rects[EGL_TEX_BUFFER_DAMAGE_MAX];
}
EGL_TexBufferDamage;

View File

@@ -26,8 +26,8 @@
struct TexDamage
{
int count;
FrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
int count;
KVMFRFrameDamageRect rects[LG_MAX_FRAME_DAMAGE_RECTS];
};
typedef struct TexFB
@@ -108,17 +108,17 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
else
{
memcpy(damage->rects + damage->count, update->rects,
update->rectCount * sizeof(FrameDamageRect));
update->rectCount * sizeof(KVMFRFrameDamageRect));
damage->count += update->rectCount;
if (texture->format.pixFmt == EGL_PF_BGR_32)
{
FrameDamageRect scaledDamageRects[damage->count];
KVMFRFrameDamageRect scaledDamageRects[damage->count];
for (int i = 0; i < damage->count; i++)
{
FrameDamageRect rect = damage->rects[i];
int originalX = rect.x;
int scaledX = originalX * 3 / 4;
KVMFRFrameDamageRect rect = damage->rects[i];
int originalX = rect.x;
int scaledX = originalX * 3 / 4;
rect.x = scaledX;
rect.width = (((originalX + rect.width) * 3 + 3) / 4) - scaledX;
scaledDamageRects[i] = rect;
@@ -175,7 +175,7 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
damage->count + update->rectCount <= LG_MAX_FRAME_DAMAGE_RECTS)
{
memcpy(damage->rects + damage->count, update->rects,
update->rectCount * sizeof(FrameDamageRect));
update->rectCount * sizeof(KVMFRFrameDamageRect));
damage->count += update->rectCount;
}
else