Files
vatrog-vm-signaling/src/si/vgpu-stream/win32/ctx.h
T
lirent bd8b966017 vgpu in-guest producer in-tree, release CI, flexible vmie discovery
- src/si/vgpu-stream: in-guest vgpu producer built as a Windows cross-compiled target (if(WIN32))
- .gitea: release workflow — cross-build the agent and build/publish the deb against system vmie
- cmake/makefile: resolve vmie from a source tree (LIBVMIE_PATH) or installed libvmie-dev
2026-06-22 18:35:12 +03:00

67 lines
2.6 KiB
C

#ifndef VGPU_CTX_H
#define VGPU_CTX_H
/* ctx.h — win32 runtime context. Embeds the neutral region-view (the engine's
* borrowed handle onto the contract) alongside win32-owned staging/cursor/sync
* state. Object = memory: ctx owns the staging arena and cursor state. */
#include <stdint.h>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include "stream.h" /* vgpu_region_view (neutral contract handle) */
#include "region.h" /* vgpu_region_t (win32 pinned region) */
/*
* vgpu_ctx — the explicitly-passed context. Replaces all former g_* shared
* state. Object = memory: ctx owns the producer staging arena and cursor
* state; capture threads receive a vgpu_ctx* via their LPVOID thread param.
*
* Staging is a fixed arena sized for the max mode (no STL, no per-frame
* malloc). content_buf holds the latest submitted desktop; frame_buf is the
* composed (cursor-drawn) frame the publisher copies into a ring slot.
*/
#define VGPU_STAGING_BYTES ((size_t)VGPU_MAX_WIDTH * VGPU_MAX_HEIGHT * 4u)
/* Cursor sample/compose state (GDI). Fixed buffers, no heap. */
typedef struct {
HCURSOR handle;
int visible;
int x, y;
int hot_x, hot_y;
int gw, gh; /* glyph dims */
int cursor_id; /* VGPU_CURSOR_ID_* resolved on shape change */
int mono; /* 1 = AND/XOR monochrome cursor */
uint8_t* bgra; /* color cursor BGRA (arena) */
uint8_t* and_mask; /* mono AND (arena) */
uint8_t* xor_mask; /* mono XOR (arena) */
} vgpu_cursor_t;
typedef struct vgpu_ctx {
/* neutral contract handle (borrowed from region) — engine publishes through
* this; win32 code reads region blocks via view.producer / view.control */
vgpu_region_view view;
/* producer staging arena (owned) */
uint8_t* arena; /* one VirtualAlloc block for all buffers */
size_t arena_bytes;
uint8_t* content_buf; /* latest submitted desktop, tight BGRA */
uint8_t* frame_buf; /* composed frame to publish, tight BGRA */
/* submit handoff (capture thread -> publish pump) */
CRITICAL_SECTION lock;
HANDLE submit_event;
int64_t content_seq; /* bumped on every submit */
uint32_t content_w, content_h;
/* cursor */
vgpu_cursor_t cursor;
/* runtime config (resolved from control) */
uint32_t default_fps; /* fps from CLI; used when target_fps==0 */
uint32_t backend; /* VGPU_BK_* chosen */
int draw_cursor_cap; /* backend capability: does it need SW cursor */
} vgpu_ctx;
#endif /* VGPU_CTX_H */