mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
feat(vkbridge): self-checking smoke test, frame dump, WSI extensions and crash log on the server
Smoke test passes 9/9 through the bridge on RADV (dmabuf) and lavapipe (hostptr, UMA model); vkcube renders correctly over Wayland dma-buf, wl_shm and X11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KZqR8XUE8czvGzEpgSCVQR
This commit is contained in:
1 parent
a8fd343fc1
commit
d82c42d818
11 files changed
+741
-1
No files matched your search
@@ -21,6 +21,7 @@ static pthread_mutex_t procs_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static vkb_srv_proc *procs;
|
||||
|
||||
static __thread vkb_srv_table *tls_table;
|
||||
__thread const char *vkb_srv_current_cmd;
|
||||
|
||||
vkb_srv_table *vkb_srv_current_table(void) { return tls_table; }
|
||||
void vkb_srv_set_current_table(vkb_srv_table *t) { tls_table = t; }
|
||||
@@ -193,7 +194,9 @@ void vkb_sv_vkEndCommandBuffer(vkb_srv_call *c)
|
||||
sub.table = c->table;
|
||||
sub.conn = c->conn;
|
||||
sub.in_stream = 1;
|
||||
vkb_srv_current_cmd = vkb_cmd_names[id];
|
||||
vkb_srv_handlers[id](&sub);
|
||||
vkb_srv_current_cmd = vkb_cmd_names[VKB_CMD_vkEndCommandBuffer];
|
||||
scratch = sub.r;
|
||||
if (sub.status != VKB_ST_OK) {
|
||||
VKB_ERR("command stream: %s failed (status %u)", vkb_cmd_names[id], sub.status);
|
||||
@@ -274,7 +277,9 @@ static void *conn_main(void *arg)
|
||||
if (c.status == VKB_ST_OK) {
|
||||
vkb_srv_set_current_table(c.table);
|
||||
if (vkb_verbose) VKB_DBG("-> %s", vkb_cmd_names[h.cmd]);
|
||||
vkb_srv_current_cmd = vkb_cmd_names[h.cmd];
|
||||
vkb_srv_handlers[h.cmd](&c);
|
||||
vkb_srv_current_cmd = NULL;
|
||||
vkb_srv_set_current_table(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ void vkb_sv_vkCreateDevice(vkb_srv_call *c)
|
||||
inst->real.vkEnumerateDeviceExtensionProperties(pd, NULL, &avail_n, avail);
|
||||
uint32_t extra_n = 0;
|
||||
const char *const *extra = vkb_mem_required_extensions(strategy, &extra_n);
|
||||
const char **exts = vkb_dec_alloc(&c->d, (ci->enabledExtensionCount + extra_n + 1) * sizeof(char *));
|
||||
const char **exts = vkb_dec_alloc(&c->d, (ci->enabledExtensionCount + extra_n + 8) * sizeof(char *));
|
||||
uint32_t n = 0;
|
||||
for (uint32_t i = 0; i < ci->enabledExtensionCount; i++) {
|
||||
const char *e = ci->ppEnabledExtensionNames[i];
|
||||
@@ -258,6 +258,13 @@ void vkb_sv_vkCreateDevice(vkb_srv_call *c)
|
||||
}
|
||||
for (uint32_t i = 0; i < extra_n; i++)
|
||||
if (has_ext(avail, avail_n, extra[i]) && !list_has(exts, n, extra[i])) exts[n++] = extra[i];
|
||||
/* What the client's presentation code uses on every device (dma-buf swapchains, sync fds). */
|
||||
static const char *const wsi_exts[] = {
|
||||
"VK_KHR_external_memory_fd", "VK_EXT_external_memory_dma_buf", "VK_KHR_image_format_list",
|
||||
"VK_EXT_image_drm_format_modifier", "VK_KHR_external_semaphore_fd", "VK_KHR_external_fence_fd",
|
||||
};
|
||||
for (size_t i = 0; i < sizeof(wsi_exts) / sizeof(wsi_exts[0]); i++)
|
||||
if (has_ext(avail, avail_n, wsi_exts[i]) && !list_has(exts, n, wsi_exts[i])) exts[n++] = wsi_exts[i];
|
||||
ci->enabledExtensionCount = n;
|
||||
ci->ppEnabledExtensionNames = exts;
|
||||
ci->enabledLayerCount = 0;
|
||||
|
||||
@@ -67,6 +67,25 @@ void vkb_log(int level, const char *fmt, ...)
|
||||
#endif
|
||||
}
|
||||
|
||||
extern __thread const char *vkb_srv_current_cmd;
|
||||
|
||||
/* A crash is almost always the driver's: say in which call, then die as we would have. */
|
||||
static void on_crash(int sig)
|
||||
{
|
||||
char buf[256];
|
||||
const char *cmd = vkb_srv_current_cmd ? vkb_srv_current_cmd : "(no Vulkan call)";
|
||||
int n = snprintf(buf, sizeof(buf), "vkbridge-server E crashed with signal %d in %s\n", sig, cmd);
|
||||
if (log_file) {
|
||||
if (write(fileno(log_file), buf, (size_t)n) < 0) {}
|
||||
}
|
||||
if (write(2, buf, (size_t)n) < 0) {}
|
||||
#ifdef __ANDROID__
|
||||
__android_log_write(ANDROID_LOG_FATAL, "vkbridge", buf);
|
||||
#endif
|
||||
signal(sig, SIG_DFL);
|
||||
raise(sig);
|
||||
}
|
||||
|
||||
static void *load_vulkan(const char *override)
|
||||
{
|
||||
const char *names[] = {
|
||||
@@ -149,6 +168,11 @@ int main(int argc, char **argv)
|
||||
if (!log_file) fprintf(stderr, "vkbridge-server: cannot open log %s: %s\n", log_path, strerror(errno));
|
||||
}
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGSEGV, on_crash);
|
||||
signal(SIGBUS, on_crash);
|
||||
signal(SIGABRT, on_crash);
|
||||
signal(SIGILL, on_crash);
|
||||
signal(SIGFPE, on_crash);
|
||||
/* The server is the app's child: when the app dies, so does the session's GPU. */
|
||||
prctl(PR_SET_PDEATHSIG, SIGTERM);
|
||||
|
||||
|
||||
Reference in new issue
Block a user