#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 #define WIN32_LEAN_AND_MEAN #include #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 */