Experimental Samsung Xclipse support on the system Vulkan path

Detect Samsung's Vulkan HAL (vulkan.samsung.so) and its sgpu render node
alongside PowerVR, and run Xclipse through the same libhybris bridge:

- VK_LAYER_DROIDDECK_xclipse (tools/linuxfs/xclipse-layer), built with the
  glibc preloads and enabled only on Xclipse: sets bionic's environ for the
  driver's shader compiler, avoids immutable YCbCr samplers in compute
  layouts, forwards the KHR calibrated-timestamp entry points to the EXT
  ones, and reports textureCompressionBC and BC4/BC5 filtering over the
  compat layer's BC emulation.
- Upstream DXVK 2.6.2, pinned as a tar.gz component and selected on Xclipse:
  the driver has 128 bytes of push constants, DXVK 3 needs 256.
- android_wlegl accepts a zero stride and passes it through unchanged:
  Samsung's gralloc records none for GPU-only buffers.

Tested on a Galaxy A56 (Xclipse 540, driver 24.0.560): Steam Big Picture
and PICO PARK (D3D9).
This commit is contained in:
Stefan Zijlstra committed 2026-10-12 05:55:57 +02:00
1 parent d33715ca8a
commit b93141b757
21 files changed
+793 -30

No files matched your search

+6 -1
View File
@@ -13,7 +13,7 @@ else
fi
sdk_dir=${ANDROID_HOME:-${ANDROID_SDK_ROOT:-"${HOME}/Library/Android/sdk"}}
java_dir=${JAVA_HOME:-"/opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk/Contents/Home"}
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
image_name=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v4}
build_variant=${DROIDDECK_BUILD_VARIANT:-release}
case "$build_variant" in
debug) gradle_task=assembleDebug ;;
@@ -100,6 +100,11 @@ docker run --rm --platform linux/amd64 \
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -pthread \
-o "$d/libssbs.so" tools/linuxfs/ssbs/ssbs_adapter.c -ldl
aarch64-linux-gnu-strip --strip-unneeded "$d/libssbs.so"
mkdir -p "$d/usr/local/lib/droiddeck-xclipse"
aarch64-linux-gnu-gcc -shared -fPIC -O2 -Wall -Wextra -Wno-unused-parameter -fvisibility=hidden -pthread \
-o "$d/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so" tools/linuxfs/xclipse-layer/xclipse_layer.c -ldl
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so"
install -m644 tools/linuxfs/xclipse-layer/VkLayer_droiddeck_xclipse.json "$d/usr/local/lib/droiddeck-xclipse/"
mkdir -p "$d/usr/local/bin"
aarch64-linux-gnu-gcc -O2 -Wall -Wextra -o "$d/usr/local/bin/droiddeck-clipboard" tools/linuxfs/clipboard/clipboard.c -ldl
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-clipboard"
+7 -1
View File
@@ -11,6 +11,7 @@ change synchronization settings, or provide game-specific workarounds.
"""
import argparse
import os
from pathlib import Path
import sys
@@ -58,7 +59,12 @@ def main():
parser.error("expected: PROTON waitforexitandrun GAME [ARGUMENTS...]")
proton = Path(args.proton)
dxvk = Path(__file__).resolve().parent / "dxvk"
# A sibling payload directory by name (dxvk-2.6.2 for Xclipse); never a path.
name = os.environ.get("DROIDDECK_HYBRIS_DXVK") or "dxvk"
if not name.startswith("dxvk") or "/" in name or name.startswith("."):
print(f"DroidDeck DXVK profile: invalid payload name {name!r}", file=sys.stderr)
return 1
dxvk = Path(__file__).resolve().parent / name
try:
code = prepare(proton, dxvk)
except (OSError, ValueError, SyntaxError) as error:
+5
View File
@@ -31,5 +31,10 @@ SSBS=$(syms "$D/libssbs.so")
for sym in sigaction signal bsd_signal sysv_signal; do
grep -qx "$sym" <<<"$SSBS" || { echo "::error::libssbs.so does not export $sym"; exit 1; }
done
XCLIPSE=$(syms "$D/usr/local/lib/droiddeck-xclipse/libVkLayer_droiddeck_xclipse.so")
for sym in vkNegotiateLoaderLayerInterfaceVersion vkGetInstanceProcAddr vkGetDeviceProcAddr; do
grep -qx "$sym" <<<"$XCLIPSE" || { echo "::error::the Xclipse layer does not export $sym"; exit 1; }
done
test -f "$D/usr/local/lib/droiddeck-xclipse/VkLayer_droiddeck_xclipse.json"
test -f "$D/usr/local/bin/droiddeck-session"
test -f "$D/usr/local/bin/droiddeck-proton-extra"
@@ -287,10 +287,14 @@ def system_graphics_launch(command, env):
directory = Path(runtime)
if not directory.is_absolute():
raise SystemGraphicsError("system Vulkan runtime path is not absolute")
# run-proton.py picks the same payload by name; Xclipse needs a DXVK within 128 bytes of push data.
payload = env.get("DROIDDECK_HYBRIS_DXVK") or "dxvk"
if not payload.startswith("dxvk") or "/" in payload:
raise SystemGraphicsError("invalid DXVK payload name: %s" % payload)
required = (
"run-proton.py", "wsi/libVkLayer_window_system_integration.so",
"wsi/VkLayer_window_system_integration.json", "lib/libVkLayer_hybris_compat.so",
*("dxvk/%s/%s.dll" % (arch, name) for arch in ("x32", "x64")
*("%s/%s/%s.dll" % (payload, arch, name) for arch in ("x32", "x64")
for name in ("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi")),
)
try:
@@ -304,10 +308,12 @@ def system_graphics_launch(command, env):
except OSError as error:
raise SystemGraphicsError("system Vulkan component is unreadable: %s" % error) from error
result = dict(env)
layers = "VK_LAYER_window_system_integration:" + env.get("DROIDDECK_HYBRIS_LAYERS", "VK_LAYER_HYBRIS_compat")
result.update({
"HYBRIS_BC_TEXTURES": "dxvk",
"VK_LAYER_PATH": "%s:%s" % (directory / "wsi", directory / "lib"),
"VK_INSTANCE_LAYERS": "VK_LAYER_window_system_integration:VK_LAYER_HYBRIS_compat",
"VK_LAYER_PATH": ":".join(filter(None, (str(directory / "wsi"), str(directory / "lib"),
env.get("DROIDDECK_HYBRIS_LAYER_PATH")))),
"VK_INSTANCE_LAYERS": layers,
"ENABLE_GAMESCOPE_WSI": "0",
"VK_LOADER_LAYERS_DISABLE": "*gamescope*",
"DISABLE_VK_LAYER_VALVE_steam_fossilize_1": "1",
@@ -0,0 +1,11 @@
{
"file_format_version": "1.2.0",
"layer": {
"name": "VK_LAYER_DROIDDECK_xclipse",
"type": "GLOBAL",
"library_path": "./libVkLayer_droiddeck_xclipse.so",
"api_version": "1.3.0",
"implementation_version": "1",
"description": "Workarounds for Samsung Xclipse drivers loaded through libhybris"
}
}
+409
View File
@@ -0,0 +1,409 @@
/*
* VK_LAYER_DROIDDECK_xclipse: workarounds for Samsung's Xclipse driver loaded through libhybris.
*
* 1. bionic environ. A glibc process never initializes bionic's `environ`; the driver's
* AMD-derived shader compiler walks it for AMD_SC_* settings and crashed on the NULL.
* Once instance creation has loaded the driver, point it at a snapshot of ours.
* 2. YCbCr immutable samplers in compute. Compute pipelines whose layout binds an array of
* immutable YCbCr-conversion samplers fail to compile (VK_ERROR_UNKNOWN); gamescope's
* composite shaders all bind one. Such bindings get a plain linear sampler instead, so only
* multi-planar (NV12) layers sample incorrectly.
* 3. Calibrated timestamps. The driver has only VK_EXT_calibrated_timestamps, but the bridge
* lists the KHR names too, and Wine calls those; the loader then aborts (it took down Wine's
* explorer.exe and with it every game window). The KHR entry points forward to the EXT ones.
* 4. BC4/BC5 filtering. The libhybris compat layer emulates BC textures; BC4/BC5 decode into
* R16/R16G16 images, for which this driver advertises no linear filtering, so DXVK would
* treat them as unfilterable. The layer reports linear filtering for BC4/BC5 where they are
* sampled at all (RDNA filters 16-bit normalized formats; at worst they sample unfiltered).
* 5. textureCompressionBC. The compat layer emulates BC formats but keeps the feature bit off;
* DXVK before 3.0 (the last that fits this driver's 128 bytes of push constants) requires
* it. The layer reports it while BC formats are sampleable and clears it at device creation.
* Everything else passes straight through.
*/
#define _GNU_SOURCE
#include <vulkan/vk_layer.h>
#include <vulkan/vulkan.h>
#include <dlfcn.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define EXPORT __attribute__((visibility("default")))
#define MAX_OBJECTS 64
#define MAX_YCBCR_SAMPLERS 256
extern char **environ;
/* The loader's dispatch table pointer heads every dispatchable object: an instance shares it
* with its physical devices, a device with its queues and command buffers. */
typedef void *dispatch_key;
static dispatch_key key_of(const void *object) { return *(dispatch_key *)object; }
static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static int debug;
struct instance_data {
dispatch_key key;
VkInstance handle;
PFN_vkGetInstanceProcAddr next;
PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT time_domains;
PFN_vkGetPhysicalDeviceFeatures features;
PFN_vkGetPhysicalDeviceFeatures2 features2;
PFN_vkGetPhysicalDeviceFormatProperties format_properties;
PFN_vkGetPhysicalDeviceFormatProperties2 format_properties2;
};
struct device_data {
dispatch_key key;
VkDevice handle;
PFN_vkGetDeviceProcAddr next;
PFN_vkCreateSampler create_sampler;
PFN_vkDestroySampler destroy_sampler;
PFN_vkCreateDescriptorSetLayout create_set_layout;
PFN_vkDestroyDevice destroy_device;
PFN_vkGetCalibratedTimestampsEXT timestamps;
VkSampler fallback;
};
static struct instance_data instances[MAX_OBJECTS];
static struct device_data devices[MAX_OBJECTS];
/* YCbCr samplers by handle; non-dispatchable handles are unique per device on 64-bit. */
static VkSampler ycbcr_samplers[MAX_YCBCR_SAMPLERS];
static struct instance_data *instance_by_key(dispatch_key key) {
for (int i = 0; i < MAX_OBJECTS; i++)
if (instances[i].handle && instances[i].key == key) return &instances[i];
return NULL;
}
static struct device_data *device_by_key(dispatch_key key) {
for (int i = 0; i < MAX_OBJECTS; i++)
if (devices[i].handle && devices[i].key == key) return &devices[i];
return NULL;
}
/* Entries are never freed while their object lives, so a looked-up copy of the pointers is safe. */
static struct instance_data instance_of(const void *object) {
struct instance_data copy = {0};
pthread_mutex_lock(&lock);
struct instance_data *data = instance_by_key(key_of(object));
if (data) copy = *data;
pthread_mutex_unlock(&lock);
return copy;
}
static struct device_data device_of(const void *object) {
struct device_data copy = {0};
pthread_mutex_lock(&lock);
struct device_data *data = device_by_key(key_of(object));
if (data) copy = *data;
pthread_mutex_unlock(&lock);
return copy;
}
static void fix_bionic_environ(void) {
void *common = dlopen("libhybris-common.so.1", RTLD_NOW | RTLD_NOLOAD);
if (!common) return; /* not a libhybris driver */
void *(*h_dlopen)(const char *, int) = (void *(*)(const char *, int))dlsym(common, "hybris_dlopen");
void *(*h_dlsym)(void *, const char *) = (void *(*)(void *, const char *))dlsym(common, "hybris_dlsym");
if (!h_dlopen || !h_dlsym) return;
void *libc = h_dlopen("libc.so", RTLD_NOW);
char ***bionic_environ = libc ? (char ***)h_dlsym(libc, "environ") : NULL;
if (!bionic_environ || *bionic_environ) return;
size_t count = 0;
while (environ && environ[count]) count++;
char **snapshot = calloc(count + 1, sizeof(*snapshot));
if (!snapshot) return;
for (size_t i = 0; i < count; i++) snapshot[i] = strdup(environ[i]);
*bionic_environ = snapshot;
if (debug) fprintf(stderr, "xclipse layer: bionic environ set (%zu entries)\n", count);
}
/* ---- instance ---- */
static VkResult VKAPI_CALL create_instance(const VkInstanceCreateInfo *info, const VkAllocationCallbacks *allocator,
VkInstance *instance) {
VkLayerInstanceCreateInfo *chain = (VkLayerInstanceCreateInfo *)info->pNext;
while (chain && !(chain->sType == VK_STRUCTURE_TYPE_LOADER_INSTANCE_CREATE_INFO && chain->function == VK_LAYER_LINK_INFO))
chain = (VkLayerInstanceCreateInfo *)chain->pNext;
if (!chain || !chain->u.pLayerInfo) return VK_ERROR_INITIALIZATION_FAILED;
PFN_vkGetInstanceProcAddr next = chain->u.pLayerInfo->pfnNextGetInstanceProcAddr;
chain->u.pLayerInfo = chain->u.pLayerInfo->pNext;
PFN_vkCreateInstance next_create = (PFN_vkCreateInstance)next(NULL, "vkCreateInstance");
if (!next_create) return VK_ERROR_INITIALIZATION_FAILED;
VkResult result = next_create(info, allocator, instance);
if (result != VK_SUCCESS) return result;
fix_bionic_environ();
struct instance_data data = {
.key = key_of(*instance),
.handle = *instance,
.next = next,
.time_domains = (PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT)
next(*instance, "vkGetPhysicalDeviceCalibrateableTimeDomainsEXT"),
.features = (PFN_vkGetPhysicalDeviceFeatures)next(*instance, "vkGetPhysicalDeviceFeatures"),
.features2 = (PFN_vkGetPhysicalDeviceFeatures2)next(*instance, "vkGetPhysicalDeviceFeatures2"),
.format_properties = (PFN_vkGetPhysicalDeviceFormatProperties)next(*instance, "vkGetPhysicalDeviceFormatProperties"),
.format_properties2 = (PFN_vkGetPhysicalDeviceFormatProperties2)next(*instance, "vkGetPhysicalDeviceFormatProperties2"),
};
pthread_mutex_lock(&lock);
for (int i = 0; i < MAX_OBJECTS; i++)
if (!instances[i].handle) { instances[i] = data; break; }
pthread_mutex_unlock(&lock);
return result;
}
static void VKAPI_CALL destroy_instance(VkInstance instance, const VkAllocationCallbacks *allocator) {
PFN_vkGetInstanceProcAddr next = instance_of(instance).next;
pthread_mutex_lock(&lock);
struct instance_data *data = instance_by_key(key_of(instance));
if (data) memset(data, 0, sizeof(*data));
pthread_mutex_unlock(&lock);
PFN_vkDestroyInstance next_destroy = next ? (PFN_vkDestroyInstance)next(instance, "vkDestroyInstance") : NULL;
if (next_destroy) next_destroy(instance, allocator);
}
static VkResult VKAPI_CALL time_domains_khr(VkPhysicalDevice physical, uint32_t *count, VkTimeDomainEXT *domains) {
PFN_vkGetPhysicalDeviceCalibrateableTimeDomainsEXT ext = instance_of(physical).time_domains;
if (!ext) { *count = 0; return VK_SUCCESS; }
return ext(physical, count, domains);
}
/* BC formats sampleable below us although the driver's feature bit is off: the compat layer emulates them. */
static int bc_emulated(VkPhysicalDevice physical) {
struct instance_data data = instance_of(physical);
if (!data.features || !data.format_properties) return 0;
VkPhysicalDeviceFeatures native;
data.features(physical, &native);
if (native.textureCompressionBC) return 0;
VkFormatProperties bc1, bc7;
data.format_properties(physical, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, &bc1);
data.format_properties(physical, VK_FORMAT_BC7_UNORM_BLOCK, &bc7);
return (bc1.optimalTilingFeatures & bc7.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) != 0;
}
static void VKAPI_CALL get_features(VkPhysicalDevice physical, VkPhysicalDeviceFeatures *features) {
PFN_vkGetPhysicalDeviceFeatures next = instance_of(physical).features;
if (next) next(physical, features);
if (bc_emulated(physical)) features->textureCompressionBC = VK_TRUE;
}
static void VKAPI_CALL get_features2(VkPhysicalDevice physical, VkPhysicalDeviceFeatures2 *features) {
PFN_vkGetPhysicalDeviceFeatures2 next = instance_of(physical).features2;
if (next) next(physical, features);
if (bc_emulated(physical)) features->features.textureCompressionBC = VK_TRUE;
}
static int bc45(VkFormat format) {
return format >= VK_FORMAT_BC4_UNORM_BLOCK && format <= VK_FORMAT_BC5_SNORM_BLOCK;
}
static void VKAPI_CALL get_format_properties(VkPhysicalDevice physical, VkFormat format, VkFormatProperties *out) {
PFN_vkGetPhysicalDeviceFormatProperties next = instance_of(physical).format_properties;
if (next) next(physical, format, out);
if (bc45(format) && (out->optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT))
out->optimalTilingFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
}
static void VKAPI_CALL get_format_properties2(VkPhysicalDevice physical, VkFormat format, VkFormatProperties2 *out) {
PFN_vkGetPhysicalDeviceFormatProperties2 next = instance_of(physical).format_properties2;
if (next) next(physical, format, out);
if (!bc45(format)) return;
if (out->formatProperties.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
out->formatProperties.optimalTilingFeatures |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
for (VkBaseOutStructure *p = (VkBaseOutStructure *)out->pNext; p; p = p->pNext) {
if (p->sType != VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_3) continue;
VkFormatProperties3 *f3 = (VkFormatProperties3 *)p;
if (f3->optimalTilingFeatures & VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_BIT)
f3->optimalTilingFeatures |= VK_FORMAT_FEATURE_2_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
}
}
/* ---- device ---- */
static VkResult VKAPI_CALL create_device(VkPhysicalDevice physical, const VkDeviceCreateInfo *info,
const VkAllocationCallbacks *allocator, VkDevice *device) {
VkLayerDeviceCreateInfo *chain = (VkLayerDeviceCreateInfo *)info->pNext;
while (chain && !(chain->sType == VK_STRUCTURE_TYPE_LOADER_DEVICE_CREATE_INFO && chain->function == VK_LAYER_LINK_INFO))
chain = (VkLayerDeviceCreateInfo *)chain->pNext;
if (!chain || !chain->u.pLayerInfo) return VK_ERROR_INITIALIZATION_FAILED;
PFN_vkGetInstanceProcAddr next_gipa = chain->u.pLayerInfo->pfnNextGetInstanceProcAddr;
PFN_vkGetDeviceProcAddr next_gdpa = chain->u.pLayerInfo->pfnNextGetDeviceProcAddr;
chain->u.pLayerInfo = chain->u.pLayerInfo->pNext;
PFN_vkCreateDevice next_create = (PFN_vkCreateDevice)next_gipa(NULL, "vkCreateDevice");
if (!next_create) return VK_ERROR_INITIALIZATION_FAILED;
VkDeviceCreateInfo patched = *info;
/* An emulated textureCompressionBC never reaches the compat layer, which refuses the bit. */
int strip_bc = bc_emulated(physical);
VkPhysicalDeviceFeatures plain_features;
if (strip_bc && info->pEnabledFeatures && info->pEnabledFeatures->textureCompressionBC) {
plain_features = *info->pEnabledFeatures;
plain_features.textureCompressionBC = VK_FALSE;
patched.pEnabledFeatures = &plain_features;
}
VkPhysicalDeviceFeatures2 *features2 = NULL;
for (VkBaseOutStructure *p = (VkBaseOutStructure *)info->pNext; p && strip_bc; p = p->pNext)
if (p->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2 &&
((VkPhysicalDeviceFeatures2 *)p)->features.textureCompressionBC) {
features2 = (VkPhysicalDeviceFeatures2 *)p;
features2->features.textureCompressionBC = VK_FALSE;
}
VkResult result = next_create(physical, &patched, allocator, device);
if (features2) features2->features.textureCompressionBC = VK_TRUE;
if (result != VK_SUCCESS) return result;
PFN_vkCreateSampler create_sampler = (PFN_vkCreateSampler)next_gdpa(*device, "vkCreateSampler");
VkSamplerCreateInfo plain = {
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
.magFilter = VK_FILTER_LINEAR, .minFilter = VK_FILTER_LINEAR,
.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
.borderColor = VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
};
VkSampler fallback = VK_NULL_HANDLE;
if (create_sampler) create_sampler(*device, &plain, NULL, &fallback);
struct device_data data = {
.key = key_of(*device),
.handle = *device,
.next = next_gdpa,
.create_sampler = create_sampler,
.destroy_sampler = (PFN_vkDestroySampler)next_gdpa(*device, "vkDestroySampler"),
.create_set_layout = (PFN_vkCreateDescriptorSetLayout)next_gdpa(*device, "vkCreateDescriptorSetLayout"),
.destroy_device = (PFN_vkDestroyDevice)next_gdpa(*device, "vkDestroyDevice"),
.timestamps = (PFN_vkGetCalibratedTimestampsEXT)next_gdpa(*device, "vkGetCalibratedTimestampsEXT"),
.fallback = fallback,
};
pthread_mutex_lock(&lock);
for (int i = 0; i < MAX_OBJECTS; i++)
if (!devices[i].handle) { devices[i] = data; break; }
pthread_mutex_unlock(&lock);
return result;
}
static void VKAPI_CALL destroy_device(VkDevice device, const VkAllocationCallbacks *allocator) {
struct device_data data = device_of(device);
pthread_mutex_lock(&lock);
struct device_data *entry = device_by_key(key_of(device));
if (entry) memset(entry, 0, sizeof(*entry));
pthread_mutex_unlock(&lock);
if (data.fallback && data.destroy_sampler) data.destroy_sampler(device, data.fallback, NULL);
if (data.destroy_device) data.destroy_device(device, allocator);
}
static VkResult VKAPI_CALL timestamps_khr(VkDevice device, uint32_t count, const VkCalibratedTimestampInfoEXT *infos,
uint64_t *timestamps, uint64_t *deviation) {
PFN_vkGetCalibratedTimestampsEXT ext = device_of(device).timestamps;
return ext ? ext(device, count, infos, timestamps, deviation) : VK_ERROR_FEATURE_NOT_PRESENT;
}
static VkResult VKAPI_CALL create_sampler(VkDevice device, const VkSamplerCreateInfo *info,
const VkAllocationCallbacks *allocator, VkSampler *sampler) {
PFN_vkCreateSampler next = device_of(device).create_sampler;
if (!next) return VK_ERROR_INITIALIZATION_FAILED;
VkResult result = next(device, info, allocator, sampler);
if (result != VK_SUCCESS) return result;
for (const VkBaseInStructure *p = info->pNext; p; p = p->pNext) {
if (p->sType != VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_INFO) continue;
pthread_mutex_lock(&lock);
for (int k = 0; k < MAX_YCBCR_SAMPLERS; k++)
if (!ycbcr_samplers[k]) { ycbcr_samplers[k] = *sampler; break; }
pthread_mutex_unlock(&lock);
break;
}
return result;
}
static int is_ycbcr(VkSampler sampler) {
for (int k = 0; k < MAX_YCBCR_SAMPLERS; k++)
if (sampler && ycbcr_samplers[k] == sampler) return 1;
return 0;
}
static VkResult VKAPI_CALL create_set_layout(VkDevice device, const VkDescriptorSetLayoutCreateInfo *info,
const VkAllocationCallbacks *allocator, VkDescriptorSetLayout *layout) {
struct device_data data = device_of(device);
if (!data.create_set_layout) return VK_ERROR_INITIALIZATION_FAILED;
int replace = 0;
pthread_mutex_lock(&lock);
for (uint32_t b = 0; data.fallback && b < info->bindingCount && !replace; b++) {
const VkDescriptorSetLayoutBinding *binding = &info->pBindings[b];
if (!(binding->stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) || !binding->pImmutableSamplers) continue;
for (uint32_t s = 0; s < binding->descriptorCount; s++)
if (is_ycbcr(binding->pImmutableSamplers[s])) { replace = 1; break; }
}
pthread_mutex_unlock(&lock);
if (!replace) return data.create_set_layout(device, info, allocator, layout);
VkDescriptorSetLayoutBinding *bindings = calloc(info->bindingCount, sizeof(*bindings));
VkSampler **arrays = calloc(info->bindingCount, sizeof(*arrays));
if (!bindings || !arrays) { free(bindings); free(arrays); return VK_ERROR_OUT_OF_HOST_MEMORY; }
for (uint32_t b = 0; b < info->bindingCount; b++) {
bindings[b] = info->pBindings[b];
if (!(bindings[b].stageFlags & VK_SHADER_STAGE_COMPUTE_BIT) || !bindings[b].pImmutableSamplers) continue;
arrays[b] = malloc(bindings[b].descriptorCount * sizeof(VkSampler));
if (!arrays[b]) continue;
pthread_mutex_lock(&lock);
for (uint32_t s = 0; s < bindings[b].descriptorCount; s++) {
VkSampler original = bindings[b].pImmutableSamplers[s];
arrays[b][s] = is_ycbcr(original) ? data.fallback : original;
}
pthread_mutex_unlock(&lock);
bindings[b].pImmutableSamplers = arrays[b];
}
VkDescriptorSetLayoutCreateInfo patched = *info;
patched.pBindings = bindings;
VkResult result = data.create_set_layout(device, &patched, allocator, layout);
if (debug) fprintf(stderr, "xclipse layer: compute YCbCr immutable samplers replaced (%d)\n", result);
for (uint32_t b = 0; b < info->bindingCount; b++) free(arrays[b]);
free(arrays);
free(bindings);
return result;
}
/* ---- dispatch ---- */
static PFN_vkVoidFunction device_hook(const char *name) {
if (!strcmp(name, "vkGetDeviceProcAddr")) return NULL; /* handled by the caller */
if (!strcmp(name, "vkDestroyDevice")) return (PFN_vkVoidFunction)destroy_device;
if (!strcmp(name, "vkCreateSampler")) return (PFN_vkVoidFunction)create_sampler;
if (!strcmp(name, "vkCreateDescriptorSetLayout")) return (PFN_vkVoidFunction)create_set_layout;
if (!strcmp(name, "vkGetCalibratedTimestampsKHR")) return (PFN_vkVoidFunction)timestamps_khr;
return NULL;
}
EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *name) {
if (!strcmp(name, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction)vkGetDeviceProcAddr;
PFN_vkVoidFunction hook = device_hook(name);
if (hook) return hook;
struct device_data data = device ? device_of(device) : (struct device_data){0};
return data.next ? data.next(device, name) : NULL;
}
EXPORT VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *name) {
if (!strcmp(name, "vkGetInstanceProcAddr")) return (PFN_vkVoidFunction)vkGetInstanceProcAddr;
if (!strcmp(name, "vkCreateInstance")) return (PFN_vkVoidFunction)create_instance;
if (!strcmp(name, "vkDestroyInstance")) return (PFN_vkVoidFunction)destroy_instance;
if (!strcmp(name, "vkCreateDevice")) return (PFN_vkVoidFunction)create_device;
if (!strcmp(name, "vkGetDeviceProcAddr")) return (PFN_vkVoidFunction)vkGetDeviceProcAddr;
if (!strcmp(name, "vkGetPhysicalDeviceFeatures")) return (PFN_vkVoidFunction)get_features;
if (!strcmp(name, "vkGetPhysicalDeviceFeatures2") || !strcmp(name, "vkGetPhysicalDeviceFeatures2KHR"))
return (PFN_vkVoidFunction)get_features2;
if (!strcmp(name, "vkGetPhysicalDeviceCalibrateableTimeDomainsKHR")) return (PFN_vkVoidFunction)time_domains_khr;
if (!strcmp(name, "vkGetPhysicalDeviceFormatProperties")) return (PFN_vkVoidFunction)get_format_properties;
if (!strcmp(name, "vkGetPhysicalDeviceFormatProperties2") || !strcmp(name, "vkGetPhysicalDeviceFormatProperties2KHR"))
return (PFN_vkVoidFunction)get_format_properties2;
PFN_vkVoidFunction hook = device_hook(name);
if (hook) return hook;
PFN_vkGetInstanceProcAddr next = instance ? instance_of(instance).next : NULL;
return next ? next(instance, name) : NULL;
}
EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkNegotiateLoaderLayerInterfaceVersion(VkNegotiateLayerInterface *negotiate) {
if (!negotiate || negotiate->loaderLayerInterfaceVersion < 2) return VK_ERROR_INITIALIZATION_FAILED;
debug = getenv("DROIDDECK_XCLIPSE_LAYER_DEBUG") != NULL;
negotiate->loaderLayerInterfaceVersion = 2;
negotiate->pfnGetInstanceProcAddr = vkGetInstanceProcAddr;
negotiate->pfnGetDeviceProcAddr = vkGetDeviceProcAddr;
negotiate->pfnGetPhysicalDeviceProcAddr = NULL;
return VK_SUCCESS;
}
+1
View File
@@ -10,6 +10,7 @@ RUN apt-get update \
g++ \
gcc-aarch64-linux-gnu \
g++-aarch64-linux-gnu \
libvulkan-dev \
python3 \
zstd \
unzip \
+60 -10
View File
@@ -12,6 +12,7 @@ import json
import os
from pathlib import Path, PurePosixPath
import posixpath
import re
import stat
import subprocess
import tarfile
@@ -194,6 +195,50 @@ def read_zip(data, component):
return entries
def read_tar_gz(data, component):
"""An upstream release tarball, held to the same per-file pins as a CI archive."""
entries, seen = {}, set()
expected = {item["name"]: item for item in component["files"]}
allowed = set(expected) | set(component["ignored"])
total = 0
with tarfile.open(fileobj=io.BytesIO(data), mode="r:gz") as archive:
for member in archive:
name = safe_name(member.name)
if name in seen:
raise ValueError("duplicate archive path: " + name)
seen.add(name)
if member.isdir():
continue
if not member.isfile() or name not in allowed:
raise ValueError("unexpected component archive entry: " + name)
total += member.size
if total > MAX_UNPACKED:
raise ValueError("component archive exceeds size limit")
if name not in expected:
continue
pin = expected[name]
content = archive.extractfile(member).read()
if len(content) != pin["size"] or sha256(content) != pin["sha256"]:
raise ValueError("component member checksum mismatch: " + name)
path = safe_name(pin["path"])
if path in entries:
raise ValueError("duplicate component destination: " + path)
entries[path] = ("file", pin["mode"], content)
if set(expected) - seen:
raise ValueError("component archive missing files: " + ", ".join(sorted(set(expected) - seen)))
check_tree(entries)
return entries
def read_component(data, component):
kind = component.get("format", "zip")
if kind == "zip":
return read_zip(data, component)
if kind == "tar.gz":
return read_tar_gz(data, component)
raise ValueError("unsupported component archive format: " + kind)
def check_bundle(entries, release, root):
check_tree(entries)
if read(entries, "assembly-inputs.json") != json_bytes(assembly_inputs(root)):
@@ -221,15 +266,20 @@ def check_bundle(entries, release, root):
content = read(entries, name)
if content[:6] != b"\x7fELF\x02\x01" or content[18:20] != b"\xb7\x00":
raise ValueError("runtime library is not ELF64 AArch64: " + name)
for architecture, machine, magic in (("x32", b"\x4c\x01", b"\x0b\x01"),
("x64", b"\x64\x86", b"\x0b\x02")):
for name in ("d3d8.dll", "d3d9.dll", "d3d10core.dll", "d3d11.dll", "dxgi.dll"):
path = "dxvk/" + architecture + "/" + name
content = read(entries, path)
pe = int.from_bytes(content[60:64], "little")
if (content[:2] != b"MZ" or pe < 64 or content[pe:pe + 4] != b"PE\0\0"
or content[pe + 4:pe + 6] != machine or content[pe + 24:pe + 26] != magic):
raise ValueError("DXVK library has wrong PE architecture: " + path)
# dxvk/ is the default payload; run-proton.py can select another dxvk-* sibling by name.
payloads = sorted({name.split("/")[0] for name in entries if re.fullmatch(r"dxvk[^/]*/x(32|64)/[^/]+\.dll", name)})
if "dxvk" not in payloads:
raise ValueError("default DXVK payload missing")
for payload in payloads:
for architecture, machine, magic in (("x32", b"\x4c\x01", b"\x0b\x01"),
("x64", b"\x64\x86", b"\x0b\x02")):
for name in ("d3d8.dll", "d3d9.dll", "d3d10core.dll", "d3d11.dll", "dxgi.dll"):
path = payload + "/" + architecture + "/" + name
content = read(entries, path)
pe = int.from_bytes(content[60:64], "little")
if (content[:2] != b"MZ" or pe < 64 or content[pe:pe + 4] != b"PE\0\0"
or content[pe + 4:pe + 6] != machine or content[pe + 24:pe + 26] != magic):
raise ValueError("DXVK library has wrong PE architecture: " + path)
def pack(entries):
@@ -273,7 +323,7 @@ def assemble(root, cache):
if tree_digest(entries) != release["hybris"]["tree_sha256"]:
raise ValueError("PowerVR bridge tree checksum mismatch")
for component in release["archives"]:
additions = read_zip(fetch(component, cache), component)
additions = read_component(fetch(component, cache), component)
if set(entries) & set(additions):
raise ValueError("component overwrites existing runtime files")
entries.update(additions)
+85
View File
@@ -226,6 +226,91 @@
"sha256": "348f9ec42159c1ee6e2baba4312a5e845d26687238f29e3f4a1b0c3c97e13b3c",
"size": 362717,
"url": "https://github.com/wallentx/DroidDeck/releases/download/v0.3.2-progress.20261010.4/wsi-abe5861.zip"
},
{
"files": [
{
"mode": 493,
"name": "dxvk-2.6.2/x32/d3d10core.dll",
"path": "dxvk-2.6.2/x32/d3d10core.dll",
"sha256": "b34b479fa0bce29eba6dcff5b1f8584c2ae699d53a123668590f8a2b84e84094",
"size": 176142
},
{
"mode": 493,
"name": "dxvk-2.6.2/x32/d3d11.dll",
"path": "dxvk-2.6.2/x32/d3d11.dll",
"sha256": "858d1a848dd5023191cb16cd986e0f00008faf5df8a87b5c835b56cf4b646910",
"size": 4845582
},
{
"mode": 493,
"name": "dxvk-2.6.2/x32/d3d8.dll",
"path": "dxvk-2.6.2/x32/d3d8.dll",
"sha256": "617459c8d1239f98687f8157bdaec85738ee4699885ed7d1ff13deb32609c759",
"size": 1658894
},
{
"mode": 493,
"name": "dxvk-2.6.2/x32/d3d9.dll",
"path": "dxvk-2.6.2/x32/d3d9.dll",
"sha256": "00bc142e98ddad1e334a4d88fa630038e092b0758b3d79e295172b181a4c772d",
"size": 4460558
},
{
"mode": 493,
"name": "dxvk-2.6.2/x32/dxgi.dll",
"path": "dxvk-2.6.2/x32/dxgi.dll",
"sha256": "67d7ca4a4f8f66baabd381c73b52a8e85870083e868ed474a4bc58b7da486883",
"size": 3137550
},
{
"mode": 493,
"name": "dxvk-2.6.2/x64/d3d10core.dll",
"path": "dxvk-2.6.2/x64/d3d10core.dll",
"sha256": "565154a0763c6460843fe47e5aaec62e609163d9995a922d5e19e85027fe2f88",
"size": 155662
},
{
"mode": 493,
"name": "dxvk-2.6.2/x64/d3d11.dll",
"path": "dxvk-2.6.2/x64/d3d11.dll",
"sha256": "5b63515a432d19302f7dc81dd2ee5bf40043683b5064a2bce03a2b6d27dcce5d",
"size": 4399118
},
{
"mode": 493,
"name": "dxvk-2.6.2/x64/d3d8.dll",
"path": "dxvk-2.6.2/x64/d3d8.dll",
"sha256": "dfd837c3467eeb15f69a773e18bbc0550cb69c9e33d5d57b4ea42c5f63bfdc4b",
"size": 1544206
},
{
"mode": 493,
"name": "dxvk-2.6.2/x64/d3d9.dll",
"path": "dxvk-2.6.2/x64/d3d9.dll",
"sha256": "01e7ae2b0544b6031fe695fd16fbc76786ded57fdbe3f6bd11eee7c98d2c370d",
"size": 4108302
},
{
"mode": 493,
"name": "dxvk-2.6.2/x64/dxgi.dll",
"path": "dxvk-2.6.2/x64/dxgi.dll",
"sha256": "074616e1af172edf175f3fc6ed7ca30f6c685a70875eed3af10797a10840ed39",
"size": 2891790
}
],
"format": "tar.gz",
"id": "dxvk-xclipse",
"ignored": [],
"provenance": {
"note": "Unmodified upstream release, selected on Samsung Xclipse: its 128 bytes of push constants predate DXVK 3's 256-byte requirement. Covered by the zlib license already shipped as licenses/dxvk-LICENSE.",
"upstream_release": "https://github.com/doitsujin/dxvk/releases/tag/v2.6.2"
},
"recipe_inputs": {},
"sha256": "17761876556afd55736cb895d184f5a1c55d43350f1b1e3b129f8d28706d7992",
"size": 10107492,
"url": "https://github.com/doitsujin/dxvk/releases/download/v2.6.2/dxvk-2.6.2.tar.gz"
}
],
"format": 1,
+2
View File
@@ -64,6 +64,8 @@ def required():
paths += ['assets/linuxfs/i386/libfaultreport.so']
paths += ['assets/linuxfs/usr/local/lib/droiddeck-msitools/' + name for name in
['msiinfo', 'cabextract', '7z', '7z.so', 'libmsi-1.0.so.0', 'libgsf-1.so.114', 'libgcab-1.0.so.0']]
paths += ['assets/linuxfs/usr/local/lib/droiddeck-xclipse/' + name for name in
['libVkLayer_droiddeck_xclipse.so', 'VkLayer_droiddeck_xclipse.json']]
paths += ['assets/linuxfs/usr/local/lib/mangoapp/' + name for name in
['mangoapp', 'libfmt.so.10', 'libspdlog.so.1.13', 'libglfw.so.3', 'libtraceevent.so.1', 'libtracefs.so.1']]
for driver in ['linux-wine11', 'linux-wine11-systhread']:
+1 -1
View File
@@ -6,7 +6,7 @@ cd "$repo_root"
if [[ $(uname -s) == Linux ]]; then
exec python3 -m unittest discover -s tools/tests "$@"
fi
image=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v3}
image=${DROIDDECK_BUILD_IMAGE:-droiddeck-local-cross:24.04-v4}
python3 tools/docker_preflight.py "$image"
exec docker run --rm --platform linux/amd64 --user "$(id -u):$(id -g)" \
-v "$repo_root:/src:ro" -w /src "$image" python3 -m unittest discover -s tools/tests "$@"
+26
View File
@@ -82,6 +82,32 @@ class SystemGraphicsLaunchTest(unittest.TestCase):
for key in ("FEX_TSOENABLED", "WINESERVER", "CUSTOM"):
self.assertEqual(result[key], env[key])
def test_xclipse_selection_adds_its_layers_layer_path_and_dxvk_payload(self):
with tempfile.TemporaryDirectory() as tmp:
runtime, _ = self.runtime(Path(tmp))
env = {"DROIDDECK_POWERVR_RUNTIME": str(runtime), "STEAM_COMPAT_DATA_PATH": "/compatdata/42",
"DROIDDECK_HYBRIS_LAYERS": "VK_LAYER_DROIDDECK_xclipse:VK_LAYER_HYBRIS_compat",
"DROIDDECK_HYBRIS_LAYER_PATH": "/usr/local/lib/droiddeck-xclipse",
"DROIDDECK_HYBRIS_DXVK": "dxvk-2.6.2"}
command = ["/proton", "waitforexitandrun", "game.exe"]
# The selected payload is required like the default one.
with self.assertRaises(MODULE["SystemGraphicsError"]):
MODULE["system_graphics_launch"](command, env)
for arch in ("x32", "x64"):
for name in ("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi"):
target = runtime / "dxvk-2.6.2" / arch / (name + ".dll")
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(b"component")
launch, result = MODULE["system_graphics_launch"](command, env)
self.assertEqual(launch, [str(runtime / "run-proton.py"), *command])
self.assertEqual(result["VK_INSTANCE_LAYERS"],
"VK_LAYER_window_system_integration:VK_LAYER_DROIDDECK_xclipse:VK_LAYER_HYBRIS_compat")
self.assertEqual(result["VK_LAYER_PATH"], f"{runtime}/wsi:{runtime}/lib:/usr/local/lib/droiddeck-xclipse")
self.assertEqual(result["DROIDDECK_HYBRIS_DXVK"], "dxvk-2.6.2")
for name in ("../dxvk", "other", "dxvk/x"):
with self.subTest(name=name), self.assertRaises(MODULE["SystemGraphicsError"]):
MODULE["system_graphics_launch"](command, dict(env, DROIDDECK_HYBRIS_DXVK=name))
def test_incomplete_runtime_fails_before_any_proton_exec(self):
with tempfile.TemporaryDirectory() as tmp:
runtime, files = self.runtime(Path(tmp))
+67
View File
@@ -48,6 +48,29 @@ def tar(entries):
capture_output=True, check=True).stdout
def tar_gz(entries):
stream = io.BytesIO()
with tarfile.open(fileobj=stream, mode='w:gz') as archive:
for name, kind, content in entries:
info = tarfile.TarInfo(name)
info.type = kind
if kind == tarfile.SYMTYPE:
info.linkname = content
archive.addfile(info)
elif kind == tarfile.REGTYPE:
info.size = len(content)
archive.addfile(info, io.BytesIO(content))
else:
archive.addfile(info)
return stream.getvalue()
def upstream_dxvk(version, architecture_of=lambda arch: arch):
return {'dxvk-%s/%s/%s' % (version, arch, name): pe(architecture_of(arch))
for arch in ('x32', 'x64')
for name in ('d3d8.dll', 'd3d9.dll', 'd3d10core.dll', 'd3d11.dll', 'dxgi.dll')}
class PowerVRRuntimeTest(unittest.TestCase):
def setUp(self):
self.temporary = tempfile.TemporaryDirectory()
@@ -95,6 +118,18 @@ class PowerVRRuntimeTest(unittest.TestCase):
(self.cache / (component['sha256'] + '-' + name)).write_bytes(data)
return component
def add_upstream_dxvk(self, files):
top = next(iter(files)).split('/')[0]
data = tar_gz([(top, tarfile.DIRTYPE, None)] +
[(name, tarfile.REGTYPE, content) for name, content in files.items()])
component = self.component('dxvk-upstream.tar.gz', data)
component.update({'format': 'tar.gz', 'ignored': [], 'files': [
{'name': name, 'path': name, 'size': len(content), 'sha256': runtime.sha256(content), 'mode': 0o755}
for name, content in files.items()]})
self.release['archives'].append(component)
self.pins.write_bytes(runtime.json_bytes(self.release))
return component
def assembled(self):
runtime.assemble(self.root, self.cache)
return runtime.read_tar((self.root / runtime.ASSETS / 'runtime.tzst').read_bytes())
@@ -107,6 +142,38 @@ class PowerVRRuntimeTest(unittest.TestCase):
self.assertEqual(first, (self.root / runtime.ASSETS / 'runtime.tzst').read_bytes())
self.assertEqual(runtime.read_tar(first)['lib/libhybris-common.so.1'][0], 'symlink')
def test_upstream_tarball_adds_a_second_dxvk_payload(self):
files = upstream_dxvk('2.6.2')
self.add_upstream_dxvk(files)
entries = self.assembled()
runtime.verify(self.root)
for name, content in files.items():
self.assertEqual(entries[name], ('file', 0o755, content))
self.assertIn('dxvk/x64/d3d9.dll', entries)
def test_second_dxvk_payload_with_wrong_pe_architecture_is_rejected(self):
self.add_upstream_dxvk(upstream_dxvk('2.6.2', lambda arch: 'x64' if arch == 'x32' else 'x32'))
with self.assertRaisesRegex(ValueError, 'wrong PE architecture: dxvk-2.6.2/'):
self.assembled()
def test_tar_gz_rejects_symlinks_unknown_members_and_changed_files(self):
pin = {'name': 'dxvk-1/x64/d3d9.dll', 'path': 'dxvk-1/x64/d3d9.dll', 'size': 4,
'sha256': runtime.sha256(b'good'), 'mode': 0o755}
component = {'files': [pin], 'ignored': []}
cases = [
[('dxvk-1/x64/d3d9.dll', tarfile.SYMTYPE, '../../outside')],
[('dxvk-1/x64/d3d9.dll', tarfile.REGTYPE, b'good'), ('dxvk-1/extra.dll', tarfile.REGTYPE, b'x')],
[('dxvk-1/x64/d3d9.dll', tarfile.REGTYPE, b'evil')],
[],
]
for entries in cases:
with self.subTest(entries=[name for name, _, _ in entries]), self.assertRaises(ValueError):
runtime.read_tar_gz(tar_gz(entries), component)
self.assertEqual(runtime.read_tar_gz(tar_gz([('dxvk-1/x64/d3d9.dll', tarfile.REGTYPE, b'good')]), component),
{'dxvk-1/x64/d3d9.dll': ('file', 0o755, b'good')})
with self.assertRaisesRegex(ValueError, 'unsupported component archive format'):
runtime.read_component(b'', {'format': 'rar'})
def test_stale_wrapper_cannot_pass_with_an_updated_archive_checksum(self):
self.assembled()
(self.root / 'tools/hybris/run-proton.py').write_text('print("new wrapper")\n')
+32 -2
View File
@@ -89,7 +89,7 @@ class ProtonWrapperTest(unittest.TestCase):
return {"wrapper": wrapper, "dxvk": dxvk, "depot": depot, "proton": proton,
"probe": root / "proton-ran.json"}
def run_wrapper(self, fixture, *proton_args, check=False, exit_status=0):
def run_wrapper(self, fixture, *proton_args, check=False, exit_status=0, env=None):
command = [sys.executable, str(fixture["wrapper"])]
if check:
command.append("--check")
@@ -98,7 +98,7 @@ class ProtonWrapperTest(unittest.TestCase):
command,
cwd=fixture["wrapper"].parent,
env={"PATH": os.defpath, "PROBE": str(fixture["probe"]),
"PROTON_EXIT": str(exit_status)},
"PROTON_EXIT": str(exit_status), **(env or {})},
text=True,
capture_output=True,
)
@@ -126,6 +126,36 @@ class ProtonWrapperTest(unittest.TestCase):
{name: f"{architecture}:{name}" for name in DLL_NAMES},
)
def test_named_sibling_payload_replaces_the_default(self):
with tempfile.TemporaryDirectory() as tmp:
fixture = self.fixture(Path(tmp))
for architecture in ("x32", "x64"):
payload = fixture["wrapper"].parent / "dxvk-2.6.2" / architecture
payload.mkdir(parents=True)
for name in DLL_NAMES:
(payload / name).write_text(f"2.6.2 {architecture}:{name}")
result = self.run_wrapper(fixture, "waitforexitandrun", "game.exe",
env={"DROIDDECK_HYBRIS_DXVK": "dxvk-2.6.2"})
self.assertEqual(result.returncode, 0, result.stderr)
record = json.loads(fixture["probe"].read_text())
for architecture in ("x32", "x64"):
self.assertEqual(
record["payloads"][architecture],
{name: f"2.6.2 {architecture}:{name}" for name in DLL_NAMES},
)
def test_payload_names_outside_the_wrapper_directory_are_refused(self):
for name in ("../dxvk", "dxvk/../../x", "/tmp/dxvk", "other", ".dxvk"):
with self.subTest(name=name), tempfile.TemporaryDirectory() as tmp:
fixture = self.fixture(Path(tmp))
result = self.run_wrapper(fixture, "waitforexitandrun", "game.exe",
env={"DROIDDECK_HYBRIS_DXVK": name})
self.assertEqual(result.returncode, 1)
self.assertIn("invalid payload name", result.stderr)
self.assertFalse(fixture["probe"].exists())
def test_check_validates_without_executing_proton(self):
with tempfile.TemporaryDirectory() as tmp:
fixture = self.fixture(Path(tmp))