mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db1c6b5280 | ||
|
|
d7787706dd | ||
|
|
4a5e20bf98 | ||
|
|
2a445ea183 | ||
|
|
8217cb2513 | ||
|
|
e78d1097ef | ||
|
|
22f34c8252 | ||
|
|
02b2486858 | ||
|
|
66f59dc9d0 | ||
|
|
90f794e96d | ||
|
|
aa3c64dec9 |
No files matched your search
@@ -73,6 +73,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
||||
- DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence.
|
||||
- x86 programs linking OpenSSL 3 use the copy in the [Steam Linux Runtime 4.0](https://gitlab.steamos.cloud/steamrt/steamrt). x86 Linux games get the `/etc/asound.conf` that [pressure-vessel](https://gitlab.steamos.cloud/steamrt/steam-runtime-tools) writes.
|
||||
- `WriteProcessMemory` hooks fall back to `/proc/<pid>/mem` the way [Wine](https://gitlab.winehq.org/wine/wine)'s `server/ptrace.c` did before Wine 11.
|
||||
- Windows components give Wine Mono a `Gac=n` assembly override only for assemblies in Mono's own GAC, following the assembly search order in [Wine](https://gitlab.winehq.org/wine/wine)'s `dlls/mscoree/metahost.c`.
|
||||
- Windows programs on noexec storage get executable copies of their image pages, following [@yujikaido](https://github.com/yujikaido)'s finding in [droiddeck-rp4pro](https://github.com/yujikaido/droiddeck-rp4pro) that Wine's own processes need the noexec shim.
|
||||
- Wine write watches use userfaultfd support in [Proton](https://github.com/ValveSoftware/wine)'s `dlls/ntdll/unix/virtual.c` (LGPL-2.1-or-later). libddsession supplies the arm64 syscall number and answers `PAGEMAP_SCAN` from `/proc/self/pagemap`.
|
||||
- libddsession runs Wine's arm64 `SIGUSR2` context handler (`dlls/ntdll/unix/signal_arm64.c`, LGPL-2.1-or-later) in place on a frame laid out like [Linux](https://github.com/torvalds/linux)'s `arch/arm64/kernel/signal.c`, and serves `fill_vm_counters` in `dlls/ntdll/unix/process.c` the kernel's own `/proc/<pid>/status`.
|
||||
|
||||
@@ -242,10 +242,6 @@ struct surface {
|
||||
enum surface_role role;
|
||||
struct wl_resource *idle_buffer;
|
||||
struct wl_listener idle_buffer_destroy;
|
||||
struct surface_state *waiting;
|
||||
struct wl_event_source *waiting_source, *waiting_timer;
|
||||
int waiting_fd;
|
||||
int64_t waiting_since_ns;
|
||||
uint32_t *idle_px;
|
||||
int idle_w, idle_h;
|
||||
struct wl_resource *xdg_surface, *xdg_toplevel;
|
||||
@@ -377,8 +373,6 @@ static struct {
|
||||
unsigned copy_scenes;
|
||||
unsigned releases, releases_held;
|
||||
int64_t release_ns, release_max_ns;
|
||||
unsigned commit_waits, commit_wait_limits;
|
||||
int64_t commit_wait_ns, commit_wait_max_ns;
|
||||
} g_perf;
|
||||
|
||||
static void schedule_render(void);
|
||||
@@ -852,55 +846,6 @@ static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) {
|
||||
s->pending_buffer = NULL;
|
||||
}
|
||||
|
||||
struct surface_state {
|
||||
struct wl_resource *buffer;
|
||||
struct wl_listener buffer_destroy;
|
||||
int attach;
|
||||
int src_set, dst_set, opaque_set;
|
||||
float src[4];
|
||||
int dst[2], opaque[4];
|
||||
struct damage_list damage_buf, damage_local;
|
||||
struct wl_list frames, feedback;
|
||||
};
|
||||
|
||||
static void on_state_buffer_destroyed(struct wl_listener *l, void *data) {
|
||||
struct surface_state *st = wl_container_of(l, st, buffer_destroy);
|
||||
wl_list_remove(&st->buffer_destroy.link);
|
||||
wl_list_init(&st->buffer_destroy.link);
|
||||
st->buffer = NULL;
|
||||
st->attach = 0;
|
||||
}
|
||||
|
||||
static void surface_state_take(struct surface *s, struct surface_state *st) {
|
||||
st->attach = s->pending_attach;
|
||||
st->buffer = s->pending_buffer;
|
||||
wl_list_init(&st->buffer_destroy.link);
|
||||
if (st->buffer) {
|
||||
wl_list_remove(&s->pending_buffer_destroy.link);
|
||||
wl_list_init(&s->pending_buffer_destroy.link);
|
||||
st->buffer_destroy.notify = on_state_buffer_destroyed;
|
||||
wl_resource_add_destroy_listener(st->buffer, &st->buffer_destroy);
|
||||
}
|
||||
s->pending_buffer = NULL;
|
||||
s->pending_attach = 0;
|
||||
st->src_set = s->pending_src_set;
|
||||
memcpy(st->src, s->pending_src, sizeof(st->src));
|
||||
st->dst_set = s->pending_dst_set;
|
||||
memcpy(st->dst, s->pending_dst, sizeof(st->dst));
|
||||
st->opaque_set = s->pending_opaque_set;
|
||||
memcpy(st->opaque, s->pending_opaque, sizeof(st->opaque));
|
||||
s->pending_src_set = s->pending_dst_set = s->pending_opaque_set = 0;
|
||||
st->damage_buf = s->pending_damage_buf;
|
||||
st->damage_local = s->pending_damage_local;
|
||||
s->pending_damage_buf.n = s->pending_damage_local.n = 0;
|
||||
wl_list_init(&st->frames);
|
||||
wl_list_insert_list(&st->frames, &s->pending_frames);
|
||||
wl_list_init(&s->pending_frames);
|
||||
wl_list_init(&st->feedback);
|
||||
wl_list_insert_list(&st->feedback, &s->pending_feedback);
|
||||
wl_list_init(&s->pending_feedback);
|
||||
}
|
||||
|
||||
static void fire_frames(struct wl_list *frames) {
|
||||
struct wl_resource *cb, *tmp;
|
||||
uint32_t t;
|
||||
@@ -1418,23 +1363,35 @@ static void surface_drop_idle(struct surface *s) {
|
||||
if (buffer) send_buffer_release(buffer);
|
||||
}
|
||||
|
||||
static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
||||
static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
struct surface *s = wl_resource_get_user_data(r);
|
||||
struct surface *child;
|
||||
|
||||
if (st->src_set) {
|
||||
s->src_set = st->src[2] > 0;
|
||||
memcpy(s->src, st->src, sizeof(s->src));
|
||||
if (s->xdg_toplevel && !s->toplevel_committed) {
|
||||
s->toplevel_committed = 1;
|
||||
send_toplevel_configure(s);
|
||||
}
|
||||
if (st->dst_set) {
|
||||
s->dst_set = st->dst[0] > 0;
|
||||
memcpy(s->dst, st->dst, sizeof(s->dst));
|
||||
}
|
||||
if (st->opaque_set) memcpy(s->opaque, st->opaque, sizeof(s->opaque));
|
||||
|
||||
s->damage_buf = st->damage_buf;
|
||||
s->damage_local = st->damage_local;
|
||||
if (st->attach) {
|
||||
struct wl_resource *buffer = st->buffer;
|
||||
if (s->pending_src_set) {
|
||||
s->src_set = s->pending_src[2] > 0;
|
||||
memcpy(s->src, s->pending_src, sizeof(s->src));
|
||||
s->pending_src_set = 0;
|
||||
}
|
||||
if (s->pending_dst_set) {
|
||||
s->dst_set = s->pending_dst[0] > 0;
|
||||
memcpy(s->dst, s->pending_dst, sizeof(s->dst));
|
||||
s->pending_dst_set = 0;
|
||||
}
|
||||
if (s->pending_opaque_set) {
|
||||
memcpy(s->opaque, s->pending_opaque, sizeof(s->opaque));
|
||||
s->pending_opaque_set = 0;
|
||||
}
|
||||
|
||||
s->damage_buf = s->pending_damage_buf;
|
||||
s->damage_local = s->pending_damage_local;
|
||||
s->pending_damage_buf.n = s->pending_damage_local.n = 0;
|
||||
if (s->pending_attach) {
|
||||
struct wl_resource *buffer = s->pending_buffer;
|
||||
struct dmabuf_buffer *db = get_dmabuf(buffer);
|
||||
struct wl_shm_buffer *shm = buffer && !db ? wl_shm_buffer_get(buffer) : NULL;
|
||||
uint8_t pixel[4];
|
||||
@@ -1443,10 +1400,12 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
||||
if (!buffer) g_pace.null_attaches++;
|
||||
else if (!db) s->last_dmabuf = NULL;
|
||||
|
||||
wl_list_remove(&st->buffer_destroy.link);
|
||||
wl_list_init(&st->buffer_destroy.link);
|
||||
st->buffer = NULL;
|
||||
st->attach = 0;
|
||||
if (buffer) {
|
||||
wl_list_remove(&s->pending_buffer_destroy.link);
|
||||
wl_list_init(&s->pending_buffer_destroy.link);
|
||||
}
|
||||
s->pending_buffer = NULL;
|
||||
s->pending_attach = 0;
|
||||
|
||||
surface_drop_idle(s);
|
||||
buf_trace_attach(buffer);
|
||||
@@ -1483,10 +1442,10 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
||||
}
|
||||
}
|
||||
|
||||
wl_list_insert_list(s->frames.prev, &st->frames);
|
||||
wl_list_init(&st->frames);
|
||||
wl_list_insert_list(s->feedback.prev, &st->feedback);
|
||||
wl_list_init(&st->feedback);
|
||||
wl_list_insert_list(s->frames.prev, &s->pending_frames);
|
||||
wl_list_init(&s->pending_frames);
|
||||
wl_list_insert_list(s->feedback.prev, &s->pending_feedback);
|
||||
wl_list_init(&s->pending_feedback);
|
||||
constraints_surface_commit(s);
|
||||
droiddeck_color_commit(s->resource);
|
||||
|
||||
@@ -1496,186 +1455,6 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
||||
}
|
||||
schedule_render();
|
||||
}
|
||||
|
||||
#define COMMIT_WAIT_LIMIT_MS 1000
|
||||
|
||||
static struct surface *g_zero_copy_shown, *g_unwaited;
|
||||
|
||||
static int state_unfinished_fd(const struct surface *s, const struct surface_state *st, int *unwaited) {
|
||||
struct dmabuf_buffer *db = st->attach ? get_dmabuf(st->buffer) : NULL;
|
||||
int fd = -1;
|
||||
*unwaited = 0;
|
||||
for (int i = 0; db && fd < 0 && i < db->n_planes; i++) {
|
||||
if (db->fd[i] < 0) continue;
|
||||
struct pollfd p = {.fd = db->fd[i], .events = POLLIN};
|
||||
int r;
|
||||
do { r = poll(&p, 1, 0); } while (r < 0 && errno == EINTR);
|
||||
if (r == 0) fd = db->fd[i];
|
||||
}
|
||||
if (fd >= 0 && s == g_zero_copy_shown && ahb_swapchain_has_ahb(db)) {
|
||||
*unwaited = 1;
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
static void settle_unwaited(void) {
|
||||
struct surface *s = g_unwaited;
|
||||
if (!s) return;
|
||||
g_unwaited = NULL;
|
||||
struct dmabuf_buffer *db = s->dmabuf_buf;
|
||||
const int64_t deadline = now_ns() + 100000000LL;
|
||||
for (int i = 0; db && i < db->n_planes; i++) {
|
||||
if (db->fd[i] < 0) continue;
|
||||
struct pollfd p = {.fd = db->fd[i], .events = POLLIN};
|
||||
for (;;) {
|
||||
const int64_t left = deadline - now_ns();
|
||||
const int r = poll(&p, 1, left > 0 ? (int)((left + 999999) / 1000000) : 0);
|
||||
if (r >= 0 || errno != EINTR || left <= 0) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void surface_state_discard(struct surface_state *st) {
|
||||
struct wl_resource *cb, *tmp;
|
||||
wl_list_remove(&st->buffer_destroy.link);
|
||||
wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb);
|
||||
feedback_discard_all(&st->feedback);
|
||||
free(st);
|
||||
}
|
||||
|
||||
static void surface_state_merge(struct surface_state *older, struct surface_state *newer) {
|
||||
if (older->attach && !newer->attach) {
|
||||
newer->attach = 1;
|
||||
newer->buffer = older->buffer;
|
||||
wl_list_remove(&older->buffer_destroy.link);
|
||||
wl_list_init(&older->buffer_destroy.link);
|
||||
if (newer->buffer) {
|
||||
newer->buffer_destroy.notify = on_state_buffer_destroyed;
|
||||
wl_resource_add_destroy_listener(newer->buffer, &newer->buffer_destroy);
|
||||
}
|
||||
wl_list_insert_list(&newer->feedback, &older->feedback);
|
||||
wl_list_init(&older->feedback);
|
||||
} else if (older->attach) {
|
||||
if (older->buffer && older->buffer != newer->buffer) send_buffer_release(older->buffer);
|
||||
g_pace.replaced += feedback_discard_all(&older->feedback);
|
||||
}
|
||||
if (older->src_set && !newer->src_set) {
|
||||
newer->src_set = 1;
|
||||
memcpy(newer->src, older->src, sizeof(newer->src));
|
||||
}
|
||||
if (older->dst_set && !newer->dst_set) {
|
||||
newer->dst_set = 1;
|
||||
memcpy(newer->dst, older->dst, sizeof(newer->dst));
|
||||
}
|
||||
if (older->opaque_set && !newer->opaque_set) {
|
||||
newer->opaque_set = 1;
|
||||
memcpy(newer->opaque, older->opaque, sizeof(newer->opaque));
|
||||
}
|
||||
for (int i = 0; i < older->damage_buf.n; i++)
|
||||
note_damage(&newer->damage_buf, older->damage_buf.r[i][0], older->damage_buf.r[i][1],
|
||||
older->damage_buf.r[i][2], older->damage_buf.r[i][3]);
|
||||
for (int i = 0; i < older->damage_local.n; i++)
|
||||
note_damage(&newer->damage_local, older->damage_local.r[i][0], older->damage_local.r[i][1],
|
||||
older->damage_local.r[i][2], older->damage_local.r[i][3]);
|
||||
wl_list_insert_list(&newer->frames, &older->frames);
|
||||
wl_list_init(&older->frames);
|
||||
surface_state_discard(older);
|
||||
}
|
||||
|
||||
static void surface_wait_stop(struct surface *s) {
|
||||
if (s->waiting_source) wl_event_source_remove(s->waiting_source);
|
||||
if (s->waiting_timer) wl_event_source_remove(s->waiting_timer);
|
||||
if (s->waiting_fd >= 0) close(s->waiting_fd);
|
||||
s->waiting_source = s->waiting_timer = NULL;
|
||||
s->waiting_fd = -1;
|
||||
}
|
||||
|
||||
static void surface_wait_end(struct surface *s, int over_limit) {
|
||||
struct surface_state *st = s->waiting;
|
||||
if (!st) return;
|
||||
surface_wait_stop(s);
|
||||
s->waiting = NULL;
|
||||
const int64_t waited = now_ns() - s->waiting_since_ns;
|
||||
g_perf.commit_waits++;
|
||||
g_perf.commit_wait_ns += waited;
|
||||
if (waited > g_perf.commit_wait_max_ns) g_perf.commit_wait_max_ns = waited;
|
||||
if (over_limit) g_perf.commit_wait_limits++;
|
||||
if (st->attach && g_unwaited == s) g_unwaited = NULL;
|
||||
surface_state_apply(s, st);
|
||||
free(st);
|
||||
}
|
||||
|
||||
static int on_commit_ready(int fd, uint32_t mask, void *data) {
|
||||
surface_wait_end(data, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int on_commit_wait_limit(void *data) {
|
||||
static int said;
|
||||
if (!said) {
|
||||
said = 1;
|
||||
droiddeck_log("compositor", "a client's GPU writes ran past %d ms; its frame is shown as it is", COMMIT_WAIT_LIMIT_MS);
|
||||
}
|
||||
surface_wait_end(data, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int surface_wait_start(struct surface *s, int fd, int timeout_ms) {
|
||||
struct wl_event_loop *loop = wl_display_get_event_loop(g_display);
|
||||
s->waiting_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
|
||||
if (s->waiting_fd >= 0) {
|
||||
s->waiting_source = wl_event_loop_add_fd(loop, s->waiting_fd, WL_EVENT_READABLE, on_commit_ready, s);
|
||||
s->waiting_timer = wl_event_loop_add_timer(loop, on_commit_wait_limit, s);
|
||||
}
|
||||
if (!s->waiting_source || !s->waiting_timer ||
|
||||
wl_event_source_timer_update(s->waiting_timer, timeout_ms) != 0) {
|
||||
surface_wait_stop(s);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
struct surface *s = wl_resource_get_user_data(r);
|
||||
|
||||
if (s->xdg_toplevel && !s->toplevel_committed) {
|
||||
s->toplevel_committed = 1;
|
||||
send_toplevel_configure(s);
|
||||
}
|
||||
struct surface_state *st = calloc(1, sizeof(*st));
|
||||
if (!st) {
|
||||
struct surface_state now;
|
||||
surface_state_take(s, &now);
|
||||
surface_state_apply(s, &now);
|
||||
return;
|
||||
}
|
||||
surface_state_take(s, st);
|
||||
const int was_waiting = s->waiting != NULL;
|
||||
if (was_waiting) {
|
||||
surface_wait_stop(s);
|
||||
surface_state_merge(s->waiting, st);
|
||||
s->waiting = NULL;
|
||||
}
|
||||
int unwaited;
|
||||
const int fd = state_unfinished_fd(s, st, &unwaited);
|
||||
if (!was_waiting) s->waiting_since_ns = now_ns();
|
||||
const int64_t left_ms = COMMIT_WAIT_LIMIT_MS - (now_ns() - s->waiting_since_ns) / 1000000;
|
||||
if (fd >= 0 && left_ms > 0 && surface_wait_start(s, fd, (int)left_ms) == 0) {
|
||||
s->waiting = st;
|
||||
return;
|
||||
}
|
||||
const int attaches = st->attach;
|
||||
if (was_waiting) {
|
||||
s->waiting = st;
|
||||
surface_wait_end(s, fd >= 0 && left_ms <= 0);
|
||||
} else {
|
||||
surface_state_apply(s, st);
|
||||
free(st);
|
||||
}
|
||||
if (unwaited) g_unwaited = s;
|
||||
else if (attaches && g_unwaited == s) g_unwaited = NULL;
|
||||
}
|
||||
static void surface_set_buffer_transform(struct wl_client *c, struct wl_resource *r, int32_t t) {}
|
||||
static void surface_set_buffer_scale(struct wl_client *c, struct wl_resource *r, int32_t s) {}
|
||||
static void surface_damage_buffer(struct wl_client *c, struct wl_resource *r,
|
||||
@@ -1737,13 +1516,6 @@ static void surface_resource_destroy(struct wl_resource *r) {
|
||||
child->parent = NULL;
|
||||
}
|
||||
if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link);
|
||||
if (s->waiting) {
|
||||
surface_wait_stop(s);
|
||||
surface_state_discard(s->waiting);
|
||||
s->waiting = NULL;
|
||||
}
|
||||
if (g_zero_copy_shown == s) g_zero_copy_shown = NULL;
|
||||
if (g_unwaited == s) g_unwaited = NULL;
|
||||
pending_releases_forget_surface(s);
|
||||
drop_dmabuf(s, 0);
|
||||
ahb_swapchain_surface_gone(s);
|
||||
@@ -1807,7 +1579,6 @@ static void compositor_create_surface(struct wl_client *c, struct wl_resource *r
|
||||
wl_list_init(&s->child_link);
|
||||
wl_list_init(&s->toplevel_link);
|
||||
wl_list_init(&s->pending_buffer_destroy.link);
|
||||
s->waiting_fd = -1;
|
||||
wl_list_init(&s->idle_buffer_destroy.link);
|
||||
wl_list_insert(&g_surfaces, &s->link);
|
||||
wl_resource_set_implementation(s->resource, &surface_impl, s, surface_resource_destroy);
|
||||
@@ -2731,13 +2502,7 @@ static int64_t scene_next_due(int64_t now, int64_t due, int limit) {
|
||||
|
||||
static void render_scene(void) {
|
||||
g_scene_due_ns = scene_next_due(now_ns(), g_scene_due_ns, g_fps_limit);
|
||||
if (atomic_load(&g_stream_on)) {
|
||||
g_dirty_since_ns = 0;
|
||||
g_zero_copy_shown = NULL;
|
||||
settle_unwaited();
|
||||
render_stream();
|
||||
return;
|
||||
}
|
||||
if (atomic_load(&g_stream_on)) { g_dirty_since_ns = 0; render_stream(); return; }
|
||||
struct draw_list dl = {0};
|
||||
struct surface *s;
|
||||
int w, h;
|
||||
@@ -2811,8 +2576,6 @@ static void render_scene(void) {
|
||||
} else {
|
||||
cursor_hdr_said = 0;
|
||||
}
|
||||
g_zero_copy_shown = NULL;
|
||||
if (hdr_route == 1 || hdr_route == 2) settle_unwaited();
|
||||
if (hdr_route == 1) {
|
||||
static int fell_back;
|
||||
vkp_apply_window_request();
|
||||
@@ -2846,7 +2609,6 @@ static void render_scene(void) {
|
||||
}
|
||||
if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
||||
!ahb_only) {
|
||||
settle_unwaited();
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
} else if (hdr_route == 0 || hdr_route == 3) {
|
||||
const int pass_on = fx_on || framegen;
|
||||
@@ -2896,7 +2658,6 @@ static void render_scene(void) {
|
||||
vkp_apply_window_request();
|
||||
int r = -1;
|
||||
const int fg_pass = framegen && fx_on && li >= 0;
|
||||
if (framegen && li >= 0) settle_unwaited();
|
||||
const int generated = (framegen && li >= 0)
|
||||
? sc_layer_present_generated(&dl.d[li], 1, NULL, w, h, fg_pass,
|
||||
ls ? droiddeck_surface_color(ls) : NULL) : 0;
|
||||
@@ -2910,8 +2671,6 @@ static void render_scene(void) {
|
||||
r = generated >= 0 ? 0 : -1;
|
||||
else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
||||
r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld);
|
||||
if (r == 0 && !fg_pass) g_zero_copy_shown = ls;
|
||||
else settle_unwaited();
|
||||
if (!fg_pass && generated >= 0 && r != 0 && li >= 0)
|
||||
r = fx_on ? sc_layer_present_pass(&dl.d[li], 1, w, h)
|
||||
: sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL);
|
||||
@@ -2922,7 +2681,6 @@ static void render_scene(void) {
|
||||
ov = sc_layer_present_overlay(dl.d[li + 1].img, go, dl.d[li + 1].blend) == 0 ? 1 : -1;
|
||||
if (ov <= 0) sc_layer_hide_overlay();
|
||||
if (ov < 0) {
|
||||
settle_unwaited();
|
||||
sc_layer_hide();
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
copy = 1;
|
||||
@@ -2932,14 +2690,12 @@ static void render_scene(void) {
|
||||
g_scene_queues = sc_layer_queues();
|
||||
}
|
||||
} else {
|
||||
settle_unwaited();
|
||||
sc_layer_hide();
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
copy = 1;
|
||||
hdr_copy = "its display layer was unavailable this frame";
|
||||
}
|
||||
} else {
|
||||
settle_unwaited();
|
||||
sc_layer_hide();
|
||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||
copy = 1;
|
||||
@@ -4588,12 +4344,11 @@ static int on_stats_timer(void *data) {
|
||||
unsigned aimed_next, aimed_later, aimed_even;
|
||||
sc_layer_aim_take(&aimed_next, &aimed_later, &aimed_even);
|
||||
#define PERF_MS(sum, n) ((n) ? (double)(sum) / 1e6 / (double)(n) : 0.0)
|
||||
if (g_perf.scenes || vp.presents || g_perf.releases || drops || g_perf.commit_waits)
|
||||
if (g_perf.scenes || vp.presents || g_perf.releases || drops)
|
||||
droiddeck_log("perf", "last 10 s: %u ticks, %u scenes, %u on screen (copy %u, zero-copy %u, layer copy %u) | "
|
||||
"render_scene %.2f/%.2f ms | base %u black kept, %u presented | acquire %.2f/%.2f ms | "
|
||||
"present %.2f/%.2f ms (%u) | fence wait %.2f/%.2f ms (%u, %u GPU release waits) | "
|
||||
"release %.2f/%.2f ms (%u, %u held) | commits held for client writes %.2f/%.2f ms (%u, %u past the limit) | "
|
||||
"%u pool drops | layer frames timed for the next refresh %u, "
|
||||
"release %.2f/%.2f ms (%u, %u held) | %u pool drops | layer frames timed for the next refresh %u, "
|
||||
"the one after %u, held to an even step %u",
|
||||
g_perf.ticks, g_perf.scenes, g_stat_frames, g_perf.copy_scenes, zero_copy, layer_frames,
|
||||
PERF_MS(g_perf.scene_ns, g_perf.scenes), (double)g_perf.scene_max_ns / 1e6,
|
||||
@@ -4602,9 +4357,7 @@ static int on_stats_timer(void *data) {
|
||||
PERF_MS(vp.present_ns, vp.presents), (double)vp.present_max_ns / 1e6, vp.presents,
|
||||
PERF_MS(vp.wait_ns, vp.waits), (double)vp.wait_max_ns / 1e6, vp.waits, vp.gpu_release_waits,
|
||||
PERF_MS(g_perf.release_ns, g_perf.releases), (double)g_perf.release_max_ns / 1e6,
|
||||
g_perf.releases, g_perf.releases_held,
|
||||
PERF_MS(g_perf.commit_wait_ns, g_perf.commit_waits), (double)g_perf.commit_wait_max_ns / 1e6,
|
||||
g_perf.commit_waits, g_perf.commit_wait_limits, drops, aimed_next, aimed_later, aimed_even);
|
||||
g_perf.releases, g_perf.releases_held, drops, aimed_next, aimed_later, aimed_even);
|
||||
#undef PERF_MS
|
||||
memset(&g_perf, 0, sizeof(g_perf));
|
||||
}
|
||||
|
||||
@@ -483,6 +483,12 @@ object WinComponents {
|
||||
return dir
|
||||
}
|
||||
|
||||
internal fun nativeDlls(c: Component): List<String> = c.steps.filter { it.action == "override_dll" }.flatMap { step ->
|
||||
listOf(step.str("dll") to step.str("type")) + (step.json.optJSONArray("bundle")?.let { b ->
|
||||
(0 until b.length()).map { b.getJSONObject(it).let { o -> o.optString("value") to o.optString("data") } }
|
||||
} ?: emptyList())
|
||||
}.filter { (dll, type) -> type == "native" && validId(dll) }.map { it.first.lowercase() }.distinct()
|
||||
|
||||
private fun installPackage(context: Context, c: Component, step: Step, staging: File, onProgress: (Progress) -> Unit): Pair<JSONObject?, String> {
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
val url = step.str("url")
|
||||
@@ -500,7 +506,9 @@ object WinComponents {
|
||||
onProgress(Progress(c.name, "installing", Phase.INSTALL, 0))
|
||||
var result: JSONObject? = null
|
||||
var problem: String? = null
|
||||
val status = GuestCommand.run(context, guest(listOf(MSI_INSTALL, "/$MSI_CACHE/${file.name}", "/$STORE/${staging.name}")),
|
||||
val native = nativeDlls(c)
|
||||
val flags = if (native.isEmpty()) emptyList() else listOf("--native", native.joinToString(","))
|
||||
val status = GuestCommand.run(context, guest(listOf(MSI_INSTALL) + flags + listOf("/$MSI_CACHE/${file.name}", "/$STORE/${staging.name}")),
|
||||
logName = "wincomponents-${c.name}") { line ->
|
||||
when {
|
||||
line.startsWith("progress ") -> engineLine(line.removePrefix("progress ")).let { (text, pct) -> onProgress(Progress(c.name, text, Phase.INSTALL, pct)) }
|
||||
|
||||
@@ -121,8 +121,6 @@ object StoresState {
|
||||
var unfinished by mutableStateOf<List<StoreInstallRoot.Unfinished>>(emptyList())
|
||||
internal set
|
||||
|
||||
var steamPicking by mutableStateOf<CatalogItem?>(null)
|
||||
|
||||
fun isUnfinished(item: CatalogItem): Boolean = unfinished.any {
|
||||
it.store == item.store && (it.id == item.id || (it.id == null && it.folder.name == StoreInstallRoot.folderName(item.title, item.id)))
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import android.net.Uri
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.setValue
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
@@ -43,6 +46,8 @@ internal object SteamStore {
|
||||
/** InvalidPassword, AccessDenied, AccountNotFound, Revoked, Expired, AccountLogonDenied. */
|
||||
private val REFUSALS = setOf(5, 15, 18, 26, 27, 63)
|
||||
|
||||
var picking by mutableStateOf<CatalogItem?>(null)
|
||||
|
||||
class Plan(val installDir: String, val downloadBytes: Long, val installBytes: Long, val buildId: String, val linuxBuild: Boolean) {
|
||||
companion object {
|
||||
fun of(json: JSONObject): Plan? {
|
||||
@@ -217,7 +222,7 @@ internal object SteamStore {
|
||||
toast(context, R.string.steam_store_close_steam)
|
||||
return
|
||||
}
|
||||
StoresState.steamPicking = item
|
||||
picking = item
|
||||
}
|
||||
|
||||
fun install(context: Context, item: CatalogItem, target: SteamClient.Target) {
|
||||
|
||||
@@ -847,7 +847,7 @@ private fun FrontEndScreenBody(s: FrontEndState, a: FrontEndActions, page: (@Com
|
||||
com.droiddeck.launcher.stores.StoresState.pendingInstall?.let { item -> StoreTheme(item.store) { InstallWhere(item) } }
|
||||
com.droiddeck.launcher.stores.StoresState.itchPicking?.let { item -> StoreTheme(item.store) { ItchBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.itchPicking = null } } }
|
||||
com.droiddeck.launcher.stores.StoresState.gameJoltPicking?.let { item -> StoreTheme(item.store) { GameJoltBuildPicker(item) { com.droiddeck.launcher.stores.StoresState.gameJoltPicking = null } } }
|
||||
com.droiddeck.launcher.stores.StoresState.steamPicking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.StoresState.steamPicking = null } } }
|
||||
com.droiddeck.launcher.stores.steam.SteamStore.picking?.let { item -> StoreTheme(item.store) { SteamInstallWhereDialog(item) { com.droiddeck.launcher.stores.steam.SteamStore.picking = null } } }
|
||||
StepsLayer(screenAt)
|
||||
UiZooSheet()
|
||||
SessionDrawerPreview(s.secondScreenDisplays)
|
||||
|
||||
@@ -32,6 +32,14 @@ class WinComponentsSupportTest {
|
||||
step("install_msi", "url" to "$base/ps-x86.msi"), step("install_msi", "url" to "$base/ps-x64.msi"))))
|
||||
}
|
||||
|
||||
@Test fun onlyDllsOrderedNativeAreKeptFromDownlevelSystemComponents() {
|
||||
val c = component("dotnet40", step("override_dll", "dll" to "MSCOREE", "type" to "native"),
|
||||
step("override_dll", "dll" to "fusion", "type" to "builtin"), step("override_dll", "dll" to "msvcr100"),
|
||||
step("override_dll", "dll" to "../x", "type" to "native"), step("install_exe", "url" to "$base/dotnet40.exe"))
|
||||
assertEquals(listOf("mscoree"), WinComponents.nativeDlls(c))
|
||||
assertEquals(emptyList<String>(), WinComponents.nativeDlls(component("xna40", step("install_msi", "url" to "$base/xna40.msi"))))
|
||||
}
|
||||
|
||||
@Test fun builtInArm64RuntimeInstallsTheRedistributable() {
|
||||
val c = WinComponents.builtInArm64Runtime()
|
||||
assertEquals(Support.READY, support(c))
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.droiddeck.launcher.stores.steam
|
||||
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.snapshots.Snapshot
|
||||
import androidx.compose.runtime.snapshots.StateObject
|
||||
import com.droiddeck.launcher.stores.StoresState
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [33], manifest = Config.NONE)
|
||||
class SteamPickingSnapshotTest {
|
||||
@Test
|
||||
fun theInstallPickerIsReadableInASnapshotOpenedBeforeTheSteamEngineStarts() {
|
||||
StoresState.steamPicking = null
|
||||
val snapshot = Snapshot.takeMutableSnapshot()
|
||||
try {
|
||||
thread { SteamStore.hashCode() }.join()
|
||||
assertNull(snapshot.enter { StoresState.steamPicking })
|
||||
} finally {
|
||||
snapshot.dispose()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theSteamEngineHoldsNoComposeState() {
|
||||
val stateFields = SteamStore::class.java.declaredFields.filter {
|
||||
StateObject::class.java.isAssignableFrom(it.type) || State::class.java.isAssignableFrom(it.type)
|
||||
}
|
||||
assertTrue(stateFields.joinToString { it.name }, stateFields.isEmpty())
|
||||
}
|
||||
}
|
||||
@@ -9,25 +9,6 @@ import org.junit.Test
|
||||
class XodusDiagnosticsTest {
|
||||
private val rejected = Regex(Xodus.SIGN_IN_REJECTED)
|
||||
|
||||
@Test fun aDeviceLimitReachesTheInstallerWithoutBecomingASignInFailure() {
|
||||
val line = "NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200"
|
||||
val tail = listOf(line).filter { it.matches(Xodus.reportable) }
|
||||
assertEquals(listOf(line), tail)
|
||||
assertFalse(line.matches(rejected))
|
||||
assertEquals(com.droiddeck.launcher.R.string.stores_xbox_device_group_full, XboxInstaller.licenseRefusal(tail))
|
||||
}
|
||||
|
||||
@Test fun aLaterLicenseSuccessClearsTheDeviceLimitThroughTheDiagnosticFilter() {
|
||||
val stderr = listOf(
|
||||
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-device-limit 200",
|
||||
"NEXUS_CONTENT_LICENSE_DIAGNOSTIC_V1 content-parsed 200",
|
||||
"NEXUS_EXTRACT_DIAGNOSTIC_V1 extract-failed"
|
||||
)
|
||||
val tail = stderr.filter { it.matches(Xodus.reportable) }
|
||||
assertEquals(stderr, tail)
|
||||
assertNull(XboxInstaller.licenseRefusal(tail))
|
||||
}
|
||||
|
||||
@Test fun aContentLicenseRejectionIsRecognised() {
|
||||
assertTrue("Microsoft content licensing rejected sign-in (HTTP 401). Sign in again in Settings.".matches(rejected))
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ SYSTEM_PROPERTIES = {
|
||||
"Msix64": "6", "ALLUSERS": "1", "Privileged": "1", "AdminUser": "1", "MsiNTProductType": "1",
|
||||
"UILevel": "2", "INSTALLLEVEL": "1", "ProgramFilesFolder": None, "VersionMsi": "5.00",
|
||||
}
|
||||
DOWNLEVEL_PROPERTIES = {"VersionNT": "502", "VersionNT64": "502", "WindowsBuild": "3790", "ServicePackLevel": "2"}
|
||||
SYSTEM_DIRS = ("drive_c/windows/system32", "drive_c/windows/syswow64")
|
||||
|
||||
NATIVE_ARCHITECTURE = {"intel": "x86", "x64": "AMD64", "amd64": "AMD64", "arm64": "ARM64"}
|
||||
ARCHITECTURE_VALUE = ("system\\currentcontrolset\\control\\session manager\\environment", "processor_architecture")
|
||||
@@ -323,8 +325,9 @@ def clr_version(path):
|
||||
|
||||
|
||||
class Installer:
|
||||
def __init__(self, msi, out, package=None, span=None):
|
||||
def __init__(self, msi, out, package=None, span=None, native=()):
|
||||
self.pkg = package or Package(msi)
|
||||
self.native = {name.lower() for name in native}
|
||||
self.out = Path(out)
|
||||
self.span = span or Span()
|
||||
self.notes = []
|
||||
@@ -479,10 +482,19 @@ class Installer:
|
||||
owners = mapped.get(name)
|
||||
if owners is not None and not owners & self.included_features:
|
||||
continue
|
||||
if not self.conditions.evaluate(row.get("Condition", ""), default=True):
|
||||
if not self.conditions.evaluate(row.get("Condition", ""), default=True) and not self.downlevel_native(row):
|
||||
continue
|
||||
self.included_components.add(name)
|
||||
|
||||
def downlevel_native(self, row):
|
||||
if not self.native or (self.directory(row.get("Directory_", "")) or "").lower() not in SYSTEM_DIRS:
|
||||
return False
|
||||
key = next((f for f in self.pkg.table("File") if f["File"] == row.get("KeyPath")), None)
|
||||
if key is None or Path(long_name(key["FileName"])).stem.lower() not in self.native:
|
||||
return False
|
||||
props = dict(self.props, **DOWNLEVEL_PROPERTIES)
|
||||
return Conditions(props, self.feature_state, self.component_state).evaluate(row.get("Condition", ""), default=False)
|
||||
|
||||
def assemblies(self):
|
||||
names = {}
|
||||
for row in self.pkg.table("MsiAssemblyName"):
|
||||
@@ -888,7 +900,7 @@ def choose_packages(found, root):
|
||||
return native or top
|
||||
|
||||
|
||||
def install_wrapper(path, out):
|
||||
def install_wrapper(path, out, native=()):
|
||||
total = {"product": "", "version": "", "counts": {"files": 0, "assemblies": 0, "registry": 0}, "notes": [], "packages": []}
|
||||
with tempfile.TemporaryDirectory(dir=str(out.parent), prefix=".unpack-") as work:
|
||||
dest = Path(work) / "x"
|
||||
@@ -901,7 +913,7 @@ def install_wrapper(path, out):
|
||||
lo, hi = 0.1 + 0.9 * index / len(packages), 0.1 + 0.9 * (index + 1) / len(packages)
|
||||
progress("package %d of %d: %s" % (index + 1, len(packages), package.name), lo)
|
||||
try:
|
||||
result = Installer(str(package), out, span=Span(lo, hi)).install()
|
||||
result = Installer(str(package), out, span=Span(lo, hi), native=native).install()
|
||||
except MsiError as error:
|
||||
if "installs nothing" in str(error) and len(packages) > 1:
|
||||
total["notes"].append("%s: %s" % (package.name, error))
|
||||
@@ -955,6 +967,10 @@ def unpack_only(path, dest):
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
native = []
|
||||
while len(args) > 1 and args[0] == "--native":
|
||||
native += [name for name in args[1].split(",") if name]
|
||||
args = args[2:]
|
||||
if len(args) == 3 and args[0] == "--unpack":
|
||||
try:
|
||||
result = unpack_only(Path(args[1]), Path(args[2]))
|
||||
@@ -964,16 +980,16 @@ def main():
|
||||
print("result " + json.dumps(result), flush=True)
|
||||
return 0
|
||||
if len(args) != 2:
|
||||
print("usage: droiddeck-msi-install <package.msi | installer.exe> <component dir>\n"
|
||||
print("usage: droiddeck-msi-install [--native dll,...] <package.msi | installer.exe> <component dir>\n"
|
||||
" droiddeck-msi-install --unpack <archive> <dir>", file=sys.stderr)
|
||||
return 2
|
||||
source, out = Path(args[0]), Path(args[1])
|
||||
out.mkdir(parents=True, exist_ok=True)
|
||||
try:
|
||||
if kind_of(source) == "msi":
|
||||
result = Installer(str(source), out).install()
|
||||
result = Installer(str(source), out, native=native).install()
|
||||
else:
|
||||
result = install_wrapper(source, out)
|
||||
result = install_wrapper(source, out, native)
|
||||
except MsiError as error:
|
||||
print("error " + str(error), flush=True)
|
||||
return 1
|
||||
|
||||
@@ -23,6 +23,7 @@ BUILTIN_MARKS = (b"Wine builtin DLL", b"Wine placeholder DLL")
|
||||
ARCH_DIRS = ("system32", "syswow64")
|
||||
ID = re.compile(r"[A-Za-z0-9][A-Za-z0-9._-]{0,63}")
|
||||
HIVES = {"HKLM": "system.reg", "HKCU": "user.reg"}
|
||||
PROTON_MONO = ("files/share/wine/mono", "dist/share/wine/mono")
|
||||
VALUE_TYPES = {"key", "sz", "expand_sz", "multi_sz", "dword", "binary", "append", "prepend"}
|
||||
|
||||
|
||||
@@ -44,7 +45,7 @@ def wanted(app_id, selection=SELECTION):
|
||||
return ids
|
||||
|
||||
|
||||
def component(store, cid):
|
||||
def component(store, cid, mono=frozenset()):
|
||||
root = Path(store) / cid
|
||||
try:
|
||||
with open(root / "component.json", encoding="utf-8") as source:
|
||||
@@ -65,7 +66,40 @@ def component(store, cid):
|
||||
if entry.is_file() and not entry.is_symlink():
|
||||
files.append(("drive_c/" + entry.relative_to(drive).as_posix(), entry))
|
||||
requires = [r for r in meta.get("requires", []) if valid_id(r)]
|
||||
return [str(o) for o in meta.get("overrides", [])], files, requires, registry_values(root)
|
||||
overrides = [str(o) for o in meta.get("overrides", [])]
|
||||
values = registry_values(root)
|
||||
if any(o.strip().lower() == "mscoree=n" for o in overrides):
|
||||
assemblies = set()
|
||||
for rel, _ in files:
|
||||
parts = Path(rel.lower()).parts
|
||||
gac_paths = (("windows", "assembly"), ("windows", "microsoft.net", "assembly"))
|
||||
if rel.lower().endswith(".dll") and Path(rel).stem.lower() in mono and any(
|
||||
parts[i:i + len(prefix)] == prefix
|
||||
and i + len(prefix) < len(parts)
|
||||
and (parts[i + len(prefix)] == "gac" or parts[i + len(prefix)].startswith("gac_"))
|
||||
for prefix in gac_paths for i in range(len(parts) - len(prefix))):
|
||||
assemblies.add(Path(rel).stem)
|
||||
assemblies = sorted(assemblies)
|
||||
values = [{"hive": "HKCU", "key": "Software\\Wine\\Mono\\AsmOverrides", "name": name,
|
||||
"type": "sz", "data": "Gac=n", "generated": True} for name in assemblies] + values
|
||||
return overrides, files, requires, values
|
||||
|
||||
|
||||
def mono_assemblies(pfx, proton=None):
|
||||
candidates = [[spelled(Path(pfx) / "drive_c/windows/mono/mono-2.0/lib/mono/gac")]]
|
||||
if proton:
|
||||
candidates += [sorted((Path(proton).parent / home).glob("wine-mono*/lib/mono/gac")) for home in PROTON_MONO]
|
||||
for gacs in candidates:
|
||||
names = set()
|
||||
for gac in gacs:
|
||||
try:
|
||||
with os.scandir(gac) as entries:
|
||||
names.update(entry.name.lower() for entry in entries if entry.is_dir())
|
||||
except OSError:
|
||||
pass
|
||||
if names:
|
||||
return names
|
||||
return set()
|
||||
|
||||
|
||||
def registry_values(root):
|
||||
@@ -418,7 +452,8 @@ def apply_registry(pfx, values, state, held=()):
|
||||
files[hive] = RegistryFile(pfx / name)
|
||||
old = state.get("registry") if isinstance(state.get("registry"), dict) else {}
|
||||
keep, notes, written, waiting = {}, [], 0, 0
|
||||
for cid, value in values:
|
||||
ordered = [item for item in values if item[1].get("generated")] + [item for item in values if not item[1].get("generated")]
|
||||
for cid, value in ordered:
|
||||
reg = files.get(value["hive"])
|
||||
if reg is None:
|
||||
waiting += 1
|
||||
@@ -562,8 +597,9 @@ def apply(compat_path, app_id, selection=SELECTION, store=STORE, pending=PENDING
|
||||
saved_requires = dict(saved_requires, **{cid: loose})
|
||||
inferred.add(cid)
|
||||
kept_overrides, kept_requires = {}, {}
|
||||
mono = mono_assemblies(pfx, proton)
|
||||
for cid in expand(store, ids, saved_requires):
|
||||
found = component(store, cid)
|
||||
found = component(store, cid, mono)
|
||||
if found is None:
|
||||
if cid in saved_requires or cid in recorded or cid in owners or cid in registry_owners:
|
||||
held.add(cid)
|
||||
@@ -683,10 +719,10 @@ def overrides_value(names):
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 3:
|
||||
print("usage: droiddeck-wincomponents <compatdata dir> <appid>", file=sys.stderr)
|
||||
if len(sys.argv) not in (3, 4):
|
||||
print("usage: droiddeck-wincomponents <compatdata dir> <appid> [proton]", file=sys.stderr)
|
||||
return 2
|
||||
names, notes = apply(sys.argv[1], sys.argv[2])
|
||||
names, notes = apply(sys.argv[1], sys.argv[2], proton=sys.argv[3] if len(sys.argv) == 4 else None)
|
||||
for note in notes:
|
||||
print(note)
|
||||
print("WINEDLLOVERRIDES=" + overrides_value(names))
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <link.h>
|
||||
#include <linux/input.h>
|
||||
#include <pthread.h>
|
||||
#include <stdatomic.h>
|
||||
@@ -16,7 +15,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/sysmacros.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
@@ -36,8 +34,7 @@
|
||||
"NAME=\"Xbox 360 Controller (%d)\"\n" \
|
||||
"PHYS=\"usb-fakeinput/input%d\"\n"
|
||||
|
||||
#define STEAM_VIRTUAL_VENDOR 0x28de
|
||||
#define STEAM_VIRTUAL_PRODUCT 0x11ff
|
||||
#define RING_SDL_ID 0x045e028eu
|
||||
|
||||
#define PARENT_NAME "droiddeck-input"
|
||||
#define PARENT_SYSPATH_FORMAT "/sys/devices/droiddeck%d/" PARENT_NAME "%d"
|
||||
@@ -144,8 +141,66 @@ static int any_virtual_pad(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char *sdl_id_list_text(const char *list) {
|
||||
char *text = NULL;
|
||||
char *grown;
|
||||
size_t length = 0;
|
||||
size_t got;
|
||||
FILE *file;
|
||||
|
||||
if (list[0] != '@') return strdup(list);
|
||||
file = fopen(list + 1, "re");
|
||||
if (file == NULL) return NULL;
|
||||
do {
|
||||
grown = realloc(text, length + 4097);
|
||||
if (grown == NULL) {
|
||||
free(text);
|
||||
fclose(file);
|
||||
return NULL;
|
||||
}
|
||||
text = grown;
|
||||
got = fread(text + length, 1, 4096, file);
|
||||
length += got;
|
||||
} while (got > 0);
|
||||
fclose(file);
|
||||
text[length] = '\0';
|
||||
return text;
|
||||
}
|
||||
|
||||
static int sdl_id_list_entries(const char *list, int *has_ring) {
|
||||
char *text = sdl_id_list_text(list);
|
||||
char *spot = text;
|
||||
uint32_t entry;
|
||||
int entries = 0;
|
||||
|
||||
*has_ring = 0;
|
||||
if (text == NULL) return 0;
|
||||
while ((spot = strstr(spot, "0x")) != NULL) {
|
||||
entry = (uint32_t)(uint16_t)strtol(spot, &spot, 0) << 16;
|
||||
spot = strstr(spot, "0x");
|
||||
if (spot == NULL) break;
|
||||
entry |= (uint16_t)strtol(spot, &spot, 0);
|
||||
entries++;
|
||||
if (entry == RING_SDL_ID) *has_ring = 1;
|
||||
}
|
||||
free(text);
|
||||
return entries;
|
||||
}
|
||||
|
||||
static int sdl_bus_skips_ring_pad(void) {
|
||||
const char *steam_virtual = getenv("FAKE_EVDEV_STEAM_VIRTUAL");
|
||||
const char *except = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT");
|
||||
const char *ignore = getenv("SDL_GAMECONTROLLER_IGNORE_DEVICES");
|
||||
int has_ring;
|
||||
|
||||
if (steam_virtual != NULL && atoi(steam_virtual) != 0) return 1;
|
||||
if (except != NULL && sdl_id_list_entries(except, &has_ring) > 0) return !has_ring;
|
||||
return ignore != NULL && sdl_id_list_entries(ignore, &has_ring) > 0 && has_ring;
|
||||
}
|
||||
|
||||
static const char *ring_uevent_format(void) {
|
||||
return uinput_enabled() && any_virtual_pad() ? PAD_PHYSICAL_UEVENT_FORMAT : PAD_UEVENT_FORMAT;
|
||||
if (uinput_enabled() && any_virtual_pad()) return PAD_PHYSICAL_UEVENT_FORMAT;
|
||||
return sdl_bus_skips_ring_pad() ? PAD_UEVENT_FORMAT : PAD_PHYSICAL_UEVENT_FORMAT;
|
||||
}
|
||||
|
||||
static void refresh_locked(int node) {
|
||||
@@ -459,60 +514,6 @@ static int caller_in_library(void *caller, const char *library) {
|
||||
|
||||
static int caller_is_winebus(void *caller) { return caller_in_library(caller, "winebus.so"); }
|
||||
|
||||
static int note_winebus(struct dl_phdr_info *info, size_t size, void *data) {
|
||||
(void)size;
|
||||
if (info->dlpi_name == NULL || strstr(info->dlpi_name, "winebus.so") == NULL) return 0;
|
||||
*(int *)data = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int winebus_reads_udev(void) {
|
||||
const char *x360 = getenv("FAKE_EVDEV_STEAM_PAD_AS_X360");
|
||||
int loaded = 0;
|
||||
|
||||
if (x360 != NULL && atoi(x360) != 0) return 0;
|
||||
dl_iterate_phdr(note_winebus, &loaded);
|
||||
return loaded;
|
||||
}
|
||||
|
||||
static int ring_pad_fd(int fd) {
|
||||
const char *spec = getenv("FAKE_EVDEV_MEMFD_PATHS");
|
||||
const char *entry;
|
||||
struct stat opened;
|
||||
struct stat ring;
|
||||
char path[PATH_MAX];
|
||||
|
||||
if (spec == NULL || fstat(fd, &opened) != 0) return 0;
|
||||
for (entry = spec; *entry != '\0';) {
|
||||
char *end;
|
||||
long slot = strtol(entry, &end, 10);
|
||||
const char *next = strchr(entry, ';');
|
||||
size_t length;
|
||||
|
||||
if (end != entry && *end == '=' && slot >= 0 && slot < RING_MAX) {
|
||||
length = next != NULL ? (size_t)(next - end - 1) : strlen(end + 1);
|
||||
if (length < sizeof(path)) {
|
||||
memcpy(path, end + 1, length);
|
||||
path[length] = '\0';
|
||||
if (stat(path, &ring) == 0 && ring.st_dev == opened.st_dev && ring.st_ino == opened.st_ino) return 1;
|
||||
}
|
||||
}
|
||||
if (next == NULL) break;
|
||||
entry = next + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("hidden"))) void dd_ring_pad_sdl_id(int fd, unsigned long request, void *arg,
|
||||
void *caller, int rc) {
|
||||
struct input_id *id = arg;
|
||||
|
||||
if (rc != 0 || request != EVIOCGID || id == NULL) return;
|
||||
if (!caller_in_library(caller, "libSDL") || !winebus_reads_udev() || !ring_pad_fd(fd)) return;
|
||||
id->vendor = STEAM_VIRTUAL_VENDOR;
|
||||
id->product = STEAM_VIRTUAL_PRODUCT;
|
||||
}
|
||||
|
||||
typedef int (*sdl_rumble_fn)(void *, uint16_t, uint16_t, uint32_t);
|
||||
static _Atomic(sdl_rumble_fn) real_sdl_rumble;
|
||||
static __thread int winebus_sdl_call;
|
||||
|
||||
@@ -424,8 +424,6 @@ int dd_venc_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute
|
||||
int dd_vdec_ioctl(int fd, unsigned long request, void *arg, int *rc) __attribute__((visibility("hidden")));
|
||||
int dd_winebus_rumble_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request,
|
||||
void *arg, void *caller, int *rc) __attribute__((visibility("hidden")));
|
||||
void dd_ring_pad_sdl_id(int fd, unsigned long request, void *arg, void *caller, int rc)
|
||||
__attribute__((visibility("hidden")));
|
||||
int dd_writewatch_ioctl(int (*real)(int, unsigned long, void *), int fd, unsigned long request, void *arg,
|
||||
int *rc) __attribute__((visibility("hidden")));
|
||||
|
||||
@@ -446,7 +444,6 @@ int ioctl(int fd, unsigned long request, ...) {
|
||||
if (dd_winebus_rumble_ioctl(real, fd, request, arg, __builtin_return_address(0), &rc)) return rc;
|
||||
if (dd_writewatch_ioctl(real, fd, request, arg, &rc)) return rc;
|
||||
if (!dd_kgsl_poll(real, fd, request, arg, &rc)) rc = quest_kgsl_ioctl(real, fd, request, arg);
|
||||
dd_ring_pad_sdl_id(fd, request, arg, __builtin_return_address(0), rc);
|
||||
dd_kgsl_track(real, fd, request, arg, &rc);
|
||||
dd_kgsl_chip_id_fixup(request, arg, rc);
|
||||
if (arg == NULL || !is_link_query(request)) return rc;
|
||||
|
||||
@@ -452,8 +452,7 @@ static int ddnatv_execve(const char *filename, char *const argv[], char *const e
|
||||
char resolved_target[PATH_MAX];
|
||||
|
||||
// Only intercept binaries/scripts within DDNATV_ROOT
|
||||
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename) ||
|
||||
is_bound_guest_program(target)) {
|
||||
if ((g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(filename)) {
|
||||
struct exec_probe probe;
|
||||
const char *elf_target = select_exec_target(target, resolved_target, sizeof(resolved_target), &probe);
|
||||
if (probe.is_elf && !probe.is_dynamic) static_elf = elf_target;
|
||||
@@ -970,8 +969,7 @@ static int ddnatv_posix_spawn(pid_t *pid, const char *path,
|
||||
}
|
||||
|
||||
char *const *orig_ep = envp ? envp : environ;
|
||||
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path) ||
|
||||
is_bound_guest_program(target);
|
||||
int in_root = (g_ddnatv_root[0] != '\0' && strncmp(target, g_ddnatv_root, g_ddnatv_root_len) == 0) || is_mapped_guest_path(path);
|
||||
|
||||
struct exec_probe probe;
|
||||
char resolved_target[PATH_MAX];
|
||||
|
||||
@@ -983,14 +983,6 @@ static int is_host_interpreter(const char *interp, const char *rewritten) {
|
||||
return probe.android_interp;
|
||||
}
|
||||
|
||||
static int is_bound_guest_program(const char *path) {
|
||||
if (g_ddnatv_root[0] == '\0' || !is_identity_bound_path(path)) return 0;
|
||||
struct exec_probe probe;
|
||||
probe_exec_file(path, &probe);
|
||||
if (probe.is_elf) return probe.is_dynamic && !probe.android_interp;
|
||||
return probe.n >= 2 && probe.hdr[0] == '#' && probe.hdr[1] == '!';
|
||||
}
|
||||
|
||||
// argv for running `script` with its interpreter: interp [arg] script args... (the script's own
|
||||
// argv[0] is dropped, as the kernel does). free() the result.
|
||||
static char **build_script_argv(const char *interp, const char *interp_arg, const char *script, char *const argv[]) {
|
||||
|
||||
@@ -234,13 +234,6 @@ static int is_mapped_guest_path(const char *path) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int is_identity_bound_path(const char *path) {
|
||||
if (!path || path[0] != '/') return 0;
|
||||
for (int i = 0; i < g_nbinds; i++)
|
||||
if (g_binds[i].identity && is_path_prefix(path, g_binds[i].dst, g_binds[i].dst_len)) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Android's own mounts and files, which must never be redirected into the rootfs.
|
||||
// `path` starts with '/'; a prefix can only match when its second character does.
|
||||
static int is_android_host_path(const char *path) {
|
||||
|
||||
@@ -1,293 +0,0 @@
|
||||
"""A commit whose dma-buf the client's GPU is still writing is held until the buffer polls readable.
|
||||
|
||||
The compiled functions come from compositor.c; libwayland's lists and event loop, poll and the clock are faked.
|
||||
"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
SOURCE = Path(__file__).resolve().parents[2] / 'app/src/main/cpp/waylandcomp/src/compositor.c'
|
||||
|
||||
|
||||
def function(text, name):
|
||||
match = re.search(r'^(?:static )?[^\n;]+\b' + name + r'\([^;]*?\)\s*\{', text, re.M)
|
||||
if not match:
|
||||
raise AssertionError('Production function not found: ' + name)
|
||||
pos = text.index('{', match.start())
|
||||
depth, end = 1, pos + 1
|
||||
while depth:
|
||||
depth += (text[end] == '{') - (text[end] == '}')
|
||||
end += 1
|
||||
return text[match.start():end]
|
||||
|
||||
|
||||
def block(text, start):
|
||||
begin = text.index(start)
|
||||
return text[begin:text.index('\n};\n', begin) + 4]
|
||||
|
||||
|
||||
HARNESS = r'''
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stddef.h>
|
||||
#define DAMAGE_RECTS 4
|
||||
#define POLLIN 1
|
||||
#define F_DUPFD_CLOEXEC 1030
|
||||
#define WL_EVENT_READABLE 1
|
||||
struct pollfd { int fd; short events, revents; };
|
||||
struct wl_list { struct wl_list *prev, *next; };
|
||||
struct wl_listener { struct wl_list link; void (*notify)(struct wl_listener *, void *); };
|
||||
static void wl_list_init(struct wl_list *l) { l->prev = l->next = l; }
|
||||
static void wl_list_remove(struct wl_list *l) { l->prev->next = l->next; l->next->prev = l->prev; l->prev = l->next = NULL; }
|
||||
static void wl_list_insert(struct wl_list *list, struct wl_list *elm) {
|
||||
elm->prev = list; elm->next = list->next; list->next = elm; elm->next->prev = elm;
|
||||
}
|
||||
static void wl_list_insert_list(struct wl_list *list, struct wl_list *other) {
|
||||
if (other->next == other) return;
|
||||
other->next->prev = list; other->prev->next = list->next; list->next->prev = other->prev; list->next = other->next;
|
||||
}
|
||||
static int wl_list_length(const struct wl_list *l) { int n = 0; for (struct wl_list *e = l->next; e != l; e = e->next) n++; return n; }
|
||||
#define wl_container_of(ptr, sample, member) (__typeof__(sample))((char *)(ptr) - offsetof(__typeof__(*sample), member))
|
||||
|
||||
struct dmabuf_buffer { int fd[4]; int n_planes; int ahb; };
|
||||
struct wl_resource { struct wl_list link; struct wl_listener *listener; struct dmabuf_buffer *db; int released, destroyed; };
|
||||
static struct wl_resource *from_link(struct wl_list *l) { return wl_container_of(l, (struct wl_resource *)0, link); }
|
||||
#define wl_resource_for_each_safe(r, t, list) \
|
||||
for (r = from_link((list)->next), t = from_link(r->link.next); &r->link != (list); r = t, t = from_link(t->link.next))
|
||||
static void wl_resource_destroy(struct wl_resource *r) { wl_list_remove(&r->link); r->destroyed = 1; }
|
||||
static void wl_resource_add_destroy_listener(struct wl_resource *r, struct wl_listener *l) { r->listener = l; wl_list_init(&l->link); }
|
||||
static void client_destroys(struct wl_resource *r) {
|
||||
if (r->listener) { struct wl_listener *l = r->listener; r->listener = NULL; l->notify(l, r); }
|
||||
}
|
||||
|
||||
static int ready[64], dup_of[64], next_dup = 40, closed[64];
|
||||
static int poll(struct pollfd *p, unsigned n, int timeout) {
|
||||
if (n != 1 || timeout != 0 || p->events != POLLIN) { puts("FAIL poll args"); exit(1); }
|
||||
return ready[p->fd] ? 1 : 0;
|
||||
}
|
||||
static int fcntl(int fd, int cmd, int arg) { (void)cmd; (void)arg; dup_of[next_dup] = fd; return next_dup++; }
|
||||
static int close(int fd) { closed[fd]++; return 0; }
|
||||
|
||||
struct wl_event_source { int fd; int (*fd_cb)(int, uint32_t, void *); int (*timer_cb)(void *); void *data; int armed_ms, removed; };
|
||||
struct wl_event_loop;
|
||||
struct wl_display;
|
||||
static struct wl_display *g_display;
|
||||
static struct wl_event_source sources[32];
|
||||
static int n_sources;
|
||||
static struct wl_event_loop *wl_display_get_event_loop(struct wl_display *d) { (void)d; return NULL; }
|
||||
static struct wl_event_source *wl_event_loop_add_fd(struct wl_event_loop *l, int fd, uint32_t mask,
|
||||
int (*cb)(int, uint32_t, void *), void *data) {
|
||||
(void)l; (void)mask; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s));
|
||||
s->fd = fd; s->fd_cb = cb; s->data = data; return s;
|
||||
}
|
||||
static struct wl_event_source *wl_event_loop_add_timer(struct wl_event_loop *l, int (*cb)(void *), void *data) {
|
||||
(void)l; struct wl_event_source *s = &sources[n_sources++]; memset(s, 0, sizeof(*s));
|
||||
s->fd = -1; s->timer_cb = cb; s->data = data; return s;
|
||||
}
|
||||
static int wl_event_source_timer_update(struct wl_event_source *s, int ms) { s->armed_ms = ms; return 0; }
|
||||
static int wl_event_source_remove(struct wl_event_source *s) { s->removed = 1; return 0; }
|
||||
static void dispatch(int timers_expire) {
|
||||
for (int i = 0; i < n_sources; i++) {
|
||||
struct wl_event_source *s = &sources[i];
|
||||
if (s->removed) continue;
|
||||
if (s->fd_cb && ready[dup_of[s->fd]]) s->fd_cb(s->fd, WL_EVENT_READABLE, s->data);
|
||||
else if (s->timer_cb && s->armed_ms && timers_expire) { s->armed_ms = 0; s->timer_cb(s->data); }
|
||||
}
|
||||
}
|
||||
|
||||
static int64_t clock_ns;
|
||||
static int64_t now_ns(void) { return clock_ns; }
|
||||
static struct { unsigned replaced; } g_pace;
|
||||
static struct { unsigned commit_waits, commit_wait_limits; int64_t commit_wait_ns, commit_wait_max_ns; } g_perf;
|
||||
static int logged;
|
||||
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; logged++; }
|
||||
static void send_buffer_release(struct wl_resource *r) { r->released++; }
|
||||
static unsigned feedback_discard_all(struct wl_list *list) {
|
||||
unsigned n = 0; struct wl_resource *r, *t; wl_resource_for_each_safe(r, t, list) { wl_resource_destroy(r); n++; } return n;
|
||||
}
|
||||
static struct dmabuf_buffer *get_dmabuf(struct wl_resource *r) { return r ? r->db : NULL; }
|
||||
static int ahb_swapchain_has_ahb(const struct dmabuf_buffer *b) { return b->ahb; }
|
||||
static int64_t rect_area(const int32_t *r, int bw, int bh) { (void)bw; (void)bh; return (int64_t)r[2] * r[3]; }
|
||||
|
||||
struct damage_list { int32_t r[DAMAGE_RECTS][4]; int n; };
|
||||
struct surface {
|
||||
struct wl_resource *resource, *xdg_toplevel;
|
||||
int toplevel_committed;
|
||||
struct wl_resource *pending_buffer;
|
||||
struct wl_listener pending_buffer_destroy;
|
||||
int pending_attach, pending_src_set, pending_dst_set, pending_opaque_set;
|
||||
float pending_src[4];
|
||||
int pending_dst[2], pending_opaque[4];
|
||||
struct damage_list pending_damage_buf, pending_damage_local;
|
||||
struct wl_list pending_frames, pending_feedback;
|
||||
struct surface_state *waiting;
|
||||
struct wl_event_source *waiting_source, *waiting_timer;
|
||||
int waiting_fd;
|
||||
int64_t waiting_since_ns;
|
||||
};
|
||||
static void send_toplevel_configure(struct surface *s) { (void)s; }
|
||||
struct wl_client;
|
||||
static struct surface surf;
|
||||
|
||||
STATE_STRUCT
|
||||
|
||||
static int applies, applied_attach, applied_frames, applied_opaque, applied_damage;
|
||||
static struct wl_resource *applied_buffer;
|
||||
static void surface_state_apply(struct surface *s, struct surface_state *st);
|
||||
|
||||
FUNCTIONS
|
||||
|
||||
static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
||||
(void)s;
|
||||
applies++;
|
||||
applied_attach = st->attach;
|
||||
applied_buffer = st->attach ? st->buffer : NULL;
|
||||
applied_frames = wl_list_length(&st->frames);
|
||||
applied_opaque = st->opaque_set ? st->opaque[2] : -1;
|
||||
applied_damage = st->damage_buf.n;
|
||||
if (st->attach) { wl_list_remove(&st->buffer_destroy.link); wl_list_init(&st->buffer_destroy.link); }
|
||||
struct wl_resource *r, *t;
|
||||
wl_resource_for_each_safe(r, t, &st->frames) wl_resource_destroy(r);
|
||||
feedback_discard_all(&st->feedback);
|
||||
}
|
||||
|
||||
static struct wl_resource frame_res[16];
|
||||
static int n_frames;
|
||||
static void attach(struct wl_resource *b) {
|
||||
if (surf.pending_buffer) wl_list_remove(&surf.pending_buffer_destroy.link);
|
||||
wl_list_init(&surf.pending_buffer_destroy.link);
|
||||
surf.pending_buffer = b; surf.pending_attach = 1;
|
||||
}
|
||||
static void frame(void) { struct wl_resource *f = &frame_res[n_frames++]; wl_list_insert(surf.pending_frames.prev, &f->link); }
|
||||
static void damage(int w) { surf.pending_damage_buf.r[surf.pending_damage_buf.n][2] = w;
|
||||
surf.pending_damage_buf.r[surf.pending_damage_buf.n][3] = 1; surf.pending_damage_buf.n++; }
|
||||
static void commit(void) { surface_commit(NULL, NULL); }
|
||||
#define CHECK(c, what) do { if (!(c)) { printf("FAIL %s (line %d)\n", what, __LINE__); return 1; } } while (0)
|
||||
|
||||
int main(void) {
|
||||
wl_list_init(&surf.pending_frames); wl_list_init(&surf.pending_feedback);
|
||||
wl_list_init(&surf.pending_buffer_destroy.link);
|
||||
surf.waiting_fd = -1;
|
||||
struct dmabuf_buffer d1 = {{10, -1}, 1, 0}, d2 = {{11, -1}, 1, 0}, d3 = {{12, -1}, 1, 0}, dz = {{13, -1}, 1, 1};
|
||||
struct wl_resource b1 = {.db = &d1}, b2 = {.db = &d2}, b3 = {.db = &d3}, bz = {.db = &dz};
|
||||
|
||||
ready[10] = 1;
|
||||
attach(&b1); frame(); commit();
|
||||
CHECK(applies == 1 && applied_buffer == &b1 && applied_frames == 1 && !surf.waiting && n_sources == 0, "ready buffer");
|
||||
|
||||
ready[11] = 0;
|
||||
clock_ns = 1000000;
|
||||
attach(&b2); frame(); damage(5); commit();
|
||||
CHECK(applies == 1 && surf.waiting && surf.waiting_fd >= 40 && dup_of[surf.waiting_fd] == 11, "held");
|
||||
CHECK(sources[0].armed_ms == 0 && sources[1].armed_ms == 1000, "waits on the buffer with a 1 s limit");
|
||||
dispatch(0);
|
||||
CHECK(applies == 1, "nothing before the writes end");
|
||||
clock_ns = 4000000;
|
||||
ready[11] = 1;
|
||||
dispatch(0);
|
||||
CHECK(applies == 2 && applied_buffer == &b2 && applied_frames == 1 && applied_damage == 1 && !surf.waiting, "applied once ready");
|
||||
CHECK(closed[40] == 1 && sources[0].removed && sources[1].removed, "wait cleaned up");
|
||||
CHECK(g_perf.commit_waits == 1 && g_perf.commit_wait_max_ns == 3000000, "wait counted");
|
||||
|
||||
ready[11] = 0; ready[12] = 0;
|
||||
attach(&b2); frame(); damage(7); commit();
|
||||
attach(&b3); frame(); damage(9); commit();
|
||||
CHECK(applies == 2 && b2.released == 1 && dup_of[surf.waiting_fd] == 12, "replaced while waiting");
|
||||
ready[12] = 1;
|
||||
dispatch(0);
|
||||
CHECK(applies == 3 && applied_buffer == &b3 && applied_frames == 2 && applied_damage == 2, "newest shown with both callbacks");
|
||||
CHECK(g_perf.commit_waits == 2, "merged wait counted once");
|
||||
|
||||
ready[11] = 0;
|
||||
attach(&b2); commit();
|
||||
surf.pending_opaque[2] = 640; surf.pending_opaque_set = 1; frame(); commit();
|
||||
CHECK(applies == 3 && b2.released == 1 && dup_of[surf.waiting_fd] == 11, "the waiting buffer is not released");
|
||||
ready[11] = 1;
|
||||
dispatch(0);
|
||||
CHECK(applies == 4 && applied_buffer == &b2 && applied_opaque == 640 && applied_frames == 1, "buffer kept, opaque applied");
|
||||
|
||||
g_zero_copy_shown = &surf;
|
||||
attach(&bz); commit();
|
||||
CHECK(applies == 5 && applied_buffer == &bz && !surf.waiting && g_unwaited == &surf, "zero-copy buffer");
|
||||
g_zero_copy_shown = NULL;
|
||||
ready[13] = 0;
|
||||
attach(&bz); commit();
|
||||
CHECK(applies == 5 && surf.waiting, "a droiddeck-ahb buffer not shown zero-copy waits");
|
||||
ready[13] = 1;
|
||||
dispatch(0);
|
||||
CHECK(applies == 6 && !g_unwaited, "waited buffer clears the mark");
|
||||
ready[13] = 0;
|
||||
|
||||
ready[10] = 0;
|
||||
attach(&b1); frame(); commit();
|
||||
client_destroys(&b1);
|
||||
ready[10] = 1;
|
||||
dispatch(0);
|
||||
CHECK(applies == 7 && !applied_attach && applied_frames == 1, "destroyed buffer dropped from the commit");
|
||||
|
||||
ready[11] = 0;
|
||||
attach(&b2); commit();
|
||||
dispatch(1);
|
||||
CHECK(applies == 8 && applied_buffer == &b2 && g_perf.commit_wait_limits == 1 && logged == 1 && !surf.waiting, "limit");
|
||||
|
||||
ready[11] = 0; ready[12] = 0;
|
||||
clock_ns = 10000000000;
|
||||
attach(&b2); commit();
|
||||
CHECK(applies == 8 && sources[n_sources - 1].armed_ms == 1000, "held again");
|
||||
clock_ns += 600000000;
|
||||
attach(&b3); commit();
|
||||
CHECK(applies == 8 && surf.waiting && sources[n_sources - 1].armed_ms == 400, "a newer commit keeps the first deadline");
|
||||
clock_ns += 500000000;
|
||||
attach(&b2); commit();
|
||||
CHECK(applies == 9 && applied_buffer == &b2 && g_perf.commit_wait_limits == 2 && !surf.waiting, "commits past the deadline are applied at once");
|
||||
puts("PASS");
|
||||
return 0;
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
class CommitWaitsForClientWritesTest(unittest.TestCase):
|
||||
def test_commits_wait_for_the_clients_gpu_writes(self):
|
||||
compiler = shutil.which(os.environ.get('CC', 'cc'))
|
||||
if not compiler:
|
||||
self.skipTest('A host C compiler is required')
|
||||
source = SOURCE.read_text()
|
||||
functions = '\n'.join(re.search(pattern, source, re.M).group(0) for pattern in
|
||||
(r'^#define COMMIT_WAIT_LIMIT_MS .*$', r'^static struct surface \*g_zero_copy_shown, \*g_unwaited;$')) + '\n' + '\n'.join(
|
||||
function(source, name) for name in
|
||||
('note_damage', 'on_state_buffer_destroyed', 'surface_state_take', 'state_unfinished_fd',
|
||||
'surface_state_discard', 'surface_state_merge', 'surface_wait_stop', 'surface_wait_end', 'on_commit_ready',
|
||||
'on_commit_wait_limit', 'surface_wait_start', 'surface_commit'))
|
||||
probe = HARNESS.replace('STATE_STRUCT', block(source, 'struct surface_state {')).replace('FUNCTIONS', functions)
|
||||
probe = probe.replace('struct surface *s = wl_resource_get_user_data(r);', 'struct surface *s = &surf; (void)r;')
|
||||
with tempfile.TemporaryDirectory(prefix='droiddeck-commit-wait-') as temp:
|
||||
folder = Path(temp)
|
||||
(folder / 'probe.c').write_text(probe)
|
||||
built = subprocess.run([compiler, '-std=gnu11', '-Wall', '-Wextra', '-Wno-unused-parameter', '-Wno-unused-function',
|
||||
str(folder / 'probe.c'), '-o', str(folder / 'probe')],
|
||||
capture_output=True, text=True)
|
||||
self.assertEqual(built.returncode, 0, built.stdout + built.stderr)
|
||||
run = subprocess.run([str(folder / 'probe')], capture_output=True, text=True, timeout=10)
|
||||
self.assertEqual(run.returncode, 0, run.stdout + run.stderr)
|
||||
self.assertEqual(run.stdout.strip(), 'PASS')
|
||||
|
||||
def test_scenes_settle_an_unwaited_buffer_before_copying_it(self):
|
||||
body = function(SOURCE.read_text(), 'render_scene').splitlines()
|
||||
copies = [i for i, line in enumerate(body) if 'vkp_render(w, h, dl.d, dl.n)' in line]
|
||||
self.assertGreaterEqual(len(copies), 4)
|
||||
for i in copies:
|
||||
self.assertTrue(any('settle_unwaited();' in line for line in body[max(0, i - 3):i]), body[i])
|
||||
text = '\n'.join(body)
|
||||
self.assertIn('if (hdr_route == 1 || hdr_route == 2) settle_unwaited();', text)
|
||||
self.assertIn('settle_unwaited();\n render_stream();', text)
|
||||
self.assertIn('if (r == 0 && !fg_pass) g_zero_copy_shown = ls;\n else settle_unwaited();', text)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
@@ -670,10 +670,7 @@ class InputUdevPreloadTest(unittest.TestCase):
|
||||
])
|
||||
|
||||
def test_no_device_call_on_a_pad_reaches_the_real_libudev(self):
|
||||
for extra in ({}, {"FAKE_EVDEV_STEAM_VIRTUAL": "1"}):
|
||||
with self.subTest(**extra):
|
||||
self.assertEqual(self.run_program("every", args=DEVICE_FUNCTIONS, extra=extra),
|
||||
["pad 1 real calls 0"])
|
||||
self.assertEqual(self.run_program("every", args=DEVICE_FUNCTIONS), ["pad 1 real calls 0"])
|
||||
|
||||
def test_a_handle_keeps_its_strings_after_the_pad_goes_away(self):
|
||||
self.assertEqual(self.run_program("stable", pads=self.pad_dir("stable", "event0")), [
|
||||
@@ -710,15 +707,36 @@ class InputUdevPreloadTest(unittest.TestCase):
|
||||
def identity(self, pads=None, **extra):
|
||||
return self.run_program("identity", pads=pads, extra=extra)
|
||||
|
||||
def test_a_ring_pad_keeps_the_steam_input_identity_whatever_sdl_is_told(self):
|
||||
steam = ["pad PRODUCT=6/28de/11ff/110", "parent PRODUCT=6/28de/11ff/110"]
|
||||
for extra in ({}, {"FAKE_EVDEV_UINPUT": "1"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "0"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "1"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142,0x045E/0x028E"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x045e/0x028e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x28de/0x11ff"},
|
||||
@classmethod
|
||||
def id_list(cls, name, text):
|
||||
path = cls.dir / name
|
||||
path.write_text(text)
|
||||
return "@" + str(path)
|
||||
|
||||
def test_a_pad_wine_also_reads_through_sdl_is_described_as_the_pad_sdl_sees(self):
|
||||
xbox = ["pad PRODUCT=3/45e/28e/110", "parent PRODUCT=3/45e/28e/110"]
|
||||
for extra in ({}, {"FAKE_EVDEV_UINPUT": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x045e/0x028e"}, {"FAKE_EVDEV_STEAM_VIRTUAL": "0"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-other.txt", "0x28de/0x1142\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "@" + str(self.dir / "missing.txt")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-ring.txt", "0x045E/0x028E\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x45e/0x28e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": ""},
|
||||
{"FAKE_EVDEV_UINPUT": "1", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"}):
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028f"}):
|
||||
with self.subTest(**extra):
|
||||
self.assertEqual(self.identity(**extra), xbox)
|
||||
|
||||
def test_a_pad_sdl_skips_keeps_the_steam_input_identity(self):
|
||||
steam = ["pad PRODUCT=6/28de/11ff/110", "parent PRODUCT=6/28de/11ff/110"]
|
||||
for extra in ({"FAKE_EVDEV_STEAM_VIRTUAL": "1"}, {"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x28de/0x1142,0x045E/0x028E"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "0x28de/0x11ff"},
|
||||
{"FAKE_EVDEV_UINPUT": "1", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-ring.txt", "0x28de/0x1142\n0x045e/0x028e\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": self.id_list("except-other.txt", "0x28de/0x11ff\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": self.id_list("ignore-long.txt", "0x28de/0x1142\n" * 400 + "0x045e/0x028e\n")},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x45e/0x28e"},
|
||||
{"SDL_GAMECONTROLLER_IGNORE_DEVICES_EXCEPT": "", "SDL_GAMECONTROLLER_IGNORE_DEVICES": "0x045e/0x028e"}):
|
||||
with self.subTest(**extra):
|
||||
self.assertEqual(self.identity(**extra), steam)
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ def rows(columns, *values):
|
||||
return [dict(zip(names, value)) for value in values]
|
||||
|
||||
|
||||
def installer(tables, out="/tmp/unused", summary=None):
|
||||
return MSI["Installer"]("fake.msi", out, FakePackage(tables, summary))
|
||||
def installer(tables, out="/tmp/unused", summary=None, native=()):
|
||||
return MSI["Installer"]("fake.msi", out, FakePackage(tables, summary), native=native)
|
||||
|
||||
|
||||
class ChoosePackagesTest(unittest.TestCase):
|
||||
@@ -174,6 +174,40 @@ class LayoutTest(unittest.TestCase):
|
||||
inst.select()
|
||||
self.assertEqual(inst.included_components, {"Up", "Wide"})
|
||||
|
||||
def downlevel_shim(self, native, directory="SysShim", key="ShimDll", condition="VersionNT < 600"):
|
||||
inst = installer({
|
||||
"Directory": rows("Directory Directory_Parent DefaultDir",
|
||||
("TARGETDIR", "", "SourceDir"),
|
||||
("ProgramFilesFolder", "TARGETDIR", "PFiles"),
|
||||
("AppDir", "ProgramFilesFolder", "App"),
|
||||
("SysShim", "TARGETDIR", "Win")),
|
||||
"CustomAction": rows("Action Type Source Target", ("SetSys", "51", "SysShim", "[SystemFolder]")),
|
||||
"InstallExecuteSequence": rows("Action Condition Sequence", ("SetSys", "", "1")),
|
||||
"Feature": rows("Feature Feature_Parent Level", ("Main", "", "1")),
|
||||
"Component": rows("Component Directory_ Attributes Condition KeyPath",
|
||||
("Shim", directory, "0", condition, key),
|
||||
("Old", "SysShim", "0", "VersionNT < 600", "OldDll"),
|
||||
("Vista", "SysShim", "0", "VersionNT = 600", "VistaDll")),
|
||||
"FeatureComponents": rows("Feature_ Component_", ("Main", "Shim"), ("Main", "Old"), ("Main", "Vista")),
|
||||
"File": rows("File Component_ FileName", ("ShimDll", "Shim", "MSCOREE.DLL|mscoree.dll"),
|
||||
("OldDll", "Old", "dxva2.dll"), ("VistaDll", "Vista", "mscoree.dll")),
|
||||
}, native=native)
|
||||
inst.run_set_actions()
|
||||
inst.select()
|
||||
return inst.included_components
|
||||
|
||||
def test_a_native_override_keeps_a_system_file_newer_windows_ships_itself(self):
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"]), {"Shim"})
|
||||
|
||||
def test_without_a_native_override_os_version_conditions_still_apply(self):
|
||||
self.assertEqual(self.downlevel_shim([]), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscorwks"]), set())
|
||||
|
||||
def test_only_system_folders_and_downlevel_conditions_are_relaxed(self):
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], directory="AppDir"), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], condition="VersionNT = 600"), set())
|
||||
self.assertEqual(self.downlevel_shim(["mscoree"], condition="VersionNT < 600 AND VersionNT64"), {"Shim"})
|
||||
|
||||
def architecture_package(self, platform, key="SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", name="PROCESSOR_ARCHITECTURE"):
|
||||
return installer({
|
||||
"Feature": rows("Feature Feature_Parent Level", ("Main", "", "1")),
|
||||
|
||||
@@ -120,14 +120,6 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
script.parent.mkdir(exist_ok=True)
|
||||
script.write_text(f"#!{interpreter}\n")
|
||||
script.chmod(0o755)
|
||||
cls.app_files = tmp / "app-files"
|
||||
cls.app_files.mkdir()
|
||||
shutil.copy(cls.probe, cls.app_files / "tool")
|
||||
shutil.copy(cls.android / "sh", cls.app_files / "android-tool")
|
||||
for name, interpreter in (("guest.py", GUEST_TOOL), ("android.sh", f"{ANDROID_DIR}/sh")):
|
||||
(cls.app_files / name).write_text(f"#!{interpreter}\n")
|
||||
for entry in cls.app_files.iterdir():
|
||||
entry.chmod(0o755)
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -228,32 +220,6 @@ class NativeHookLdsoSpawnTest(unittest.TestCase):
|
||||
call = self.call(how, "/opt/host.sh", "x", binds=f"{self.runtime}:{BOUND_DIR}")
|
||||
self.assertEqual([HOST_SHELL, HOST_SHELL, str(self.root / "opt/host.sh"), "x"], call)
|
||||
|
||||
def test_a_script_on_a_mount_at_its_host_path_runs_with_the_guest_interpreter(self):
|
||||
script = str(self.app_files / "guest.py")
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, script, "x", binds=f"{self.app_files}:{self.app_files}")
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([str(self.root / GUEST_TOOL.lstrip("/")), script, "x"], call[-3:])
|
||||
|
||||
def test_a_glibc_program_on_a_mount_at_its_host_path_starts_through_the_guest_ldso(self):
|
||||
tool = str(self.app_files / "tool")
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
call = self.call(how, tool, "x", binds=f"{self.app_files}:{self.app_files}")
|
||||
self.assertEqual(str(self.root / GUEST_LDSO.lstrip("/")), call[0])
|
||||
self.assertEqual([tool, "x"], call[-2:])
|
||||
|
||||
def test_android_programs_on_a_mount_at_its_host_path_stay_on_the_host(self):
|
||||
tool = str(self.app_files / "android-tool")
|
||||
script = str(self.app_files / "android.sh")
|
||||
sh = str(self.android / "sh")
|
||||
binds = f"{self.app_files}:{self.app_files}|{self.android}:{ANDROID_DIR}"
|
||||
for how in ("exec", "spawn"):
|
||||
with self.subTest(how=how):
|
||||
self.assertEqual([tool, tool, "x"], self.call(how, tool, "x", binds=binds))
|
||||
self.assertEqual([sh, sh, script, "x"], self.call(how, script, "x", binds=binds))
|
||||
|
||||
def test_an_android_interpreter_reached_through_a_bind_stays_on_the_host(self):
|
||||
sh = str(self.android / "sh")
|
||||
for how in ("exec", "spawn"):
|
||||
|
||||
@@ -1,125 +0,0 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
PRELOAD = Path(__file__).resolve().parents[1] / "linuxfs/preload"
|
||||
|
||||
SHIM = r"""
|
||||
#include <linux/input.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
int ioctl(int fd, unsigned long request, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
struct input_id *id = va_arg(ap, struct input_id *);
|
||||
va_end(ap);
|
||||
(void)fd;
|
||||
if (request != EVIOCGID) return -1;
|
||||
memset(id, 0, sizeof(*id));
|
||||
id->bustype = 3;
|
||||
id->vendor = 0x045e;
|
||||
id->product = 0x028e;
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
QUERY = r"""
|
||||
#include <fcntl.h>
|
||||
#include <linux/input.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
void query(const char *path) {
|
||||
struct input_id id;
|
||||
int fd = open(path, O_RDONLY | O_CLOEXEC);
|
||||
int rc = ioctl(fd, EVIOCGID, &id);
|
||||
printf("%d %04x:%04x\n", rc, id.vendor, id.product);
|
||||
close(fd);
|
||||
}
|
||||
"""
|
||||
|
||||
PROGRAM = r"""
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void query(const char *path);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
(void)argc;
|
||||
if (strcmp(argv[1], "-") != 0) dlopen(argv[1], RTLD_NOW);
|
||||
if (strcmp(argv[2], "program") == 0) {
|
||||
query(argv[3]);
|
||||
} else {
|
||||
void *sdl = dlopen(argv[2], RTLD_NOW | RTLD_LOCAL);
|
||||
void (*sdl_query)(const char *) = (void (*)(const char *))dlsym(sdl, "query");
|
||||
sdl_query(argv[3]);
|
||||
}
|
||||
fflush(stdout);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
@unittest.skipUnless(sys.platform == "linux" and shutil.which("cc"), "needs Linux and cc")
|
||||
class RingPadSdlIdentityTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.dir = Path(tempfile.mkdtemp())
|
||||
build = cls.dir / "build"
|
||||
build.mkdir()
|
||||
for name, text in (("shim.c", SHIM), ("query.c", QUERY), ("program.c", PROGRAM), ("empty.c", "int bus;\n")):
|
||||
(build / name).write_text(text)
|
||||
cls.lib = cls.dir / "libddsession.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-Wall", "-pthread", "-o", str(cls.lib),
|
||||
*map(str, sorted(PRELOAD.glob("*.c"))), "-ldl"], check=True)
|
||||
cls.shim = cls.dir / "libshim.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.shim), str(build / "shim.c")], check=True)
|
||||
cls.winebus = cls.dir / "winebus.so"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.winebus), str(build / "empty.c")], check=True)
|
||||
cls.sdl_library = cls.dir / "libSDL2-2.0.so.0"
|
||||
subprocess.run(["cc", "-shared", "-fPIC", "-O2", "-o", str(cls.sdl_library), str(build / "query.c")], check=True)
|
||||
cls.program = cls.dir / "program"
|
||||
subprocess.run(["cc", "-O2", "-o", str(cls.program), str(build / "program.c"), str(build / "query.c"), "-ldl"],
|
||||
check=True)
|
||||
cls.ring = cls.dir / "ring0"
|
||||
cls.ring.write_text("")
|
||||
cls.virtual = cls.dir / "ring16"
|
||||
cls.virtual.write_text("")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
shutil.rmtree(cls.dir, True)
|
||||
|
||||
def query(self, winebus=True, caller="sdl", path=None, **extra):
|
||||
env = dict(os.environ, LD_PRELOAD="%s:%s" % (self.lib, self.shim),
|
||||
FAKE_EVDEV_MEMFD_PATHS="0=%s;16=%s" % (self.ring, self.virtual))
|
||||
env.pop("FAKE_EVDEV_STEAM_PAD_AS_X360", None)
|
||||
env.update(extra)
|
||||
result = subprocess.run([str(self.program), str(self.winebus) if winebus else "-",
|
||||
str(self.sdl_library) if caller == "sdl" else "program", str(path or self.ring)],
|
||||
env=env, capture_output=True, text=True, timeout=10, check=True)
|
||||
return result.stdout.strip()
|
||||
|
||||
def test_sdl_in_a_winebus_process_sees_a_ring_pad_as_the_steam_input_pad(self):
|
||||
self.assertEqual(self.query(), "0 28de:11ff")
|
||||
|
||||
def test_sdl_outside_winebus_keeps_the_pad_identity(self):
|
||||
self.assertEqual(self.query(winebus=False), "0 045e:028e")
|
||||
|
||||
def test_other_callers_and_devices_keep_their_identity(self):
|
||||
self.assertEqual(self.query(caller="program"), "0 045e:028e")
|
||||
self.assertEqual(self.query(path=self.virtual), "0 045e:028e")
|
||||
|
||||
def test_a_winebus_without_a_udev_bus_keeps_the_pad_for_sdl(self):
|
||||
self.assertEqual(self.query(FAKE_EVDEV_STEAM_PAD_AS_X360="1"), "0 045e:028e")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -95,7 +95,7 @@ class SubsurfaceReleaseTest(unittest.TestCase):
|
||||
|
||||
def test_compositor_attach_and_commit_use_the_release_hold(self):
|
||||
self.assertIn('pending_releases_cancel(buffer);', function_body(self.source, 'take_dmabuf'))
|
||||
commit = function_body(self.source, 'surface_state_apply')
|
||||
commit = function_body(self.source, 'surface_commit')
|
||||
self.assertIn('pending_releases_apply(s);', commit)
|
||||
self.assertLess(commit.index('take_dmabuf(s, db, buffer);'), commit.index('pending_releases_apply(s);'))
|
||||
self.assertLess(commit.index('buf_trace_attach(buffer);'), commit.index('if (s->role == ROLE_CURSOR)'))
|
||||
|
||||
@@ -19,6 +19,7 @@ class WinComponentsTest(unittest.TestCase):
|
||||
self.compat = root / "compatdata/2571976725"
|
||||
self.selection = root / "wincomponents.json"
|
||||
self.pfx = self.compat / "pfx/drive_c/windows"
|
||||
self.mono_proton = root / "mono-proton"
|
||||
|
||||
def tearDown(self):
|
||||
self.tmp.cleanup()
|
||||
@@ -35,8 +36,12 @@ class WinComponentsTest(unittest.TestCase):
|
||||
def pick(self, *ids):
|
||||
self.selection.write_text(json.dumps({"version": 1, "games": {"2571976725": list(ids)}}))
|
||||
|
||||
def mono(self, *names, home="files/share/wine/mono/wine-mono"):
|
||||
for name in names:
|
||||
(self.mono_proton / home / "lib/mono/gac" / name / "4.0.0.0__b77a5c561934e089").mkdir(parents=True)
|
||||
|
||||
def apply(self, proton=None, env=None):
|
||||
return MODULE["apply"](self.compat, "2571976725", self.selection, self.store, proton=proton, env=env)
|
||||
return MODULE["apply"](self.compat, "2571976725", self.selection, self.store, proton=proton or self.mono_proton / "proton", env=env)
|
||||
|
||||
def proton(self, arm=True):
|
||||
root = Path(self.tmp.name) / ("arm-proton" if arm else "x64-proton")
|
||||
@@ -455,6 +460,24 @@ class WinComponentsTest(unittest.TestCase):
|
||||
self.assertEqual(GAME_ENV["win_components"](str(self.compat) + "/", "2571976725"), "openal32=n,b")
|
||||
self.assertEqual(GAME_ENV["win_components"]("", "2571976725"), "")
|
||||
|
||||
def test_game_env_hands_proton_to_the_mono_check(self):
|
||||
self.component("framework", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4/System.dll": b"system",
|
||||
})
|
||||
self.mono("System")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("framework")
|
||||
globals_ = GAME_ENV["win_components"].__globals__
|
||||
real = runpy.run_path(str(BIN / "droiddeck-wincomponents"))
|
||||
real["apply"].__defaults__ = (self.selection, self.store, self.selection.parent / "no-pending.json", None, None, None)
|
||||
with mock.patch.dict(globals_, {"runpy": mock.Mock(run_path=lambda _path: real)}):
|
||||
self.assertEqual(GAME_ENV["win_components"](str(self.compat), "2571976725", str(self.mono_proton / "proton")),
|
||||
"mscoree=n,b")
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
self.assertEqual(registry.get("Software\\Wine\\Mono\\AsmOverrides", "System"), '"System"="Gac=n"')
|
||||
|
||||
def test_bundle_brings_its_parts_and_catalog_names_with_dots_work(self):
|
||||
self.component("dmband", ["dmband"], {"syswow64/dmband.dll": b"band"})
|
||||
self.component("dsound", ["dsound=n"], {"syswow64/dsound.dll": b"ds"})
|
||||
@@ -499,6 +522,153 @@ class WinComponentsTest(unittest.TestCase):
|
||||
self.assertEqual(MODULE["overrides_value"](names), "mscoree=n,b")
|
||||
self.assertIn("mscoree=n has no native DLL in the prefix; using n,b", notes)
|
||||
|
||||
def test_framework_gac_component_disables_windows_gac_for_mono(self):
|
||||
self.component("dotnet48", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll": b"system",
|
||||
})
|
||||
self.mono("System")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("dotnet48")
|
||||
self.apply()
|
||||
self.assertIn(
|
||||
'"System"="Gac=n"',
|
||||
user.read_text(),
|
||||
)
|
||||
self.pick()
|
||||
self.apply()
|
||||
self.assertNotIn('"System"="Gac=n"', user.read_text())
|
||||
|
||||
def test_msi_clr2_and_unsuffixed_gac_assemblies_disable_windows_gac_for_mono(self):
|
||||
self.component("dotnet", ["mscoree=n"], {
|
||||
"drive_c/windows/assembly/GAC_MSIL/System/v2.0.0.0__b77a5c561934e089/System.dll": b"system",
|
||||
"drive_c/windows/assembly/GAC/Legacy/v1.0.0.0__1234567890abcdef/Legacy.dll": b"legacy",
|
||||
})
|
||||
self.mono("System", "Legacy", home="dist/share/wine/mono/wine-mono-7.4.0")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("dotnet")
|
||||
self.apply()
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
key = "Software\\Wine\\Mono\\AsmOverrides"
|
||||
self.assertEqual(registry.get(key, "System"), '"System"="Gac=n"')
|
||||
self.assertEqual(registry.get(key, "Legacy"), '"Legacy"="Gac=n"')
|
||||
|
||||
def test_framework_gac_override_keeps_other_assemblies_and_explicit_component_values(self):
|
||||
self.component("framework", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4/System.dll": b"system",
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System.Core/v4/System.Core.dll": b"core",
|
||||
})
|
||||
self.mono("System", "System.Core")
|
||||
key = "Software\\Wine\\Mono\\AsmOverrides"
|
||||
(self.store / "framework/registry.json").write_text(json.dumps({"values": [
|
||||
{"hive": "HKCU", "key": key, "name": "System", "type": "sz", "data": "Gac=y"},
|
||||
]}))
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
original = ('WINE REGISTRY Version 2\n\n' + MODULE["reg_key_line"](key)
|
||||
+ ' 1\n"*"="Gac=y"\n"Microsoft.Xna.Framework"="Gac=y"\n')
|
||||
user.write_text(original)
|
||||
self.pick("framework")
|
||||
names, _ = self.apply()
|
||||
self.assertEqual(names, ["mscoree=n,b"])
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
self.assertEqual(registry.get(key, "System"), '\"System\"=\"Gac=y\"')
|
||||
self.assertEqual(registry.get(key, "System.Core"), '\"System.Core\"=\"Gac=n\"')
|
||||
self.assertEqual(registry.get(key, "*"), '\"*\"=\"Gac=y\"')
|
||||
self.assertEqual(registry.get(key, "Microsoft.Xna.Framework"),
|
||||
'\"Microsoft.Xna.Framework\"=\"Gac=y\"')
|
||||
self.pick()
|
||||
self.apply()
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
self.assertIsNone(registry.get(key, "System"))
|
||||
self.assertIsNone(registry.get(key, "System.Core"))
|
||||
self.assertEqual(registry.get(key, "*"), '\"*\"=\"Gac=y\"')
|
||||
|
||||
def test_explicit_registry_value_in_earlier_component_wins_over_later_generated_gac_override(self):
|
||||
key = "Software\\Wine\\Mono\\AsmOverrides"
|
||||
self.component("first", [], {})
|
||||
(self.store / "first/registry.json").write_text(json.dumps({"values": [
|
||||
{"hive": "HKCU", "key": key, "name": "System", "type": "sz", "data": "Gac=y"},
|
||||
]}))
|
||||
self.component("second", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4/System.dll": b"system",
|
||||
})
|
||||
self.mono("System")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("first", "second")
|
||||
self.apply()
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
self.assertEqual(registry.get(key, "System"), '"System"="Gac=y"')
|
||||
|
||||
def test_unselected_framework_and_non_framework_components_do_not_change_mono(self):
|
||||
gac = "drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4/System.dll"
|
||||
self.component("framework", ["mscoree=n"], {gac: b"system"})
|
||||
self.component("other", ["other=n"], {gac: b"other"})
|
||||
self.mono("System")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
original = "WINE REGISTRY Version 2\n"
|
||||
user.write_text(original)
|
||||
self.pick("other")
|
||||
self.apply()
|
||||
self.assertEqual(user.read_text(), original)
|
||||
self.pick()
|
||||
self.apply()
|
||||
self.assertEqual(user.read_text(), original)
|
||||
|
||||
def test_gac_assemblies_missing_from_mono_keep_the_windows_gac(self):
|
||||
self.component("framework", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll": b"system",
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/Vendor.Engine/v4.0_1.0.0.0__0123456789abcdef/Vendor.Engine.dll": b"vendor",
|
||||
"drive_c/windows/assembly/GAC/stdole/7.0.3300.0__b03f5f7f11d50a3a/stdole.dll": b"stdole",
|
||||
})
|
||||
self.mono("System")
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("framework")
|
||||
self.apply()
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
key = "Software\\Wine\\Mono\\AsmOverrides"
|
||||
self.assertEqual(registry.get(key, "System"), '"System"="Gac=n"')
|
||||
self.assertIsNone(registry.get(key, "Vendor.Engine"))
|
||||
self.assertIsNone(registry.get(key, "stdole"))
|
||||
|
||||
def test_no_mono_runtime_found_leaves_mono_settings_alone(self):
|
||||
self.component("framework", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll": b"system",
|
||||
})
|
||||
(self.mono_proton / "files/share/wine/mono/wine-mono/lib/mono/gac").mkdir(parents=True)
|
||||
self.pfx.parent.mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
original = "WINE REGISTRY Version 2\n"
|
||||
user.write_text(original)
|
||||
self.pick("framework")
|
||||
names, _ = self.apply()
|
||||
self.assertEqual(names, ["mscoree=n,b"])
|
||||
self.assertEqual(user.read_text(), original)
|
||||
|
||||
def test_a_prefix_mono_install_is_used_before_protons(self):
|
||||
self.component("framework", ["mscoree=n"], {
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System/v4/System.dll": b"system",
|
||||
"drive_c/windows/Microsoft.NET/assembly/GAC_MSIL/System.Core/v4/System.Core.dll": b"core",
|
||||
})
|
||||
self.mono("System", "System.Core")
|
||||
(self.pfx / "Mono/mono-2.0/lib/mono/gac/System/4.0.0.0__b77a5c561934e089").mkdir(parents=True)
|
||||
user = self.compat / "pfx/user.reg"
|
||||
user.write_text("WINE REGISTRY Version 2\n")
|
||||
self.pick("framework")
|
||||
self.apply()
|
||||
registry = MODULE["RegistryFile"](user)
|
||||
key = "Software\\Wine\\Mono\\AsmOverrides"
|
||||
self.assertEqual(registry.get(key, "System"), '"System"="Gac=n"')
|
||||
self.assertIsNone(registry.get(key, "System.Core"))
|
||||
|
||||
def test_a_wine_placeholder_file_is_not_a_native_dll(self):
|
||||
self.component("dotnet48", ["mscoree=n"], {})
|
||||
for arch in ("system32", "syswow64"):
|
||||
|
||||
Reference in new issue
Block a user