perf(vkbridge): async requests with ordering, batched descriptor sets, buffered server reads

- Ordered async protocol: vkb_msg_hdr seq/barrier, per-process ordering gate on
  the server; void commands and VkResult commands without outputs (submits,
  resets, binds, vkEndCommandBuffer replay) no longer wait for a reply.
  VKBRIDGE_SYNC=1 restores synchronous calls for debugging.
- Client async queue batched across threads with a ~100us background flusher.
- Descriptor sets allocated in batches per (pool, layout); the client keeps the
  pool's books (layout descriptor counts vs pool sizes) so batches ask only for
  what fits and a full pool answers OUT_OF_POOL_MEMORY without a round trip.
  Caches for a destroyed layout are dropped (its handle may be reused).
- Server parses requests out of one receive buffer (descriptor FIFO for
  SCM_RIGHTS) instead of two reads per message.
- Server logs async VkResult failures (generated vkb_cmd_result table) and
  per-command timing with VKBRIDGE_STATS=<s>.
- tests/d3d11_bench.c: game-like D3D11 frame (1000 draws, Map DISCARD, rebinds).

d3d11_bench 1000 draws on RADV: native 0.30 ms/frame; bridge 26.3 ms (sync)
-> 1.43 ms. Host suite 14/14 in plain and Mali-imitation modes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ahmad Sayed Alsayed EbrahimandClaude Opus 5.5 committed 2026-10-10 14:28:13 +03:00
1 parent 308b200350
commit a4bd2eb271
14 files changed
+1247 -314

No files matched your search

+13 -2
View File
@@ -20,18 +20,29 @@
#define VKB_MAX_PDS 16
/* A client process (all connections that said hello with the same token). */
#define VKB_SEQ_RING 65536
typedef struct vkb_srv_proc {
uint64_t token;
int pid;
int conns;
struct vkb_srv_proc *next;
/* Ordering of the process's asynchronous requests (vkb_msg_hdr.seq/barrier). */
pthread_mutex_t olock;
pthread_cond_t ocond;
uint64_t watermark; /* every async seq <= this has run */
uint8_t done[VKB_SEQ_RING]; /* seqs above the watermark that have run */
int conn_closed; /* a connection ended (a seq may never arrive) */
} vkb_srv_proc;
typedef struct vkb_srv_conn {
int sock;
vkb_srv_proc *proc;
uint8_t *inbuf;
size_t incap;
/* Receive buffer: messages are parsed out of it in place (srv_recv). */
uint8_t *rb;
size_t rcap, rpos, rlen;
int fdq[2 * VKB_MAX_FDS]; /* descriptors received ahead of their message's turn */
int fdn;
vkb_arena arena;
pthread_t thread;
} vkb_srv_conn;