Compare commits

..
Author SHA1 Message Date
The412Banner cfe07b0848 fix(ea): Steam copies of EA games get the CPUID of their own exe's bitness
Merges main, keeping the steam request key from #3021 in prepare_ea.
prepare_steam_ea now puts the game exe in the sidecar it passes to
prepare_ea, so ea_game_hardware sends the 64-bit CPUID for a 64-bit game.
2026-11-27 18:33:17 +00:00
The412Banner 6346b5ebdf fix(ea): retake the hardware probe when its 64-bit CPUID run fails 2026-11-22 15:29:17 +00:00
The412Banner 2702ba2db8 fix(ea): bind activation licences to the CPUID of the game's own bitness
The machine hash of activation versions 2 and 3 includes CPUID leaf 1 ECX,
and FEX reports AVX to 64-bit (ARM64EC) processes but not to 32-bit (WOW64)
ones. The hardware probe only ran a 32-bit CPUID program, so 64-bit games
rejected their licence and looped through ActivationUI. The probe now runs
CPUID in both bitnesses, the game gets the values its exe sees, and the
cache is retaken when the Proton or FEX build changes.
2026-11-22 14:39:35 +00:00
74 changed files with 417 additions and 1055 deletions

No files matched your search

@@ -133,24 +133,6 @@ static void objects_destroy(void) {
g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE;
}
void blendp_destroy(void) {
if (g_dev) {
for (int i = 0; i < NSRC; i++) src_release(i);
for (int i = 0; i < NDST; i++) dst_release(i);
for (int i = 0; i < NFMT; i++) {
if (g_out[i].pipe) g_vk.DestroyPipeline(g_dev, g_out[i].pipe, NULL);
if (g_out[i].rp) g_vk.DestroyRenderPass(g_dev, g_out[i].rp, NULL);
}
objects_destroy();
}
memset(g_src, 0, sizeof(g_src));
memset(g_dst, 0, sizeof(g_dst));
memset(g_out, 0, sizeof(g_out));
g_ready = 0;
g_frame = 1;
g_dev = VK_NULL_HANDLE;
}
static int objects_ensure(void) {
if (g_ready) return g_ready == 1 ? 0 : -1;
g_ready = -1;
@@ -4,7 +4,6 @@
#include <vulkan/vulkan.h>
void blendp_bind_device(VkDevice dev);
void blendp_destroy(void);
void blendp_forget_image(VkImage img);
void blendp_begin_frame(void);
@@ -311,16 +311,6 @@ static void objects_destroy(void) {
g_dsl = VK_NULL_HANDLE; g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE;
}
void vkp_cardboard_destroy(void) {
if (g_dev) objects_destroy();
g_dev = VK_NULL_HANDLE;
g_ready = 0;
memset(&g_t, 0, sizeof(g_t));
memset(g_src, 0, sizeof(g_src));
g_nsrc = 0;
memset(&g_mp, 0, sizeof(g_mp));
}
static int objects_ensure(void) {
if (g_ready) return g_ready == 1 ? 0 : -1;
if (!g_dev || !g_vk.CreateGraphicsPipelines) goto fail;
@@ -26,7 +26,6 @@ void vkp_cardboard_set_pose_file(const char *path);
void vkp_cardboard_set_render_height(int height);
void vkp_cardboard_bind_device(VkDevice dev, const VkPhysicalDeviceMemoryProperties *memprops);
void vkp_cardboard_destroy(void);
int vkp_cardboard_active(void);
int vkp_cardboard_source(void);
int vkp_cardboard_pose_changed(void);
@@ -194,31 +194,7 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable");
}
void vkp_framegen_device_lost(void) {
atomic_store(&g_dev_lost, 1);
atomic_store(&g_dev_ready, 0);
fge_device_lost();
if (g_dev) {
for (uint32_t i = 0; i < g_ring_n; i++) {
if (g_ring[i].view && vk.DestroyImageView) vk.DestroyImageView(g_dev, g_ring[i].view, NULL);
if (g_ring[i].img && vk.DestroyImage) vk.DestroyImage(g_dev, g_ring[i].img, NULL);
if (g_ring[i].mem && vk.FreeMemory) vk.FreeMemory(g_dev, g_ring[i].mem, NULL);
}
}
memset(g_ring, 0, sizeof(g_ring));
g_ring_n = g_ring_w = g_ring_h = 0;
g_ring_fmt = VK_FORMAT_UNDEFINED;
g_engine_ok = 0;
g_engine_kind = -1;
g_engine_cache_gen = -1;
g_built_w = g_built_h = 0;
g_built_fmt = VK_FORMAT_UNDEFINED;
g_planned = 0;
memset(&vk, 0, sizeof(vk));
g_dev = VK_NULL_HANDLE;
g_queue = VK_NULL_HANDLE;
g_qfam = 0;
}
void vkp_framegen_device_lost(void) { atomic_store(&g_dev_lost, 1); }
static void destroy_ring(void) {
@@ -126,23 +126,6 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
(int)g_caps.storageOnSwapchainFormat);
}
void fge_device_lost(void) {
g_lsfg.reset();
g_ddfg.reset();
g_kind = -1;
g_dev = VK_NULL_HANDLE;
g_queue = VK_NULL_HANDLE;
g_pd = VK_NULL_HANDLE;
g_qfam = 0;
g_ready = false;
g_probed = false;
g_table = {};
g_caps = {};
g_v12 = {};
g_f2 = {};
g_build[0] = 0;
}
int fge_caps_ok(int kind) {
if (!g_ready) return 0;
if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0;
@@ -12,7 +12,6 @@ extern "C" {
const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
VkFormat ring_fmt);
void fge_device_lost(void);
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
int fge_caps_ok(int kind);
@@ -9,7 +9,6 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled) {
(void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled;
}
void fge_device_lost(void) {}
int fge_caps_ok(int kind) { (void)kind; return 0; }
const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; }
int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; }
@@ -73,19 +73,8 @@ void vkp_gpu_busy_device(VkPhysicalDevice pd, VkDevice dev, uint32_t family) {
}
void vkp_gpu_busy_device_lost(void) {
pthread_mutex_lock(&g_lock);
atomic_store(&g_lost, 1);
atomic_store(&g_timing, 0);
if (g_v.device) {
gpuload_ring_release(&g_ring, &g_v);
g_ring.state = 0;
}
if (g_vk.QueueSubmit == timed_submit && g_submit) g_vk.QueueSubmit = g_submit;
g_submit = NULL;
memset(&g_v, 0, sizeof(g_v));
g_family = g_bits = 0;
g_was_on = 0;
pthread_mutex_unlock(&g_lock);
}
JNIEXPORT jlong JNICALL Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeGpuBusyNs(JNIEnv *env, jclass cls) {
+3 -3
View File
@@ -15,9 +15,9 @@
X(GetPhysicalDeviceImageFormatProperties2) X(GetPhysicalDeviceProperties2)
#define VK_DEVICE_FUNCS(X) \
X(DestroyDevice) X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \
X(CreateCommandPool) X(DestroyCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \
X(DeviceWaitIdle) X(DestroyFence) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \
X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \
X(CreateCommandPool) X(AllocateCommandBuffers) X(CreateSemaphore) X(CreateFence) \
X(DeviceWaitIdle) X(CreateImage) X(GetImageMemoryRequirements) X(AllocateMemory) \
X(BindImageMemory) X(DestroyImage) X(FreeMemory) X(AcquireNextImageKHR) \
X(ResetCommandBuffer) X(BeginCommandBuffer) X(CmdPipelineBarrier) X(CmdBlitImage) \
X(EndCommandBuffer) X(ResetFences) X(QueueSubmit) X(QueuePresentKHR) X(WaitForFences) \
+18 -319
View File
@@ -31,15 +31,6 @@
#define LOGE(...) droiddeck_log("error", __VA_ARGS__)
#define MOD_INVALID VKP_MOD_INVALID
enum vkp_image_source {
VKP_IMAGE_SOURCE_NONE = 0,
VKP_IMAGE_SOURCE_DMABUF,
VKP_IMAGE_SOURCE_AHB_WLEGL,
VKP_IMAGE_SOURCE_AHB_SOURCE,
VKP_IMAGE_SOURCE_AHB_TARGET,
VKP_IMAGE_SOURCE_SHM
};
struct vkp_image {
VkImage image;
VkDeviceMemory mem;
@@ -56,61 +47,14 @@ struct vkp_image {
VkBuffer linear_buf;
VkDeviceMemory linear_mem;
VkBufferImageCopy linear_copy;
enum vkp_image_source source_type;
int source_fd;
uint32_t source_drm_format, source_stride, source_offset;
uint64_t source_modifier;
uint8_t *recovery_pixels;
struct vkp_image *next;
};
static struct vkp_image *g_client_images;
static struct vkp_image *g_rb;
static int g_recovery_attempted;
static void image_register(struct vkp_image *img) {
if (!img) return;
img->next = g_client_images;
g_client_images = img;
}
static void image_unregister(struct vkp_image *img) {
struct vkp_image **p = &g_client_images;
while (*p && *p != img) p = &(*p)->next;
if (*p) *p = img->next;
if (img) img->next = NULL;
}
static void image_track_dmabuf(struct vkp_image *img, int fd, uint32_t drm_format,
uint64_t modifier, uint32_t stride, uint32_t offset) {
img->source_fd = dup(fd);
img->source_type = img->source_fd >= 0 ? VKP_IMAGE_SOURCE_DMABUF : VKP_IMAGE_SOURCE_NONE;
img->source_drm_format = drm_format;
img->source_modifier = modifier;
img->source_stride = stride;
img->source_offset = offset;
image_register(img);
if (img->source_type == VKP_IMAGE_SOURCE_NONE)
droiddeck_log("gpu", "device recovery unavailable for one DMA-BUF: source FD could not be retained");
}
static void image_track_ahb(struct vkp_image *img, AHardwareBuffer *buffer,
enum vkp_image_source source_type) {
AHardwareBuffer_acquire(buffer);
img->android_buffer = buffer;
img->source_type = source_type;
image_register(img);
}
static void destroy_image_objects(struct vkp_image *img);
static ANativeWindow *g_window;
static int g_ahb_import;
static int g_drm_modifiers;
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
static int g_allow_driver_fallback;
static int g_dev_state;
static int dev_init(void);
static void device_lost(const char *where);
static const char *vk_result_name(VkResult r);
@@ -544,26 +488,6 @@ static int has_ext(VkExtensionProperties *e, uint32_t n, const char *name) {
return 0;
}
static VkResult create_device(const VkDeviceCreateInfo *dci, VkDeviceQueueCreateInfo *qci, int *high_priority) {
VkDeviceQueueGlobalPriorityCreateInfoEXT gp = {
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT,
.globalPriority = VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT};
qci->pNext = *high_priority ? &gp : NULL;
VkResult dr = g_vk.CreateDevice(g_pd, dci, NULL, &g_dev);
if (dr != VK_SUCCESS && *high_priority) {
qci->pNext = NULL;
const VkResult plain = g_vk.CreateDevice(g_pd, dci, NULL, &g_dev);
if (plain == VK_SUCCESS) {
droiddeck_log("gpu", "the driver refused a high-priority compositor queue (%s); using the default priority",
vk_result_name(dr));
*high_priority = 0;
}
dr = plain;
}
qci->pNext = NULL;
return dr;
}
static int is_proprietary(VkDriverId id) {
return id == VK_DRIVER_ID_ARM_PROPRIETARY || id == VK_DRIVER_ID_QUALCOMM_PROPRIETARY ||
id == VK_DRIVER_ID_IMAGINATION_PROPRIETARY || id == VK_DRIVER_ID_SAMSUNG_PROPRIETARY ||
@@ -594,7 +518,7 @@ static void log_display_driver(void) {
g_library_name);
}
static int dev_init_once(void) {
static int dev_init(void) {
if (g_dev_state != 0) return g_dev_state == 1 ? 0 : -1;
if (vk_loader_open(g_driver_path, g_library_name, g_native_lib_dir) != 0) {
@@ -685,7 +609,7 @@ static int dev_init_once(void) {
static const char *const import_exts[4] = {"VK_KHR_external_memory_fd", "VK_EXT_external_memory_dma_buf",
"VK_EXT_image_drm_format_modifier", "VK_KHR_image_format_list"};
const char *dev_exts[10] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
const char *dev_exts[9] = {VK_KHR_SWAPCHAIN_EXTENSION_NAME};
uint32_t n_dev_exts = 1;
uint32_t ne = 0;
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, NULL);
@@ -726,11 +650,6 @@ static int dev_init_once(void) {
dev_exts[n_dev_exts++] = VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME;
dev_exts[n_dev_exts++] = VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME;
}
const char *priority_ext = has_ext(exts, ne, "VK_KHR_global_priority") ? "VK_KHR_global_priority"
: has_ext(exts, ne, VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME) ? VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME
: NULL;
if (priority_ext) dev_exts[n_dev_exts++] = priority_ext;
int high_priority = priority_ext != NULL;
free(exts);
float prio = 1.0f;
@@ -740,13 +659,13 @@ static int dev_init_once(void) {
VkDeviceCreateInfo dci = {.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO, .pNext = fg_features,
.queueCreateInfoCount = 1, .pQueueCreateInfos = &qci,
.enabledExtensionCount = n_dev_exts, .ppEnabledExtensionNames = dev_exts};
VkResult dr = create_device(&dci, &qci, &high_priority);
VkResult dr = g_vk.CreateDevice(g_pd, &dci, NULL, &g_dev);
if (dr != VK_SUCCESS && fg_features) {
droiddeck_log("framegen", "the driver refused the LSFG feature set (%s); device created without it",
vk_result_name(dr));
dci.pNext = NULL;
fg_features = NULL;
dr = create_device(&dci, &qci, &high_priority);
dr = g_vk.CreateDevice(g_pd, &dci, NULL, &g_dev);
}
if (dr != VK_SUCCESS) {
LOGE("present: vkCreateDevice failed"); g_dev_state = -1;
@@ -754,7 +673,6 @@ static int dev_init_once(void) {
return -1;
}
vk_loader_load_device(g_dev);
if (high_priority) droiddeck_log("gpu", "compositor queue runs at high GPU priority");
log_display_driver();
g_vk.GetDeviceQueue(g_dev, g_qfam, 0, &g_queue);
vkp_gpu_busy_device(g_pd, g_dev, g_qfam);
@@ -802,189 +720,6 @@ static int dev_init_once(void) {
return 0;
}
static void suspend_client_images(void) {
for (struct vkp_image *img = g_client_images; img; img = img->next) {
if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels)
img->source_type = VKP_IMAGE_SOURCE_NONE;
if (img->map && g_vk.UnmapMemory && g_dev) g_vk.UnmapMemory(g_dev, img->mem);
img->map = NULL;
destroy_image_objects(img);
}
}
static int restore_client_image(struct vkp_image *img) {
if (!img || img->source_type == VKP_IMAGE_SOURCE_NONE) return -1;
struct vkp_image *replacement = NULL;
switch (img->source_type) {
case VKP_IMAGE_SOURCE_DMABUF:
if (img->source_fd >= 0)
replacement = vkp_image_import_dmabuf(img->source_fd, img->source_drm_format, img->source_modifier,
img->w, img->h, img->source_stride, img->source_offset,
img->blit_dst);
break;
case VKP_IMAGE_SOURCE_AHB_WLEGL:
replacement = vkp_image_from_android_buffer(img->android_buffer);
break;
case VKP_IMAGE_SOURCE_AHB_SOURCE:
replacement = vkp_image_from_ahb(img->android_buffer);
break;
case VKP_IMAGE_SOURCE_AHB_TARGET:
replacement = vkp_image_import_ahb(img->android_buffer, NULL, 0);
break;
case VKP_IMAGE_SOURCE_SHM:
replacement = vkp_image_create_shm(img->w, img->h);
break;
default:
break;
}
if (!replacement) return -1;
struct vkp_image *next = img->next;
const enum vkp_image_source old_type = img->source_type;
const int old_fd = img->source_fd;
AHardwareBuffer *old_ahb = img->android_buffer;
uint8_t *pixels = img->recovery_pixels;
image_unregister(replacement);
*img = *replacement;
img->next = next;
free(replacement);
if (old_type == VKP_IMAGE_SOURCE_DMABUF && old_fd >= 0) close(old_fd);
if (old_ahb) AHardwareBuffer_release(old_ahb);
if (old_type == VKP_IMAGE_SOURCE_SHM && pixels && img->map) {
const size_t row_bytes = (size_t)img->w * 4;
for (int y = 0; y < img->h; y++)
memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch,
pixels + (size_t)y * row_bytes, row_bytes);
img->recovery_pixels = pixels;
pixels = NULL;
}
free(pixels);
return 0;
}
static int restore_client_images(void) {
int failed = 0;
for (struct vkp_image *img = g_client_images; img; ) {
struct vkp_image *next = img->next;
if (restore_client_image(img) != 0) {
failed++;
droiddeck_log("error", "GPU recovery: could not re-import a retained %dx%d client buffer",
img->w, img->h);
}
img = next;
}
return failed ? -1 : 0;
}
static void release_lost_device(void) {
vkp_pass_abort();
blendp_destroy();
vkp_effects_destroy();
hdrc_destroy();
vkp_cardboard_destroy();
vkp_framegen_device_lost();
vkp_gpu_busy_device_lost();
suspend_client_images();
if (g_rb) {
vkp_image_destroy(g_rb);
g_rb = NULL;
}
if (g_scene.img) g_vk.DestroyImage(g_dev, g_scene.img, NULL);
if (g_scene.mem) g_vk.FreeMemory(g_dev, g_scene.mem, NULL);
memset(&g_scene, 0, sizeof(g_scene));
struct vkp_img_slot *slots[] = {&g_mixed, &g_hdrscene, &g_fgscene};
for (size_t i = 0; i < sizeof(slots) / sizeof(slots[0]); i++) {
if (slots[i]->img) g_vk.DestroyImage(g_dev, slots[i]->img, NULL);
if (slots[i]->mem) g_vk.FreeMemory(g_dev, slots[i]->mem, NULL);
memset(slots[i], 0, sizeof(*slots[i]));
}
if (g_black_img) g_vk.DestroyImage(g_dev, g_black_img, NULL);
if (g_black_mem) g_vk.FreeMemory(g_dev, g_black_mem, NULL);
g_black_img = VK_NULL_HANDLE;
g_black_mem = VK_NULL_HANDLE;
g_black_state = 0;
for (int i = 0; i < MAX_PRESENTS; i++) {
if (g_acqs[i]) g_vk.DestroySemaphore(g_dev, g_acqs[i], NULL);
if (g_rnds[i]) g_vk.DestroySemaphore(g_dev, g_rnds[i], NULL);
g_acqs[i] = g_rnds[i] = VK_NULL_HANDLE;
}
if (g_wait_sem) g_vk.DestroySemaphore(g_dev, g_wait_sem, NULL);
g_wait_sem = VK_NULL_HANDLE;
if (g_fence) g_vk.DestroyFence(g_dev, g_fence, NULL);
g_fence = VK_NULL_HANDLE;
if (g_pool) g_vk.DestroyCommandPool(g_dev, g_pool, NULL);
g_pool = VK_NULL_HANDLE;
memset(g_cmds, 0, sizeof(g_cmds));
if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL);
g_swapchain = VK_NULL_HANDLE;
free(g_images);
g_images = NULL;
g_nimg = 0;
if (g_surface) g_vk.DestroySurfaceKHR(g_inst, g_surface, NULL);
g_surface = VK_NULL_HANDLE;
if (g_dev) g_vk.DestroyDevice(g_dev, NULL);
g_dev = VK_NULL_HANDLE;
if (g_inst) g_vk.DestroyInstance(g_inst, NULL);
g_inst = VK_NULL_HANDLE;
vk_loader_close();
g_pd = VK_NULL_HANDLE;
g_queue = VK_NULL_HANDLE;
g_qfam = 0;
memset(&g_memprops, 0, sizeof(g_memprops));
memset(&g_map, 0, sizeof(g_map));
memset(&g_extent, 0, sizeof(g_extent));
memset(&g_caps_extent, 0, sizeof(g_caps_extent));
g_surface_transform_known = 0;
g_surface_checked_ns = 0;
g_ahb_import = 0;
g_drm_modifiers = 0;
g_colorspace_ext = 0;
g_import_sem_fd = NULL;
g_ahb_properties = NULL;
g_set_hdr_metadata = NULL;
g_swap_extra = 0;
g_swap_is_hdr = 0;
g_swap_fmt = VK_FORMAT_UNDEFINED;
g_swap_md_identity = 0;
g_swap_retry_at_ns = 0;
g_swap_fail_logged = 0;
g_base_black = 0;
g_dev_state = 0;
}
static int dev_init(void) {
if (g_dev_state != -2) return dev_init_once();
if (g_recovery_attempted) return -1;
g_recovery_attempted = 1;
droiddeck_log("gpu", "VK_ERROR_DEVICE_LOST: attempting one in-process compositor recovery");
release_lost_device();
if (dev_init_once() != 0) {
if (g_dev_state == -3) {
droiddeck_log("error", "GPU recovery initialization left completion unknown; retaining resources");
return -1;
}
release_lost_device();
g_dev_state = -2;
droiddeck_log("error", "GPU recovery failed while recreating the Vulkan device; restart the session");
set_fault("the display GPU was lost and in-process recovery failed");
return -1;
}
if (restore_client_images() != 0) {
release_lost_device();
g_dev_state = -2;
droiddeck_log("error", "GPU recovery could not restore every client buffer; restart the session");
set_fault("the display GPU was lost and some client buffers could not be restored");
return -1;
}
g_recovery_attempted = 0;
droiddeck_log("gpu", "Vulkan device and retained client buffers recovered");
return 0;
}
int vkp_ready(void) { return dev_init(); }
static int swap_init_locked(void);
@@ -1481,8 +1216,6 @@ struct vkp_image *vkp_image_from_android_buffer(AHardwareBuffer *buffer) {
if (result != VK_SUCCESS) goto fail;
AHardwareBuffer_acquire(buffer);
img->android_buffer = buffer;
img->source_type = VKP_IMAGE_SOURCE_AHB_WLEGL;
image_register(img);
return img;
fail:
LOGE("android_wlegl: Vulkan buffer import failed: %s", vk_result_name(result));
@@ -1634,7 +1367,6 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
if (linear_size && import_linear_dmabuf(img, fd, &linear_copy, linear_size) == 0) {
if (padded_target) droiddeck_log("gpu", "linear layer target %dx%d writes at pitch %u via DMA-BUF",
w, h, stride);
image_track_dmabuf(img, fd, drm_format, modifier, stride, offset);
return img;
}
if (padded_target) { free(img); return NULL; }
@@ -1704,12 +1436,11 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
g_vk.FreeMemory(g_dev, img->mem, NULL); g_vk.DestroyImage(g_dev, img->image, NULL);
free(img); return NULL;
}
image_track_dmabuf(img, fd, drm_format, modifier, stride, offset);
return img;
}
void vkp_wait_idle(void) {
if (g_dev_state == 1 && g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev);
if (g_dev && g_vk.DeviceWaitIdle) g_vk.DeviceWaitIdle(g_dev);
}
struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) {
@@ -1759,7 +1490,6 @@ struct vkp_image *vkp_image_from_ahb(AHardwareBuffer *ahb) {
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
g_vk.DestroyImage(g_dev, img->image, NULL); free(img); return NULL;
}
image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_SOURCE);
return img;
}
@@ -1855,7 +1585,6 @@ struct vkp_image *vkp_image_import_ahb(struct AHardwareBuffer *ahb, char *info,
if (info && info_n)
snprintf(info, info_n, "VkFormat %d, %llu bytes, memory type %d of memoryTypeBits %#x", (int)fp.format,
(unsigned long long)hp.allocationSize, idx, hp.memoryTypeBits);
image_track_ahb(img, ahb, VKP_IMAGE_SOURCE_AHB_TARGET);
return img;
}
@@ -1909,34 +1638,13 @@ struct vkp_image *vkp_image_create_shm(int w, int h) {
if (g_vk.MapMemory(g_dev, img->mem, 0, req.size, 0, &img->map) != VK_SUCCESS) {
vkp_image_destroy(img); return NULL;
}
img->source_type = VKP_IMAGE_SOURCE_SHM;
image_register(img);
return img;
}
void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride) {
if (!img || !data || img->w <= 0 || img->h <= 0 || stride <= 0 ||
(size_t)img->w > SIZE_MAX / 4)
return;
const size_t full_rowbytes = (size_t)img->w * 4;
size_t rowbytes = full_rowbytes;
if (g_dev_state != 1 || !img || !img->map || !data) return;
size_t rowbytes = (size_t)img->w * 4;
if ((size_t)stride < rowbytes) rowbytes = (size_t)stride;
if (img->source_type == VKP_IMAGE_SOURCE_SHM && !img->recovery_pixels) {
if ((size_t)img->h <= SIZE_MAX / full_rowbytes) {
const size_t bytes = full_rowbytes * (size_t)img->h;
img->recovery_pixels = calloc(1, bytes);
}
if (!img->recovery_pixels) img->source_type = VKP_IMAGE_SOURCE_NONE;
}
if (img->source_type == VKP_IMAGE_SOURCE_SHM && img->recovery_pixels) {
for (int y = 0; y < img->h; y++)
memcpy(img->recovery_pixels + (size_t)y * full_rowbytes,
(const uint8_t *)data + (size_t)y * stride, rowbytes);
}
if (g_dev_state != 1 || !img->map) return;
for (int y = 0; y < img->h; y++)
memcpy((uint8_t *)img->map + img->offset + (size_t)y * img->row_pitch,
(const uint8_t *)data + (size_t)y * stride, rowbytes);
@@ -1953,10 +1661,7 @@ void vkp_image_destroy(struct vkp_image *img) {
if (img->map) g_vk.UnmapMemory(g_dev, img->mem);
destroy_image_objects(img);
}
image_unregister(img);
if (img->source_type == VKP_IMAGE_SOURCE_DMABUF && img->source_fd >= 0) close(img->source_fd);
if (img->android_buffer) AHardwareBuffer_release(img->android_buffer);
free(img->recovery_pixels);
free(img);
}
@@ -2220,23 +1925,14 @@ static int compose_hdr(VkCommandBuffer cmd, const struct vkp_draw *draws, int n,
}
static void device_lost(const char *where) {
if (g_dev_state == -2 || g_dev_state == -3) return;
if (g_dev_state == 1) {
VkResult idle = g_vk.DeviceWaitIdle ? g_vk.DeviceWaitIdle(g_dev) : VK_ERROR_UNKNOWN;
if (idle != VK_SUCCESS && idle != VK_ERROR_DEVICE_LOST) {
quarantine_pending_work(idle, "device-loss idle");
return;
}
}
if (g_dev_state == -2) return;
g_dev_state = -2;
g_base_black = 0;
vkp_framegen_device_lost();
vkp_gpu_busy_device_lost();
droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor will try one in-process recovery",
where);
set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s); recovery pending", where);
droiddeck_log("error", "GPU device lost (VK_ERROR_DEVICE_LOST in %s): the compositor has stopped presenting; "
"restart the session", where);
set_fault("the display GPU was lost (VK_ERROR_DEVICE_LOST in %s)", where);
for (uint32_t i = 0; i < g_nimg; i++) blendp_forget_image(g_images[i]);
if (g_swapchain) g_vk.DestroySwapchainKHR(g_dev, g_swapchain, NULL);
g_swapchain = VK_NULL_HANDLE;
@@ -2461,10 +2157,11 @@ static void send_hdr_metadata(const struct droiddeck_color *c) {
static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
const struct vkp_hdr_frame *hf, int *how) {
if (how) *how = 0;
if (g_dev_state == -1 || g_dev_state == -3) return -1;
if (g_dev_state < 0) return -1;
vkp_apply_window_request();
sc_layer_hide_base();
check_surface_changed();
if (g_dev_state == -2) return -1;
if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1;
if (g_swapchain && vkp_framegen_extra_images() != g_swap_extra) {
@@ -2809,7 +2506,7 @@ void vkp_signal_first_frame(void) {
}
int vkp_update_map(int scene_w, int scene_h) {
if (dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1;
if (g_dev_state == -2 || dev_init() != 0 || !g_window || scene_w <= 0 || scene_h <= 0) return -1;
if (vkp_quest_layer_presentation()) {
int w = ANativeWindow_getWidth(g_window), h = ANativeWindow_getHeight(g_window);
if (w <= 0 || h <= 0) return -1;
@@ -2883,7 +2580,7 @@ static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_la
}
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
if (!src || src->blit_dst || !dst || !dst->blit_dst || dev_init() != 0) {
if (!src || src->blit_dst || !dst || !dst->blit_dst || g_dev_state == -2 || dev_init() != 0) {
if (wait_fd >= 0) close(wait_fd);
return -1;
}
@@ -2946,9 +2643,11 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
static struct vkp_image *g_rb;
int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) {
if (!src || src->blit_dst || !out || src->w <= 0 || src->h <= 0 || src->w * src->h > max_px ||
dev_init() != 0)
g_dev_state == -2 || dev_init() != 0)
return -1;
if (g_rb && (g_rb->w != src->w || g_rb->h != src->h)) { vkp_image_destroy(g_rb); g_rb = NULL; }
if (!g_rb) {
@@ -349,7 +349,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private var gestureSettingsOpen by mutableStateOf(false)
private var steamImportAsk by mutableStateOf<com.droiddeck.launcher.session.SteamImportPrompt.Ask?>(null)
private var steamImportAnswered: String? = null
private var directHoldBehavior by mutableStateOf(com.droiddeck.launcher.input.TouchGestureConfig.MOUSE_BEHAVIOR_CLICK)
private var directHoldBehavior by mutableStateOf(com.droiddeck.launcher.input.TouchGestureConfig.MOUSE_BEHAVIOR_NONE)
private var relativeMouseMode by mutableIntStateOf(0)
@Volatile private var appliedRelativeMouseMode: Int? = null
private val agentReadyListener: () -> Unit = {
@@ -6960,7 +6960,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (!hasFocus && ::padMouse.isInitialized) padMouse.reset()
if (runtimeRemovalBlocked) return
if (!hasFocus) {
cancelTouchGestures()
if (::touchscreenGestures.isInitialized) touchscreenGestures.cancel()
if (::touchpad.isInitialized) touchpad.cancel()
if (::scrollTouch.isInitialized) scrollTouch.cancel()
releaseHeldGuestInput()
}
if (hasFocus && !pipUi) {
@@ -23,7 +23,7 @@ class DirectTouchHold(
private var downY = 0f
private var downId = 0
private var delayMs = 0L
private var holdBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK
private var holdBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_NONE
private var forwarded = false
private var forwardedAt = 0L
private var held = false
@@ -15,7 +15,7 @@ data class TouchGestureConfig(
val longPressAction: String = ACTION_RIGHT_CLICK,
val longPressMouseBehavior: String = MOUSE_BEHAVIOR_HOLD,
val longPressDelay: Int = DEFAULT_DELAY_MS,
val directHoldBehavior: String = MOUSE_BEHAVIOR_CLICK,
val directHoldBehavior: String = MOUSE_BEHAVIOR_NONE,
val doubleTapEnabled: Boolean = true,
val doubleTapDelay: Int = DEFAULT_DELAY_MS,
val twoFingerDragEnabled: Boolean = true,
@@ -167,7 +167,7 @@ data class TouchGestureConfig(
),
longPressDelay = obj.optInt(KEY_LONG_PRESS_DELAY, DEFAULT_DELAY_MS),
directHoldBehavior = normalizeDirectHoldBehavior(
obj.optString(KEY_DIRECT_HOLD_BEHAVIOR, MOUSE_BEHAVIOR_CLICK)
obj.optString(KEY_DIRECT_HOLD_BEHAVIOR, MOUSE_BEHAVIOR_NONE)
),
doubleTapEnabled = obj.optBoolean(KEY_DOUBLE_TAP_ENABLED, true),
doubleTapDelay = obj.optInt(KEY_DOUBLE_TAP_DELAY, DEFAULT_DELAY_MS),
@@ -1,54 +0,0 @@
package com.droiddeck.launcher.session
import java.io.File
/** Finds the processes a session left running, also once proot is gone and they belong to init. */
object GuestLeftovers {
private const val MARKER = "DD_DEBUG_DIR="
fun find(rootfs: String, ended: File?, skip: Set<Int>): Set<Int> {
val marker = ended?.let { MARKER + it.path }
val parents = HashMap<Int, Int>()
val matched = HashSet<Int>()
File("/proc").listFiles { f -> f.name.all { it.isDigit() } }?.forEach { proc ->
val pid = proc.name.toIntOrNull() ?: return@forEach
parentOf(proc)?.let { parents[pid] = it }
if (pid in skip) return@forEach
val exe = runCatching { File(proc, "exe").canonicalPath }.getOrNull()
// proot runs a guest through its loader, which is then the process's executable
if (exe?.startsWith(rootfs) == true ||
marker != null && carries(runCatching { File(proc, "environ").readBytes() }.getOrNull(), marker)) {
matched.add(pid)
}
}
return withDescendants(matched, parents) - skip
}
internal fun carries(environ: ByteArray?, marker: String): Boolean {
if (environ == null) return false
val wanted = marker.toByteArray()
var start = 0
while (start < environ.size) {
var end = start
while (end < environ.size && environ[end] != 0.toByte()) end++
if (end - start == wanted.size && (0 until wanted.size).all { environ[start + it] == wanted[it] }) return true
start = end + 1
}
return false
}
internal fun withDescendants(roots: Set<Int>, parents: Map<Int, Int>): Set<Int> {
val out = HashSet(roots)
var grew = true
while (grew) {
grew = false
for ((pid, ppid) in parents) if (pid > 1 && ppid in out && out.add(pid)) grew = true
}
return out
}
private fun parentOf(proc: File): Int? {
val stat = runCatching { File(proc, "stat").readText() }.getOrNull() ?: return null
return stat.substringAfterLast(") ").split(' ').getOrNull(1)?.toIntOrNull()
}
}
@@ -1735,7 +1735,6 @@ object SessionPrefs {
signal = p.getInt("customThemeSignal", defaults.signal),
good = p.getInt("customThemeGood", defaults.good),
error = p.getInt("customThemeError", defaults.error),
warning = p.getInt("customThemeWarning", defaults.warning),
)
}
@@ -1756,7 +1755,6 @@ object SessionPrefs {
.putInt("customThemeSignal", colors.signal)
.putInt("customThemeGood", colors.good)
.putInt("customThemeError", colors.error)
.putInt("customThemeWarning", colors.warning)
.apply()
}
@@ -1888,11 +1888,21 @@ class SessionService : Service() {
File(directory, STEAM_GAME_REQUEST + ".tmp").delete()
}
private fun killGuestLeftovers(ended: File?) {
private fun killGuestLeftovers() {
val me = android.os.Process.myPid()
val rootfs = try { File(filesDir, "linuxfs").canonicalPath } catch (e: Exception) { return } + "/"
val leftovers = GuestLeftovers.find(rootfs, ended, OrphanReaper.spared() + android.os.Process.myPid())
leftovers.forEach { android.os.Process.killProcess(it) }
if (leftovers.isNotEmpty()) Log.w(TAG, "killed ${leftovers.size} guest process(es) proot no longer tracked")
val procs = File("/proc").listFiles { f -> f.name.all { it.isDigit() } } ?: return
val spared = OrphanReaper.spared()
var killed = 0
for (proc in procs) {
val pid = proc.name.toIntOrNull() ?: continue
if (pid == me || pid in spared) continue
val exe = try { File(proc, "exe").canonicalPath } catch (e: Exception) { continue }
if (!exe.startsWith(rootfs)) continue
android.os.Process.killProcess(pid)
killed++
}
if (killed > 0) Log.w(TAG, "killed $killed guest process(es) proot no longer tracked")
}
private fun killStragglers() {
@@ -2378,7 +2388,7 @@ class SessionService : Service() {
com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession)
auxiliary.forEach { (pid, started) -> teardown(pid, started) }
if (prootPid > 1) teardown(prootPid)
killGuestLeftovers(ended)
killGuestLeftovers()
pruneSystemVulkanRuntime()
finishSessionStop(status, stoppedGen, collectEnded)
if (launcherEnded) importLauncherGames()
@@ -96,7 +96,8 @@ import androidx.compose.ui.layout.onGloballyPositioned
import androidx.compose.ui.layout.onPlaced
import com.droiddeck.launcher.core.PhantomProcessLimit
internal val AttentionAmber: Color @Composable get() = LocalPalette.current.warning
internal val AttentionAmber = Color(0xFFFFB547)
@Composable
internal fun BottomBar(
@@ -307,7 +308,7 @@ private fun RailItem(
}
if (badge) Box(
modifier = Modifier.align(Alignment.TopEnd).padding(top = if (iconOnly) 7.dp else 8.dp, end = if (iconOnly) 9.dp else 18.dp)
.size(8.dp).clip(CircleShape).background(pal.warning),
.size(8.dp).clip(CircleShape).background(AttentionAmber),
)
if (count > 0) Text(
if (count > 9) "9+" else count.toString(),
@@ -1254,7 +1254,6 @@ private fun CustomColorRows() {
Triple("signal", stringResource(R.string.theme_custom_signal), colors.signal),
Triple("good", stringResource(R.string.theme_custom_good), colors.good),
Triple("error", stringResource(R.string.theme_custom_error), colors.error),
Triple("warning", stringResource(R.string.theme_custom_warning), colors.warning),
)
rows.forEach { (key, label, argb) ->
@@ -333,7 +333,7 @@ class DrawerActions(
val onInputSelection: (com.droiddeck.launcher.input.InputRole?) -> Unit = {},
val onGestureSettings: () -> Unit = {},
val touchActive: String = "",
val directHoldBehavior: String = MOUSE_BEHAVIOR_CLICK,
val directHoldBehavior: String = MOUSE_BEHAVIOR_NONE,
val onDirectHoldBehavior: (String) -> Unit = {},
val onFexPreset: (String) -> Unit,
val onUpscaler: (Int) -> Unit = {},
@@ -38,7 +38,7 @@ class Palette(
val background: Color, val surface: Color, val surfaceVariant: Color, val line: Color, val line2: Color,
val onBackground: Color, val onSurfaceVariant: Color,
val primary: Color, val primary2: Color, val onPrimary: Color, val signal: Color,
val good: Color, val error: Color = Color(0xFFFF8A80), val warning: Color = Color(0xFFFFB547),
val good: Color, val error: Color = Color(0xFFFF8A80),
)
data class CustomThemeColors(
@@ -54,7 +54,6 @@ data class CustomThemeColors(
val signal: Int = 0xFF1A9FFF.toInt(),
val good: Int = 0xFF4CD37F.toInt(),
val error: Int = 0xFFFF8A80.toInt(),
val warning: Int = 0xFFFFB547.toInt(),
)
object Themes {
@@ -145,7 +144,6 @@ object Themes {
"signal" -> current.copy(signal = color)
"good" -> current.copy(good = color)
"error" -> current.copy(error = color)
"warning" -> current.copy(warning = color)
else -> return
}
setCustomColors(context, updated)
@@ -166,7 +164,6 @@ object Themes {
signal = Color(colors.signal),
good = Color(colors.good),
error = Color(colors.error),
warning = Color(colors.warning),
)
fun current(context: Context): Palette {
@@ -232,9 +229,7 @@ val Palette.onSignal: Color get() = if (signal.luminance() > 0.18f) Color(0xFF03
@Composable
fun DroidDeckTheme(theme: String? = null, appScale: Int = AppUiPrefs.DEFAULT_SCALE, content: @Composable () -> Unit) {
val context = LocalContext.current
remember(context) { Themes.loadGradient(context) }
val id = theme ?: SessionPrefs.theme(context)
val id = theme ?: SessionPrefs.theme(LocalContext.current)
if (id == Themes.INNER_GAMER) InnerGamerHue(Themes.rgbSpeed)
val p = Themes.byId(id)
val scheme = darkColorScheme(
-1
View File
@@ -4299,7 +4299,6 @@
<string name="theme_custom_signal">الإبرازات</string>
<string name="theme_custom_good">نجاح</string>
<string name="theme_custom_error">خطأ</string>
<string name="theme_custom_warning">تحذير</string>
<string name="hud_only_during_game">عرض HUD أثناء اللعب فقط</string>
<string name="hud_only_during_game_hint">إخفاء HUD عند عدم اكتشاف إطارات اللعبة.</string>
<string name="steam_store_close_steam">أغلق Steam أولاً</string>
@@ -4179,7 +4179,6 @@
<string name="theme_custom_signal">Destacados</string>
<string name="theme_custom_good">Éxito</string>
<string name="theme_custom_error">Error</string>
<string name="theme_custom_warning">Advertencia</string>
<string name="hud_only_during_game">Mostrar el HUD solo durante una partida</string>
<string name="hud_only_during_game_hint">Ocultar el HUD cuando no se detecten fotogramas del juego.</string>
<string name="steam_store_close_steam">Cierra Steam primero</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Акценти</string>
<string name="theme_custom_good">Успех</string>
<string name="theme_custom_error">Грешка</string>
<string name="theme_custom_warning">Предупреждение</string>
<string name="hud_only_during_game">Показвай HUD само по време на игра</string>
<string name="hud_only_during_game_hint">Скривай HUD, когато не се засичат кадри от играта.</string>
<string name="steam_store_close_steam">Първо затворете Steam</string>
-1
View File
@@ -4219,7 +4219,6 @@
<string name="theme_custom_signal">Zvýraznění</string>
<string name="theme_custom_good">Úspěch</string>
<string name="theme_custom_error">Chyba</string>
<string name="theme_custom_warning">Varování</string>
<string name="hud_only_during_game">Zobrazovat HUD pouze během hry</string>
<string name="hud_only_during_game_hint">Skrýt HUD, když nejsou detekovány snímky hry.</string>
<string name="steam_store_close_steam">Nejprve zavřete Steam</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Fremhævninger</string>
<string name="theme_custom_good">Succes</string>
<string name="theme_custom_error">Fejl</string>
<string name="theme_custom_warning">Advarsel</string>
<string name="hud_only_during_game">Vis kun HUD under spil</string>
<string name="hud_only_during_game_hint">Skjul HUD, når der ikke registreres spilbilleder.</string>
<string name="steam_store_close_steam">Luk Steam først</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Hervorhebungen</string>
<string name="theme_custom_good">Erfolg</string>
<string name="theme_custom_error">Fehler</string>
<string name="theme_custom_warning">Warnung</string>
<string name="hud_only_during_game">HUD nur während eines Spiels anzeigen</string>
<string name="hud_only_during_game_hint">HUD ausblenden, wenn keine Spielframes erkannt werden.</string>
<string name="steam_store_close_steam">Schließe zuerst Steam</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Επισημάνσεις</string>
<string name="theme_custom_good">Επιτυχία</string>
<string name="theme_custom_error">Σφάλμα</string>
<string name="theme_custom_warning">Προειδοποίηση</string>
<string name="hud_only_during_game">Εμφάνιση HUD μόνο κατά τη διάρκεια παιχνιδιού</string>
<string name="hud_only_during_game_hint">Απόκρυψη HUD όταν δεν ανιχνεύονται καρέ παιχνιδιού.</string>
<string name="steam_store_close_steam">Κλείστε πρώτα το Steam</string>
-1
View File
@@ -4179,7 +4179,6 @@
<string name="theme_custom_signal">Destacados</string>
<string name="theme_custom_good">Éxito</string>
<string name="theme_custom_error">Error</string>
<string name="theme_custom_warning">Advertencia</string>
<string name="hud_only_during_game">Mostrar el HUD solo durante una partida</string>
<string name="hud_only_during_game_hint">Ocultar el HUD cuando no se detecten fotogramas del juego.</string>
<string name="steam_store_close_steam">Cierra Steam primero</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Korostukset</string>
<string name="theme_custom_good">Onnistuminen</string>
<string name="theme_custom_error">Virhe</string>
<string name="theme_custom_warning">Varoitus</string>
<string name="hud_only_during_game">Näytä HUD vain pelin aikana</string>
<string name="hud_only_during_game_hint">Piilota HUD, kun pelin ruutuja ei havaita.</string>
<string name="steam_store_close_steam">Sulje Steam ensin</string>
-1
View File
@@ -4178,7 +4178,6 @@
<string name="theme_custom_signal">Mises en évidence</string>
<string name="theme_custom_good">Succès</string>
<string name="theme_custom_error">Erreur</string>
<string name="theme_custom_warning">Avertissement</string>
<string name="hud_only_during_game">Afficher le HUD uniquement pendant une partie</string>
<string name="hud_only_during_game_hint">Masquer le HUD lorsqu’aucune image du jeu n’est détectée.</string>
<string name="steam_store_close_steam">Fermez d\'abord Steam</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">हाइलाइट</string>
<string name="theme_custom_good">सफलता</string>
<string name="theme_custom_error">त्रुटि</string>
<string name="theme_custom_warning">चेतावनी</string>
<string name="hud_only_during_game">HUD केवल गेम के दौरान दिखाएँ</string>
<string name="hud_only_during_game_hint">गेम के फ़्रेम का पता न चलने पर HUD छिपाएँ।</string>
<string name="steam_store_close_steam">पहले Steam बंद करें</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Kiemelések</string>
<string name="theme_custom_good">Siker</string>
<string name="theme_custom_error">Hiba</string>
<string name="theme_custom_warning">Figyelmeztetés</string>
<string name="hud_only_during_game">HUD megjelenítése csak játék közben</string>
<string name="hud_only_during_game_hint">HUD elrejtése, ha nem észlelhetők játék képkockái.</string>
<string name="steam_store_close_steam">Előbb zárd be a Steamet</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">Sorotan</string>
<string name="theme_custom_good">Berhasil</string>
<string name="theme_custom_error">Kesalahan</string>
<string name="theme_custom_warning">Peringatan</string>
<string name="hud_only_during_game">Tampilkan HUD hanya saat bermain</string>
<string name="hud_only_during_game_hint">Sembunyikan HUD saat tidak ada frame game yang terdeteksi.</string>
<string name="steam_store_close_steam">Tutup Steam terlebih dahulu</string>
-1
View File
@@ -4178,7 +4178,6 @@
<string name="theme_custom_signal">Evidenziazioni</string>
<string name="theme_custom_good">Successo</string>
<string name="theme_custom_error">Errore</string>
<string name="theme_custom_warning">Avviso</string>
<string name="hud_only_during_game">Mostra l’HUD solo durante il gioco</string>
<string name="hud_only_during_game_hint">Nascondi l’HUD quando non vengono rilevati fotogrammi del gioco.</string>
<string name="steam_store_close_steam">Chiudi prima Steam</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">強調表示</string>
<string name="theme_custom_good">成功</string>
<string name="theme_custom_error">エラー</string>
<string name="theme_custom_warning">警告</string>
<string name="hud_only_during_game">ゲーム中のみHUDを表示</string>
<string name="hud_only_during_game_hint">ゲームのフレームが検出されないときはHUDを非表示にする。</string>
<string name="steam_store_close_steam">先に Steam を閉じてください</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">강조 표시</string>
<string name="theme_custom_good">성공</string>
<string name="theme_custom_error">오류</string>
<string name="theme_custom_warning">경고</string>
<string name="hud_only_during_game">게임 중에만 HUD 표시</string>
<string name="hud_only_during_game_hint">게임 프레임이 감지되지 않으면 HUD 숨기기.</string>
<string name="steam_store_close_steam">먼저 Steam을 닫으세요</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">Sorotan</string>
<string name="theme_custom_good">Berjaya</string>
<string name="theme_custom_error">Ralat</string>
<string name="theme_custom_warning">Amaran</string>
<string name="hud_only_during_game">Paparkan HUD hanya semasa bermain</string>
<string name="hud_only_during_game_hint">Sembunyikan HUD apabila bingkai permainan tidak dikesan.</string>
<string name="steam_store_close_steam">Tutup Steam dahulu</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Uthevinger</string>
<string name="theme_custom_good">Suksess</string>
<string name="theme_custom_error">Feil</string>
<string name="theme_custom_warning">Advarsel</string>
<string name="hud_only_during_game">Vis HUD bare mens du spiller</string>
<string name="hud_only_during_game_hint">Skjul HUD når ingen spillbilder registreres.</string>
<string name="steam_store_close_steam">Lukk Steam først</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Accenten</string>
<string name="theme_custom_good">Geslaagd</string>
<string name="theme_custom_error">Fout</string>
<string name="theme_custom_warning">Waarschuwing</string>
<string name="hud_only_during_game">HUD alleen tijdens een game weergeven</string>
<string name="hud_only_during_game_hint">Verberg de HUD wanneer er geen gameframes worden gedetecteerd.</string>
<string name="steam_store_close_steam">Sluit eerst Steam</string>
-1
View File
@@ -4219,7 +4219,6 @@
<string name="theme_custom_signal">Wyróżnienia</string>
<string name="theme_custom_good">Sukces</string>
<string name="theme_custom_error">Błąd</string>
<string name="theme_custom_warning">Ostrzeżenie</string>
<string name="hud_only_during_game">Pokazuj HUD tylko podczas gry</string>
<string name="hud_only_during_game_hint">Ukryj HUD, gdy nie wykryto klatek gry.</string>
<string name="steam_store_close_steam">Najpierw zamknij Steam</string>
@@ -1812,7 +1812,6 @@
<string name="theme_custom_signal">Destaques e indicadores</string>
<string name="theme_custom_good">Sucesso</string>
<string name="theme_custom_error">Erro</string>
<string name="theme_custom_warning">Aviso</string>
<string name="pckb_key_esc">Esc</string>
<string name="pckb_key_ins">Ins</string>
<string name="pckb_key_del">Del</string>
-1
View File
@@ -1820,7 +1820,6 @@
<string name="theme_custom_signal">Destaques e indicadores</string>
<string name="theme_custom_good">Sucesso</string>
<string name="theme_custom_error">Erro</string>
<string name="theme_custom_warning">Aviso</string>
<string name="pckb_key_esc">Esc</string>
<string name="pckb_key_ins">Ins</string>
<string name="pckb_key_del">Del</string>
-1
View File
@@ -4179,7 +4179,6 @@
<string name="theme_custom_signal">Evidențieri</string>
<string name="theme_custom_good">Succes</string>
<string name="theme_custom_error">Eroare</string>
<string name="theme_custom_warning">Avertisment</string>
<string name="hud_only_during_game">Afișează HUD-ul doar în timpul jocului</string>
<string name="hud_only_during_game_hint">Ascunde HUD-ul când nu sunt detectate cadre ale jocului.</string>
<string name="steam_store_close_steam">Închide mai întâi Steam</string>
-1
View File
@@ -4220,7 +4220,6 @@
<string name="theme_custom_signal">Выделения</string>
<string name="theme_custom_good">Успех</string>
<string name="theme_custom_error">Ошибка</string>
<string name="theme_custom_warning">Предупреждение</string>
<string name="hud_only_during_game">Показывать HUD только во время игры</string>
<string name="hud_only_during_game_hint">Скрывать HUD, когда кадры игры не обнаруживаются.</string>
<string name="steam_store_close_steam">Сначала закройте Steam</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Markeringar</string>
<string name="theme_custom_good">Lyckades</string>
<string name="theme_custom_error">Fel</string>
<string name="theme_custom_warning">Varning</string>
<string name="hud_only_during_game">Visa HUD endast under spel</string>
<string name="hud_only_during_game_hint">Dölj HUD när inga spelbildrutor upptäcks.</string>
<string name="steam_store_close_steam">Stäng Steam först</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">จุดเน้น</string>
<string name="theme_custom_good">สำเร็จ</string>
<string name="theme_custom_error">ข้อผิดพลาด</string>
<string name="theme_custom_warning">คำเตือน</string>
<string name="hud_only_during_game">แสดง HUD เฉพาะขณะเล่นเกม</string>
<string name="hud_only_during_game_hint">ซ่อน HUD เมื่อไม่พบเฟรมของเกม</string>
<string name="steam_store_close_steam">ปิด Steam ก่อน</string>
-1
View File
@@ -4139,7 +4139,6 @@
<string name="theme_custom_signal">Vurgular</string>
<string name="theme_custom_good">Başarılı</string>
<string name="theme_custom_error">Hata</string>
<string name="theme_custom_warning">Uyarı</string>
<string name="hud_only_during_game">HUD\'yi yalnızca oyun sırasında göster</string>
<string name="hud_only_during_game_hint">Oyun kareleri algılanmadığında HUD\'yi gizle.</string>
<string name="steam_store_close_steam">Önce Steam\'i kapatın</string>
-1
View File
@@ -4219,7 +4219,6 @@
<string name="theme_custom_signal">Виділення</string>
<string name="theme_custom_good">Успіх</string>
<string name="theme_custom_error">Помилка</string>
<string name="theme_custom_warning">Попередження</string>
<string name="hud_only_during_game">Показувати HUD лише під час гри</string>
<string name="hud_only_during_game_hint">Приховувати HUD, коли кадри гри не виявляються.</string>
<string name="steam_store_close_steam">Спочатку закрийте Steam</string>
-1
View File
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">Điểm nhấn</string>
<string name="theme_custom_good">Thành công</string>
<string name="theme_custom_error">Lỗi</string>
<string name="theme_custom_warning">Cảnh báo</string>
<string name="hud_only_during_game">Chỉ hiển thị HUD khi đang chơi</string>
<string name="hud_only_during_game_hint">Ẩn HUD khi không phát hiện khung hình trò chơi.</string>
<string name="steam_store_close_steam">Hãy đóng Steam trước</string>
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">高亮</string>
<string name="theme_custom_good">成功</string>
<string name="theme_custom_error">错误</string>
<string name="theme_custom_warning">警告</string>
<string name="hud_only_during_game">仅在游戏期间显示 HUD</string>
<string name="hud_only_during_game_hint">未检测到游戏帧时隐藏 HUD。</string>
<string name="steam_store_close_steam">请先关闭 Steam</string>
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">重點標示</string>
<string name="theme_custom_good">成功</string>
<string name="theme_custom_error">錯誤</string>
<string name="theme_custom_warning">警告</string>
<string name="hud_only_during_game">只在遊戲期間顯示 HUD</string>
<string name="hud_only_during_game_hint">未偵測到遊戲畫面時隱藏 HUD。</string>
<string name="steam_store_close_steam">請先關閉 Steam</string>
@@ -4109,7 +4109,6 @@
<string name="theme_custom_signal">醒目標示</string>
<string name="theme_custom_good">成功</string>
<string name="theme_custom_error">錯誤</string>
<string name="theme_custom_warning">警告</string>
<string name="hud_only_during_game">僅在遊戲期間顯示 HUD</string>
<string name="hud_only_during_game_hint">未偵測到遊戲畫面時隱藏 HUD。</string>
<string name="steam_store_close_steam">請先關閉 Steam</string>
-1
View File
@@ -2028,7 +2028,6 @@
<string name="theme_custom_signal">Highlights</string>
<string name="theme_custom_good">Success</string>
<string name="theme_custom_error">Error</string>
<string name="theme_custom_warning">Warning</string>
<string name="pckb_key_esc">Esc</string>
<string name="pckb_key_ins">Ins</string>
<string name="pckb_key_del">Del</string>
@@ -29,7 +29,7 @@ class DirectTouchHoldTest {
override fun move(pointerId: Int, x: Float, y: Float) { touches += "move $pointerId at $x,$y" }
override fun up(pointerId: Int, x: Float, y: Float) { touches += "up $pointerId at $x,$y" }
override fun cancel() { touches += "cancel" }
}).also { it.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 500)) }
}).also { it.configure(TouchGestureConfig(longPressDelay = 500, directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK)) }
@Test fun holdClicksRightWithoutTouchingTheGame() {
touch(MotionEvent.ACTION_DOWN)
@@ -87,18 +87,49 @@ class DirectTouchHoldTest {
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 44.0,30.0"), touches)
}
@Test fun stillHoldClicksRightWithTheDefaultConfig() {
@Test fun stillHoldStaysHeldWithTheDefaultConfig() {
hold.configure(TouchGestureConfig())
touch(MotionEvent.ACTION_DOWN)
assertEquals(listOf("down 0 at 40.0,30.0"), touches)
advance(2000)
touch(MotionEvent.ACTION_MOVE)
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
touch(MotionEvent.ACTION_UP)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 40.0,30.0"), touches)
assertTrue(buttons.isEmpty())
}
@Test fun aSavedRightClickChoiceIsKept() {
val saved = TouchGestureConfig.fromJson(
TouchGestureConfig(directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK).toJson())
assertEquals(TouchGestureConfig.MOUSE_BEHAVIOR_CLICK, saved.directHoldBehavior)
hold.configure(saved)
touch(MotionEvent.ACTION_DOWN)
advance(2000)
touch(MotionEvent.ACTION_UP)
assertEquals(listOf("true at 40.0,30.0", "false at 40.0,30.0"), buttons)
assertTrue(touches.isEmpty())
}
@Test fun aHeldTouchLiftsAtOnce() {
hold.configure(TouchGestureConfig())
touch(MotionEvent.ACTION_DOWN)
advance(80)
touch(MotionEvent.ACTION_UP)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 40.0,30.0"), touches)
}
@Test fun aShortTapStaysPressedLongEnoughToBeSeen() {
hold.configure(TouchGestureConfig())
touch(MotionEvent.ACTION_DOWN)
advance(10)
touch(MotionEvent.ACTION_UP)
advance(39)
assertEquals(listOf("down 0 at 40.0,30.0"), touches)
advance(1)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 40.0,30.0"), touches)
}
@Test fun longPressFollowsTheConfiguredDelay() {
hold.configure(TouchGestureConfig(longPressEnabled = true, longPressDelay = 800))
hold.configure(TouchGestureConfig(longPressDelay = 800, directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK))
touch(MotionEvent.ACTION_DOWN)
advance(700)
assertTrue(buttons.isEmpty())
@@ -201,25 +232,6 @@ class DirectTouchHoldTest {
)
}
@Test fun aDragLiftsAtOnce() {
touch(MotionEvent.ACTION_DOWN)
touch(MotionEvent.ACTION_MOVE, 80f)
advance(80)
touches.clear()
touch(MotionEvent.ACTION_UP, 80f)
assertEquals(listOf("up 0 at 80.0,30.0"), touches)
}
@Test fun aTapStaysPressedLongEnoughToBeSeen() {
touch(MotionEvent.ACTION_DOWN)
advance(10)
touch(MotionEvent.ACTION_UP)
advance(49)
assertEquals(listOf("down 0 at 40.0,30.0"), touches)
advance(1)
assertEquals(listOf("down 0 at 40.0,30.0", "up 0 at 40.0,30.0"), touches)
}
private fun advance(ms: Long) = shadowOf(Looper.getMainLooper()).idleFor(Duration.ofMillis(ms))
private fun touch(action: Int, x: Float = 40f): Boolean {
val event = MotionEvent.obtain(0, 0, action, x, 30f, 0)
@@ -152,7 +152,8 @@ class SessionGestureRoutingTest {
@Test fun pausingCancelsPendingHoldsInBothTouchModes() {
for (mode in listOf(SessionPrefs.TOUCH_GESTURES, SessionPrefs.TOUCH_DIRECT)) {
prepare(mode, TouchGestureConfig(longPressEnabled = true, longPressAction = "key_E"))
prepare(mode, TouchGestureConfig(longPressEnabled = true, longPressAction = "key_E",
directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK))
val now = SystemClock.uptimeMillis()
val event = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 400f, 300f, 0)
try { assertTrue(activity.onTouchEvent(event)) } finally { event.recycle() }
@@ -167,7 +168,8 @@ class SessionGestureRoutingTest {
for (mode in listOf(SessionPrefs.TOUCH_GESTURES, SessionPrefs.TOUCH_DIRECT)) {
keys.clear()
directButtons.clear()
prepare(mode, TouchGestureConfig(longPressEnabled = true, longPressAction = "key_E"))
prepare(mode, TouchGestureConfig(longPressEnabled = true, longPressAction = "key_E",
directHoldBehavior = TouchGestureConfig.MOUSE_BEHAVIOR_CLICK))
val now = SystemClock.uptimeMillis()
val event = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN, 400f, 300f, 0)
try { assertTrue(activity.onTouchEvent(event)) } finally { event.recycle() }
@@ -1,35 +0,0 @@
package com.droiddeck.launcher.session
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
class GuestLeftoversTest {
private fun environ(vararg entries: String) = entries.joinToString("\u0000", postfix = "\u0000").toByteArray()
@Test
fun aProcessOfTheEndedSessionCarriesItsFolder() {
val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam"
assertTrue(GuestLeftovers.carries(environ("HOME=/home/deck", marker, "TERM=xterm"), marker))
assertTrue(GuestLeftovers.carries(environ(marker), marker))
}
@Test
fun anotherSessionsFolderOrALongerPathIsNotTheEndedSession() {
val marker = "DD_DEBUG_DIR=/data/logs/2026-11-28-85-steam"
assertFalse(GuestLeftovers.carries(environ("DD_DEBUG_DIR=/data/logs/2026-11-28-86-steam"), marker))
assertFalse(GuestLeftovers.carries(environ("$marker-2"), marker))
assertFalse(GuestLeftovers.carries(environ("X$marker"), marker))
assertFalse(GuestLeftovers.carries(null, marker))
assertFalse(GuestLeftovers.carries(ByteArray(0), marker))
}
@Test
fun whatAMatchedProcessStartedGoesWithIt() {
// 10 was proot's child and now belongs to init; 12 cleared its environment; 20 is unrelated
val parents = mapOf(10 to 1, 11 to 10, 12 to 11, 13 to 12, 20 to 1, 21 to 20)
assertEquals(setOf(10, 11, 12, 13), GuestLeftovers.withDescendants(setOf(10), parents))
assertEquals(emptySet<Int>(), GuestLeftovers.withDescendants(emptySet(), parents))
}
}
+5 -3
View File
@@ -12,7 +12,7 @@ EA games install, update and start without the EA app. The research behind it is
| Queries | `app/src/main/resources/ea/graphql/*.gql` | EA's own query texts, byte for byte. The gateway matches persisted queries by SHA-256, so these files must not be reformatted (`-text` in `.gitattributes`). |
| Downloads | Rust `src/ea/` in `libdroiddeckstores.so`, `EaInstaller.kt` | A build is one ZIP on EA's CDN. The engine reads its central directory with ranged reads, keeps files whose size and CRC match, and streams every other entry through inflate into place. `.droiddeck-ea-files` records what it placed, so a resume or update does not re-hash those files; files a new build drops are removed. |
| Updates | `EaUpdates` in `EaBackend.kt` | The game page compares the installed version with the offer's live `gameVersion` (every 30 minutes at most). Update runs the same install, which only fetches changed files. |
| Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`; cached in `pfx/.droiddeck-ea-hw.json`), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. |
| Launch, guest | `droiddeck-store-launch` (`prepare_ea`) | Creates the prefix, reads the machine as Wine reports it (`wmic`, `vol`, `hostname`, CPUID from a 32-bit and a 64-bit probe; cached in `pfx/.droiddeck-ea-hw.json` until the Proton version or its FEX libraries change; a probe that times out, fails or misses a value keeps the older complete cache), writes EA app presence keys and the game's `Install Dir` keys in both registry views, runs the build's Touchup once per installed build, then asks the app for the session and writes any licence files. |
| Launch, Steam copy | `prepare_steam_ea` in `droiddeck-store-launch`, the Proton wrapper | Steam starts its EA titles with `steam2ea://`, which only the EA app handles, and the EA app does not install here. When the prefix has no EA app, the hook reads the game's `__Installer/installerdata.xml` and its offers (`__Installer/LOC/Origin.OFR.*.dat`), runs `prepare_ea` with a `steam` request (the app answers with the launch environment instead of a sidecar file), and writes `droiddeck-ea-steam.bat` in the game's compatdata. The wrapper runs that launcher in place of the link. Writing the EA app presence keys also satisfies the install script, so Steam stops running the EA app installer. |
| Launch, app | `EaLaunch.kt`, `EaOoa.kt`, `EaLsx.kt` | Answers `ea-prepare`: starts the LSX endpoint on `127.0.0.1:3216`, mints the short-lived opaque token, writes `.droiddeck-ea-env` (read once and deleted by the launcher `.bat`), and for games with a `Core` folder requests an online-activation licence for the machine hash. |
| LSX | `EaLsx.kt` | The local endpoint EA's SDK talks to instead of the EA app: challenge, AES session key, config, profile, settings, game info, auth codes for the game's own client ids, licences with Denuvo tokens, entitlements. Friends, presence and the overlay answer empty. |
@@ -21,8 +21,10 @@ EA games install, update and start without the EA app. The research behind it is
The licence names a hash of the machine the game's activation layer computes itself. The hash
version follows the activation library's product version (`Core/activation.dll` or `awc.dll`):
5.x → 4, 4.7.6+ → 3, 4.7.x → 2, 4.x → 1. Versions 2 and 3 also need CPUID leaf 1 ECX, which Wine's
WMI does not expose, so those use `00000000` unless the probe learns it.
5.x → 4, 4.7.6+ → 3, 4.7.x → 2, 4.x → 1. Versions 2 and 3 also hash CPUID leaf 1 ECX, which FEX
reports differently to 32-bit (WOW64) and 64-bit (ARM64EC) processes when their AVX support differs,
so the game is sent the CPUID its own exe's bitness sees. A cache from before the 64-bit probe has
only the 32-bit values, and every game gets those until a probe with Proton found succeeds.
## Not done yet
-1
View File
@@ -10,7 +10,6 @@ export SHELL=/bin/bash
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
export MOZ_SHM_NO_SEALS=1
export QTWEBENGINE_DISABLE_SANDBOX=1
export KWIN_COMPOSE=Q QT_QUICK_BACKEND=software LIBGL_ALWAYS_SOFTWARE=1 GALLIUM_DRIVER=llvmpipe
export KWIN_USE_OVERLAYS=0
[ -e /etc/mpv/mpv.conf ] || { mkdir -p /etc/mpv && echo gpu-sw=yes >/etc/mpv/mpv.conf; } 2>/dev/null
@@ -12,7 +12,6 @@ fi
export MOZ_DISABLE_CONTENT_SANDBOX=1 MOZ_DISABLE_GMP_SANDBOX=1 MOZ_DISABLE_RDD_SANDBOX=1
export MOZ_DISABLE_SOCKET_PROCESS_SANDBOX=1 MOZ_DISABLE_UTILITY_SANDBOX=1
export MOZ_SHM_NO_SEALS=1
export QTWEBENGINE_DISABLE_SANDBOX=1
if [ -s /etc/ld.so.preload ]; then
preload=$(tr -s '\n' ':' < /etc/ld.so.preload)
export LD_PRELOAD="${preload%:}${LD_PRELOAD:+:$LD_PRELOAD}" SHARUN_ALLOW_LD_PRELOAD=1
@@ -1258,39 +1258,69 @@ def wmi_value(text):
CPUID_LEAVES = (0, 1, 0x80000002, 0x80000003, 0x80000004)
def cpuid_exe():
"""A 32-bit console program that writes the raw CPUID leaves an x86 game sees under the emulator."""
def cpuid_exe(wide=False):
"""A console program that writes the raw CPUID leaves an x86 game sees under the emulator: 32-bit, or 64-bit when wide."""
import struct
base, rva = 0x400000, 0x1000
buf, written = base + rva + 0x180, base + rva + 0x1D0
iat = base + rva + 0x138
code = b"\x53\x57\xbf" + struct.pack("<I", buf)
rva = 0x1000
if wide:
base, thunk, optional, names, dll, buf, written = 0x140000000, 8, 0xF0, (0x168, 0x178, 0x184), 0x192, 0x1A0, 0x1F0
else:
base, thunk, optional, names, dll, buf, written = 0x400000, 4, 0xE0, (0x148, 0x158, 0x164), 0x172, 0x180, 0x1D0
ilt, iat = 0x128, 0x128 + 4 * thunk
code = bytearray()
def rip(op, target):
code.extend(op + struct.pack("<i", target - len(code) - len(op) - 4))
if wide:
code += b"\x53\x57\x48\x83\xec\x38"
rip(b"\x48\x8d\x3d", buf)
else:
code += b"\x53\x57\xbf" + struct.pack("<I", base + rva + buf)
for leaf in CPUID_LEAVES:
code += b"\xb8" + struct.pack("<I", leaf) + b"\x31\xc9\x0f\xa2\x89\x07\x89\x5f\x04\x89\x4f\x08\x89\x57\x0c\x83\xc7\x10"
code += b"\x6a\xf5\xff\x15" + struct.pack("<I", iat)
code += b"\x6a\x00\x68" + struct.pack("<I", written) + b"\x6a\x50\x68" + struct.pack("<I", buf) + b"\x50\xff\x15" + struct.pack("<I", iat + 4)
code += b"\x6a\x00\xff\x15" + struct.pack("<I", iat + 8)
code += b"\xb8" + struct.pack("<I", leaf) + b"\x31\xc9\x0f\xa2\x89\x07\x89\x5f\x04\x89\x4f\x08\x89\x57\x0c"
code += b"\x48\x83\xc7\x10" if wide else b"\x83\xc7\x10"
if wide:
code += b"\xb9\xf5\xff\xff\xff"
rip(b"\xff\x15", iat)
code += b"\x48\x89\xc1"
rip(b"\x48\x8d\x15", buf)
code += b"\x41\xb8\x50\x00\x00\x00"
rip(b"\x4c\x8d\x0d", written)
code += b"\x48\xc7\x44\x24\x20\x00\x00\x00\x00"
rip(b"\xff\x15", iat + 8)
code += b"\x31\xc9"
rip(b"\xff\x15", iat + 16)
else:
at = base + rva
code += b"\x6a\xf5\xff\x15" + struct.pack("<I", at + iat)
code += b"\x6a\x00\x68" + struct.pack("<I", at + written) + b"\x6a\x50\x68" + struct.pack("<I", at + buf)
code += b"\x50\xff\x15" + struct.pack("<I", at + iat + 4) + b"\x6a\x00\xff\x15" + struct.pack("<I", at + iat + 8)
section = bytearray(0x200)
section[:len(code)] = code
names = [(0x148, b"GetStdHandle"), (0x158, b"WriteFile"), (0x164, b"ExitProcess")]
struct.pack_into("<IIIII", section, 0x100, rva + 0x128, 0, 0, rva + 0x172, rva + 0x138)
for i, (at, name) in enumerate(names):
struct.pack_into("<I", section, 0x128 + 4 * i, rva + at)
struct.pack_into("<I", section, 0x138 + 4 * i, rva + at)
struct.pack_into("<IIIII", section, 0x100, rva + ilt, 0, 0, rva + dll, rva + iat)
entry = "<Q" if wide else "<I"
for i, (at, name) in enumerate(zip(names, (b"GetStdHandle", b"WriteFile", b"ExitProcess"))):
struct.pack_into(entry, section, ilt + thunk * i, rva + at)
struct.pack_into(entry, section, iat + thunk * i, rva + at)
section[at + 2:at + 2 + len(name)] = name
section[0x172:0x172 + 12] = b"KERNEL32.dll"
section[dll:dll + 12] = b"KERNEL32.dll"
header = bytearray(0x200)
header[0:2] = b"MZ"
struct.pack_into("<I", header, 0x3C, 0x40)
header[0x40:0x44] = b"PE\0\0"
struct.pack_into("<HHIIIHH", header, 0x44, 0x14C, 1, 0, 0, 0, 0xE0, 0x0103)
opt = struct.pack("<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII", 0x10B, 0, 0, 0x200, 0, 0, rva, rva, rva, base, 0x1000, 0x200,
4, 0, 0, 0, 4, 0, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
struct.pack_into("<HHIIIHH", header, 0x44, 0x8664 if wide else 0x14C, 1, 0, 0, 0, optional, 0x0023 if wide else 0x0103)
if wide:
opt = struct.pack("<HBBIIIIIQIIHHHHHHIIIIHHQQQQII", 0x20B, 0, 0, 0x200, 0, 0, rva, rva, base, 0x1000, 0x200,
5, 2, 0, 0, 5, 2, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
else:
opt = struct.pack("<HBBIIIIIIIIIHHHHHHIIIIHHIIIIII", 0x10B, 0, 0, 0x200, 0, 0, rva, rva, rva, base, 0x1000, 0x200,
4, 0, 0, 0, 4, 0, 0, 0x2000, 0x200, 0, 3, 0, 0x100000, 0x1000, 0x100000, 0x1000, 0, 16)
dirs = bytearray(128)
struct.pack_into("<II", dirs, 8, rva + 0x100, 40)
struct.pack_into("<II", dirs, 96, rva + 0x138, 16)
header[0x58:0x58 + 0xE0] = opt + bytes(dirs)
header[0x138:0x138 + 40] = struct.pack("<8sIIIIIIHHI", b".text", 0x1000, rva, 0x200, 0x200, 0, 0, 0, 0, 0xE0000060)
struct.pack_into("<II", dirs, 96, rva + iat, 4 * thunk)
header[0x58:0x58 + optional] = opt + bytes(dirs)
header[0x58 + optional:0x58 + optional + 40] = struct.pack("<8sIIIIIIHHI", b".text", 0x1000, rva, 0x200, 0x200, 0, 0, 0, 0, 0xE0000060)
return bytes(header) + bytes(section)
@@ -1342,24 +1372,65 @@ def cpuid_values(raw):
"cpuEcx": "%08x" % regs[1][2], "cpuBrand": brand}
EA_PROBE_FIELDS = ("boardManufacturer", "biosManufacturer", "osInstallDate", "osSerial", "volumeSerial", "hostname",
"cpuVendor", "cpuEax", "cpuEdx", "cpuEcx")
EA_CPU_FIELDS = ("cpuVendor", "cpuEax", "cpuEdx", "cpuEcx")
EA_PROBE_FIELDS = ("boardManufacturer", "biosManufacturer", "osInstallDate", "osSerial", "volumeSerial",
"hostname") + EA_CPU_FIELDS
def probe_complete(values):
return all(str(values.get(key) or "").strip() for key in EA_PROBE_FIELDS)
EA_CPU64 = "cpu64"
EA_RUNTIME = "runtime"
EA_RUNTIME_FILES = ("version", "files/lib/wine/aarch64-windows/libarm64ecfex.dll", "files/lib/wine/aarch64-windows/libwow64fex.dll")
def probe_complete(values, fields=EA_PROBE_FIELDS):
return all(str(values.get(key) or "").strip() for key in fields)
def runtime_stamp(proton):
if not proton or not Path(proton).is_file():
return ""
root = Path(proton).parent
parts = []
for name in EA_RUNTIME_FILES:
try:
parts.append(name + " " + hashlib.sha256((root / name).read_bytes()).hexdigest())
except OSError:
parts.append(name + " -")
return hashlib.sha256("\n".join(parts).encode("utf-8")).hexdigest()
def read_cpuid(path):
try:
return cpuid_values(path.read_bytes())
except OSError:
return {}
def ea_game_hardware(values, folder, sidecar):
chosen = {key: value for key, value in values.items() if key not in (EA_CPU64, EA_RUNTIME)}
wide = values.get(EA_CPU64)
exe = find_case(folder, str(sidecar.get("exe") or ""))
if isinstance(wide, dict) and exe is not None and exe.is_file():
pe = runpy.run_path(str(Path(__file__).resolve().parent / "droiddeck-wine-pe"))
if pe["pe_machine"](str(exe)) == 0x8664:
chosen.update(wide)
return chosen
def ea_hardware(compat_data, proton, timeout=240):
pfx = Path(compat_data) / "pfx"
cache = pfx / EA_HARDWARE
runtime = runtime_stamp(proton)
stale = {}
try:
cached = json.loads(cache.read_text())
if isinstance(cached, dict) and probe_complete(cached):
return cached, "cached"
if not runtime or cached.get(EA_RUNTIME) == runtime:
return cached, "cached"
stale = cached
except (OSError, ValueError):
pass
if not proton or not Path(proton).is_file():
if not runtime:
return {}, "no-proton"
values = {}
with tempfile.TemporaryDirectory(prefix="droiddeck-ea-") as tmp:
@@ -1369,17 +1440,18 @@ def ea_hardware(compat_data, proton, timeout=240):
lines.append('wmic path %s get %s > "%s"' % (cls, prop, windows_path(str(folder / (key + ".txt")))))
lines.append('vol C: > "%s"' % windows_path(str(folder / "volume.txt")))
lines.append('hostname > "%s"' % windows_path(str(folder / "hostname.txt")))
(folder / "cpuid.exe").write_bytes(cpuid_exe())
lines.append('"%s" > "%s"' % (windows_path(str(folder / "cpuid.exe")), windows_path(str(folder / "cpuid.bin"))))
for name, wide in (("cpuid", False), ("cpuid64", True)):
(folder / (name + ".exe")).write_bytes(cpuid_exe(wide))
lines.append('"%s" > "%s"' % (windows_path(str(folder / (name + ".exe"))), windows_path(str(folder / (name + ".bin")))))
bat = folder / "probe.bat"
bat.write_bytes(("\r\n".join(lines) + "\r\n").encode())
try:
subprocess.run([proton, "run", "cmd.exe", "/d", "/c", windows_path(str(bat))], stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, timeout=timeout)
except subprocess.TimeoutExpired:
return {}, "timeout"
return stale, "timeout"
except OSError:
return {}, "failed"
return stale, "failed"
for key, _, _ in EA_WMI:
try:
values[key] = wmi_value(decode_output((folder / (key + ".txt")).read_bytes()))
@@ -1394,17 +1466,18 @@ def ea_hardware(compat_data, proton, timeout=240):
values["hostname"] = decode_output((folder / "hostname.txt").read_bytes()).strip().splitlines()[0].strip()
except (OSError, IndexError):
values["hostname"] = ""
try:
values.update(cpuid_values((folder / "cpuid.bin").read_bytes()))
except OSError:
pass
if probe_complete(values):
values.update(read_cpuid(folder / "cpuid.bin"))
wide = read_cpuid(folder / "cpuid64.bin")
if wide:
values[EA_CPU64] = wide
if probe_complete(values) and probe_complete(values.get(EA_CPU64, {}), EA_CPU_FIELDS):
values[EA_RUNTIME] = runtime
try:
cache.write_text(json.dumps(values))
except OSError:
pass
return values, "probed"
return values, "incomplete"
return stale or values, "incomplete"
def ea_registry_entries(folder, sidecar):
@@ -1571,7 +1644,7 @@ def prepare_ea(folder, sidecar, compat_data, launch_dir, steam=None):
hardware, probe = ea_hardware(compat_data, proton) if ready else ({}, "no-prefix")
answer = None
if launch_dir:
request = {"op": "ea-prepare", "store": "ea", "id": game, "hardware": hardware}
request = {"op": "ea-prepare", "store": "ea", "id": game, "hardware": ea_game_hardware(hardware, folder, sidecar)}
if steam is not None:
request["steam"] = steam
answer = ask(Path(launch_dir) / "stores", request, timeout=40.0)
@@ -1691,10 +1764,11 @@ def prepare_steam_ea(argv, compat_data, launch_dir):
log("steam ea: no channel to DroidDeck, left to the EA app")
return 0
exe = manifest["exe"]
sidecar = {"store": "ea", "id": offers[0], "title": manifest["title"],
relative = str(exe.relative_to(folder))
sidecar = {"store": "ea", "id": offers[0], "title": manifest["title"], "exe": relative,
"extra": {"contentIds": ",".join(manifest["contentIds"]), "displayName": manifest["title"], "locale": "en_US"}}
steam = {"folder": str(folder), "offers": offers, "contentIds": manifest["contentIds"], "title": manifest["title"],
"version": manifest["version"], "locale": "en_US", "exe": str(exe.relative_to(folder))}
"version": manifest["version"], "locale": "en_US", "exe": relative}
answer = prepare_ea(folder, sidecar, compat_data, launch_dir, steam)
env = answer.get("env") if answer and answer.get("ok") else None
if not isinstance(env, dict):
+17 -42
View File
@@ -1161,7 +1161,6 @@ int system(const char *command) {
int status = -1;
pid_t pid = start_shell(command, -1, -1, &old, &intr, &quit, 0);
if (pid < 0) status = 127 << 8; // as glibc's system() when the shell could not be started
if (pid > 0) {
while (waitpid(pid, &status, 0) < 0) {
if (errno != EINTR) {
@@ -1193,52 +1192,28 @@ static pthread_mutex_t g_popen_lock = PTHREAD_MUTEX_INITIALIZER;
static pid_t start_shell(const char *command, int child_fd, int target_fd, const sigset_t *mask,
const struct sigaction *intr, const struct sigaction *quit, int close_popen_streams) {
// Through posix_spawn(), as glibc does: its child only makes system calls. A forked child running
// the exec code here would take locks that another thread of a multithreaded caller may have held
// at fork(), and wait for them forever (Steam's popen()s did, and its main loop stalled).
posix_spawn_file_actions_t actions;
posix_spawnattr_t attr;
if (posix_spawn_file_actions_init(&actions) != 0) return -1;
if (posix_spawnattr_init(&attr) != 0) {
posix_spawn_file_actions_destroy(&actions);
return -1;
}
int err = 0;
pid_t pid = fork();
if (pid != 0) return pid;
if (intr) sigaction(SIGINT, intr, NULL);
if (quit) sigaction(SIGQUIT, quit, NULL);
if (mask) sigprocmask(SIG_SETMASK, mask, NULL);
if (child_fd >= 0) {
// dup2 onto itself clears FD_CLOEXEC in the child (glibc 2.29 and later)
err = posix_spawn_file_actions_adddup2(&actions, child_fd, target_fd);
if (child_fd == target_fd) {
fcntl(target_fd, F_SETFD, 0);
} else if (dup2(child_fd, target_fd) < 0) {
_exit(127);
}
}
// POSIX: the streams of earlier popen() calls are not open in the new shell
for (struct ddnatv_popen *p = g_popen_streams; !err && close_popen_streams && p; p = p->next) {
int fd = fileno(p->fp);
if (fd >= 0 && fd != target_fd) err = posix_spawn_file_actions_addclose(&actions, fd);
if (close_popen_streams) {
for (struct ddnatv_popen *p = g_popen_streams; p; p = p->next) {
int fd = fileno(p->fp);
if (fd >= 0 && fd != target_fd) close(fd);
}
}
short flags = 0;
if (!err && mask) {
posix_spawnattr_setsigmask(&attr, mask);
flags |= POSIX_SPAWN_SETSIGMASK;
}
// SIGINT and SIGQUIT as they were before system() ignored them: an exec keeps an ignored signal
// ignored and puts a handled one back to the default
sigset_t defaults;
sigemptyset(&defaults);
if (intr && intr->sa_handler != SIG_IGN) sigaddset(&defaults, SIGINT);
if (quit && quit->sa_handler != SIG_IGN) sigaddset(&defaults, SIGQUIT);
if (!err && (intr || quit)) {
posix_spawnattr_setsigdefault(&attr, &defaults);
flags |= POSIX_SPAWN_SETSIGDEF;
}
if (!err) err = posix_spawnattr_setflags(&attr, flags);
pid_t pid = -1;
char *const argv[] = { (char *)"sh", (char *)"-c", (char *)command, NULL };
if (!err) err = posix_spawn(&pid, "/bin/sh", &actions, &attr, argv, environ);
posix_spawn_file_actions_destroy(&actions);
posix_spawnattr_destroy(&attr);
if (err) {
errno = err;
return -1;
}
return pid;
ddnatv_execve("/bin/sh", argv, environ, 0);
_exit(127);
}
FILE *popen(const char *command, const char *type) {
+1 -6
View File
@@ -6,7 +6,7 @@ import unittest
from pathlib import Path
RUN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin/droiddeck-appimage-run"
KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI", "QTWEBENGINE_DISABLE_SANDBOX")
KEYS = ("TU_DEBUG", "DROIDDECK_GAME_TU_DEBUG", "QT_QPA_PLATFORM", "WAYLAND_DISPLAY", "SDL_VIDEODRIVER", "XDG_SESSION_TYPE", "QT_WAYLAND_DISABLE_WINDOWDECORATION", "DISABLE_GAMESCOPE_WSI")
QUICK = ("usr/lib/libQt6Quick.so.6", "usr/lib/libvulkan.so.1", "usr/plugins/platforms/libqwayland-generic.so")
RUN_MODE = {"GAMESCOPE_WAYLAND_DISPLAY": "gamescope-0", "WAYLAND_DISPLAY": "gamescope-0", "DISPLAY": ":0",
"QT_QPA_PLATFORM": "xcb", "SDL_VIDEODRIVER": "x11", "XDG_SESSION_TYPE": "x11"}
@@ -128,11 +128,6 @@ class AppImageRunTest(unittest.TestCase):
self.assertEqual("wayland;xcb", env["QT_QPA_PLATFORM"])
def test_a_web_engine_app_starts_as_root_in_either_session(self):
for session in (RUN_MODE, DESKTOP):
env, _ = self.launch(session)
self.assertEqual("1", env["QTWEBENGINE_DISABLE_SANDBOX"])
def test_a_program_drops_the_sessions_sysmem_like_a_steam_game(self):
env, _ = self.launch(dict(RUN_MODE, TU_DEBUG="sysmem", DROIDDECK_GAME_TU_DEBUG=""))
self.assertEqual("unset", env["TU_DEBUG"])
-36
View File
@@ -1,36 +0,0 @@
import os
from pathlib import Path
import subprocess
import unittest
TOOLS = Path(__file__).resolve().parents[1]
DESKTOP = (TOOLS / "linuxfs/desktop/droiddeck-desktop").read_text()
PACKAGES = (TOOLS / "ubuntu/packages-desktop.txt").read_text().split()
SANDBOXES = ("MOZ_DISABLE_CONTENT_SANDBOX", "MOZ_SHM_NO_SEALS", "QTWEBENGINE_DISABLE_SANDBOX")
class DesktopRootAppsTest(unittest.TestCase):
def desktop_environment(self):
head = DESKTOP[:DESKTOP.index("\nexport KWIN_COMPOSE=")]
env = {k: v for k, v in os.environ.items() if k not in SANDBOXES}
probe = "".join('echo %s=${%s-unset}\n' % (name, name) for name in SANDBOXES)
result = subprocess.run(["bash", "-c", head + "\nsh -c '" + probe + "'"], env=env,
capture_output=True, text=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
return dict(line.split("=", 1) for line in result.stdout.splitlines())
def test_web_engine_apps_start_as_root_like_firefox(self):
self.assertEqual({name: "1" for name in SANDBOXES}, self.desktop_environment())
def test_the_sandbox_switches_are_set_before_plasma(self):
self.assertLess(DESKTOP.index("export QTWEBENGINE_DISABLE_SANDBOX=1"),
DESKTOP.index("dbus-run-session -- startplasma-wayland"))
def test_software_sources_gets_the_modules_it_imports(self):
self.assertIn("software-properties-qt", PACKAGES)
for module in ("pyqt6-dev-tools", "ubuntu-drivers-common"):
self.assertIn(module, PACKAGES)
if __name__ == "__main__":
unittest.main()
@@ -163,14 +163,6 @@ typedef struct {
#define droiddeck_log(...) ((void)0)
#define LOGE(...) ((void)0)
struct droiddeck_color { uint32_t identity; };
enum vkp_image_source {
VKP_IMAGE_SOURCE_NONE = 0,
VKP_IMAGE_SOURCE_DMABUF,
VKP_IMAGE_SOURCE_AHB_WLEGL,
VKP_IMAGE_SOURCE_AHB_SOURCE,
VKP_IMAGE_SOURCE_AHB_TARGET,
VKP_IMAGE_SOURCE_SHM
};
typedef struct AHardwareBuffer AHardwareBuffer;
'''
-129
View File
@@ -1,129 +0,0 @@
import os
import subprocess
import tempfile
import unittest
from pathlib import Path
from tools.tests.test_usr2_preload import runner
HOOK_BUILD = Path(__file__).resolve().parents[1] / "nativeguest/build.sh"
# The rootfs' /bin/sh for these tests: "sh -c 'echo WORDS'" prints WORDS, "sh -c 'exit N'" exits N.
SHELL = r"""
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv) {
if (argc < 3 || strcmp(argv[1], "-c") != 0) return 2;
if (strncmp(argv[2], "echo ", 5) == 0) {
puts(argv[2] + 5);
return 0;
}
if (strncmp(argv[2], "exit ", 5) == 0) return atoi(argv[2] + 5);
return 127;
}
"""
# posix_spawn() of argv[1] -c "exit 3", without the hook: prints the exit status it got
SPAWN_PROBE = r"""
#include <spawn.h>
#include <stdio.h>
#include <sys/wait.h>
extern char **environ;
int main(int argc, char **argv) {
pid_t pid;
char *args[] = {"sh", "-c", "exit 3", NULL};
int status = 0;
if (posix_spawn(&pid, argv[1], NULL, NULL, args, environ) != 0 || waitpid(pid, &status, 0) != pid) return 1;
printf("%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1);
return 0;
}
"""
# popen() and system() through the hook (which starts the shell with posix_spawn())
PROGRAM = r"""
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
int main(int argc, char **argv) {
if (strcmp(argv[1], "system") == 0) {
int status = system("exit 3");
printf("system\t%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1);
return 0;
}
// a second stream open while the first is read: the shell of the first must not hold it
FILE *other = popen("echo other", "r");
FILE *f = popen("echo from the shell", "r");
char line[64] = "";
if (f && !fgets(line, sizeof(line), f)) line[0] = 0;
line[strcspn(line, "\n")] = 0;
int status = f ? pclose(f) : -1;
if (other) pclose(other);
printf("popen\t%s\n", line);
printf("pclose\t%d\n", WIFEXITED(status) ? WEXITSTATUS(status) : -1);
return 0;
}
"""
class NativeHookPopenTest(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.cc, cls.prefix = runner()
if cls.cc is None:
raise unittest.SkipTest("no aarch64 compiler and runner")
cls.tmp = tempfile.TemporaryDirectory(dir="/tmp")
tmp = Path(cls.tmp.name)
cls.hook = tmp / "hook.so"
subprocess.run(["bash", str(HOOK_BUILD), str(cls.hook), cls.cc], check=True, capture_output=True)
cls.root = tmp / "root"
(cls.root / "bin").mkdir(parents=True)
(tmp / "sh.c").write_text(SHELL)
subprocess.run([cls.cc, "-static", "-O1", "-o", str(cls.root / "bin/sh"), str(tmp / "sh.c")], check=True)
# posix_spawn()'s child execs the shell itself. Under qemu-user that exec works only where the
# kernel runs aarch64 programs (binfmt_misc), which a plain x86 runner does not.
(tmp / "spawn.c").write_text(SPAWN_PROBE)
subprocess.run([cls.cc, "-static", "-O1", "-o", str(tmp / "spawn"), str(tmp / "spawn.c")], check=True)
probe = subprocess.run(list(cls.prefix or []) + [str(tmp / "spawn"), str(cls.root / "bin/sh")],
capture_output=True, text=True, timeout=60)
if probe.stdout.strip() != "3":
cls.tmp.cleanup()
raise unittest.SkipTest("this runner cannot exec an aarch64 program from a posix_spawn() child")
(tmp / "prog.c").write_text(PROGRAM)
cls.program = tmp / "prog"
subprocess.run([cls.cc, "-O1", "-o", str(cls.program), str(tmp / "prog.c")], check=True)
@classmethod
def tearDownClass(cls):
cls.tmp.cleanup()
def run_program(self, mode):
hook_env = {"DDNATV_ROOT": str(self.root), "LD_PRELOAD": str(self.hook)}
# Only what the program needs: other test modules in the same run change os.environ
env = {"PATH": os.environ.get("PATH", "/usr/bin:/bin")}
if self.prefix:
cmd = list(self.prefix) + [arg for key, value in hook_env.items() for arg in ("-E", f"{key}={value}")]
else:
cmd = []
env.update(hook_env)
out = subprocess.run(cmd + [str(self.program), mode], env=env, capture_output=True, text=True, timeout=60)
self.assertEqual(0, out.returncode, out.stderr)
return dict(line.split("\t", 1) for line in out.stdout.splitlines() if "\t" in line), out
def test_popen_reads_the_shells_output(self):
result, out = self.run_program("popen")
self.assertEqual("from the shell", result.get("popen"), out.stdout + out.stderr)
self.assertEqual("0", result.get("pclose"), out.stdout)
def test_system_returns_the_shells_status(self):
result, out = self.run_program("system")
self.assertEqual("3", result.get("system"), out.stdout + out.stderr)
if __name__ == "__main__":
unittest.main()
+26
View File
@@ -532,6 +532,32 @@ class SteamEa(unittest.TestCase):
self.assertEqual(0, store.main(['--exited', 'steam2ea://launchgame/1237970']))
self.assertEqual([{'op': 'ea-exited', 'store': 'ea', 'id': 'Origin.OFR.50.0001452'}], asked)
def test_a_steam_copy_is_sent_the_cpuid_of_its_exes_bitness(self):
narrow = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, cpuEcx='82d8230f')
values = dict(narrow, cpu64={'cpuEcx': 'bed8330f'}, runtime='stamp')
for image, expected in ((store.cpuid_exe(True), dict(narrow, cpuEcx='bed8330f')), (store.cpuid_exe(), narrow)):
with tempfile.TemporaryDirectory() as root:
folder, data = self.steam_copy(root)
(folder / 'Titanfall2.exe').write_bytes(image)
asked = []
def fake_ask(channel, request, timeout=5.0, claim=False):
asked.append(request)
return {'ok': True, 'id': 'Origin.OFR.50.0001452', 'env': {'EALsxPort': '3216'}}
env = {'STEAM_COMPAT_INSTALL_PATH': str(folder), 'STEAM_COMPAT_DATA_PATH': str(data),
'DD_LAUNCH_DIR': str(Path(root) / 'session'), 'DD_STORE_PROTON': ''}
with patch.dict(os.environ, env), patch.object(store, 'ask', side_effect=fake_ask), \
patch.object(store, 'create_prefix', return_value='present'), \
patch.object(store, 'install_origin_stub', return_value='ready'), \
patch.object(store, 'ea_hardware', return_value=(values, 'cached')), \
patch.object(store, 'ea_registry', return_value='ready'), \
patch.object(store, 'ea_touchup', return_value='none'):
self.assertEqual(store.REPLACED, store.main(['steam2ea://launchgame/1237970']))
self.assertEqual('ea-prepare', asked[0]['op'])
self.assertEqual('Titanfall2.exe', asked[0]['steam']['exe'])
self.assertEqual(expected, asked[0]['hardware'])
def test_the_manifests_launch_parameters_keep_their_quotes(self):
with tempfile.TemporaryDirectory() as root:
folder, data = self.steam_copy(root)
+155
View File
@@ -3,6 +3,8 @@ import importlib.machinery
import importlib.util
import json
from pathlib import Path
import re
import struct
import subprocess
import tempfile
import unittest
@@ -15,6 +17,53 @@ store = importlib.util.module_from_spec(spec)
loader.exec_module(store)
def called_imports(exe):
wide = struct.unpack_from('<H', exe, 0x58)[0] == 0x20B
base = struct.unpack_from('<Q', exe, 0x58 + 24)[0] if wide else struct.unpack_from('<I', exe, 0x58 + 28)[0]
dirs = 0x58 + struct.unpack_from('<H', exe, 0x54)[0] - 128
raw = lambda rva: 0x200 + rva - 0x1000
ilt, _, _, dll, iat = struct.unpack_from('<IIIII', exe, raw(struct.unpack_from('<I', exe, dirs + 8)[0]))
thunk = 8 if wide else 4
slots = {}
for i in range(3):
hint = struct.unpack_from('<Q' if wide else '<I', exe, raw(iat) + thunk * i)[0]
if hint != struct.unpack_from('<Q' if wide else '<I', exe, raw(ilt) + thunk * i)[0]:
return None
slots[iat + thunk * i] = exe[raw(hint) + 2:].split(b'\0')[0]
code = exe[0x200:0x300]
called = []
for at in range(len(code) - 6):
if code[at:at + 2] == b'\xff\x15':
value = struct.unpack_from('<i' if wide else '<I', code, at + 2)[0]
called.append(slots.get(0x1000 + at + 6 + value if wide else value - base))
return exe[raw(dll):].split(b'\0')[0], called
PROBE_NARROW = bytes.fromhex('1600000047656e756e74656c696e654961060a00000805000f23d882fffb8b27436f727465782d4135323000000000000000000000000000000000000000000000000000000000000000000000000000')
PROBE_WIDE = bytearray(PROBE_NARROW)
PROBE_WIDE[16 + 8:16 + 12] = bytes.fromhex('0f33d8be')
def fake_probe(wide):
def run(argv, **kwargs):
bat = Path(argv[-1][2:].replace('\\', '/'))
for line in bat.read_text().splitlines():
found = re.search(r'"?([^"]*)"? > "([^"]*)"$', line)
if not found:
continue
source, out = found.group(1), Path(found.group(2)[2:].replace('\\', '/'))
if source.endswith('cpuid64.exe'):
if wide is not None:
out.write_bytes(wide)
elif source.endswith('cpuid.exe'):
out.write_bytes(PROBE_NARROW)
elif source.startswith('vol'):
out.write_text(' Volume Serial Number is 1A2B-3C4D\r\n')
else:
out.write_text('Header\r\nvalue\r\n')
return run
class EaHook(unittest.TestCase):
def test_wmi_output_reads_the_value_under_the_header(self):
text = 'Manufacturer \r\r\nThe Wine Project \r\r\n\r\r\n'
@@ -101,6 +150,112 @@ class EaHook(unittest.TestCase):
self.assertEqual(struct.unpack_from('<H', exe, 0x58 + 68)[0], 3)
self.assertIn(b'KERNEL32.dll', exe)
self.assertEqual(len(exe), 0x400)
self.assertEqual(called_imports(exe), (b'KERNEL32.dll', [b'GetStdHandle', b'WriteFile', b'ExitProcess']))
def test_cpuid_probe_has_a_64_bit_form_that_writes_the_same_leaves(self):
exe = store.cpuid_exe(True)
self.assertEqual(exe[:2], b'MZ')
self.assertEqual(struct.unpack_from('<H', exe, 0x44)[0], 0x8664)
self.assertEqual(struct.unpack_from('<H', exe, 0x58)[0], 0x20B)
self.assertEqual(struct.unpack_from('<H', exe, 0x58 + 68)[0], 3)
self.assertEqual(len(exe), 0x400)
self.assertEqual(called_imports(exe), (b'KERNEL32.dll', [b'GetStdHandle', b'WriteFile', b'ExitProcess']))
code = exe[0x200:0x300]
self.assertEqual(code.count(b'\x0f\xa2'), len(store.CPUID_LEAVES))
loads = {}
for at in range(len(code) - 7):
if code[at:at + 3] in (b'\x48\x8d\x3d', b'\x48\x8d\x15', b'\x4c\x8d\x0d'):
loads[code[at:at + 3]] = at + 7 + struct.unpack_from('<i', code, at + 3)[0]
self.assertEqual(loads[b'\x48\x8d\x3d'], loads[b'\x48\x8d\x15'])
self.assertGreaterEqual(loads[b'\x4c\x8d\x0d'], loads[b'\x48\x8d\x15'] + 16 * len(store.CPUID_LEAVES))
self.assertLessEqual(loads[b'\x4c\x8d\x0d'] + 4, 0x200)
self.assertFalse(any(exe[0x200 + loads[b'\x48\x8d\x15']:0x200 + loads[b'\x4c\x8d\x0d'] + 4]))
self.assertEqual(store.cpuid_exe(False), store.cpuid_exe())
def test_each_game_is_sent_the_cpuid_of_its_own_bitness(self):
narrow = {'cpuVendor': 'GenuineIntel', 'cpuEax': '000A0661', 'cpuEdx': '278BFBFF', 'cpuEcx': '82d8230f', 'cpuBrand': 'Cortex-A520'}
probe = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, **narrow)
values = dict(probe, cpu64=dict(narrow, cpuEcx='bed8330f'), runtime='stamp')
with tempfile.TemporaryDirectory() as tmp:
folder = Path(tmp)
(folder / 'Game64.exe').write_bytes(store.cpuid_exe(True))
(folder / 'bin').mkdir()
(folder / 'bin/Game32.exe').write_bytes(store.cpuid_exe())
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'game64.exe'}), dict(probe, cpuEcx='bed8330f'))
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'bin/Game32.exe'}), probe)
self.assertEqual(store.ea_game_hardware(values, folder, {'exe': 'Missing.exe'}), probe)
self.assertEqual(store.ea_game_hardware(values, folder, {}), probe)
self.assertEqual(store.ea_game_hardware(probe, folder, {'exe': 'Game64.exe'}), probe)
def test_a_probe_from_another_proton_or_fex_build_is_taken_again(self):
with tempfile.TemporaryDirectory() as tmp:
proton = Path(tmp) / 'tool/proton'
fex = proton.parent / 'files/lib/wine/aarch64-windows/libwow64fex.dll'
fex.parent.mkdir(parents=True)
proton.write_text('')
(proton.parent / 'version').write_text('1 experimental-11.0')
fex.write_bytes(b'fex 1')
runtime = store.runtime_stamp(str(proton))
self.assertTrue(runtime)
self.assertEqual(store.runtime_stamp(str(proton)), runtime)
self.assertEqual(store.runtime_stamp(''), '')
compat = Path(tmp) / 'compat'
(compat / 'pfx').mkdir(parents=True)
cached = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, runtime=runtime)
(compat / 'pfx' / store.EA_HARDWARE).write_text(json.dumps(cached))
with patch.object(store.subprocess, 'run', side_effect=AssertionError('probed again')):
self.assertEqual(store.ea_hardware(str(compat), str(proton)), (cached, 'cached'))
self.assertEqual(store.ea_hardware(str(compat), ''), (cached, 'cached'))
fex.write_bytes(b'fex 2')
self.assertNotEqual(store.runtime_stamp(str(proton)), runtime)
with patch.object(store.subprocess, 'run', side_effect=OSError) as run:
self.assertEqual(store.ea_hardware(str(compat), str(proton)), (cached, 'failed'))
run.assert_called_once()
(proton.parent / 'version').write_text('2 experimental-11.0')
self.assertNotEqual(store.runtime_stamp(str(proton)), runtime)
def test_the_probe_records_both_bitnesses_and_the_runtime(self):
with tempfile.TemporaryDirectory() as tmp:
proton = Path(tmp) / 'tool/proton'
proton.parent.mkdir()
proton.write_text('')
compat = Path(tmp) / 'compat'
(compat / 'pfx').mkdir(parents=True)
with patch.object(store.subprocess, 'run', side_effect=fake_probe(bytes(PROBE_WIDE))):
values, how = store.ea_hardware(str(compat), str(proton))
self.assertEqual(how, 'probed')
self.assertEqual(values['cpuEcx'], '82d8230f')
self.assertEqual(values['cpu64']['cpuEcx'], 'bed8330f')
self.assertEqual(values['volumeSerial'], '1a2b3c4d')
self.assertEqual(values['runtime'], store.runtime_stamp(str(proton)))
self.assertEqual(json.loads((compat / 'pfx' / store.EA_HARDWARE).read_text()), values)
def test_a_failed_64_bit_probe_keeps_the_old_cache_and_is_retried(self):
with tempfile.TemporaryDirectory() as tmp:
proton = Path(tmp) / 'tool/proton'
proton.parent.mkdir()
proton.write_text('')
compat = Path(tmp) / 'compat'
(compat / 'pfx').mkdir(parents=True)
cache = compat / 'pfx' / store.EA_HARDWARE
for wide in (None, PROBE_NARROW[:40]):
with patch.object(store.subprocess, 'run', side_effect=fake_probe(wide)):
values, how = store.ea_hardware(str(compat), str(proton))
self.assertEqual(how, 'incomplete')
self.assertEqual(values['cpuEcx'], '82d8230f')
self.assertNotIn('cpu64', values)
self.assertNotIn('runtime', values)
self.assertFalse(cache.exists())
stale = dict({key: 'x' for key in store.EA_PROBE_FIELDS}, cpu64={'cpuEcx': 'bed8330f'}, runtime='old')
cache.write_text(json.dumps(stale))
with patch.object(store.subprocess, 'run', side_effect=fake_probe(None)):
self.assertEqual(store.ea_hardware(str(compat), str(proton)), (stale, 'incomplete'))
self.assertEqual(json.loads(cache.read_text()), stale)
with patch.object(store.subprocess, 'run', side_effect=fake_probe(bytes(PROBE_WIDE))):
values, how = store.ea_hardware(str(compat), str(proton))
self.assertEqual(how, 'probed')
self.assertEqual(values['cpu64']['cpuEcx'], 'bed8330f')
self.assertEqual(json.loads(cache.read_text()), values)
def test_origin_stub_is_a_windowless_program_installed_once(self):
import struct
@@ -1,127 +0,0 @@
import os
from pathlib import Path
import re
import shutil
import subprocess
import tempfile
import unittest
from tools.tests.test_vk_pending_completion import function
SOURCE = Path(__file__).resolve().parents[2] / "app/src/main/cpp/waylandcomp/src/vk_present.c"
HARNESS = r'''
#include <assert.h>
#include <stddef.h>
#include <stdint.h>
typedef int VkResult;
typedef uintptr_t VkPhysicalDevice;
typedef uintptr_t VkDevice;
#define VK_SUCCESS 0
#define VK_ERROR_INITIALIZATION_FAILED -3
#define VK_ERROR_NOT_PERMITTED_EXT -1000174001
#define VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT 1000174000
#define VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT 256
#define VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT 512
typedef struct { int sType; const void *pNext; int globalPriority; } VkDeviceQueueGlobalPriorityCreateInfoEXT;
typedef struct { int sType; const void *pNext; uint32_t queueFamilyIndex; uint32_t queueCount;
const float *pQueuePriorities; } VkDeviceQueueCreateInfo;
typedef struct { int sType; const void *pNext; uint32_t queueCreateInfoCount;
const VkDeviceQueueCreateInfo *pQueueCreateInfos; } VkDeviceCreateInfo;
static VkPhysicalDevice g_pd = 7;
static VkDevice g_dev;
static int calls, logs, high_seen[4];
static VkResult answers[4];
static VkResult fake_create(VkPhysicalDevice pd, const VkDeviceCreateInfo *dci, const void *alloc, VkDevice *out) {
assert(pd == 7 && !alloc && dci->queueCreateInfoCount == 1);
const VkDeviceQueueGlobalPriorityCreateInfoEXT *gp = dci->pQueueCreateInfos[0].pNext;
if (gp) assert(gp->sType == VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT && !gp->pNext);
high_seen[calls] = gp ? gp->globalPriority : VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT;
const VkResult r = answers[calls++];
if (r == VK_SUCCESS) *out = 42;
return r;
}
static struct { VkResult (*CreateDevice)(VkPhysicalDevice, const VkDeviceCreateInfo *, const void *, VkDevice *); } g_vk = {
fake_create};
static const char *vk_result_name(VkResult r) { (void)r; return "result"; }
static void droiddeck_log(const char *tag, const char *fmt, ...) { (void)tag; (void)fmt; logs++; }
%(create_device)s
static VkDeviceQueueCreateInfo qci;
static VkDeviceCreateInfo dci = {.queueCreateInfoCount = 1, .pQueueCreateInfos = &qci};
static VkResult run(int *high, VkResult first, VkResult second) {
calls = logs = 0;
g_dev = 0;
answers[0] = first;
answers[1] = second;
high_seen[0] = high_seen[1] = 0;
const VkResult r = create_device(&dci, &qci, high);
assert(qci.pNext == NULL);
return r;
}
int main(void) {
int high = 1;
assert(run(&high, VK_SUCCESS, -99) == VK_SUCCESS);
assert(calls == 1 && high_seen[0] == VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT && high == 1 && logs == 0 && g_dev == 42);
high = 1;
assert(run(&high, VK_ERROR_NOT_PERMITTED_EXT, VK_SUCCESS) == VK_SUCCESS);
assert(calls == 2 && high_seen[0] == VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT);
assert(high_seen[1] == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT && high == 0 && logs == 1 && g_dev == 42);
assert(run(&high, VK_SUCCESS, -99) == VK_SUCCESS);
assert(calls == 1 && high_seen[0] == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT && logs == 0);
high = 1;
assert(run(&high, VK_ERROR_INITIALIZATION_FAILED, VK_SUCCESS) == VK_SUCCESS);
assert(calls == 2 && high == 0 && high_seen[1] == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT);
high = 1;
assert(run(&high, VK_ERROR_INITIALIZATION_FAILED, VK_ERROR_INITIALIZATION_FAILED) ==
VK_ERROR_INITIALIZATION_FAILED);
assert(calls == 2 && high == 1 && logs == 0 && g_dev == 0);
assert(high_seen[0] == VK_QUEUE_GLOBAL_PRIORITY_HIGH_EXT && high_seen[1] == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT);
high = 0;
assert(run(&high, VK_ERROR_INITIALIZATION_FAILED, VK_SUCCESS) == VK_ERROR_INITIALIZATION_FAILED);
assert(calls == 1 && high_seen[0] == VK_QUEUE_GLOBAL_PRIORITY_MEDIUM_EXT && logs == 0);
return 0;
}
'''
class CompositorQueuePriorityTest(unittest.TestCase):
def test_high_priority_is_requested_and_dropped_when_the_driver_refuses_it(self):
compiler = shutil.which(os.environ.get("CC", "cc"))
if not compiler:
self.fail("A C compiler is required for the compositor queue priority test")
body = function(SOURCE.read_text(), "create_device")
with tempfile.TemporaryDirectory(prefix="droiddeck-queue-priority-") as tmp:
source = Path(tmp) / "queue_priority_test.c"
source.write_text(HARNESS % {"create_device": body})
program = Path(tmp) / "queue-priority"
built = subprocess.run([compiler, "-std=c11", "-Wall", "-Wextra", "-Werror", "-UNDEBUG", str(source),
"-o", str(program)], capture_output=True, text=True)
self.assertEqual(built.returncode, 0, built.stdout + built.stderr)
ran = subprocess.run([str(program)], capture_output=True, text=True, timeout=30)
self.assertEqual(ran.returncode, 0, ran.stdout + ran.stderr)
def test_the_priority_extension_is_enabled_only_when_advertised_and_every_device_uses_it(self):
text = SOURCE.read_text()
self.assertEqual(len(re.findall(r"g_vk\.CreateDevice\(", text)), 2)
self.assertEqual(len(re.findall(r"g_vk\.CreateDevice\(", function(text, "create_device"))), 2)
self.assertEqual(len(re.findall(r"create_device\(&dci, &qci, &high_priority\)", text)), 2)
self.assertRegex(text, r'has_ext\(exts, ne, "VK_KHR_global_priority"\)')
self.assertRegex(text, r"has_ext\(exts, ne, VK_EXT_GLOBAL_PRIORITY_EXTENSION_NAME\)")
self.assertRegex(text, r"if \(priority_ext\) dev_exts\[n_dev_exts\+\+\] = priority_ext;")
self.assertRegex(text, r"int high_priority = priority_ext != NULL;")
if __name__ == "__main__":
unittest.main()
-8
View File
@@ -20,14 +20,6 @@ LAYER_HARNESS = r'''
#include "vk_linear_dmabuf.h"
typedef struct AHardwareBuffer AHardwareBuffer;
enum vkp_image_source {
VKP_IMAGE_SOURCE_NONE = 0,
VKP_IMAGE_SOURCE_DMABUF,
VKP_IMAGE_SOURCE_AHB_WLEGL,
VKP_IMAGE_SOURCE_AHB_SOURCE,
VKP_IMAGE_SOURCE_AHB_TARGET,
VKP_IMAGE_SOURCE_SHM
};
%(image)s
struct vkp_draw {
struct vkp_image *img;
+2 -23
View File
@@ -31,10 +31,8 @@ def function(text, name):
HARNESS = r'''
#include <assert.h>
#include <stdint.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
typedef int VkResult;
typedef uintptr_t VkFence;
#define VK_TRUE 1
@@ -71,31 +69,12 @@ static struct {
typedef struct AHardwareBuffer AHardwareBuffer;
static int released_buffers;
static void AHardwareBuffer_release(AHardwareBuffer *b) { (void)b; ++released_buffers; }
enum vkp_image_source {
VKP_IMAGE_SOURCE_NONE = 0,
VKP_IMAGE_SOURCE_DMABUF,
VKP_IMAGE_SOURCE_AHB_WLEGL,
VKP_IMAGE_SOURCE_AHB_SOURCE,
VKP_IMAGE_SOURCE_AHB_TARGET,
VKP_IMAGE_SOURCE_SHM
};
struct vkp_image {
uintptr_t image, mem;
void *map;
AHardwareBuffer *android_buffer;
uintptr_t linear_buf, linear_mem;
int staged, in_general;
enum vkp_image_source source_type;
int source_fd;
uint8_t *recovery_pixels;
struct vkp_image *next;
};
static void image_unregister(struct vkp_image *img) { (void)img; }
struct vkp_image { uintptr_t image, mem; void *map; AHardwareBuffer *android_buffer; uintptr_t linear_buf, linear_mem; int staged, in_general; };
static void blendp_forget_image(uintptr_t image) { (void)image; ++forgotten; }
/* PRODUCTION_FUNCTIONS */
static struct vkp_image *image(void) {
struct vkp_image *p = calloc(1, sizeof(*p)); assert(p);
p->image=1; p->mem=2; p->map=p; p->source_fd=-1; return p;
p->image=1; p->mem=2; p->map=p; return p;
}
int main(void) {
g_dev_state=1; answer=VK_SUCCESS;
-6
View File
@@ -117,9 +117,6 @@ int __android_log_print(int, const char *, const char *, ...);
def test_finite_blit_timeout_same_size_pixel_upload(self):
self.run_scenario('pixel-timeout')
def test_lost_device_shm_upload_keeps_cpu_snapshot(self):
self.run_scenario('lost-shm-upload')
def test_normal_present(self):
self.run_scenario('normal')
@@ -129,9 +126,6 @@ int __android_log_print(int, const char *, const char *, ...);
def test_healthy_later_acquire_timeout_drains_work(self):
self.run_scenario('later-timeout')
def test_device_loss_with_unconfirmed_idle_retains_resources(self):
self.run_scenario('acquire-device-lost-unconfirmed')
def test_real_device_lost_on_acquire(self):
self.run_scenario('acquire-device-lost')
+6 -44
View File
@@ -38,11 +38,7 @@ static void blit(VkCommandBuffer c, VkImage s, VkImageLayout sl, VkImage d, VkIm
uint32_t n, const VkImageBlit *b, VkFilter f) { live(); }
static void destroy_swap(VkDevice d, VkSwapchainKHR s, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_surface(VkInstance i, VkSurfaceKHR s, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_fence(VkDevice d, VkFence f, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_pool(VkDevice d, VkCommandPool p, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_device(VkDevice d, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_instance(VkInstance i, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_sem(VkDevice d, VkSemaphore s, const VkAllocationCallbacks *a) { ++destroys; }
static void destroy_sem(VkDevice d, VkSemaphore s, const VkAllocationCallbacks *a) { live(); ++destroys; }
static VkResult create_sem(VkDevice d, const VkSemaphoreCreateInfo *c, const VkAllocationCallbacks *a, VkSemaphore *s) {
live(); *s = (VkSemaphore)(uintptr_t)1; return VK_SUCCESS;
}
@@ -65,17 +61,15 @@ int sc_layer_base_black(int w, int h) { return 0; }
void sc_layer_hide_base(void) {}
void sc_layer_hide_overlay(void) {}
void vkp_cardboard_bind_device(VkDevice d, const VkPhysicalDeviceMemoryProperties *m) {}
void vkp_cardboard_destroy(void) {}
int vkp_cardboard_active(void) { return 0; }
void vkp_cardboard_begin_frame(void) {}
VkImage vkp_cardboard_run(VkCommandBuffer c, VkImage s, int sw, int sh, int ow, int oh) { return s; }
int vk_loader_open(const char *a, const char *b, const char *c) { return -1; }
void vk_loader_close(void) {}
void vk_loader_load_instance(VkInstance i) {}
void vk_loader_load_device(VkDevice d) {}
int vk_loader_open(const char *a, const char *b, const char *c) { assert(0); return -1; }
void vk_loader_close(void) { assert(0); }
void vk_loader_load_instance(VkInstance i) { assert(0); }
void vk_loader_load_device(VkDevice d) { assert(0); }
PFN_vkGetInstanceProcAddr vk_loader_gipa(void) { return NULL; }
void vkp_effects_bind_device(VkDevice d, VkPhysicalDevice p, const VkPhysicalDeviceMemoryProperties *m) {}
void vkp_effects_destroy(void) {}
int vkp_effects_active(void) { return 0; }
int vkp_effects_upscaling(void) { return 0; }
int vkp_effects_sharpening(void) { return 0; }
@@ -100,11 +94,9 @@ void vkp_framegen_presented(int n) { ++presented_notifications; }
void vkp_gpu_busy_device(VkPhysicalDevice p, VkDevice d, uint32_t f) {}
void vkp_gpu_busy_device_lost(void) {}
void hdrc_bind_device(VkDevice d, const VkPhysicalDeviceMemoryProperties *m) {}
void hdrc_destroy(void) {}
void hdrc_forget_image(VkImage i) {}
int hdrc_encode(VkCommandBuffer c, VkImage a, VkImage b, VkFormat f, int w, int h, const struct hdrc_params *p) { return -1; }
void blendp_bind_device(VkDevice d) {}
void blendp_destroy(void) {}
void blendp_forget_image(VkImage i) {}
void vkp_effects_forget_image(VkImage i) {}
void blendp_begin_frame(void) {}
@@ -163,8 +155,6 @@ static void setup(int extra) {
.ResetCommandBuffer = reset_cmd, .ResetFences = reset_fence, .BeginCommandBuffer = begin_cmd,
.EndCommandBuffer = end_cmd, .CmdPipelineBarrier = barrier, .CmdClearColorImage = clear,
.CmdBlitImage = blit, .DestroySwapchainKHR = destroy_swap, .DestroySurfaceKHR = destroy_surface,
.DestroyFence = destroy_fence, .DestroyCommandPool = destroy_pool,
.DestroyDevice = destroy_device, .DestroyInstance = destroy_instance,
.DestroySemaphore = destroy_sem, .CreateSemaphore = create_sem,
.DestroyImage = destroy_image, .FreeMemory = free_memory, .UnmapMemory = unmap};
idle_answer = fence_answer = acquire_answer = present_answer = VK_SUCCESS;
@@ -190,7 +180,6 @@ static void setup(int extra) {
/* Probe the public GPU entry points after a terminal result. This includes an
* active off-screen pass and consumed release fds, not just the render guard. */
static void assert_stopped(void) {
assert(g_dev_state == -3 || (g_dev_state == -2 && g_recovery_attempted));
unsigned before = operations, before_destroys = destroys;
struct vkp_image src = {.image = (VkImage)(uintptr_t)7, .w = 1, .h = 1};
struct vkp_image dst = {.image = (VkImage)(uintptr_t)8, .w = 1, .h = 1, .blit_dst = 1};
@@ -279,20 +268,7 @@ int main(int argc, char **argv) {
else if (!strcmp(name, "later-surface-lost")) acquire_failure(1, VK_ERROR_SURFACE_LOST_KHR);
else if (!strcmp(name, "shm-timeout")) upload_timeout(0);
else if (!strcmp(name, "pixel-timeout")) upload_timeout(1);
else if (!strcmp(name, "lost-shm-upload")) {
setup(0);
uint8_t bytes[64], data[16];
memset(bytes, 0xa5, sizeof(bytes));
for (unsigned i = 0; i < sizeof(data); i++) data[i] = (uint8_t)(i + 1);
struct vkp_image img = {.map = bytes, .offset = 3, .row_pitch = 16, .w = 2, .h = 2,
.source_type = VKP_IMAGE_SOURCE_SHM};
g_dev_state = -2;
vkp_image_upload_shm(&img, data, 8);
assert(img.recovery_pixels && !memcmp(img.recovery_pixels, data, sizeof(data)));
assert(bytes[3] == 0xa5 && bytes[19] == 0xa5);
free(img.recovery_pixels);
free(g_images);
} else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); }
else if (!strcmp(name, "pass-terminal")) { setup(0); g_dev_state = -3; assert_stopped(); free(g_images); }
else if (!strcmp(name, "normal") || !strcmp(name, "framegen")) {
int extra = !strcmp(name, "framegen"); setup(extra);
assert(vkp_render(64, 64, NULL, 0) == 0 && g_dev_state == 1);
@@ -303,18 +279,6 @@ int main(int argc, char **argv) {
setup(1); fail_acquire_at = 2; acquire_answer = VK_TIMEOUT;
assert(vkp_render(64, 64, NULL, 0) == -1 && g_dev_state == 1);
assert(acquires == 2 && submits == 2 && markers == 1 && waits == 1); free(g_images);
} else if (!strcmp(name, "acquire-device-lost-unconfirmed")) {
setup(1);
fail_acquire_at = 2;
acquire_answer = VK_ERROR_DEVICE_LOST;
idle_answer = VK_ERROR_OUT_OF_HOST_MEMORY;
VkImage *retained = g_images;
assert(vkp_render(64, 64, NULL, 0) == -1);
assert(g_dev_state == -3 && vkp_completion_unknown() && !vkp_device_lost());
assert(idle_calls == 1 && lost_notifications == 0 && waits == 0);
assert(g_images == retained && g_nimg == 1 && g_swapchain && g_surface && destroys == 0);
assert_stopped();
free(g_images); /* test-owned fake resources only */
} else if (!strcmp(name, "acquire-device-lost") || !strcmp(name, "present-device-lost")) {
setup(1);
if (!strcmp(name, "acquire-device-lost")) { fail_acquire_at = 2; acquire_answer = VK_ERROR_DEVICE_LOST; }
@@ -323,8 +287,6 @@ int main(int argc, char **argv) {
assert(!vkp_completion_unknown());
assert(g_dev_state == -2 && lost_notifications == 1 && markers == 0 && waits == 0);
assert(!g_images && !g_swapchain && !g_surface && destroys == 2);
assert(vkp_ready() == -1);
assert(g_dev_state == -2 && g_recovery_attempted);
assert_stopped();
} else assert(0 && "unknown scenario");
return 0;
-2
View File
@@ -215,7 +215,6 @@ power-profiles-daemon
powerdevil
ppa-purge
print-manager
pyqt6-dev-tools
python3-dbus
python3-launchpadlib
python3-setuptools
@@ -242,7 +241,6 @@ software-properties-qt
squashfs-tools
synaptic
systemsettings
ubuntu-drivers-common
udisks2
unrar-free
upower