mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-29 09:35:38 +00:00
Compare commits
119
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cadef0c04d | ||
|
|
f3ba9351e5 | ||
|
|
6eacea916c | ||
|
|
d2a4394d5a | ||
|
|
d13b9d88f0 | ||
|
|
3d0d96786a | ||
|
|
380a70b485 | ||
|
|
948b9cbc8d | ||
|
|
53edc4882a | ||
|
|
0c688c11e6 | ||
|
|
5e7be54a49 | ||
|
|
feb13b52e3 | ||
|
|
c2b00e1db6 | ||
|
|
941cde30f2 | ||
|
|
c19b541611 | ||
|
|
a7a1ebf14b | ||
|
|
e24ed8abb5 | ||
|
|
acb3ee64da | ||
|
|
cc4f704ee7 | ||
|
|
c4bba945ce | ||
|
|
746b5f369c | ||
|
|
39bade8833 | ||
|
|
379dd900f1 | ||
|
|
f9f65719ab | ||
|
|
e7b523d653 | ||
|
|
21f393f93b | ||
|
|
48a7b614cb | ||
|
|
f985bd6720 | ||
|
|
710806a554 | ||
|
|
f0608bb134 | ||
|
|
7ad99aba3d | ||
|
|
bab999038f | ||
|
|
6778a224ec | ||
|
|
b3f3e4fdaf | ||
|
|
5bc5f68761 | ||
|
|
00b8fc2b7d | ||
|
|
89b101abdd | ||
|
|
a281bc881e | ||
|
|
b0c694d9e1 | ||
|
|
75612da44b | ||
|
|
653613527a | ||
|
|
6621013aef | ||
|
|
85c9442e23 | ||
|
|
f292274d7f | ||
|
|
cc69dfa323 | ||
|
|
02b2918dab | ||
|
|
ac32bad12d | ||
|
|
556e6b4185 | ||
|
|
e8737edc53 | ||
|
|
9fa3ffadd4 | ||
|
|
dfc68b7cdf | ||
|
|
533ea1b1c6 | ||
|
|
b0b9c9bc40 | ||
|
|
06abb772d6 | ||
|
|
64718da354 | ||
|
|
b383604175 | ||
|
|
a2c778f6e8 | ||
|
|
9035dd1dc2 | ||
|
|
584e9b1ad0 | ||
|
|
248b34f4f1 | ||
|
|
80671a7a37 | ||
|
|
bbbd41658a | ||
|
|
387359ad9e | ||
|
|
c09e0511c8 | ||
|
|
a8d48e82bc | ||
|
|
cb7453ab8b | ||
|
|
21793cdc8f | ||
|
|
9855a64c52 | ||
|
|
cdc260e52d | ||
|
|
9dae0575c0 | ||
|
|
ccf3eb4e04 | ||
|
|
d1773ee30f | ||
|
|
39631f30c8 | ||
|
|
6cfec416e2 | ||
|
|
da45bbc7cf | ||
|
|
797840be7e | ||
|
|
d544f0f0dd | ||
|
|
857d4d1920 | ||
|
|
c22d9d4f71 | ||
|
|
ddb3b176a2 | ||
|
|
c15ead4b73 | ||
|
|
a2637af094 | ||
|
|
56dc433673 | ||
|
|
2f6095ed92 | ||
|
|
e282318dc7 | ||
|
|
e5132b7c45 | ||
|
|
6fcc11ab80 | ||
|
|
b763091896 | ||
|
|
b93141b757 | ||
|
|
5a5c4131ff | ||
|
|
74103ccf64 | ||
|
|
cdefcd78f4 | ||
|
|
0b13e59852 | ||
|
|
f93ec9149c | ||
|
|
d59adae787 | ||
|
|
4e3fad37e7 | ||
|
|
53f7577d20 | ||
|
|
d33715ca8a | ||
|
|
272bc7593d | ||
|
|
a1cdcc442e | ||
|
|
bb5346c6c4 | ||
|
|
2f3e34439d | ||
|
|
bc48e6b64d | ||
|
|
022b272b9d | ||
|
|
51d3c8ffbf | ||
|
|
03bf84f12a | ||
|
|
9fffb08f5a | ||
|
|
2298db2982 | ||
|
|
3ee7c4afbb | ||
|
|
5588fedf1d | ||
|
|
b00e7bc1d0 | ||
|
|
6a615472a3 | ||
|
|
3bb74b70b6 | ||
|
|
92691b363d | ||
|
|
690f737a4c | ||
|
|
cf4b210ef8 | ||
|
|
6fb6cb83ab | ||
|
|
37b775a9b6 | ||
|
|
a3d7e70f41 |
No files matched your search
@@ -0,0 +1,31 @@
|
||||
name: Build Venus (Mali)
|
||||
# The Mali (Venus) route's binaries from tools/venus (David Cimo's recipes): Mesa's Venus ICD and the
|
||||
# Mali compatibility layer (glibc, for the session) and virglrenderer's vtest server (bionic, run by
|
||||
# the app over the phone's own Vulkan driver), packed as venus.tzst rooted at app/src/main. The apk
|
||||
# build fetches it by tools/venus/release.env (tag + sha256); nothing compiled is kept in this repo.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches: [test/non-adreno-all]
|
||||
paths: ['tools/venus/**', '.github/workflows/build-venus.yml']
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Tools
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y -qq ninja-build pkg-config zstd python3-pip
|
||||
pip3 install --break-system-packages 'meson>=1.5'
|
||||
- name: Build
|
||||
run: ANDROID_NDK_HOME="$ANDROID_NDK_LATEST_HOME" WORK=$PWD/venus-work tools/venus/ci-build.sh
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: venus
|
||||
path: |
|
||||
venus-work/venus.tzst
|
||||
venus-work/venus.tzst.sha256
|
||||
@@ -144,6 +144,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/docs/releases/media/
|
||||
@@ -265,6 +266,20 @@ jobs:
|
||||
if: steps.proot.outputs.cache-hit != 'true'
|
||||
run: python3 tools/components/prepare.py proot
|
||||
|
||||
- name: Build the non-Adreno test additions (Mali bridge client, Venus GL probe, Xclipse layer)
|
||||
run: |
|
||||
set -euo pipefail
|
||||
bash tools/ci/install-ubuntu-packages.sh gcc-aarch64-linux-gnu libvulkan-dev
|
||||
D=app/src/main/assets/linuxfs
|
||||
mkdir -p "$D/usr/local/bin" "$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/"
|
||||
external/MaliBridge/scripts/build-client-linux.sh "$D" aarch64-linux-gnu-gcc
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -o "$D/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$D/usr/local/bin/droiddeck-glprobe"
|
||||
|
||||
- name: Check the preloads
|
||||
run: |
|
||||
set -euo pipefail
|
||||
@@ -299,6 +314,7 @@ jobs:
|
||||
with:
|
||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
sparse-checkout: |
|
||||
/*
|
||||
!/docs/releases/media/
|
||||
@@ -526,6 +542,22 @@ jobs:
|
||||
echo "::warning::built proot pack $sha does not match tools/packs/proot/release.env ($PROOT_PACK_SHA256). This build publishes the pack it just built. Source builds keep downloading the pinned pack until release.env is updated."
|
||||
fi
|
||||
|
||||
# Mali (Venus), David Cimo's route: the vtest server (jniLibs), the Venus ICD (assets/venus)
|
||||
# and the Mali compatibility layer (assets/linuxfs), built by build-venus.yml and fetched by
|
||||
# tag + sha256 like gamescope. The app uses it only on a GPU that is not an Adreno.
|
||||
- name: Fetch the Mali (Venus) component (tools/venus/release.env)
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
. tools/venus/release.env
|
||||
gh release download "${VENUS_TAG}" -R "${VENUS_REPO}" -p venus.tzst -O venus.tzst
|
||||
echo "${VENUS_SHA256} venus.tzst" | sha256sum -c -
|
||||
tar --use-compress-program=unzstd -xf venus.tzst -C app/src/main
|
||||
test -f app/src/main/jniLibs/arm64-v8a/libvirgl_test_server.so
|
||||
test -f app/src/main/assets/venus/libvulkan_virtio.so
|
||||
rm venus.tzst
|
||||
|
||||
- name: Build
|
||||
id: build
|
||||
env:
|
||||
@@ -533,6 +565,7 @@ jobs:
|
||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||
run: |
|
||||
set -o pipefail
|
||||
python3 tools/powervr/fetch.py
|
||||
python3 tools/release/runtime_inputs.py record
|
||||
./gradlew assembleRelease --console=plain -PndkVersion="$NDK_VERSION" 2>&1 | tee /tmp/build.log
|
||||
python3 tools/release/check_session_assets.py app/build/outputs/apk/release/app-release.apk
|
||||
|
||||
@@ -32,4 +32,5 @@ __pycache__/
|
||||
|
||||
.signing.env
|
||||
app/src/main/assets/directaudio/
|
||||
app/src/main/assets/hybris/
|
||||
/tools/vr/out/
|
||||
@@ -0,0 +1,3 @@
|
||||
[submodule "external/MaliBridge"]
|
||||
path = external/MaliBridge
|
||||
url = https://github.com/ASEbrahim/MaliBridge.git
|
||||
@@ -5,7 +5,7 @@
|
||||
</picture>
|
||||
</p>
|
||||
|
||||
DroidDeck brings the SteamOS experience to Android: Valve's Steam client in Big Picture on your Adreno handheld, with Windows games through Valve's ARM64 Proton.
|
||||
DroidDeck brings the SteamOS experience to Android: Valve's Steam client in Big Picture on your Android handheld, with Windows games through Valve's ARM64 Proton.
|
||||
|
||||
<p align="center"><a href="https://discord.gg/JRGAvawjsm"><img src="https://img.shields.io/badge/Discord-Join%20the%20community-5865F2?logo=discord&logoColor=white" alt="Join the DroidDeck Discord"></a></p>
|
||||
|
||||
@@ -29,7 +29,7 @@ DroidDeck brings the SteamOS experience to Android: Valve's Steam client in Big
|
||||
|
||||
## Requirements and install
|
||||
|
||||
Use Android 9 or newer on a supported Adreno device (730 or newer, or 8xx). Adreno 6xx is experimental: DirectX 11 uses DXVK 2 and may run, and DirectX 12 games can still crash. Mali, Xclipse, PowerVR, and Adreno 710 are unsupported. No root is required. Allow about 3 GB for the runtime and 1.1 GB more for the desktop and emulators. Install the APK from [Releases](https://github.com/Droid-Deck/DroidDeck/releases), install the Linux runtime, then press **Play** and sign in. Steam downloads on first launch. Install **Desktop & apps** to use the desktop and emulators. The **Store** installs Linux apps and games from Flathub (ARM64 builds) with Flatpak; with additional options to install Appimages and set up scripts. **Stores** (Setup › Stores › "Show Stores in the rail") signs in to GOG, Epic Games and Amazon Games and downloads games into the Games storage. Epic keeps its direct API install path. Opening Epic Stores prepares Epic’s official Linux launcher preview. When installed, Epic games launched from DroidDeck use that client, and games installed in the client are imported into DroidDeck’s library and shortcuts. The x86-64 client runs through FEX on ARM and DroidDeck retains its Proton hooks; this preview and ARM setup are outside Epic’s listed Linux support. The cog on a store’s chip row sets its opening tab and download speed tier.
|
||||
Use Android 9 or newer on a supported Adreno device (730 or newer, or 8xx). Adreno 6xx is experimental: DirectX 11 uses DXVK 2 and may run, and DirectX 12 games can still crash. PowerVR support is experimental: where the system Vulkan backend is available, the app selects it automatically. Mali, Xclipse, and Adreno 710 are unsupported in official builds; this non-Adreno test build adds experimental routes for them. No root is required. Allow about 3 GB for the runtime and 1.1 GB more for the desktop and emulators. Install the APK from [Releases](https://github.com/Droid-Deck/DroidDeck/releases), install the Linux runtime, then press **Play** and sign in. Steam downloads on first launch. Install **Desktop & apps** to use the desktop and emulators. The **Store** installs Linux apps and games from Flathub (ARM64 builds) with Flatpak; with additional options to install Appimages and set up scripts. **Stores** (Setup › Stores › "Show Stores in the rail") signs in to GOG, Epic Games and Amazon Games and downloads games into the Games storage. Epic keeps its direct API install path. Opening Epic Stores prepares Epic’s official Linux launcher preview. When installed, Epic games launched from DroidDeck use that client, and games installed in the client are imported into DroidDeck’s library and shortcuts. The x86-64 client runs through FEX on ARM and DroidDeck retains its Proton hooks; this preview and ARM setup are outside Epic’s listed Linux support. The cog on a store’s chip row sets its opening tab and download speed tier.
|
||||
|
||||
On Android 14 and newer, before Steam launches, you must turn on **Disable child process restrictions** in Developer options. If this option is not available in developer settings (Android 12 and 13 devices), first launch of Steam will present a "Fix it for me" button, which will help automate the setup process.
|
||||
|
||||
|
||||
@@ -200,6 +200,9 @@ android {
|
||||
release {
|
||||
minifyEnabled false
|
||||
signingConfig signingConfigs.testkey
|
||||
// Mali bridge development fork: debuggable so `adb shell run-as` reaches the session
|
||||
// logs and VkBridgeNative's development override (-Pdroiddeck.notDebuggable to drop).
|
||||
debuggable !project.hasProperty('droiddeck.notDebuggable')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,6 +344,24 @@ def buildRustStores = tasks.register('buildRustStores', Exec) {
|
||||
if (!skipRust) android.sourceSets.main.jniLibs.srcDir(rustJniLibsDir)
|
||||
tasks.named('preBuild').configure { dependsOn(buildRustStores) }
|
||||
|
||||
// The Mali bridge's server (the MaliBridge submodule, external/MaliBridge) is a program, not a library:
|
||||
// it runs beside the session as the app's child, so a driver crash ends that process and not the
|
||||
// app. AGP's CMake integration packages only shared libraries, so the NDK's clang builds it here
|
||||
// into one more jniLibs source, named libvkbridge_server.so so Android extracts it (the native
|
||||
// library directory is the one place the app may exec from).
|
||||
def maliBridgeDir = rootProject.file('external/MaliBridge')
|
||||
def vkbridgeJniLibsDir = layout.buildDirectory.dir('vkbridgeJniLibs')
|
||||
def buildVkBridgeServer = tasks.register('buildVkBridgeServer', Exec) {
|
||||
description = 'Builds the Vulkan bridge server (libvkbridge_server.so) with the NDK.'
|
||||
inputs.dir(new File(maliBridgeDir, 'common'))
|
||||
inputs.dir(new File(maliBridgeDir, 'server'))
|
||||
inputs.file(new File(maliBridgeDir, 'scripts/build-server-android.sh'))
|
||||
outputs.dir(vkbridgeJniLibsDir)
|
||||
commandLine 'bash', new File(maliBridgeDir, 'scripts/build-server-android.sh').absolutePath,
|
||||
android.ndkDirectory.absolutePath, vkbridgeJniLibsDir.get().asFile.absolutePath
|
||||
}
|
||||
android.sourceSets.main.jniLibs.srcDir(vkbridgeJniLibsDir)
|
||||
tasks.named('preBuild').configure { dependsOn(buildVkBridgeServer) }
|
||||
dependencies {
|
||||
implementation "org.opencv:opencv:${trackingPack.OPENCV_VERSION}"
|
||||
implementation 'org.khronos.openxr:openxr_loader_for_android:1.1.49'
|
||||
|
||||
@@ -11,6 +11,7 @@ add_library(droiddeckwayland SHARED
|
||||
src/gpu_clock_pin.c
|
||||
src/droiddeck_ext.c
|
||||
src/wl_dmabuf.c
|
||||
src/wl_android_buffer.c
|
||||
src/wl_clipboard.c
|
||||
src/wl_text_input.c
|
||||
src/wl_toplevel_icon.c
|
||||
@@ -21,6 +22,7 @@ add_library(droiddeckwayland SHARED
|
||||
generated/color-management-v1-protocol.c
|
||||
generated/xdg-shell-protocol.c
|
||||
generated/linux-dmabuf-v1-protocol.c
|
||||
generated/wayland-android-protocol.c
|
||||
generated/viewporter-protocol.c
|
||||
generated/banner-desktop-v1-protocol.c
|
||||
generated/presentation-time-protocol.c
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/* Generated by wayland-scanner 1.26.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2012 Collabora, Ltd.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this
|
||||
* software and its documentation for any purpose is hereby granted
|
||||
* without fee, provided that the above copyright notice appear in
|
||||
* all copies and that both that copyright notice and this permission
|
||||
* notice appear in supporting documentation, and that the name of
|
||||
* the copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
* THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface android_wlegl_handle_interface;
|
||||
extern const struct wl_interface android_wlegl_server_buffer_handle_interface;
|
||||
extern const struct wl_interface wl_buffer_interface;
|
||||
|
||||
static const struct wl_interface *android_types[] = {
|
||||
NULL,
|
||||
NULL,
|
||||
&android_wlegl_handle_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&android_wlegl_handle_interface,
|
||||
&android_wlegl_server_buffer_handle_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&wl_buffer_interface,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message android_wlegl_requests[] = {
|
||||
{ "create_handle", "nia", android_types + 2 },
|
||||
{ "create_buffer", "niiiiio", android_types + 5 },
|
||||
{ "get_server_buffer_handle", "2niiii", android_types + 12 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface android_wlegl_interface = {
|
||||
"android_wlegl", 3,
|
||||
3, android_wlegl_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message android_wlegl_handle_requests[] = {
|
||||
{ "add_fd", "h", android_types + 0 },
|
||||
{ "destroy", "", android_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface android_wlegl_handle_interface = {
|
||||
"android_wlegl_handle", 1,
|
||||
2, android_wlegl_handle_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message android_wlegl_server_buffer_handle_events[] = {
|
||||
{ "buffer_fd", "h", android_types + 0 },
|
||||
{ "buffer_ints", "a", android_types + 0 },
|
||||
{ "buffer", "nii", android_types + 17 },
|
||||
{ "linear_layout", "3uu", android_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface android_wlegl_server_buffer_handle_interface = {
|
||||
"android_wlegl_server_buffer_handle", 3,
|
||||
0, NULL,
|
||||
4, android_wlegl_server_buffer_handle_events,
|
||||
};
|
||||
@@ -0,0 +1,341 @@
|
||||
/* Generated by wayland-scanner 1.26.0 */
|
||||
|
||||
#ifndef ANDROID_SERVER_PROTOCOL_H
|
||||
#define ANDROID_SERVER_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-server.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct wl_client;
|
||||
struct wl_resource;
|
||||
|
||||
/**
|
||||
* @page page_android The android protocol
|
||||
* @section page_ifaces_android Interfaces
|
||||
* - @subpage page_iface_android_wlegl - Android EGL graphics buffer support
|
||||
* - @subpage page_iface_android_wlegl_handle - An Android native_handle_t object
|
||||
* - @subpage page_iface_android_wlegl_server_buffer_handle - a server allocated buffer
|
||||
* @section page_copyright_android Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2012 Collabora, Ltd.
|
||||
*
|
||||
* Permission to use, copy, modify, distribute, and sell this
|
||||
* software and its documentation for any purpose is hereby granted
|
||||
* without fee, provided that the above copyright notice appear in
|
||||
* all copies and that both that copyright notice and this permission
|
||||
* notice appear in supporting documentation, and that the name of
|
||||
* the copyright holders not be used in advertising or publicity
|
||||
* pertaining to distribution of the software without specific,
|
||||
* written prior permission. The copyright holders make no
|
||||
* representations about the suitability of this software for any
|
||||
* purpose. It is provided "as is" without express or implied
|
||||
* warranty.
|
||||
*
|
||||
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
* THIS SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct android_wlegl;
|
||||
struct android_wlegl_handle;
|
||||
struct android_wlegl_server_buffer_handle;
|
||||
struct wl_buffer;
|
||||
|
||||
#ifndef ANDROID_WLEGL_INTERFACE
|
||||
#define ANDROID_WLEGL_INTERFACE
|
||||
/**
|
||||
* @page page_iface_android_wlegl android_wlegl
|
||||
* @section page_iface_android_wlegl_desc Description
|
||||
*
|
||||
* Interface used in the Android wrapper libEGL to share
|
||||
* graphics buffers between the server and the client.
|
||||
* @section page_iface_android_wlegl_api API
|
||||
* See @ref iface_android_wlegl.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_android_wlegl The android_wlegl interface
|
||||
*
|
||||
* Interface used in the Android wrapper libEGL to share
|
||||
* graphics buffers between the server and the client.
|
||||
*/
|
||||
extern const struct wl_interface android_wlegl_interface;
|
||||
#endif
|
||||
#ifndef ANDROID_WLEGL_HANDLE_INTERFACE
|
||||
#define ANDROID_WLEGL_HANDLE_INTERFACE
|
||||
/**
|
||||
* @page page_iface_android_wlegl_handle android_wlegl_handle
|
||||
* @section page_iface_android_wlegl_handle_desc Description
|
||||
*
|
||||
* The Android native_handle_t is a semi-opaque object, that
|
||||
* contains an EGL implementation specific number of int32
|
||||
* values and file descriptors.
|
||||
*
|
||||
* We cannot send a variable size array of file descriptors
|
||||
* over the Wayland protocol, so we send them one by one.
|
||||
* @section page_iface_android_wlegl_handle_api API
|
||||
* See @ref iface_android_wlegl_handle.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_android_wlegl_handle The android_wlegl_handle interface
|
||||
*
|
||||
* The Android native_handle_t is a semi-opaque object, that
|
||||
* contains an EGL implementation specific number of int32
|
||||
* values and file descriptors.
|
||||
*
|
||||
* We cannot send a variable size array of file descriptors
|
||||
* over the Wayland protocol, so we send them one by one.
|
||||
*/
|
||||
extern const struct wl_interface android_wlegl_handle_interface;
|
||||
#endif
|
||||
#ifndef ANDROID_WLEGL_SERVER_BUFFER_HANDLE_INTERFACE
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_INTERFACE
|
||||
/**
|
||||
* @page page_iface_android_wlegl_server_buffer_handle android_wlegl_server_buffer_handle
|
||||
* @section page_iface_android_wlegl_server_buffer_handle_desc Description
|
||||
*
|
||||
* On creation a server_side_buffer object will immediately send
|
||||
* the "buffer_fd" and "buffer_ints" events needed by the client to
|
||||
* reference the gralloc buffer, followed by the "buffer" event carrying
|
||||
* the wl_buffer object.
|
||||
* @section page_iface_android_wlegl_server_buffer_handle_api API
|
||||
* See @ref iface_android_wlegl_server_buffer_handle.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_android_wlegl_server_buffer_handle The android_wlegl_server_buffer_handle interface
|
||||
*
|
||||
* On creation a server_side_buffer object will immediately send
|
||||
* the "buffer_fd" and "buffer_ints" events needed by the client to
|
||||
* reference the gralloc buffer, followed by the "buffer" event carrying
|
||||
* the wl_buffer object.
|
||||
*/
|
||||
extern const struct wl_interface android_wlegl_server_buffer_handle_interface;
|
||||
#endif
|
||||
|
||||
#ifndef ANDROID_WLEGL_ERROR_ENUM
|
||||
#define ANDROID_WLEGL_ERROR_ENUM
|
||||
enum android_wlegl_error {
|
||||
ANDROID_WLEGL_ERROR_BAD_HANDLE = 0,
|
||||
ANDROID_WLEGL_ERROR_BAD_VALUE = 1,
|
||||
};
|
||||
#endif /* ANDROID_WLEGL_ERROR_ENUM */
|
||||
|
||||
#ifndef ANDROID_WLEGL_ERROR_ENUM_IS_VALID
|
||||
#define ANDROID_WLEGL_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_android_wlegl
|
||||
* Validate a android_wlegl error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref android_wlegl_error
|
||||
*/
|
||||
static inline bool
|
||||
android_wlegl_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ANDROID_WLEGL_ERROR_BAD_HANDLE:
|
||||
return version >= 1;
|
||||
case ANDROID_WLEGL_ERROR_BAD_VALUE:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ANDROID_WLEGL_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl
|
||||
* @struct android_wlegl_interface
|
||||
*/
|
||||
struct android_wlegl_interface {
|
||||
/**
|
||||
* Create an Android native_handle_t object
|
||||
*
|
||||
* This creator method initialises the native_handle_t object
|
||||
* with everything except the file descriptors, which have to be
|
||||
* submitted separately.
|
||||
* @param ints an array of int32_t
|
||||
*/
|
||||
void (*create_handle)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
int32_t num_fds,
|
||||
struct wl_array *ints);
|
||||
/**
|
||||
* Create a wl_buffer from the native handle
|
||||
*
|
||||
* Pass the Android native_handle_t to the server and attach it
|
||||
* to the new wl_buffer object.
|
||||
*
|
||||
* The android_wlegl_handle object must be destroyed immediately
|
||||
* after this request.
|
||||
*/
|
||||
void (*create_buffer)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t stride,
|
||||
int32_t format,
|
||||
int32_t usage,
|
||||
struct wl_resource *native_handle);
|
||||
/**
|
||||
* @since 2
|
||||
*/
|
||||
void (*get_server_buffer_handle)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
uint32_t id,
|
||||
int32_t width,
|
||||
int32_t height,
|
||||
int32_t format,
|
||||
int32_t usage);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl
|
||||
*/
|
||||
#define ANDROID_WLEGL_CREATE_HANDLE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl
|
||||
*/
|
||||
#define ANDROID_WLEGL_CREATE_BUFFER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl
|
||||
*/
|
||||
#define ANDROID_WLEGL_GET_SERVER_BUFFER_HANDLE_SINCE_VERSION 2
|
||||
|
||||
#ifndef ANDROID_WLEGL_HANDLE_ERROR_ENUM
|
||||
#define ANDROID_WLEGL_HANDLE_ERROR_ENUM
|
||||
enum android_wlegl_handle_error {
|
||||
ANDROID_WLEGL_HANDLE_ERROR_TOO_MANY_FDS = 0,
|
||||
};
|
||||
#endif /* ANDROID_WLEGL_HANDLE_ERROR_ENUM */
|
||||
|
||||
#ifndef ANDROID_WLEGL_HANDLE_ERROR_ENUM_IS_VALID
|
||||
#define ANDROID_WLEGL_HANDLE_ERROR_ENUM_IS_VALID
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_handle
|
||||
* Validate a android_wlegl_handle error value.
|
||||
*
|
||||
* @return true on success, false on error.
|
||||
* @ref android_wlegl_handle_error
|
||||
*/
|
||||
static inline bool
|
||||
android_wlegl_handle_error_is_valid(uint32_t value, uint32_t version) {
|
||||
switch (value) {
|
||||
case ANDROID_WLEGL_HANDLE_ERROR_TOO_MANY_FDS:
|
||||
return version >= 1;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* ANDROID_WLEGL_HANDLE_ERROR_ENUM_IS_VALID */
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_handle
|
||||
* @struct android_wlegl_handle_interface
|
||||
*/
|
||||
struct android_wlegl_handle_interface {
|
||||
/**
|
||||
*/
|
||||
void (*add_fd)(struct wl_client *client,
|
||||
struct wl_resource *resource,
|
||||
int32_t fd);
|
||||
/**
|
||||
*/
|
||||
void (*destroy)(struct wl_client *client,
|
||||
struct wl_resource *resource);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_HANDLE_ADD_FD_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_HANDLE_DESTROY_SINCE_VERSION 1
|
||||
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_FD 0
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_INTS 1
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER 2
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_LINEAR_LAYOUT 3
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_FD_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_INTS_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
*/
|
||||
#define ANDROID_WLEGL_SERVER_BUFFER_HANDLE_LINEAR_LAYOUT_SINCE_VERSION 3
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
* Sends an buffer_fd event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
android_wlegl_server_buffer_handle_send_buffer_fd(struct wl_resource *resource_, int32_t fd)
|
||||
{
|
||||
wl_resource_post_event(resource_, ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_FD, fd);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
* Sends an buffer_ints event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
android_wlegl_server_buffer_handle_send_buffer_ints(struct wl_resource *resource_, struct wl_array *ints)
|
||||
{
|
||||
wl_resource_post_event(resource_, ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER_INTS, ints);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
* Sends an buffer event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
android_wlegl_server_buffer_handle_send_buffer(struct wl_resource *resource_, struct wl_resource *buffer, int32_t format, int32_t stride)
|
||||
{
|
||||
wl_resource_post_event(resource_, ANDROID_WLEGL_SERVER_BUFFER_HANDLE_BUFFER, buffer, format, stride);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_android_wlegl_server_buffer_handle
|
||||
* Sends an linear_layout event to the client owning the resource.
|
||||
* @param resource_ The client's resource
|
||||
*/
|
||||
static inline void
|
||||
android_wlegl_server_buffer_handle_send_linear_layout(struct wl_resource *resource_, uint32_t drm_format, uint32_t stride)
|
||||
{
|
||||
wl_resource_post_event(resource_, ANDROID_WLEGL_SERVER_BUFFER_HANDLE_LINEAR_LAYOUT, drm_format, stride);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,139 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="android">
|
||||
|
||||
<copyright>
|
||||
Copyright © 2012 Collabora, Ltd.
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of
|
||||
the copyright holders not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission. The copyright holders make no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="android_wlegl" version="3">
|
||||
<description summary="Android EGL graphics buffer support">
|
||||
Interface used in the Android wrapper libEGL to share
|
||||
graphics buffers between the server and the client.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="bad_handle" value="0" />
|
||||
<entry name="bad_value" value="1" />
|
||||
</enum>
|
||||
|
||||
<request name="create_handle">
|
||||
<description summary="Create an Android native_handle_t object">
|
||||
This creator method initialises the native_handle_t object
|
||||
with everything except the file descriptors, which have to be
|
||||
submitted separately.
|
||||
</description>
|
||||
|
||||
<arg name="id" type="new_id" interface="android_wlegl_handle" />
|
||||
<arg name="num_fds" type="int" />
|
||||
<arg name="ints" type="array" summary="an array of int32_t" />
|
||||
</request>
|
||||
|
||||
<request name="create_buffer">
|
||||
<description summary="Create a wl_buffer from the native handle">
|
||||
Pass the Android native_handle_t to the server and attach it
|
||||
to the new wl_buffer object.
|
||||
|
||||
The android_wlegl_handle object must be destroyed immediately
|
||||
after this request.
|
||||
</description>
|
||||
|
||||
<arg name="id" type="new_id" interface="wl_buffer" />
|
||||
<arg name="width" type="int" />
|
||||
<arg name="height" type="int" />
|
||||
<arg name="stride" type="int" />
|
||||
<arg name="format" type="int" />
|
||||
<arg name="usage" type="int" />
|
||||
<arg name="native_handle" type="object" interface="android_wlegl_handle" />
|
||||
</request>
|
||||
|
||||
|
||||
<request name="get_server_buffer_handle" since="2">
|
||||
<arg name="id" type="new_id" interface="android_wlegl_server_buffer_handle"/>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
<arg name="format" type="int"/>
|
||||
<arg name="usage" type="int"/>
|
||||
</request>
|
||||
|
||||
</interface>
|
||||
|
||||
<interface name="android_wlegl_handle" version="1">
|
||||
<description summary="An Android native_handle_t object">
|
||||
The Android native_handle_t is a semi-opaque object, that
|
||||
contains an EGL implementation specific number of int32
|
||||
values and file descriptors.
|
||||
|
||||
We cannot send a variable size array of file descriptors
|
||||
over the Wayland protocol, so we send them one by one.
|
||||
</description>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="too_many_fds" value="0" />
|
||||
</enum>
|
||||
|
||||
<request name="add_fd">
|
||||
<arg name="fd" type="fd" />
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor" />
|
||||
|
||||
</interface>
|
||||
|
||||
|
||||
<interface name="android_wlegl_server_buffer_handle" version="3">
|
||||
<description summary="a server allocated buffer">
|
||||
On creation a server_side_buffer object will immediately send
|
||||
the "buffer_fd" and "buffer_ints" events needed by the client to
|
||||
reference the gralloc buffer, followed by the "buffer" event carrying
|
||||
the wl_buffer object.
|
||||
</description>
|
||||
<event name="buffer_fd">
|
||||
<arg name="fd" type="fd"/>
|
||||
</event>
|
||||
<event name="buffer_ints">
|
||||
<arg name="ints" type="array"/>
|
||||
</event>
|
||||
<event name="buffer">
|
||||
<description summary="the wl_buffer">
|
||||
This event will be sent after the ints and all the fds have been sent
|
||||
</description>
|
||||
<arg name="buffer" type="new_id" interface="wl_buffer"/>
|
||||
<arg name="format" type="int"/>
|
||||
<arg name="stride" type="int"/>
|
||||
</event>
|
||||
<event name="linear_layout" since="3">
|
||||
<description summary="verified single-plane linear allocation">
|
||||
Optional metadata sent before the buffer event. The first buffer_fd
|
||||
contains one uncompressed 32-bit RGB plane at byte offset zero.
|
||||
drm_format is its DRM FourCC and stride is its row pitch in bytes.
|
||||
The server has verified the layout and allocation bounds using
|
||||
Android mapper metadata, not inferred them from opaque handle ints.
|
||||
Absence of this event means the layout is unspecified.
|
||||
</description>
|
||||
<arg name="drm_format" type="uint"/>
|
||||
<arg name="stride" type="uint"/>
|
||||
</event>
|
||||
</interface>
|
||||
|
||||
</protocol>
|
||||
@@ -79,6 +79,9 @@ static struct ahb_buf *find_buf(uint64_t id) {
|
||||
}
|
||||
|
||||
static void buf_free(struct ahb_buf *ab) {
|
||||
/* A display release does not prove the compositor's Vulkan reads finished.
|
||||
* Keep the AHB reference and its DMA-BUF record even if the client is gone. */
|
||||
if (vkp_completion_unknown()) return;
|
||||
if (ab->resource) { wl_list_remove(&ab->resource_destroy.link); ab->resource = NULL; }
|
||||
if (ab->fence_src) { wl_event_source_remove(ab->fence_src); ab->fence_src = NULL; }
|
||||
if (ab->fence_fd >= 0) { close(ab->fence_fd); ab->fence_fd = -1; }
|
||||
@@ -103,6 +106,7 @@ static void on_buffer_resource_destroyed(struct wl_listener *l, void *data) {
|
||||
|
||||
|
||||
static void send_deferred_release(struct ahb_buf *ab) {
|
||||
if (vkp_completion_unknown()) return;
|
||||
if (ab->release_pending && ab->resource)
|
||||
droiddeck_release_buffer(ab->surface, ab->resource, ab->surface != NULL, ab->deferred_ns);
|
||||
ab->release_pending = 0;
|
||||
|
||||
@@ -154,6 +154,16 @@ static void on_client_destroyed(struct wl_listener *l, void *data) {
|
||||
free(ci);
|
||||
}
|
||||
|
||||
/* libwayland's own reasons for dropping a client (a failed read or flush, an invalid object, a
|
||||
* malformed request) go through wl_log, which on Android writes to a closed stderr. */
|
||||
static void wl_log_to_session(const char *fmt, va_list ap) {
|
||||
char line[512];
|
||||
vsnprintf(line, sizeof(line), fmt, ap);
|
||||
size_t n = strlen(line);
|
||||
while (n && (line[n - 1] == '\n' || line[n - 1] == '\r')) line[--n] = 0;
|
||||
droiddeck_log("program", "libwayland: %s", line);
|
||||
}
|
||||
|
||||
static void on_client_created(struct wl_listener *l, void *data) {
|
||||
struct wl_client *client = data;
|
||||
struct client_info *ci = calloc(1, sizeof(*ci));
|
||||
@@ -350,6 +360,62 @@ static void perf_note_release(int64_t since_ns) {
|
||||
}
|
||||
|
||||
|
||||
/* Completion-unknown is terminal for externally owned DMA-BUF contents too.
|
||||
* Keeping a VkImage alone cannot stop the client from overwriting its backing
|
||||
* memory after wl_buffer.release. All paths (including cursors and idle roles)
|
||||
* use this gate; copied SHM buffers retain their normal release behaviour. */
|
||||
static struct dmabuf_buffer *get_dmabuf(struct wl_resource *buffer);
|
||||
static int buffer_release_blocked(struct wl_resource *buffer) {
|
||||
return vkp_completion_unknown() && get_dmabuf(buffer) != NULL;
|
||||
}
|
||||
/* Buffer tracing on a GPU that is not an Adreno (no KGSL node): every attach and release of the
|
||||
* first 400 buffer events, by wl_buffer id and the line that sent it, and any release of a buffer
|
||||
* already released and not attached again since (gamescope: "Compositor released us but we were
|
||||
* not acquired"). Off on an Adreno. */
|
||||
static int g_buf_trace = -1;
|
||||
static int g_buf_trace_left = 400;
|
||||
static uint32_t g_released_ids[128];
|
||||
static int buf_trace_on(void) {
|
||||
if (g_buf_trace < 0) g_buf_trace = access("/dev/kgsl-3d0", F_OK) != 0;
|
||||
return g_buf_trace;
|
||||
}
|
||||
static void buf_trace_attach(struct wl_resource *buffer) {
|
||||
if (!buffer || !buf_trace_on()) return;
|
||||
uint32_t id = wl_resource_get_id(buffer);
|
||||
for (int i = 0; i < 128; i++) if (g_released_ids[i] == id) g_released_ids[i] = 0;
|
||||
if (g_buf_trace_left > 0) { g_buf_trace_left--; droiddeck_log("buffer", "attach id %u", id); }
|
||||
}
|
||||
static void buf_trace_release(struct wl_resource *buffer, int line) {
|
||||
if (!buffer || !buf_trace_on()) return;
|
||||
uint32_t id = wl_resource_get_id(buffer);
|
||||
int twice = 0, slot = -1;
|
||||
for (int i = 0; i < 128; i++) {
|
||||
if (g_released_ids[i] == id) twice = 1;
|
||||
if (slot < 0 && g_released_ids[i] == 0) slot = i;
|
||||
}
|
||||
if (twice) droiddeck_log("buffer", "DOUBLE release id %u (line %d): released again without an attach", id, line);
|
||||
else if (slot >= 0) g_released_ids[slot] = id;
|
||||
if (g_buf_trace_left > 0) { g_buf_trace_left--; droiddeck_log("buffer", "release id %u (line %d)", id, line); }
|
||||
}
|
||||
|
||||
#define send_buffer_release(b) send_buffer_release_at((b), __LINE__)
|
||||
static void send_buffer_release_at(struct wl_resource *buffer, int line) {
|
||||
if (!buffer_release_blocked(buffer)) { buf_trace_release(buffer, line); wl_buffer_send_release(buffer); }
|
||||
}
|
||||
|
||||
/* Whether a surface other than `except` is showing this buffer right now. gamescope's Wayland
|
||||
* backend moves one buffer between its planes (the game's frame goes from the window to a
|
||||
* subsurface above a black backing while a Steam notification is up): releasing it when the first
|
||||
* surface lets go handed gamescope a buffer still on screen ("Compositor released us but we were
|
||||
* not acquired"). Only the last surface to let go releases it. */
|
||||
static int buffer_shown_elsewhere(struct wl_resource *buffer, const struct surface *except) {
|
||||
struct surface *o;
|
||||
if (!buffer) return 0;
|
||||
wl_list_for_each(o, &g_surfaces, link)
|
||||
if (o != except && o->dmabuf == buffer) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void pending_release_free(struct pending_release *pr) {
|
||||
if (pr->surface && pr->surface->releases_pending > 0) pr->surface->releases_pending--;
|
||||
wl_list_remove(&pr->destroy.link);
|
||||
@@ -373,7 +439,8 @@ static void arm_release_timer(void) {
|
||||
int64_t earliest = 0;
|
||||
if (g_release_timer_fd < 0) return;
|
||||
wl_list_for_each(pr, &g_pending_releases, link)
|
||||
if (!earliest || pr->at_ns < earliest) earliest = pr->at_ns;
|
||||
if (!buffer_release_blocked(pr->buffer) && (!earliest || pr->at_ns < earliest))
|
||||
earliest = pr->at_ns;
|
||||
struct itimerspec its = {0};
|
||||
if (earliest) { its.it_value.tv_sec = earliest / 1000000000LL; its.it_value.tv_nsec = earliest % 1000000000LL; }
|
||||
timerfd_settime(g_release_timer_fd, TFD_TIMER_ABSTIME, &its, NULL);
|
||||
@@ -385,8 +452,13 @@ static int on_release_timer(int fd, uint32_t mask, void *data) {
|
||||
int64_t now = now_ns() + 300000;
|
||||
if (read(fd, &expirations, sizeof(expirations)) < 0 && errno != EAGAIN) return 0;
|
||||
wl_list_for_each_safe(pr, tmp, &g_pending_releases, link) {
|
||||
if (pr->at_ns <= now) {
|
||||
wl_buffer_send_release(pr->buffer);
|
||||
if (pr->at_ns <= now && !buffer_release_blocked(pr->buffer)) {
|
||||
/* Attached again since (to its surface or another): that surface releases it later. */
|
||||
if (buffer_shown_elsewhere(pr->buffer, NULL)) {
|
||||
pending_release_free(pr);
|
||||
continue;
|
||||
}
|
||||
send_buffer_release(pr->buffer);
|
||||
perf_note_release(pr->since_ns);
|
||||
pending_release_free(pr);
|
||||
}
|
||||
@@ -397,9 +469,12 @@ static int on_release_timer(int fd, uint32_t mask, void *data) {
|
||||
}
|
||||
|
||||
static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_t since_ns) {
|
||||
/* No allocation or immediate-release fallback is allowed for a quarantined
|
||||
* DMA-BUF. Existing queued releases stay held; their timer is disarmed. */
|
||||
if (buffer_release_blocked(buffer)) return;
|
||||
const int limit = g_fps_limit;
|
||||
const int64_t interval = limit > 0 ? 1000000000LL / limit : g_refresh_ns;
|
||||
if (g_release_unpaced || interval <= 0 || g_release_timer_fd < 0) { wl_buffer_send_release(buffer); perf_note_release(since_ns); return; }
|
||||
if (g_release_unpaced || interval <= 0 || g_release_timer_fd < 0) { send_buffer_release(buffer); perf_note_release(since_ns); return; }
|
||||
int64_t now = now_ns();
|
||||
int64_t at = s->next_release_ns + interval;
|
||||
int64_t latest = now + interval * (int64_t)(s->releases_pending + 1);
|
||||
@@ -407,7 +482,7 @@ static void release_buffer(struct surface *s, struct wl_resource *buffer, int64_
|
||||
if (at > latest) at = latest;
|
||||
s->next_release_ns = at;
|
||||
struct pending_release *pr = calloc(1, sizeof(*pr));
|
||||
if (!pr) { wl_buffer_send_release(buffer); perf_note_release(since_ns); return; }
|
||||
if (!pr) { send_buffer_release(buffer); perf_note_release(since_ns); return; }
|
||||
pr->buffer = buffer;
|
||||
pr->surface = s;
|
||||
pr->at_ns = at;
|
||||
@@ -518,7 +593,10 @@ static void constraints_focus_entered(struct wl_resource *target, struct wl_clie
|
||||
|
||||
|
||||
void dmabuf_buffer_unref(struct dmabuf_buffer *b) {
|
||||
if (!b || --b->refs > 0) return;
|
||||
/* Surface/client destruction must not close the backing FDs or free the
|
||||
* imported-buffer record while a GPU read may still be pending. Retain the
|
||||
* reference without allocating a quarantine node; process exit reclaims it. */
|
||||
if (!b || vkp_completion_unknown() || --b->refs > 0) return;
|
||||
vkp_image_destroy(b->img);
|
||||
for (int i = 0; i < b->n_planes; i++)
|
||||
if (b->fd[i] >= 0) close(b->fd[i]);
|
||||
@@ -617,9 +695,10 @@ static void unmap_toplevel(struct surface *s) {
|
||||
static void drop_dmabuf(struct surface *s, int paced) {
|
||||
if (s->dmabuf) {
|
||||
wl_list_remove(&s->dmabuf_destroy.link);
|
||||
if (!ahb_swapchain_defer_release(s->dmabuf_buf, s->dmabuf, s, paced)) {
|
||||
if (buffer_shown_elsewhere(s->dmabuf, s)) {
|
||||
} else if (!ahb_swapchain_defer_release(s->dmabuf_buf, s->dmabuf, s, paced)) {
|
||||
if (paced) release_buffer(s, s->dmabuf, now_ns());
|
||||
else wl_buffer_send_release(s->dmabuf);
|
||||
else send_buffer_release(s->dmabuf);
|
||||
}
|
||||
s->dmabuf = NULL;
|
||||
}
|
||||
@@ -728,7 +807,7 @@ static void take_shm(struct surface *s, struct wl_shm_buffer *shm, struct wl_res
|
||||
vkp_image_upload_shm(s->shm_img, wl_shm_buffer_get_data(shm), stride);
|
||||
wl_shm_buffer_end_access(shm);
|
||||
}
|
||||
wl_buffer_send_release(buffer);
|
||||
send_buffer_release(buffer);
|
||||
s->buf_w = w;
|
||||
s->buf_h = h;
|
||||
s->buf_alpha = wl_shm_buffer_get_format(shm) == WL_SHM_FORMAT_ARGB8888;
|
||||
@@ -772,7 +851,7 @@ static void take_pixel(struct surface *s, const uint8_t bgra[4], struct wl_resou
|
||||
}
|
||||
if (!s->shm_img) s->shm_img = vkp_image_create_shm(1, 1);
|
||||
if (s->shm_img) vkp_image_upload_shm(s->shm_img, bgra, 4);
|
||||
wl_buffer_send_release(buffer);
|
||||
send_buffer_release(buffer);
|
||||
s->buf_w = 1;
|
||||
s->buf_h = 1;
|
||||
s->buf_alpha = bgra[3] != 0xff;
|
||||
@@ -875,8 +954,9 @@ void **droiddeck_dmabuf_ahb_slot(struct dmabuf_buffer *b) { return &b->ahb_state
|
||||
void droiddeck_dmabuf_ref(struct dmabuf_buffer *b) { b->refs++; }
|
||||
void droiddeck_dmabuf_unref(struct dmabuf_buffer *b) { dmabuf_buffer_unref(b); }
|
||||
void droiddeck_release_buffer(struct surface *s, struct wl_resource *buffer, int paced, int64_t since_ns) {
|
||||
if (buffer_release_blocked(buffer)) return;
|
||||
if (paced && s) release_buffer(s, buffer, since_ns);
|
||||
else { wl_buffer_send_release(buffer); perf_note_release(since_ns); }
|
||||
else { send_buffer_release(buffer); perf_note_release(since_ns); }
|
||||
}
|
||||
void droiddeck_surface_describe(const struct surface *s, char *out, size_t size) { describe(s, out, size); }
|
||||
const struct droiddeck_color *droiddeck_surface_color(const struct surface *s) {
|
||||
@@ -1096,7 +1176,7 @@ static void surface_hold_idle(struct surface *s, struct wl_resource *buffer) {
|
||||
struct wl_shm_buffer *shm = db ? NULL : wl_shm_buffer_get(buffer);
|
||||
int64_t px = db ? (int64_t)db->width * db->height
|
||||
: shm ? (int64_t)wl_shm_buffer_get_width(shm) * wl_shm_buffer_get_height(shm) : 0;
|
||||
if (px <= 0 || px > CURSOR_MAX_PX) { wl_buffer_send_release(buffer); return; }
|
||||
if (px <= 0 || px > CURSOR_MAX_PX) { send_buffer_release(buffer); return; }
|
||||
s->idle_buffer = buffer;
|
||||
s->idle_buffer_destroy.notify = on_idle_buffer_destroyed;
|
||||
wl_resource_add_destroy_listener(buffer, &s->idle_buffer_destroy);
|
||||
@@ -1114,7 +1194,7 @@ static struct wl_resource *surface_take_idle(struct surface *s) {
|
||||
static void surface_drop_idle(struct surface *s) {
|
||||
surface_forget_idle_px(s);
|
||||
struct wl_resource *buffer = surface_take_idle(s);
|
||||
if (buffer) wl_buffer_send_release(buffer);
|
||||
if (buffer) send_buffer_release(buffer);
|
||||
}
|
||||
|
||||
static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
@@ -1167,11 +1247,12 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
cursor_publish_hidden();
|
||||
} else {
|
||||
cursor_publish_buffer(s, buffer);
|
||||
wl_buffer_send_release(buffer);
|
||||
send_buffer_release(buffer);
|
||||
}
|
||||
} else if (s->role == ROLE_NONE) {
|
||||
if (buffer) surface_hold_idle(s, buffer);
|
||||
} else if (db) {
|
||||
buf_trace_attach(buffer);
|
||||
take_dmabuf(s, db, buffer);
|
||||
} else if (shm) {
|
||||
drop_dmabuf(s, 1);
|
||||
@@ -1182,7 +1263,7 @@ static void surface_commit(struct wl_client *c, struct wl_resource *r) {
|
||||
} else {
|
||||
drop_dmabuf(s, 1);
|
||||
s->has_content = 0;
|
||||
if (buffer) wl_buffer_send_release(buffer);
|
||||
if (buffer) send_buffer_release(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2421,7 +2502,7 @@ static void pointer_set_cursor(struct wl_client *c, struct wl_resource *r, uint3
|
||||
struct wl_resource *buffer = surface_take_idle(s);
|
||||
if (buffer) {
|
||||
cursor_publish_buffer(s, buffer);
|
||||
wl_buffer_send_release(buffer);
|
||||
send_buffer_release(buffer);
|
||||
} else if (g_cursor_shown == s) {
|
||||
cursor_publish_shown();
|
||||
} else if (s->idle_px) {
|
||||
@@ -3717,6 +3798,10 @@ int droiddeck_wayland_run(void) {
|
||||
return 1;
|
||||
}
|
||||
droiddeck_log("display", "Wayland compositor listening on %s/wayland-0", rt ? rt : "?");
|
||||
wl_log_set_handler_server(wl_log_to_session);
|
||||
/* A client that falls behind reading (gamescope at a few fps) must not be dropped for a full
|
||||
* event buffer: libwayland's default is 4 KB per direction. */
|
||||
wl_display_set_default_max_buffer_size(display, 1u << 20);
|
||||
wl_display_add_client_created_listener(display, &g_client_created);
|
||||
|
||||
wl_global_create(display, &wl_compositor_interface, 6, NULL, bind_compositor);
|
||||
@@ -3727,6 +3812,7 @@ int droiddeck_wayland_run(void) {
|
||||
wl_global_create(display, &wl_output_interface, 4, NULL, bind_output);
|
||||
wl_global_create(display, &xdg_wm_base_interface, 1, NULL, bind_xdg_wm_base);
|
||||
wl_global_create(display, &zwp_linux_dmabuf_v1_interface, 4, NULL, bind_dmabuf);
|
||||
droiddeck_android_wlegl_init(display);
|
||||
wl_global_create(display, &wl_seat_interface, 9, NULL, bind_seat);
|
||||
wl_global_create(display, &banner_desktop_v1_interface, 1, NULL, bind_desktop);
|
||||
wl_global_create(display, &wp_presentation_interface, 2, NULL, bind_presentation);
|
||||
|
||||
@@ -61,3 +61,6 @@ extern volatile int g_no_render_node;
|
||||
|
||||
COMPOSITOR_INTERNAL extern dev_t g_main_device;
|
||||
COMPOSITOR_INTERNAL void bind_dmabuf(struct wl_client *c, void *data, uint32_t ver, uint32_t id);
|
||||
|
||||
/* ---- wl_android_buffer.c */
|
||||
COMPOSITOR_INTERNAL void droiddeck_android_wlegl_init(struct wl_display *display);
|
||||
@@ -0,0 +1,47 @@
|
||||
#ifndef VK_EXTERNAL_IMAGE_SYNC_H
|
||||
#define VK_EXTERNAL_IMAGE_SYNC_H
|
||||
|
||||
#include <vulkan/vulkan.h>
|
||||
|
||||
struct vkp_external_client_barrier_pair {
|
||||
VkImageMemoryBarrier acquire;
|
||||
VkImageMemoryBarrier release;
|
||||
};
|
||||
|
||||
static inline int vkp_is_external_client_image(int dmabuf, int blit_dst) {
|
||||
return dmabuf && !blit_dst;
|
||||
}
|
||||
|
||||
/* Client-owned dma-bufs, including AHardwareBuffers, live in GENERAL while
|
||||
* FOREIGN owns them. Layer pool dma-bufs are destinations with a separate
|
||||
* acquire/release lifecycle and must never take this source-image path. */
|
||||
static inline int vkp_external_client_barrier_pair(
|
||||
VkImage image, uint32_t queue_family, int dmabuf, int blit_dst,
|
||||
struct vkp_external_client_barrier_pair *pair) {
|
||||
if (!vkp_is_external_client_image(dmabuf, blit_dst) || !pair) return 0;
|
||||
|
||||
const VkImageSubresourceRange range = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
||||
pair->acquire = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.dstQueueFamilyIndex = queue_family,
|
||||
.image = image,
|
||||
.subresourceRange = range,
|
||||
.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||
};
|
||||
pair->release = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||
.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = queue_family,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT,
|
||||
.image = image,
|
||||
.subresourceRange = range,
|
||||
.srcAccessMask = VK_ACCESS_MEMORY_READ_BIT,
|
||||
};
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -12,7 +12,7 @@
|
||||
X(CreateAndroidSurfaceKHR) X(DestroySurfaceKHR) X(CreateDevice) \
|
||||
X(GetDeviceProcAddr) X(EnumerateDeviceExtensionProperties) \
|
||||
X(GetPhysicalDeviceMemoryProperties) X(GetPhysicalDeviceFormatProperties2) \
|
||||
X(GetPhysicalDeviceImageFormatProperties2)
|
||||
X(GetPhysicalDeviceImageFormatProperties2) X(GetPhysicalDeviceProperties2)
|
||||
|
||||
#define VK_DEVICE_FUNCS(X) \
|
||||
X(GetDeviceQueue) X(CreateSwapchainKHR) X(DestroySwapchainKHR) X(GetSwapchainImagesKHR) \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#define _POSIX_C_SOURCE 200809L
|
||||
#include "vk_present.h"
|
||||
#include "vk_loader.h"
|
||||
#include "vk_external_image_sync.h"
|
||||
#include "sc_layer.h"
|
||||
#include "effects_chain.h"
|
||||
#include "cardboard.h"
|
||||
@@ -18,6 +19,7 @@
|
||||
#include <poll.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
#include <stdarg.h>
|
||||
#include <android/log.h>
|
||||
#include <android/hardware_buffer.h>
|
||||
|
||||
@@ -37,16 +39,59 @@ struct vkp_image {
|
||||
int in_general;
|
||||
VkFormat fmt;
|
||||
int sampled;
|
||||
AHardwareBuffer *android_buffer;
|
||||
};
|
||||
|
||||
static ANativeWindow *g_window;
|
||||
static int g_ahb_import;
|
||||
static char *g_driver_path, *g_library_name, *g_native_lib_dir;
|
||||
static int g_dev_state;
|
||||
static void device_lost(const char *where);
|
||||
static const char *vk_result_name(VkResult r);
|
||||
|
||||
/* Why the compositor cannot present ("" while it can). Logged as a DD_PRESENT_FAULT line, read
|
||||
* back over JNI, and shown on the session-ended screen instead of a silent black one. */
|
||||
static char g_fault[256];
|
||||
static char g_swap_reason[160];
|
||||
static pthread_mutex_t g_fault_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
static void set_fault(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
||||
static void set_fault(const char *fmt, ...) {
|
||||
char msg[sizeof(g_fault)];
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, sizeof(msg), fmt, ap);
|
||||
va_end(ap);
|
||||
pthread_mutex_lock(&g_fault_lock);
|
||||
int same = !strcmp(msg, g_fault);
|
||||
if (!same) snprintf(g_fault, sizeof(g_fault), "%s", msg);
|
||||
pthread_mutex_unlock(&g_fault_lock);
|
||||
if (!same) droiddeck_log("present", "DD_PRESENT_FAULT: %s", msg);
|
||||
}
|
||||
static void clear_fault(void) {
|
||||
pthread_mutex_lock(&g_fault_lock);
|
||||
int had = g_fault[0] != 0;
|
||||
g_fault[0] = 0;
|
||||
pthread_mutex_unlock(&g_fault_lock);
|
||||
if (had) droiddeck_log("present", "presentation recovered: fault cleared");
|
||||
}
|
||||
const char *vkp_fault(void) {
|
||||
static __thread char copy[sizeof(g_fault)];
|
||||
pthread_mutex_lock(&g_fault_lock);
|
||||
snprintf(copy, sizeof(copy), "%s", g_fault);
|
||||
pthread_mutex_unlock(&g_fault_lock);
|
||||
if (!copy[0] && g_dev_state == -3)
|
||||
snprintf(copy, sizeof(copy), "the GPU did not confirm the compositor's work finished; presenting stopped");
|
||||
return copy;
|
||||
}
|
||||
|
||||
/* The driver that answered for the display, as the driver itself reports it. */
|
||||
static char g_display_driver[320];
|
||||
const char *vkp_display_driver(void) { return g_display_driver; }
|
||||
static VkInstance g_inst;
|
||||
static VkPhysicalDevice g_pd;
|
||||
static VkDevice g_dev;
|
||||
static VkQueue g_queue;
|
||||
static PFN_vkGetAndroidHardwareBufferPropertiesANDROID g_ahb_properties;
|
||||
static uint32_t g_qfam;
|
||||
static VkCommandPool g_pool;
|
||||
#define MAX_PRESENTS (1 + VKP_FG_MAX_GENERATIONS)
|
||||
@@ -106,10 +151,22 @@ static void perf_add(int64_t *sum, int64_t *max, unsigned *count, int64_t d) {
|
||||
if (d > *max) *max = d;
|
||||
(*count)++;
|
||||
}
|
||||
static void quarantine_pending_work(VkResult result, const char *where) {
|
||||
if (g_dev_state != 1) return;
|
||||
g_dev_state = -3;
|
||||
g_base_black = 0;
|
||||
LOGE("GPU completion unconfirmed (%d in %s): presenting stopped; pending resources retained; "
|
||||
"restart DroidDeck", (int)result, where);
|
||||
}
|
||||
|
||||
static VkResult timed_wait(VkFence fence, uint64_t timeout) {
|
||||
if (g_dev_state != 1)
|
||||
return g_dev_state == -2 ? VK_ERROR_DEVICE_LOST : VK_ERROR_UNKNOWN;
|
||||
int64_t t0 = perf_now();
|
||||
VkResult r = g_vk.WaitForFences(g_dev, 1, &fence, VK_TRUE, timeout);
|
||||
perf_add(&g_perf.wait_ns, &g_perf.wait_max_ns, &g_perf.waits, perf_now() - t0);
|
||||
if (r != VK_SUCCESS && r != VK_ERROR_DEVICE_LOST)
|
||||
quarantine_pending_work(r, "fence wait");
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -204,7 +261,12 @@ static void reset_sync(void) {
|
||||
static void destroy_swapchain(void) {
|
||||
g_base_black = 0;
|
||||
if (g_dev_state != 1) return;
|
||||
g_vk.DeviceWaitIdle(g_dev);
|
||||
VkResult idle = g_vk.DeviceWaitIdle(g_dev);
|
||||
if (idle != VK_SUCCESS) {
|
||||
if (idle == VK_ERROR_DEVICE_LOST) device_lost("swapchain idle");
|
||||
else quarantine_pending_work(idle, "swapchain idle");
|
||||
return;
|
||||
}
|
||||
reset_sync();
|
||||
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);
|
||||
@@ -294,6 +356,7 @@ int vkp_has_window(void) {
|
||||
}
|
||||
|
||||
int vkp_device_lost(void) { return g_dev_state == -2; }
|
||||
int vkp_completion_unknown(void) { return g_dev_state == -3; }
|
||||
|
||||
void vk_present_set_scale_mode(int mode, int alignment) {
|
||||
if (mode < VKP_MODE_OFF || mode > VKP_MODE_INTEGER) mode = VKP_MODE_FIT;
|
||||
@@ -404,11 +467,43 @@ static int has_ext(VkExtensionProperties *e, uint32_t n, const char *name) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 ||
|
||||
id == VK_DRIVER_ID_BROADCOM_PROPRIETARY;
|
||||
}
|
||||
|
||||
/* What really loaded: adrenotools falls back to the vendor driver when the requested one fails
|
||||
* to load (hook_impl.cpp), so the name asked for is not proof of the driver in use. */
|
||||
static void log_display_driver(void) {
|
||||
PFN_vkGetPhysicalDeviceProperties2 props2 = g_vk.GetPhysicalDeviceProperties2;
|
||||
VkPhysicalDeviceDriverProperties drv = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES};
|
||||
VkPhysicalDeviceProperties2 p2 = {.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2, .pNext = &drv};
|
||||
if (!props2) {
|
||||
snprintf(g_display_driver, sizeof(g_display_driver), "%.200s (driver properties not available)", g_gpu_name);
|
||||
droiddeck_log("gpu", "display driver: %s", g_display_driver);
|
||||
return;
|
||||
}
|
||||
props2(g_pd, &p2);
|
||||
int fell_back = g_library_name && is_proprietary(drv.driverID);
|
||||
snprintf(g_display_driver, sizeof(g_display_driver), "%.80s: %.64s %.96s (driver id %d, Vulkan %u.%u.%u)%s", p2.properties.deviceName,
|
||||
drv.driverName, drv.driverInfo, (int)drv.driverID, VK_API_VERSION_MAJOR(p2.properties.apiVersion),
|
||||
VK_API_VERSION_MINOR(p2.properties.apiVersion), VK_API_VERSION_PATCH(p2.properties.apiVersion),
|
||||
fell_back ? " - FELL BACK to the phone's own driver" : "");
|
||||
droiddeck_log("gpu", "display driver loaded: %s", g_display_driver);
|
||||
if (fell_back)
|
||||
droiddeck_log("gpu", "display driver: %s was requested but the phone's own driver answered; the requested "
|
||||
"driver did not load (a missing library beside it, or a rejected ABI - see the adrenotools lines)",
|
||||
g_library_name);
|
||||
}
|
||||
|
||||
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) {
|
||||
LOGE("present: vk_loader_open failed"); g_dev_state = -1; return -1;
|
||||
LOGE("present: vk_loader_open failed"); g_dev_state = -1;
|
||||
set_fault("no Vulkan driver could be loaded for the display (%s)", g_library_name ? g_library_name : "libvulkan.so");
|
||||
return -1;
|
||||
}
|
||||
|
||||
const char *inst_exts[3] = {VK_KHR_SURFACE_EXTENSION_NAME,
|
||||
@@ -439,13 +534,19 @@ static int dev_init(void) {
|
||||
.enabledExtensionCount = n_inst_exts,
|
||||
.ppEnabledExtensionNames = inst_exts};
|
||||
if (g_vk.CreateInstance(&ici, NULL, &g_inst) != VK_SUCCESS) {
|
||||
LOGE("present: vkCreateInstance failed"); g_dev_state = -1; return -1;
|
||||
LOGE("present: vkCreateInstance failed"); g_dev_state = -1;
|
||||
set_fault("vkCreateInstance failed on the display driver (%s)", g_library_name ? g_library_name : "the phone's own");
|
||||
return -1;
|
||||
}
|
||||
vk_loader_load_instance(g_inst);
|
||||
|
||||
uint32_t npd = 0;
|
||||
g_vk.EnumeratePhysicalDevices(g_inst, &npd, NULL);
|
||||
if (!npd) { LOGE("present: no physical devices"); g_dev_state = -1; return -1; }
|
||||
if (!npd) {
|
||||
LOGE("present: no physical devices"); g_dev_state = -1;
|
||||
set_fault("the display driver exposed no GPU to the app");
|
||||
return -1;
|
||||
}
|
||||
VkPhysicalDevice pds[8]; if (npd > 8) npd = 8;
|
||||
g_vk.EnumeratePhysicalDevices(g_inst, &npd, pds);
|
||||
g_pd = VK_NULL_HANDLE;
|
||||
@@ -457,7 +558,11 @@ static int dev_init(void) {
|
||||
for (uint32_t q = 0; q < nq; q++)
|
||||
if (qs[q].queueFlags & VK_QUEUE_GRAPHICS_BIT) { g_pd = pds[i]; g_qfam = q; break; }
|
||||
}
|
||||
if (g_pd == VK_NULL_HANDLE) { LOGE("present: no graphics queue"); g_dev_state = -1; return -1; }
|
||||
if (g_pd == VK_NULL_HANDLE) {
|
||||
LOGE("present: no graphics queue"); g_dev_state = -1;
|
||||
set_fault("the display GPU offers no graphics queue");
|
||||
return -1;
|
||||
}
|
||||
{
|
||||
VkPhysicalDeviceProperties props;
|
||||
g_vk.GetPhysicalDeviceProperties(g_pd, &props);
|
||||
@@ -476,6 +581,21 @@ static int dev_init(void) {
|
||||
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, NULL);
|
||||
VkExtensionProperties *exts = calloc(ne ? ne : 1, sizeof(*exts));
|
||||
g_vk.EnumerateDeviceExtensionProperties(g_pd, NULL, &ne, exts);
|
||||
if (!g_library_name || !strstr(g_library_name, "freedreno")) {
|
||||
char names[440];
|
||||
size_t len = 0;
|
||||
names[0] = 0;
|
||||
droiddeck_log("gpu", "device extensions: %u", ne);
|
||||
for (uint32_t i = 0; i < ne; i++) {
|
||||
if (len + strlen(exts[i].extensionName) + 2 > sizeof(names)) {
|
||||
droiddeck_log("gpu", " %s", names);
|
||||
len = 0;
|
||||
names[0] = 0;
|
||||
}
|
||||
len += (size_t)snprintf(names + len, sizeof(names) - len, "%s%s", len ? " " : "", exts[i].extensionName);
|
||||
}
|
||||
if (len) droiddeck_log("gpu", " %s", names);
|
||||
}
|
||||
/* Only what the driver has: the system driver lacks the dma-buf ones, which the cloud player never needs. */
|
||||
for (unsigned i = 0; i < 4; i++) {
|
||||
if (has_ext(exts, ne, import_exts[i])) dev_exts[n_dev_exts++] = import_exts[i];
|
||||
@@ -491,6 +611,8 @@ static int dev_init(void) {
|
||||
/* The cloud player's decoded frames arrive as AHardwareBuffers (vkp_image_from_ahb). */
|
||||
g_ahb_import = has_ext(exts, ne, VK_ANDROID_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER_EXTENSION_NAME) &&
|
||||
has_ext(exts, ne, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME);
|
||||
/* The present path's own AHB import (#561) stays on the phone's own driver. */
|
||||
const int want_ahb = !g_library_name && g_ahb_import;
|
||||
if (g_ahb_import) {
|
||||
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;
|
||||
@@ -513,10 +635,16 @@ static int dev_init(void) {
|
||||
dr = g_vk.CreateDevice(g_pd, &dci, NULL, &g_dev);
|
||||
}
|
||||
if (dr != VK_SUCCESS) {
|
||||
LOGE("present: vkCreateDevice failed"); g_dev_state = -1; return -1;
|
||||
LOGE("present: vkCreateDevice failed"); g_dev_state = -1;
|
||||
set_fault("vkCreateDevice failed on %s (%s)", g_gpu_name[0] ? g_gpu_name : "the display GPU", vk_result_name(dr));
|
||||
return -1;
|
||||
}
|
||||
vk_loader_load_device(g_dev);
|
||||
log_display_driver();
|
||||
g_vk.GetDeviceQueue(g_dev, g_qfam, 0, &g_queue);
|
||||
if (want_ahb)
|
||||
g_ahb_properties = (PFN_vkGetAndroidHardwareBufferPropertiesANDROID)
|
||||
g_vk.GetDeviceProcAddr(g_dev, "vkGetAndroidHardwareBufferPropertiesANDROID");
|
||||
if (want_sem_fd) {
|
||||
g_import_sem_fd = (PFN_vkImportSemaphoreFdKHR)g_vk.GetDeviceProcAddr(g_dev, "vkImportSemaphoreFdKHR");
|
||||
VkSemaphoreCreateInfo wsci = {.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO};
|
||||
@@ -553,6 +681,7 @@ static int dev_init(void) {
|
||||
g_dev_state = 1;
|
||||
reset_sync();
|
||||
init_black_image();
|
||||
if (g_dev_state != 1) return -1;
|
||||
vkp_framegen_device_ready(g_dev, g_queue, g_qfam, fg_features != NULL);
|
||||
return 0;
|
||||
}
|
||||
@@ -564,13 +693,15 @@ static int swap_init_locked(void);
|
||||
static int swap_init(void) {
|
||||
struct timespec ts;
|
||||
int64_t now;
|
||||
if (!g_window) return -1;
|
||||
if (!g_window || g_dev_state != 1) return -1;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
now = (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||
if (now < g_swap_retry_at_ns) return -1;
|
||||
g_swap_reason[0] = 0;
|
||||
if (swap_init_locked() == 0) {
|
||||
g_swap_retry_at_ns = 0;
|
||||
g_swap_fail_logged = 0;
|
||||
clear_fault();
|
||||
return 0;
|
||||
}
|
||||
destroy_swapchain();
|
||||
@@ -578,11 +709,12 @@ static int swap_init(void) {
|
||||
if (!g_swap_fail_logged) {
|
||||
g_swap_fail_logged = 1;
|
||||
LOGE("present: no swapchain on the screen surface; retrying every 0.5 s");
|
||||
set_fault("no swapchain on the session screen (%s)", g_swap_reason[0] ? g_swap_reason : "unknown reason");
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define SWLOGE(...) do { if (!g_swap_fail_logged) LOGE(__VA_ARGS__); } while (0)
|
||||
#define SWLOGE(...) do { snprintf(g_swap_reason, sizeof(g_swap_reason), __VA_ARGS__); if (!g_swap_fail_logged) LOGE(__VA_ARGS__); } while (0)
|
||||
|
||||
static void vk_format_short(VkFormat f, char *out, size_t n) {
|
||||
const char *s = NULL;
|
||||
@@ -822,10 +954,15 @@ static void init_black_image(void) {
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, .pCommandBuffers = &cmd};
|
||||
g_vk.ResetFences(g_dev, 1, &g_fence);
|
||||
if (g_vk.QueueSubmit(g_queue, 1, &si, g_fence) == VK_SUCCESS &&
|
||||
g_vk.WaitForFences(g_dev, 1, &g_fence, VK_TRUE, 1000000000ULL) == VK_SUCCESS)
|
||||
g_black_state = 1;
|
||||
else
|
||||
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||
if (qr == VK_SUCCESS) {
|
||||
VkResult fr = timed_wait(g_fence, 1000000000ULL);
|
||||
if (fr == VK_SUCCESS) g_black_state = 1;
|
||||
else if (fr == VK_ERROR_DEVICE_LOST) device_lost("black image");
|
||||
} else if (qr == VK_ERROR_DEVICE_LOST) {
|
||||
device_lost("black image submit");
|
||||
}
|
||||
if (g_black_state != 1)
|
||||
droiddeck_log("gpu", "letterbox black image unavailable: the whole output is cleared every copy-path frame");
|
||||
}
|
||||
|
||||
@@ -924,7 +1061,98 @@ struct vkp_image *vkp_image_from_dmabuf(int fd, uint32_t drm_format, uint64_t mo
|
||||
return vkp_image_import_dmabuf(fd, drm_format, modifier, w, h, stride, offset, 0);
|
||||
}
|
||||
|
||||
int vkp_image_is_dmabuf(const struct vkp_image *img) { return img && img->dmabuf && !img->blit_dst; }
|
||||
/* Return client sources to FOREIGN after their final read. The consuming paths
|
||||
* wait for our fence before Wayland can release an ordinary dma-buf or an
|
||||
* android_wlegl AHardwareBuffer. Producer-fence synchronization is separate from
|
||||
* these image-layout and ownership transfers. */
|
||||
static void release_external_client_image(VkCommandBuffer cmd, struct vkp_image *img) {
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (!img || !vkp_external_client_barrier_pair(
|
||||
img->image, g_qfam, img->dmabuf, img->blit_dst, &pair))
|
||||
return;
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, 0, 0, NULL, 0, NULL, 1, &pair.release);
|
||||
}
|
||||
|
||||
static void release_external_client_draws(VkCommandBuffer cmd, const struct vkp_draw *draws, int count) {
|
||||
for (int i = 0; i < count; i++) {
|
||||
int seen = 0;
|
||||
for (int j = 0; j < i; j++) if (draws[j].img == draws[i].img) { seen = 1; break; }
|
||||
if (!seen) release_external_client_image(cmd, draws[i].img);
|
||||
}
|
||||
}
|
||||
|
||||
int vkp_image_is_dmabuf(const struct vkp_image *img) {
|
||||
return img && vkp_is_external_client_image(img->dmabuf, img->blit_dst);
|
||||
}
|
||||
|
||||
int vkp_android_buffer_supported(void) {
|
||||
return dev_init() == 0 && g_ahb_properties != NULL;
|
||||
}
|
||||
|
||||
struct vkp_image *vkp_image_from_android_buffer(AHardwareBuffer *buffer) {
|
||||
if (!buffer || !vkp_android_buffer_supported()) return NULL;
|
||||
AHardwareBuffer_Desc desc;
|
||||
AHardwareBuffer_describe(buffer, &desc);
|
||||
if (!desc.width || !desc.height || desc.layers != 1 ||
|
||||
(desc.usage & (AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT | AHARDWAREBUFFER_USAGE_GPU_MIPMAP_COMPLETE)) ||
|
||||
!(desc.usage & AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE)) return NULL;
|
||||
VkAndroidHardwareBufferFormatPropertiesANDROID format = {
|
||||
.sType = VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_FORMAT_PROPERTIES_ANDROID};
|
||||
VkAndroidHardwareBufferPropertiesANDROID props = {
|
||||
.sType = VK_STRUCTURE_TYPE_ANDROID_HARDWARE_BUFFER_PROPERTIES_ANDROID, .pNext = &format};
|
||||
VkResult result = g_ahb_properties(g_dev, buffer, &props);
|
||||
if (result != VK_SUCCESS ||
|
||||
(format.format != VK_FORMAT_R8G8B8A8_UNORM && format.format != VK_FORMAT_R8G8B8A8_SRGB &&
|
||||
format.format != VK_FORMAT_B8G8R8A8_UNORM && format.format != VK_FORMAT_B8G8R8A8_SRGB) ||
|
||||
!props.memoryTypeBits ||
|
||||
!(format.formatFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT)) {
|
||||
LOGE("android_wlegl: unsupported Android buffer import (%s, format %d)",
|
||||
vk_result_name(result), format.format);
|
||||
return NULL;
|
||||
}
|
||||
struct vkp_image *img = calloc(1, sizeof(*img));
|
||||
if (!img) return NULL;
|
||||
img->w = (int)desc.width; img->h = (int)desc.height;
|
||||
img->fmt = format.format; img->dmabuf = 1;
|
||||
const VkFormatFeatureFlags sampled = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
|
||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
||||
img->sampled = (format.formatFeatures & sampled) == sampled;
|
||||
VkExternalMemoryImageCreateInfo external = {
|
||||
.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO,
|
||||
.handleTypes = VK_EXTERNAL_MEMORY_HANDLE_TYPE_ANDROID_HARDWARE_BUFFER_BIT_ANDROID};
|
||||
VkImageCreateInfo create = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, .pNext = &external,
|
||||
.imageType = VK_IMAGE_TYPE_2D, .format = img->fmt,
|
||||
.extent = {desc.width, desc.height, 1}, .mipLevels = 1, .arrayLayers = 1,
|
||||
.samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||
.usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | (img->sampled ? VK_IMAGE_USAGE_SAMPLED_BIT : 0),
|
||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||
result = g_vk.CreateImage(g_dev, &create, NULL, &img->image);
|
||||
if (result != VK_SUCCESS) goto fail;
|
||||
/* AHB image requirements are not queryable before binding. The AHB query supplies them. */
|
||||
uint32_t memory_type = 0;
|
||||
while (!(props.memoryTypeBits & (1u << memory_type))) memory_type++;
|
||||
VkImportAndroidHardwareBufferInfoANDROID import = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMPORT_ANDROID_HARDWARE_BUFFER_INFO_ANDROID, .buffer = buffer};
|
||||
VkMemoryDedicatedAllocateInfo dedicated = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
|
||||
.pNext = &import, .image = img->image};
|
||||
VkMemoryAllocateInfo allocate = {
|
||||
.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .pNext = &dedicated,
|
||||
.allocationSize = props.allocationSize, .memoryTypeIndex = memory_type};
|
||||
result = g_vk.AllocateMemory(g_dev, &allocate, NULL, &img->mem);
|
||||
if (result != VK_SUCCESS) goto fail;
|
||||
result = g_vk.BindImageMemory(g_dev, img->image, img->mem, 0);
|
||||
if (result != VK_SUCCESS) goto fail;
|
||||
AHardwareBuffer_acquire(buffer);
|
||||
img->android_buffer = buffer;
|
||||
return img;
|
||||
fail:
|
||||
LOGE("android_wlegl: Vulkan buffer import failed: %s", vk_result_name(result));
|
||||
vkp_image_destroy(img);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t modifier, int w, int h,
|
||||
uint32_t stride, uint32_t offset, int as_blit_dst) {
|
||||
@@ -938,7 +1166,27 @@ struct vkp_image *vkp_image_import_dmabuf(int fd, uint32_t drm_format, uint64_t
|
||||
const VkImageUsageFlags sampled_usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
img->sampled = !as_blit_dst && g_vk.GetPhysicalDeviceImageFormatProperties2 &&
|
||||
modifier_importable(img->fmt, modifier, sampled_usage);
|
||||
/* Each new format/modifier/size a client hands over, once, for the graphics report: a colour
|
||||
* or swizzle mismatch on a non-Adreno driver shows up as the pair it arrived as. */
|
||||
{
|
||||
static struct { uint32_t fmt; uint64_t mod; int w, h; } seen[32];
|
||||
static int nseen;
|
||||
int known = 0;
|
||||
for (int i = 0; i < nseen; i++)
|
||||
if (seen[i].fmt == drm_format && seen[i].mod == modifier && seen[i].w == w && seen[i].h == h) known = 1;
|
||||
if (!known && nseen < 32) {
|
||||
seen[nseen].fmt = drm_format; seen[nseen].mod = modifier; seen[nseen].w = w; seen[nseen].h = h; nseen++;
|
||||
droiddeck_log("gpu", "dmabuf import: %c%c%c%c %s %dx%d stride %u offset %u -> vk format %d, %s%s",
|
||||
drm_format & 0xff, (drm_format >> 8) & 0xff, (drm_format >> 16) & 0xff, (drm_format >> 24) & 0xff,
|
||||
vkp_modifier_name(modifier), w, h, stride, offset, (int)img->fmt,
|
||||
img->sampled ? "sampled" : "copied", as_blit_dst ? ", blit target" : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* Venus reports a row pitch of 0 for gamescope's 1x1 root buffer, and a zero pitch fails
|
||||
* vkCreateImage, which left the whole window unshown (David Cimo). One packed, 64-byte aligned
|
||||
* row is what a linear buffer that small holds. */
|
||||
if (stride == 0 && modifier == 0) stride = ((uint32_t)w * 4 + 63) & ~63u;
|
||||
VkSubresourceLayout plane = {.offset = offset, .rowPitch = stride};
|
||||
VkImageDrmFormatModifierExplicitCreateInfoEXT modInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_EXPLICIT_CREATE_INFO_EXT,
|
||||
@@ -1113,7 +1361,7 @@ struct vkp_image *vkp_image_create_shm(int w, int h) {
|
||||
}
|
||||
|
||||
void vkp_image_upload_shm(struct vkp_image *img, const void *data, int stride) {
|
||||
if (!img || !img->map || !data) return;
|
||||
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;
|
||||
for (int y = 0; y < img->h; y++)
|
||||
@@ -1126,12 +1374,14 @@ int vkp_image_height(const struct vkp_image *img) { return img ? img->h : 0; }
|
||||
|
||||
void vkp_image_destroy(struct vkp_image *img) {
|
||||
if (!img) return;
|
||||
if (g_dev_state == -3) return; /* completion unknown: retain GPU ownership */
|
||||
if (g_dev) {
|
||||
blendp_forget_image(img->image);
|
||||
if (img->map) g_vk.UnmapMemory(g_dev, img->mem);
|
||||
if (img->image) g_vk.DestroyImage(g_dev, img->image, NULL);
|
||||
if (img->mem) g_vk.FreeMemory(g_dev, img->mem, NULL);
|
||||
}
|
||||
if (img->android_buffer) AHardwareBuffer_release(img->android_buffer);
|
||||
free(img);
|
||||
}
|
||||
|
||||
@@ -1176,11 +1426,14 @@ static int draw_to_scene_blit(const struct vkp_draw *d, int scene_w, int scene_h
|
||||
static void record_draw(VkCommandBuffer cmd, const struct vkp_draw *d, const VkImageBlit *blit, VkImage target,
|
||||
VkFormat target_fmt, int target_w, int target_h, VkFilter filter) {
|
||||
const struct vkp_image *im = d->img;
|
||||
const int external_client = vkp_image_is_dmabuf(im);
|
||||
if (d->blend && im->sampled &&
|
||||
blendp_draw(cmd, im->image, im->fmt, im->w, im->h, !im->dmabuf, target, target_fmt, target_w, target_h,
|
||||
blendp_draw(cmd, im->image, im->fmt, im->w, im->h, !external_client,
|
||||
target, target_fmt, target_w, target_h,
|
||||
blit) == 0)
|
||||
return;
|
||||
g_vk.CmdBlitImage(cmd, im->image, im->dmabuf ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
g_vk.CmdBlitImage(cmd, im->image,
|
||||
external_client ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
target, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, blit, filter);
|
||||
}
|
||||
|
||||
@@ -1313,6 +1566,7 @@ static void device_lost(const char *where) {
|
||||
vkp_framegen_device_lost();
|
||||
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;
|
||||
@@ -1410,6 +1664,7 @@ static void record_screen_blit(VkCommandBuffer cmd, VkImage src, int src_w, int
|
||||
|
||||
static int acquire_image(int k, int first, uint32_t *img, VkResult *ar_out) {
|
||||
for (int attempt = 0; ; attempt++) {
|
||||
if (g_dev_state != 1) return -1;
|
||||
if (!g_swapchain && (!first || swap_init() != 0)) return -1;
|
||||
const int64_t t_acq = perf_now();
|
||||
VkResult ar = g_vk.AcquireNextImageKHR(g_dev, g_swapchain, 1000000000ULL, g_acqs[k], VK_NULL_HANDLE, img);
|
||||
@@ -1419,7 +1674,7 @@ static int acquire_image(int k, int first, uint32_t *img, VkResult *ar_out) {
|
||||
if (ar == VK_ERROR_OUT_OF_DATE_KHR || ar == VK_ERROR_SURFACE_LOST_KHR) {
|
||||
droiddeck_log("gpu", "screen surface %s on acquire: rebuilding the swapchain", vk_result_name(ar));
|
||||
destroy_swapchain();
|
||||
if (first && attempt == 0) continue;
|
||||
if (first && attempt == 0 && g_dev_state == 1) continue;
|
||||
return -1;
|
||||
}
|
||||
droiddeck_log("error", "present: acquire %d failed (%s %d)", k, vk_result_name(ar), (int)ar);
|
||||
@@ -1536,6 +1791,7 @@ 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 < 0) return -1;
|
||||
vkp_apply_window_request();
|
||||
sc_layer_hide_base();
|
||||
check_surface_changed();
|
||||
@@ -1554,6 +1810,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
: "no HDR frames through the screen swapchain any more: rebuilding it as SDR");
|
||||
destroy_swapchain();
|
||||
}
|
||||
if (g_dev_state != 1) return -1;
|
||||
g_swap_hdr_want = want_hdr;
|
||||
|
||||
uint32_t img = 0;
|
||||
@@ -1619,13 +1876,11 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
int seen = 0;
|
||||
for (int j = 0; j < i; j++) if (draws[j].img == im) { seen = 1; break; }
|
||||
if (seen || !im) continue;
|
||||
if (im->dmabuf) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .dstQueueFamilyIndex = g_qfam,
|
||||
.image = im->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||
} else if (!im->in_general) {
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (vkp_external_client_barrier_pair(
|
||||
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
|
||||
bars[nb++] = pair.acquire;
|
||||
} else if (!im->blit_dst && !im->in_general) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_PREINITIALIZED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
@@ -1682,6 +1937,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
drawn++;
|
||||
}
|
||||
|
||||
release_external_client_draws(cmd, draws, n);
|
||||
int ngen = 0;
|
||||
VkImage gens[VKP_FG_MAX_GENERATIONS] = {VK_NULL_HANDLE};
|
||||
VkImage result = scene_img;
|
||||
@@ -1735,6 +1991,10 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
if (k > 0) {
|
||||
VkResult ark;
|
||||
if (acquire_image(k, 0, &img, &ark) != 0) {
|
||||
/* Teardown may have retained this frame's pending work, or
|
||||
* acquire may have reported real device loss. Neither permits
|
||||
* a completion-marker submit or another fence wait. */
|
||||
if (g_dev_state != 1) return -1;
|
||||
droiddeck_log("framegen", "present %d/%d: no swapchain image; the frame ends early", k + 1, presents);
|
||||
pr = VK_ERROR_OUT_OF_DATE_KHR;
|
||||
break;
|
||||
@@ -1766,15 +2026,22 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
||||
pr = g_vk.QueuePresentKHR(g_queue, &pi);
|
||||
perf_add(&g_perf.present_ns, &g_perf.present_max_ns, &g_perf.presents, perf_now() - t_pres);
|
||||
if (k < ngen) presented_gen++;
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR || pr == VK_ERROR_DEVICE_LOST) break;
|
||||
if (pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) break;
|
||||
}
|
||||
if (!fence_submitted) {
|
||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO};
|
||||
g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||
VkResult marker = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||
if (marker != VK_SUCCESS) {
|
||||
if (marker == VK_ERROR_DEVICE_LOST) device_lost("frame completion submit");
|
||||
else quarantine_pending_work(marker, "frame completion submit");
|
||||
return -1; /* no fence was submitted; never wait on its unsignalled state */
|
||||
}
|
||||
}
|
||||
VkResult fr = timed_wait(g_fence, UINT64_MAX);
|
||||
if (fg) vkp_framegen_presented(presented_gen);
|
||||
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||
if (fr != VK_SUCCESS) return -1;
|
||||
if (fg) vkp_framegen_presented(presented_gen);
|
||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) {
|
||||
droiddeck_log("gpu", "screen surface %s on present: rebuilding the swapchain", vk_result_name(pr));
|
||||
destroy_swapchain();
|
||||
@@ -1847,6 +2114,7 @@ void vkp_reset_first_frame(void) {
|
||||
void vkp_signal_first_frame(void) {
|
||||
if (g_first_frame_done) return;
|
||||
g_first_frame_done = 1;
|
||||
clear_fault();
|
||||
droiddeck_on_first_frame();
|
||||
}
|
||||
|
||||
@@ -1862,6 +2130,7 @@ int vkp_update_map(int scene_w, int scene_h) {
|
||||
return g_map.valid ? 0 : -1;
|
||||
}
|
||||
check_surface_changed();
|
||||
if (g_dev_state != 1) return -1;
|
||||
if (!g_swapchain && swap_init() != 0) return -1;
|
||||
update_map(scene_w, scene_h);
|
||||
return g_map.valid ? 0 : -1;
|
||||
@@ -1884,7 +2153,7 @@ int vkp_map_draw(const struct vkp_draw *d, int out[8]) {
|
||||
}
|
||||
|
||||
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
if (!src || !dst || !dst->blit_dst || g_dev_state == -2 || 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;
|
||||
}
|
||||
@@ -1897,17 +2166,21 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(g_cmd, &bi);
|
||||
struct vkp_external_client_barrier_pair src_pair;
|
||||
const int src_external = vkp_external_client_barrier_pair(
|
||||
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
|
||||
VkImageMemoryBarrier acq[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = src->dmabuf ? VK_QUEUE_FAMILY_FOREIGN_EXT : VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = src->dmabuf ? g_qfam : VK_QUEUE_FAMILY_IGNORED,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .dstQueueFamilyIndex = g_qfam,
|
||||
.image = dst->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT}};
|
||||
if (!src->dmabuf) {
|
||||
if (!src_external) {
|
||||
acq[0].oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
|
||||
acq[0].newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||
acq[0].srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||
@@ -1921,8 +2194,9 @@ int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||
.dstOffsets = {{0, 0, 0}, {bw, bh, 1}}};
|
||||
g_vk.CmdBlitImage(g_cmd, src->image,
|
||||
src->dmabuf ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||
dst->image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &blit, VK_FILTER_NEAREST);
|
||||
release_external_client_image(g_cmd, src);
|
||||
VkImageMemoryBarrier rel = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = g_qfam,
|
||||
@@ -1957,7 +2231,7 @@ 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 || !out || src->w <= 0 || src->h <= 0 || src->w * src->h > max_px ||
|
||||
if (!src || src->blit_dst || !out || src->w <= 0 || src->h <= 0 || src->w * src->h > max_px ||
|
||||
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; }
|
||||
@@ -1998,11 +2272,15 @@ int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) {
|
||||
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||
g_vk.BeginCommandBuffer(cmd, &bi);
|
||||
struct vkp_external_client_barrier_pair src_pair;
|
||||
const int src_external = vkp_external_client_barrier_pair(
|
||||
src->image, g_qfam, src->dmabuf, src->blit_dst, &src_pair);
|
||||
VkImageMemoryBarrier acq[2] = {
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = src->dmabuf ? VK_QUEUE_FAMILY_FOREIGN_EXT : VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = src->dmabuf ? g_qfam : VK_QUEUE_FAMILY_IGNORED,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT},
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
@@ -2020,15 +2298,20 @@ int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px) {
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL, .srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .image = g_rb->image, .subresourceRange = range,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, .dstAccessMask = VK_ACCESS_HOST_READ_BIT},
|
||||
{.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT, .dstAccessMask = VK_ACCESS_HOST_READ_BIT}};
|
||||
uint32_t done_count = 1;
|
||||
if (!src_external) {
|
||||
done[done_count++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
.srcQueueFamilyIndex = src->dmabuf ? g_qfam : VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = src->dmabuf ? VK_QUEUE_FAMILY_FOREIGN_EXT : VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT}};
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.image = src->image, .subresourceRange = range, .srcAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||
}
|
||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT,
|
||||
0, 0, NULL, 0, NULL, 2, done);
|
||||
0, 0, NULL, 0, NULL, done_count, done);
|
||||
release_external_client_image(cmd, src);
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, .pCommandBuffers = &cmd};
|
||||
g_vk.ResetFences(g_dev, 1, &g_fence);
|
||||
@@ -2100,13 +2383,11 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
int seen = 0;
|
||||
for (int j = 0; j < i; j++) if (draws[j].img == im) { seen = 1; break; }
|
||||
if (seen || !im) continue;
|
||||
if (im->dmabuf) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_FOREIGN_EXT, .dstQueueFamilyIndex = g_qfam,
|
||||
.image = im->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||
} else if (!im->in_general) {
|
||||
struct vkp_external_client_barrier_pair pair;
|
||||
if (vkp_external_client_barrier_pair(
|
||||
im->image, g_qfam, im->dmabuf, im->blit_dst, &pair)) {
|
||||
bars[nb++] = pair.acquire;
|
||||
} else if (!im->blit_dst && !im->in_general) {
|
||||
bars[nb++] = (VkImageMemoryBarrier){
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_PREINITIALIZED,
|
||||
.newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||
@@ -2145,6 +2426,7 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
if (vkp_effects_active()) vkp_effects_set_formats(VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8A8_UNORM);
|
||||
}
|
||||
|
||||
release_external_client_draws(cmd, draws, n);
|
||||
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||
g_pass.rw = scene_w; g_pass.rh = scene_h;
|
||||
g_pass.result = vkp_effects_run(cmd, scene_img, scene_w, scene_h, mapped_w, mapped_h,
|
||||
@@ -2158,8 +2440,9 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
||||
int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd) {
|
||||
if (!g_pass.active) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
g_pass.active = 0;
|
||||
if (g_dev_state != 1) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||
VkCommandBuffer cmd = g_cmds[0];
|
||||
if (!dst || !dst->blit_dst || g_dev_state == -2) {
|
||||
if (!dst || !dst->blit_dst) {
|
||||
if (wait_fd >= 0) close(wait_fd);
|
||||
g_vk.EndCommandBuffer(cmd);
|
||||
return -1;
|
||||
@@ -2211,5 +2494,6 @@ int vkp_pass_copy_to(struct vkp_image *dst, int wait_fd) {
|
||||
void vkp_pass_abort(void) {
|
||||
if (!g_pass.active) return;
|
||||
g_pass.active = 0;
|
||||
g_vk.EndCommandBuffer(g_cmds[0]);
|
||||
if (g_dev_state == 1)
|
||||
g_vk.EndCommandBuffer(g_cmds[0]);
|
||||
}
|
||||
@@ -2,6 +2,8 @@
|
||||
#define VK_PRESENT_H
|
||||
#include <stdint.h>
|
||||
#include <android/native_window.h>
|
||||
#include <android/hardware_buffer.h>
|
||||
|
||||
void vk_present_set_driver(const char *driver_path, const char *library_name,
|
||||
const char *native_lib_dir);
|
||||
|
||||
@@ -21,6 +23,9 @@ void vkp_output_size(int *w, int *h);
|
||||
|
||||
struct vkp_image;
|
||||
|
||||
int vkp_android_buffer_supported(void);
|
||||
struct vkp_image *vkp_image_from_android_buffer(AHardwareBuffer *buffer);
|
||||
|
||||
#define VKP_MOD_LINEAR 0x0000000000000000ULL
|
||||
#define VKP_MOD_QCOM_COMPRESSED 0x0500000000000001ULL
|
||||
#define VKP_MOD_INVALID 0x00ffffffffffffffULL
|
||||
@@ -57,6 +62,10 @@ int vkp_ready(void);
|
||||
int vkp_has_window(void);
|
||||
int vkp_wait_window_request(int timeout_ms);
|
||||
int vkp_device_lost(void);
|
||||
/* Compositor thread only. Submitted reads may still be pending: retain imported
|
||||
* buffer references and withhold DMA-BUF releases until the app process exits.
|
||||
* This terminal state is distinct from genuine device loss. */
|
||||
int vkp_completion_unknown(void);
|
||||
|
||||
int vkp_render(int scene_w, int scene_h, const struct vkp_draw *draws, int n);
|
||||
int vkp_render_plain(int scene_w, int scene_h);
|
||||
|
||||
@@ -215,6 +215,24 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCompositorTid(JNIEnv
|
||||
return (jint)g_comp_tid;
|
||||
}
|
||||
|
||||
/* Why presenting failed ("" while it works), for the session-ended screen and the report. */
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCompositorFault(JNIEnv *env, jclass clazz) {
|
||||
(void)clazz;
|
||||
extern const char *vkp_fault(void);
|
||||
const char *f = vkp_fault();
|
||||
return (*env)->NewStringUTF(env, f ? f : "");
|
||||
}
|
||||
|
||||
/* The display driver as the driver itself reports it ("" before the compositor's device exists). */
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeDisplayDriver(JNIEnv *env, jclass clazz) {
|
||||
(void)clazz;
|
||||
extern const char *vkp_display_driver(void);
|
||||
const char *d = vkp_display_driver();
|
||||
return (*env)->NewStringUTF(env, d ? d : "");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStart(JNIEnv *env, jclass clazz,
|
||||
jstring xdgRuntimeDir) {
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
/* android_wlegl buffer import for the existing libhybris Wayland WSI.
|
||||
* Protocol: Collabora/libhybris, vendored with its license in protocols/wayland-android.xml.
|
||||
* Native handles are cloned through Android; opaque vendor integers are never interpreted. */
|
||||
#include "compositor_internal.h"
|
||||
#include "droiddeck_ext.h"
|
||||
#include "wayland-android-server-protocol.h"
|
||||
#include <android/hardware_buffer.h>
|
||||
#include <dlfcn.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/* Stable native_handle_t ABI, unavailable in the public NDK. */
|
||||
struct android_native_handle {
|
||||
int version, num_fds, num_ints;
|
||||
int data[];
|
||||
};
|
||||
struct wire_handle {
|
||||
struct android_native_handle *handle;
|
||||
int received;
|
||||
};
|
||||
enum { MAX_HANDLE_FDS = 64, MAX_HANDLE_INTS = 256, MAX_BUFFER_SIDE = 8192 };
|
||||
/* VNDK ABI (not exposed by the NDK): frameworks/native/libs/nativewindow/include/
|
||||
* vndk/hardware_buffer.h, AHARDWAREBUFFER_CREATE_FROM_HANDLE_METHOD_CLONE = 3.
|
||||
* Method 1 is not accepted by AHardwareBuffer_createFromHandle. */
|
||||
enum { CREATE_FROM_HANDLE_CLONE = 3 };
|
||||
static int (*import_handle)(const AHardwareBuffer_Desc *, const struct android_native_handle *,
|
||||
int32_t, AHardwareBuffer **);
|
||||
static const struct android_native_handle *(*native_handle)(const AHardwareBuffer *);
|
||||
|
||||
static int valid_description(int32_t width, int32_t height, int32_t stride, int32_t format) {
|
||||
return width > 0 && height > 0 && width <= MAX_BUFFER_SIDE && height <= MAX_BUFFER_SIDE &&
|
||||
stride >= width && stride <= MAX_BUFFER_SIDE * 4 &&
|
||||
(format == 1 || format == 2 || format == 5);
|
||||
}
|
||||
|
||||
static void handle_resource_destroy(struct wl_resource *resource) {
|
||||
struct wire_handle *wire = wl_resource_get_user_data(resource);
|
||||
if (!wire) return;
|
||||
for (int i = 0; i < wire->received; i++) close(wire->handle->data[i]);
|
||||
free(wire->handle);
|
||||
free(wire);
|
||||
}
|
||||
|
||||
static void handle_add_fd(struct wl_client *client, struct wl_resource *resource, int32_t fd) {
|
||||
struct wire_handle *wire = wl_resource_get_user_data(resource);
|
||||
if (wire->received >= wire->handle->num_fds) {
|
||||
close(fd);
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_HANDLE_ERROR_TOO_MANY_FDS,
|
||||
"more native handle descriptors than declared");
|
||||
return;
|
||||
}
|
||||
wire->handle->data[wire->received++] = fd;
|
||||
}
|
||||
|
||||
static void handle_destroy(struct wl_client *client, struct wl_resource *resource) {
|
||||
wl_resource_destroy(resource);
|
||||
}
|
||||
|
||||
static const struct android_wlegl_handle_interface handle_impl = {
|
||||
.add_fd = handle_add_fd, .destroy = handle_destroy,
|
||||
};
|
||||
|
||||
static void create_handle(struct wl_client *client, struct wl_resource *resource,
|
||||
uint32_t id, int32_t fds, struct wl_array *ints) {
|
||||
if (fds < 0 || fds > MAX_HANDLE_FDS || ints->size % sizeof(int32_t) ||
|
||||
ints->size > MAX_HANDLE_INTS * sizeof(int32_t)) {
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_VALUE, "invalid native handle size");
|
||||
return;
|
||||
}
|
||||
struct wire_handle *wire = calloc(1, sizeof(*wire));
|
||||
if (!wire) { wl_client_post_no_memory(client); return; }
|
||||
wire->handle = calloc(1, sizeof(*wire->handle) + (size_t)fds * sizeof(int32_t) + ints->size);
|
||||
if (!wire->handle) { free(wire); wl_client_post_no_memory(client); return; }
|
||||
wire->handle->version = sizeof(*wire->handle);
|
||||
wire->handle->num_fds = fds;
|
||||
wire->handle->num_ints = (int)(ints->size / sizeof(int32_t));
|
||||
if (ints->size) memcpy(wire->handle->data + fds, ints->data, ints->size);
|
||||
struct wl_resource *handle = wl_resource_create(client, &android_wlegl_handle_interface, 1, id);
|
||||
if (!handle) {
|
||||
free(wire->handle); free(wire); wl_client_post_no_memory(client); return;
|
||||
}
|
||||
wl_resource_set_implementation(handle, &handle_impl, wire, handle_resource_destroy);
|
||||
}
|
||||
|
||||
static void buffer_resource_destroy(struct wl_resource *resource) {
|
||||
dmabuf_buffer_unref(wl_resource_get_user_data(resource));
|
||||
}
|
||||
|
||||
static struct wl_resource *create_android_buffer(struct wl_client *client, uint32_t id,
|
||||
AHardwareBuffer *hardware) {
|
||||
AHardwareBuffer_Desc desc;
|
||||
AHardwareBuffer_describe(hardware, &desc);
|
||||
struct vkp_image *image = vkp_image_from_android_buffer(hardware);
|
||||
if (!image) return NULL;
|
||||
struct dmabuf_buffer *buffer = calloc(1, sizeof(*buffer));
|
||||
if (!buffer) { vkp_image_destroy(image); wl_client_post_no_memory(client); return NULL; }
|
||||
buffer->refs = 1;
|
||||
buffer->width = (int32_t)desc.width; buffer->height = (int32_t)desc.height;
|
||||
buffer->format = desc.format == 5 ? DRM_ARGB8888 : desc.format == 2 ? DRM_XBGR8888 : DRM_ABGR8888;
|
||||
buffer->modifier = MOD_INVALID; /* No DMA-BUF layout was inferred from the native handle. */
|
||||
buffer->img = image;
|
||||
for (int i = 0; i < MAX_PLANES; i++) buffer->fd[i] = -1;
|
||||
struct wl_resource *result = wl_resource_create(client, &wl_buffer_interface, 1, id);
|
||||
if (!result) { dmabuf_buffer_unref(buffer); wl_client_post_no_memory(client); return NULL; }
|
||||
wl_resource_set_implementation(result, &dbuf_buffer_impl, buffer, buffer_resource_destroy);
|
||||
struct client_info *info = client_info_of(client);
|
||||
if (info) info->dmabuf_buffers++;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void create_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id,
|
||||
int32_t width, int32_t height, int32_t stride, int32_t format,
|
||||
int32_t usage, struct wl_resource *handle_resource) {
|
||||
/* Some vendor allocators (Samsung Xclipse) record no stride for GPU-only buffers. The import
|
||||
* must pass that 0 back unchanged: gralloc validates it against the handle's own value. */
|
||||
if (!valid_description(width, height, stride ? stride : width, format) ||
|
||||
!wl_resource_instance_of(handle_resource, &android_wlegl_handle_interface, &handle_impl)) {
|
||||
droiddeck_log("display", "android_wlegl rejected: %dx%d stride=%d format=%d usage=0x%x",
|
||||
width, height, stride, format, (uint32_t)usage);
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_VALUE, "invalid Android buffer description");
|
||||
return;
|
||||
}
|
||||
struct wire_handle *wire = wl_resource_get_user_data(handle_resource);
|
||||
if (wire->received != wire->handle->num_fds || !wire->received) {
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_HANDLE, "incomplete native handle");
|
||||
return;
|
||||
}
|
||||
AHardwareBuffer_Desc desc = {
|
||||
.width = (uint32_t)width, .height = (uint32_t)height, .layers = 1,
|
||||
.format = (uint32_t)format, .usage = (uint32_t)usage, .stride = (uint32_t)stride};
|
||||
AHardwareBuffer *hardware = NULL;
|
||||
int status = import_handle(&desc, wire->handle, CREATE_FROM_HANDLE_CLONE, &hardware);
|
||||
if (status != 0 || !hardware) {
|
||||
droiddeck_log("display", "android_wlegl import failed: status=%d %dx%d stride=%d format=%d usage=0x%x fds=%d ints=%d",
|
||||
status, width, height, stride, format, (uint32_t)usage,
|
||||
wire->handle->num_fds, wire->handle->num_ints);
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_HANDLE,
|
||||
"Android rejected the native handle (status %d)", status);
|
||||
return;
|
||||
}
|
||||
struct wl_resource *buffer = create_android_buffer(client, id, hardware);
|
||||
AHardwareBuffer_release(hardware);
|
||||
if (!buffer) wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_HANDLE, "Vulkan cannot import this buffer");
|
||||
}
|
||||
|
||||
static void get_server_buffer(struct wl_client *client, struct wl_resource *resource, uint32_t id,
|
||||
int32_t width, int32_t height, int32_t format, int32_t usage) {
|
||||
if (!format) format = 1;
|
||||
if (!valid_description(width, height, width, format)) {
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_VALUE, "invalid buffer allocation request");
|
||||
return;
|
||||
}
|
||||
AHardwareBuffer_Desc desc = {
|
||||
.width = (uint32_t)width, .height = (uint32_t)height, .layers = 1,
|
||||
.format = (uint32_t)format,
|
||||
.usage = (uint32_t)usage | AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE | AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT};
|
||||
AHardwareBuffer *hardware = NULL;
|
||||
if (AHardwareBuffer_allocate(&desc, &hardware) != 0 || !hardware) {
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_VALUE, "Android buffer allocation failed");
|
||||
return;
|
||||
}
|
||||
AHardwareBuffer_describe(hardware, &desc);
|
||||
const struct android_native_handle *handle = native_handle(hardware);
|
||||
if (!handle || handle->num_fds < 1 || handle->num_fds > MAX_HANDLE_FDS ||
|
||||
handle->num_ints < 0 || handle->num_ints > MAX_HANDLE_INTS) {
|
||||
AHardwareBuffer_release(hardware);
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_HANDLE, "invalid allocated native handle");
|
||||
return;
|
||||
}
|
||||
struct wl_resource *buffer = create_android_buffer(client, 0, hardware);
|
||||
if (!buffer) {
|
||||
AHardwareBuffer_release(hardware);
|
||||
wl_resource_post_error(resource, ANDROID_WLEGL_ERROR_BAD_HANDLE, "Vulkan cannot import allocated buffer");
|
||||
return;
|
||||
}
|
||||
struct wl_resource *reply = wl_resource_create(client, &android_wlegl_server_buffer_handle_interface,
|
||||
wl_resource_get_version(resource), id);
|
||||
if (!reply) {
|
||||
wl_resource_destroy(buffer); AHardwareBuffer_release(hardware);
|
||||
wl_client_post_no_memory(client); return;
|
||||
}
|
||||
struct wl_array ints = {.size = (size_t)handle->num_ints * sizeof(int32_t),
|
||||
.alloc = 0, .data = (void *)(handle->data + handle->num_fds)};
|
||||
android_wlegl_server_buffer_handle_send_buffer_ints(reply, &ints);
|
||||
for (int i = 0; i < handle->num_fds; i++)
|
||||
android_wlegl_server_buffer_handle_send_buffer_fd(reply, handle->data[i]);
|
||||
/* No linear_layout event: Android's opaque allocation need not be linear. */
|
||||
android_wlegl_server_buffer_handle_send_buffer(reply, buffer, (int32_t)desc.format, (int32_t)desc.stride);
|
||||
wl_resource_destroy(reply);
|
||||
AHardwareBuffer_release(hardware);
|
||||
}
|
||||
|
||||
static const struct android_wlegl_interface wlegl_impl = {
|
||||
.create_handle = create_handle, .create_buffer = create_buffer,
|
||||
.get_server_buffer_handle = get_server_buffer,
|
||||
};
|
||||
|
||||
static void bind_android_wlegl(struct wl_client *client, void *data, uint32_t version, uint32_t id) {
|
||||
struct wl_resource *resource = wl_resource_create(client, &android_wlegl_interface,
|
||||
version < 3 ? version : 3, id);
|
||||
if (!resource) { wl_client_post_no_memory(client); return; }
|
||||
wl_resource_set_implementation(resource, &wlegl_impl, NULL, NULL);
|
||||
}
|
||||
|
||||
void droiddeck_android_wlegl_init(struct wl_display *display) {
|
||||
if (!vkp_android_buffer_supported()) return;
|
||||
void *library = dlopen("libnativewindow.so", RTLD_NOW | RTLD_LOCAL);
|
||||
if (!library) return;
|
||||
import_handle = dlsym(library, "AHardwareBuffer_createFromHandle");
|
||||
native_handle = dlsym(library, "AHardwareBuffer_getNativeHandle");
|
||||
if (!import_handle || !native_handle) { dlclose(library); return; }
|
||||
/* Keep the platform entry points valid for the compositor's lifetime. */
|
||||
if (wl_global_create(display, &android_wlegl_interface, 3, NULL, bind_android_wlegl))
|
||||
droiddeck_log("display", "android_wlegl v3: Android buffer import available");
|
||||
}
|
||||
@@ -14,10 +14,12 @@ import androidx.compose.runtime.mutableIntStateOf
|
||||
import com.droiddeck.launcher.gpu.AutoDriverTrial
|
||||
import com.droiddeck.launcher.gpu.AutoPicks
|
||||
import com.droiddeck.launcher.gpu.DriverBundle
|
||||
import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.gpu.DriverPairs
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipReleases
|
||||
import com.droiddeck.launcher.session.SessionService
|
||||
@@ -42,7 +44,8 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
var canRestoreBundled by mutableStateOf(false)
|
||||
private val releaseProgress = HashMap<String, Int>()
|
||||
var linuxSelected by mutableStateOf("")
|
||||
val gpu: GpuInfo = GpuInfo.detect()
|
||||
var gpu: GpuInfo = GpuInfo.detect()
|
||||
private set
|
||||
var mode by mutableStateOf(SessionPrefs.GPU_DRIVERS_AUTO)
|
||||
var pairRows by mutableStateOf<List<PairRow>>(emptyList())
|
||||
var pairBusy by mutableStateOf<String?>(null)
|
||||
@@ -65,13 +68,14 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
}
|
||||
|
||||
fun state() = GpuDriversState(
|
||||
gpuName = gpu.displayName(activity), gpuFamily = gpu.family.label(activity), soc = gpu.soc, supportText = gpu.supportText(activity),
|
||||
gpuName = gpu.displayName(activity), gpuFamily = if (gpu.name.contains("Xclipse", ignoreCase = true)) gpu.family.label(gpu.name) else gpu.family.label(activity), soc = gpu.soc, supportText = gpu.supportText(activity),
|
||||
supported = gpu.support == GpuInfo.Support.TESTED, unsupported = gpu.support == GpuInfo.Support.UNSUPPORTED,
|
||||
auto = mode == SessionPrefs.GPU_DRIVERS_AUTO, pairs = pairRows, busy = pairBusy, percent = pairPercent,
|
||||
autoStatus = autoStatus, releaseStatus = releaseStatus.ifEmpty { activity.getString(R.string.drivers_not_checked) }, checking = releaseChecking,
|
||||
linuxRows = linuxRows, linuxSelected = linuxSelected, androidRows = androidRows, androidSelected = androidSelected,
|
||||
linuxDownloads = linuxDownloads, androidDownloads = androidDownloads, canRestoreBundled = canRestoreBundled,
|
||||
activeBundle = activeBundle,
|
||||
activeBundle = activeBundle, powerVr = gpu.family == GpuInfo.Family.POWERVR,
|
||||
systemPowerVr = SystemVulkanDriver.usesDefault(linuxSelected),
|
||||
mode = uiMode, display = displaySlot(), runtime = runtimeSlot(),
|
||||
canRestart = !sessionRunning,
|
||||
checkedAt = TurnipReleases.cached(activity)?.checkedAt ?: 0L,
|
||||
@@ -142,7 +146,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
DriverRow(id, it.label, activity.getString(if (linux) R.string.drivers_bundle_sets_display else R.string.drivers_bundle_sets_runtime), true, DriverRow.BUNDLE)
|
||||
}
|
||||
linuxRows = LinuxVulkanDriver.optionValues(activity).map { id ->
|
||||
if (id.isEmpty()) DriverRow("", activity.getString(R.string.gpu_runtime_default), activity.getString(R.string.drivers_runtime_builtin), false)
|
||||
if (id.isEmpty()) DriverRow("", activity.getString(if (gpu.family == GpuInfo.Family.POWERVR) R.string.gpu_system_powervr else R.string.gpu_runtime_default), activity.getString(R.string.drivers_runtime_builtin), false)
|
||||
else bundleRow(id, linux = true) ?: DriverRow(
|
||||
id, lm.getDriverName(id),
|
||||
listOfNotNull(
|
||||
@@ -177,6 +181,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
|
||||
fun summary(): String {
|
||||
val active = pairRows.firstOrNull { it.active }?.name ?: activeBundle
|
||||
?: if (SystemVulkanDriver.usesDefault(linuxSelected) && androidSelected == TurnipDriver.AUTO) activity.getString(R.string.gpu_system_powervr) else null
|
||||
val display = displaySlot().name
|
||||
val base = when {
|
||||
uiMode == GPU_MODE_AUTO -> activity.getString(R.string.drivers_summary, activity.getString(R.string.common_auto), active ?: display)
|
||||
@@ -193,17 +198,28 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
val pairs = DriverPairs.from(TurnipReleases.cached(activity))
|
||||
val recommended = if (QuestExperimental.isSupported()) null else recommendedKey(pairs)
|
||||
pairRows = pairs.map { p ->
|
||||
val bundle = p.bundle?.let { installedBundle(it) }
|
||||
val nad = DriverPairs.isNonAdreno(p.key)
|
||||
val bundle = p.bundle?.let { if (nad) installedBundleAnyBuild(it) else installedBundle(it) }
|
||||
val displayId = if (p.bundle != null) bundle?.androidId else p.display?.let { TurnipReleases.installedId(activity, it, td::isInstalled) }
|
||||
val linuxId = if (p.bundle != null) bundle?.linuxId else p.linux?.let { TurnipReleases.installedId(activity, it, lm::isInstalled) }
|
||||
val mb = p.assets.sumOf { it.size } / 1_048_576.0
|
||||
val update = nad && bundle != null && p.bundle?.let { TurnipReleases.updateAvailable(activity, it) } == true
|
||||
val builtOn = if (nad) p.bundle?.builtOn.orEmpty() else ""
|
||||
val version = when {
|
||||
!nad -> p.version
|
||||
bundle != null -> bundle.version.ifEmpty { p.version }
|
||||
builtOn.isNotEmpty() -> activity.getString(R.string.drivers_built_on, builtOn)
|
||||
else -> p.version
|
||||
}
|
||||
PairRow(
|
||||
key = p.key, name = p.name, version = p.version,
|
||||
key = p.key, name = p.name, version = version, update = if (update) builtOn.takeIf { it.isNotEmpty() }?.let { activity.getString(R.string.drivers_built_on, it) } ?: p.version else null,
|
||||
detail = if (!p.complete) activity.getString(R.string.drivers_half_published) else activity.getString(R.string.drivers_pair_size, mb),
|
||||
recommended = p.key == recommended, suits = p.suits(gpu), complete = p.complete,
|
||||
installed = displayId != null && linuxId != null,
|
||||
active = displayId != null && linuxId != null &&
|
||||
SessionPrefs.androidDriver(activity) == displayId && SessionPrefs.linuxDriver(activity) == linuxId,
|
||||
active = displayId != null && linuxId != null && SessionPrefs.linuxDriver(activity) == linuxId &&
|
||||
(SessionPrefs.androidDriver(activity) == displayId ||
|
||||
// A Mali pair under Auto: the display is the phone's own driver.
|
||||
(gpu.family.mali && DriverPairs.isNonAdreno(p.key) && SessionPrefs.androidDriver(activity) == TurnipDriver.AUTO)),
|
||||
)
|
||||
}.sortedByDescending { it.recommended }
|
||||
}
|
||||
@@ -237,7 +253,9 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
private fun releasesStale(): Boolean {
|
||||
val cached = TurnipReleases.cached(activity)
|
||||
return cached == null || System.currentTimeMillis() - cached.checkedAt > RELEASE_CHECK_INTERVAL_MS ||
|
||||
cached.assets.none { it.pair.isNotEmpty() }
|
||||
cached.assets.none { it.pair.isNotEmpty() } ||
|
||||
// A list checked before this device's open non-Adreno drivers were offered has none of them.
|
||||
(!DeviceSupport.adreno() && cached.assets.none { DriverPairs.isNonAdreno(it.pair) })
|
||||
}
|
||||
|
||||
fun ensureAuto(force: Boolean) {
|
||||
@@ -247,9 +265,33 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
if (force) autoStatus = activity.getString(R.string.drivers_auto_waits_for_session)
|
||||
return
|
||||
}
|
||||
if (gpu.family == GpuInfo.Family.POWERVR && !SystemVulkanDriver.isXclipse()) {
|
||||
// Auto owns both choices. Manual imports remain available when Manual is selected.
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
// A Mali pair set by an earlier build put its PanVK Android half on the display, which fails
|
||||
// on Mali gralloc. Under Auto the display is the phone's own driver (Android's loader).
|
||||
if (gpu.family.mali) {
|
||||
// Builds before 0.5.0-nad1 turned the bridge on under Auto without recording it, and
|
||||
// left it on for good (it wins over the pair). Under Auto that switch is taken as Auto's.
|
||||
if (!SessionPrefs.maliFallbackKnown(activity))
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, if (SessionPrefs.vkBridge(activity)) "bridge" else "")
|
||||
// A lone imported PanVK Android driver set by hand stalls the display the same way
|
||||
// ("black screen with the start-up logo"), so under Auto any imported display goes.
|
||||
val display = SessionPrefs.androidDriver(activity)
|
||||
if (display != TurnipDriver.AUTO) {
|
||||
SessionPrefs.setAndroidDriver(activity, TurnipDriver.AUTO)
|
||||
Log.i(TAG, "auto: Mali display back on the phone's own driver (was $display)")
|
||||
}
|
||||
}
|
||||
AutoDriverTrial.rollbackDue(activity)?.let { trial ->
|
||||
AutoDriverTrial.rollBack(activity, trial)
|
||||
autoStatus = activity.getString(R.string.drivers_rolled_back, trial.name)
|
||||
// The drivers before the trial on a Mali are the runtime's Turnip, which finds no GPU there.
|
||||
if (gpu.family.mali && maliHasNoRoute()) useMaliFallback(trial.name)
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
@@ -263,6 +305,27 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null &&
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.cachedOrNull() == null) {
|
||||
autoStatus = activity.getString(R.string.drivers_checking_latest)
|
||||
Thread({
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.query()
|
||||
ui.post {
|
||||
gpu = GpuInfo.detect()
|
||||
Log.i(TAG, "auto: Mali named by its driver: ${gpu.name} -> ${gpu.family}")
|
||||
lastAutoCheck = 0L
|
||||
ensureAuto(force)
|
||||
}
|
||||
}, "gpu-name").start()
|
||||
return
|
||||
}
|
||||
Log.i(TAG, "auto: ${gpu.name} (${gpu.family}) -> " + (DriverPairs.recommendedKey(gpu, emptyList()) ?: "no pair"))
|
||||
if (gpu.family.mali && DriverPairs.recommendedKey(gpu, emptyList()) == null) {
|
||||
// No PanVK build covers this Mali (e.g. the G1 series, arch v14): the phone's own driver.
|
||||
autoStatus = useMaliFallback(null)
|
||||
refreshDrivers()
|
||||
return
|
||||
}
|
||||
if (DriverPairs.recommendedKey(gpu, emptyList()) == null) {
|
||||
autoStatus = activity.getString(R.string.drivers_none_to_set, gpu.supportText(activity).lowercase())
|
||||
return
|
||||
@@ -284,10 +347,37 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
when {
|
||||
row?.active == true -> autoStatus = problem?.let { activity.getString(R.string.drivers_up_to_date_check_failed, it) }
|
||||
?: activity.getString(R.string.upd_current_status)
|
||||
gpu.family == GpuInfo.Family.POWERVR && (pair == null || !pair.complete) -> {
|
||||
// RADV is not published right now: the Xclipse falls back to the system route.
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(activity)
|
||||
autoStatus = activity.getString(R.string.drivers_powervr_builtin)
|
||||
refreshDrivers()
|
||||
}
|
||||
gpu.family.mali && (pair == null || !pair.complete) &&
|
||||
(problem != null || TurnipReleases.cached(activity)?.failed?.contains(TurnipReleases.NON_ADRENO_LABEL) == true) -> {
|
||||
// The list could not be read: nothing is known to be missing, so a working route stays.
|
||||
// With no open driver, Venus or bridge the session would run the runtime's Turnip,
|
||||
// which finds no GPU on a Mali, so the stand-in goes on anyway.
|
||||
autoStatus = activity.getString(R.string.upd_couldnt_check, problem ?: TurnipReleases.NON_ADRENO_LABEL)
|
||||
if (maliHasNoRoute()) {
|
||||
useMaliFallback(null)
|
||||
refreshDrivers()
|
||||
}
|
||||
}
|
||||
gpu.family.mali && (pair == null || !pair.complete) -> {
|
||||
// No open driver for this Mali published yet: the phone's own driver until it is.
|
||||
autoStatus = useMaliFallback(key?.let { DriverPairs.nonAdrenoName(it) } ?: gpu.name)
|
||||
refreshDrivers()
|
||||
}
|
||||
pair == null || !pair.complete ->
|
||||
autoStatus = problem?.let { activity.getString(R.string.upd_couldnt_check, it) } ?: activity.getString(R.string.drivers_recommended_unpublished)
|
||||
AutoDriverTrial.release(pair) in AutoDriverTrial.bad(activity) ->
|
||||
AutoDriverTrial.release(pair) in AutoDriverTrial.bad(activity) -> {
|
||||
autoStatus = activity.getString(R.string.drivers_skipping_bad, pair.name, pair.version)
|
||||
if (gpu.family.mali && maliHasNoRoute()) {
|
||||
useMaliFallback(pair.name)
|
||||
refreshDrivers()
|
||||
}
|
||||
}
|
||||
SessionState.running -> autoStatus = activity.getString(R.string.drivers_auto_waits_for_session)
|
||||
holdBack && row?.installed != true -> autoStatus = activity.getString(R.string.drivers_auto_waits_for_network, pair.name, pair.version)
|
||||
else -> installPair(pair, auto = true)
|
||||
@@ -296,6 +386,53 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
}, "gpu-driver-auto").start()
|
||||
}
|
||||
|
||||
/**
|
||||
* A Mali with no open driver pair to install ([missing] names the unpublished pair, or null when
|
||||
* no PanVK build covers this GPU) runs through the phone's own driver: Mali (Venus) where this
|
||||
* apk carries it (Steam runs on it from the G57 to the G1 series), the Mali bridge otherwise.
|
||||
* Venus needs Vulkan 1.2 from the phone's driver; the bridge raises a Vulkan 1.1 driver
|
||||
* (r32p1 on the G77, G78 and G610) for gamescope itself, so there the bridge stands in.
|
||||
* The Linux driver choice is left alone (it is the bridge's fallback), and Auto
|
||||
* switches only its own choice off again once a pair is installed ([endMaliFallback]).
|
||||
*/
|
||||
private fun useMaliFallback(missing: String?): String {
|
||||
val oldVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity)
|
||||
val venus = oldVulkan == null && com.droiddeck.launcher.session.VenusComponent.available(activity)
|
||||
if (oldVulkan != null) Log.i(TAG, "auto: Mali driver reports Vulkan $oldVulkan; Venus needs 1.2, the bridge stands in")
|
||||
if (venus && !SessionPrefs.venus(activity)) {
|
||||
SessionPrefs.setVenus(activity, true)
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, "venus")
|
||||
} else if (!venus && !SessionPrefs.vkBridge(activity)) {
|
||||
SessionPrefs.setVkBridge(activity, true)
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, "bridge")
|
||||
}
|
||||
val route = activity.getString(if (venus) R.string.drivers_route_venus else R.string.drivers_route_bridge)
|
||||
Log.i(TAG, "auto: Mali stand-in route $route (missing pair: ${missing ?: "none covers ${gpu.name}"})")
|
||||
if (oldVulkan != null) return activity.getString(R.string.drivers_mali_old_vulkan_bridge, missing ?: gpu.name, oldVulkan)
|
||||
return if (missing == null) activity.getString(R.string.drivers_mali_no_pair_auto, route)
|
||||
else activity.getString(R.string.drivers_mali_unpublished_auto, missing, route)
|
||||
}
|
||||
|
||||
/** Neither an installed open Linux driver nor Venus or the bridge: the runtime's Turnip would run. */
|
||||
private fun maliHasNoRoute(): Boolean {
|
||||
if (SessionPrefs.vkBridge(activity)) return false
|
||||
// Venus on a Vulkan 1.1 driver does not start (VenusComponent.wanted), so it is no route.
|
||||
if (SessionPrefs.venus(activity) && com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(activity) == null) return false
|
||||
val linux = SessionPrefs.linuxDriver(activity)
|
||||
return linux.isEmpty() || !LinuxVulkanDriverManager(activity).isInstalled(linux)
|
||||
}
|
||||
|
||||
/** A pair is installed for this Mali: the route Auto switched on in its place goes off again. */
|
||||
private fun endMaliFallback() {
|
||||
when (SessionPrefs.maliFallbackByAuto(activity)) {
|
||||
"venus" -> SessionPrefs.setVenus(activity, false)
|
||||
"bridge" -> SessionPrefs.setVkBridge(activity, false)
|
||||
else -> return
|
||||
}
|
||||
Log.i(TAG, "auto: pair installed; ${SessionPrefs.maliFallbackByAuto(activity)} (Auto's stand-in) off")
|
||||
SessionPrefs.setMaliFallbackByAuto(activity, "")
|
||||
}
|
||||
|
||||
fun selectPair(key: String) {
|
||||
if (pairBusy != null) return
|
||||
val pair = DriverPairs.from(TurnipReleases.cached(activity)).firstOrNull { it.key == key && it.complete } ?: return
|
||||
@@ -304,7 +441,15 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
installPair(pair, auto = false)
|
||||
}
|
||||
|
||||
private fun installPair(pair: DriverPairs.DriverPair, auto: Boolean) {
|
||||
/** A newer build of an installed open non-Adreno pair: replaced in place, still selected if it was. */
|
||||
fun updatePair(key: String) {
|
||||
if (pairBusy != null) return
|
||||
val pair = DriverPairs.from(TurnipReleases.cached(activity)).firstOrNull { it.key == key && it.complete } ?: return
|
||||
val wasActive = pairRows.firstOrNull { it.key == key }?.active == true
|
||||
installPair(pair, auto = wasActive && mode == SessionPrefs.GPU_DRIVERS_AUTO, force = true, select = wasActive)
|
||||
}
|
||||
|
||||
private fun installPair(pair: DriverPairs.DriverPair, auto: Boolean, force: Boolean = false, select: Boolean = true) {
|
||||
if (!pair.complete) return
|
||||
pairBusy = pair.key
|
||||
pairPercent = 0
|
||||
@@ -314,7 +459,7 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
val result = runCatching {
|
||||
val zips = pair.assets
|
||||
val ids = zips.mapIndexed { i, asset ->
|
||||
installedIdOf(asset)
|
||||
(if (force) null else installedIdOf(asset))
|
||||
?: installAsset(asset) { pct -> ui.post { pairPercent = (i * 100 + pct) / zips.size } }.also { downloaded = true }
|
||||
}
|
||||
if (pair.bundle != null) DriverBundle.get(activity, ids[0])!!.let { listOf(it.androidId, it.linuxId) } else ids
|
||||
@@ -322,23 +467,39 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
ui.post {
|
||||
pairBusy = null
|
||||
pairPercent = -1
|
||||
result.onSuccess { (displayId, linuxId) ->
|
||||
result.onSuccess { (pairDisplayId, linuxId) ->
|
||||
if (!select) {
|
||||
android.widget.Toast.makeText(activity, activity.getString(R.string.drivers_pair_updated, pair.name), android.widget.Toast.LENGTH_LONG).show()
|
||||
return@onSuccess
|
||||
}
|
||||
if (auto && SessionState.running) {
|
||||
lastAutoCheck = 0L
|
||||
autoStatus = activity.getString(R.string.drivers_auto_waits_for_session)
|
||||
return@onSuccess
|
||||
}
|
||||
// A Mali pair under Auto: the compositor draws on the phone's own Mali driver
|
||||
// (dma-buf, modifiers and AHB all work there) and the guest runs the pair's
|
||||
// PanVK. Its Android half stays installed for a manual pick.
|
||||
// The same when the pair is picked by hand: a PanVK Android half on the display
|
||||
// stalls Mali gralloc ("Waiting for Steam's first frame"); it stays a manual pick
|
||||
// under "Runtime and display drivers separately".
|
||||
val displayId = if (gpu.family.mali && DriverPairs.isNonAdreno(pair.key)) TurnipDriver.AUTO else pairDisplayId
|
||||
val previousDisplay = SessionPrefs.androidDriver(activity)
|
||||
val previousLinux = SessionPrefs.linuxDriver(activity)
|
||||
val displayChanged = previousDisplay != displayId
|
||||
SessionPrefs.setAndroidDriver(activity, displayId)
|
||||
SessionPrefs.setLinuxDriver(activity, linuxId)
|
||||
// A route Auto switched on in place of a missing pair goes off now that one is
|
||||
// here. A Mali bridge or Venus switch the user set stays: it wins for the session
|
||||
// (DeviceSupport.vkBridge, VenusComponent.wanted) and the pair waits.
|
||||
if (gpu.family.mali && DriverPairs.isNonAdreno(pair.key)) endMaliFallback()
|
||||
val restart = displayChanged && CompositorHost.isStarted
|
||||
if (auto) {
|
||||
val trial = AutoDriverTrial.current(activity)
|
||||
val lastGood = trial?.let { setOf(it.previousDisplay, it.previousLinux) } ?: setOf(previousDisplay, previousLinux)
|
||||
val changed = previousDisplay != displayId || previousLinux != linuxId
|
||||
SessionPrefs.setGpuAutoInstalled(activity, SessionPrefs.gpuAutoInstalled(activity) + setOf(displayId, linuxId))
|
||||
// A Mali pair's display is the phone's own driver (AUTO): not a download to own or prune.
|
||||
SessionPrefs.setGpuAutoInstalled(activity, SessionPrefs.gpuAutoInstalled(activity) + setOf(displayId, linuxId).filter { it.isNotEmpty() && it != TurnipDriver.AUTO })
|
||||
if (changed) AutoDriverTrial.begin(
|
||||
activity, AutoDriverTrial.release(pair), "${pair.name} ${pair.version}", displayId, linuxId,
|
||||
trial?.previousDisplay ?: previousDisplay, trial?.previousLinux ?: previousLinux,
|
||||
@@ -366,6 +527,9 @@ internal class DriverMenus(private val activity: Activity, private val ui: Handl
|
||||
private fun installedBundle(asset: TurnipReleases.Asset): DriverBundle.Bundle? =
|
||||
TurnipReleases.installedId(activity, asset) { DriverBundle.get(activity, it) != null }?.let { DriverBundle.get(activity, it) }
|
||||
|
||||
private fun installedBundleAnyBuild(asset: TurnipReleases.Asset): DriverBundle.Bundle? =
|
||||
TurnipReleases.installedIdAnyBuild(activity, asset) { DriverBundle.get(activity, it) != null }?.let { DriverBundle.get(activity, it) }
|
||||
|
||||
private fun installedIdOf(asset: TurnipReleases.Asset): String? = when {
|
||||
asset.bundle -> installedBundle(asset)?.id
|
||||
asset.linux -> TurnipReleases.installedId(activity, asset, LinuxVulkanDriverManager(activity)::isInstalled)
|
||||
|
||||
@@ -162,6 +162,11 @@ class FrontEndActivity : ComponentActivity() {
|
||||
private var gameCores by mutableStateOf<Set<Int>>(emptySet())
|
||||
private var tuSysmem by mutableStateOf(false)
|
||||
private var zinkLazy by mutableStateOf(false)
|
||||
private var vkBridge by mutableStateOf(false)
|
||||
private var venus by mutableStateOf(false)
|
||||
private var venusHostVulkan by mutableStateOf<String?>(null)
|
||||
private var vkBridgeSafe by mutableStateOf(true)
|
||||
private val adrenoGpu by lazy { com.droiddeck.launcher.core.DeviceSupport.adreno() }
|
||||
private var noXalia by mutableStateOf(true)
|
||||
private var fastSync by mutableStateOf(false)
|
||||
private var syncFallback by mutableStateOf(true)
|
||||
@@ -502,6 +507,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
private var gameDebugLogsNeedsRestart by mutableStateOf(false)
|
||||
private var vacDiagnostics by mutableStateOf(false)
|
||||
private var agentCommands by mutableStateOf(false)
|
||||
private var graphicsLogs by mutableStateOf(false)
|
||||
private var steamGpuDrawing by mutableStateOf(false)
|
||||
private var bridgeFellBack by mutableStateOf(false)
|
||||
private var bridgeFellBackMemory by mutableStateOf(false)
|
||||
private var clearCachedApps by mutableStateOf(false)
|
||||
private var adbPaired by mutableStateOf(false)
|
||||
private var memoryHud by mutableStateOf(SessionPrefs.MEMORY_HUD_OFF)
|
||||
@@ -1037,6 +1046,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
FrontEndScreen(
|
||||
FrontEndState(
|
||||
installed = installed, ready = ready, available = available?.version, removalPending = removalPending, runtimeActionsBlocked = runtimeChangesBlocked(),
|
||||
vkBridge = vkBridge, venus = venus, venusHostVulkan = venusHostVulkan, vkBridgeSafe = vkBridgeSafe, adreno = adrenoGpu,
|
||||
shortcutPicker = shortcutPicker,
|
||||
shortcutLibraryScanning = shortcutLibraryScanning,
|
||||
gameSyncFolder = gameSyncFolder,
|
||||
@@ -1046,6 +1056,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
frameGenLabel = frameGenLabel, romsDir = romsDir, logsEnabled = logsEnabled,
|
||||
gameDebugLogsEnabled = gameDebugLogsEnabled, gameDebugLogsNeedsRestart = gameDebugLogsNeedsRestart,
|
||||
vacDiagnostics = vacDiagnostics, agentCommands = agentCommands,
|
||||
graphicsLogs = graphicsLogs, steamGpuDrawing = steamGpuDrawing, bridgeFellBack = bridgeFellBack, bridgeFellBackMemory = bridgeFellBackMemory,
|
||||
clearCachedApps = clearCachedApps, adbPaired = adbPaired, memoryHud = memoryHud, backgroundAppLimit = backgroundAppLimit,
|
||||
steamGames = steamGames, steamGamesX64 = steamGamesX64, emulators = emulatorList, running = runningLabel,
|
||||
frameGen = FrameGen.mode(this),
|
||||
@@ -1185,6 +1196,17 @@ class FrontEndActivity : ComponentActivity() {
|
||||
onInstallPackage = { id -> installPackage(id) },
|
||||
onRemovePackage = { id -> removePackage(id) },
|
||||
onRuntime = { onRuntimeButton() },
|
||||
onVkBridge = { on -> SessionPrefs.setVkBridge(this, on); SessionPrefs.setMaliFallbackByAuto(this, ""); vkBridge = on },
|
||||
onVenus = { on ->
|
||||
SessionPrefs.setVenus(this, on)
|
||||
SessionPrefs.setMaliFallbackByAuto(this, "")
|
||||
venus = on
|
||||
if (on && !com.droiddeck.launcher.core.DeviceSupport.adreno()) Thread({
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
|
||||
runOnUiThread { venusHostVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(this) }
|
||||
}, "venus-host-vulkan").start()
|
||||
},
|
||||
onVkBridgeSafe = { on -> SessionPrefs.setVkBridgeSafe(this, on); vkBridgeSafe = on },
|
||||
onFrameGenPick = { mode ->
|
||||
FrameGen.set(this, mode)
|
||||
frameGenLabel = FrameGen.label(this)
|
||||
@@ -1222,6 +1244,14 @@ class FrontEndActivity : ComponentActivity() {
|
||||
gameDebugLogsEnabled = SessionPrefs.gameDebugLogsEnabled(this)
|
||||
gameDebugLogsNeedsRestart = gameDebugLogsNeedsRestart()
|
||||
},
|
||||
onSteamGpuDrawing = {
|
||||
SessionPrefs.setSteamGpuCompositing(this, !SessionPrefs.steamGpuCompositing(this))
|
||||
steamGpuDrawing = SessionPrefs.steamGpuCompositing(this)
|
||||
},
|
||||
onGraphicsLogs = {
|
||||
SessionPrefs.setDetailedGraphicsLogs(this, !SessionPrefs.detailedGraphicsLogs(this))
|
||||
graphicsLogs = SessionPrefs.detailedGraphicsLogs(this)
|
||||
},
|
||||
onVacDiagnostics = {
|
||||
SessionPrefs.setVacDiagnostics(this, !SessionPrefs.vacDiagnostics(this))
|
||||
vacDiagnostics = SessionPrefs.vacDiagnostics(this)
|
||||
@@ -1527,6 +1557,9 @@ class FrontEndActivity : ComponentActivity() {
|
||||
com.droiddeck.launcher.frontend.GamesFolderMigration.run(this)
|
||||
SessionLogShare.clear(this)
|
||||
SessionArtifacts.finishAbandoned(this)
|
||||
if (SessionPrefs.takeMemoryKillNotice(this)) runOnUiThread {
|
||||
android.widget.Toast.makeText(this, R.string.session_killed_for_memory, android.widget.Toast.LENGTH_LONG).show()
|
||||
}
|
||||
SessionArtifacts.scrubOlder(this)
|
||||
SessionArtifacts.prune(this)
|
||||
}, "finish-abandoned").start()
|
||||
@@ -1918,6 +1951,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
gpuActions = com.droiddeck.launcher.ui.GpuDriversActions(
|
||||
onAuto = { on -> drivers.setMode(on) },
|
||||
onPair = { key -> drivers.selectPair(key) },
|
||||
onPairUpdate = { key -> drivers.updatePair(key) },
|
||||
onRefresh = { if (drivers.mode == SessionPrefs.GPU_DRIVERS_AUTO) drivers.ensureAuto(force = true) else drivers.checkLatestTurnip() },
|
||||
onSelectLinux = { id -> drivers.selectDriver(id, linux = true) },
|
||||
onSelectAndroid = { id -> drivers.selectDriver(id, linux = false) },
|
||||
@@ -2442,6 +2476,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
gameCores = CpuCores.parse(SessionPrefs.gameCpus(this)).ifEmpty { CpuCores.all.toSet() }
|
||||
tuSysmem = SessionPrefs.tuSysmem(this)
|
||||
zinkLazy = SessionPrefs.zinkLazy(this)
|
||||
vkBridge = SessionPrefs.vkBridge(this)
|
||||
venus = SessionPrefs.venus(this)
|
||||
venusHostVulkan = com.droiddeck.launcher.session.VenusComponent.hostVulkanTooOld(this)
|
||||
vkBridgeSafe = SessionPrefs.vkBridgeSafe(this)
|
||||
noXalia = SessionPrefs.noXalia(this)
|
||||
fastSync = SessionPrefs.fastSync(this)
|
||||
syncFallback = SessionPrefs.syncFallback(this)
|
||||
@@ -2479,6 +2517,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
offline = OfflineMode.enabled(this)
|
||||
installed = LinuxRuntimeInstaller.installedVersion(this)
|
||||
ready = LinuxRuntime.isInstalled(this)
|
||||
// Setup's Mali bridge row reads these; refreshCores() alone ran only for the Performance
|
||||
// page, so a new process (every APK update) showed "Mali bridge: off" with the switch on.
|
||||
vkBridge = SessionPrefs.vkBridge(this)
|
||||
vkBridgeSafe = SessionPrefs.vkBridgeSafe(this)
|
||||
removalPending = LinuxRuntimeInstaller.hasRemovalPending(this)
|
||||
ui.post { autoUpdateRuntime() }
|
||||
frameGenLabel = FrameGen.label(this)
|
||||
@@ -2488,6 +2530,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
gameDebugLogsNeedsRestart = gameDebugLogsNeedsRestart()
|
||||
vacDiagnostics = SessionPrefs.vacDiagnostics(this)
|
||||
agentCommands = com.droiddeck.launcher.agent.AgentAccess.commandsEnabled(this)
|
||||
graphicsLogs = SessionPrefs.detailedGraphicsLogs(this)
|
||||
steamGpuDrawing = SessionPrefs.steamGpuCompositing(this)
|
||||
bridgeFellBack = SessionPrefs.bridgeFellBack(this)
|
||||
bridgeFellBackMemory = SessionPrefs.bridgeFellBackForMemory(this)
|
||||
clearCachedApps = SessionPrefs.clearCachedApps(this)
|
||||
adbPaired = WirelessAdbFix.hasSavedPairing(this)
|
||||
memoryHud = SessionPrefs.memoryHud(this)
|
||||
@@ -2583,7 +2629,10 @@ class FrontEndActivity : ComponentActivity() {
|
||||
Thread({ checkCatalog() }, "catalog").start()
|
||||
return
|
||||
}
|
||||
if (installed == null && !com.droiddeck.launcher.core.DeviceSupport.adreno()) { showNonAdreno = release; return }
|
||||
// The runtime draws with Turnip, an Adreno driver: on Mali, Xclipse or PowerVR the
|
||||
// compositor gets no usable Vulkan device and a session is sound over a black screen.
|
||||
// Said before the download, not after it; the user may still go ahead.
|
||||
if (installed == null && !com.droiddeck.launcher.core.DeviceSupport.canDraw(this)) { showNonAdreno = release; return }
|
||||
install(release)
|
||||
}
|
||||
|
||||
@@ -2602,7 +2651,7 @@ class FrontEndActivity : ComponentActivity() {
|
||||
showPhantomGate = true
|
||||
return false
|
||||
}
|
||||
val warn = installed == null && !com.droiddeck.launcher.core.DeviceSupport.adreno()
|
||||
val warn = installed == null && !com.droiddeck.launcher.core.DeviceSupport.canDraw(this)
|
||||
if (warn && available != null) { showNonAdreno = available; return false }
|
||||
startActivity(intent)
|
||||
return true
|
||||
|
||||
@@ -1143,6 +1143,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
SessionDrawer(drawerOpen, drawerPage, drawerControllerActive, onPageChange = { drawerPage = it }, docked = docked,
|
||||
backRequest = drawerBackRequests, onLayerChange = { drawerLayerOpen = it }, a = DrawerActions(
|
||||
steam = SessionState.mode == SessionService.MODE_STEAM,
|
||||
systemPowerVr = com.droiddeck.launcher.gpu.SystemVulkanDriver.usesDefault(
|
||||
SessionPrefs.linuxDriver(this@SessionActivity)),
|
||||
direct = noSteamSession(),
|
||||
title = if (SessionState.mode == SessionService.MODE_RUN)
|
||||
com.droiddeck.launcher.frontend.Library.nameForProgram(SessionState.program) ?: getString(R.string.session_title_game) else null,
|
||||
@@ -2409,6 +2411,29 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
return EndHint(resources.getQuantityString(R.plurals.session_end_runtime_damaged, broken.size, broken.size, broken.first()), repair = true)
|
||||
}
|
||||
|
||||
private fun presentationFault(): String? {
|
||||
runCatching { com.droiddeck.launcher.wayland.WaylandCompositor.compositorFault() }.getOrNull()
|
||||
?.takeIf { it.isNotEmpty() }?.let { return it }
|
||||
val waylandLog = SessionState.logDirectory?.let { File(it, "wayland.log") }?.takeIf { it.isFile } ?: return null
|
||||
return try {
|
||||
java.io.RandomAccessFile(waylandLog, "r").use { f ->
|
||||
val start = maxOf(0L, waylandLog.length() - 256L * 1024)
|
||||
f.seek(start)
|
||||
val bytes = ByteArray((waylandLog.length() - start).toInt())
|
||||
f.readFully(bytes)
|
||||
var fault: String? = null
|
||||
String(bytes, Charsets.ISO_8859_1).lineSequence().forEach { line ->
|
||||
val i = line.indexOf("DD_PRESENT_FAULT: ")
|
||||
if (i >= 0) fault = line.substring(i + 18).trim().ifEmpty { null }
|
||||
else if (line.contains("presentation recovered: fault cleared")) fault = null
|
||||
}
|
||||
fault
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun prootFailureHint(): EndHint? {
|
||||
if (SessionState.failureCode != "PROOT_MISSING") return null
|
||||
val message = SessionState.failureMessage ?: return null
|
||||
@@ -2416,6 +2441,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun sessionEndHint(log: File?): EndHint? {
|
||||
presentationFault()?.let { return EndHint(getString(R.string.session_end_present_fault, it), evenOnSuccess = true) }
|
||||
if (log == null || !log.isFile) return null
|
||||
return try {
|
||||
var enosys = 0
|
||||
|
||||
@@ -130,22 +130,46 @@ public class PulseAudioComponent extends SessionPart {
|
||||
|
||||
private void ensureClientSink(java.io.PrintWriter out) {
|
||||
try {
|
||||
long deadline = System.currentTimeMillis() + 15000L;
|
||||
// Nothing that may block (a sink whose AAudio open hangs: a Galaxy S24 FE (US) hung the
|
||||
// daemon's start-up loading one from default.pa) is loaded by the daemon itself; the
|
||||
// fallbacks are loaded here, after it is up, each pactl call bounded by its timeout.
|
||||
long started = System.currentTimeMillis();
|
||||
long deadline = started + 30000L;
|
||||
String sinks = null;
|
||||
boolean socketSeen = false;
|
||||
while (System.currentTimeMillis() < deadline && pid > 1) {
|
||||
if (socket().exists() && (sinks = pactl("list", "short", "sinks")) != null) break;
|
||||
socketSeen |= socket().exists();
|
||||
if (socketSeen && (sinks = pactl("list", "short", "sinks")) != null) break;
|
||||
try { Thread.sleep(250L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; }
|
||||
}
|
||||
note(out, "client sink: daemon " + (sinks != null ? "answered" : "did not answer") + " after "
|
||||
+ (System.currentTimeMillis() - started) + " ms (socket " + (socketSeen ? "present" : "never appeared") + ", pactl "
|
||||
+ (new File(workingDir, "pactl").isFile() ? "present" : "MISSING") + ", daemon pid " + pid + ")");
|
||||
String line;
|
||||
if (sinks == null) {
|
||||
line = "== client sink: the daemon did not answer in 15 s; no fallback attempted";
|
||||
line = "== client sink: the daemon did not answer in 30 s; no fallback attempted";
|
||||
} else if (sinks.contains("\tDirectAudio\t") || sinks.startsWith("DirectAudio\t") || sinks.contains("\tDirectAudio\n") || sinks.matches("(?s).*\\bDirectAudio\\b.*")) {
|
||||
line = "== client sink: DirectAudio (module-directaudio-native-sink)";
|
||||
} else {
|
||||
boolean loaded = pactl("load-module", "module-aaudio-sink", "sink_name=AAudioSink", "performance_mode=1", "adaptive=1", "volume=1.0", "control_dir=" + deviceControls) != null
|
||||
&& pactl("set-default-sink", "AAudioSink") != null;
|
||||
line = loaded ? "== client sink: DirectAudio did not come up; FALLBACK to the plain AAudio sink (AAudioSink)"
|
||||
: "== client sink: DirectAudio did not come up and the AAudio fallback failed too - no client sound";
|
||||
// AAudio can refuse the first open with AAUDIO_ERROR_DISCONNECTED while Android is
|
||||
// still switching the output route as the session starts (seen on a Galaxy S24 FE):
|
||||
// try DirectAudio again, then the plain sink, a few times over ten seconds.
|
||||
String loadedAs = null;
|
||||
for (int attempt = 1; attempt <= 5 && loadedAs == null && pid > 1; attempt++) {
|
||||
try { Thread.sleep(2000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; }
|
||||
if (pactl("load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", "performance_mode=1",
|
||||
"adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls) != null
|
||||
&& pactl("set-default-sink", "DirectAudio") != null) {
|
||||
loadedAs = "DirectAudio on attempt " + attempt;
|
||||
} else if (pactl("load-module", "module-aaudio-sink", "sink_name=AAudioSink",
|
||||
"performance_mode=" + (attempt == 1 ? "1" : "0"), "adaptive=1", "volume=1.0", "control_dir=" + deviceControls) != null
|
||||
&& pactl("set-default-sink", "AAudioSink") != null) {
|
||||
loadedAs = "the plain AAudio sink (AAudioSink) on attempt " + attempt;
|
||||
}
|
||||
}
|
||||
line = loadedAs != null ? "== client sink: DirectAudio did not come up at start; retried and got " + loadedAs
|
||||
: "== client sink: DirectAudio did not come up and the AAudio fallback failed too after 5 retries - no client sound."
|
||||
+ " If audio.log shows AAUDIO_ERROR_DISCONNECTED, Android refused the audio output: rebooting the phone usually fixes this";
|
||||
Log.w(TAG, line);
|
||||
}
|
||||
Log.i(TAG, line);
|
||||
@@ -155,6 +179,14 @@ public class PulseAudioComponent extends SessionPart {
|
||||
}
|
||||
}
|
||||
|
||||
/** A timestamped line in the session's audio log. */
|
||||
private void note(java.io.PrintWriter out, String what) {
|
||||
String line = "== " + new java.text.SimpleDateFormat("HH:mm:ss.SSS", java.util.Locale.US).format(new java.util.Date()) + " " + what;
|
||||
Log.i(TAG, line);
|
||||
if (out != null) synchronized (out) { out.println(line); out.flush(); }
|
||||
}
|
||||
|
||||
/** Runs pactl against this daemon; its stdout, or null when it failed or timed out. */
|
||||
private String pactl(String... args) {
|
||||
File pactl = new File(workingDir, "pactl");
|
||||
if (!pactl.isFile() || pid <= 1) return null;
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.os.PowerManager
|
||||
import android.os.StatFs
|
||||
import android.provider.Settings
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.gpu.DeviceInfo
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import android.view.Display
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
@@ -111,6 +113,7 @@ object DeviceReport {
|
||||
runCatching {
|
||||
val info = context.packageManager.getPackageInfo(context.packageName, 0)
|
||||
k("Version", "${info.versionName} (${info.longVersionCode})")
|
||||
k("App build", "${com.droiddeck.launcher.BuildConfig.BUILD_LABEL} (source ${com.droiddeck.launcher.BuildConfig.SOURCE_COMMIT})")
|
||||
}
|
||||
k("Package", context.packageName)
|
||||
k("targetSdk", context.applicationInfo.targetSdkVersion)
|
||||
@@ -187,7 +190,11 @@ object DeviceReport {
|
||||
h("GPU")
|
||||
k("KGSL gpu_model", readSys("/sys/class/kgsl/kgsl-3d0/gpu_model"))
|
||||
k("KGSL chip id", readSys("/sys/class/kgsl/kgsl-3d0/gpu_chipid"))
|
||||
k("System Vulkan ICD", if (File("/vendor/lib64/hw/vulkan.adreno.so").exists()) "/vendor/lib64/hw/vulkan.adreno.so" else "not at the usual path")
|
||||
k("System Vulkan ICD", when {
|
||||
SystemVulkanDriver.isPowerVr() -> SystemVulkanDriver.hal()
|
||||
File("/vendor/lib64/hw/vulkan.adreno.so").exists() -> "/vendor/lib64/hw/vulkan.adreno.so"
|
||||
else -> "not at the usual path"
|
||||
})
|
||||
|
||||
h("Display")
|
||||
k("Session output", SessionState.outputSize?.let { "${it.first}x${it.second}" })
|
||||
@@ -209,7 +216,7 @@ object DeviceReport {
|
||||
|
||||
h("Drivers")
|
||||
val gpu = com.droiddeck.launcher.gpu.GpuInfo.detect()
|
||||
k("GPU", "${gpu.name} · ${gpu.family.label} · ${gpu.supportText}" + if (gpu.oneUi8Gen2) " · One UI 8 Gen 2" else "")
|
||||
k("GPU", "${gpu.name} · ${gpu.family.label(gpu.name)} · ${gpu.supportText}" + if (gpu.oneUi8Gen2) " · One UI 8 Gen 2" else "")
|
||||
if (gpu.model == 740) {
|
||||
val hint = com.droiddeck.launcher.gpu.TpUbwcHint
|
||||
k("TP UBWC hint", hint.forThisDevice(context) ?: "driver default")
|
||||
@@ -222,19 +229,25 @@ object DeviceReport {
|
||||
com.droiddeck.launcher.gpu.AutoDriverTrial.bad(context))?.let { " (recommended pair: $it)" } ?: ""))
|
||||
val turnip = TurnipDriver(context)
|
||||
val androidChoice = SessionPrefs.androidDriver(context)
|
||||
k("Display driver (chosen)", if (androidChoice.isEmpty()) "Auto -> ${turnip.autoId()}" else androidChoice)
|
||||
k(" name / version", "${turnip.displayName(if (androidChoice.isEmpty()) turnip.autoId() else androidChoice)} ${turnip.driverVersion(if (androidChoice.isEmpty()) turnip.autoId() else androidChoice)}".trim())
|
||||
val displayId = androidChoice.ifEmpty { turnip.autoId() }
|
||||
val displayLabel = if (displayId == "system") DeviceInfo.builtinDriverLabel(SystemVulkanDriver.isPowerVr(), runtime = false)
|
||||
else "${turnip.displayName(displayId)} ${turnip.driverVersion(displayId)}".trim()
|
||||
k("Display driver (chosen)", if (androidChoice.isEmpty()) "Auto -> $displayLabel" else androidChoice)
|
||||
k(" name / version", displayLabel)
|
||||
k(" imported available", turnip.enumerateImported().ifEmpty { listOf("none") }.joinToString(", "))
|
||||
val lm = LinuxVulkanDriverManager(context)
|
||||
run {
|
||||
val id = SessionPrefs.linuxDriver(context)
|
||||
val label = if (id.isEmpty()) "runtime default (the Turnip built into the runtime)"
|
||||
val label = if (id.isEmpty()) DeviceInfo.builtinDriverLabel(SystemVulkanDriver.isPowerVr(), runtime = true)
|
||||
else "${lm.getDriverName(id)} ${lm.getDriverVersion(id)}".trim() +
|
||||
lm.getMinGlibc(id).let { if (it.isEmpty()) "" else " (glibc $it+)" } +
|
||||
if (lm.isInstalled(id)) "" else " [MISSING - falls back to the runtime's own]"
|
||||
if (lm.isInstalled(id)) "" else if (SystemVulkanDriver.isPowerVr()) " [MISSING - select an installed driver or Auto]"
|
||||
else " [MISSING - falls back to the runtime's own]"
|
||||
k("Linux driver", label)
|
||||
}
|
||||
k("Runtime's own ICD", LinuxRuntime.vulkanIcd(context)?.path)
|
||||
k("Mali (Venus)", if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) "in use"
|
||||
else if (com.droiddeck.launcher.session.VenusComponent.available(context)) "available, off" else "not in this build")
|
||||
|
||||
h("Runtime")
|
||||
k("Installed version", LinuxRuntimeInstaller.installedVersion(context))
|
||||
|
||||
@@ -3,12 +3,41 @@ package com.droiddeck.launcher.core
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import java.io.File
|
||||
|
||||
object DeviceSupport {
|
||||
fun adreno(): Boolean =
|
||||
File("/sys/class/kgsl/kgsl-3d0").exists() || File("/vendor/lib64/hw/vulkan.adreno.so").exists()
|
||||
|
||||
fun graphicsAvailable(): Boolean = graphicsAvailable(adreno(), SystemVulkanDriver.isAvailable())
|
||||
|
||||
internal fun graphicsAvailable(adreno: Boolean, powerVrReady: Boolean): Boolean = adreno || powerVrReady
|
||||
|
||||
fun vkBridge(context: Context): Boolean =
|
||||
bridgeUsable() && !com.droiddeck.launcher.session.VenusComponent.wanted(context) &&
|
||||
com.droiddeck.launcher.session.SessionPrefs.vkBridge(context)
|
||||
|
||||
fun mali(): Boolean = isMali
|
||||
|
||||
private val isMali by lazy {
|
||||
!adreno() && (File("/dev/mali0").exists() ||
|
||||
com.droiddeck.launcher.gpu.GpuInfo.detect().family.name.startsWith("MALI"))
|
||||
}
|
||||
|
||||
fun bridgeUsable(): Boolean = !adreno() && !SystemVulkanDriver.isAvailable() && File("/dev/mali0").exists()
|
||||
|
||||
fun openDriverActive(context: Context): Boolean {
|
||||
if (adreno()) return false
|
||||
if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) return false
|
||||
if (bridgeUsable() && com.droiddeck.launcher.session.SessionPrefs.vkBridge(context)) return false
|
||||
val linux = com.droiddeck.launcher.session.SessionPrefs.linuxDriver(context).ifEmpty { return false }
|
||||
return com.droiddeck.launcher.gpu.DriverPairs.isNonAdreno(com.droiddeck.launcher.gpu.DriverBundle.containing(context, linux, true)?.id)
|
||||
}
|
||||
|
||||
fun canDraw(context: Context): Boolean = graphicsAvailable() || openDriverActive(context) || vkBridge(context) ||
|
||||
com.droiddeck.launcher.session.VenusComponent.wanted(context)
|
||||
|
||||
fun gpuName(context: Context): String {
|
||||
val soc = if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL.takeIf { it.isNotBlank() && it != Build.UNKNOWN } else null
|
||||
return soc?.let { "$it (${Build.HARDWARE})" } ?: Build.HARDWARE.ifBlank { context.getString(R.string.gpu_this_gpu) }
|
||||
|
||||
@@ -14,6 +14,8 @@ object SteamRedists {
|
||||
"228988" to ("vcredist2019_dll" to "VC++ 2019"),
|
||||
"228989" to ("vcredist2022_dll" to "VC++ 2022"),
|
||||
"228990" to ("d3dx9" to "DirectX (June 2010)"),
|
||||
// OpenAL 2.0.7.0 (Hotline Miami lists it; without it HotlineGL.exe fails to load, c0000135).
|
||||
"229020" to ("oalinst_dll" to "OpenAL"),
|
||||
)
|
||||
/** Redists a game's own install script runs on Windows that its shared depots don't name. */
|
||||
val SCRIPTED = mapOf(
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.PowerManager
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.SessionPart
|
||||
import java.io.File
|
||||
import java.io.FileWriter
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* Clocks and thermal state through a Mali bridge session, into the session folder
|
||||
* (vkbridge-clocks.log), for telling the bridge's overhead apart from the phone holding the chip
|
||||
* back: Samsung's SSRM lowers the CPU policies' scaling_max_freq when the device warms, so a
|
||||
* policy whose max is below its cpuinfo_max_freq is being clamped (upstream issue #64).
|
||||
*
|
||||
* Every [PERIOD_MS]: each CPU policy as cur/max(hardware max) MHz, the GPU clock from the first
|
||||
* Mali/MediaTek source the app may read, and Android's thermal status and headroom. Which GPU
|
||||
* sources were readable is logged once at the start - SELinux refuses apps most of them, each
|
||||
* vendor differently, and this is how the next run finds out which.
|
||||
*/
|
||||
class ClockLogComponent(private val logFile: File) : SessionPart() {
|
||||
@Volatile private var running = false
|
||||
private var thread: Thread? = null
|
||||
|
||||
override fun start() {
|
||||
running = true
|
||||
thread = Thread({ run() }, "clock-log").apply { isDaemon = true; start() }
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
running = false
|
||||
thread?.interrupt()
|
||||
thread = null
|
||||
}
|
||||
|
||||
private fun run() {
|
||||
val policies = File("/sys/devices/system/cpu/cpufreq").listFiles { f -> f.name.startsWith("policy") }
|
||||
?.sortedBy { it.name.removePrefix("policy").toIntOrNull() ?: 0 } ?: emptyList()
|
||||
val gpuCandidates = gpuSources()
|
||||
// The /proc status files hold several numbers: listed for whether they read, not taken as the clock.
|
||||
val gpu = gpuCandidates.firstOrNull { !it.startsWith("/proc/") && firstNumber(it) != null }
|
||||
val power = app().getSystemService(Context.POWER_SERVICE) as? PowerManager
|
||||
val time = SimpleDateFormat("HH:mm:ss", Locale.US)
|
||||
try {
|
||||
FileWriter(logFile, true).use { w ->
|
||||
w.write("== clocks: ${Build.MANUFACTURER} ${Build.MODEL} (${Build.HARDWARE}), every ${PERIOD_MS / 1000}s\n")
|
||||
w.write("cpu policies: ${policies.joinToString { p -> p.name + " " + (File(p, "related_cpus").readTextOrNull()?.trim() ?: "?") }}\n")
|
||||
for (source in gpuCandidates) {
|
||||
val f = File(source)
|
||||
val state = when {
|
||||
!f.exists() -> continue
|
||||
firstNumber(source) != null -> "readable"
|
||||
else -> "refused"
|
||||
}
|
||||
w.write("gpu source $source: $state\n")
|
||||
}
|
||||
w.write("gpu clock from: ${gpu ?: "nothing readable"}\n")
|
||||
w.flush()
|
||||
while (running && logFile.length() < MAX_BYTES) {
|
||||
val line = StringBuilder(time.format(Date()))
|
||||
for (p in policies) {
|
||||
val cur = firstNumber(File(p, "scaling_cur_freq").path)
|
||||
val max = firstNumber(File(p, "scaling_max_freq").path)
|
||||
val hw = firstNumber(File(p, "cpuinfo_max_freq").path)
|
||||
line.append(" ${p.name.removePrefix("policy").let { "p$it" }} ${mhz(cur)}/${mhz(max)}")
|
||||
if (hw != null && max != null && max < hw) line.append("(of ${mhz(hw)})")
|
||||
}
|
||||
gpu?.let { line.append(" | gpu ${mhz(firstNumber(it))} MHz") }
|
||||
if (power != null && Build.VERSION.SDK_INT >= 29) {
|
||||
line.append(" | thermal ${power.currentThermalStatus}")
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
val h = power.getThermalHeadroom(10)
|
||||
if (!h.isNaN()) line.append(String.format(Locale.US, " headroom %.2f", h))
|
||||
}
|
||||
}
|
||||
w.write(line.append('\n').toString())
|
||||
w.flush()
|
||||
try { Thread.sleep(PERIOD_MS) } catch (e: InterruptedException) { break }
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.w(TAG, "clock log stopped: $e")
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "SessionService"
|
||||
private const val PERIOD_MS = 2000L
|
||||
private const val MAX_BYTES = 4L shl 20
|
||||
|
||||
/** Mali (Exynos, Tensor, MediaTek) and MediaTek GED clock files, plus any GPU devfreq node. */
|
||||
private fun gpuSources(): List<String> {
|
||||
val list = mutableListOf(
|
||||
"/sys/kernel/ged/hal/current_freqency", "/sys/kernel/ged/hal/current_frequency",
|
||||
"/proc/gpufreqv2/gpufreq_status", "/proc/gpufreq/gpufreq_var_dump",
|
||||
"/sys/kernel/gpu/gpu_clock", "/sys/class/misc/mali0/device/cur_freq",
|
||||
"/sys/class/misc/mali0/device/clock",
|
||||
)
|
||||
File("/sys/class/devfreq").list()?.sorted()?.forEach { node ->
|
||||
if (node.contains("mali", true) || node.contains("gpu", true)) list.add("/sys/class/devfreq/$node/cur_freq")
|
||||
}
|
||||
return list.distinct()
|
||||
}
|
||||
|
||||
private fun File.readTextOrNull(): String? = runCatching { readText() }.getOrNull()
|
||||
|
||||
private fun firstNumber(path: String): Long? =
|
||||
runCatching { Regex("\\d+").find(File(path).readText())?.value?.toLong() }.getOrNull()
|
||||
|
||||
/** Hz, kHz or MHz to MHz; "?" when unread. */
|
||||
private fun mhz(raw: Long?): String = when {
|
||||
raw == null -> "?"
|
||||
raw > 10_000_000 -> (raw / 1_000_000).toString()
|
||||
raw > 10_000 -> (raw / 1_000).toString()
|
||||
else -> raw.toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,7 @@ object DeviceInfo {
|
||||
|
||||
private fun gpu(gpu: GpuInfo) = Section("GPU", buildList<Pair<String, String>> {
|
||||
add("GPU", gpu.name)
|
||||
add("Family", gpu.family.label)
|
||||
add("Family", gpu.family.label(gpu.name))
|
||||
add("Model found from", when (gpu.modelSource) {
|
||||
"kernel" -> "the kernel's GPU name"
|
||||
"vulkan" -> "the Vulkan driver (the kernel's name has no model)"
|
||||
@@ -146,10 +146,20 @@ object DeviceInfo {
|
||||
add("Driver mode", SessionPrefs.gpuDriverMode(context))
|
||||
val turnip = TurnipDriver(context)
|
||||
val choice = SessionPrefs.androidDriver(context).ifEmpty { turnip.autoId() }
|
||||
add("Display driver", "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
||||
val powerVr = gpu.family == GpuInfo.Family.POWERVR
|
||||
add("Display driver", if (choice == "system") builtinDriverLabel(powerVr, runtime = false)
|
||||
else "${turnip.displayName(choice)} ${turnip.driverVersion(choice)}".trim())
|
||||
val linux = LinuxVulkanDriverManager(context)
|
||||
val id = SessionPrefs.linuxDriver(context)
|
||||
add("Game driver", if (id.isEmpty()) "the runtime's own Turnip" else "${linux.getDriverName(id)} ${linux.getDriverVersion(id)}".trim())
|
||||
add("Game driver", if (id.isEmpty()) builtinDriverLabel(powerVr, runtime = true) else "${linux.getDriverName(id)} ${linux.getDriverVersion(id)}".trim())
|
||||
if (gpu.oneUi8Gen2) add("Note", "One UI on an 8 Gen 2: needs the OneUI Turnip build")
|
||||
})
|
||||
|
||||
/** Shared by the device card and the session report, which are written in English. */
|
||||
internal fun builtinDriverLabel(powerVr: Boolean, runtime: Boolean): String = when {
|
||||
powerVr -> "System PowerVR"
|
||||
runtime -> "the runtime's own Turnip"
|
||||
else -> "System Vulkan"
|
||||
}
|
||||
|
||||
}
|
||||
@@ -61,6 +61,13 @@ object DriverBundle {
|
||||
val manifest = File(work, MANIFEST).takeIf { it.isFile }
|
||||
?.let { runCatching { parseManifest(JSONObject(FileUtils.readString(it))) }.getOrNull() }
|
||||
?: throw IllegalArgumentException(context.getString(R.string.bundle_no_manifest))
|
||||
// The same open non-Adreno pair again (picked again after another one): replace it
|
||||
// rather than keeping a "-2" copy beside the old one. Adreno bundles keep their copies.
|
||||
val sameId = LinuxVulkanDriverManager.sanitizeId(manifest.tag.ifEmpty { "${manifest.name}-${manifest.version}" })
|
||||
get(context, sameId)?.takeIf { DriverPairs.isNonAdreno(it.id) }?.let { old ->
|
||||
Log.i(TAG, "replacing bundle ${old.id} (display ${old.androidId}, runtime ${old.linuxId})")
|
||||
remove(context, old)
|
||||
}
|
||||
val androidDir = File(work, manifest.androidPath)
|
||||
val linuxDir = File(work, manifest.linuxPath)
|
||||
|
||||
@@ -75,8 +82,8 @@ object DriverBundle {
|
||||
|
||||
val linuxStage = lm.newStagingDir()
|
||||
val linuxId = try {
|
||||
val library = linuxDir.listFiles()?.firstOrNull { it.isFile && it.name.startsWith("libvulkan_freedreno") && it.name.endsWith(".so") }
|
||||
library?.copyTo(File(linuxStage, LinuxVulkanDriverManager.LIB_NAME))
|
||||
val library = linuxDir.listFiles()?.firstOrNull { it.isFile && LinuxVulkanDriverManager.isDriverLibrary(it.name) }
|
||||
library?.copyTo(File(linuxStage, LinuxVulkanDriverManager.storedName(library.name)))
|
||||
val meta = File(linuxDir, LinuxVulkanDriverManager.META_NAME).takeIf { it.isFile }
|
||||
?.let { runCatching { JSONObject(FileUtils.readString(it)) }.getOrNull() }
|
||||
lm.adopt(linuxStage, library?.name, meta, manifest.name)
|
||||
|
||||
@@ -12,6 +12,47 @@ object DriverPairs {
|
||||
const val DD_TURNIP = "dd-turnip"
|
||||
fun ddTurnip(tag: String) = "$DD_TURNIP:$tag"
|
||||
|
||||
/** The open non-Adreno drivers (The412Banner/droiddeck-nonadreno-drivers), one pair per driver. */
|
||||
const val NON_ADRENO = "nad"
|
||||
const val NAD_RADV_XCLIPSE = "nad:radv-xclipse"
|
||||
/** RADV-Xclipse rebased on JimVulkan's upstream: a manual choice, never Auto. */
|
||||
const val NAD_RADV_XCLIPSE_UPSTREAM = "nad:radv-xclipse-upstream"
|
||||
const val NAD_MALI_JM = "nad:panvk-mali-jm"
|
||||
const val NAD_MALI_G710 = "nad:panvk-mali-g710"
|
||||
const val NAD_MALI_G615 = "nad:panvk-mali-g615"
|
||||
const val NAD_MALI_G720 = "nad:panvk-mali-g720"
|
||||
/** One PanVK kbase binary for Mali v9-v13; its display half needs Android 15. */
|
||||
const val NAD_MALI_KBASE = "nad:panvk-mali-kbase"
|
||||
const val MALI_KBASE_MIN_SDK = 35
|
||||
/** faux123's PanVK builds for three handhelds: manual choices, never Auto. */
|
||||
const val NAD_FAUX_RP4PRO = "nad:panvk-faux123-rp4pro"
|
||||
const val NAD_FAUX_ACE = "nad:panvk-faux123-ace"
|
||||
const val NAD_FAUX_RG556 = "nad:panvk-faux123-rg556"
|
||||
/** The one Mali a device-specific build is for, by the number in the GPU's name. */
|
||||
private val DEVICE_BUILDS = mapOf(NAD_FAUX_RP4PRO to 77, NAD_FAUX_ACE to 610, NAD_FAUX_RG556 to 57)
|
||||
/** "PanVK-Mali-G720" (the release asset's id) to its pair key, "nad:panvk-mali-g720". */
|
||||
fun nonAdreno(id: String) = "$NON_ADRENO:" + id.lowercase()
|
||||
/** True for a non-Adreno pair's key, or a bundle installed from one ("PanVK-Mali-G720"). */
|
||||
fun isNonAdreno(keyOrBundleId: String?): Boolean = keyOrBundleId != null &&
|
||||
(keyOrBundleId.startsWith("$NON_ADRENO:") || Regex("""^(?i)(RADV-Xclipse|PanVK-[A-Za-z0-9]+)(-[A-Za-z0-9]+)*$""").matches(keyOrBundleId))
|
||||
|
||||
fun nonAdrenoName(key: String): String = describeNonAdreno(key).first
|
||||
|
||||
private fun describeNonAdreno(key: String): Pair<String, Set<Family>> = when (key) {
|
||||
NAD_RADV_XCLIPSE -> "RADV · Samsung Xclipse" to setOf(Family.POWERVR)
|
||||
NAD_RADV_XCLIPSE_UPSTREAM -> "RADV upstream · Samsung Xclipse" to setOf(Family.POWERVR)
|
||||
NAD_MALI_JM -> "PanVK · Mali G52-G78" to setOf(Family.MALI_JM)
|
||||
NAD_MALI_G710 -> "PanVK · Mali-G610/G710" to setOf(Family.MALI_G610_G710)
|
||||
NAD_MALI_G615 -> "PanVK · Mali-G615" to setOf(Family.MALI_G615)
|
||||
NAD_MALI_G720 -> "PanVK · Mali-G720" to setOf(Family.MALI_G720)
|
||||
NAD_FAUX_RP4PRO -> "PanVK faux123 · Retroid Pocket 4 Pro (Mali-G77)" to setOf(Family.MALI_JM)
|
||||
NAD_FAUX_ACE -> "PanVK faux123 · GameForce Ace (Mali-G610)" to setOf(Family.MALI_G610_G710)
|
||||
NAD_FAUX_RG556 -> "PanVK faux123 · Anbernic RG556 (Mali-G57)" to setOf(Family.MALI_JM)
|
||||
NAD_MALI_KBASE -> "PanVK kbase · Mali G57-G925" to
|
||||
setOf(Family.MALI_JM, Family.MALI_G610_G710, Family.MALI_G615, Family.MALI_G720, Family.MALI_LATEST)
|
||||
else -> key.removePrefix("$NON_ADRENO:") to emptySet<Family>()
|
||||
}
|
||||
|
||||
class DriverPair(
|
||||
val key: String,
|
||||
val name: String,
|
||||
@@ -24,14 +65,23 @@ object DriverPairs {
|
||||
val assets: List<TurnipReleases.Asset> get() = listOfNotNull(bundle ?: display, if (bundle == null) linux else null)
|
||||
val version: String
|
||||
get() = listOfNotNull(bundle?.tag, display?.tag, linux?.tag).distinct().joinToString(" + ") { it.removePrefix("linux-").removePrefix("DD-Turnip-") }
|
||||
fun suits(gpu: GpuInfo) = gpu.family in families ||
|
||||
(gpu.family == Family.ADRENO_UNKNOWN && (Family.A7XX in families || Family.A8XX in families))
|
||||
fun suits(gpu: GpuInfo) = when {
|
||||
// The system-driver family covers PowerVR and Xclipse; RADV is only for the Xclipse.
|
||||
key == NAD_RADV_XCLIPSE || key == NAD_RADV_XCLIPSE_UPSTREAM ->
|
||||
gpu.family == Family.POWERVR && gpu.name.contains("Xclipse", ignoreCase = true)
|
||||
// One binary for Mali v9-v13, not the older G52/G76 in the Job Manager family.
|
||||
key == NAD_MALI_KBASE -> gpu.family.mali && GpuInfo.maliKbaseCovered(gpu.name)
|
||||
key in DEVICE_BUILDS -> gpu.family.mali && GpuInfo.maliNumber(gpu.name) == DEVICE_BUILDS[key]
|
||||
else -> gpu.family in families ||
|
||||
(gpu.family == Family.ADRENO_UNKNOWN && (Family.A7XX in families || Family.A8XX in families))
|
||||
}
|
||||
}
|
||||
|
||||
private val ALL_ADRENO = setOf(Family.A6XX, Family.A7XX, Family.A7XX_LOW, Family.A8XX, Family.ADRENO_UNKNOWN)
|
||||
|
||||
private fun describe(key: String): Pair<String, Set<Family>> = when {
|
||||
key.startsWith(DD_TURNIP) -> "DroidDeck · DD-Turnip" to ALL_ADRENO
|
||||
key.startsWith("$NON_ADRENO:") -> describeNonAdreno(key)
|
||||
else -> describeFixed(key)
|
||||
}
|
||||
|
||||
@@ -47,7 +97,7 @@ object DriverPairs {
|
||||
|
||||
fun from(check: TurnipReleases.Check?): List<DriverPair> {
|
||||
val assets = check?.assets.orEmpty().filter { it.pair.isNotEmpty() }
|
||||
val order = listOf(DD_TURNIP, BANNER, BANNER_A8XX, BANNER_ONEUI, BANNER_710, WN_BALANCED, WN_PERFORMANCE)
|
||||
val order = listOf(DD_TURNIP, BANNER, BANNER_A8XX, BANNER_ONEUI, BANNER_710, WN_BALANCED, WN_PERFORMANCE, NON_ADRENO)
|
||||
return assets.map { it.pair }.distinct()
|
||||
.sortedBy { key -> order.indexOf(key.substringBefore(':')).let { i -> if (i < 0) order.size else i } }
|
||||
.map { key ->
|
||||
@@ -66,7 +116,13 @@ object DriverPairs {
|
||||
rules: List<AutoPicks.Rule> = AutoPicks.BUILT_IN, bad: Set<String> = emptySet(),
|
||||
sdk: Int = android.os.Build.VERSION.SDK_INT, blob: Int? = null,
|
||||
): String? {
|
||||
if (gpu.family == Family.NOT_ADRENO) return null
|
||||
when (gpu.family) {
|
||||
Family.POWERVR -> return NAD_RADV_XCLIPSE.takeIf { gpu.name.contains("Xclipse", ignoreCase = true) }
|
||||
Family.MALI_OTHER, Family.NOT_ADRENO -> return null
|
||||
Family.MALI_JM, Family.MALI_G610_G710, Family.MALI_G615, Family.MALI_G720, Family.MALI_LATEST ->
|
||||
return maliKey(gpu, pairs, sdk)
|
||||
else -> Unit
|
||||
}
|
||||
val keys = AutoPicks.preferences(gpu, rules, sdk, blob)
|
||||
.ifEmpty { AutoPicks.preferences(gpu, AutoPicks.BUILT_IN, sdk, blob) }
|
||||
.mapNotNull { if (it == AutoPicks.NEWEST_DD_TURNIP) newestDdTurnip(pairs) else it }
|
||||
@@ -74,6 +130,20 @@ object DriverPairs {
|
||||
?: keys.firstOrNull()
|
||||
}
|
||||
|
||||
private fun maliKey(gpu: GpuInfo, pairs: List<DriverPair>, sdk: Int): String? {
|
||||
val family = when (gpu.family) {
|
||||
Family.MALI_JM -> NAD_MALI_JM
|
||||
Family.MALI_G610_G710 -> NAD_MALI_G710
|
||||
Family.MALI_G615 -> NAD_MALI_G615
|
||||
Family.MALI_G720 -> NAD_MALI_G720
|
||||
else -> null
|
||||
}
|
||||
val kbase = NAD_MALI_KBASE.takeIf { sdk >= MALI_KBASE_MIN_SDK && GpuInfo.maliKbaseCovered(gpu.name) }
|
||||
if (pairs.isEmpty()) return kbase ?: family
|
||||
fun listed(key: String?) = key?.takeIf { k -> pairs.any { it.key == k && it.complete } }
|
||||
return listed(kbase) ?: listed(family) ?: kbase ?: family
|
||||
}
|
||||
|
||||
fun newestDdTurnip(pairs: List<DriverPair>): String? = pairs
|
||||
.filter { it.key.startsWith("$DD_TURNIP:") && it.complete }
|
||||
.maxByOrNull { p ->
|
||||
|
||||
@@ -24,8 +24,22 @@ data class GpuInfo(
|
||||
A7XX("Adreno 7xx"),
|
||||
A6XX("Adreno 6xx"),
|
||||
ADRENO_UNKNOWN("Adreno"),
|
||||
POWERVR("PowerVR"),
|
||||
/** Mali on Arm's kbase driver, by the open PanVK build each generation needs. */
|
||||
MALI_JM("Mali (G52-G78)"),
|
||||
MALI_G610_G710("Mali-G610/G710"),
|
||||
MALI_G615("Mali-G615"),
|
||||
MALI_G720("Mali-G720"),
|
||||
/** Mali-G715/G725/G925: only the one-binary PanVK kbase build covers them (Android 15+). */
|
||||
MALI_LATEST("Mali-G715/G725/G925"),
|
||||
/** A Mali no open driver build covers: the Vulkan bridge is its only path. */
|
||||
MALI_OTHER("Mali"),
|
||||
NOT_ADRENO("Not an Adreno GPU");
|
||||
|
||||
val mali: Boolean get() = name.startsWith("MALI_")
|
||||
|
||||
fun label(gpuName: String): String = if (this == POWERVR && gpuName.contains("Xclipse", ignoreCase = true)) "Samsung Xclipse" else label
|
||||
|
||||
fun label(context: Context): String = if (this == NOT_ADRENO) context.getString(R.string.gpuinfo_not_adreno) else label
|
||||
}
|
||||
|
||||
@@ -47,17 +61,24 @@ data class GpuInfo(
|
||||
val supportText: String
|
||||
get() = when (support) {
|
||||
Support.TESTED -> "Supported"
|
||||
Support.UNTESTED -> if (isA850) "Experimental Adreno 850 support: requires compatible experimental display and game drivers; not verified on this device"
|
||||
else if (family == Family.A7XX_LOW) "Experimental: its drivers are test builds"
|
||||
else "Outside tested hardware (Adreno 650, 725 and newer): it may not run"
|
||||
Support.UNSUPPORTED -> "Not supported: DroidDeck needs an Adreno (Snapdragon) GPU"
|
||||
Support.UNTESTED -> when {
|
||||
family == Family.POWERVR -> if (name.contains("Xclipse", ignoreCase = true)) "Experimental: RADV or the system Xclipse driver"
|
||||
else "System PowerVR driver: compatibility varies by device"
|
||||
family == Family.MALI_OTHER -> "Experimental: Mali through the phone's own driver (Venus)"
|
||||
family.mali -> "Experimental: open Mali driver (test builds)"
|
||||
isA850 -> "Experimental Adreno 850 support: requires compatible experimental display and game drivers; not verified on this device"
|
||||
family == Family.A7XX_LOW -> "Experimental: its drivers are test builds"
|
||||
else -> "Outside tested hardware (Adreno 650, 725 and newer): it may not run"
|
||||
}
|
||||
Support.UNSUPPORTED -> "Not supported: no compatible graphics backend is available for this GPU"
|
||||
}
|
||||
|
||||
fun supportText(context: Context): String = context.getString(when (support) {
|
||||
Support.TESTED -> R.string.gpuinfo_supported
|
||||
Support.UNTESTED -> when {
|
||||
family == Family.POWERVR -> if (name.contains("Xclipse", ignoreCase = true)) R.string.gpuinfo_xclipse else R.string.gpuinfo_powervr
|
||||
isA850 -> R.string.gpuinfo_a850_experimental
|
||||
family == Family.A7XX_LOW -> R.string.gpuinfo_experimental
|
||||
family == Family.A7XX_LOW || family.mali -> R.string.gpuinfo_experimental
|
||||
else -> R.string.gpuinfo_below_tested
|
||||
}
|
||||
Support.UNSUPPORTED -> R.string.gpuinfo_unsupported
|
||||
@@ -79,10 +100,20 @@ data class GpuInfo(
|
||||
{ VulkanInfo.cachedOrNull()?.get("device") },
|
||||
{ platformGpuModel },
|
||||
) else 0 to ""
|
||||
val family = familyOf(adreno, model)
|
||||
// Mali, named by the vendor's Vulkan driver ("Mali-G720-Immortalis MC12") or by kbase.
|
||||
val mali = if (adreno || !File("/dev/mali0").exists()) null else maliName()
|
||||
val family = familyOf(adreno, model, SystemVulkanDriver.isPowerVr(), mali)
|
||||
val samsung = Build.MANUFACTURER.equals("samsung", ignoreCase = true)
|
||||
return GpuInfo(
|
||||
name = if (!adreno) Build.HARDWARE.ifBlank { UNNAMED } else if (model > 0) "Adreno $model" else "Adreno",
|
||||
name = when {
|
||||
family == Family.POWERVR -> SystemVulkanDriver.gpuName().let { gpu ->
|
||||
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains(gpu, ignoreCase = true) } ?: gpu
|
||||
}
|
||||
mali != null && mali.isNotEmpty() -> mali
|
||||
!adreno -> Build.HARDWARE.ifBlank { UNNAMED }
|
||||
model > 0 -> "Adreno $model"
|
||||
else -> "Adreno"
|
||||
},
|
||||
model = model, family = family, soc = soc,
|
||||
oneUi8Gen2 = samsung && model == 740,
|
||||
kgslName = raw.orEmpty(), modelSource = source, kgslChipId = chipId,
|
||||
@@ -124,7 +155,68 @@ data class GpuInfo(
|
||||
""
|
||||
}
|
||||
|
||||
internal fun familyOf(adreno: Boolean, model: Int): Family = when {
|
||||
/**
|
||||
* The Mali's name, "" when nothing names it: the vendor Vulkan driver's own name when this
|
||||
* process has asked it, kbase's gpuinfo where SELinux lets the app read it (most phones do
|
||||
* not), else the GPU the chip is known to carry ([MALI_SOCS]).
|
||||
*/
|
||||
private fun maliName(): String =
|
||||
VulkanInfo.cachedOrNull()?.get("device")?.takeIf { it.contains("Mali", ignoreCase = true) }
|
||||
?: FileUtils.readString(File("/sys/class/misc/mali0/device/gpuinfo"))?.trim()?.takeIf { it.contains("Mali", ignoreCase = true) }
|
||||
?.substringBefore(" ")
|
||||
?: maliOfSoc(socIds())
|
||||
?: ""
|
||||
|
||||
/** The chip's names as the platform gives them: "mt6989", "MT6989", "gs201". */
|
||||
private fun socIds(): List<String> = listOfNotNull(
|
||||
if (Build.VERSION.SDK_INT >= 31) Build.SOC_MODEL else null,
|
||||
systemProperty("ro.board.platform"), systemProperty("ro.soc.model"), Build.HARDWARE, Build.BOARD,
|
||||
).filter { it.isNotBlank() }
|
||||
|
||||
/** Chips whose Mali is known for certain (MediaTek Dimensity / Helio / Kompanio, Google Tensor). */
|
||||
private val MALI_SOCS = mapOf(
|
||||
"mt6993" to "Mali-G1-Ultra", "mt6991" to "Mali-G925", "mt6989" to "Mali-G720", "mt6899" to "Mali-G720", "mt6985" to "Mali-G715",
|
||||
"mt6983" to "Mali-G710", "mt6897" to "Mali-G615", "mt6878" to "Mali-G615", "mt6895" to "Mali-G610",
|
||||
"mt6896" to "Mali-G610", "mt6886" to "Mali-G610", "mt6893" to "Mali-G77", "mt6891" to "Mali-G77",
|
||||
"mt6889" to "Mali-G77", "mt6885" to "Mali-G77", "mt6877" to "Mali-G68", "mt6853" to "Mali-G57",
|
||||
"mt6833" to "Mali-G57", "mt6835" to "Mali-G57", "mt6789" to "Mali-G57", "mt6785" to "Mali-G76",
|
||||
"mt6781" to "Mali-G52", "mt6769" to "Mali-G52", "mt8192" to "Mali-G57", "mt8195" to "Mali-G57",
|
||||
"gs101" to "Mali-G78", "gs201" to "Mali-G710", "zuma" to "Mali-G715", "zumapro" to "Mali-G715",
|
||||
"s5e8835" to "Mali-G68", "s5e8825" to "Mali-G68",
|
||||
)
|
||||
|
||||
/** The Mali [ids] name a chip of, "Mali-G720 (by chip mt6989)", or null for an unknown chip. */
|
||||
internal fun maliOfSoc(ids: List<String>): String? = ids.firstNotNullOfOrNull { id ->
|
||||
MALI_SOCS[id.trim().lowercase()]?.let { "$it (by chip ${id.trim().lowercase()})" }
|
||||
}
|
||||
|
||||
/** The number in a Mali's name: 720 for "Mali-G720-Immortalis MC12". */
|
||||
fun maliNumber(name: String): Int? =
|
||||
Regex("""G(\d{2,3})""", RegexOption.IGNORE_CASE).find(name)?.groupValues?.get(1)?.toIntOrNull()
|
||||
|
||||
/**
|
||||
* The Malis the one-binary PanVK kbase build covers (arch v9-v13): G57/G68/G77/G78,
|
||||
* G610/G710, G615/G715, G720/G725 and G925. Not the older Bifrost G52/G76.
|
||||
*/
|
||||
fun maliKbaseCovered(name: String): Boolean =
|
||||
maliNumber(name) in setOf(57, 68, 77, 78, 610, 710, 615, 715, 720, 725, 925)
|
||||
|
||||
/** The PanVK generation a Mali name belongs to; MALI_OTHER when none of the builds covers it. */
|
||||
internal fun maliFamily(name: String): Family {
|
||||
val number = maliNumber(name) ?: return Family.MALI_OTHER
|
||||
return when (number) {
|
||||
31, 51, 52, 57, 68, 71, 72, 76, 77, 78 -> Family.MALI_JM
|
||||
610, 710 -> Family.MALI_G610_G710
|
||||
615 -> Family.MALI_G615
|
||||
720 -> Family.MALI_G720
|
||||
715, 725, 925 -> Family.MALI_LATEST
|
||||
else -> Family.MALI_OTHER
|
||||
}
|
||||
}
|
||||
|
||||
internal fun familyOf(adreno: Boolean, model: Int, powerVr: Boolean = false, mali: String? = null): Family = when {
|
||||
!adreno && powerVr -> Family.POWERVR
|
||||
!adreno && mali != null -> maliFamily(mali)
|
||||
!adreno -> Family.NOT_ADRENO
|
||||
model == 0 -> Family.ADRENO_UNKNOWN
|
||||
model >= 800 -> Family.A8XX
|
||||
|
||||
@@ -3,8 +3,12 @@ package com.droiddeck.launcher.gpu;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
|
||||
import com.droiddeck.launcher.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class LinuxVulkanDriver {
|
||||
private static final String TAG = "LinuxVulkanDriver";
|
||||
@@ -26,22 +30,35 @@ public final class LinuxVulkanDriver {
|
||||
}
|
||||
|
||||
public static String optionLabel(Context context, String value) {
|
||||
if (value == null || value.isEmpty()) return "Runtime default (built into the runtime)";
|
||||
if (value == null || value.isEmpty()) return SystemVulkanDriver.isPowerVr()
|
||||
? context.getString(R.string.gpu_system_powervr) : "Runtime default (built into the runtime)";
|
||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||
if (!m.isInstalled(value)) return value + " (imported, missing - uses the runtime default)";
|
||||
if (!m.isInstalled(value)) return value + (SystemVulkanDriver.isPowerVr()
|
||||
? " (imported, missing)" : " (imported, missing - uses the runtime default)");
|
||||
String ver = m.getDriverVersion(value);
|
||||
return m.getDriverName(value) + (ver.isEmpty() ? "" : " " + ver) + " (imported)";
|
||||
}
|
||||
|
||||
public static String resolveIcdPath(Context context, String value) {
|
||||
boolean powerVr = SystemVulkanDriver.isPowerVr();
|
||||
return resolveIcdPath(value, powerVr,
|
||||
() -> SystemVulkanDriver.icdPath(context), id -> {
|
||||
String icd = new LinuxVulkanDriverManager(context).getIcdPath(id);
|
||||
if (icd == null) Log.w(TAG, "imported Linux driver \"" + id + "\" is gone"
|
||||
+ (powerVr ? "" : "; using the runtime's own driver"));
|
||||
else Log.i(TAG, "Linux session draws with imported driver " + id + " (" + icd + ")");
|
||||
return icd;
|
||||
});
|
||||
}
|
||||
|
||||
/** Resolve the selected backend before looking up an imported driver. */
|
||||
static String resolveIcdPath(String value, boolean powerVr, Supplier<String> systemIcd,
|
||||
Function<String, String> importedIcd) {
|
||||
if (SystemVulkanDriver.usesDefault(powerVr, value)) return systemIcd.get();
|
||||
if (value == null || value.isEmpty()) return null;
|
||||
LinuxVulkanDriverManager m = new LinuxVulkanDriverManager(context);
|
||||
String icd = m.getIcdPath(value);
|
||||
if (icd == null) {
|
||||
Log.w(TAG, "imported Linux driver \"" + value + "\" is gone; using the runtime's own driver");
|
||||
return null;
|
||||
}
|
||||
Log.i(TAG, "Linux session draws with imported driver " + value + " (" + icd + ")");
|
||||
String icd = importedIcd.apply(value);
|
||||
if (powerVr && icd == null) throw new IllegalStateException(
|
||||
"Selected Linux Vulkan driver \"" + value + "\" is unavailable. Select an installed driver or use Auto.");
|
||||
return icd;
|
||||
}
|
||||
}
|
||||
@@ -45,7 +45,9 @@ public class LinuxVulkanDriverManager {
|
||||
public boolean isInstalled(String id) {
|
||||
if (id == null || id.isEmpty() || id.contains("/") || id.contains("..")) return false;
|
||||
File dir = getDriverDir(id);
|
||||
return new File(dir, LIB_NAME).isFile() && new File(dir, ICD_NAME).isFile();
|
||||
if (!new File(dir, ICD_NAME).isFile()) return false;
|
||||
for (String name : STORED_NAMES) if (new File(dir, name).isFile()) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getIcdPath(String id) {
|
||||
@@ -107,10 +109,10 @@ public class LinuxVulkanDriverManager {
|
||||
if (entry.isDirectory()) continue;
|
||||
String base = new File(entry.getName()).getName();
|
||||
if (base.isEmpty()) continue;
|
||||
if (base.startsWith("libvulkan_freedreno") && base.endsWith(".so")) {
|
||||
if (soName != null) Log.w(TAG, "zip has several libvulkan_freedreno*.so; using the first (" + soName + ")");
|
||||
if (isDriverLibrary(base)) {
|
||||
if (soName != null) Log.w(TAG, "zip has several driver libraries; using the first (" + soName + ")");
|
||||
else {
|
||||
Files.copy(zis, new File(tmpDir, LIB_NAME).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
Files.copy(zis, new File(tmpDir, storedName(base)).toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
soName = base;
|
||||
}
|
||||
} else if (base.equals(META_NAME)) {
|
||||
@@ -142,7 +144,8 @@ public class LinuxVulkanDriverManager {
|
||||
if (soName == null) {
|
||||
throw new IllegalArgumentException(context.getString(R.string.lvd_no_library));
|
||||
}
|
||||
File so = new File(tmpDir, LIB_NAME);
|
||||
String stored = storedName(soName);
|
||||
File so = new File(tmpDir, stored);
|
||||
if (!isAarch64Elf(so)) {
|
||||
throw new IllegalArgumentException(context.getString(R.string.lvd_not_aarch64, soName));
|
||||
}
|
||||
@@ -167,7 +170,7 @@ public class LinuxVulkanDriverManager {
|
||||
JSONObject icd = new JSONObject();
|
||||
icd.put("file_format_version", "1.0.0");
|
||||
JSONObject icdBody = new JSONObject();
|
||||
icdBody.put("library_path", new File(dir, LIB_NAME).getAbsolutePath());
|
||||
icdBody.put("library_path", new File(dir, stored).getAbsolutePath());
|
||||
icdBody.put("api_version", "1.1.274");
|
||||
icd.put("ICD", icdBody);
|
||||
if (!FileUtils.writeString(new File(tmpDir, ICD_NAME), icd.toString(2))) throw new IOException("cannot write icd.json");
|
||||
@@ -180,6 +183,7 @@ public class LinuxVulkanDriverManager {
|
||||
meta.put("libc", "glibc");
|
||||
meta.put("minGlibc", minGlibc);
|
||||
meta.put("sourceLibraryName", soName);
|
||||
meta.put("libraryName", stored);
|
||||
meta.put("importedAt", System.currentTimeMillis());
|
||||
if (!FileUtils.writeString(new File(tmpDir, META_NAME), meta.toString(2))) throw new IOException("cannot write meta.json");
|
||||
|
||||
@@ -198,6 +202,29 @@ public class LinuxVulkanDriverManager {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Linux Vulkan driver's library as release zips name it: Turnip (freedreno) on Adreno, PanVK
|
||||
* (panfrost) on Mali, RADV (radeon) on Xclipse. Whichever it is, it is installed as
|
||||
* {@link #LIB_NAME}; the ICD manifest loads it by that absolute path.
|
||||
*/
|
||||
/** The names an installed driver's library is kept under; Turnip keeps {@link #LIB_NAME}. */
|
||||
private static final String[] STORED_NAMES = {LIB_NAME, "libvulkan_panfrost.so", "libvulkan_radeon.so"};
|
||||
|
||||
/**
|
||||
* The name a driver library is installed under: its own driver's (PanVK, RADV), so the session
|
||||
* log and the graphics report say which driver it is; a Turnip build keeps {@link #LIB_NAME}.
|
||||
*/
|
||||
public static String storedName(String soName) {
|
||||
if (soName != null && soName.startsWith("libvulkan_panfrost")) return "libvulkan_panfrost.so";
|
||||
if (soName != null && soName.startsWith("libvulkan_radeon")) return "libvulkan_radeon.so";
|
||||
return LIB_NAME;
|
||||
}
|
||||
|
||||
public static boolean isDriverLibrary(String base) {
|
||||
return base.endsWith(".so") && (base.startsWith("libvulkan_freedreno")
|
||||
|| base.startsWith("libvulkan_panfrost") || base.startsWith("libvulkan_radeon"));
|
||||
}
|
||||
|
||||
static String sanitizeId(String name) {
|
||||
String s = name.trim().replaceAll("[^A-Za-z0-9._-]+", "_").replaceAll("^[._]+", "");
|
||||
if (s.length() > 64) s = s.substring(0, 64);
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
package com.droiddeck.launcher.gpu;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.OsConstants;
|
||||
import com.droiddeck.launcher.core.FileUtils;
|
||||
import com.droiddeck.launcher.core.TarZst;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Predicate;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/** Isolated glibc-to-Android Vulkan bridge. It does not replace the rootfs's Mesa libraries. */
|
||||
public final class SystemVulkanDriver {
|
||||
private static final String ASSET = "hybris/runtime.tzst";
|
||||
/** Vendor HALs the bridge loads. Samsung Xclipse (Exynos, sgpu) is experimental. */
|
||||
private static final String[] HALS = {
|
||||
"/vendor/lib64/hw/vulkan.powervr.so",
|
||||
"/vendor/lib64/hw/vulkan.samsung.so"
|
||||
};
|
||||
private static final String[] REQUIRED = {
|
||||
"lib/libhybris-vulkan-icd.so.0", "lib/libhybris-common.so.1",
|
||||
"lib/libhybris/linker/q.so", "lib/libVkLayer_hybris_compat.so",
|
||||
"run-proton.py", "wsi/libVkLayer_window_system_integration.so",
|
||||
"wsi/VkLayer_window_system_integration.json",
|
||||
"dxvk/x32/d3d8.dll", "dxvk/x32/d3d9.dll", "dxvk/x32/d3d10core.dll",
|
||||
"dxvk/x32/d3d11.dll", "dxvk/x32/dxgi.dll",
|
||||
"dxvk/x64/d3d8.dll", "dxvk/x64/d3d9.dll", "dxvk/x64/d3d10core.dll",
|
||||
"dxvk/x64/d3d11.dll", "dxvk/x64/dxgi.dll"
|
||||
};
|
||||
|
||||
/** Rootfs directory of the Xclipse layer the apk stages (SessionFiles). */
|
||||
private static final String XCLIPSE_LAYER_DIR = "/usr/local/lib/droiddeck-xclipse";
|
||||
|
||||
private SystemVulkanDriver() {}
|
||||
|
||||
/**
|
||||
* The first vendor HAL present, or null. An Exynos with a Mali (Exynos 1280/1380: /dev/mali0)
|
||||
* may name its HAL vulkan.samsung.so too; that is a Mali, not an Xclipse, and is not taken.
|
||||
*/
|
||||
public static String hal() {
|
||||
for (String path : HALS) {
|
||||
if (!new File(path).isFile()) continue;
|
||||
if (path.endsWith("/vulkan.samsung.so") && new File("/dev/mali0").exists()) continue;
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/** Samsung's Xclipse (Exynos, sgpu) rather than PowerVR. */
|
||||
public static boolean isXclipse() {
|
||||
String hal = hal();
|
||||
return hal != null && hal.endsWith("/vulkan.samsung.so");
|
||||
}
|
||||
|
||||
/** The system-driver GPU family, for labels. */
|
||||
public static String gpuName() { return isXclipse() ? "Xclipse" : "PowerVR"; }
|
||||
|
||||
/** Whether a system-driver GPU (PowerVR or Xclipse) is present; the name predates Xclipse. */
|
||||
public static boolean isPowerVr() { return hal() != null; }
|
||||
|
||||
/** HAL detection names the GPU; launching also needs the real DRM render node. */
|
||||
public static boolean isAvailable() { return isPowerVr() && renderNodeAvailable(); }
|
||||
|
||||
public static boolean renderNodeAvailable() {
|
||||
return renderNodePath() != null;
|
||||
}
|
||||
|
||||
/** Select the actual PowerVR node, including devices where another GPU owns renderD128. */
|
||||
public static String renderNodePath() {
|
||||
String[] nodes = new File("/dev/dri").list();
|
||||
if (nodes == null) nodes = new File("/sys/class/drm").list();
|
||||
return findRenderNode(nodes, SystemVulkanDriver::renderNodeAvailable);
|
||||
}
|
||||
|
||||
static String findRenderNode(String[] nodes, Predicate<String> available) {
|
||||
TreeSet<String> candidates = new TreeSet<>();
|
||||
// Android can deny directory listing while allowing direct access. Probe the kernel's
|
||||
// reserved render range too; directory entries also cover dynamically allocated minors.
|
||||
for (int minor = 128; minor < 192; minor++) candidates.add("renderD" + minor);
|
||||
if (nodes != null) for (String node : nodes)
|
||||
if (node.matches("renderD[0-9]+")) candidates.add(node);
|
||||
for (String node : candidates) {
|
||||
String path = "/dev/dri/" + node;
|
||||
if (available.test(path)) return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static boolean renderNodeAvailable(String node) {
|
||||
try {
|
||||
if (!renderNodeAvailable(OsConstants.S_ISCHR(Os.stat(node).st_mode),
|
||||
Os.access(node, OsConstants.R_OK), Os.access(node, OsConstants.W_OK))) return false;
|
||||
return powerVrDevice(new File("/sys/class/drm/" + new File(node).getName() + "/device"));
|
||||
} catch (ErrnoException error) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean powerVrDriver(String driver) {
|
||||
return "pvrsrvkm".equals(driver) || "pvr".equals(driver) || "powervr".equals(driver)
|
||||
|| "sgpu".equals(driver);
|
||||
}
|
||||
|
||||
static boolean powerVrDevice(File device) {
|
||||
try {
|
||||
return powerVrDriver(Files.readSymbolicLink(new File(device, "driver").toPath())
|
||||
.getFileName().toString());
|
||||
} catch (IOException error) {
|
||||
// Some Android policies expose uevent but deny reading the driver symlink.
|
||||
try (BufferedReader input = Files.newBufferedReader(
|
||||
new File(device, "uevent").toPath(), StandardCharsets.US_ASCII)) {
|
||||
String line;
|
||||
while ((line = input.readLine()) != null)
|
||||
if (line.startsWith("DRIVER=")) return powerVrDriver(line.substring(7));
|
||||
} catch (IOException ignored) { }
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean renderNodeAvailable(boolean characterDevice, boolean readable, boolean writable) {
|
||||
return characterDevice && readable && writable;
|
||||
}
|
||||
|
||||
public static boolean usesDefault(String choice) {
|
||||
return usesDefault(isPowerVr(), choice);
|
||||
}
|
||||
|
||||
static boolean usesDefault(boolean powerVr, String choice) {
|
||||
return powerVr && (choice == null || choice.isEmpty());
|
||||
}
|
||||
|
||||
/** APK-versioned directories stay intact while an older session still has libraries mapped. */
|
||||
public static synchronized File prepare(Context context) throws IOException {
|
||||
if (!isPowerVr()) throw new IOException("System PowerVR Vulkan driver is unavailable");
|
||||
if (!renderNodeAvailable()) throw new IOException(
|
||||
"System PowerVR requires an identifiable, readable and writable DRM render node");
|
||||
File target = runtimeDirectory(context);
|
||||
File base = target.getParentFile();
|
||||
if (complete(target)) return target;
|
||||
if (!base.isDirectory() && !base.mkdirs()) throw new IOException("Cannot create system Vulkan directory");
|
||||
File staged = new File(base, ".stage-" + UUID.randomUUID());
|
||||
try {
|
||||
if (!TarZst.extractAsset(context, ASSET, staged)) throw new IOException("Cannot unpack system Vulkan runtime");
|
||||
for (String name : REQUIRED)
|
||||
if (!present(staged, name)) throw new IOException("Missing system Vulkan component: " + name);
|
||||
if (!new File(staged, "run-proton.py").canExecute())
|
||||
throw new IOException("System Vulkan Proton wrapper is not executable");
|
||||
JSONObject library = new JSONObject();
|
||||
library.put("library_path", new File(target, REQUIRED[0]).getPath());
|
||||
library.put("api_version", "1.3.0");
|
||||
JSONObject manifest = new JSONObject();
|
||||
manifest.put("file_format_version", "1.0.0");
|
||||
manifest.put("ICD", library);
|
||||
Files.write(new File(staged, "icd.json").toPath(), manifest.toString().getBytes(StandardCharsets.UTF_8));
|
||||
if (target.exists()) throw new IOException("Incomplete system Vulkan runtime directory: " + target.getName());
|
||||
if (!staged.renameTo(target)) throw new IOException("Cannot publish system Vulkan runtime");
|
||||
return target;
|
||||
} catch (org.json.JSONException error) {
|
||||
throw new IOException("Cannot write system Vulkan manifest", error);
|
||||
} finally {
|
||||
if (staged.exists()) FileUtils.delete(staged);
|
||||
}
|
||||
}
|
||||
|
||||
/** The current APK's versioned runtime path, without extracting or modifying it. */
|
||||
public static File runtimeDirectory(Context context) throws IOException {
|
||||
String version;
|
||||
try (BufferedReader input = new BufferedReader(new InputStreamReader(
|
||||
context.getAssets().open("hybris/version.txt"), StandardCharsets.US_ASCII))) {
|
||||
version = input.readLine();
|
||||
}
|
||||
if (version == null || !version.matches("[0-9a-f]{64}")) throw new IOException("Invalid system Vulkan runtime version");
|
||||
return new File(new File(context.getFilesDir(), "system_vulkan"), version);
|
||||
}
|
||||
|
||||
/** Collect abandoned stages, and obsolete versions once older guests can no longer load them. */
|
||||
public static synchronized void pruneUnused(Context context, boolean guestsStopped) throws IOException {
|
||||
pruneUnused(runtimeDirectory(context), guestsStopped);
|
||||
}
|
||||
|
||||
static synchronized void pruneUnused(File current, boolean guestsStopped) {
|
||||
File base = current.getParentFile();
|
||||
if (base == null || Files.isSymbolicLink(base.toPath()) || Files.isSymbolicLink(current.toPath())) return;
|
||||
File[] entries = base.listFiles();
|
||||
if (entries == null) return;
|
||||
// Retain the previous good version if publishing the replacement failed.
|
||||
boolean pruneVersions = guestsStopped && complete(current);
|
||||
for (File entry : entries) {
|
||||
if (entry.equals(current)) continue;
|
||||
String name = entry.getName();
|
||||
boolean oldVersion = pruneVersions && name.matches("[0-9a-f]{64}");
|
||||
boolean abandonedStage = name.matches("\\.stage-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
||||
// The prepare monitor excludes any extraction still writing a .stage directory.
|
||||
if (oldVersion || abandonedStage) FileUtils.delete(entry);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean complete(File directory) {
|
||||
if (!new File(directory, "icd.json").isFile()) return false;
|
||||
for (String name : REQUIRED) if (!present(directory, name)) return false;
|
||||
return new File(directory, "run-proton.py").canExecute();
|
||||
}
|
||||
|
||||
private static boolean present(File directory, String name) {
|
||||
File file = new File(directory, name);
|
||||
return file.isFile() && file.length() > 0;
|
||||
}
|
||||
|
||||
public static String icdPath(Context context) {
|
||||
try {
|
||||
return new File(prepare(context), "icd.json").getPath();
|
||||
} catch (IOException error) {
|
||||
throw new IllegalStateException("System Vulkan runtime is unavailable", error);
|
||||
}
|
||||
}
|
||||
|
||||
public static void addEnvironment(Context context, List<String> environment) {
|
||||
File directory;
|
||||
try { directory = prepare(context); }
|
||||
catch (IOException error) { throw new IllegalStateException("System Vulkan runtime is unavailable", error); }
|
||||
String node = renderNodePath();
|
||||
if (node == null) throw new IllegalStateException("System PowerVR render node is unavailable");
|
||||
environment.add("HYBRIS_ANDROID_SDK_VERSION=" + Build.VERSION.SDK_INT);
|
||||
environment.add("HYBRIS_VULKAN_HAL=" + hal());
|
||||
environment.add("HYBRIS_LINKER_DIR=" + new File(directory, "lib/libhybris/linker").getPath());
|
||||
// Prefer framework dependencies for the system Vulkan loader, including libbase.so.
|
||||
environment.add("HYBRIS_LD_LIBRARY_PATH=/system/lib64:/system_ext/lib64:/vendor/lib64/egl:/vendor/lib64/hw:/vendor/lib64");
|
||||
boolean xclipse = isXclipse();
|
||||
// Xclipse gets its own layer (tools/linuxfs/xclipse-layer) in front of everything: it sets
|
||||
// bionic's environ for the driver's shader compiler, among other driver workarounds. The
|
||||
// session's own clients need nothing else; games keep the compat layer's BC emulation.
|
||||
String layers = xclipse ? "VK_LAYER_DROIDDECK_xclipse" : "VK_LAYER_HYBRIS_compat";
|
||||
environment.add("VK_LAYER_PATH=" + new File(directory, "lib").getPath() + (xclipse ? ":" + XCLIPSE_LAYER_DIR : ""));
|
||||
environment.add("VK_INSTANCE_LAYERS=" + layers);
|
||||
// Proton game launches add their WSI layer in front of these (droiddeck-game-env).
|
||||
environment.add("DROIDDECK_HYBRIS_LAYERS=" + (xclipse ? layers + ":VK_LAYER_HYBRIS_compat" : layers));
|
||||
if (xclipse) environment.add("DROIDDECK_HYBRIS_LAYER_PATH=" + XCLIPSE_LAYER_DIR);
|
||||
// DXVK 3 needs 256 bytes of push constants; this driver has 128.
|
||||
if (xclipse) environment.add("DROIDDECK_HYBRIS_DXVK=dxvk-2.6.2");
|
||||
// The Android driver has a render node, but no KMS primary node. SDL presents
|
||||
// through the wrapper's Wayland Vulkan swapchain instead of a KMS-style path.
|
||||
environment.add("BL_GAMESCOPE_BACKEND=sdl");
|
||||
// The Android pvr kernel accepts Vulkan DMA-BUF imports but rejects PRIME GEM handles.
|
||||
environment.add("BL_POWERVR_DRM_HANDLES=1");
|
||||
environment.add("BL_POWERVR_RENDER_NODE=" + node);
|
||||
// Inner Gamescope/Xwayland lacks the bridge's Android-buffer WSI protocols.
|
||||
environment.add("BL_STEAM_GL_PRESENT=1");
|
||||
// Only actual Proton game launches use the bundled DXVK and X11 WSI layer.
|
||||
environment.add("DROIDDECK_POWERVR_RUNTIME=" + directory.getPath());
|
||||
}
|
||||
}
|
||||
@@ -263,7 +263,24 @@ public final class TurnipDriver {
|
||||
}
|
||||
|
||||
private String choose() {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(context);
|
||||
String chosen = SessionPrefs.androidDriver(context);
|
||||
// Mali (Venus): the phone's own driver draws the screen, as Venus replays on it.
|
||||
if (com.droiddeck.launcher.session.VenusComponent.wanted(context)) {
|
||||
Log.i(TAG, "Mali (Venus): display on the system Vulkan loader");
|
||||
return null;
|
||||
}
|
||||
// A Mali under Auto draws its display on Android's own Vulkan loader, whatever an earlier
|
||||
// build set: a PanVK Android half fails on Mali gralloc. A manual pick is respected.
|
||||
if (chosen != null && !chosen.isEmpty() && new File("/dev/mali0").exists()
|
||||
&& !com.droiddeck.launcher.core.DeviceSupport.INSTANCE.adreno()
|
||||
&& SessionPrefs.GPU_DRIVERS_AUTO.equals(SessionPrefs.INSTANCE.gpuDriverMode(context))) {
|
||||
DriverBundle.Bundle bundle = DriverBundle.INSTANCE.containing(context, chosen, false);
|
||||
if (bundle != null && DriverPairs.INSTANCE.isNonAdreno(bundle.getId())) {
|
||||
Log.i(TAG, "Mali under Auto: display on the system Vulkan loader, not " + chosen);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (chosen != null && !chosen.isEmpty()) {
|
||||
if (BUNDLED.contains(chosen)) {
|
||||
Log.i(TAG, "driver pinned by the user: " + chosen);
|
||||
@@ -289,8 +306,14 @@ public final class TurnipDriver {
|
||||
if (forced.startsWith("a7")) return DRIVER_A7XX;
|
||||
if (forced.startsWith("a6")) return DRIVER_A6XX;
|
||||
}
|
||||
if (SystemVulkanDriver.isPowerVr()) return null;
|
||||
String quest = QuestExperimental.INSTANCE.defaultAndroidDriver();
|
||||
if (quest != null) return quest;
|
||||
// Turnip cannot open a Mali (no KGSL): the compositor runs on the phone's own driver.
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.INSTANCE.mali()) {
|
||||
Log.i(TAG, "Mali: the compositor uses the system Vulkan driver");
|
||||
return null;
|
||||
}
|
||||
GpuInfo gpu = gpuDetector.get();
|
||||
if (gpu.getFamily() == GpuInfo.Family.NOT_ADRENO) {
|
||||
Log.i(TAG, "not an Adreno GPU; leaving the display driver to the system");
|
||||
|
||||
@@ -22,12 +22,17 @@ object TurnipReleases {
|
||||
private const val KEY_PICKS = "autoPicks"
|
||||
|
||||
class Asset(val source: String, val tag: String, val name: String, val url: String, val size: Long, val linux: Boolean, val label: String,
|
||||
val sha256: String = "", val pair: String = "", val bundle: Boolean = false)
|
||||
val sha256: String = "", val pair: String = "", val bundle: Boolean = false,
|
||||
val assetId: Long = 0, val updatedAt: String = "") {
|
||||
/** "2026-10-15" from GitHub's updated_at; empty when the check did not record it. */
|
||||
val builtOn: String get() = updatedAt.take(10)
|
||||
}
|
||||
class Check(val assets: List<Asset>, val latest: List<Pair<String, String>>, val failed: List<String>, val checkedAt: Long)
|
||||
|
||||
private class Kind(val linux: Boolean, val label: String, val pair: String, val bundle: Boolean = false)
|
||||
|
||||
private class Source(val label: String, val repo: String, val classify: (name: String, tag: String) -> Kind?)
|
||||
/** [prerelease]: a source whose bundles are all test builds offers them from pre-releases too. */
|
||||
private class Source(val label: String, val repo: String, val prerelease: Boolean = false, val classify: (name: String, tag: String) -> Kind?)
|
||||
|
||||
private val SOURCES = listOf(
|
||||
Source("Banners-Turnip", "The412Banner/Banners-Turnip") { name, tag ->
|
||||
@@ -56,8 +61,22 @@ object TurnipReleases {
|
||||
if (!Regex("""^DD-Turnip-v\d+\.\d+\.\d+\.zip$""").matches(name)) return@Source null
|
||||
Kind(false, "Android + Linux · all Adreno", DriverPairs.ddTurnip(tag), bundle = true)
|
||||
},
|
||||
// <Id>-Pair.zip: open drivers for GPUs that are not Adreno (PanVK for Mali, RADV for
|
||||
// Xclipse), both halves in one zip. One release per driver, replaced in place on each
|
||||
// rebuild; every one is a test build, published as a pre-release.
|
||||
Source(NON_ADRENO_LABEL, NON_ADRENO_REPO, prerelease = true) { name, _ ->
|
||||
val m = Regex("""^(RADV-Xclipse(?:-[A-Za-z0-9]+)*?|PanVK-[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*?)-Pair\.zip$""").find(name) ?: return@Source null
|
||||
val key = DriverPairs.nonAdreno(m.groupValues[1])
|
||||
Kind(false, "Android + Linux · " + DriverPairs.nonAdrenoName(key), key, bundle = true)
|
||||
},
|
||||
)
|
||||
|
||||
private const val NON_ADRENO_REPO = "The412Banner/droiddeck-nonadreno-drivers"
|
||||
const val NON_ADRENO_LABEL = "Non-Adreno"
|
||||
|
||||
private fun sources(): List<Source> =
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.adreno()) SOURCES.filter { it.repo != NON_ADRENO_REPO } else SOURCES
|
||||
|
||||
fun autoPicks(context: Context): List<AutoPicks.Rule> =
|
||||
AutoPicks.parse(prefs(context).getString(KEY_PICKS, null)) ?: AutoPicks.BUILT_IN
|
||||
|
||||
@@ -71,9 +90,13 @@ object TurnipReleases {
|
||||
val latest = JSONArray()
|
||||
val failed = ArrayList<String>()
|
||||
var lastError: Exception? = null
|
||||
for (src in SOURCES) {
|
||||
val sources = sources()
|
||||
for (src in sources) {
|
||||
try {
|
||||
val releases = JSONArray(get(context, "https://api.github.com/repos/${src.repo}/releases?per_page=15"))
|
||||
// The non-Adreno repo keeps one release per driver plus many component builds (gamescope,
|
||||
// Venus): its driver pairs fall past the first 15, so it is read in one full page.
|
||||
val perPage = if (src.repo == NON_ADRENO_REPO) 100 else 15
|
||||
val releases = JSONArray(get(context, "https://api.github.com/repos/${src.repo}/releases?per_page=$perPage"))
|
||||
val seen = HashSet<String>()
|
||||
var newest: String? = null
|
||||
for (i in 0 until releases.length()) {
|
||||
@@ -86,7 +109,7 @@ object TurnipReleases {
|
||||
val a = list.getJSONObject(j)
|
||||
val name = a.getString("name")
|
||||
val kind = src.classify(name, tag) ?: continue
|
||||
if (kind.bundle && r.optBoolean("prerelease")) continue
|
||||
if (kind.bundle && r.optBoolean("prerelease") && !src.prerelease) continue
|
||||
val linux = kind.linux
|
||||
val label = kind.label
|
||||
val sha = Hashes.githubSha256(a.optString("digest")) ?: continue
|
||||
@@ -94,7 +117,7 @@ object TurnipReleases {
|
||||
assets.put(JSONObject().put("source", src.label).put("tag", tag).put("name", name)
|
||||
.put("url", a.getString("browser_download_url")).put("size", a.optLong("size"))
|
||||
.put("linux", linux).put("label", label).put("sha256", sha).put("pair", kind.pair)
|
||||
.put("bundle", kind.bundle))
|
||||
.put("bundle", kind.bundle).put("id", a.optLong("id")).put("updated_at", a.optString("updated_at")))
|
||||
}
|
||||
}
|
||||
if (newest != null) latest.put(JSONObject().put("source", src.label).put("tag", newest))
|
||||
@@ -103,7 +126,7 @@ object TurnipReleases {
|
||||
lastError = e
|
||||
}
|
||||
}
|
||||
if (failed.size == SOURCES.size) throw lastError ?: IOException("no source answered")
|
||||
if (failed.size == sources.size) throw lastError ?: IOException("no source answered")
|
||||
runCatching { get(context, AutoPicks.URL, AutoPicks.URL) }
|
||||
.onFailure { Log.i(TAG, "auto picks: ${it.message}") }
|
||||
.getOrNull()?.takeIf { AutoPicks.parse(it) != null }
|
||||
@@ -154,7 +177,7 @@ object TurnipReleases {
|
||||
val a = list.getJSONObject(i)
|
||||
out.add(Asset(a.getString("source"), a.getString("tag"), a.getString("name"), a.getString("url"),
|
||||
a.optLong("size"), a.getBoolean("linux"), a.getString("label"), a.optString("sha256", ""), a.optString("pair", ""),
|
||||
a.optBoolean("bundle", false)))
|
||||
a.optBoolean("bundle", false), a.optLong("id"), a.optString("updated_at", "")))
|
||||
}
|
||||
val latest = ArrayList<Pair<String, String>>()
|
||||
val l = json.optJSONArray("latest") ?: JSONArray()
|
||||
@@ -165,16 +188,53 @@ object TurnipReleases {
|
||||
return Check(out, latest, failed, json.optLong("checkedAt"))
|
||||
}
|
||||
|
||||
fun installedId(context: Context, asset: Asset, isInstalled: (String) -> Boolean): String? =
|
||||
fun installedId(context: Context, asset: Asset, isInstalled: (String) -> Boolean): String? {
|
||||
val d = downloads(context)
|
||||
if (DriverPairs.isNonAdreno(asset.pair) && asset.sha256.isNotEmpty() &&
|
||||
!asset.sha256.equals(d.optString(SHA_PREFIX + asset.name, asset.sha256), ignoreCase = true)) return null
|
||||
return d.optString(asset.name, "").takeIf { it.isNotEmpty() && isInstalled(it) }
|
||||
}
|
||||
|
||||
private const val SHA_PREFIX = "sha256:"
|
||||
private const val ASSET_ID_PREFIX = "asset:"
|
||||
private const val UPDATED_PREFIX = "updated:"
|
||||
|
||||
/** The id an open non-Adreno pair's asset was installed as, whichever build of it that was. */
|
||||
fun installedIdAnyBuild(context: Context, asset: Asset, isInstalled: (String) -> Boolean): String? =
|
||||
downloads(context).optString(asset.name, "").takeIf { it.isNotEmpty() && isInstalled(it) }
|
||||
|
||||
/**
|
||||
* An open non-Adreno pair is rebuilt in place under the same tag: a different digest, asset id
|
||||
* or upload time than the one installed means a newer build.
|
||||
*/
|
||||
fun updateAvailable(context: Context, asset: Asset): Boolean {
|
||||
if (!DriverPairs.isNonAdreno(asset.pair)) return false
|
||||
val d = downloads(context)
|
||||
if (d.optString(asset.name, "").isEmpty()) return false
|
||||
val sha = d.optString(SHA_PREFIX + asset.name, "")
|
||||
val id = d.optLong(ASSET_ID_PREFIX + asset.name, 0)
|
||||
val updated = d.optString(UPDATED_PREFIX + asset.name, "")
|
||||
return (sha.isNotEmpty() && asset.sha256.isNotEmpty() && !sha.equals(asset.sha256, ignoreCase = true)) ||
|
||||
(id != 0L && asset.assetId != 0L && id != asset.assetId) ||
|
||||
(updated.isNotEmpty() && asset.updatedAt.isNotEmpty() && updated != asset.updatedAt)
|
||||
}
|
||||
|
||||
/** When the installed build of [asset] was uploaded, as recorded at download ("" if unknown). */
|
||||
fun installedBuiltOn(context: Context, asset: Asset): String = downloads(context).optString(UPDATED_PREFIX + asset.name, "").take(10)
|
||||
|
||||
fun isDownloaded(context: Context, id: String): Boolean {
|
||||
val d = downloads(context)
|
||||
return d.keys().asSequence().any { d.optString(it) == id }
|
||||
}
|
||||
|
||||
fun recordDownload(context: Context, asset: Asset, id: String) {
|
||||
prefs(context).edit().putString(KEY_DOWNLOADS, downloads(context).put(asset.name, id).toString()).apply()
|
||||
val d = downloads(context).put(asset.name, id)
|
||||
if (DriverPairs.isNonAdreno(asset.pair)) {
|
||||
if (asset.sha256.isNotEmpty()) d.put(SHA_PREFIX + asset.name, asset.sha256)
|
||||
if (asset.assetId != 0L) d.put(ASSET_ID_PREFIX + asset.name, asset.assetId)
|
||||
if (asset.updatedAt.isNotEmpty()) d.put(UPDATED_PREFIX + asset.name, asset.updatedAt)
|
||||
}
|
||||
prefs(context).edit().putString(KEY_DOWNLOADS, d.toString()).apply()
|
||||
}
|
||||
|
||||
fun forget(context: Context, id: String) {
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.HostProcess
|
||||
import com.droiddeck.launcher.core.SessionPart
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* The Vulkan bridge server (external/MaliBridge) for one session.
|
||||
*
|
||||
* On a GPU without Adreno's KGSL nothing inside the Linux runtime can reach the GPU: Turnip needs
|
||||
* KGSL, and the phone's own driver is a bionic library a glibc program cannot load. The server is
|
||||
* a bionic process the app starts here - executed from the native library directory like the
|
||||
* DirectAudio relay - which loads the system Vulkan loader and runs the Vulkan calls the
|
||||
* session's programs send it through the bridge ICD over a Unix socket. It is the app's child, so
|
||||
* it dies with the app (it also asks for that with PR_SET_PDEATHSIG).
|
||||
*
|
||||
* Started before the guest and waited for: the server runs a self-test first (which memory
|
||||
* sharing works on this GPU), and only then listens; a program that starts before the socket
|
||||
* exists would find no Vulkan driver.
|
||||
*/
|
||||
class VkBridgeComponent(private val socket: File, private val logFile: File) : SessionPart() {
|
||||
@Volatile private var pid = -1
|
||||
@Volatile private var exited = false
|
||||
|
||||
override fun start() {
|
||||
stop()
|
||||
val binary = File(app().applicationInfo.nativeLibraryDir, BINARY)
|
||||
if (!binary.isFile) {
|
||||
Log.e(TAG, "server missing at $binary; the session will have no Vulkan")
|
||||
return
|
||||
}
|
||||
socket.parentFile?.mkdirs()
|
||||
// Pipeline cache kept across sessions (Mali recompiles everything in a new process otherwise).
|
||||
val cacheDir = cacheDir(app())
|
||||
// Setup's "Safe mode", for a new server and for the in-app one that is reused (it reads
|
||||
// the file again at each client): the JNI call stays as it is.
|
||||
writeMode(cacheDir, com.droiddeck.launcher.session.SessionPrefs.vkBridgeMode(app()))
|
||||
// A separate process by default: a crash in the GPU driver (seen once inside Mali's
|
||||
// vkBeginCommandBuffer) then ends the session, not the app. In-process gave the same driver
|
||||
// and the same 119 extensions on the Tab S10+; it remains the fallback.
|
||||
if (VkBridgeNative.start(app(), socket, logFile, cacheDir)) {
|
||||
Log.i(TAG, "server ready in the app's process at $socket")
|
||||
return
|
||||
}
|
||||
socket.delete()
|
||||
exited = false
|
||||
val cmd = listOf(binary.absolutePath, "--socket", socket.absolutePath, "--log", logFile.absolutePath,
|
||||
"--cache-dir", cacheDir.absolutePath)
|
||||
.joinToString(" ") { it.replace("\\", "\\\\").replace(" ", "\\ ") }
|
||||
val env = arrayOf("HOME=" + app().filesDir)
|
||||
pid = HostProcess.start(cmd, env, app().filesDir, { status ->
|
||||
exited = true
|
||||
Log.w(TAG, "server exited with status $status")
|
||||
runCatching { logFile.appendText("== vkbridge server exited with status $status\n") }
|
||||
}, { line -> Log.i(TAG, line) })
|
||||
// The self-test takes about a second; a cold driver can take longer.
|
||||
val began = System.currentTimeMillis()
|
||||
val deadline = began + 15_000L
|
||||
while (!socket.exists() && !exited && System.currentTimeMillis() < deadline) {
|
||||
try { Thread.sleep(50L) } catch (e: InterruptedException) { Thread.currentThread().interrupt(); break }
|
||||
}
|
||||
val waited = System.currentTimeMillis() - began
|
||||
Log.i(TAG, if (socket.exists()) "server ready (pid $pid) at $socket after $waited ms"
|
||||
else "server NOT ready (pid $pid, exited=$exited) after $waited ms; see $logFile")
|
||||
if (!socket.exists() && VkBridgeNative.start(app(), socket, logFile, cacheDir)) Log.i(TAG, "server ready in the app's process at $socket")
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
// The in-app server outlives sessions: its socket stays.
|
||||
if (pid > 0) {
|
||||
Process.killProcess(pid)
|
||||
pid = -1
|
||||
}
|
||||
if (!VkBridgeNative.serving) socket.delete()
|
||||
}
|
||||
|
||||
override fun suspendPid(): Int = pid
|
||||
|
||||
companion object {
|
||||
private const val TAG = "VkBridge"
|
||||
private const val CACHE_DIR = "vkbridge-pipelines"
|
||||
private const val MODE_FILE = "mode"
|
||||
|
||||
/**
|
||||
* The server's own directory (--cache-dir): pipeline caches, the startup probe's device
|
||||
* profile, stuck-pipelines and stuck-spirv/, and the env file of test switches. In the
|
||||
* app's files, which Android never trims: it empties the app's cacheDir when storage runs
|
||||
* low, and once took all of this from under a running server. Nothing trims it here; the
|
||||
* server bounds what it keeps (64 MB per pipeline cache file, and in newer servers a total
|
||||
* limit, VKBRIDGE_PCACHE_TOTAL_MB). A directory left in cacheDir by an older build is moved
|
||||
* over once.
|
||||
*/
|
||||
fun cacheDir(context: Context): File {
|
||||
val dir = File(context.filesDir, CACHE_DIR)
|
||||
val old = File(context.cacheDir, CACHE_DIR)
|
||||
if (old.isDirectory) migrate(old, dir)
|
||||
dir.mkdirs()
|
||||
return dir
|
||||
}
|
||||
|
||||
/**
|
||||
* <cache dir>/mode: "safe" or "performance", one word, written atomically (the server may
|
||||
* read it at any moment). VKBRIDGE_MODE in <cache dir>/env or the server's environment
|
||||
* wins over it (developer overrides).
|
||||
*/
|
||||
fun writeMode(dir: File, mode: String) {
|
||||
val file = File(dir, MODE_FILE)
|
||||
if (runCatching { file.readText().trim() }.getOrNull() == mode) return
|
||||
val tmp = File(dir, "$MODE_FILE.tmp")
|
||||
runCatching {
|
||||
tmp.writeText(mode + "\n")
|
||||
if (!tmp.renameTo(file)) error("rename failed")
|
||||
Log.i(TAG, "bridge mode: $mode")
|
||||
}.onFailure { Log.w(TAG, "could not write $file: $it"); tmp.delete() }
|
||||
}
|
||||
|
||||
/** Moves old's contents into dir (what dir already has wins), then removes old. */
|
||||
private fun migrate(old: File, dir: File) {
|
||||
val moved = if (!dir.exists()) old.renameTo(dir) else false
|
||||
if (!moved) {
|
||||
dir.mkdirs()
|
||||
old.listFiles()?.forEach { f ->
|
||||
val to = File(dir, f.name)
|
||||
if (to.exists()) return@forEach
|
||||
if (!f.renameTo(to)) runCatching { f.copyRecursively(to, overwrite = false) }
|
||||
}
|
||||
old.deleteRecursively()
|
||||
}
|
||||
Log.i(TAG, "bridge cache moved from $old to $dir")
|
||||
}
|
||||
|
||||
/** The server, named as a library so Android extracts it and lets the app run it. */
|
||||
const val BINARY = "libvkbridge_server.so"
|
||||
/** Inside the runtime (staged by SessionFiles). */
|
||||
const val GUEST_ICD = "/usr/local/share/vkbridge/droidbridge_icd.json"
|
||||
const val GUEST_LIB = "/usr/local/lib/vkbridge/libvulkan_droidbridge.so"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.util.Log
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* The bridge server inside the app's own process (libvkbridge_jni.so, server_main.c).
|
||||
*
|
||||
* Android chooses the GPU driver - Samsung's updatable one included - while the app starts up, and
|
||||
* only for the app's process: the server run as a separate executable got the plain /vendor driver,
|
||||
* which on the Tab S10+ lacked VK_EXT_robustness2 and more that the app itself sees. Started by the
|
||||
* first bridge session and kept for the app's life; later sessions only point its log at their
|
||||
* own folder. VkBridgeComponent falls back to the executable when this cannot start.
|
||||
*/
|
||||
object VkBridgeNative {
|
||||
private const val TAG = "VkBridge"
|
||||
|
||||
@Volatile private var loaded: Boolean? = null
|
||||
|
||||
/**
|
||||
* The packaged library, or - in a debuggable build only - files/vkbridge/dev/libvkbridge_jni.so
|
||||
* when present, so a rebuilt server can be tried with `adb push` + `run-as cp` and an app
|
||||
* restart instead of a new APK (the app targets SDK 28 and may load code from its files).
|
||||
*/
|
||||
private fun load(context: Context): Boolean {
|
||||
loaded?.let { return it }
|
||||
val ok = try {
|
||||
val dev = File(context.filesDir, "vkbridge/dev/libvkbridge_jni.so")
|
||||
val debuggable = context.applicationInfo.flags and ApplicationInfo.FLAG_DEBUGGABLE != 0
|
||||
if (debuggable && dev.isFile) {
|
||||
Log.w(TAG, "in-app server from the development override $dev")
|
||||
System.load(dev.absolutePath)
|
||||
} else {
|
||||
System.loadLibrary("vkbridge_jni")
|
||||
}
|
||||
true
|
||||
} catch (e: Throwable) {
|
||||
Log.w(TAG, "in-app server unavailable: $e")
|
||||
false
|
||||
}
|
||||
loaded = ok
|
||||
return ok
|
||||
}
|
||||
|
||||
/** Whether the in-app server is serving (its socket must then be left alone). */
|
||||
@Volatile var serving = false
|
||||
private set
|
||||
|
||||
/** Starts the server, or points its log at [log] when it already runs; false when it cannot serve. */
|
||||
fun start(context: Context, socket: File, log: File, cacheDir: File): Boolean {
|
||||
if (!load(context)) return false
|
||||
val ok = try {
|
||||
nativeStart(socket.absolutePath, log.absolutePath, cacheDir.absolutePath) == 1
|
||||
} catch (e: Throwable) {
|
||||
Log.w(TAG, "in-app server failed to start: $e")
|
||||
false
|
||||
}
|
||||
if (ok) serving = true
|
||||
return ok
|
||||
}
|
||||
|
||||
@JvmStatic private external fun nativeStart(socket: String, log: String, cacheDir: String): Int
|
||||
}
|
||||
@@ -196,6 +196,7 @@ object BwrapSpawner {
|
||||
LIB_DIRS.map { File(rootfs, "$it/$name") }.firstOrNull { it.exists() }
|
||||
|
||||
private fun gpu(rootfs: String, root: File, env: MutableMap<String, String>): List<Bind>? {
|
||||
env["VKBRIDGE_SOCKET"]?.let { sock -> if (File(sock).exists()) return bridgeGpu(rootfs, root, env, sock) }
|
||||
val driver = runtimeLib(rootfs, "libvulkan_freedreno.so")
|
||||
if (driver == null || !File("/dev/kgsl-3d0").exists()) return null
|
||||
if (env.containsKey("VK_ICD_FILENAMES") || env.containsKey("VK_DRIVER_FILES")) return null
|
||||
@@ -218,6 +219,25 @@ object BwrapSpawner {
|
||||
return binds
|
||||
}
|
||||
|
||||
private fun bridgeGpu(rootfs: String, root: File, env: MutableMap<String, String>, socket: String): List<Bind>? {
|
||||
val driver = File(rootfs, "usr/local/lib/vkbridge/libvulkan_droidbridge.so")
|
||||
if (!driver.isFile) { Log.w(TAG, "gpu: vkbridge session but no bridge ICD in the runtime"); return null }
|
||||
val binds = ArrayList<Bind>()
|
||||
binds.add(Bind(driver.canonicalPath, "$GPU_DIR/libvulkan_droidbridge.so"))
|
||||
val sockDir = File(socket).parent ?: return null
|
||||
binds.add(Bind(sockDir, sockDir))
|
||||
val icd = File(root.parentFile, "vkbridge_icd.json")
|
||||
icd.writeText("{\"file_format_version\": \"1.0.0\", \"ICD\": {\"library_path\": \"$GPU_DIR/libvulkan_droidbridge.so\", \"api_version\": \"1.3.247\"}}\n")
|
||||
binds.add(Bind(icd.path, "$GPU_DIR/vkbridge_icd.json"))
|
||||
env["VK_DRIVER_FILES"] = "$GPU_DIR/vkbridge_icd.json"
|
||||
env["VK_ICD_FILENAMES"] = "$GPU_DIR/vkbridge_icd.json"
|
||||
if (!env.containsKey("MESA_LOADER_DRIVER_OVERRIDE") && !env.containsKey("GALLIUM_DRIVER")) {
|
||||
env["MESA_LOADER_DRIVER_OVERRIDE"] = "zink"
|
||||
env["GALLIUM_DRIVER"] = "zink"
|
||||
}
|
||||
return binds
|
||||
}
|
||||
|
||||
private fun preload(session: List<Bind>, rootfs: String, env: MutableMap<String, String>): List<Bind> {
|
||||
val libs = FileUtils.readString(File(rootfs, "etc/ld.so.preload"))?.lines()
|
||||
?.map { it.trim() }?.filter { it.startsWith("/") && File(rootfs + it).isFile } ?: return emptyList()
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.system.StructStat;
|
||||
import android.system.StructUtsname;
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver;
|
||||
import com.droiddeck.launcher.session.SessionPrefs;
|
||||
|
||||
|
||||
@@ -196,6 +197,13 @@ public final class LinuxRuntime {
|
||||
bind(cmd, "/dev");
|
||||
bind(cmd, "/proc");
|
||||
bind(cmd, "/sys");
|
||||
if (com.droiddeck.launcher.gpu.SystemVulkanDriver.isPowerVr()) {
|
||||
// The glibc bridge loads the device's existing Android HAL and its dependencies.
|
||||
// These read-only Android partitions remain subject to the app's normal permissions.
|
||||
for (String path : new String[]{"/system", "/vendor", "/apex", "/system_ext", "/product", "/odm"})
|
||||
if (new File(path).isDirectory()) bind(cmd, path);
|
||||
if (new File("/linkerconfig/ld.config.txt").isFile()) bind(cmd, "/linkerconfig/ld.config.txt");
|
||||
}
|
||||
bind(cmd, DeviceControlsComponent.prepareBacklight(context, root).getPath() + ":/sys/class/backlight");
|
||||
bind(cmd, "/dev/urandom:/dev/random");
|
||||
bind(cmd, "/proc/self/fd:/dev/fd");
|
||||
@@ -203,6 +211,10 @@ public final class LinuxRuntime {
|
||||
bind(cmd, "/proc/self/fd/1:/dev/stdout");
|
||||
bind(cmd, "/proc/self/fd/2:/dev/stderr");
|
||||
bind(cmd, new File(root, "etc/droiddeck/empty").getPath() + ":/sys/fs/selinux");
|
||||
// A kernel that refuses to list /sys/class/thermal (Pixel 10, Android 17) made mangoapp abort
|
||||
// at start ("filesystem_error ... Permission denied: '/sys/class/thermal/'") until its
|
||||
// wrapper gave up: it lists the directory for CPU temperatures. Empty there instead.
|
||||
if (new File("/sys/class/thermal").list() == null) bind(cmd, new File(root, "etc/droiddeck/empty").getPath() + ":/sys/class/thermal");
|
||||
bind(cmd, context.getFilesDir().getPath());
|
||||
bind(cmd, context.getCacheDir().getPath());
|
||||
bind(cmd, liveDir(context).getPath());
|
||||
@@ -264,7 +276,11 @@ public final class LinuxRuntime {
|
||||
if (unreadablePciDevice()) {
|
||||
bind(cmd, new File(root, "etc/droiddeck/empty").getPath() + ":/sys/bus/pci/devices");
|
||||
}
|
||||
bindGpuNode(context, cmd);
|
||||
if (com.droiddeck.launcher.gpu.SystemVulkanDriver.isPowerVr()) {
|
||||
bindPowerVrGpuNode(context, cmd);
|
||||
} else {
|
||||
bindGpuNode(context, cmd);
|
||||
}
|
||||
bindAdrenoStats(cmd, extraBinds);
|
||||
bindCpuTemps(cmd, root);
|
||||
if (extraBinds != null) {
|
||||
@@ -275,6 +291,44 @@ public final class LinuxRuntime {
|
||||
return specs;
|
||||
}
|
||||
|
||||
private static void bindPowerVrGpuNode(Context context, List<String> cmd) {
|
||||
if (new File("/dev/dri").list() != null) return;
|
||||
String node = SystemVulkanDriver.renderNodePath();
|
||||
if (node == null) return;
|
||||
String name = new File(node).getName();
|
||||
File dri = new File(context.getCacheDir(), "powervr-drm/" + name + "/dri");
|
||||
try {
|
||||
if (!dri.isDirectory() && !dri.mkdirs()) return;
|
||||
new File(dri, name).createNewFile();
|
||||
} catch (IOException e) {
|
||||
android.util.Log.w("LinuxRuntime", "Cannot expose the PowerVR render node", e);
|
||||
return;
|
||||
}
|
||||
bind(cmd, dri.getPath() + ":/dev/dri");
|
||||
bind(cmd, node + ":" + node);
|
||||
android.util.Log.i("LinuxRuntime", "PowerVR: exposing real " + name + " through a listable directory");
|
||||
}
|
||||
|
||||
public static final String MALI_DEVICE = "/dev/mali0";
|
||||
|
||||
public static String gpuStandIn(Context context) {
|
||||
if (new File(KGSL_DEVICE).exists()) return KGSL_DEVICE;
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.INSTANCE.vkBridge(context) && new File(MALI_DEVICE).exists()) return MALI_DEVICE;
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.INSTANCE.openDriverActive(context) && new File(MALI_DEVICE).exists()) return MALI_DEVICE;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String deviceNumbers(String path) {
|
||||
try {
|
||||
long dev = Os.stat(path).st_rdev;
|
||||
long major = ((dev >> 8) & 0xfff) | ((dev >> 32) & ~0xfffL);
|
||||
long minor = (dev & 0xff) | ((dev >> 12) & ~0xffL);
|
||||
return major + ":" + minor;
|
||||
} catch (ErrnoException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean unreadablePciDevice() {
|
||||
File[] devices = new File("/sys/bus/pci/devices").listFiles();
|
||||
if (devices == null) return false;
|
||||
@@ -285,9 +339,12 @@ public final class LinuxRuntime {
|
||||
}
|
||||
|
||||
private static void bindGpuNode(Context context, List<String> cmd) {
|
||||
String standIn = gpuStandIn(context);
|
||||
if (standIn == null) return;
|
||||
boolean kgsl = standIn.equals(KGSL_DEVICE);
|
||||
StructStat st;
|
||||
try {
|
||||
st = Os.stat(KGSL_DEVICE);
|
||||
st = Os.stat(standIn);
|
||||
} catch (ErrnoException e) {
|
||||
return;
|
||||
}
|
||||
@@ -307,13 +364,14 @@ public final class LinuxRuntime {
|
||||
Files.write(new File(drm, "dev").toPath(),
|
||||
(major + ":" + minor + "\n").getBytes(StandardCharsets.UTF_8));
|
||||
Files.write(new File(device, "uevent").toPath(),
|
||||
"DRIVER=kgsl-3d0\nMODALIAS=platform:kgsl-3d0\n".getBytes(StandardCharsets.UTF_8));
|
||||
(kgsl ? "DRIVER=kgsl-3d0\nMODALIAS=platform:kgsl-3d0\n" : "DRIVER=mali\nMODALIAS=platform:mali\n")
|
||||
.getBytes(StandardCharsets.UTF_8));
|
||||
File subsystem = new File(device, "subsystem");
|
||||
if (!Files.isSymbolicLink(subsystem.toPath())) {
|
||||
Os.symlink("/sys/bus/platform", subsystem.getPath());
|
||||
}
|
||||
File driver = new File(device, "driver");
|
||||
if (!Files.isSymbolicLink(driver.toPath())) {
|
||||
if (kgsl && !Files.isSymbolicLink(driver.toPath())) {
|
||||
Os.symlink("/sys/bus/platform/drivers/msm_drm", driver.getPath());
|
||||
}
|
||||
} catch (IOException | ErrnoException e) {
|
||||
@@ -321,7 +379,7 @@ public final class LinuxRuntime {
|
||||
}
|
||||
bind(cmd, new File(base, "sys").getPath() + ":/sys/dev/char");
|
||||
bind(cmd, dri.getPath() + ":/dev/dri");
|
||||
bind(cmd, KGSL_DEVICE + ":/dev/dri/" + node);
|
||||
bind(cmd, standIn + ":/dev/dri/" + node);
|
||||
bindDrmClass(base, cmd, node, major + ":" + minor);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.droiddeck.launcher.core.Downloader
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import com.github.luben.zstd.ZstdInputStream
|
||||
import com.github.luben.zstd.ZstdOutputStream
|
||||
@@ -199,9 +200,13 @@ object ComponentsManager {
|
||||
COMPONENTS.mapNotNull { comp -> profile.optString(comp).takeIf(String::isNotEmpty)?.let { comp to it } }.toMap()
|
||||
}
|
||||
|
||||
fun setGameComponent(context: Context, scope: String, comp: String, file: String?) = synchronized(lock) {
|
||||
fun setGameComponent(context: Context, scope: String, comp: String, file: String?) =
|
||||
setGameComponent(context, scope, comp, file) { runtimeManaged(context, it) }
|
||||
|
||||
internal fun setGameComponent(context: Context, scope: String, comp: String, file: String?, managed: (String) -> Boolean) = synchronized(lock) {
|
||||
require(scope.matches(Regex("[1-9][0-9]{0,9}")) && scope.toLong() <= 4294967295L)
|
||||
require(comp in COMPONENTS)
|
||||
if (file != null) requireSelectable(context, comp, managed)
|
||||
val state = loadState(context)
|
||||
val profiles = state.sub("profiles")
|
||||
val profile = profiles.optJSONObject(scope) ?: JSONObject().also { profiles.put(scope, it) }
|
||||
@@ -638,11 +643,21 @@ object ComponentsManager {
|
||||
return PreparedLaunchState(lines.toString(), keep)
|
||||
}
|
||||
|
||||
internal fun runtimeManaged(comp: String, systemPowerVr: Boolean): Boolean = comp == "dxvk" && systemPowerVr
|
||||
|
||||
private fun runtimeManaged(context: Context, comp: String): Boolean =
|
||||
runtimeManaged(comp, SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(context)))
|
||||
|
||||
private fun requireSelectable(context: Context, comp: String, managed: (String) -> Boolean = { runtimeManaged(context, it) }) {
|
||||
check(!managed(comp)) { context.getString(R.string.cmgr_powervr_dxvk_managed) }
|
||||
}
|
||||
|
||||
|
||||
fun swap(context: Context, protonId: String, file: String): String = synchronized(lock) {
|
||||
val p = proton(context, protonId)
|
||||
val wcp = File(packagesDir(context), safeName(file))
|
||||
val info = packageInfo(context, wcp)
|
||||
requireSelectable(context, info.comp)
|
||||
val state = loadState(context)
|
||||
if (inUse(context, p)) {
|
||||
state.sub("queued").sub(p.id).put(info.comp, JSONObject().put("kind", "package").put("file", wcp.name).put("label", info.version))
|
||||
@@ -666,6 +681,7 @@ object ComponentsManager {
|
||||
}
|
||||
|
||||
fun restore(context: Context, protonId: String, comp: String, protonVersion: String): String = synchronized(lock) {
|
||||
requireSelectable(context, comp)
|
||||
val p = proton(context, protonId)
|
||||
val wcp = File(originalsDir(context), "$protonId/${safeName(protonVersion)}/$comp.wcp")
|
||||
check(wcp.isFile) { context.getString(R.string.cmgr_original_missing) }
|
||||
@@ -691,7 +707,10 @@ object ComponentsManager {
|
||||
.put("protonVersion", p.version).put("files", JSONObject(fingerprint(p.dir, comp) as Map<*, *>)).put("at", System.currentTimeMillis() / 1000))
|
||||
}
|
||||
|
||||
fun applyQueued(context: Context): List<String> = synchronized(lock) {
|
||||
/** Runs the swaps that waited for a game to close. Cheap when nothing is queued. */
|
||||
fun applyQueued(context: Context): List<String> = applyQueued(context) { runtimeManaged(context, it) }
|
||||
|
||||
internal fun applyQueued(context: Context, managed: (String) -> Boolean): List<String> = synchronized(lock) {
|
||||
val state = loadState(context)
|
||||
val queued = state.sub("queued")
|
||||
if (queued.length() == 0) return emptyList()
|
||||
@@ -703,6 +722,7 @@ object ComponentsManager {
|
||||
val comps = queued.optJSONObject(pid) ?: continue
|
||||
for (comp in comps.keys().asSequence().toList()) {
|
||||
val q = comps.optJSONObject(comp) ?: continue
|
||||
if (managed(comp)) continue
|
||||
runCatching {
|
||||
if (q.optString("kind") == "original") {
|
||||
val v = q.optString("protonVersion")
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.system.Os
|
||||
import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.gpu.DriverBundle
|
||||
import com.droiddeck.launcher.gpu.DriverPairs
|
||||
import com.droiddeck.launcher.gpu.GpuInfo
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipReleases
|
||||
import com.droiddeck.launcher.gpu.VulkanInfo
|
||||
import java.io.File
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
|
||||
/**
|
||||
* graphics-report.txt in each session's folder: which graphics path the session drew with and why,
|
||||
* the GPU and its device nodes, the environment the guest got, and at the end what the compositor
|
||||
* said about its driver. Written for a non-Adreno test report, where a black screen otherwise comes
|
||||
* with nothing to read; the Share logs zip takes the whole folder, so it travels with the logs.
|
||||
* Read-only: nothing here opens a GPU node or changes a setting.
|
||||
*/
|
||||
object GraphicsReport {
|
||||
const val FILE = "graphics-report.txt"
|
||||
const val GAMES_DIR = "games"
|
||||
|
||||
/** One file in games/ past this is cut to its first part at the session's end. */
|
||||
private const val GAME_FILE_MAX = 20L * 1024 * 1024
|
||||
/** All of games/ past this loses its oldest launches. */
|
||||
private const val GAMES_TOTAL_MAX = 120L * 1024 * 1024
|
||||
|
||||
/** The guest keys the report repeats: everything that decides which Vulkan driver loads. */
|
||||
private val ENV_PREFIXES = listOf(
|
||||
"VK_", "BL_VK", "BL_DRM", "BL_VKBRIDGE", "VKBRIDGE", "MESA_", "GALLIUM_", "ZINK", "TU_", "PANVK",
|
||||
"DROIDDECK_POWERVR", "DROIDDECK_HYBRIS", "BL_GAME_LOGS", "LIBGL_", "GAMESCOPE_DISABLE", "XWAYLAND",
|
||||
)
|
||||
|
||||
/** Per-game graphics logs and the guest's Vulkan summary: on for a non-Adreno GPU, or by Setup's switch. */
|
||||
fun detailed(context: Context): Boolean = !DeviceSupport.adreno() || SessionPrefs.detailedGraphicsLogs(context)
|
||||
|
||||
/** For finish(), which runs from the session's end without a context of its own. */
|
||||
@Volatile private var appContext: Context? = null
|
||||
|
||||
/** Writes the start of the report; never throws. */
|
||||
fun begin(context: Context, dir: File, guest: List<String>) {
|
||||
appContext = context.applicationContext
|
||||
runCatching { File(dir, FILE).writeText(start(context, guest)) }
|
||||
.onFailure { android.util.Log.w("GraphicsReport", "could not write $FILE", it) }
|
||||
}
|
||||
|
||||
private fun start(context: Context, guest: List<String>): String = buildString {
|
||||
val time = SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(Date())
|
||||
appendLine("== graphics report, session start $time")
|
||||
appendLine("build: ${com.droiddeck.launcher.BuildConfig.BUILD_LABEL} (source ${com.droiddeck.launcher.BuildConfig.SOURCE_COMMIT})")
|
||||
appendLine()
|
||||
val gpu = runCatching { GpuInfo.detect() }.getOrNull()
|
||||
appendLine("-- path")
|
||||
appendLine("path: " + path(context))
|
||||
appendLine("driver mode: " + SessionPrefs.gpuDriverMode(context))
|
||||
appendLine("display driver (compositor): " + SessionPrefs.androidDriver(context).ifEmpty {
|
||||
if (DeviceSupport.adreno()) "(auto: bundled Turnip)" else "(auto: the phone's own Vulkan driver, ${SystemVulkanDriver.hal() ?: "vendor HAL"})"
|
||||
})
|
||||
val display = SessionPrefs.androidDriver(context)
|
||||
appendLine("display driver chosen by: " + when {
|
||||
display.isEmpty() -> "auto (or a pair on a non-Adreno GPU: the phone's own driver)"
|
||||
DriverBundle.containing(context, display, false) != null -> "pair (its display half)"
|
||||
else -> "user (picked on its own)"
|
||||
})
|
||||
val linux = SessionPrefs.linuxDriver(context)
|
||||
appendLine("runtime driver: " + linux.ifEmpty { "(runtime default)" })
|
||||
if (linux.isNotEmpty()) {
|
||||
val dir = com.droiddeck.launcher.gpu.LinuxVulkanDriverManager(context).getDriverDir(linux)
|
||||
appendLine("runtime driver dir: ${dir.path} (" + (dir.listFiles()?.filter { it.name.endsWith(".so") }?.joinToString { it.name } ?: "missing") + ")")
|
||||
}
|
||||
val prefs = context.getSharedPreferences("graphics_report", Context.MODE_PRIVATE)
|
||||
val previous = prefs.getString("lastDrivers", null)
|
||||
val now = "display ${SessionPrefs.androidDriver(context).ifEmpty { "(auto)" }}, runtime ${linux.ifEmpty { "(default)" }}, bridge ${DeviceSupport.vkBridge(context)}, venus ${VenusComponent.wanted(context)}"
|
||||
appendLine("previous session's drivers: " + (previous ?: "(none recorded)") + if (previous != null && previous != now) " << CHANGED" else "")
|
||||
prefs.edit().putString("lastDrivers", now).apply()
|
||||
DriverBundle.active(context)?.let { b ->
|
||||
appendLine("pair: ${b.name} ${b.version} (bundle ${b.id})")
|
||||
release(context, b.id)?.let { appendLine("pair release: $it") }
|
||||
}
|
||||
if (gpu != null) {
|
||||
val pairs = DriverPairs.from(TurnipReleases.cached(context))
|
||||
appendLine("auto would pick: " + (DriverPairs.recommendedKey(gpu, pairs) ?: "(no pair: system driver or bridge)"))
|
||||
}
|
||||
appendLine("frame generation: " + runCatching { com.droiddeck.launcher.gpu.FrameGen.mode(context).toString() }.getOrDefault("?") +
|
||||
" (engine=off means it is switched off in Play settings; a driver that fails LSFG's gates logs \"device gates\" below)")
|
||||
appendLine("mali bridge setting: " + SessionPrefs.vkBridge(context) + ", in use: " + DeviceSupport.vkBridge(context))
|
||||
val standIn = runCatching { com.droiddeck.launcher.runtime.LinuxRuntime.gpuStandIn(context) }.getOrNull()
|
||||
appendLine("render node for the guest: " + (standIn?.let { node ->
|
||||
com.droiddeck.launcher.runtime.LinuxRuntime.deviceNumbers(node)?.let { n -> "/dev/dri/renderD${n.substringAfter(':')} -> $node ($n)" } ?: node
|
||||
} ?: if (SystemVulkanDriver.isPowerVr()) "the system GPU's own /dev/dri node (#570)" else "none"))
|
||||
appendLine()
|
||||
appendLine("-- gpu")
|
||||
if (gpu != null) {
|
||||
appendLine("family: ${gpu.family} (${gpu.supportText})")
|
||||
appendLine("name: ${gpu.name}" + if (gpu.model > 0) ", model ${gpu.model} (${gpu.modelSource})" else "")
|
||||
}
|
||||
appendLine("vulkan device (app): " + (VulkanInfo.cachedOrNull()?.get("device") ?: "(not probed)"))
|
||||
appendLine("system vulkan hal: " + (SystemVulkanDriver.hal() ?: "none"))
|
||||
read("/sys/class/misc/mali0/device/gpuinfo")?.let { appendLine("mali gpuinfo: $it") }
|
||||
appendLine("android: ${Build.VERSION.RELEASE} (sdk ${Build.VERSION.SDK_INT}), ${Build.MANUFACTURER} ${Build.MODEL}")
|
||||
val soc = if (Build.VERSION.SDK_INT >= 31) "${Build.SOC_MANUFACTURER} ${Build.SOC_MODEL}" else Build.HARDWARE
|
||||
appendLine("soc: $soc, board ${Build.BOARD}, hardware ${Build.HARDWARE}")
|
||||
appendLine("kernel: " + (System.getProperty("os.version") ?: "?"))
|
||||
appendLine()
|
||||
appendLine("-- gpu nodes (from the app; not opened)")
|
||||
val dri = File("/dev/dri").list()?.sorted()?.map { "/dev/dri/$it" }.orEmpty()
|
||||
for (path in listOf("/dev/kgsl-3d0", "/dev/mali0") + dri) appendLine(node(path))
|
||||
if (dri.isEmpty()) appendLine("/dev/dri: " + if (File("/dev/dri").exists()) "not listable" else "absent")
|
||||
appendLine()
|
||||
appendLine("-- guest environment (graphics)")
|
||||
guest.filter { e -> ENV_PREFIXES.any { e.startsWith(it) } }.sorted().forEach { appendLine(it) }
|
||||
appendLine()
|
||||
}
|
||||
|
||||
/** Which backend this session's Vulkan goes through, as the session decides it. */
|
||||
private fun path(context: Context): String = when {
|
||||
DeviceSupport.adreno() -> "Turnip (Adreno, KGSL)"
|
||||
VenusComponent.wanted(context) -> "Mali (Venus): Mesa Venus over vtest to the phone's own Vulkan driver, with the Mali compatibility layer"
|
||||
DeviceSupport.vkBridge(context) -> "Mali bridge (#517): the phone's own Vulkan driver through the bridge"
|
||||
DeviceSupport.openDriverActive(context) -> "open driver pair (PanVK / RADV)"
|
||||
SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(context)) && SystemVulkanDriver.isAvailable() ->
|
||||
"system Vulkan (#570): ${SystemVulkanDriver.gpuName()} driver through libhybris"
|
||||
SessionPrefs.linuxDriver(context).isNotEmpty() -> "imported runtime driver ${SessionPrefs.linuxDriver(context)}"
|
||||
else -> "none for this GPU (no Adreno, no system HAL, no pair, bridge off)"
|
||||
}
|
||||
|
||||
/** The release tag and download a pair bundle came from, when the last release check knows it. */
|
||||
private fun release(context: Context, bundleId: String): String? {
|
||||
val bundles = TurnipReleases.cached(context)?.assets?.filter { it.bundle }.orEmpty()
|
||||
val asset = bundles.firstOrNull { it.name.removeSuffix("-Pair.zip") == bundleId }
|
||||
?: bundles.firstOrNull { bundleId.startsWith(it.name.removeSuffix("-Pair.zip") + "-") }
|
||||
?: return null
|
||||
val installed = TurnipReleases.installedBuiltOn(context, asset)
|
||||
return "${asset.tag} ${asset.url}" +
|
||||
(if (installed.isNotEmpty()) ", installed build uploaded $installed" else "") +
|
||||
(if (asset.builtOn.isNotEmpty()) ", listed build uploaded ${asset.builtOn}" else "") +
|
||||
(if (TurnipReleases.updateAvailable(context, asset)) " << NEWER BUILD AVAILABLE" else "")
|
||||
}
|
||||
|
||||
private fun node(path: String): String {
|
||||
val f = File(path)
|
||||
if (!f.exists()) return "$path: absent"
|
||||
val access = (if (f.canRead()) "r" else "-") + (if (f.canWrite()) "w" else "-")
|
||||
val rdev = runCatching { Os.stat(path).st_rdev }.getOrNull()
|
||||
val numbers = rdev?.let { " ${major(it)}:${minor(it)}" }.orEmpty()
|
||||
val label = runCatching { String(Os.getxattr(path, "security.selinux")).trimEnd('\u0000') }.getOrNull()
|
||||
return "$path: $access$numbers" + (label?.let { " $it" } ?: "")
|
||||
}
|
||||
|
||||
/** Linux's dev_t split (glibc's gnu_dev_major / gnu_dev_minor). */
|
||||
internal fun major(dev: Long): Long = ((dev ushr 8) and 0xfff) or ((dev ushr 32) and 0xfffff000L)
|
||||
internal fun minor(dev: Long): Long = (dev and 0xff) or ((dev ushr 12) and 0xffffff00L)
|
||||
|
||||
private fun read(path: String): String? = FileUtils.readString(File(path))?.trim()?.takeIf { it.isNotEmpty() }
|
||||
|
||||
/** The compositor's driver lines from the app's own log. */
|
||||
private val COMPOSITOR = Regex(
|
||||
"""vk_present|waylandcomp|vk_loader|compositor|vkCreateDevice|extension|adrenotools|TurnipDriver|""" +
|
||||
"""graphics driver|display driver|DD_PRESENT_FAULT|SystemVulkan|vkbridge|VkBridge|mali_gralloc|panvk|PanVK|radv|MESA|native buffer|first frame|present|""" +
|
||||
"""lsfg|FrameGen|device gates|AAudio|directaudio|pulse|gralloc|dma.?buf|modifier|import""",
|
||||
RegexOption.IGNORE_CASE,
|
||||
)
|
||||
|
||||
/** The session script's driver lines: what it exported, the bridge's self-test, vulkaninfo, gamescope's Vulkan errors. */
|
||||
private val GUEST = Regex("""== vulkan driver|== vkbridge|== vulkaninfo|vulkan:|panvk|PanVK|radv|primary node|No compatible|DRM format|kbase|AAUDIO|client sink|Xwayland|\(EE\)|glamor|XWAYLAND_NO_GLAMOR""", RegexOption.IGNORE_CASE)
|
||||
|
||||
/**
|
||||
* The end of the report, from the finished folder: the compositor's driver lines out of
|
||||
* app.log, and games/ held to its size limits. Never throws.
|
||||
*/
|
||||
fun finish(dir: File) {
|
||||
runCatching {
|
||||
val report = File(dir, FILE)
|
||||
if (!report.isFile) return
|
||||
val lines = File(dir, "app.log").takeIf { it.isFile }?.useLines { seq -> seq.filter { COMPOSITOR.containsMatchIn(it) }.take(400).toList() }.orEmpty()
|
||||
val games = File(dir, GAMES_DIR).listFiles()?.filter { it.isDirectory }?.sortedBy { it.name }.orEmpty()
|
||||
val guestLines = File(dir, "session.log").takeIf { it.isFile }?.useLines { seq ->
|
||||
seq.filter { GUEST.containsMatchIn(it) }.take(200).toList()
|
||||
}.orEmpty()
|
||||
val fallbackLines = File(dir, "vkbridge-fallback").takeIf { it.isFile }?.readLines()?.map { it.trim() }?.filter { it.isNotEmpty() }
|
||||
val fellBack = fallbackLines?.firstOrNull()
|
||||
val fallbackReason = fallbackLines?.getOrNull(1).orEmpty()
|
||||
runCatching { SessionPrefs.setBridgeFellBack(appContext ?: return@runCatching, fellBack != null, fallbackReason) }
|
||||
val limits = File(dir, "limits.txt").takeIf { it.isFile }?.readText()?.trim()
|
||||
val audio = File(dir, "audio.log").takeIf { it.isFile }?.readText().orEmpty()
|
||||
report.appendText(buildString {
|
||||
limits?.let { appendLine("open files limit: $it") }
|
||||
fellBack?.let {
|
||||
if (fallbackReason == "memory") appendLine("!! MALI BRIDGE FELL BACK: memory sharing = none (no method passed the server's self-test); the session ran on $it")
|
||||
else appendLine("!! MALI BRIDGE FELL BACK: the self-test failed images or draws; the session ran on $it")
|
||||
}
|
||||
com.droiddeck.launcher.wayland.WaylandCompositor.compositorFault().takeIf { it.isNotEmpty() }?.let {
|
||||
appendLine("!! DISPLAY FAILED: $it")
|
||||
}
|
||||
com.droiddeck.launcher.wayland.WaylandCompositor.displayDriver().takeIf { it.isNotEmpty() }?.let {
|
||||
appendLine("display driver (as loaded): $it")
|
||||
}
|
||||
appContext?.let { ctx ->
|
||||
if (SessionPrefs.venus(ctx)) VenusComponent.hostVulkanTooOld(ctx)?.let {
|
||||
appendLine("!! VENUS OFF: the phone's driver reports Vulkan $it; gamescope needs 1.2 or newer, so the session did not use Venus")
|
||||
}
|
||||
}
|
||||
if (audio.contains("AAUDIO_ERROR_DISCONNECTED")) {
|
||||
appendLine("!! SOUND: Android refused the audio output (AAUDIO_ERROR_DISCONNECTED) - rebooting the phone usually fixes this")
|
||||
}
|
||||
if (guestLines.any { it.contains("vkbridge", ignoreCase = true) && it.contains("FAIL") }) {
|
||||
appendLine("!! MALI BRIDGE SELF-TEST FAILED: this GPU's driver did not pass the bridge's checks (see below)")
|
||||
}
|
||||
if (guestLines.any { it.contains("MEM_EXEC_INIT") }) {
|
||||
appendLine("note: kbase refused KBASE_IOCTL_MEM_EXEC_INIT with EPERM. That answer comes from the kbase driver")
|
||||
appendLine(" itself (proot does not filter ioctls; Android's seccomp would kill or return ENOSYS; SELinux")
|
||||
appendLine(" would return EACCES), so it is the kernel's policy for this context, not the session's.")
|
||||
}
|
||||
appendLine("-- driver lines from the session log (${guestLines.size})")
|
||||
guestLines.forEach { appendLine(it) }
|
||||
appendLine()
|
||||
appendLine("-- compositor and driver lines from app.log (${lines.size})")
|
||||
lines.forEach { appendLine(it) }
|
||||
appendLine()
|
||||
appendLine("-- game launches with detailed logs: ${games.size}")
|
||||
games.forEach { appendLine(it.name) }
|
||||
appendLine("== session end " + SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(Date()))
|
||||
})
|
||||
capGames(File(dir, GAMES_DIR))
|
||||
}.onFailure { android.util.Log.w("GraphicsReport", "could not finish $FILE", it) }
|
||||
}
|
||||
|
||||
/** Cuts each file in [games] to [GAME_FILE_MAX] and drops the oldest launches past [GAMES_TOTAL_MAX]. */
|
||||
internal fun capGames(games: File, fileMax: Long = GAME_FILE_MAX, totalMax: Long = GAMES_TOTAL_MAX) {
|
||||
if (!games.isDirectory) return
|
||||
games.walkTopDown().filter { it.isFile && it.length() > fileMax }.forEach { f ->
|
||||
runCatching { java.io.RandomAccessFile(f, "rw").use { it.setLength(fileMax) } }
|
||||
}
|
||||
val launches = games.listFiles()?.filter { it.isDirectory }?.sortedBy { it.name }.orEmpty().toMutableList()
|
||||
fun size(d: File) = d.walkTopDown().filter { it.isFile }.sumOf { it.length() }
|
||||
var total = launches.sumOf { size(it) }
|
||||
while (total > totalMax && launches.size > 1) {
|
||||
val oldest = launches.removeAt(0)
|
||||
total -= size(oldest)
|
||||
FileUtils.delete(oldest)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,23 @@ object OrphanReaper {
|
||||
|
||||
fun release(pid: Int) { kept.remove(pid) }
|
||||
|
||||
/** Signal 0 checks ownership/liveness without sending a signal, even when /proc is unreadable. */
|
||||
fun hasOtherProcesses(): Boolean = hasOtherProcesses(
|
||||
File("/proc").list()?.mapNotNull { it.toIntOrNull() }, android.os.Process.myPid(),
|
||||
) { pid ->
|
||||
try {
|
||||
android.system.Os.kill(pid, 0)
|
||||
true
|
||||
} catch (error: android.system.ErrnoException) {
|
||||
error.errno != android.system.OsConstants.ESRCH && error.errno != android.system.OsConstants.EPERM
|
||||
} catch (error: SecurityException) {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
internal fun hasOtherProcesses(pids: List<Int>?, ownPid: Int, signalable: (Int) -> Boolean): Boolean =
|
||||
pids == null || pids.any { it > 1 && it != ownPid && signalable(it) }
|
||||
|
||||
fun reap(reason: String): Int {
|
||||
val me = android.os.Process.myPid()
|
||||
val uid = android.os.Process.myUid()
|
||||
|
||||
@@ -504,14 +504,20 @@ object SessionArtifacts {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Finishes the folders of sessions whose process died without its teardown. Returns true when
|
||||
* the newest of them ended because Android killed the app for memory, so the app can say so
|
||||
* (a game "crashing" on a phone with little free RAM is usually this, not a driver fault).
|
||||
*/
|
||||
@Synchronized
|
||||
fun finishAbandoned(context: Context, beforeGuestStart: Boolean = false) {
|
||||
fun finishAbandoned(context: Context, beforeGuestStart: Boolean = false): Boolean {
|
||||
val stopWhenSessionStarts = !beforeGuestStart
|
||||
val parent = LinuxRuntime.logDir(context)
|
||||
val abandoned = parent.listFiles { f ->
|
||||
SessionPaths.isSessionFolder(f) && !File(f, COMPLETE_MARKER).exists() && !inFlight(f)
|
||||
}?.sortedWith(SessionPaths.chronological) ?: return
|
||||
if (abandoned.isEmpty()) return
|
||||
}?.sortedWith(SessionPaths.chronological) ?: return false
|
||||
if (abandoned.isEmpty()) return false
|
||||
var killedForMemory = false
|
||||
val current = SessionPaths.current()
|
||||
val latestPreviousSession = SessionPaths.sessionFolders(context).lastOrNull { it != current }
|
||||
LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
||||
@@ -536,8 +542,10 @@ object SessionArtifacts {
|
||||
"audio.log, device.txt) were on disk already and are as they were left.\n" +
|
||||
(if (newest) "" else "Steam's logs are not included: a later session has overwritten them.\n") +
|
||||
"crash.log holds Android's crash buffer as of the next app start - if this\n" +
|
||||
"session died of a crash, the entry is in there unless the device rebooted.\n"
|
||||
"session died of a crash, the entry is in there unless the device rebooted.\n" +
|
||||
(if (newest) exitReasons(context) else "")
|
||||
)
|
||||
if (newest && lastExitForMemory(context)) killedForMemory = true
|
||||
}
|
||||
if (recoveryPreviouslyAttempted && !runtimeCaptured.exists() &&
|
||||
(runtimeExpired.exists() || !beforeGuestStart) &&
|
||||
@@ -595,7 +603,7 @@ object SessionArtifacts {
|
||||
break
|
||||
}
|
||||
SessionEvents.record("session.artifacts_recovered", mapOf("newest" to newest), dir)
|
||||
if (beforeGuestStart) return
|
||||
if (beforeGuestStart) break
|
||||
val scrubbed = scrubTree(record) { stopWhenSessionStarts && SessionState.running }
|
||||
val marked = markScrubbed(scrubbed)
|
||||
if (scrubbed.deferred) break
|
||||
@@ -606,6 +614,54 @@ object SessionArtifacts {
|
||||
Log.w(TAG, "could not finish $dir", e)
|
||||
}
|
||||
}
|
||||
// Whoever finishes the folder first (the agent provider starts before the activity) leaves
|
||||
// the notice for the launcher to show.
|
||||
if (killedForMemory) SessionPrefs.setMemoryKillNotice(context, true)
|
||||
return killedForMemory
|
||||
}
|
||||
|
||||
/** Android's newest record for this app's main process says it was killed for memory. */
|
||||
private fun lastExitForMemory(context: Context): Boolean {
|
||||
if (android.os.Build.VERSION.SDK_INT < 30) return false
|
||||
return runCatching {
|
||||
val am = context.getSystemService(android.app.ActivityManager::class.java) ?: return false
|
||||
am.getHistoricalProcessExitReasons(context.packageName, 0, 3)
|
||||
.firstOrNull { it.processName == context.packageName }
|
||||
?.reason == android.app.ApplicationExitInfo.REASON_LOW_MEMORY
|
||||
}.getOrDefault(false)
|
||||
}
|
||||
|
||||
private fun exitReasons(context: Context): String {
|
||||
if (android.os.Build.VERSION.SDK_INT < 30) return ""
|
||||
return runCatching {
|
||||
val am = context.getSystemService(android.app.ActivityManager::class.java) ?: return ""
|
||||
val reasons = am.getHistoricalProcessExitReasons(context.packageName, 0, 3)
|
||||
if (reasons.isEmpty()) return ""
|
||||
val fmt = java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss", java.util.Locale.US)
|
||||
buildString {
|
||||
append("\nAndroid's record of how this app's recent processes ended (newest first):\n")
|
||||
reasons.forEach { r ->
|
||||
append(" ${fmt.format(java.util.Date(r.timestamp))} ${r.processName} pid ${r.pid}: reason ${reasonName(r.reason)}, " +
|
||||
"status ${r.status}, importance ${r.importance}, pss ${r.pss / 1024} MB, rss ${r.rss / 1024} MB" +
|
||||
(r.description?.let { " - $it" } ?: "") + "\n")
|
||||
}
|
||||
}
|
||||
}.getOrDefault("")
|
||||
}
|
||||
|
||||
private fun reasonName(reason: Int): String = when (reason) {
|
||||
android.app.ApplicationExitInfo.REASON_LOW_MEMORY -> "LOW_MEMORY (killed for memory)"
|
||||
android.app.ApplicationExitInfo.REASON_SIGNALED -> "SIGNALED"
|
||||
android.app.ApplicationExitInfo.REASON_CRASH -> "CRASH"
|
||||
android.app.ApplicationExitInfo.REASON_CRASH_NATIVE -> "CRASH_NATIVE"
|
||||
android.app.ApplicationExitInfo.REASON_ANR -> "ANR"
|
||||
android.app.ApplicationExitInfo.REASON_EXCESSIVE_RESOURCE_USAGE -> "EXCESSIVE_RESOURCE_USAGE"
|
||||
android.app.ApplicationExitInfo.REASON_USER_REQUESTED -> "USER_REQUESTED"
|
||||
android.app.ApplicationExitInfo.REASON_USER_STOPPED -> "USER_STOPPED"
|
||||
android.app.ApplicationExitInfo.REASON_EXIT_SELF -> "EXIT_SELF"
|
||||
android.app.ApplicationExitInfo.REASON_DEPENDENCY_DIED -> "DEPENDENCY_DIED"
|
||||
android.app.ApplicationExitInfo.REASON_OTHER -> "OTHER"
|
||||
else -> reason.toString()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
||||
@@ -44,6 +44,7 @@ object SessionFiles {
|
||||
"usr/local/bin/droiddeck-msi-install" to "usr/local/bin/droiddeck-msi-install",
|
||||
"usr/local/bin/droiddeck-esync" to "usr/local/bin/droiddeck-esync",
|
||||
"usr/local/bin/droiddeck-steam-compat" to "usr/local/bin/droiddeck-steam-compat",
|
||||
"usr/local/bin/droiddeck-steam-taskset" to "usr/local/libexec/droiddeck-steam/taskset",
|
||||
"usr/local/bin/droiddeck-fex" to "usr/local/bin/droiddeck-fex",
|
||||
"libblsession.so" to "usr/local/lib/libblsession.so",
|
||||
"libfakeinput.so" to "usr/local/lib/libfakeinput.so",
|
||||
@@ -141,6 +142,8 @@ object SessionFiles {
|
||||
"usr/local/lib/mangoapp/libtraceevent.so.1",
|
||||
"usr/local/lib/mangoapp/libtracefs.so.1",
|
||||
).map { it to it }
|
||||
val xclipse = listOf("libVkLayer_droiddeck_xclipse.so", "VkLayer_droiddeck_xclipse.json")
|
||||
.map { "usr/local/lib/droiddeck-xclipse/$it" }
|
||||
val msitools = listOf("msiinfo", "cabextract", "7z", "7z.so", "libmsi-1.0.so.0", "libgsf-1.so.114", "libgcab-1.0.so.0")
|
||||
.map { "usr/local/lib/droiddeck-msitools/$it" } +
|
||||
listOf("NOTICE", "GPL-2", "GPL-3", "LGPL-2.1", "7zip-License", "7zip-unRarLicense").map { "usr/local/share/licenses/droiddeck-msitools/$it" }
|
||||
@@ -163,14 +166,26 @@ object SessionFiles {
|
||||
val fexPreloads = listOf("x86_64", "i386").flatMap { arch ->
|
||||
listOf("libblsession.so", "libfakeinput.so", "libfaultreport.so").map { "$arch/$it" to "usr/local/lib/droiddeck-fex/$arch/$it" }
|
||||
} + listOf("libvulkan-thunk.so", "libwebkitinput.so").map { "x86_64/$it" to "usr/local/lib/droiddeck-fex/x86_64/$it" }
|
||||
// The Mali compatibility layer (tools/venus/layer, David Cimo): an implicit Vulkan layer that
|
||||
// fills in the features DXVK requires and Mali lacks. Idle outside Wine and on GPUs that have them.
|
||||
// Never staged on an Adreno: an implicit layer is loaded into every Vulkan program there.
|
||||
val maliCompat = if (com.droiddeck.launcher.core.DeviceSupport.adreno()) emptyList() else listOf(
|
||||
"usr/local/lib/droiddeck-mali/libVkLayer_droiddeck_mali_compat.so",
|
||||
"usr/local/share/vulkan/implicit_layer.d/VkLayer_droiddeck_mali_compat.json",
|
||||
).map { it to it }
|
||||
val optional = (arrayOf(
|
||||
"usr/local/bin/gamescope" to "usr/local/bin/gamescope",
|
||||
// The Mali bridge's Linux side (external/MaliBridge): the ICD, its manifest and the self-test.
|
||||
"usr/local/lib/vkbridge/libvulkan_droidbridge.so" to "usr/local/lib/vkbridge/libvulkan_droidbridge.so",
|
||||
"usr/local/share/vkbridge/droidbridge_icd.json" to "usr/local/share/vkbridge/droidbridge_icd.json",
|
||||
"usr/local/bin/droiddeck-vkbridge-smoke" to "usr/local/bin/droiddeck-vkbridge-smoke",
|
||||
"usr/local/bin/droiddeck-glprobe" to "usr/local/bin/droiddeck-glprobe",
|
||||
// The gamescope pack carries its own WSI layer (patch 0117); it replaces the runtime's stock copy.
|
||||
"usr/lib/libVkLayer_FROG_gamescope_wsi_aarch64.so" to "usr/lib/libVkLayer_FROG_gamescope_wsi_aarch64.so",
|
||||
"usr/local/lib/droiddeck/uruntime" to "usr/local/lib/droiddeck/uruntime",
|
||||
"usr/local/lib/droiddeck-pipewire.tzst" to "usr/local/lib/droiddeck-pipewire.tzst",
|
||||
"usr/local/share/licenses/uruntime/LICENSE" to "usr/local/share/licenses/uruntime/LICENSE",
|
||||
) + mangoapp + msitools.map { it to it } + vr + fexPreloads).filter { (asset, _) ->
|
||||
) + mangoapp + xclipse.map { it to it } + maliCompat + listOf("comet", "GalaxyCommunication.exe", "update-permissions.exe", "LICENSE", "version").map { "usr/local/lib/droiddeck-comet/$it" to "usr/local/lib/droiddeck-comet/$it" } + msitools.map { it to it } + vr + fexPreloads).filter { (asset, _) ->
|
||||
val dir = asset.substringBeforeLast('/')
|
||||
runCatching { context.assets.list("linuxfs/$dir")?.contains(asset.substringAfterLast('/')) == true }.getOrDefault(false)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.droiddeck.launcher.core.GameEnvironment
|
||||
import com.droiddeck.launcher.core.TextureFiltering
|
||||
import com.droiddeck.launcher.gpu.Cardboard
|
||||
import com.droiddeck.launcher.gpu.ScreenEffects
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import org.json.JSONObject
|
||||
import java.io.File
|
||||
|
||||
@@ -410,6 +412,17 @@ object SessionPrefs {
|
||||
p.edit().putString("gpuDriverMode", if (chosen) GPU_DRIVERS_MANUAL else GPU_DRIVERS_AUTO).apply()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun ensurePowerVrAutoDrivers(context: Context) {
|
||||
if (com.droiddeck.launcher.core.DeviceSupport.openDriverActive(context)) return
|
||||
ensurePowerVrAutoDrivers(context, SystemVulkanDriver.isPowerVr())
|
||||
}
|
||||
|
||||
internal fun ensurePowerVrAutoDrivers(context: Context, powerVr: Boolean) {
|
||||
if (!powerVr || gpuDriverMode(context) != GPU_DRIVERS_AUTO) return
|
||||
prefs(context).edit().putString("linuxDriver", "").putString("androidDriver", TurnipDriver.AUTO).apply()
|
||||
}
|
||||
|
||||
fun gpuAutoInstalled(context: Context): Set<String> =
|
||||
prefs(context).getStringSet("gpuAutoInstalled", emptySet()).orEmpty()
|
||||
|
||||
@@ -694,6 +707,108 @@ object SessionPrefs {
|
||||
|
||||
fun zinkLazy(context: Context): Boolean = prefs(context).getBoolean("zinkLazy", true)
|
||||
|
||||
/**
|
||||
* The Mali bridge (experimental): the session's Vulkan goes through the app's bridge server to
|
||||
* the phone's own driver instead of Turnip (external/MaliBridge). Only offered, and only used, on a
|
||||
* GPU without Adreno's KGSL; off by default everywhere.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun vkBridge(context: Context): Boolean = prefs(context).getBoolean("vkBridge", false)
|
||||
|
||||
/**
|
||||
* Setup's "Mali (Venus)": the session's Vulkan through Mesa's Venus to the phone's own driver
|
||||
* (VenusComponent, David Cimo's route). Off by default; on a GPU that is not an Adreno only.
|
||||
*/
|
||||
fun venus(context: Context): Boolean = prefs(context).getBoolean("venus", false)
|
||||
|
||||
fun hostVulkanApi(context: Context): String = prefs(context).getString("hostVulkanApi", "").orEmpty()
|
||||
|
||||
fun setHostVulkanApi(context: Context, api: String) {
|
||||
if (api != hostVulkanApi(context)) prefs(context).edit().putString("hostVulkanApi", api).apply()
|
||||
}
|
||||
|
||||
/** The last session's Mali bridge self-test failed and it ran on the pair instead (Setup says so). */
|
||||
fun bridgeFellBack(context: Context): Boolean = prefs(context).getBoolean("bridgeFellBack", false)
|
||||
|
||||
fun bridgeFellBackForMemory(context: Context): Boolean = prefs(context).getString("bridgeFallbackReason", "") == "memory"
|
||||
|
||||
fun setBridgeFellBack(context: Context, on: Boolean, reason: String = "") {
|
||||
prefs(context).edit().putBoolean("bridgeFellBack", on).putString("bridgeFallbackReason", if (on) reason else "").apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup's "Steam interface: GPU drawing": with an open driver pair the Steam client composites
|
||||
* its web views in software (stale tiles on RADV/Xclipse); this turns GPU compositing back on.
|
||||
*/
|
||||
fun steamGpuCompositing(context: Context): Boolean {
|
||||
if (!steamGpuCompositingAllowed()) {
|
||||
// Never on a Mali: with PanVK it rebooted an Edge 60 (G615) twice as steamwebhelper
|
||||
// started. A value saved by the build that offered it is cleared.
|
||||
if (prefs(context).getBoolean("steamGpuCompositing", false))
|
||||
prefs(context).edit().putBoolean("steamGpuCompositing", false).apply()
|
||||
return false
|
||||
}
|
||||
return prefs(context).getBoolean("steamGpuCompositing", false)
|
||||
}
|
||||
|
||||
/** Setup offers "Steam interface: GPU drawing" on Xclipse (RADV) and other non-Mali, non-Adreno GPUs. */
|
||||
fun steamGpuCompositingAllowed(): Boolean =
|
||||
!com.droiddeck.launcher.core.DeviceSupport.adreno() && !com.droiddeck.launcher.core.DeviceSupport.mali()
|
||||
|
||||
fun setSteamGpuCompositing(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("steamGpuCompositing", on && steamGpuCompositingAllowed()).apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* The route Auto switched on for a Mali that has no open driver pair yet ("venus" or "bridge"),
|
||||
* or "" when the user's own Setup switches are in charge. Auto turns only its own choice off
|
||||
* again once a pair is installed; a Setup switch the user flips clears this.
|
||||
*/
|
||||
/** The last session's process was killed by Android for memory; the launcher says so once. */
|
||||
fun takeMemoryKillNotice(context: Context): Boolean {
|
||||
val on = prefs(context).getBoolean("memoryKillNotice", false)
|
||||
if (on) prefs(context).edit().putBoolean("memoryKillNotice", false).apply()
|
||||
return on
|
||||
}
|
||||
|
||||
fun setMemoryKillNotice(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("memoryKillNotice", on).apply()
|
||||
}
|
||||
|
||||
fun maliFallbackByAuto(context: Context): String = prefs(context).getString("maliFallbackByAuto", "").orEmpty()
|
||||
|
||||
/** Whether [maliFallbackByAuto] was ever recorded (builds before it left the bridge on without saying who). */
|
||||
fun maliFallbackKnown(context: Context): Boolean = prefs(context).contains("maliFallbackByAuto")
|
||||
|
||||
fun setMaliFallbackByAuto(context: Context, route: String) {
|
||||
prefs(context).edit().putString("maliFallbackByAuto", route).apply()
|
||||
}
|
||||
|
||||
fun setVenus(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("venus", on).apply()
|
||||
}
|
||||
|
||||
fun setVkBridge(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("vkBridge", on).putBoolean("bridgeFellBack", false).apply()
|
||||
}
|
||||
|
||||
/**
|
||||
* The Mali bridge's safe mode, on by default: the bridge keeps its proven workarounds wherever
|
||||
* its startup probe has not verified this GPU and driver. Off is performance mode (native paths
|
||||
* wherever the probe passed). Reaches the server as <cache dir>/mode (VkBridgeComponent) and
|
||||
* the guest as VKBRIDGE_MODE (SessionService).
|
||||
*/
|
||||
@JvmStatic
|
||||
fun vkBridgeSafe(context: Context): Boolean = prefs(context).getBoolean("vkBridgeSafe", true)
|
||||
|
||||
fun setVkBridgeSafe(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("vkBridgeSafe", on).apply()
|
||||
}
|
||||
|
||||
/** The bridge's mode as the server and the client read it: "safe" or "performance". */
|
||||
@JvmStatic
|
||||
fun vkBridgeMode(context: Context): String = if (vkBridgeSafe(context)) "safe" else "performance"
|
||||
|
||||
fun setZinkLazy(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("zinkLazy", on).apply()
|
||||
}
|
||||
@@ -787,6 +902,13 @@ object SessionPrefs {
|
||||
}
|
||||
}
|
||||
|
||||
fun detailedGraphicsLogs(context: Context): Boolean =
|
||||
prefs(context).getBoolean("detailedGraphicsLogs", false)
|
||||
|
||||
fun setDetailedGraphicsLogs(context: Context, on: Boolean) {
|
||||
prefs(context).edit().putBoolean("detailedGraphicsLogs", on).apply()
|
||||
}
|
||||
|
||||
fun battleNetNoSteamSet(context: Context): Boolean = prefs(context).getBoolean("battleNetNoSteamSet", false)
|
||||
fun setBattleNetNoSteamSet(context: Context) { prefs(context).edit().putBoolean("battleNetNoSteamSet", true).apply() }
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.droiddeck.launcher.session
|
||||
import com.droiddeck.launcher.core.AddonPack
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriver
|
||||
import com.droiddeck.launcher.gpu.LinuxVulkanDriverManager
|
||||
import com.droiddeck.launcher.gpu.SystemVulkanDriver
|
||||
|
||||
import android.app.Notification
|
||||
import android.app.NotificationChannel
|
||||
@@ -403,6 +404,7 @@ class SessionService : Service() {
|
||||
private fun collectSessionArtifacts(dir: File, steamArch: String?) {
|
||||
SessionLogCapture.stopFor(dir)
|
||||
try {
|
||||
GraphicsReport.finish(dir)
|
||||
SessionArtifacts.collect(this, dir, "session stopped", steamArch)
|
||||
} finally {
|
||||
SessionPaths.release(this, dir)
|
||||
@@ -422,6 +424,21 @@ class SessionService : Service() {
|
||||
return lines
|
||||
}
|
||||
|
||||
/** Whether a kernel release ("6.1.157-android14-11") is older than [major].[minor]; false if unreadable. */
|
||||
internal fun kernelBefore(release: String, major: Int, minor: Int): Boolean {
|
||||
val m = Regex("""^(\d+)\.(\d+)""").find(release) ?: return false
|
||||
val (a, b) = m.destructured
|
||||
return a.toInt() < major || (a.toInt() == major && b.toInt() < minor)
|
||||
}
|
||||
|
||||
/** Whether the newest finished session's log shows Xwayland itself crashing. */
|
||||
private fun lastXwaylandCrashed(): Boolean = runCatching {
|
||||
val last = SessionPaths.sessionFolders(this).filter { it != SessionPaths.current() }.lastOrNull() ?: return false
|
||||
val log = File(last, "session.log").takeIf { it.isFile } ?: return false
|
||||
log.useLines { lines -> lines.any { it.contains("(EE) Segmentation fault") } } &&
|
||||
log.useLines { lines -> lines.any { it.contains("X11 I/O error") || it.contains("Xwayland", ignoreCase = true) } }
|
||||
}.getOrDefault(false)
|
||||
|
||||
private fun tuDebugOverride(): String? = File(Environment.getExternalStorageDirectory(), TU_DEBUG_SWITCH)
|
||||
.takeIf { it.isFile }?.let { FileUtils.readString(it)?.trim() }?.takeIf { it.isNotEmpty() }
|
||||
|
||||
@@ -433,6 +450,13 @@ class SessionService : Service() {
|
||||
|
||||
|
||||
private fun runSession(gen: Int) {
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(this)
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
||||
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
|
||||
if (SessionPrefs.venus(this)) VenusComponent.hostVulkanTooOld(this)?.let {
|
||||
Log.w(TAG, "venus: off for this session - the phone's driver reports Vulkan $it and gamescope needs 1.2 or newer; the session uses the PanVK pair or the bridge")
|
||||
}
|
||||
}
|
||||
SessionTerminal.clear()
|
||||
com.droiddeck.launcher.gpu.TpUbwcHint.forThisDevice(this)
|
||||
try {
|
||||
@@ -474,7 +498,17 @@ class SessionService : Service() {
|
||||
val agentEnvironment = runCatching { com.droiddeck.launcher.agent.AgentEnv.beginSession(this) }
|
||||
.onFailure { Log.w(TAG, "agent environment skipped", it) }
|
||||
.getOrDefault(emptyList())
|
||||
SessionFiles.stage(this, root, startsSession = true)
|
||||
try {
|
||||
if (SystemVulkanDriver.usesDefault(SessionPrefs.linuxDriver(this))) {
|
||||
SystemVulkanDriver.prepare(this)
|
||||
pruneSystemVulkanRuntime()
|
||||
}
|
||||
SessionFiles.stage(this, root, startsSession = true)
|
||||
} catch (error: Exception) {
|
||||
Log.e(TAG, "Could not prepare the session graphics runtime", error)
|
||||
stopSession(-1)
|
||||
return
|
||||
}
|
||||
// Earlier sessions' reports still read the Steam logs and VAC marker this session replaces.
|
||||
SessionArtifacts.awaitCollections()
|
||||
SessionArtifacts.finishAbandoned(this, beforeGuestStart = true)
|
||||
@@ -516,6 +550,10 @@ class SessionService : Service() {
|
||||
val fastPathAt = guest.size
|
||||
|
||||
val pulse = startAudio(guest, sessionDir, directAudioPack)
|
||||
startVkBridge(guest, sessionDir)
|
||||
if (VenusComponent.wanted(this)) {
|
||||
components.add(VenusComponent(File(sessionDir, "venus.log")).also { it.attach(this) })
|
||||
}
|
||||
if (steamHere) {
|
||||
val encoder = VideoEncodeBridge(File(filesDir, "venc/venc.sock"))
|
||||
encoder.attach(this)
|
||||
@@ -568,6 +606,10 @@ class SessionService : Service() {
|
||||
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
|
||||
GameStorage.effective(this)?.let { guest.add("BL_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
|
||||
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("BL_STEAM_UI=desktop")
|
||||
// Detailed graphics logs: per-game logs and the guest's Vulkan summary (a GPU that is not
|
||||
// an Adreno, or Setup's switch), and graphics-report.txt for every session.
|
||||
if (GraphicsReport.detailed(this)) guest.add("BL_GAME_LOGS=1")
|
||||
GraphicsReport.begin(this, sessionDir, guest)
|
||||
val shellGuest = ArrayList(guest).apply {
|
||||
add("SHELL=/bin/bash")
|
||||
add("TERM=xterm-256color")
|
||||
@@ -771,7 +813,12 @@ class SessionService : Service() {
|
||||
guest.add("MESA_LOADER_DRIVER_OVERRIDE=zink")
|
||||
guest.add("GALLIUM_DRIVER=zink")
|
||||
guest.add("LIBGL_KOPPER_DRI2=true")
|
||||
LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
|
||||
val venus = VenusComponent.wanted(this)
|
||||
if (venus) {
|
||||
VenusComponent.guestEnv(this).forEach { guest.add(it) }
|
||||
} else {
|
||||
LinuxRuntime.vulkanIcd(this)?.let { guest.add("VK_ICD_FILENAMES=" + it.path) }
|
||||
}
|
||||
val linuxDriverId = SessionPrefs.linuxDriver(this)
|
||||
SessionState.runtimeDriver = linuxDriverId
|
||||
com.droiddeck.launcher.gpu.AutoDriverTrial.sessionStarting(
|
||||
@@ -780,11 +827,42 @@ class SessionService : Service() {
|
||||
?: SessionPrefs.androidDriver(this),
|
||||
linuxDriverId,
|
||||
)
|
||||
LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId)
|
||||
// Mali bridge (PR #517) on: the bridge ICD is the driver (startVkBridge). Otherwise the system
|
||||
// PowerVR/Xclipse path (PR #570) or the imported/runtime Turnip, as before.
|
||||
val bridge = com.droiddeck.launcher.core.DeviceSupport.vkBridge(this)
|
||||
if (!bridge && !venus && SystemVulkanDriver.usesDefault(linuxDriverId)) {
|
||||
SystemVulkanDriver.addEnvironment(this, guest)
|
||||
}
|
||||
(if (bridge || venus) null else LinuxVulkanDriver.resolveIcdPath(this, linuxDriverId))
|
||||
?.let { guest.add(LinuxVulkanDriver.ENV + "=" + it) }
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno() && lastXwaylandCrashed()) {
|
||||
guest.add("XWAYLAND_NO_GLAMOR=1")
|
||||
Log.w(TAG, "xwayland: the last session's Xwayland crashed; glamor off for this one (XWAYLAND_NO_GLAMOR=1)")
|
||||
}
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) guest.add("BL_RAISE_NOFILE=1")
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
||||
val kernel = System.getProperty("os.version").orEmpty()
|
||||
val old = kernelBefore(kernel, 6, 6)
|
||||
val maliNode = LinuxRuntime.gpuStandIn(this) == LinuxRuntime.MALI_DEVICE
|
||||
if (old || maliNode) {
|
||||
guest.add("GAMESCOPE_DISABLE_EXPLICIT_SYNC=1")
|
||||
Log.i(TAG, "gamescope: explicit sync off (" + (if (old) "kernel $kernel has no SYNCOBJ_EVENTFD" else "Mali stand-in node has no syncobjs") + ")")
|
||||
}
|
||||
}
|
||||
if (!bridge && com.droiddeck.launcher.core.DeviceSupport.openDriverActive(this)) {
|
||||
if (SessionPrefs.steamGpuCompositing(this)) {
|
||||
Log.i(TAG, "steam: GPU web compositing (Setup's \"Steam interface: GPU drawing\")")
|
||||
} else {
|
||||
guest.add("BL_STEAM_SOFT_COMPOSITING=1")
|
||||
Log.i(TAG, "steam: software web compositing for the open driver pair (GPU raster kept)")
|
||||
}
|
||||
guest.add("BL_OPEN_DRIVER=1")
|
||||
LinuxRuntime.gpuStandIn(this)?.takeIf { it == LinuxRuntime.MALI_DEVICE }?.let { guest.add("BL_DRM_STANDIN=$it") }
|
||||
}
|
||||
val tuOverride = tuDebugOverride()
|
||||
val tuDriver = sysmemDriver(linuxDriverId)
|
||||
(tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
||||
// Turnip's switch; a non-Adreno GPU runs another driver (PanVK, RADV, the bridge, Venus).
|
||||
if (!venus && com.droiddeck.launcher.core.DeviceSupport.adreno()) (tuOverride ?: "sysmem".takeIf { tuDriver || SessionPrefs.tuSysmem(this) })?.let { guest.add("TU_DEBUG=$it") }
|
||||
if (SessionPrefs.zinkLazy(this)) {
|
||||
guest.add("ZINK_DESCRIPTORS=lazy")
|
||||
guest.add("ZINK_DEBUG=compact")
|
||||
@@ -831,6 +909,32 @@ class SessionService : Service() {
|
||||
.takeIf { it.isNotEmpty() }?.let { guest.add("BL_GAME_CPUS=$it") }
|
||||
}
|
||||
|
||||
private fun startVkBridge(guest: MutableList<String>, sessionDir: File) {
|
||||
if (!com.droiddeck.launcher.core.DeviceSupport.vkBridge(this)) return
|
||||
val socket = File(filesDir, "vkbridge/server.sock")
|
||||
val bridge = com.droiddeck.launcher.gpu.VkBridgeComponent(socket, File(sessionDir, "vkbridge-server.log"))
|
||||
bridge.attach(this)
|
||||
components.add(bridge)
|
||||
com.droiddeck.launcher.gpu.ClockLogComponent(File(sessionDir, "vkbridge-clocks.log")).let {
|
||||
it.attach(this)
|
||||
components.add(it)
|
||||
}
|
||||
guest.add("BL_VKBRIDGE=1")
|
||||
if (SessionPrefs.steamGpuCompositing(this)) guest.add("BL_STEAM_GPU_COMPOSITING=1")
|
||||
SessionPrefs.linuxDriver(this).takeIf { it.isNotEmpty() }
|
||||
?.let { runCatching { LinuxVulkanDriver.resolveIcdPath(this, it) }.getOrNull() }
|
||||
?.let { guest.add("BL_VKBRIDGE_FALLBACK_ICD=$it") }
|
||||
guest.add("VKBRIDGE_SOCKET=" + socket.path)
|
||||
guest.add("VKBRIDGE_CLIENT_LOG=" + File(sessionDir, "vkbridge-client.log").path)
|
||||
// Setup's "Safe mode": the client's defaults by mode (the server reads <cache dir>/mode,
|
||||
// written by VkBridgeComponent); /root/.vkbridge-env can still override it.
|
||||
guest.add("VKBRIDGE_MODE=" + SessionPrefs.vkBridgeMode(this))
|
||||
LinuxRuntime.gpuStandIn(this)?.let { node ->
|
||||
guest.add("BL_DRM_STANDIN=$node")
|
||||
LinuxRuntime.deviceNumbers(node)?.let { guest.add("VKBRIDGE_DRM_RENDER=$it") }
|
||||
}
|
||||
Log.i(TAG, "vkbridge: on (${com.droiddeck.launcher.core.DeviceSupport.gpuName(this)}, ${SessionPrefs.vkBridgeMode(this)} mode), socket $socket")
|
||||
}
|
||||
private fun noSteamGame(): Boolean =
|
||||
SessionState.mode == MODE_RUN && SessionState.program in setOf(NoSteamLaunch.PROTON_RUN, NoSteamLaunch.EPIC, NoSteamLaunch.BATTLENET)
|
||||
|
||||
@@ -1734,6 +1838,12 @@ class SessionService : Service() {
|
||||
}.onFailure { Log.w(TAG, "could not request Steam wake", it) }
|
||||
}
|
||||
|
||||
/** Background-only: preserve old runtimes until all earlier guest processes are gone. */
|
||||
private fun pruneSystemVulkanRuntime() {
|
||||
runCatching { SystemVulkanDriver.pruneUnused(this, !OrphanReaper.hasOtherProcesses()) }
|
||||
.onFailure { Log.w(TAG, "could not prune unused system Vulkan runtimes", it) }
|
||||
}
|
||||
|
||||
private fun finishSessionStop(status: Int, stoppedGen: Int, afterStopped: () -> Unit = {}) {
|
||||
mainHandler.post {
|
||||
try {
|
||||
@@ -1860,10 +1970,12 @@ class SessionService : Service() {
|
||||
auxiliary.forEach { (pid, started) -> teardown(pid, started) }
|
||||
if (prootPid > 1) teardown(prootPid)
|
||||
killGuestLeftovers()
|
||||
pruneSystemVulkanRuntime()
|
||||
finishSessionStop(status, stoppedGen, collectEnded)
|
||||
if (launcherEnded) importLauncherGames()
|
||||
}, "session-teardown").start()
|
||||
} else {
|
||||
Thread({ pruneSystemVulkanRuntime() }, "system-vulkan-prune").start()
|
||||
Thread({
|
||||
com.droiddeck.launcher.stores.gog.GogComet.end(stoppedSession)
|
||||
finishSessionStop(status, stoppedGen, collectEnded)
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Process
|
||||
import android.util.Log
|
||||
import com.droiddeck.launcher.core.DeviceSupport
|
||||
import com.droiddeck.launcher.core.FileUtils
|
||||
import com.droiddeck.launcher.core.HostProcess
|
||||
import com.droiddeck.launcher.core.SessionPart
|
||||
import java.io.File
|
||||
import java.io.PrintWriter
|
||||
|
||||
/**
|
||||
* Vulkan for the session on a Mali, through Venus (the "Mali (Venus)" route; by David Cimo,
|
||||
* DavidCimo/droiddeck-mali, ported to this branch).
|
||||
*
|
||||
* The guest's processes are glibc and cannot load the vendor's bionic driver. Instead they load
|
||||
* Mesa's Venus ICD (libvulkan_virtio.so), which serializes every Vulkan call over a unix socket to
|
||||
* virglrenderer's vtest server. The server runs here, on the Android side, and replays the calls
|
||||
* on the device's own Vulkan driver. Both ends of the socket are under the app's files directory,
|
||||
* which the session binds at its own path, so the same path works inside and out.
|
||||
*/
|
||||
class VenusComponent(private val logFile: File?) : SessionPart() {
|
||||
@Volatile private var pid = -1
|
||||
|
||||
override fun start() {
|
||||
val context = app()
|
||||
stageIcd(context)
|
||||
val libDir = context.applicationInfo.nativeLibraryDir
|
||||
val socket = socket(context)
|
||||
socket.delete()
|
||||
val env = arrayOf(
|
||||
"LD_LIBRARY_PATH=$libDir",
|
||||
// vtest forks a render server per client; this is where its executable is.
|
||||
"RENDER_SERVER_EXEC_PATH=$libDir/libvirgl_render_server.so",
|
||||
"TMPDIR=" + context.cacheDir.path,
|
||||
)
|
||||
val command = "$libDir/libvirgl_test_server.so --venus --no-virgl --socket-path " + socket.path
|
||||
val out = logFile?.let { runCatching { PrintWriter(java.io.FileWriter(it, true)) }.getOrNull() }
|
||||
pid = HostProcess.start(command, env, context.filesDir, { status ->
|
||||
Log.w(TAG, "vtest server exited: $status")
|
||||
out?.let { synchronized(it) { it.println("vtest server exited: $status"); it.flush() } }
|
||||
}, { line ->
|
||||
Log.i(TAG, line)
|
||||
out?.let { synchronized(it) { it.println(line); it.flush() } }
|
||||
})
|
||||
Log.i(TAG, "vtest server pid $pid on $socket")
|
||||
}
|
||||
|
||||
override fun stop() {
|
||||
if (pid > 1) Process.killProcess(pid)
|
||||
pid = -1
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val TAG = "Venus"
|
||||
private const val ASSET = "venus/libvulkan_virtio.so"
|
||||
private const val DIR = "venus"
|
||||
private const val LIB = "libvulkan_virtio.so"
|
||||
private const val ICD = "virtio_icd.json"
|
||||
|
||||
/**
|
||||
* The selection rule: Venus when Setup's "Mali (Venus)" is on, on a GPU that is neither an
|
||||
* Adreno nor one the system-driver route covers (PowerVR, Xclipse), and the apk carries it.
|
||||
* It then replaces the Mali bridge and any open driver pair for the session.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun wanted(context: Context): Boolean =
|
||||
!DeviceSupport.adreno() && !com.droiddeck.launcher.gpu.SystemVulkanDriver.isAvailable() &&
|
||||
SessionPrefs.venus(context) && available(context) && hostVulkanTooOld(context) == null
|
||||
|
||||
/** The phone driver's Vulkan version when it is below 1.2: gamescope skips such a device, so Venus cannot run. */
|
||||
@JvmStatic
|
||||
fun hostVulkanTooOld(context: Context): String? {
|
||||
val api = com.droiddeck.launcher.gpu.VulkanInfo.cachedOrNull()?.get("api") ?: SessionPrefs.hostVulkanApi(context)
|
||||
val parts = api.split('.').mapNotNull { it.trim().toIntOrNull() }
|
||||
if (parts.size < 2) return null
|
||||
return api.takeIf { parts[0] < 1 || (parts[0] == 1 && parts[1] < 2) }
|
||||
}
|
||||
|
||||
/** Whether this apk carries the Venus component (tools/venus, venus.tzst). */
|
||||
@JvmStatic
|
||||
fun available(context: Context): Boolean = runCatching {
|
||||
context.assets.list(DIR)?.contains(LIB) == true &&
|
||||
File(context.applicationInfo.nativeLibraryDir, "libvirgl_test_server.so").isFile
|
||||
}.getOrDefault(false)
|
||||
|
||||
@JvmStatic
|
||||
fun socket(context: Context): File = File(File(context.filesDir, DIR), "vtest.sock")
|
||||
|
||||
/** What the guest needs to find the ICD and the server. */
|
||||
@JvmStatic
|
||||
fun guestEnv(context: Context): List<String> {
|
||||
val dir = File(context.filesDir, DIR)
|
||||
return listOf(
|
||||
"VK_ICD_FILENAMES=" + File(dir, ICD).path,
|
||||
"VN_DEBUG=vtest",
|
||||
"VTEST_SOCKET_NAME=" + socket(context).path,
|
||||
// Xwayland has no DRI3 without a DRM node, so swapchains present through shared memory.
|
||||
"MESA_VK_WSI_DEBUG=sw",
|
||||
// The Mali compatibility layer in every process but gamescope, not only Wine: Zink
|
||||
// (Steam's GL, Xwayland's glamor) requires robustness2's nullDescriptor, which the
|
||||
// layer stands in for. The session script checks it and falls back to llvmpipe.
|
||||
"DROIDDECK_MALI_COMPAT=1",
|
||||
"BL_VENUS=1",
|
||||
// gamescope's composite layout without immutable YCbCr samplers from the start
|
||||
// (patch 0930): a Mali-G615 refused every composite pipeline with them, and testing
|
||||
// that through Venus took the render server down.
|
||||
"GAMESCOPE_NO_YCBCR_SAMPLERS=1",
|
||||
)
|
||||
}
|
||||
|
||||
/** Copies the ICD out of the APK when it changed, and writes its manifest with an absolute path. */
|
||||
private fun stageIcd(context: Context) {
|
||||
val dir = File(context.filesDir, DIR).apply { mkdirs() }
|
||||
val lib = File(dir, LIB)
|
||||
// Copied again after every app update: the asset is compressed, so its size is unknown up front.
|
||||
val installed = context.packageManager.getPackageInfo(context.packageName, 0).lastUpdateTime
|
||||
if (!lib.isFile || lib.lastModified() < installed) {
|
||||
val tmp = File(dir, "$LIB.tmp")
|
||||
context.assets.open(ASSET).use { input -> tmp.outputStream().use { input.copyTo(it) } }
|
||||
if (!tmp.renameTo(lib)) Log.e(TAG, "could not move the Venus ICD into place")
|
||||
Log.i(TAG, "staged $lib (${lib.length()} bytes)")
|
||||
}
|
||||
FileUtils.writeString(
|
||||
File(dir, ICD),
|
||||
"""{"file_format_version":"1.0.1","ICD":{"library_path":"${lib.path}","api_version":"1.4.354"}}""",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -483,17 +483,27 @@ fun ComponentsPage(
|
||||
)
|
||||
else -> {
|
||||
val st = compState(l)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
if (st == null) InUseBar(false, stringResource(R.string.comp_no_proton), "")
|
||||
else {
|
||||
val reappliedAt = view?.reappliedAt?.takeIf { it > 0 }?.let { DateFormat.getTimeInstance(DateFormat.SHORT).format(Date(it * 1000)) }
|
||||
InUseBar(
|
||||
queued = st.queued != null,
|
||||
sentence = (if (st.queued != null) stringResource(R.string.comp_next_queued, st.queued) else stringResource(R.string.comp_in_use, label, st.inUse))
|
||||
.let { if (reappliedAt != null) stringResource(R.string.comp_reapplied, it, reappliedAt) else it },
|
||||
note = if (view?.inUseByGame == true) stringResource(R.string.comp_waits) else stringResource(R.string.comp_applies_next_game),
|
||||
onCancel = if (st.queued != null) onCancelQueued else null,
|
||||
)
|
||||
Column {
|
||||
InUseBar(
|
||||
queued = st.queued != null,
|
||||
sentence = (if (managedDxvk) stringResource(R.string.comp_in_use, label, stringResource(R.string.gpu_system_powervr)) +
|
||||
(st.queued?.let { "\n" + stringResource(R.string.cmgr_powervr_dxvk_queued, it) } ?: "")
|
||||
else if (st.queued != null) stringResource(R.string.comp_next_queued, st.queued) else stringResource(R.string.comp_in_use, label, st.inUse))
|
||||
.let { if (reappliedAt != null && !managedDxvk) stringResource(R.string.comp_reapplied, it, reappliedAt) else it },
|
||||
note = if (managedDxvk) "" else if (view?.inUseByGame == true) stringResource(R.string.comp_waits) else stringResource(R.string.comp_applies_next_game),
|
||||
onCancel = if (st.queued != null) onCancelQueued else null,
|
||||
maxLines = if (managedDxvk && st.queued != null) 3 else 2,
|
||||
)
|
||||
if (managedDxvk) Text(
|
||||
stringResource(R.string.cmgr_powervr_dxvk_managed),
|
||||
fontSize = 13.sp, color = colors.onSurfaceVariant, modifier = Modifier.padding(top = 8.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,16 +547,17 @@ fun ComponentsPage(
|
||||
}
|
||||
else -> {
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
val rows = installedFor(l, view, snapshot)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
val rows = installedFor(l, view, snapshot, managedDxvk)
|
||||
if (rows.isEmpty()) EmptyLine(stringResource(R.string.comp_nothing_stored, label))
|
||||
val p = view?.proton
|
||||
rows.forEachIndexed { i, item ->
|
||||
val key = "row:$l:${item.file ?: item.protonVersion}"
|
||||
ChoiceLine(
|
||||
item.name, item.detail, item.selected, item.removable, tag = item.tag,
|
||||
modifier = (if (i == 0) Modifier.focusRequester(firstRow) else Modifier).trackRow(key, rowsAt),
|
||||
item.name, item.detail, item.selected, item.removable, tag = item.tag, enabled = !managedDxvk,
|
||||
modifier = (if (i == 0 && !managedDxvk) Modifier.focusRequester(firstRow) else Modifier).trackRow(key, rowsAt),
|
||||
onSelect = {
|
||||
if (item.selected || p == null) return@ChoiceLine
|
||||
if (managedDxvk || item.selected || p == null) return@ChoiceLine
|
||||
val waits = if (view.inUseByGame) ctx.getString(R.string.comp_waits_long) else ctx.getString(R.string.comp_applies_long)
|
||||
if (item.file != null) ask(key, right, ctx.getString(R.string.comp_swap_title, label), ctx.getString(R.string.comp_swap_body, item.name, p.name, waits), ctx.getString(R.string.comp_swap), false, item.name) {
|
||||
onSwap(item.file); flyHome(key, l)
|
||||
@@ -617,14 +628,19 @@ fun ComponentsPage(
|
||||
}
|
||||
}
|
||||
else -> {
|
||||
SmallButton(stringResource(R.string.comp_import_wcp), onClick = onImport)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)
|
||||
SmallButton(
|
||||
stringResource(R.string.comp_import_wcp), onClick = onImport,
|
||||
modifier = if (managedDxvk) Modifier.focusRequester(firstRow) else Modifier,
|
||||
)
|
||||
val st = compState(l)
|
||||
val p = view?.proton
|
||||
val build = p?.let { ComponentsManager.safeName(it.version) }
|
||||
if (st != null && p != null && st.activeFile != null && view.originals.any { it.comp == l && it.protonVersion == build }) {
|
||||
val label = ComponentsManager.LABEL[l] ?: l
|
||||
Box(Modifier.trackRow("restore:$l", rowsAt)) {
|
||||
FocusText(stringResource(R.string.comp_restore_original), pal.signal) {
|
||||
if (managedDxvk) SmallButton(stringResource(R.string.comp_restore_original), enabled = false) {}
|
||||
else FocusText(stringResource(R.string.comp_restore_original), pal.signal) {
|
||||
ask("restore:$l", false, ctx.getString(R.string.comp_restore_title, label), ctx.getString(R.string.comp_restore_original_body, p.name, label), ctx.getString(R.string.common_restore), false, ctx.getString(R.string.comp_restore_original)) {
|
||||
onRestore(build!!); flyHome("restore:$l", l)
|
||||
}
|
||||
@@ -770,6 +786,7 @@ fun ComponentsPage(
|
||||
protonChoice = gameProtonChoice,
|
||||
packages = snapshot?.packages.orEmpty(),
|
||||
componentChoices = gameComponents,
|
||||
systemPowerVr = gpu.systemPowerVr,
|
||||
componentMenu = gameComponentMenu,
|
||||
protonMenu = gameProtonMenu,
|
||||
fexMenu = fexMenu,
|
||||
@@ -908,11 +925,11 @@ fun ComponentsPage(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapshot: Snapshot?): List<InstalledItem> {
|
||||
private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapshot: Snapshot?, runtimeManaged: Boolean = false): List<InstalledItem> {
|
||||
view ?: return emptyList()
|
||||
val st = view.components[l] ?: return emptyList()
|
||||
val build = ComponentsManager.safeName(view.proton.version)
|
||||
val activeIsOriginal = st.activeFile == null
|
||||
val activeIsOriginal = !runtimeManaged && st.activeFile == null
|
||||
return view.originals.filter { it.comp == l }.map { o ->
|
||||
val isCurrent = o.protonVersion == build
|
||||
InstalledItem(
|
||||
@@ -921,7 +938,7 @@ private fun installedFor(l: String, view: ComponentsManager.ProtonView?, snapsho
|
||||
"ORIGINAL", activeIsOriginal && isCurrent, !isCurrent, null, o.protonVersion,
|
||||
)
|
||||
} + (snapshot?.packages ?: emptyList()).filter { it.comp == l }.map { s ->
|
||||
InstalledItem(s.version, stringResource(R.string.common_size_mb, s.size / 1048576.0), "STORED", s.file == st.activeFile, true, s.file, null)
|
||||
InstalledItem(s.version, stringResource(R.string.common_size_mb, s.size / 1048576.0), "STORED", !runtimeManaged && s.file == st.activeFile, true, s.file, null)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -961,11 +978,12 @@ private fun Stack(
|
||||
LayerCard(
|
||||
title = LayerTitle(l),
|
||||
value = when (l) {
|
||||
GPU_TAB -> gpuCardValue(gpu, auto)
|
||||
GPU_TAB -> if (gpu.systemPowerVr) stringResource(R.string.gpu_system_powervr) else gpuCardValue(gpu, auto)
|
||||
PROTON_TAB -> (view?.proton?.name ?: "") + " ▾"
|
||||
else -> st?.let { if (it.activeFile == null) original else it.inUse } ?: ""
|
||||
else -> if (ComponentsManager.runtimeManaged(l, gpu.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else st?.let { if (it.activeFile == null) original else it.inUse } ?: ""
|
||||
},
|
||||
swapped = l in ComponentsManager.COMPONENTS && st?.activeFile != null,
|
||||
swapped = l in ComponentsManager.COMPONENTS && st?.activeFile != null && !ComponentsManager.runtimeManaged(l, gpu.systemPowerVr),
|
||||
selected = l == layer,
|
||||
landed = landed[l] ?: 0, ring = rings[l] ?: 0,
|
||||
modifier = Modifier.focusRequester(focus.getValue(l)).onGloballyPositioned { onPlaced(l, it.boundsInRoot()) },
|
||||
@@ -1032,7 +1050,7 @@ private fun LayerCard(
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel: (() -> Unit)? = null) {
|
||||
private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel: (() -> Unit)? = null, maxLines: Int = 2) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
Row(
|
||||
@@ -1041,7 +1059,7 @@ private fun InUseBar(queued: Boolean, sentence: String, note: String, onCancel:
|
||||
.border(1.dp, pal.line, RoundedCornerShape(12.dp)).padding(horizontal = 14.dp, vertical = 8.dp),
|
||||
) {
|
||||
Box(Modifier.size(8.dp).background(if (queued) QUEUED else pal.good, CircleShape))
|
||||
Text(sentence, fontSize = 14.sp, color = colors.onBackground, maxLines = 2, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
Text(sentence, fontSize = 14.sp, color = colors.onBackground, maxLines = maxLines, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
|
||||
if (onCancel != null) FocusText(stringResource(R.string.common_cancel), pal.signal, onClick = onCancel)
|
||||
else if (note.isNotEmpty() && !LocalNarrowPane.current) Text(note, fontSize = 13.sp, color = colors.onSurfaceVariant, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
}
|
||||
@@ -1076,6 +1094,7 @@ private fun GameComponentOverrides(
|
||||
protonChoice: ProtonDefault.GameChoice?,
|
||||
packages: List<ComponentsManager.Package>,
|
||||
componentChoices: Map<String, String>,
|
||||
systemPowerVr: Boolean,
|
||||
componentMenu: String?,
|
||||
protonMenu: Boolean,
|
||||
fexMenu: Boolean,
|
||||
@@ -1167,6 +1186,7 @@ private fun GameComponentOverrides(
|
||||
}
|
||||
GamePackageRow(
|
||||
comp = "dxvk",
|
||||
runtimeManaged = ComponentsManager.runtimeManaged("dxvk", systemPowerVr),
|
||||
packages = packages,
|
||||
selectedFile = componentChoices["dxvk"],
|
||||
open = componentMenu == "dxvk",
|
||||
@@ -1231,13 +1251,16 @@ private fun GamePackageRow(
|
||||
onMenu: (String?) -> Unit,
|
||||
onPick: (String, String?) -> Unit,
|
||||
onRuntimeOptions: (() -> Unit)? = null,
|
||||
runtimeManaged: Boolean = false,
|
||||
) {
|
||||
val choices = packages.filter { it.comp == comp }
|
||||
val selected = choices.firstOrNull { it.file == selectedFile }
|
||||
val title = ComponentsManager.LABEL[comp] ?: comp
|
||||
val enabled = !busy && (!runtimeManaged || selectedFile != null)
|
||||
SettingsRow(
|
||||
title,
|
||||
if (selected == null) {
|
||||
if (runtimeManaged) stringResource(R.string.cmgr_powervr_dxvk_managed)
|
||||
else if (selected == null) {
|
||||
if (proton == null) stringResource(R.string.comp_game_component_general)
|
||||
else stringResource(R.string.comp_game_component_runtime, proton.name)
|
||||
} else stringResource(R.string.comp_game_component_override, selected.version),
|
||||
@@ -1245,18 +1268,18 @@ private fun GamePackageRow(
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||
Box {
|
||||
ValueChip(
|
||||
selected?.version ?: stringResource(R.string.comp_game_use_general),
|
||||
open,
|
||||
enabled = !busy,
|
||||
if (runtimeManaged) stringResource(R.string.gpu_system_powervr) else selected?.version ?: stringResource(R.string.comp_game_use_general),
|
||||
open && enabled,
|
||||
enabled = enabled,
|
||||
modifier = Modifier.widthIn(max = 240.dp),
|
||||
) { onMenu(if (open) null else comp) }
|
||||
AnchoredMenu(open, onDismiss = { onMenu(null) }, title = title) { first ->
|
||||
AnchoredMenu(open && enabled, onDismiss = { onMenu(null) }, title = title) { first ->
|
||||
MenuItem(
|
||||
stringResource(R.string.comp_game_use_general),
|
||||
checked = selected == null,
|
||||
focusRequester = first,
|
||||
) { onPick(comp, null); onMenu(null) }
|
||||
choices.forEach { option ->
|
||||
if (!runtimeManaged) choices.forEach { option ->
|
||||
MenuItem(option.version, checked = option.file == selectedFile, detail = option.description) {
|
||||
onPick(comp, option.file)
|
||||
onMenu(null)
|
||||
@@ -1378,13 +1401,13 @@ private fun Tag(text: String) {
|
||||
@Composable
|
||||
private fun ChoiceLine(
|
||||
name: String, detail: String, selected: Boolean, removable: Boolean,
|
||||
modifier: Modifier = Modifier, tag: String? = null, badge: String? = null, progress: Int? = null,
|
||||
modifier: Modifier = Modifier, tag: String? = null, badge: String? = null, progress: Int? = null, enabled: Boolean = true,
|
||||
onSelect: () -> Unit, onDelete: () -> Unit = {},
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val src = remember { MutableInteractionSource() }
|
||||
val hot = rememberHot(src)
|
||||
val hot = rememberHot(src) && enabled
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
@@ -1394,8 +1417,8 @@ private fun ChoiceLine(
|
||||
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(12.dp),
|
||||
modifier = Modifier.weight(1f).heightIn(min = 56.dp).then(modifier)
|
||||
.glideBorder(hot, ROW_SHAPE, pal.signal)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, role = Role.RadioButton, onClick = onSelect)
|
||||
.controllerConfirm(onClick = onSelect)
|
||||
.hoverable(src).clickable(interactionSource = src, indication = null, enabled = enabled, role = Role.RadioButton, onClick = onSelect)
|
||||
.controllerConfirm(enabled = enabled, onClick = onSelect)
|
||||
.padding(start = 14.dp, end = 8.dp, top = 8.dp, bottom = 8.dp),
|
||||
) {
|
||||
Box(contentAlignment = Alignment.Center, modifier = Modifier.size(20.dp).border(2.dp, if (selected) pal.signal else colors.onSurfaceVariant, CircleShape)) {
|
||||
@@ -1405,7 +1428,7 @@ private fun ChoiceLine(
|
||||
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
Text(
|
||||
name, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, maxLines = 2, overflow = TextOverflow.Ellipsis,
|
||||
color = if (selected) pal.signal else colors.onBackground, modifier = Modifier.weight(1f, fill = false),
|
||||
color = if (!enabled) colors.onSurfaceVariant else if (selected) pal.signal else colors.onBackground, modifier = Modifier.weight(1f, fill = false),
|
||||
)
|
||||
if (tag != null) Tag(tag)
|
||||
}
|
||||
|
||||
@@ -106,6 +106,10 @@ class FrontEndState(
|
||||
val gameDebugLogsNeedsRestart: Boolean = false,
|
||||
val vacDiagnostics: Boolean = false,
|
||||
val agentCommands: Boolean = false,
|
||||
val graphicsLogs: Boolean = false,
|
||||
val steamGpuDrawing: Boolean = false,
|
||||
val bridgeFellBack: Boolean = false,
|
||||
val bridgeFellBackMemory: Boolean = false,
|
||||
val clearCachedApps: Boolean = false,
|
||||
val adbPaired: Boolean = false,
|
||||
val backgroundAppLimit: Int = -1,
|
||||
@@ -149,6 +153,15 @@ class FrontEndState(
|
||||
val oscMode: String = SessionPrefs.OSC_AUTO,
|
||||
val controller: com.droiddeck.launcher.input.ControllerPrefs.Settings? = null,
|
||||
val phantomProcessStatus: PhantomProcessStatus = PhantomProcessStatus.NOT_APPLICABLE,
|
||||
/** The GPU is an Adreno (Turnip); otherwise Setup offers the experimental Mali bridge. */
|
||||
val adreno: Boolean = true,
|
||||
/** Setup's "Mali bridge (experimental)" (SessionPrefs.vkBridge). */
|
||||
val vkBridge: Boolean = false,
|
||||
/** Setup's "Mali (Venus)" (SessionPrefs.venus). */
|
||||
val venus: Boolean = false,
|
||||
val venusHostVulkan: String? = null,
|
||||
/** Setup's "Safe mode" for the Mali bridge (SessionPrefs.vkBridgeSafe), on by default. */
|
||||
val vkBridgeSafe: Boolean = true,
|
||||
val showPhantomGate: Boolean = false,
|
||||
val orientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE,
|
||||
val launcherOrientation: Int = android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER,
|
||||
@@ -205,6 +218,9 @@ class FrontEndActions(
|
||||
val onInstallPackage: (String) -> Unit,
|
||||
val onRemovePackage: (String) -> Unit,
|
||||
val onRuntime: () -> Unit,
|
||||
val onVkBridge: (Boolean) -> Unit = {},
|
||||
val onVenus: (Boolean) -> Unit = {},
|
||||
val onVkBridgeSafe: (Boolean) -> Unit = {},
|
||||
val onFrameGenPick: (FrameGen.Mode) -> Unit,
|
||||
val onImportLossless: () -> Unit,
|
||||
val onProtons: () -> Unit,
|
||||
@@ -221,6 +237,8 @@ class FrontEndActions(
|
||||
val onGameDebugLogs: () -> Unit = {},
|
||||
val onVacDiagnostics: () -> Unit = {},
|
||||
val onAgentCommands: () -> Unit = {},
|
||||
val onGraphicsLogs: () -> Unit = {},
|
||||
val onSteamGpuDrawing: () -> Unit = {},
|
||||
val onClearCachedApps: (Boolean) -> Unit = {},
|
||||
val onMemoryHud: (String) -> Unit = {},
|
||||
val onBackgroundAppLimit: (Int) -> Unit = {},
|
||||
|
||||
@@ -233,6 +233,8 @@ internal fun SetupPanel(
|
||||
Column(modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(rememberScrollState()).padding(bottom = 24.dp)) {
|
||||
when (tab) {
|
||||
0 -> {
|
||||
// Setup's "Safe mode" row, under the GPU row while the bridge is on and can be used here.
|
||||
val bridgeModeRow = !s.adreno && s.vkBridge && com.droiddeck.launcher.core.DeviceSupport.bridgeUsable()
|
||||
val gpuCheck: @Composable (Boolean) -> Unit = { divider ->
|
||||
CheckRow(
|
||||
if (gpuOk) CheckState.OK else CheckState.WARN,
|
||||
@@ -243,10 +245,45 @@ internal fun SetupPanel(
|
||||
},
|
||||
when (gpu.support) {
|
||||
com.droiddeck.launcher.gpu.GpuInfo.Support.TESTED -> stringResource(R.string.setup_gpu_detail, gpu.displayName(ctx), gpuName)
|
||||
com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED -> stringResource(R.string.setup_gpu_untested_detail, gpu.displayName(ctx), gpu.supportText(ctx).replaceFirstChar { it.lowercase() })
|
||||
else -> stringResource(R.string.setup_gpu_unsupported_detail, gpuName)
|
||||
com.droiddeck.launcher.gpu.GpuInfo.Support.UNTESTED ->
|
||||
if (!s.adreno && s.venus && s.venusHostVulkan != null) stringResource(R.string.setup_gpu_venus_host_too_old, gpu.displayName(ctx), s.venusHostVulkan)
|
||||
else if (!s.adreno && s.vkBridge && !com.droiddeck.launcher.core.DeviceSupport.bridgeUsable()) stringResource(R.string.setup_gpu_bridge_unusable, gpu.displayName(ctx))
|
||||
else if (!s.adreno && s.vkBridge && s.bridgeFellBack) stringResource(if (s.bridgeFellBackMemory) R.string.setup_gpu_bridge_no_memory_sharing else R.string.setup_gpu_bridge_fell_back, gpu.displayName(ctx))
|
||||
else stringResource(R.string.setup_gpu_untested_detail, gpu.displayName(ctx), gpu.supportText(ctx).replaceFirstChar { it.lowercase() })
|
||||
else -> if (s.venus && s.venusHostVulkan != null) stringResource(R.string.setup_gpu_venus_host_too_old, gpuName, s.venusHostVulkan)
|
||||
else if (s.vkBridge && !com.droiddeck.launcher.core.DeviceSupport.bridgeUsable()) stringResource(R.string.setup_gpu_bridge_unusable, gpuName)
|
||||
else if (s.vkBridge && s.bridgeFellBack) stringResource(if (s.bridgeFellBackMemory) R.string.setup_gpu_bridge_no_memory_sharing else R.string.setup_gpu_bridge_fell_back, gpuName)
|
||||
else if (s.vkBridge) stringResource(R.string.setup_gpu_bridge_detail, gpuName)
|
||||
else stringResource(R.string.setup_gpu_unsupported_detail, gpuName)
|
||||
},
|
||||
divider = divider || bridgeModeRow,
|
||||
// Not an Adreno: the experimental Vulkan bridge is the one way to draw.
|
||||
action = if (s.adreno) null else { {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
SecondaryButton(
|
||||
stringResource(if (s.venus) R.string.setup_gpu_venus_on else R.string.setup_gpu_venus_off),
|
||||
enabled = !s.sessionRunning, compact = true, onClick = { a.onVenus(!s.venus) },
|
||||
)
|
||||
SecondaryButton(
|
||||
stringResource(if (s.vkBridge) R.string.setup_gpu_bridge_on else R.string.setup_gpu_bridge_off),
|
||||
enabled = !s.sessionRunning, compact = true, onClick = { a.onVkBridge(!s.vkBridge) },
|
||||
)
|
||||
}
|
||||
} },
|
||||
)
|
||||
// The bridge's mode (MaliBridge server_mode.c): safe keeps its workarounds
|
||||
// wherever the startup probe has not verified this GPU; off is faster.
|
||||
if (bridgeModeRow) CheckRow(
|
||||
CheckState.OK,
|
||||
stringResource(R.string.setup_bridge_safe),
|
||||
stringResource(if (s.vkBridgeSafe) R.string.setup_bridge_safe_on_detail else R.string.setup_bridge_safe_off_detail),
|
||||
divider = divider,
|
||||
action = {
|
||||
SecondaryButton(
|
||||
stringResource(if (s.vkBridgeSafe) R.string.setup_bridge_safe_on else R.string.setup_bridge_safe_off),
|
||||
enabled = !s.sessionRunning, compact = true, onClick = { a.onVkBridgeSafe(!s.vkBridgeSafe) },
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
val runtimeCheck: @Composable (Boolean) -> Unit = { divider ->
|
||||
@@ -503,6 +540,8 @@ internal fun SetupPanel(
|
||||
) { a.onGameDebugLogs() }
|
||||
ToggleRow(host, "vacdiag", stringResource(R.string.setup_vac_diag), stringResource(R.string.setup_vac_diag_hint), s.vacDiagnostics) { a.onVacDiagnostics() }
|
||||
ToggleRow(host, "agent-commands", stringResource(R.string.setup_agent_commands), null, s.agentCommands) { a.onAgentCommands() }
|
||||
ToggleRow(host, "graphics-logs", stringResource(R.string.setup_graphics_logs), stringResource(R.string.setup_graphics_logs_hint), s.graphicsLogs) { a.onGraphicsLogs() }
|
||||
if (!s.adreno && com.droiddeck.launcher.session.SessionPrefs.steamGpuCompositingAllowed()) ToggleRow(host, "steam-gpu-drawing", stringResource(R.string.setup_steam_gpu_drawing), stringResource(R.string.setup_steam_gpu_drawing_hint), s.steamGpuDrawing) { a.onSteamGpuDrawing() }
|
||||
ActionRow(stringResource(R.string.setup_latest_logs), stringResource(R.string.drawer_logs_hint), stringResource(R.string.drawer_share_logs), a.onShareLogs,
|
||||
progress = com.droiddeck.launcher.session.SessionLogShare.progress)
|
||||
ActionRow(stringResource(R.string.setup_saved_logs), stringResource(R.string.setup_saved_logs_hint, com.droiddeck.launcher.session.SessionPaths.KEEP_SESSIONS), stringResource(R.string.setup_clear_logs), a.onClearLogs)
|
||||
|
||||
@@ -89,6 +89,8 @@ class PairRow(
|
||||
val complete: Boolean,
|
||||
val installed: Boolean,
|
||||
val active: Boolean,
|
||||
/** A newer build of this installed pair (its build date), or null. */
|
||||
val update: String? = null,
|
||||
)
|
||||
|
||||
const val GPU_MODE_AUTO = "auto"
|
||||
@@ -110,6 +112,9 @@ class GpuDriversState(
|
||||
val supported: Boolean = true,
|
||||
val unsupported: Boolean = false,
|
||||
val auto: Boolean = true,
|
||||
val powerVr: Boolean = false,
|
||||
/** The selected runtime supplies DXVK for PowerVR game launches. */
|
||||
val systemPowerVr: Boolean = false,
|
||||
val pairs: List<PairRow> = emptyList(),
|
||||
val busy: String? = null,
|
||||
val percent: Int = -1,
|
||||
@@ -138,6 +143,7 @@ class GpuDriversState(
|
||||
class GpuDriversActions(
|
||||
val onAuto: (Boolean) -> Unit = {},
|
||||
val onPair: (String) -> Unit = {},
|
||||
val onPairUpdate: (String) -> Unit = {},
|
||||
val onRefresh: () -> Unit = {},
|
||||
val onSelectLinux: (String) -> Unit = {},
|
||||
val onSelectAndroid: (String) -> Unit = {},
|
||||
@@ -259,7 +265,7 @@ internal fun GpuDriversBody(
|
||||
modes.indices.forEach { choice(it, Modifier.weight(1f).fillMaxHeight()) }
|
||||
}
|
||||
when (gpu.mode) {
|
||||
GPU_MODE_AUTO -> AutoBody(gpu)
|
||||
GPU_MODE_AUTO -> AutoBody(gpu, actions)
|
||||
GPU_MODE_PAIR -> PairBody(gpu, actions)
|
||||
else -> MixBody(single, actions, slotFocus, onOpenSlot)
|
||||
}
|
||||
@@ -352,14 +358,26 @@ private fun RestartBanner(target: String, canRestart: Boolean, afterLater: Focus
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AutoBody(gpu: GpuDriversState) {
|
||||
private fun AutoBody(gpu: GpuDriversState, actions: GpuDriversActions) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
Column(verticalArrangement = Arrangement.spacedBy(10.dp)) {
|
||||
PanelTitle(
|
||||
stringResource(if (gpu.activePair != null) R.string.gpu_auto_title else R.string.gpu_auto_builtin_title, gpu.gpuName),
|
||||
stringResource(R.string.gpu_auto_reason, gpu.gpuFamily),
|
||||
)
|
||||
gpu.activePair?.let { p -> PanelRow(p.name, "${p.version} · ${p.detail}", selected = true, onClick = null) }
|
||||
gpu.activePair?.let { p ->
|
||||
// An open non-Adreno pair is rebuilt in place while it is tested: offer the newer build.
|
||||
PanelRow(
|
||||
p.name, "${p.version} · " + (p.update?.let { stringResource(R.string.proton_update_available, it) } ?: p.detail), selected = true,
|
||||
trailing = when {
|
||||
gpu.busy == p.key -> "${gpu.percent.coerceAtLeast(0)}%"
|
||||
p.update != null -> stringResource(R.string.common_update)
|
||||
else -> null
|
||||
},
|
||||
enabled = gpu.busy == null,
|
||||
onClick = p.update?.let { { actions.onPairUpdate(p.key) } },
|
||||
)
|
||||
}
|
||||
if (gpu.autoStatus.isNotEmpty()) Text(gpu.autoStatus, fontSize = 13.sp, color = colors.onSurfaceVariant)
|
||||
}
|
||||
}
|
||||
@@ -377,15 +395,17 @@ private fun PairBody(gpu: GpuDriversState, actions: GpuDriversActions) {
|
||||
fontSize = 13.sp, color = colors.onSurfaceVariant,
|
||||
)
|
||||
for (p in rows) PanelRow(
|
||||
p.name, "${p.version} · ${p.detail}", selected = p.active,
|
||||
p.name, "${p.version} · " + (p.update?.let { stringResource(R.string.proton_update_available, it) } ?: p.detail), selected = p.active,
|
||||
badge = if (p.recommended) stringResource(R.string.gpu_autos_pick) else null,
|
||||
trailing = when {
|
||||
gpu.busy == p.key -> "${gpu.percent.coerceAtLeast(0)}%"
|
||||
p.update != null -> stringResource(R.string.common_update)
|
||||
p.installed -> stringResource(R.string.gpu_installed)
|
||||
else -> stringResource(R.string.common_download)
|
||||
},
|
||||
enabled = gpu.busy == null,
|
||||
onClick = { if (!p.active) actions.onPair(p.key) },
|
||||
// A rebuilt open non-Adreno pair (same release, newer build) is updated in place.
|
||||
onClick = { if (p.update != null) actions.onPairUpdate(p.key) else if (!p.active) actions.onPair(p.key) },
|
||||
)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
|
||||
if (gpu.pairs.any { !it.suits }) FocusText(stringResource(if (showAll) R.string.gpu_hide_other else R.string.gpu_show_other), pal.signal) { showAll = !showAll }
|
||||
|
||||
@@ -309,6 +309,7 @@ class DrawerActions(
|
||||
val onStopFrom: ((androidx.compose.ui.geometry.Rect?) -> Unit)? = null,
|
||||
val onClose: () -> Unit,
|
||||
val components: ComponentsManager.Snapshot? = null,
|
||||
val systemPowerVr: Boolean = false,
|
||||
val onComponentsRefresh: () -> Unit = {},
|
||||
val componentCatalog: List<ComponentsManager.CatalogItem> = emptyList(),
|
||||
val componentCatalogAt: Long = 0,
|
||||
@@ -1347,7 +1348,11 @@ private fun SelectedGameProfileGroup(host: MenuHost, a: DrawerActions, track: (S
|
||||
for (component in ComponentsManager.COMPONENTS) {
|
||||
val value = profile.components.getValue(component)
|
||||
if (!value.inherited) {
|
||||
ProfileSummaryRow(ComponentsManager.LABEL.getValue(component), profileValueLabel(value))
|
||||
ProfileSummaryRow(
|
||||
ComponentsManager.LABEL.getValue(component),
|
||||
if (ComponentsManager.runtimeManaged(component, a.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else profileValueLabel(value),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (profile.startWithoutSteam) {
|
||||
@@ -1456,20 +1461,23 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
)
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
val value = gameProfile.components.getValue(comp)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(comp, a.systemPowerVr)
|
||||
val options: List<Pair<String?, String>> =
|
||||
listOf(null to stringResource(R.string.comp_game_use_general)) +
|
||||
snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
if (managedDxvk) emptyList() else snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
DrawerStackedChoice(
|
||||
host = host,
|
||||
key = "game-cmp-$comp",
|
||||
label = ComponentsManager.LABEL.getValue(comp),
|
||||
hint = if (value.inherited) {
|
||||
hint = if (managedDxvk) stringResource(R.string.cmgr_powervr_dxvk_managed) else if (value.inherited) {
|
||||
stringResource(R.string.drawer_component_inherited, value.value)
|
||||
} else {
|
||||
null
|
||||
},
|
||||
options = options,
|
||||
selected = gameProfile.componentFiles[comp],
|
||||
enabled = !managedDxvk || gameProfile.componentFiles[comp] != null,
|
||||
valueLabel = if (managedDxvk) stringResource(R.string.gpu_system_powervr) else null,
|
||||
chipModifier = track("cmp-$comp"),
|
||||
onPick = { file -> a.onGameComponent(gameProfile.appId, comp, file) },
|
||||
)
|
||||
@@ -1504,7 +1512,11 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
Row(modifier = Modifier.fillMaxWidth().padding(top = 3.dp)) {
|
||||
Text(ComponentsManager.LABEL.getValue(comp), fontSize = 12.sp, color = colors.onSurfaceVariant, modifier = Modifier.width(96.dp))
|
||||
Text(r.components.getValue(comp).inUse, fontSize = 12.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis)
|
||||
Text(
|
||||
if (ComponentsManager.runtimeManaged(comp, a.systemPowerVr)) stringResource(R.string.gpu_system_powervr)
|
||||
else r.components.getValue(comp).inUse,
|
||||
fontSize = 12.sp, color = colors.onBackground, maxLines = 1, overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1532,16 +1544,21 @@ private fun ComponentsDrawerPage(host: MenuHost, a: DrawerActions, track: (Strin
|
||||
val build = ComponentsManager.safeName(p.version)
|
||||
for (comp in ComponentsManager.COMPONENTS) {
|
||||
val st = view.components.getValue(comp)
|
||||
val managedDxvk = ComponentsManager.runtimeManaged(comp, a.systemPowerVr)
|
||||
val originals = view.originals.filter { it.comp == comp }
|
||||
val options = originals.map { "orig:${it.protonVersion}" to (if (it.protonVersion == build) originalLabel else stringResource(R.string.comp_original, it.protonVersion)) } +
|
||||
snap.packages.filter { it.comp == comp }.map { it.file to it.version }
|
||||
if (options.isEmpty()) continue
|
||||
if (options.isEmpty() && !managedDxvk) continue
|
||||
val current = st.activeFile ?: "orig:$build"
|
||||
val shown = options.firstOrNull { it.first == current }?.second
|
||||
DrawerStackedChoice(
|
||||
host, "cmp-$comp", ComponentsManager.LABEL.getValue(comp),
|
||||
st.queued?.let { stringResource(R.string.comp_next_queued, it) } ?: st.inUse.takeIf { it != shown },
|
||||
if (managedDxvk) stringResource(R.string.cmgr_powervr_dxvk_managed) +
|
||||
(st.queued?.let { "\n" + stringResource(R.string.cmgr_powervr_dxvk_queued, it) } ?: "")
|
||||
else st.queued?.let { stringResource(R.string.comp_next_queued, it) } ?: st.inUse.takeIf { it != shown },
|
||||
options, current,
|
||||
enabled = !managedDxvk,
|
||||
valueLabel = if (managedDxvk) stringResource(R.string.gpu_system_powervr) else null,
|
||||
note = if (view.inUseByGame) stringResource(R.string.comp_waits_long) else stringResource(R.string.comp_applies_long),
|
||||
chipModifier = track("cmp-$comp"),
|
||||
onPick = { v -> if (v != current || st.queued != null) a.onComponentSwap(p.id, comp, v) },
|
||||
@@ -1655,11 +1672,11 @@ internal fun ComponentDownloadsDrawerGroup(
|
||||
private fun <T> DrawerStackedChoice(
|
||||
host: MenuHost, key: String, label: String, hint: String?,
|
||||
options: List<Pair<T, String>>, selected: T, note: String? = null,
|
||||
chipModifier: Modifier = Modifier, onPick: (T) -> Unit,
|
||||
chipModifier: Modifier = Modifier, enabled: Boolean = true, valueLabel: String? = null, onPick: (T) -> Unit,
|
||||
) {
|
||||
val colors = MaterialTheme.colorScheme
|
||||
val pal = LocalPalette.current
|
||||
val open = host.open == key
|
||||
val open = host.open == key && enabled
|
||||
Column(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
.background(if (open) pal.signal.copy(alpha = 0.10f) else Color.Transparent)
|
||||
@@ -1667,7 +1684,7 @@ private fun <T> DrawerStackedChoice(
|
||||
) {
|
||||
Text(label, fontSize = 15.sp, fontWeight = FontWeight.SemiBold, color = colors.onBackground)
|
||||
Box(modifier = Modifier.fillMaxWidth().padding(top = 6.dp)) {
|
||||
ValueChip(options.firstOrNull { it.first == selected }?.second ?: "-", open, modifier = chipModifier.fillMaxWidth()) {
|
||||
ValueChip(valueLabel ?: options.firstOrNull { it.first == selected }?.second ?: "-", open, enabled = enabled, modifier = chipModifier.fillMaxWidth()) {
|
||||
host.open = if (open) null else key
|
||||
}
|
||||
AnchoredMenu(open, onDismiss = { if (host.open == key) host.open = null }, title = label, note = note) { firstItemFocus ->
|
||||
|
||||
@@ -74,6 +74,12 @@ object AppUpdates {
|
||||
val updatable: Boolean,
|
||||
val committedAt: Long = 0L,
|
||||
val ciBuild: Boolean = BuildConfig.CI_BUILD,
|
||||
/**
|
||||
* A build of the non-Adreno test branch (Mali / Xclipse / PowerVR routes). The official
|
||||
* channels carry the Adreno-only app: installing one over it drops those routes, so none is
|
||||
* offered. Its updates are published on The412Banner/droiddeck-nonadreno-drivers.
|
||||
*/
|
||||
val nonAdrenoTest: Boolean = false,
|
||||
)
|
||||
|
||||
enum class PreviewHistoryKind { CURRENT, BEHIND, RECENT }
|
||||
@@ -125,6 +131,7 @@ object AppUpdates {
|
||||
BuildConfig.VERSION_CODE,
|
||||
releaseSigned,
|
||||
BuildConfig.COMMIT_TIME,
|
||||
nonAdrenoTest = BuildConfig.BUILD_LABEL.contains("non-adreno"),
|
||||
)
|
||||
|
||||
fun release(catalog: Catalog, follow: Follow): Release? = when (follow.channel) {
|
||||
@@ -191,6 +198,7 @@ object AppUpdates {
|
||||
}
|
||||
|
||||
fun installBlock(r: Release, me: Installed = installed()): InstallBlock? = when {
|
||||
me.nonAdrenoTest -> InstallBlock(R.string.upd_block_non_adreno_test)
|
||||
r.apk == null -> InstallBlock(R.string.upd_block_no_apk)
|
||||
r.apk.versionCode < me.versionCode -> InstallBlock(R.string.upd_block_version_code, r.apk.versionCode, me.versionCode)
|
||||
else -> null
|
||||
|
||||
@@ -175,6 +175,28 @@ public final class WaylandCompositor {
|
||||
|
||||
public static native int nativeCompositorTid();
|
||||
|
||||
private static native String nativeCompositorFault();
|
||||
|
||||
private static native String nativeDisplayDriver();
|
||||
|
||||
/** Why the compositor cannot present, or "" while it can (or before the library is loaded). */
|
||||
public static String compositorFault() {
|
||||
try {
|
||||
return nativeCompositorFault();
|
||||
} catch (Throwable t) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** The driver that answered for the display, as it reports itself; "" when not known yet. */
|
||||
public static String displayDriver() {
|
||||
try {
|
||||
return nativeDisplayDriver();
|
||||
} catch (Throwable t) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public static native void nativeSetHideShell(boolean hide);
|
||||
|
||||
public static native void nativeSetOutputRefreshRate(float hz);
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU no compatible</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s: %2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam necesita un controlador Adreno; %1$s puede mostrar una pantalla negra</string>
|
||||
<string name="setup_gpu_unsupported_detail">No hay un motor gráfico compatible disponible; %1$s puede mostrar una pantalla negra</string>
|
||||
<string name="setup_runtime">Runtime de Linux</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">No instalado · unos 3 GB, se instala al jugar por primera vez</string>
|
||||
@@ -1319,8 +1319,8 @@
|
||||
<string name="main_wadb_unavailable">La Depuración inalámbrica no está disponible</string>
|
||||
<string name="main_adb_copied">Comando ADB copiado</string>
|
||||
<string name="main_pick_roms">Elige la carpeta de ROMs</string>
|
||||
<string name="main_non_adreno_title">La GPU no es Adreno</string>
|
||||
<string name="main_non_adreno_text">Turnip es compatible con GPU Adreno. En %1$s, Steam puede mostrar una pantalla negra. Descarga: %2$.0f MB.</string>
|
||||
<string name="main_non_adreno_title">GPU no compatible</string>
|
||||
<string name="main_non_adreno_text">No hay un motor gráfico compatible disponible para %1$s. Steam puede mostrar una pantalla negra. Descarga: %2$.0f MB.</string>
|
||||
<string name="main_install_anyway">Instalar de todos modos</string>
|
||||
<string name="main_remove_runtime_title">Eliminar el runtime de Linux</string>
|
||||
<string name="main_remove_runtime_text">Esto elimina el runtime, el cliente de Steam que contiene y todos los juegos instalados en él.</string>
|
||||
@@ -1942,7 +1942,7 @@
|
||||
<string name="gpuinfo_supported">Compatible</string>
|
||||
<string name="gpuinfo_experimental">Experimental: sus controladores son versiones de prueba</string>
|
||||
<string name="gpuinfo_below_tested">Por debajo del hardware probado (Adreno 725 y posteriores): puede que no funcione</string>
|
||||
<string name="gpuinfo_unsupported">No compatible: DroidDeck necesita una GPU Adreno (Snapdragon)</string>
|
||||
<string name="gpuinfo_unsupported">No compatible: no hay un motor gráfico compatible disponible para esta GPU</string>
|
||||
|
||||
<string name="turnip_rate_limited">Se alcanzó el límite de solicitudes de GitHub - inténtalo más tarde</string>
|
||||
<string name="turnip_github_http">GitHub respondió HTTP %1$d</string>
|
||||
|
||||
@@ -769,7 +769,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU non pris en charge</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s : %2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam nécessite un pilote Adreno ; %1$s peut afficher un écran noir.</string>
|
||||
<string name="setup_gpu_unsupported_detail">Aucun moteur graphique compatible n’est disponible ; %1$s peut afficher un écran noir.</string>
|
||||
<string name="setup_runtime">Environnement d\'exécution Linux</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">Non installé · Environ 3 Go, installé lors du premier lancement d\'un jeu</string>
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
<string name="setup_gpu_unsupported">GPUはサポートされていません</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s:%2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">SteamにはAdrenoドライバーが必要です。%1$sでは画面が真っ暗になる可能性があります。</string>
|
||||
<string name="setup_gpu_unsupported_detail">利用できる互換グラフィックスバックエンドがありません。%1$sでは画面が真っ暗になる可能性があります。</string>
|
||||
<string name="setup_runtime">Linux実行環境</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">未インストール · 約3GB、初回ゲーム起動時にインストール</string>
|
||||
@@ -1299,8 +1299,8 @@
|
||||
<string name="main_wadb_unavailable">ワイヤレスデバッグは利用できません</string>
|
||||
<string name="main_adb_copied">ADBコマンドをコピーしました</string>
|
||||
<string name="main_pick_roms">ROMフォルダを選択</string>
|
||||
<string name="main_non_adreno_title">Adreno GPUではありません</string>
|
||||
<string name="main_non_adreno_text">TurnipはAdreno GPUをサポートしています。%1$sでは、Steamの画面が真っ暗になる可能性があります。ダウンロード:%2$.0f MB。</string>
|
||||
<string name="main_non_adreno_title">サポート対象外のGPU</string>
|
||||
<string name="main_non_adreno_text">%1$sで利用できる互換グラフィックスバックエンドがありません。Steamの画面が真っ暗になる可能性があります。ダウンロード:%2$.0f MB。</string>
|
||||
<string name="main_install_anyway">インストールする</string>
|
||||
<string name="main_remove_runtime_title">Linux実行環境を削除</string>
|
||||
<string name="main_remove_runtime_text">実行環境、その中のSteamクライアント、そこにインストールされたすべてのゲームが削除されます。</string>
|
||||
@@ -1900,7 +1900,7 @@
|
||||
<string name="gpuinfo_supported">サポート対象</string>
|
||||
<string name="gpuinfo_experimental">実験的:ドライバーはテストビルドです</string>
|
||||
<string name="gpuinfo_below_tested">テスト済みハードウェア(Adreno 725以降)未満:動作しない可能性があります</string>
|
||||
<string name="gpuinfo_unsupported">サポート対象外:DroidDeckにはAdreno(Snapdragon)GPUが必要です</string>
|
||||
<string name="gpuinfo_unsupported">サポート対象外:このGPUで利用できる互換グラフィックスバックエンドがありません</string>
|
||||
|
||||
<string name="turnip_rate_limited">GitHubのレート制限に達しました。後でもう一度お試しください</string>
|
||||
<string name="turnip_github_http">GitHubがHTTP %1$dを返しました</string>
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU 지원되지 않음</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s: %2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam에는 Adreno 드라이버가 필요합니다. %1$s에서 화면이 검게 변할 수 있습니다.</string>
|
||||
<string name="setup_gpu_unsupported_detail">사용할 수 있는 호환 그래픽 백엔드가 없습니다. %1$s에서 화면이 검게 표시될 수 있습니다.</string>
|
||||
<string name="setup_runtime">Linux 런타임</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">설치되지 않음 · 약 3GB, 처음 \"Steam 실행\" 시 설치</string>
|
||||
@@ -1299,8 +1299,8 @@
|
||||
<string name="main_wadb_unavailable">무선 디버깅을 사용할 수 없습니다</string>
|
||||
<string name="main_adb_copied">ADB 명령이 복사되었습니다</string>
|
||||
<string name="main_pick_roms">ROM 폴더 선택</string>
|
||||
<string name="main_non_adreno_title">Adreno GPU가 아님</string>
|
||||
<string name="main_non_adreno_text">Turnip은 Adreno GPU를 지원합니다. %1$s에서는 Steam 화면이 검게 표시될 수 있습니다. 다운로드: %2$.0f MB.</string>
|
||||
<string name="main_non_adreno_title">지원되지 않는 GPU</string>
|
||||
<string name="main_non_adreno_text">%1$s에서 사용할 수 있는 호환 그래픽 백엔드가 없습니다. Steam 화면이 검게 표시될 수 있습니다. 다운로드: %2$.0f MB.</string>
|
||||
<string name="main_install_anyway">그래도 설치</string>
|
||||
<string name="main_remove_runtime_title">Linux 런타임 제거</string>
|
||||
<string name="main_remove_runtime_text">런타임과 그 안의 Steam 클라이언트, 그리고 런타임에 설치된 모든 게임이 삭제됩니다.</string>
|
||||
@@ -1900,7 +1900,7 @@
|
||||
<string name="gpuinfo_supported">지원됨</string>
|
||||
<string name="gpuinfo_experimental">실험적: 드라이버가 테스트 빌드입니다</string>
|
||||
<string name="gpuinfo_below_tested">테스트된 하드웨어(Adreno 725 이상)보다 낮음: 실행되지 않을 수 있습니다</string>
|
||||
<string name="gpuinfo_unsupported">지원되지 않음: DroidDeck에는 Adreno(Snapdragon) GPU가 필요합니다</string>
|
||||
<string name="gpuinfo_unsupported">지원되지 않음: 이 GPU에서 사용할 수 있는 호환 그래픽 백엔드가 없습니다</string>
|
||||
|
||||
<string name="turnip_rate_limited">GitHub 요청 한도에 도달했습니다. 나중에 다시 시도하세요</string>
|
||||
<string name="turnip_github_http">GitHub 응답: HTTP %1$d</string>
|
||||
|
||||
@@ -772,7 +772,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU не поддерживается</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s: %2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam требует драйвер Adreno; на %1$s возможен черный экран.</string>
|
||||
<string name="setup_gpu_unsupported_detail">Совместимый графический бэкенд недоступен; на %1$s возможен черный экран.</string>
|
||||
<string name="setup_runtime">Среда выполнения Linux</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">Не установлено · около 3 ГБ, устанавливается при первом запуске игры</string>
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU 不受支持</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s:%2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam 需要 Adreno 驱动;%1$s 可能显示黑屏</string>
|
||||
<string name="setup_gpu_unsupported_detail">没有可用的兼容图形后端;%1$s 可能显示黑屏</string>
|
||||
<string name="setup_runtime">Linux 运行时</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">未安装 · 约 3 GB,首次点“游玩”时安装</string>
|
||||
@@ -1382,8 +1382,8 @@
|
||||
<string name="main_wadb_unavailable">无线调试不可用</string>
|
||||
<string name="main_adb_copied">已复制 ADB 命令</string>
|
||||
<string name="main_pick_roms">选择 ROM 文件夹</string>
|
||||
<string name="main_non_adreno_title">不是 Adreno GPU</string>
|
||||
<string name="main_non_adreno_text">Turnip 支持 Adreno GPU。在 %1$s 上,Steam 可能显示黑屏。需下载:%2$.0f MB。</string>
|
||||
<string name="main_non_adreno_title">不受支持的 GPU</string>
|
||||
<string name="main_non_adreno_text">没有适用于 %1$s 的兼容图形后端。Steam 可能显示黑屏。需下载:%2$.0f MB。</string>
|
||||
<string name="main_install_anyway">仍要安装</string>
|
||||
<string name="main_remove_runtime_title">移除 Linux 运行时</string>
|
||||
<string name="main_remove_runtime_text">这会删除运行时、其中的 Steam 客户端,以及安装在其中的所有游戏。</string>
|
||||
@@ -1978,7 +1978,7 @@
|
||||
<string name="gpuinfo_experimental">实验性:其驱动为测试构建</string>
|
||||
<string name="gpuinfo_a850_experimental">Adreno 850 实验支持:需要配套的实验版显示驱动和游戏驱动;尚未在此设备上验证</string>
|
||||
<string name="gpuinfo_below_tested">低于已测试的硬件(Adreno 725 及更新):可能无法运行</string>
|
||||
<string name="gpuinfo_unsupported">不受支持:DroidDeck 需要 Adreno(骁龙)GPU</string>
|
||||
<string name="gpuinfo_unsupported">不受支持:没有适用于此 GPU 的兼容图形后端</string>
|
||||
|
||||
<string name="turnip_rate_limited">已达到 GitHub 的请求频率限制 — 请稍后重试</string>
|
||||
<string name="turnip_github_http">GitHub 返回 HTTP %1$d</string>
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU 不受支援</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s:%2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam 需要 Adreno 驅動程式;%1$s 可能會出現黑畫面</string>
|
||||
<string name="setup_gpu_unsupported_detail">沒有可用的兼容圖形後端;%1$s 可能會出現黑畫面</string>
|
||||
<string name="setup_runtime">Linux 運行環境</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">未安裝 · 約 3 GB,首次開啟 Steam 時安裝</string>
|
||||
@@ -1299,8 +1299,8 @@
|
||||
<string name="main_wadb_unavailable">無法使用無線偵錯</string>
|
||||
<string name="main_adb_copied">已複製 ADB 指令</string>
|
||||
<string name="main_pick_roms">選擇 ROM 資料夾</string>
|
||||
<string name="main_non_adreno_title">不是 Adreno GPU</string>
|
||||
<string name="main_non_adreno_text">Turnip 支援 Adreno GPU。在 %1$s 上,Steam 可能會出現黑畫面。下載大小:%2$.0f MB。</string>
|
||||
<string name="main_non_adreno_title">不受支援的 GPU</string>
|
||||
<string name="main_non_adreno_text">沒有適用於 %1$s 的兼容圖形後端。Steam 可能會出現黑畫面。下載大小:%2$.0f MB。</string>
|
||||
<string name="main_install_anyway">仍要安裝</string>
|
||||
<string name="main_remove_runtime_title">移除 Linux 運行環境</string>
|
||||
<string name="main_remove_runtime_text">此操作會刪除運行環境、其中的 Steam 用戶端,以及安裝在其中的所有遊戲。</string>
|
||||
@@ -1901,7 +1901,7 @@
|
||||
<string name="gpuinfo_experimental">實驗性:其驅動程式為測試版本</string>
|
||||
<string name="gpuinfo_a850_experimental">Adreno 850 實驗性支援:需要相容的實驗版顯示驅動程式及遊戲驅動程式;尚未在此裝置上驗證</string>
|
||||
<string name="gpuinfo_below_tested">低於已測試的硬件(Adreno 725 或更新):可能無法執行</string>
|
||||
<string name="gpuinfo_unsupported">不受支援:DroidDeck 需要 Adreno (Snapdragon) GPU</string>
|
||||
<string name="gpuinfo_unsupported">不受支援:沒有適用於此 GPU 的兼容圖形後端</string>
|
||||
|
||||
<string name="turnip_rate_limited">已達 GitHub 的速率限制 - 請稍後再試</string>
|
||||
<string name="turnip_github_http">GitHub 回應 HTTP %1$d</string>
|
||||
|
||||
@@ -763,7 +763,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU 不受支援</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s:%2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam 需要 Adreno 驅動程式;%1$s 可能出現黑畫面。</string>
|
||||
<string name="setup_gpu_unsupported_detail">沒有可用的相容圖形後端;%1$s 可能出現黑畫面。</string>
|
||||
<string name="setup_runtime">Linux 執行環境</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">未安裝 · 約 3 GB,首次點擊「執行」時安裝</string>
|
||||
@@ -1299,8 +1299,8 @@
|
||||
<string name="main_wadb_unavailable">無法使用無線偵錯</string>
|
||||
<string name="main_adb_copied">已複製 ADB 指令</string>
|
||||
<string name="main_pick_roms">選擇 ROM 資料夾</string>
|
||||
<string name="main_non_adreno_title">不是 Adreno GPU</string>
|
||||
<string name="main_non_adreno_text">Turnip 支援 Adreno GPU。在 %1$s 上,Steam 可能會出現黑畫面。下載大小:%2$.0f MB。</string>
|
||||
<string name="main_non_adreno_title">不受支援的 GPU</string>
|
||||
<string name="main_non_adreno_text">沒有適用於 %1$s 的相容圖形後端。Steam 可能會出現黑畫面。下載大小:%2$.0f MB。</string>
|
||||
<string name="main_install_anyway">仍要安裝</string>
|
||||
<string name="main_remove_runtime_title">移除 Linux 執行環境</string>
|
||||
<string name="main_remove_runtime_text">這會刪除執行環境、其中的 Steam 用戶端,以及安裝在其中的所有遊戲。</string>
|
||||
@@ -1901,7 +1901,7 @@
|
||||
<string name="gpuinfo_experimental">實驗性:其驅動程式為測試版本</string>
|
||||
<string name="gpuinfo_a850_experimental">Adreno 850 實驗性支援:需要相容的實驗版顯示驅動程式及遊戲驅動程式;尚未在此裝置上驗證</string>
|
||||
<string name="gpuinfo_below_tested">低於已測試的硬體(Adreno 725 及更新機型):可能無法執行</string>
|
||||
<string name="gpuinfo_unsupported">不受支援:DroidDeck 需要 Adreno(Snapdragon)GPU</string>
|
||||
<string name="gpuinfo_unsupported">不受支援:沒有適用於此 GPU 的相容圖形後端</string>
|
||||
|
||||
<string name="turnip_rate_limited">已達 GitHub 速率限制 - 請稍後再試</string>
|
||||
<string name="turnip_github_http">GitHub 回應 HTTP %1$d</string>
|
||||
|
||||
@@ -206,6 +206,7 @@
|
||||
<string name="session_proot_missing">DroidDeck\'s proot could not be downloaded. Check the connection and try again. The session was not started, because the fallback proot is too slow to play on.</string>
|
||||
<string name="session_directaudio_missing">DirectAudio could not be downloaded, so game audio uses the slower path this session.</string>
|
||||
<string name="session_end_program">This program</string>
|
||||
<string name="session_end_present_fault">The session could not draw to the screen: %1$s. This screen shows why instead of a black one; the session logs have the details.</string>
|
||||
<string name="session_end_steam_download">Couldn\'t download the Steam client. Your network or VPN may be blocking Steam\'s servers; check the connection and try again.</string>
|
||||
<string name="session_end_steam_setup">Couldn\'t set up the Steam client. Check your connection and free storage, then try again.</string>
|
||||
<string name="session_end_fex_missing">%1$s is built for x86 PCs and runs through FEX, which is not installed yet. Start Steam once while signed in and let it download FEX and the Steam Linux Runtime, then start this again.</string>
|
||||
@@ -854,7 +855,7 @@
|
||||
<string name="setup_gpu_unsupported">GPU not supported</string>
|
||||
<string name="setup_gpu_detail">%1$s · %2$s</string>
|
||||
<string name="setup_gpu_untested_detail">%1$s: %2$s</string>
|
||||
<string name="setup_gpu_unsupported_detail">Steam needs an Adreno driver; %1$s may show a black screen</string>
|
||||
<string name="setup_gpu_unsupported_detail">No compatible graphics backend is available; %1$s may show a black screen</string>
|
||||
<string name="setup_runtime">Linux runtime</string>
|
||||
<string name="setup_runtime_progress">%1$s · %2$d%%</string>
|
||||
<string name="setup_runtime_missing">Not installed · about 3 GB, installed on first Play</string>
|
||||
@@ -886,6 +887,14 @@
|
||||
<string name="setup_game_debug_logs_restart">Restart this session to save game debug logs</string>
|
||||
<string name="setup_logging_update_failed">Couldn\'t update logging. Check the switch and try again.</string>
|
||||
<string name="setup_agent_commands">Debugging tools</string>
|
||||
<string name="setup_graphics_logs">Detailed graphics logs</string>
|
||||
<string name="setup_steam_gpu_drawing">Steam interface: GPU drawing</string>
|
||||
<string name="setup_steam_gpu_drawing_hint">With the Xclipse driver pair, Steam draws its pages in software (GPU drawing showed broken tiles). Turn on for a faster Steam interface if it looks right on this phone.</string>
|
||||
<string name="drivers_built_on">built %1$s</string>
|
||||
<string name="drivers_pair_updated">%1$s updated to the newest build</string>
|
||||
<string name="setup_gpu_bridge_fell_back">The Mali bridge failed its self-test on %1$s last session (images or draws), so the session used the PanVK driver pair instead.</string>
|
||||
<string name="setup_gpu_bridge_no_memory_sharing">The Mali bridge found no way to share memory with the driver on %1$s last session, so the session used the PanVK driver pair instead. The bridge cannot work on this phone; turning it off keeps the PanVK pair.</string>
|
||||
<string name="setup_graphics_logs_hint">Each game\'s Proton, DXVK and driver logs in the session\'s logs. Always on when the GPU is not an Adreno.</string>
|
||||
<string name="setup_latest_logs">Latest session logs</string>
|
||||
<string name="setup_saved_logs">Saved session logs</string>
|
||||
<string name="setup_saved_logs_hint">Keeps the newest %1$d</string>
|
||||
@@ -1468,8 +1477,8 @@
|
||||
<string name="main_wadb_unavailable">Wireless debugging is unavailable</string>
|
||||
<string name="main_adb_copied">ADB command copied</string>
|
||||
<string name="main_pick_roms">Choose the ROMs folder</string>
|
||||
<string name="main_non_adreno_title">Not an Adreno GPU</string>
|
||||
<string name="main_non_adreno_text">Turnip supports Adreno GPUs. On %1$s, Steam may show a black screen. Download: %2$.0f MB.</string>
|
||||
<string name="main_non_adreno_title">Unsupported GPU</string>
|
||||
<string name="main_non_adreno_text">No compatible graphics backend is available for %1$s. Steam may show a black screen. Download: %2$.0f MB.</string>
|
||||
<string name="main_install_anyway">Install anyway</string>
|
||||
<string name="main_remove_runtime_title">Remove Linux runtime</string>
|
||||
<string name="main_remove_runtime_text">This deletes the runtime, the Steam client inside it, and every game installed there.</string>
|
||||
@@ -2104,11 +2113,27 @@
|
||||
<string name="look_anime_edge_desc">Toon outlines plus sharpening.</string>
|
||||
|
||||
<string name="gpuinfo_not_adreno">Not an Adreno GPU</string>
|
||||
<string name="gpuinfo_powervr">System PowerVR driver: compatibility varies by device</string>
|
||||
<string name="gpuinfo_xclipse">Experimental: RADV or the system Xclipse driver</string>
|
||||
<string name="gpu_system_powervr">System PowerVR</string>
|
||||
<string name="gpu_auto_system_hint">Uses the built-in drivers for this GPU</string>
|
||||
<string name="drivers_powervr_builtin">The system PowerVR driver is selected for the runtime and display.</string>
|
||||
<string name="drivers_mali_bridge_auto">No open driver covers this Mali yet: the Mali bridge is on.</string>
|
||||
<string name="upd_block_non_adreno_test">This is the non-Snapdragon test build: the official builds here only run on Adreno, so they are not installed over it. New test builds are on github.com/The412Banner/droiddeck-nonadreno-drivers.</string>
|
||||
<string name="session_killed_for_memory">The last session ended because Android closed DroidDeck to free memory, not a crash. Close other apps or lower the game\'s texture settings, then try again.</string>
|
||||
<string name="drivers_route_venus">Mali (Venus)</string>
|
||||
<string name="drivers_route_bridge">the Mali bridge</string>
|
||||
<string name="drivers_mali_no_pair_auto">No open driver covers this Mali yet: %1$s is used, on the phone\'s own driver.</string>
|
||||
<string name="drivers_mali_unpublished_auto">%1$s isn\'t published yet: %2$s is used until it is.</string>
|
||||
<string name="drivers_mali_old_vulkan_bridge">%1$s isn\'t available, and this phone\'s driver reports Vulkan %2$s (Venus needs 1.2): the Mali bridge is used.</string>
|
||||
<string name="drivers_mali_bridge_fallback">%1$s isn\'t published yet: the Mali bridge is on until it is.</string>
|
||||
<string name="cmgr_powervr_dxvk_queued">Queued: %1$s (waiting for a different runtime driver)</string>
|
||||
<string name="cmgr_powervr_dxvk_managed">DXVK is provided by the system PowerVR runtime. Other DXVK packages can be stored but are not applied with this driver.</string>
|
||||
<string name="gpuinfo_supported">Supported</string>
|
||||
<string name="gpuinfo_experimental">Experimental: its drivers are test builds</string>
|
||||
<string name="gpuinfo_a850_experimental">Experimental Adreno 850 support: requires compatible experimental display and game drivers; not verified on this device</string>
|
||||
<string name="gpuinfo_below_tested">Below tested hardware (Adreno 725 and newer): it may not run</string>
|
||||
<string name="gpuinfo_unsupported">Not supported: DroidDeck needs an Adreno (Snapdragon) GPU</string>
|
||||
<string name="gpuinfo_unsupported">Not supported: no compatible graphics backend is available for this GPU</string>
|
||||
|
||||
<string name="turnip_rate_limited">GitHub\'s rate limit was hit - try again later</string>
|
||||
<string name="turnip_github_http">GitHub answered HTTP %1$d</string>
|
||||
@@ -2657,6 +2682,13 @@
|
||||
<string name="gog_achievements_enable_store">Enable GOG achievements in Stores settings</string>
|
||||
<string name="gog_achievements_unavailable">Achievements unavailable; check session logs</string>
|
||||
<string name="achievement_unlocked">Achievement unlocked</string>
|
||||
<string name="setup_gpu_venus_off">Mali (Venus): off</string>
|
||||
<string name="setup_gpu_venus_on">Mali (Venus): on</string>
|
||||
<string name="setup_gpu_venus_host_too_old">The driver on %1$s reports Vulkan %2$s. Mali (Venus) needs Vulkan 1.2 or newer (gamescope does not start on older), so sessions skip Venus and use the PanVK driver pair instead.</string>
|
||||
<string name="setup_gpu_bridge_off">Mali bridge: off</string>
|
||||
<string name="setup_gpu_bridge_unusable">%1$s cannot use the Mali bridge (it needs a Mali GPU without a system-driver route), so this switch has no effect here.</string>
|
||||
<string name="setup_gpu_bridge_on">Mali bridge: on</string>
|
||||
<string name="setup_gpu_bridge_detail">%1$s is not an Adreno. The experimental Vulkan bridge is on: the session draws through the phone\'s own driver. Expect bugs; send the session logs.</string>
|
||||
<string name="touch_paste">Paste</string>
|
||||
<string name="touch_dpad">D-pad</string>
|
||||
<string name="touch_left_stick">Left stick</string>
|
||||
@@ -3325,6 +3357,11 @@
|
||||
<string name="spatial_saved_views_hint">Saved views can be recalculated. Start a new calibration to capture in the current tracking frame.</string>
|
||||
<string name="spatial_model_checksum_error">Hand model checksum mismatch</string>
|
||||
<string name="spatial_opencv_load_error">OpenCV could not load</string>
|
||||
<string name="setup_bridge_safe">Safe mode</string>
|
||||
<string name="setup_bridge_safe_on">Safe mode: on</string>
|
||||
<string name="setup_bridge_safe_off">Safe mode: off</string>
|
||||
<string name="setup_bridge_safe_on_detail">Most compatible. Recommended for a new device.</string>
|
||||
<string name="setup_bridge_safe_off_detail">Faster where this GPU passed its checks.</string>
|
||||
<string name="session_end_steam_sigill">Steam stopped with an illegal instruction (SIGILL). This can be a CPU instruction compatibility problem or a client crash. Share the logs with your device details.</string>
|
||||
<string name="session_end_steam_try_x64">You can try Steam settings → Steam client → x86-64 (experimental). It needs an additional download and may run more slowly.</string>
|
||||
<string name="session_end_vulkan_device">The Linux graphics driver could not find a usable Vulkan device. Check that the selected Linux GPU driver supports this GPU.</string>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.droiddeck.launcher.core
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class DeviceSupportTest {
|
||||
@Test fun runtimeDownloadAcceptsOnlyRecognizedGraphicsBackends() {
|
||||
assertTrue(DeviceSupport.graphicsAvailable(adreno = true, powerVrReady = false))
|
||||
assertTrue(DeviceSupport.graphicsAvailable(adreno = false, powerVrReady = true))
|
||||
// A PowerVR HAL without usable DRM access also reaches this unavailable case.
|
||||
assertFalse(DeviceSupport.graphicsAvailable(adreno = false, powerVrReady = false))
|
||||
}
|
||||
}
|
||||
@@ -69,6 +69,8 @@ class WinCompSourcesTest {
|
||||
|
||||
@Test fun steamworksSharedDepotsMapToComponents() {
|
||||
assertEquals(listOf("vcredist2015_dll" to "VC++ 2015", "d3dx9" to "DirectX (June 2010)"), WinCompSources.steamDepots(listOf("228986", "228990", "999")))
|
||||
// Hotline Miami's OpenAL depot: the DLL-copy entry, which installs without running anything.
|
||||
assertEquals(listOf("oalinst_dll" to "OpenAL"), WinCompSources.steamDepots(listOf("229020")))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Test
|
||||
|
||||
class DeviceInfoTest {
|
||||
@Test fun builtinLabelsDistinguishPowerVrFromTurnipAndGenericSystemVulkan() {
|
||||
assertEquals("System PowerVR", DeviceInfo.builtinDriverLabel(powerVr = true, runtime = true))
|
||||
assertEquals("System PowerVR", DeviceInfo.builtinDriverLabel(powerVr = true, runtime = false))
|
||||
assertEquals("the runtime's own Turnip", DeviceInfo.builtinDriverLabel(powerVr = false, runtime = true))
|
||||
assertEquals("System Vulkan", DeviceInfo.builtinDriverLabel(powerVr = false, runtime = false))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class DriverPairUpdateTest {
|
||||
private fun pair(sha: String, id: Long, updated: String, key: String = DriverPairs.nonAdreno("PanVK-Mali-G615")) =
|
||||
TurnipReleases.Asset("Non-Adreno", "panvk-mali-g615", "PanVK-Mali-G615-Pair.zip", "https://example/p", 9_000_000, false,
|
||||
"label", sha, key, bundle = true, assetId = id, updatedAt = updated)
|
||||
|
||||
@Test fun aRebuildUnderTheSameTagIsAnUpdate() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val installed = pair("a".repeat(64), 1, "2026-10-13T10:00:00Z")
|
||||
assertFalse("nothing installed yet", TurnipReleases.updateAvailable(context, installed))
|
||||
TurnipReleases.recordDownload(context, installed, "PanVK-Mali-G615")
|
||||
assertFalse(TurnipReleases.updateAvailable(context, installed))
|
||||
assertEquals("2026-10-13", TurnipReleases.installedBuiltOn(context, installed))
|
||||
assertTrue(TurnipReleases.updateAvailable(context, pair("b".repeat(64), 2, "2026-10-15T10:00:00Z")))
|
||||
assertTrue("a new asset id alone", TurnipReleases.updateAvailable(context, pair("a".repeat(64), 2, "2026-10-13T10:00:00Z")))
|
||||
assertEquals("2026-10-15", pair("b".repeat(64), 2, "2026-10-15T10:00:00Z").builtOn)
|
||||
}
|
||||
|
||||
@Test fun adrenoPairsAreNeverFlagged() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
val turnip = pair("a".repeat(64), 1, "2026-10-13T10:00:00Z", key = DriverPairs.BANNER)
|
||||
TurnipReleases.recordDownload(context, turnip, "Turnip-x")
|
||||
assertFalse(TurnipReleases.updateAvailable(context, pair("b".repeat(64), 2, "2026-10-15T10:00:00Z", key = DriverPairs.BANNER)))
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,23 @@ class DriverPairsTest {
|
||||
assertEquals(GpuInfo.Support.UNSUPPORTED, gpu(0, adreno = false).support)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun powerVrUsesItsOwnFamilyWithoutClaimingAllModelsAreTested() {
|
||||
assertEquals(Family.POWERVR, GpuInfo.familyOf(false, 0, powerVr = true))
|
||||
assertEquals(Family.NOT_ADRENO, GpuInfo.familyOf(false, 0, powerVr = false))
|
||||
assertEquals(Family.A7XX, GpuInfo.familyOf(true, 740, powerVr = true))
|
||||
val powerVr = GpuInfo("PowerVR", 0, Family.POWERVR, "", false)
|
||||
assertEquals(GpuInfo.Support.UNTESTED, powerVr.support)
|
||||
assertNull("PowerVR never downloads an Adreno driver pair", DriverPairs.recommendedKey(powerVr, emptyList()))
|
||||
val pairs = DriverPairs.from(TurnipReleases.Check(
|
||||
listOf(asset("Turnip-r4.zip", "r4", false, DriverPairs.BANNER),
|
||||
asset("Turnip-r4-Linux.zip", "r4", true, DriverPairs.BANNER)),
|
||||
emptyList(), emptyList(), 0L,
|
||||
))
|
||||
assertFalse(pairs.single().suits(powerVr))
|
||||
assertNull(DriverPairs.recommendedKey(powerVr, pairs))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun autoPicksWinNativeBalancedOn8xxAndBannersElsewhere() {
|
||||
assertEquals(DriverPairs.WN_BALANCED, DriverPairs.recommendedKey(gpu(830), emptyList()))
|
||||
@@ -113,4 +130,134 @@ class DriverPairsTest {
|
||||
assertEquals(DriverPairs.WN_BALANCED, DriverPairs.recommendedKey(gpu(825), pairs))
|
||||
assertEquals(DriverPairs.BANNER, DriverPairs.recommendedKey(gpu(740), pairs))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun maliFamiliesFollowTheOpenDriverBuilds() {
|
||||
assertEquals(Family.MALI_JM, GpuInfo.familyOf(false, 0, mali = "Mali-G57 MC2"))
|
||||
assertEquals(Family.MALI_JM, GpuInfo.familyOf(false, 0, mali = "Mali-G77"))
|
||||
assertEquals(Family.MALI_G610_G710, GpuInfo.familyOf(false, 0, mali = "Mali-G710"))
|
||||
assertEquals(Family.MALI_G615, GpuInfo.familyOf(false, 0, mali = "Mali-G615 MC6"))
|
||||
assertEquals(Family.MALI_G720, GpuInfo.familyOf(false, 0, mali = "Mali-G720-Immortalis MC12"))
|
||||
assertEquals(Family.MALI_LATEST, GpuInfo.familyOf(false, 0, mali = "Mali-G925-Immortalis MC12"))
|
||||
assertEquals(Family.MALI_OTHER, GpuInfo.familyOf(false, 0, mali = "Mali-T880"))
|
||||
assertEquals(Family.MALI_OTHER, GpuInfo.familyOf(false, 0, mali = ""))
|
||||
// An Adreno is an Adreno whatever else the device reports, and the system HAL keeps priority.
|
||||
assertEquals(Family.A7XX, GpuInfo.familyOf(true, 740, mali = "Mali-G720"))
|
||||
assertEquals(Family.POWERVR, GpuInfo.familyOf(false, 0, powerVr = true, mali = "Mali-G720"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun autoPicksTheOpenDriverForEachMaliAndNothingForTheRest() {
|
||||
fun mali(name: String) = GpuInfo(name, 0, GpuInfo.familyOf(false, 0, mali = name), "", false)
|
||||
// Android 14: the per-generation builds; the newest Malis have none and use the bridge.
|
||||
assertEquals(DriverPairs.NAD_MALI_JM, DriverPairs.recommendedKey(mali("Mali-G57"), emptyList(), sdk = 34))
|
||||
assertEquals(DriverPairs.NAD_MALI_G710, DriverPairs.recommendedKey(mali("Mali-G710"), emptyList(), sdk = 34))
|
||||
assertEquals(DriverPairs.NAD_MALI_G615, DriverPairs.recommendedKey(mali("Mali-G615"), emptyList(), sdk = 34))
|
||||
assertEquals(DriverPairs.NAD_MALI_G720, DriverPairs.recommendedKey(mali("Mali-G720"), emptyList(), sdk = 34))
|
||||
assertNull(DriverPairs.recommendedKey(mali("Mali-G925-Immortalis MC12"), emptyList(), sdk = 34))
|
||||
// Android 15+: the one-binary kbase build for every Mali it covers, not the Bifrost G52/G76.
|
||||
assertEquals(DriverPairs.NAD_MALI_KBASE, DriverPairs.recommendedKey(mali("Mali-G57"), emptyList(), sdk = 35))
|
||||
assertEquals(DriverPairs.NAD_MALI_KBASE, DriverPairs.recommendedKey(mali("Mali-G720"), emptyList(), sdk = 36))
|
||||
assertEquals(DriverPairs.NAD_MALI_KBASE, DriverPairs.recommendedKey(mali("Mali-G925-Immortalis MC12"), emptyList(), sdk = 36))
|
||||
assertEquals(DriverPairs.NAD_MALI_JM, DriverPairs.recommendedKey(mali("Mali-G52 MC2"), emptyList(), sdk = 36))
|
||||
assertNull("a Mali no build covers uses the bridge", DriverPairs.recommendedKey(mali("Mali-T880"), emptyList(), sdk = 36))
|
||||
assertEquals(DriverPairs.BANNER, DriverPairs.recommendedKey(gpu(740), emptyList()))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aMissingKbaseReleaseFallsBackToTheGenerationsPair() {
|
||||
val g720 = GpuInfo("Mali-G720", 0, Family.MALI_G720, "", false)
|
||||
fun bundle(id: String) = TurnipReleases.Asset("Non-Adreno", id.lowercase(), "$id-Pair.zip", "https://example/$id", 9_000_000,
|
||||
false, "label", "0".repeat(64), DriverPairs.nonAdreno(id), bundle = true)
|
||||
val onlyG720 = DriverPairs.from(TurnipReleases.Check(listOf(bundle("PanVK-Mali-G720")), emptyList(), emptyList(), 0L))
|
||||
assertEquals(DriverPairs.NAD_MALI_G720, DriverPairs.recommendedKey(g720, onlyG720, sdk = 36))
|
||||
val both = DriverPairs.from(TurnipReleases.Check(listOf(bundle("PanVK-Mali-G720"), bundle("PanVK-Mali-kbase")), emptyList(), emptyList(), 0L))
|
||||
assertEquals(DriverPairs.NAD_MALI_KBASE, DriverPairs.recommendedKey(g720, both, sdk = 36))
|
||||
assertTrue(both.single { it.key == DriverPairs.NAD_MALI_KBASE }.suits(g720))
|
||||
assertFalse(both.single { it.key == DriverPairs.NAD_MALI_KBASE }.suits(GpuInfo("Mali-G52", 0, Family.MALI_JM, "", false)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun nonAdrenoPairsComeFromTheirBundlesAndSuitOnlyTheirGpu() {
|
||||
val pairs = DriverPairs.from(TurnipReleases.Check(
|
||||
listOf(
|
||||
TurnipReleases.Asset("Non-Adreno", "panvk-mali-g720", "PanVK-Mali-G720-Pair.zip", "https://example/a", 9_000_000,
|
||||
false, "label", "0".repeat(64), DriverPairs.nonAdreno("PanVK-Mali-G720"), bundle = true),
|
||||
TurnipReleases.Asset("Non-Adreno", "radv-xclipse", "RADV-Xclipse-Pair.zip", "https://example/b", 9_000_000,
|
||||
false, "label", "0".repeat(64), DriverPairs.nonAdreno("RADV-Xclipse"), bundle = true),
|
||||
),
|
||||
emptyList(), emptyList(), 0L,
|
||||
))
|
||||
val g720 = pairs.single { it.key == DriverPairs.NAD_MALI_G720 }
|
||||
val radv = pairs.single { it.key == DriverPairs.NAD_RADV_XCLIPSE }
|
||||
assertTrue(g720.complete)
|
||||
assertTrue(g720.suits(GpuInfo("Mali-G720", 0, Family.MALI_G720, "", false)))
|
||||
assertFalse(g720.suits(gpu(740)))
|
||||
assertTrue(radv.suits(GpuInfo("Xclipse", 0, Family.POWERVR, "", false)))
|
||||
assertFalse("RADV is not for a PowerVR Pixel", radv.suits(GpuInfo("PowerVR", 0, Family.POWERVR, "", false)))
|
||||
assertTrue(DriverPairs.isNonAdreno("PanVK-Mali-G720"))
|
||||
assertTrue(DriverPairs.isNonAdreno("RADV-Xclipse-2"))
|
||||
assertFalse(DriverPairs.isNonAdreno("DD-Turnip-v0.1.0"))
|
||||
assertFalse(DriverPairs.isNonAdreno(null))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun upstreamRadvIsAManualXclipseChoiceAndAutoKeepsOurs() {
|
||||
val asset = { id: String -> TurnipReleases.Asset("Non-Adreno", id.lowercase(), "$id-Pair.zip", "https://example/$id", 9_000_000,
|
||||
false, "label", "0".repeat(64), DriverPairs.nonAdreno(id), bundle = true) }
|
||||
val pairs = DriverPairs.from(TurnipReleases.Check(listOf(asset("RADV-Xclipse"), asset("RADV-Xclipse-upstream")), emptyList(), emptyList(), 0L))
|
||||
val xclipse = GpuInfo("Samsung Xclipse 940", 0, Family.POWERVR, "", false)
|
||||
val upstream = pairs.single { it.key == DriverPairs.NAD_RADV_XCLIPSE_UPSTREAM }
|
||||
assertEquals("nad:radv-xclipse-upstream", DriverPairs.nonAdreno("RADV-Xclipse-upstream"))
|
||||
assertTrue(upstream.complete)
|
||||
assertTrue(upstream.suits(xclipse))
|
||||
assertFalse(upstream.suits(GpuInfo("PowerVR", 0, Family.POWERVR, "", false)))
|
||||
assertEquals("RADV upstream · Samsung Xclipse", upstream.name)
|
||||
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(xclipse, pairs))
|
||||
assertTrue(DriverPairs.isNonAdreno("RADV-Xclipse-upstream"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun deviceBuildsAreOfferedOnlyForTheirMaliAndNeverByAuto() {
|
||||
fun bundle(id: String) = TurnipReleases.Asset("Non-Adreno", id.lowercase(), "$id-Pair.zip", "https://example/$id", 9_000_000,
|
||||
false, "label", "0".repeat(64), DriverPairs.nonAdreno(id), bundle = true)
|
||||
val pairs = DriverPairs.from(TurnipReleases.Check(
|
||||
listOf(bundle("PanVK-faux123-RP4Pro"), bundle("PanVK-faux123-Ace"), bundle("PanVK-faux123-RG556")),
|
||||
emptyList(), emptyList(), 0L))
|
||||
val g77 = GpuInfo("Mali-G77 MC9", 0, Family.MALI_JM, "", false)
|
||||
val g57 = GpuInfo("Mali-G57 MC2", 0, Family.MALI_JM, "", false)
|
||||
val g610 = GpuInfo("Mali-G610 MC6", 0, Family.MALI_G610_G710, "", false)
|
||||
assertTrue(pairs.single { it.key == DriverPairs.NAD_FAUX_RP4PRO }.suits(g77))
|
||||
assertFalse(pairs.single { it.key == DriverPairs.NAD_FAUX_RP4PRO }.suits(g57))
|
||||
assertTrue(pairs.single { it.key == DriverPairs.NAD_FAUX_RG556 }.suits(g57))
|
||||
assertTrue(pairs.single { it.key == DriverPairs.NAD_FAUX_ACE }.suits(g610))
|
||||
assertEquals(DriverPairs.NAD_MALI_JM, DriverPairs.recommendedKey(g77, pairs, sdk = 34))
|
||||
assertTrue(DriverPairs.isNonAdreno("PanVK-faux123-RP4Pro"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aMaliTheDeviceDoesNotNameIsKnownByItsChip() {
|
||||
assertEquals("Mali-G720 (by chip mt6989)", GpuInfo.maliOfSoc(listOf("", "mt6989")))
|
||||
assertEquals("Mali-G710 (by chip gs201)", GpuInfo.maliOfSoc(listOf("GS201")))
|
||||
assertEquals(null, GpuInfo.maliOfSoc(listOf("unknown-chip")))
|
||||
// An Exynos with a Mali, and a Helio G99, by board name.
|
||||
assertEquals(Family.MALI_JM, GpuInfo.familyOf(false, 0, mali = GpuInfo.maliOfSoc(listOf("s5e8835"))))
|
||||
assertEquals(Family.MALI_JM, GpuInfo.familyOf(false, 0, mali = GpuInfo.maliOfSoc(listOf("MT6789"))))
|
||||
assertEquals(Family.MALI_G720, GpuInfo.familyOf(false, 0, mali = "Mali-G720 (by chip mt6989)"))
|
||||
assertEquals(Family.MALI_LATEST, GpuInfo.familyOf(false, 0, mali = "Mali-G925 (by chip mt6991)"))
|
||||
assertTrue(GpuInfo.maliKbaseCovered("Mali-G720 (by chip mt6989)"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theMaliG1SeriesHasNoPanVkPairAndIsKnownByItsChip() {
|
||||
// Arch v14 (Dimensity 9500): no PanVK build is proven there, so Auto uses the phone's own driver.
|
||||
assertEquals("Mali-G1-Ultra (by chip mt6993)", GpuInfo.maliOfSoc(listOf("MT6993")))
|
||||
assertEquals(Family.MALI_OTHER, GpuInfo.familyOf(false, 0, mali = "Mali-G1-Ultra MC12"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun autoTakesRadvOnAnXclipseAndLeavesPowerVrOnTheSystemDriver() {
|
||||
assertEquals(DriverPairs.NAD_RADV_XCLIPSE, DriverPairs.recommendedKey(GpuInfo("Samsung Xclipse 940", 0, Family.POWERVR, "", false), emptyList()))
|
||||
assertNull(DriverPairs.recommendedKey(GpuInfo("PowerVR", 0, Family.POWERVR, "", false), emptyList()))
|
||||
}
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class GpuDetectionTest {
|
||||
assertEquals("Experimental Adreno 850 support: requires compatible experimental display and game drivers; not verified on this device", info(true, 850).supportText)
|
||||
assertEquals("Experimental: its drivers are test builds", info(true, 720).supportText)
|
||||
assertEquals("Outside tested hardware (Adreno 650, 725 and newer): it may not run", info(true, 618).supportText)
|
||||
assertEquals("Not supported: DroidDeck needs an Adreno (Snapdragon) GPU", info(false, 0).supportText)
|
||||
assertEquals("Not supported: no compatible graphics backend is available for this GPU", info(false, 0).supportText)
|
||||
assertEquals("Not an Adreno GPU", Family.NOT_ADRENO.label)
|
||||
assertEquals("Adreno 8xx", Family.A8XX.label)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
|
||||
class SystemVulkanPruningTest {
|
||||
@get:Rule val temporary = TemporaryFolder()
|
||||
|
||||
@Test fun completedReplacementCollectsOnlyManagedOldDirectories() {
|
||||
val base = temporary.newFolder("system_vulkan")
|
||||
val current = completeRuntime(base, "a".repeat(64))
|
||||
val old = completeRuntime(base, "b".repeat(64))
|
||||
val stage = abandonedStage(base)
|
||||
val unrelated = File(base, "notes").apply { mkdir(); File(this, "keep").writeText("keep") }
|
||||
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
|
||||
assertEquals("current ICD", File(current, "icd.json").readText())
|
||||
assertTrue(File(current, "run-proton.py").canExecute())
|
||||
assertFalse(old.exists())
|
||||
assertFalse(stage.exists())
|
||||
assertEquals("keep", File(unrelated, "keep").readText())
|
||||
}
|
||||
|
||||
@Test fun aSurvivingGuestKeepsOldVersionsButNotAbandonedStages() {
|
||||
val base = temporary.newFolder("system_vulkan")
|
||||
val current = completeRuntime(base, "a".repeat(64))
|
||||
val old = completeRuntime(base, "b".repeat(64))
|
||||
val stage = abandonedStage(base)
|
||||
|
||||
SystemVulkanDriver.pruneUnused(current, false)
|
||||
|
||||
assertTrue(current.isDirectory)
|
||||
assertTrue(old.isDirectory)
|
||||
assertFalse(stage.exists())
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
assertFalse("collect the old version once guests stop", old.exists())
|
||||
}
|
||||
|
||||
@Test fun failedReplacementPreservesThePreviousGoodRuntime() {
|
||||
val base = temporary.newFolder("system_vulkan")
|
||||
val current = File(base, "a".repeat(64))
|
||||
val old = completeRuntime(base, "b".repeat(64))
|
||||
val stage = abandonedStage(base)
|
||||
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
assertTrue("missing replacement", old.isDirectory)
|
||||
assertFalse(stage.exists())
|
||||
|
||||
current.mkdir()
|
||||
File(current, "icd.json").writeText("incomplete")
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
assertEquals("current ICD", File(old, "icd.json").readText())
|
||||
}
|
||||
|
||||
@Test fun deletingOldRuntimeDoesNotFollowItsSymlinks() {
|
||||
val base = temporary.newFolder("system_vulkan")
|
||||
val current = completeRuntime(base, "a".repeat(64))
|
||||
val old = File(base, "b".repeat(64)).apply { mkdir() }
|
||||
val outside = temporary.newFolder("outside")
|
||||
val sentinel = File(outside, "keep").apply { writeText("keep") }
|
||||
Files.createSymbolicLink(File(old, "outside").toPath(), outside.toPath())
|
||||
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
|
||||
assertFalse(old.exists())
|
||||
assertEquals("keep", sentinel.readText())
|
||||
}
|
||||
|
||||
@Test fun linkedBaseOrCurrentRuntimePreventsCleanup() {
|
||||
val base = temporary.newFolder("system_vulkan")
|
||||
val old = completeRuntime(base, "b".repeat(64))
|
||||
val current = File(base, "a".repeat(64))
|
||||
Files.createSymbolicLink(current.toPath(), old.toPath())
|
||||
SystemVulkanDriver.pruneUnused(current, true)
|
||||
assertTrue(old.isDirectory)
|
||||
|
||||
Files.delete(current.toPath())
|
||||
completeRuntime(base, current.name)
|
||||
val alias = File(temporary.root, "alias")
|
||||
Files.createSymbolicLink(alias.toPath(), base.toPath())
|
||||
SystemVulkanDriver.pruneUnused(File(alias, current.name), true)
|
||||
assertTrue(old.isDirectory)
|
||||
}
|
||||
|
||||
private fun abandonedStage(base: File) =
|
||||
File(base, ".stage-12345678-1234-1234-1234-123456789abc").apply { mkdir(); File(this, "partial").writeText("partial") }
|
||||
|
||||
private fun completeRuntime(base: File, version: String): File {
|
||||
val directory = File(base, version).apply { mkdir() }
|
||||
val components = listOf(
|
||||
"lib/libhybris-vulkan-icd.so.0", "lib/libhybris-common.so.1", "lib/libhybris/linker/q.so",
|
||||
"lib/libVkLayer_hybris_compat.so", "run-proton.py",
|
||||
"wsi/libVkLayer_window_system_integration.so", "wsi/VkLayer_window_system_integration.json",
|
||||
) + listOf("x32", "x64").flatMap { arch ->
|
||||
listOf("d3d8", "d3d9", "d3d10core", "d3d11", "dxgi").map { "dxvk/$arch/$it.dll" }
|
||||
}
|
||||
components.forEach { path -> File(directory, path).apply { parentFile!!.mkdirs(); writeText("component") } }
|
||||
File(directory, "run-proton.py").setExecutable(true)
|
||||
File(directory, "icd.json").writeText("current ICD")
|
||||
return directory
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.droiddeck.launcher.gpu
|
||||
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Assert.assertThrows
|
||||
import org.junit.Test
|
||||
|
||||
class SystemVulkanSelectionTest {
|
||||
@Test fun defaultPowerVrUsesTheSystemBridge() {
|
||||
assertTrue(SystemVulkanDriver.usesDefault(true, ""))
|
||||
assertTrue(SystemVulkanDriver.usesDefault(true, null))
|
||||
}
|
||||
|
||||
@Test fun otherGpusAndExplicitImportsKeepTheirDriver() {
|
||||
assertFalse(SystemVulkanDriver.usesDefault(false, ""))
|
||||
assertFalse(SystemVulkanDriver.usesDefault(false, null))
|
||||
assertFalse(SystemVulkanDriver.usesDefault(true, "custom-driver"))
|
||||
}
|
||||
@Test fun renderNodeRequiresARealCharacterDeviceAndBothAccessModes() {
|
||||
assertTrue(SystemVulkanDriver.renderNodeAvailable(true, true, true))
|
||||
assertFalse("a regular placeholder is not a DRM device", SystemVulkanDriver.renderNodeAvailable(false, true, true))
|
||||
assertFalse("read access is required", SystemVulkanDriver.renderNodeAvailable(true, false, true))
|
||||
assertFalse("write access is required", SystemVulkanDriver.renderNodeAvailable(true, true, false))
|
||||
assertFalse("a missing node is unavailable", SystemVulkanDriver.renderNodeAvailable(false, false, false))
|
||||
}
|
||||
|
||||
@Test fun renderNodeDriverMustIdentifyPowerVrExactly() {
|
||||
for (name in listOf("pvrsrvkm", "pvr", "powervr"))
|
||||
assertTrue(name, SystemVulkanDriver.powerVrDriver(name))
|
||||
for (name in listOf(null, "", "msm", "panfrost", "not-pvr"))
|
||||
assertFalse(name, SystemVulkanDriver.powerVrDriver(name))
|
||||
}
|
||||
|
||||
@Test fun samsungXclipseGpuNodeIsSelectedOverItsDisplayNode() {
|
||||
assertTrue(SystemVulkanDriver.powerVrDriver("sgpu"))
|
||||
assertFalse("the display controller is not the GPU", SystemVulkanDriver.powerVrDriver("exynos-drm"))
|
||||
// Galaxy A56 (Exynos 1580): the GPU owns renderD128, the display controller renderD129.
|
||||
val drivers = mapOf("/dev/dri/renderD128" to "sgpu", "/dev/dri/renderD129" to "exynos-drm")
|
||||
assertEquals("/dev/dri/renderD128", SystemVulkanDriver.findRenderNode(null) { path ->
|
||||
SystemVulkanDriver.powerVrDriver(drivers[path])
|
||||
})
|
||||
}
|
||||
|
||||
@Test fun renderNodeIdentityUsesTheDriverLinkOrUevent() {
|
||||
val device = Files.createTempDirectory("powervr-device").toFile()
|
||||
try {
|
||||
assertFalse("missing identity is unavailable", SystemVulkanDriver.powerVrDevice(device))
|
||||
val uevent = File(device, "uevent")
|
||||
uevent.writeText("DRIVER=pvrsrvkm\nOF_NAME=gpu0\n")
|
||||
assertTrue(SystemVulkanDriver.powerVrDevice(device))
|
||||
uevent.writeText("DRIVER=msm\nOF_COMPATIBLE_0=not-pvr\n")
|
||||
assertFalse(SystemVulkanDriver.powerVrDevice(device))
|
||||
val driver = File(device, "driver").toPath()
|
||||
Files.createSymbolicLink(driver, File("../../drivers/pvrsrvkm").toPath())
|
||||
assertTrue(SystemVulkanDriver.powerVrDevice(device))
|
||||
Files.delete(driver)
|
||||
Files.createSymbolicLink(driver, File("../../drivers/msm").toPath())
|
||||
uevent.writeText("DRIVER=pvrsrvkm\n")
|
||||
assertFalse("an unrelated driver link must not fall back", SystemVulkanDriver.powerVrDevice(device))
|
||||
} finally {
|
||||
device.deleteRecursively()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun renderNodeDiscoverySkipsOtherDriversAndDeniedNodes() {
|
||||
val drivers = mapOf(
|
||||
"/dev/dri/renderD128" to "msm",
|
||||
"/dev/dri/renderD129" to "pvr",
|
||||
"/dev/dri/renderD130" to "pvrsrvkm",
|
||||
)
|
||||
assertEquals("/dev/dri/renderD129", SystemVulkanDriver.findRenderNode(null) { path ->
|
||||
SystemVulkanDriver.powerVrDriver(drivers[path])
|
||||
})
|
||||
assertEquals("/dev/dri/renderD130", SystemVulkanDriver.findRenderNode(null) { path ->
|
||||
SystemVulkanDriver.powerVrDriver(drivers[path]) &&
|
||||
SystemVulkanDriver.renderNodeAvailable(true, path != "/dev/dri/renderD129", true)
|
||||
})
|
||||
}
|
||||
|
||||
@Test fun renderNodesAreDiscoveredWithoutDirectoryListing() {
|
||||
for (minor in listOf(128, 129, 191)) {
|
||||
val expected = "/dev/dri/renderD$minor"
|
||||
assertEquals(expected, SystemVulkanDriver.findRenderNode(null) { it == expected })
|
||||
}
|
||||
assertNull(SystemVulkanDriver.findRenderNode(null) { false })
|
||||
}
|
||||
|
||||
@Test fun listedRenderNodesCoverExtendedMinorNumbers() {
|
||||
assertEquals("/dev/dri/renderD256", SystemVulkanDriver.findRenderNode(
|
||||
arrayOf("card0", "renderD256", "renderD128/device", "../renderD129"),
|
||||
) { path ->
|
||||
assertTrue(path, path.matches(Regex("/dev/dri/renderD[0-9]+")))
|
||||
path == "/dev/dri/renderD256"
|
||||
})
|
||||
}
|
||||
|
||||
@Test fun defaultPowerVrResolvesToTheSystemIcd() {
|
||||
assertEquals("system/icd.json", LinuxVulkanDriver.resolveIcdPath("", true,
|
||||
{ "system/icd.json" }, { error("default must not resolve an import") }))
|
||||
}
|
||||
|
||||
@Test fun defaultAdrenoLeavesTheRuntimeIcdUnchanged() {
|
||||
assertNull(LinuxVulkanDriver.resolveIcdPath("", false,
|
||||
{ error("Adreno must not prepare the system bridge") }, { error("default must not resolve an import") }))
|
||||
}
|
||||
|
||||
@Test fun missingManualPowerVrImportFailsWithoutSwitchingBackends() {
|
||||
val failure = assertThrows(IllegalStateException::class.java) {
|
||||
LinuxVulkanDriver.resolveIcdPath("missing-driver", true,
|
||||
{ error("manual preference must not silently switch to the system backend") }, { null })
|
||||
}
|
||||
assertTrue(failure.message!!.contains("missing-driver"))
|
||||
assertTrue(failure.message!!.contains("use Auto"))
|
||||
}
|
||||
|
||||
@Test fun missingAdrenoImportKeepsTheExistingRuntimeFallback() {
|
||||
assertNull(LinuxVulkanDriver.resolveIcdPath("missing-driver", false,
|
||||
{ error("Adreno must not prepare the system bridge") }, { null }))
|
||||
}
|
||||
|
||||
@Test fun manualPowerVrResolvesTheChosenImport() {
|
||||
assertEquals("imports/chosen/icd.json", LinuxVulkanDriver.resolveIcdPath("chosen", true,
|
||||
{ error("manual must not prepare the system bridge") }, { "imports/$it/icd.json" }))
|
||||
}
|
||||
}
|
||||
@@ -142,6 +142,34 @@ class ForcedPackageTest {
|
||||
assertDefaultDxvkRestoreRow(protonName)
|
||||
}
|
||||
|
||||
@Test fun systemPowerVrRejectsNewGameDxvkSelectionsWithoutChangingSavedProfiles() {
|
||||
writeGameProfile("42", "dxvk", "custom-dxvk.wcp")
|
||||
val state = File(context.filesDir, "components/state.json")
|
||||
val saved = state.readText()
|
||||
|
||||
assertThrows(IllegalStateException::class.java) {
|
||||
ComponentsManager.setGameComponent(context, "42", "dxvk", "replacement.wcp") {
|
||||
ComponentsManager.runtimeManaged(it, true)
|
||||
}
|
||||
}
|
||||
|
||||
assertEquals(saved, state.readText())
|
||||
assertEquals("custom-dxvk.wcp", ComponentsManager.gameComponents(context, "42")["dxvk"])
|
||||
assertFalse(launchState().exists())
|
||||
}
|
||||
|
||||
@Test fun systemPowerVrAllowsClearingASavedGameDxvkSelection() {
|
||||
proton("proton-exp")
|
||||
writeGameProfile("42", "dxvk", "custom-dxvk.wcp")
|
||||
|
||||
ComponentsManager.setGameComponent(context, "42", "dxvk", null) {
|
||||
ComponentsManager.runtimeManaged(it, true)
|
||||
}
|
||||
|
||||
assertTrue(ComponentsManager.gameComponents(context, "42").isEmpty())
|
||||
assertDefaultDxvkRestoreRow("proton-exp")
|
||||
}
|
||||
|
||||
@Test fun aNewProtonIsCapturedWhenTheLastOverrideIsReset() {
|
||||
proton("existing")
|
||||
writeGameProfile("42", "dxvk", "custom-dxvk.wcp")
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.rules.TemporaryFolder
|
||||
import java.io.File
|
||||
|
||||
class GraphicsReportTest {
|
||||
@get:Rule val tmp = TemporaryFolder()
|
||||
|
||||
@Test fun deviceNumbersSplitAsLinuxDoes() {
|
||||
// /dev/mali0 on the testers' phones: 10:103 (misc); a DRM render node: 226:128.
|
||||
assertEquals(10L, GraphicsReport.major(10L shl 8 or 103L))
|
||||
assertEquals(103L, GraphicsReport.minor(10L shl 8 or 103L))
|
||||
assertEquals(226L, GraphicsReport.major(226L shl 8 or 128L))
|
||||
assertEquals(128L, GraphicsReport.minor(226L shl 8 or 128L))
|
||||
}
|
||||
|
||||
@Test fun gameLogsAreCutPerFileAndOldestLaunchesGoFirst() {
|
||||
val games = tmp.newFolder("games")
|
||||
fun launch(name: String, bytes: Int) = File(games, name).apply { mkdirs() }.also { File(it, "steam-1.log").writeBytes(ByteArray(bytes)) }
|
||||
val old = launch("20261012-100000-1", 60)
|
||||
val mid = launch("20261012-110000-2", 60)
|
||||
val new = launch("20261012-120000-3", 200)
|
||||
GraphicsReport.capGames(games, fileMax = 100, totalMax = 170)
|
||||
assertEquals(100L, File(new, "steam-1.log").length())
|
||||
assertFalse(old.exists())
|
||||
assertTrue(mid.exists())
|
||||
assertTrue(new.exists())
|
||||
}
|
||||
|
||||
@Test fun aMissingGamesFolderIsFine() {
|
||||
GraphicsReport.capGames(File(tmp.root, "none"))
|
||||
GraphicsReport.finish(tmp.newFolder("session"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class OrphanReaperProcessTest {
|
||||
@Test fun unavailableProcessListDefersCleanup() {
|
||||
assertTrue(OrphanReaper.hasOtherProcesses(null, 100) { false })
|
||||
}
|
||||
|
||||
@Test fun theAppAndForeignProcessesDoNotKeepOldRuntimes() {
|
||||
assertFalse(OrphanReaper.hasOtherProcesses(listOf(0, 1, 100, 200), 100) { pid ->
|
||||
check(pid == 200) { "do not probe self or process groups" }
|
||||
false
|
||||
})
|
||||
}
|
||||
|
||||
@Test fun anyRemainingAppProcessDefersCleanup() {
|
||||
assertTrue(OrphanReaper.hasOtherProcesses(listOf(100, 200, 300), 100) { it == 300 })
|
||||
assertFalse(OrphanReaper.hasOtherProcesses(emptyList(), 100) { true })
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import com.droiddeck.launcher.gpu.TurnipDriver
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class PowerVrAutoDriversTest {
|
||||
private val context: Context = RuntimeEnvironment.getApplication()
|
||||
|
||||
@Before fun reset() {
|
||||
context.getSharedPreferences("session", Context.MODE_PRIVATE).edit().clear().commit()
|
||||
SessionPrefs.setLinuxDriver(context, "imported-linux")
|
||||
SessionPrefs.setAndroidDriver(context, "imported-display")
|
||||
}
|
||||
|
||||
@Test fun autoRepairsStaleAdrenoSelectionsOnPowerVr() {
|
||||
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true)
|
||||
assertEquals("", SessionPrefs.linuxDriver(context))
|
||||
assertEquals(TurnipDriver.AUTO, SessionPrefs.androidDriver(context))
|
||||
}
|
||||
|
||||
@Test fun explicitManualChoicesRemainOnPowerVr() {
|
||||
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_MANUAL)
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = true)
|
||||
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
|
||||
assertEquals("imported-display", SessionPrefs.androidDriver(context))
|
||||
}
|
||||
|
||||
@Test fun adrenoAutoChoicesRemain() {
|
||||
SessionPrefs.setGpuDriverMode(context, SessionPrefs.GPU_DRIVERS_AUTO)
|
||||
SessionPrefs.ensurePowerVrAutoDrivers(context, powerVr = false)
|
||||
assertEquals("imported-linux", SessionPrefs.linuxDriver(context))
|
||||
assertEquals("imported-display", SessionPrefs.androidDriver(context))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class PowerVrComponentsTest {
|
||||
@Test fun onlyDxvkIsManagedWithTheSystemPowerVrRuntime() {
|
||||
assertTrue(ComponentsManager.runtimeManaged("dxvk", systemPowerVr = true))
|
||||
assertFalse(ComponentsManager.runtimeManaged("dxvk", systemPowerVr = false))
|
||||
assertFalse(ComponentsManager.runtimeManaged("fex", systemPowerVr = true))
|
||||
assertFalse(ComponentsManager.runtimeManaged("vkd3d", systemPowerVr = true))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.droiddeck.launcher.session
|
||||
|
||||
import android.content.Context
|
||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||
import org.json.JSONObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], manifest = Config.NONE)
|
||||
class PowerVrQueuedComponentsTest {
|
||||
@Test fun managedDxvkQueueRemainsVisibleAndCanBeCancelled() {
|
||||
val context: Context = RuntimeEnvironment.getApplication()
|
||||
val root = LinuxRuntime.rootDir(context)
|
||||
root.deleteRecursively()
|
||||
val data = File(context.filesDir, "components")
|
||||
data.deleteRecursively()
|
||||
data.mkdirs()
|
||||
val proton = File(root, "root/.local/share/Steam/compatibilitytools.d/test-proton")
|
||||
File(proton, "files/lib/wine").mkdirs()
|
||||
File(proton, "proton").writeText("# test Proton\n")
|
||||
File(proton, "version").writeText("1 test-build\n")
|
||||
File(data, "state.json").writeText(JSONObject().put("queued", JSONObject().put("test-proton",
|
||||
JSONObject().put("dxvk", JSONObject().put("kind", "package").put("file", "chosen.wcp").put("label", "chosen DXVK"))
|
||||
)).toString())
|
||||
|
||||
assertTrue(ComponentsManager.applyQueued(context) { ComponentsManager.runtimeManaged(it, true) }.isEmpty())
|
||||
val deferred = ComponentsManager.snapshot(context).protons.single().components.getValue("dxvk")
|
||||
assertEquals("chosen DXVK", deferred.queued)
|
||||
|
||||
ComponentsManager.cancelQueued(context, "test-proton", "dxvk")
|
||||
assertNull(ComponentsManager.snapshot(context).protons.single().components.getValue("dxvk").queued)
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,24 @@
|
||||
package com.droiddeck.launcher.ui
|
||||
|
||||
import android.app.Application
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.semantics.SemanticsProperties
|
||||
import androidx.compose.ui.test.SemanticsMatcher
|
||||
import androidx.compose.ui.test.assertCountEquals
|
||||
import androidx.compose.ui.test.assertIsEnabled
|
||||
import androidx.compose.ui.test.assertIsNotEnabled
|
||||
import androidx.compose.ui.test.hasText
|
||||
import androidx.compose.ui.test.onAllNodesWithText
|
||||
import androidx.compose.ui.test.onLast
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
import com.droiddeck.launcher.R
|
||||
import com.droiddeck.launcher.frontend.Library
|
||||
import com.droiddeck.launcher.session.ComponentsManager
|
||||
import java.io.File
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
@@ -12,8 +26,9 @@ import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
// Exercise the component UI without starting App's process-wide servers or crash handler.
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28])
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class ComponentsPageProfileTest {
|
||||
@get:Rule val compose = createRobolectricComposeRule()
|
||||
private val gameA = Library.SteamGame(42, "Game A", null, "internal")
|
||||
@@ -98,4 +113,143 @@ class ComponentsPageProfileTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w1280dp-h1000dp")
|
||||
fun systemPowerVrKeepsStoredDxvkDisabledAndQueuedDxvkCancellable() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
var cancelled = 0
|
||||
var imported = 0
|
||||
var swapped = 0
|
||||
var restored = 0
|
||||
showDxvk(
|
||||
systemPowerVr = true,
|
||||
onCancel = { cancelled++ },
|
||||
onImport = { imported++ },
|
||||
onSwap = { swapped++ },
|
||||
onRestore = { restored++ },
|
||||
)
|
||||
|
||||
compose.onNodeWithText(context.getString(R.string.cmgr_powervr_dxvk_managed)).assertExists()
|
||||
compose.onNodeWithText(context.getString(R.string.cmgr_powervr_dxvk_queued, "Next DXVK"), substring = true).assertExists()
|
||||
compose.onNodeWithText("Stored DXVK").assertIsNotEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_original, "1.0")).assertIsNotEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_restore_original)).assertIsNotEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.common_cancel)).performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_import_wcp)).performScrollTo().assertIsEnabled().performClick()
|
||||
compose.runOnIdle {
|
||||
assertEquals(1, cancelled)
|
||||
assertEquals(1, imported)
|
||||
assertEquals(0, swapped)
|
||||
assertEquals(0, restored)
|
||||
}
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w1280dp-h1000dp")
|
||||
fun manualRuntimeKeepsDxvkSelectionAvailable() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
showDxvk(systemPowerVr = false)
|
||||
|
||||
compose.onNode(hasText("Stored DXVK") and SemanticsMatcher.expectValue(SemanticsProperties.Role, Role.RadioButton)).assertIsEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_original, "1.0")).assertIsEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_restore_original)).assertIsEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.cmgr_powervr_dxvk_managed)).assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w1280dp-h1000dp")
|
||||
fun systemPowerVrGameProfileKeepsOtherComponentChoicesAndRuntimeOptionsAvailable() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
showDxvk(systemPowerVr = true)
|
||||
compose.onNodeWithText(context.getString(R.string.comp_scope_general)).performClick()
|
||||
compose.onNodeWithText("Game A").performClick()
|
||||
compose.waitUntil(5_000) {
|
||||
compose.onAllNodesWithText(context.getString(R.string.comp_game_reset)).fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
|
||||
compose.onNodeWithText(context.getString(R.string.gpu_system_powervr)).assertIsNotEnabled()
|
||||
compose.onNodeWithText(context.getString(R.string.cmgr_powervr_dxvk_managed)).assertExists()
|
||||
val inheritedChoices = compose.onAllNodesWithText(context.getString(R.string.comp_game_use_general))
|
||||
inheritedChoices.assertCountEquals(4) // FEX preset, FEX package, Proton and VKD3D remain selectable.
|
||||
repeat(4) { inheritedChoices[it].assertIsEnabled() }
|
||||
val runtimeOptions = compose.onAllNodesWithText(context.getString(R.string.comp_game_runtime_options))
|
||||
runtimeOptions.assertCountEquals(2)
|
||||
repeat(2) { runtimeOptions[it].assertIsEnabled() }
|
||||
compose.onNodeWithText(context.getString(R.string.comp_this_proton).uppercase()).assertDoesNotExist()
|
||||
|
||||
compose.onNodeWithText("Game A").performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_scope_general)).performClick()
|
||||
compose.onNodeWithText(context.getString(R.string.comp_this_proton).uppercase()).assertExists()
|
||||
}
|
||||
|
||||
@Test @Config(qualifiers = "w1280dp-h1000dp")
|
||||
fun systemPowerVrGameProfileCanClearAnExistingDxvkOverrideWithoutSelectingAnother() {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
showDxvk(systemPowerVr = true, gameDxvkOverride = true)
|
||||
compose.onNodeWithText(context.getString(R.string.comp_scope_general)).performClick()
|
||||
compose.onNodeWithText("Game A").performClick()
|
||||
compose.waitUntil(5_000) {
|
||||
compose.onAllNodesWithText(context.getString(R.string.comp_game_reset)).fetchSemanticsNodes().isNotEmpty()
|
||||
}
|
||||
|
||||
compose.onNodeWithText(context.getString(R.string.gpu_system_powervr)).performScrollTo().assertIsEnabled().performClick()
|
||||
compose.onNodeWithText("Stored DXVK").assertDoesNotExist()
|
||||
compose.onAllNodesWithText(context.getString(R.string.comp_game_use_general)).onLast().performClick()
|
||||
compose.waitUntil(5_000) { "dxvk" !in ComponentsManager.gameComponents(context, "42") }
|
||||
compose.onNodeWithText(context.getString(R.string.gpu_system_powervr)).assertIsNotEnabled()
|
||||
}
|
||||
|
||||
private fun showDxvk(
|
||||
systemPowerVr: Boolean,
|
||||
gameDxvkOverride: Boolean = false,
|
||||
onCancel: () -> Unit = {},
|
||||
onImport: () -> Unit = {},
|
||||
onSwap: (String) -> Unit = {},
|
||||
onRestore: (String) -> Unit = {},
|
||||
) {
|
||||
val context = RuntimeEnvironment.getApplication()
|
||||
File(context.filesDir, "components/state.json").apply {
|
||||
parentFile!!.mkdirs()
|
||||
writeText(if (gameDxvkOverride) """{"profiles":{"42":{"dxvk":"stored.wcp"}}}""" else "{}")
|
||||
}
|
||||
val proton = ComponentsManager.Proton(
|
||||
"test-proton", "Test Proton", File(context.filesDir, "test-proton"), "/test-proton", "1.0", false,
|
||||
)
|
||||
val snapshot = ComponentsManager.Snapshot(
|
||||
protons = listOf(ComponentsManager.ProtonView(
|
||||
proton = proton,
|
||||
components = mapOf("dxvk" to ComponentsManager.Component("1.0", "", "Stored DXVK", "", "stored.wcp", "Next DXVK")),
|
||||
originals = listOf(ComponentsManager.Original("dxvk", "1.0", "Original DXVK", 1)),
|
||||
inUseByGame = false,
|
||||
)),
|
||||
packages = listOf(ComponentsManager.Package("stored.wcp", "dxvk", "Stored DXVK", "", 1)),
|
||||
)
|
||||
compose.setContent {
|
||||
DroidDeckTheme {
|
||||
ComponentsPage(
|
||||
snapshot = snapshot,
|
||||
catalog = emptyList(),
|
||||
catalogAt = 0,
|
||||
protonId = proton.id,
|
||||
comp = "dxvk",
|
||||
checking = false,
|
||||
busy = null,
|
||||
downloads = emptyMap(),
|
||||
onProton = {},
|
||||
onComp = {},
|
||||
onSwap = onSwap,
|
||||
onRestore = onRestore,
|
||||
onCancelQueued = onCancel,
|
||||
onDeletePackage = {},
|
||||
onDeleteOriginal = {},
|
||||
onDownload = {},
|
||||
onRefresh = {},
|
||||
onImport = onImport,
|
||||
onBack = {},
|
||||
gpu = GpuDriversState(powerVr = true, systemPowerVr = systemPowerVr),
|
||||
games = listOf(Library.SteamGame(42, "Game A", null, "internal")),
|
||||
requestInitialFocus = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -130,6 +130,12 @@ class AppUpdatesTest {
|
||||
assertNull(AppUpdates.installBlock(stable, me("eeeeeee", versionCode = 9)))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theNonAdrenoTestBuildIsNeverReplacedByAnOfficialBuild() {
|
||||
val testBuild = AppUpdates.Installed("eeeeeee", 0, "0.2.0", 9, updatable = true, nonAdrenoTest = true)
|
||||
assertNotNull(AppUpdates.installBlock(stable, testBuild))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aMissingVariantIsBlockedBeforeDownload() {
|
||||
val missing = release("ddddddd", withApk = false)
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
# American Nightmare on Pixel: rendering workaround and remaining limits
|
||||
|
||||
Local engineering results from 2026-10-11/12. Steam game 202750 was tested on a
|
||||
Pixel 11 Pro Fold using the Pixel Lab runtime. These observations do not establish
|
||||
compatibility across the Pixel family or a fix for the system resets.
|
||||
|
||||
## Rendering result
|
||||
|
||||
The bright dotted triangle edges over textured rocks, boards and the player are
|
||||
not an application wireframe setting: traced input and driver pipelines all used
|
||||
`VK_POLYGON_MODE_FILL`, with no dynamic polygon mode. The original affected path
|
||||
used 2x MSAA, RGBA16F color and D24S8 depth. The game's minimum UI AA setting and
|
||||
`d3d11.disableMsaa` did not disable its D3D9 multisampling.
|
||||
|
||||
A real single-sample D3D9 comparison removed the visible bright triangle edges.
|
||||
Trial 16 verified 114 input and 114 driver pipelines, all single-sample. Trial 17
|
||||
retained correct meshes/textures through movement and turning, with 119 pipelines
|
||||
in each phase, all single-sample. This isolates a useful workaround to the MSAA
|
||||
path; it does not identify the precise faulty operation or prove a vendor bug.
|
||||
The override also changes effective surface descriptors, so the application may
|
||||
select different AA-aware shader/rendering paths.
|
||||
|
||||
`tools/dxvk/patches/0004-d3d9-force-single-sample.patch` adds an explicit per-game
|
||||
`d3d9.forceSingleSample` option, default **False**. After validating the original
|
||||
sample request, D3D9 surface normalization selects `D3DMULTISAMPLE_NONE` and quality
|
||||
0. GetDesc, image creation, resolves and sample-dependent state use this effective
|
||||
description. This intentionally disables MSAA, per-sample masks and
|
||||
alpha-to-coverage. It is a compatibility override, not transparent MSAA emulation
|
||||
or a universal PowerVR default. Existing low32, BC-format, present synchronization
|
||||
and tiler workarounds must remain intact.
|
||||
|
||||
Swapchain backbuffers have a separate creation path. With the override enabled,
|
||||
that path now validates a copy of the original requested descriptor and transfers
|
||||
the effective sample type/quality before allocation, so automatic depth surfaces
|
||||
and backbuffers agree. Validation uses the application's lockable-backbuffer flag;
|
||||
the internal lockability required for GDI fallback is retained on the allocated
|
||||
backbuffer. With the override disabled the original backbuffer path is unchanged.
|
||||
This correction addresses official PR602 review 5486295088. Its CPU harness
|
||||
compiles the actual DXVK sample decoder, surface normalizer and backbuffer method,
|
||||
plus the automatic-depth descriptor and framebuffer depth-binding excerpts.
|
||||
Fifteen cases cover on/off, NONMASKABLE quality, matching depth, no-depth operation,
|
||||
unsupported/invalid/lockable requests, allocation cleanup and recreation. Backend
|
||||
images and adapter capabilities are mocked; these are not GPU or gameplay tests.
|
||||
|
||||
## Independent HUD correction
|
||||
|
||||
The diagnostic frametimes HUD bound an R8_UINT storage texel buffer to a shader
|
||||
whose SPIR-V image format was Unknown. This required formatless buffer writes
|
||||
which the device did not report for that format, producing VUID 07029.
|
||||
`0003-hud-explicit-r8-texel-format.patch` declares `r8ui` to match the actual host
|
||||
view. No capabilities are fabricated. The build now compiles and validates the
|
||||
actual shader, and checks binding 3 for DimBuffer/storage/R8ui. The original shader
|
||||
fails that contract; the patched shader passes. Real-game trial 15 used the new
|
||||
DLLs, removed 07029, and retained the original triangle edges. This HUD bug is
|
||||
separate from the rendering workaround, and is not a proven reset cause.
|
||||
|
||||
VUID 06479 for color-format comparison descriptors remains under investigation.
|
||||
The D3D9 shader uses a conditional comparison path; static validation output alone
|
||||
does not prove that the offending branch executes. No warning suppression or
|
||||
false format-feature claims are proposed. Trial 14's LOG+FAIL with a duplicate
|
||||
limit blocked only the first message of each kind, not every invalid API call;
|
||||
subsequent trials used logging only. Do not describe these runs as fully blocked
|
||||
validation or GPU-assisted validation.
|
||||
|
||||
## Responsiveness, performance and stability
|
||||
|
||||
Paired screenshots prove movement and camera changes, rather than relying on an
|
||||
input receipt. Trial 17 completed eight samples without a black viewport. Its
|
||||
cold sample was 3.2 FPS; later recognized samples were 19.1-29.9 FPS, with roughly
|
||||
2.54 CPU-core equivalents. Camera/workload, capture overhead and thermals were
|
||||
not controlled; this is not a reliable A/B benchmark.
|
||||
|
||||
The planned eight-minute trial 17 stopped at a focus/session guard after the last
|
||||
confirmed sample at 315.6 seconds. Steam owned focus; the target game was still
|
||||
available for a single client quit. Its temporary settings were successfully
|
||||
restored, and the phone boot counter remained 12. The focus change's cause is
|
||||
unknown. The run is **incomplete**, not an eight-minute pass or a demonstrated
|
||||
game crash. Controls, focus ownership and sustained stability still need broader
|
||||
coverage beyond these short tests.
|
||||
|
||||
### Final production configuration and user confirmation
|
||||
|
||||
The clean production configuration was persisted only for game 202750 through
|
||||
the application's per-game environment UI. It selects the tested DXVK component
|
||||
and sets `d3d9.forceSingleSample = True`, retaining the existing low32, BC,
|
||||
presentation-sync and `dxvk.tilerMode = False` workarounds. Shared configuration
|
||||
and other games were unchanged. Shader audit layers, validation and the
|
||||
frametimes HUD are not enabled in this production configuration.
|
||||
|
||||
A final automated production trial loaded the existing saved game, verified
|
||||
turning/movement with five paired non-black screenshots, and observed 115 seconds
|
||||
without the bright triangle edges or another phone reset. It then quit normally;
|
||||
the saved per-game environment remained unchanged. This is bounded observation,
|
||||
not a long-duration stability or controlled performance benchmark.
|
||||
|
||||
On 2026-10-11 (America/Toronto), the device owner separately confirmed that this
|
||||
stage worked and authorized publication. No duration, frame rate or full-game
|
||||
completion was supplied with that confirmation. It is additional user validation
|
||||
of the stage, not a claim that all Pixel devices or the GNOC resets are fixed.
|
||||
|
||||
## Native guards, resets and diagnostic controls
|
||||
|
||||
The Pixel base is e589e3ae21959c9c74c490d917cebf256acc8ac8. PR561's 9e6fe314 and
|
||||
3c363910 guards were integrated in an isolated worktree; 26 selected production-C
|
||||
regressions and a full APK/runtime verification passed. Pixel AHB support remains
|
||||
present. The existing Lab app was updated without uninstalling or resetting its
|
||||
Steam account. This APK preceded a second system reset, so the native guards are
|
||||
not a verified reset fix.
|
||||
|
||||
Two resets changed the boot counter 10 -> 11 -> 12. After personal unlock, narrow
|
||||
kernel/firmware projections confirmed GNOC/access-control details for the first,
|
||||
and `reset,warm,gnoc_error` with a fresh GNOC numeric record for the second. The
|
||||
specific faulty component/operation and any relation to rendering are unknown.
|
||||
`tools/pixel_reset_diagnostics.py` exports only fixed fault categories/numeric
|
||||
fields, lock state, boot counter and entry times; never arbitrary log text or
|
||||
account data. Boot-property and kernel last-boot reasons use the same exact
|
||||
allowlist of canonical categories and the observed `reset,warm,gnoc_error` value;
|
||||
unknown reasons and custom suffixes produce `unknown`, never their original text.
|
||||
Primary-user states are likewise limited to recognized lifecycle categories.
|
||||
Output files are created exclusively with mode `0600` before any bytes are
|
||||
written (POSIX), and existing files/symlinks are refused. Host regressions cover
|
||||
these boundaries as well as freshness, unlock gating and narrow output.
|
||||
Dropbox's offset-free local timestamp is not assigned a guessed instant during
|
||||
a DST transition: repeated hours report `ambiguous_device_local_time`, skipped
|
||||
hours report `nonexistent_device_local_time`. Neither is attributed to the trial
|
||||
or used to project kernel-body categories until its time can be established.
|
||||
|
||||
Private opt-in diagnostics captured maintenance5 inline modules, which the older
|
||||
shim path missed. Materialization passed nine actual-C ASan/UBSan cases; benign
|
||||
pipeline-chain planning passed twelve. Real-game NoContraction, scaled vertex
|
||||
conversion and force-clip rewrites were actually applied and did not remove the
|
||||
edges. None is a production default. Sixty-two valid bounded, owned offscreen GPU
|
||||
cases passed exact pixel readback, fences and validation, covering interpolation,
|
||||
seams, perspective meshes, interface widening, scaled fetch, HDR/depth prepasses,
|
||||
real clipping and nonconstant depth. Invalid initial fixtures are excluded. These
|
||||
passing controls do not exonerate every driver/rendering path.
|
||||
|
||||
## Reproducibility and recovery
|
||||
|
||||
The runtime artifact supplies both architectures, exact DLL hashes, public patched
|
||||
DXVK sources, all four patches, wrapper and build recipe. It contains no game
|
||||
assets, bytecode, saves, account files, screenshots or raw device logs. Source
|
||||
patches apply cleanly to pinned DXVK revision 25ca63f17f34bdc05a39873ee63907d3cbbfa030.
|
||||
All five runtime DLL targets were built for both architectures.
|
||||
|
||||
Stop further load tests after a full reset. Wait for personal unlock and inspect a
|
||||
fresh narrow projection before another launch. Temporary profile restoration checks
|
||||
baseline/current hashes and unchanged shared/other-game settings; it never rolls
|
||||
back saved game progress. Persistent selection must affect only 202750 and leave
|
||||
private shader audit layers, validation settings and frametimes HUD disabled.
|
||||
Routine Heartbeat must not launch games or automatically resume this engineering.
|
||||
|
||||
## Submission scope
|
||||
|
||||
These opt-in runtime tools are submitted directly against official DroidDeck
|
||||
`main`. The standalone DXVK build recipe, source pin, BC-format prerequisite and
|
||||
presentation-semaphore patch/check are imported verbatim from the PowerVR proposal
|
||||
<https://github.com/Droid-Deck/DroidDeck/pull/570> at
|
||||
`d0f7264ea8e402d30c868779198dc2fd74e7431c`. That proposal's attribution and existing
|
||||
source/license provenance are retained. The semaphore correction originated in
|
||||
<https://github.com/wallentx/DroidDeck/pull/3>. No Android app changes, managed pack
|
||||
or the experimental fork's development history are imported with those recipes.
|
||||
|
||||
The source tools can be reviewed and built independently. Automatic PowerVR
|
||||
integration and delivery in DroidDeck require the separately reviewed #570
|
||||
foundation and a new managed-runtime release. This submission does not change
|
||||
managed-pack manifests/checksums or globally enable any override. The earlier
|
||||
fork-only stage <https://github.com/wallentx/DroidDeck/pull/4> is superseded by the
|
||||
official submission; its review history is preserved.
|
||||
|
||||
For standalone verification, run
|
||||
`python3 -m unittest discover -s tools/tests -p test_pixel_reset_diagnostics.py`
|
||||
on the host. On native 64-bit Linux/glibc,
|
||||
`tools/hybris/low32/build.sh /absolute/output-dir` builds and runs the CPU integrity
|
||||
and independent mmap/mmap64 preload-chain regressions (both library orders in
|
||||
off, trace and low32 modes). Optional Vulkan headers produce `gpu-copy-native`
|
||||
for the selected native host architecture, not a hardcoded ARM64 filename.
|
||||
`python3 -m unittest discover -s tools/tests -p test_dxvk_build.py` verifies output
|
||||
isolation with a synthetic toolchain, without fetching or compiling DXVK.
|
||||
The DXVK component recipe is `tools/dxvk/build.sh /absolute/output-dir`;
|
||||
it requires the pinned DXVK build prerequisites, including Meson/Ninja, MinGW
|
||||
cross compilers, glslangValidator and SPIR-V Tools. It retains both architectures,
|
||||
source/license provenance and downstream patches, without editing an installed
|
||||
runtime or APK. Its output directory must be new or empty (including hidden
|
||||
entries). Prior or partially built outputs are refused before fetching sources,
|
||||
left untouched and never included in a new DLL manifest. Use a fresh directory
|
||||
after a failed build.
|
||||
The recipe also requires a native C++17 compiler for
|
||||
`python3 tools/dxvk/check_d3d9_single_sample.py /path/to/patched-dxvk` before DLL
|
||||
compilation. Add `--sanitize` on supported hosts to run its ASan/UBSan controls.
|
||||
|
||||
The compositor ownership safeguards are independently proposed in
|
||||
<https://github.com/Droid-Deck/DroidDeck/pull/561>. Those native changes were present
|
||||
in the integrated Pixel Lab APK used for the game experiments, but are not part
|
||||
of this runtime PR's diff. The original BC emulation is a prerequisite supplied by
|
||||
the separately proposed PowerVR runtime. This submission supplies source and reproducibility tools,
|
||||
not an APK, proprietary driver, game data or private diagnostic archive.
|
||||
@@ -0,0 +1,88 @@
|
||||
# Compositor work whose completion is unknown
|
||||
|
||||
A timed-out fence wait does not cancel submitted GPU work. Continuing after
|
||||
that result can reset a command buffer or fence still in use, or destroy an
|
||||
image and its memory while the GPU may still read them. Previously the finite
|
||||
wait paths returned without putting the compositor into a terminal state, and
|
||||
swapchain teardown ignored the result of `vkDeviceWaitIdle`.
|
||||
|
||||
An unsuccessful completion check other than real `VK_ERROR_DEVICE_LOST` now
|
||||
puts the compositor in a distinct completion-unknown state. It stops subsequent
|
||||
presentation and retains potentially pending image/memory and swapchain
|
||||
resources until the DroidDeck app process exits. Device loss continues through
|
||||
the existing device-loss path. This is deliberate retention rather than an
|
||||
automatic recovery; restarting a guest session cannot reset the in-process GPU
|
||||
state, so the diagnostic asks for an app restart.
|
||||
|
||||
Initialization checks the black-image submit and fence result. An unsuccessful
|
||||
empty completion-marker submit no longer causes a wait on an unsignalled fence.
|
||||
Surface-rebuild and effect-map paths stop when teardown cannot establish idle.
|
||||
Acquire retries also stop: retaining the old swapchain is not permission to
|
||||
acquire from it again. A later frame-generation acquire that ends in a terminal
|
||||
state returns before the completion marker, fence wait or any further recording.
|
||||
Real device loss on present is handled before attempting that marker, too.
|
||||
Mapped SHM bytes are retained unchanged, including same-size `wl_shm` and
|
||||
single-pixel commits; keeping only the allocation would still race a GPU read.
|
||||
Off-screen pass copy/abort and the internal fence wait reject terminal states
|
||||
without further Vulkan calls. Release fds are still consumed on rejected copies.
|
||||
The normal frame fence still has its existing infinite timeout; this change is
|
||||
not a general GPU hang watchdog.
|
||||
|
||||
Externally owned DMA-BUF contents need the same protection. `vkp_completion_unknown()`
|
||||
exposes the terminal state to compositor-thread lifecycle paths. Replacement,
|
||||
surface/client destruction, cursor/idle-role releases, previously queued paced
|
||||
releases and SurfaceFlinger callbacks no longer return a DMA-BUF to its client
|
||||
after quarantine. The compositor retains DMA-BUF references/backing FDs and AHB
|
||||
references until app process exit. A display fence alone does not establish that
|
||||
the compositor's Vulkan reads completed. Queued releases detach destroyed surfaces
|
||||
and remain held without repeatedly arming an expired timer. New terminal releases
|
||||
require no allocation, so allocation failure cannot fall back to an unsafe release.
|
||||
Copied SHM releases and healthy/genuine-device-loss cleanup keep their existing
|
||||
behaviour. This intentionally prevents further client buffer reuse; restarting
|
||||
the Android app process, not just the guest session, is required.
|
||||
|
||||
## Regression coverage
|
||||
|
||||
`python3 -m unittest discover -s tools/tests -p test_vk_pending_completion.py -v`
|
||||
compiles the production wait/destructor and swapchain teardown functions with a
|
||||
fake Vulkan dispatch table. The two cases cover success, timeout, host-memory
|
||||
errors, genuine device loss, resource retention and suppressed repeated teardown.
|
||||
No real GPU fault is injected. The harness matches main's Vulkan-image resources;
|
||||
it does not assume the experimental PowerVR branch's additional AHB fields.
|
||||
|
||||
`python3 -m unittest discover -s tools/tests -p test_vk_terminal_callers.py -v`
|
||||
additionally compiles the **entire production `vk_present.c`**, with fake Vulkan
|
||||
dispatch callbacks and stub external modules. The compositor's `take_shm` and
|
||||
`take_pixel` callers are inserted verbatim, not rewritten. It needs the Android
|
||||
NDK's Vulkan-Headers (`ANDROID_HOME`/`ANDROID_SDK_ROOT`/`NDK`), a host Vulkan
|
||||
development package, or `DROIDDECK_VULKAN_INCLUDE`; absent headers are explicitly
|
||||
reported as a skip. No Android runtime or GPU is required.
|
||||
|
||||
The 12 scenarios include first/later OUT_OF_DATE and SURFACE_LOST followed by an
|
||||
idle failure, a finite blit timeout followed by same-size SHM/single-pixel
|
||||
uploads, normal presentation/frame generation, a healthy later acquire timeout
|
||||
whose earlier work still needs draining, real acquire/present device loss, and
|
||||
terminal off-screen pass entry. Every work-issuing fake callback asserts the
|
||||
device is live. After quarantine, the tests verify retained handles and unchanged
|
||||
mapped bytes, and probe the public render/blit/readback/import/pass entry points
|
||||
for suppressed acquire/submit/wait/reset and destruction. Consumed fds are checked.
|
||||
Against PR #560's `68dc1c45` the same harness compiles, but nine scenarios fail
|
||||
(the three healthy controls pass); the corrected production unit passes all 12.
|
||||
|
||||
The baseline production fence/destructor compiles but fails the timeout-state
|
||||
oracle; the corrected functions pass both cases with `-Wall -Wextra -Werror`.
|
||||
The change was also exercised in an independently integrated Pixel PowerVR Lab,
|
||||
but its short game observations do not establish the cause of the earlier GNOC
|
||||
reboot or sustained device stability. Main's native CI and APK build remain
|
||||
separate validation.
|
||||
|
||||
`python3 -m unittest discover -s tools/tests -p test_vk_dmabuf_quarantine.py -v`
|
||||
compiles the production compositor/AHB release, reference and listener functions
|
||||
verbatim, using the real Wayland list layouts/macros with fake IPC/timer/AHB
|
||||
endpoints. It covers paced replacement, immediate surface cleanup, already queued
|
||||
releases, a mixed DMA-BUF/SHM queue, client destruction, a display-fence callback,
|
||||
healthy cleanup and genuine device loss. It checks withheld releases, retained
|
||||
FDs/references/AHB ownership, removal of surface listeners and disarmed timers.
|
||||
The same harness can test an old source directory via
|
||||
`DROIDDECK_DMABUF_TEST_SOURCE`; it does not inject a real driver fault or prove
|
||||
long-term device stability.
|
||||
@@ -0,0 +1,340 @@
|
||||
# DroidDeck on Mali (Pixel 9 Pro) through Venus
|
||||
|
||||
Handoff notes for the next session.
|
||||
Upstream DroidDeck 0.3.1 runs on Adreno only.
|
||||
This branch makes it run on the user's Pixel 9 Pro (Tensor G4, Mali-G715, Android 17).
|
||||
|
||||
## Status (2026-10-08, night)
|
||||
|
||||
Prototype 13 is the APK on the phone, a release build (not debuggable).
|
||||
Prototypes 12 and 13 are published as GitHub prereleases.
|
||||
Steam Big Picture shows a clean, live picture, and Slay the Spire 2 runs at about 40 fps.
|
||||
|
||||
Direct3D 9-11 games run through DXVK.
|
||||
Test game: Hollow Knight Silksong (Unity, D3D11), app id 1030300.
|
||||
- Prototype 12: 35-40 fps in game, stable, with good audio. The phone was not throttling.
|
||||
- Prototype 13 (cached frame readback, see Performance): 45-52 fps, averaging 47-52.
|
||||
|
||||
Done and verified on the phone:
|
||||
- The Mali compatibility layer (`tools/venus/layer`) loads and reports the six features DXVK requires.
|
||||
- DXVK accepts the GPU and creates its device. D3D11 runs at feature level 11_0.
|
||||
- Silksong loads and plays.
|
||||
- The APK carries the layer and the Venus ICD; nothing on the phone is installed by hand any more.
|
||||
|
||||
Fixed: a crash in the Venus guest driver, about 20 s after launch, with a black screen until then.
|
||||
- Where: `vtest_vcmd_submit_cmd2` (`src/virtio/vulkan/vn_renderer_vtest.c`), on the `dxvk-submit` thread inside `vkQueueSubmit2`.
|
||||
- What: it reads `batch->syncs[1]->sync_id` and `syncs[1]` is the pointer `0x1`.
|
||||
- Cause: two threads submit to the same queue at once.
|
||||
- Venus's async present thread (`vn_wsi`) makes the WSI submits. On vtest, `vn_wsi_fence_wait` drops the queue lock while it waits on a fence.
|
||||
- It assumes one submit per swapchain. But `wsi_queue_submit2_unordered` makes a second, empty submit for DXVK's present fence.
|
||||
- DXVK's thread passes `vn_wsi_flush` in that window and submits at the same time.
|
||||
- Both use the per-queue scratch buffer `queue->storage`. The empty submit's `sync_vals[0] = 1` lands on DXVK's `syncs[1]`.
|
||||
- gamescope and Zink use no present fences, so Steam and Slay the Spire 2 never hit it.
|
||||
- Fix: `vn_queue_submit` holds a new per-queue `submit_mutex`. Verified with Silksong.
|
||||
|
||||
Other open problems:
|
||||
- Steam's UI blocks 30 s at a time on `IClientFriends::GetVoiceMicrophoneVolume`. A launch looks stuck on "Launching" even after the game died.
|
||||
- The render server aborts ("pthread_mutex_lock called on a destroyed mutex") when a context dies after an error. Not fixed.
|
||||
- The phone runs short of memory: about 1-2 GB free during a session. BC decoding makes textures 4-8x bigger.
|
||||
- Prototype 13 is not debuggable, so `adb run-as` fails and the hand-install loop below does not work.
|
||||
- To debug again: add `debuggable true` to the `release` build type in `app/build.gradle`, rebuild, reinstall. Keep it out of commits.
|
||||
- A debuggable build shows a harmless "not 16 KB-compatible" dialog.
|
||||
|
||||
## Performance
|
||||
|
||||
How a game frame reaches the screen (Silksong, 1280x720):
|
||||
1. The game draws through Venus. gamescope's WSI layer turns its X11 window into a Wayland surface on gamescope.
|
||||
2. Venus's present thread (`vn_wsi[0,0]`) runs WSI's software path (`MESA_VK_WSI_DEBUG=sw`).
|
||||
- It blits the image into a host-visible buffer, waits for the GPU, and `memcpy`s the buffer into a `wl_shm` buffer (3.6 MB).
|
||||
3. gamescope uploads that `wl_shm` buffer into a texture (patch 0114), composites, and hands a dma-buf to the app.
|
||||
4. The app's compositor draws it at 60 Hz. Its own work is about 2-3 ms a frame (`wayland.log`, `perf` lines).
|
||||
|
||||
Measured with `tools/venus/measure-present.patch` (see "Measuring a frame" below):
|
||||
|
||||
| Per frame | Prototype 12 | Prototype 13 |
|
||||
|---|---|---|
|
||||
| Frame interval | 26-29 ms | ~20 ms |
|
||||
| `memcpy` out of the readback buffer | 7-10 ms (~400 MB/s) | ~1.3 ms, cache sync included |
|
||||
| Present thread total | 17-20 ms | ~12 ms |
|
||||
| GPU fence waits (two per present) | ~4 ms | ~4.5 ms |
|
||||
| Game blocked in `vn_wsi_flush` | ~0.4 ms | ~0.01 ms |
|
||||
|
||||
Why the copy was slow: Venus hid Mali's cached memory type.
|
||||
- Mali's native types (`memtypes` probe): 0 = device-local, host-visible, coherent (uncached); 1 = device-local, host-visible, cached (not coherent).
|
||||
- `vn_physical_device_init_memory_properties` strips host-visible from cached types that are not coherent, and labels type 0 "cached" for app compatibility.
|
||||
- So WSI's readback buffer landed on uncached memory, and the CPU read it at ~400 MB/s.
|
||||
|
||||
The fix (prototype 13):
|
||||
- Venus allocates WSI's readback buffer in the hidden cached type (`vn_wsi_memory_type_index`). Apps still never see that type.
|
||||
- The vtest renderer keeps that buffer's dma-buf fd and implements flush and invalidate as `DMA_BUF_IOCTL_SYNC`.
|
||||
- WSI calls `vkInvalidateMappedMemoryRanges` before every CPU read of a frame (Wayland and X11 software paths).
|
||||
- The render server allocates cached memory types from the cached dma-buf heap (`/dev/dma_heap/system`).
|
||||
|
||||
What is left on the present thread (~12 ms):
|
||||
- ~4.5 ms in two GPU fence waits. WSI makes a second, empty submit for DXVK's present fence, and Venus waits on each.
|
||||
- ~6 ms in those two submits and their Venus round trips.
|
||||
- Thread sample (`top -H`, prototype 12): no thread at 100%. Game main thread 48%, `vn_wsi` 30%, `dxvk-frame` 30%, Unity render thread 25%.
|
||||
- `dxvk-frame` mostly waits for presents; 30% CPU looks like Venus polling in its semaphore waits.
|
||||
|
||||
## State outside the repo and the APK
|
||||
|
||||
On the phone, changed by hand (read this before testing anything):
|
||||
- `/sdcard/Download/droiddeck-env` holds `PROTON_LOG=1`. Every game writes a full Proton log to `/root/steam-<appid>.log`.
|
||||
- Delete it when debugging is done: `adb shell rm /sdcard/Download/droiddeck-env`.
|
||||
- `/data/local/tmp` holds copies of the pushed files and `watch-maps.sh`.
|
||||
|
||||
Published: prototypes 12 and 13 as the prereleases `mali-venus-proto12` and `mali-venus-proto13`. Prototypes 7 to 11 were never published.
|
||||
|
||||
## Where things are
|
||||
|
||||
- **Source:** `C:\Users\derab\source\repos\DroidDeck`, branch `mali-venus` (off tag `0.3.1`).
|
||||
- **Remote:** `mine` = https://github.com/DavidCimo/droiddeck-mali. It's public; the user made it public to download on the phone.
|
||||
- The gh account is `DavidCimo`.
|
||||
- Releases `mali-venus-proto1`…`proto6`, `proto12` and `proto13` hold the APKs. Proto 7 to 11 were installed over ADB only.
|
||||
- Publish with `gh release create mali-venus-proto<n> -R DavidCimo/droiddeck-mali --prerelease --target mali-venus --title "0.3.1 + Venus prototype <n>" --notes-file … <apk>`, after pushing the branch.
|
||||
- **Build outputs:** `C:\Users\derab\source\repos\droiddeck-mali\`
|
||||
- `DroidDeck-0.3.1.apk`: the official APK. Prebuilt assets and proot come from it.
|
||||
- `venus-out/`: the Mesa Venus ICD.
|
||||
- `layer/`: the Mali compatibility layer and its manifest.
|
||||
- `libblsession.so`: the session preload with `venus.c`.
|
||||
- `gamescope`: gamescope 3.16.29 with the app's patches plus 0114.
|
||||
- `venus.patch`: the source diff the APK build applies.
|
||||
- `DroidDeck-0.3.1-mali-venus-<n>.apk`: the builds.
|
||||
- **WSL Ubuntu** (`wsl -d Ubuntu`, user `delo`; use `-u root` for apt, there's no passwordless sudo):
|
||||
- `/home/delo/android-sdk`: SDK, NDK 27.3.13750724, CMake 3.22.1, build-tools 34.
|
||||
- `/home/delo/mali`: virglrenderer 1.3.0 (patched), Mesa 26.2.4 checkout (patched), libepoxy, Vulkan-Headers, `android-out/`.
|
||||
- `/home/delo/DroidDeck`: the clean LF clone the APK is built in.
|
||||
- The Edit and Read tools open WSL files at `\\wsl.localhost\Ubuntu\home\delo\...`.
|
||||
- **ADB:** `C:\Users\derab\tools\platform-tools\adb.exe`, paired with the Pixel over wireless debugging.
|
||||
- **DXVK source** for reference: `git clone https://github.com/doitsujin/dxvk` at commit `25ca63f17f34` (v3.1.1-27), the one in Proton Experimental ARM64 11.0-20260924.
|
||||
- Its shader compiler is the `subprojects/dxbc-spirv` submodule.
|
||||
|
||||
## How it works
|
||||
|
||||
The session's Linux processes (glibc) cannot load Mali's Android (bionic) Vulkan driver.
|
||||
Venus bridges them:
|
||||
|
||||
1. The guest loads Mesa's Venus ICD (`libvulkan_virtio.so`) with `VN_DEBUG=vtest`.
|
||||
2. The ICD serializes Vulkan calls over a unix socket: `files/venus/vtest.sock`.
|
||||
3. virglrenderer's `virgl_test_server --venus --no-virgl` runs on the Android side as an app child process.
|
||||
4. Per client, it forks `virgl_render_server`, which replays the calls on Mali's system Vulkan driver.
|
||||
|
||||
For Wine games, the Mali compatibility layer sits between DXVK (via winevulkan) and the Venus ICD.
|
||||
|
||||
The app's own compositor uses Mali's system driver directly.
|
||||
|
||||
## Mali compatibility layer (`tools/venus/layer`)
|
||||
|
||||
Why: DXVK 3.1.1 refuses any GPU without six features, and Mali-G715 has none of them.
|
||||
The list comes from `dxvk/dxvk_device_info.cpp`, `getFeatureList`, compared with `vulkaninfo` through Venus.
|
||||
Everything else DXVK requires is present: Vulkan 1.4, geometry and tessellation shaders, maxPushConstantsSize 256.
|
||||
|
||||
What it does, per feature:
|
||||
- `fillModeNonSolid`: LINE and POINT polygon modes draw as FILL.
|
||||
- `multiViewport`: reports maxViewports 16. Pipelines and `vkCmdSet{Viewport,Scissor}[WithCount]` keep only the first.
|
||||
- `robustBufferAccess2`: the device gets `robustBufferAccess` (version 1) instead.
|
||||
- `shaderClipDistance`: emulated per pipeline.
|
||||
- The last pre-rasterization stage writes the distances to a free varying location.
|
||||
- The fragment shader reads them and runs `OpKill` when one is negative.
|
||||
- Only when that stage is the only one using distances and the fragment shader's code is known.
|
||||
- Otherwise the distances are dropped. Depth-only passes lose clipping too.
|
||||
- DXVK passes shader code inline (`VkShaderModuleCreateInfo` in the stage), so its pipelines qualify.
|
||||
- Mali has no `graphicsPipelineLibraryIndependentInterpolationDecoration`, so DXVK compiles whole pipelines and the layer sees both stages.
|
||||
- `shaderCullDistance`: dropped.
|
||||
- `textureCompressionBC`: BC1-BC7 images are created as RGBA8, R8, RG8 or RGBA16F.
|
||||
- Every upload into one is decoded on the CPU with `bcdec` while the copy is recorded.
|
||||
- The source must be memory the application has mapped; DXVK's staging memory is.
|
||||
- Decoded texels go through the layer's own staging buffers, recycled when the command buffer is reset.
|
||||
- Copies from a BC image into a buffer, and between BC and uncompressed images, are skipped with a warning.
|
||||
|
||||
Files:
|
||||
- `layer.c`: loader plumbing, feature and limit reporting, device creation, the hook table.
|
||||
- `pipeline.c`: pipelines, shader modules, viewports.
|
||||
- `spirv.c`: the SPIR-V rewriter for clip and cull distances.
|
||||
- `bc.c`: BC formats, images and uploads.
|
||||
- `VkLayer_droiddeck_mali_compat.json`: implicit layer manifest.
|
||||
|
||||
When it is active:
|
||||
- Only in Wine processes (`WINEPREFIX` set), and only for features the GPU lacks.
|
||||
- `DROIDDECK_MALI_COMPAT=1` forces it on, `0` off. `DROIDDECK_MALI_COMPAT_DISABLE=1` keeps the loader from loading it.
|
||||
- Wine's own `explorer.exe` uses Zink, so it gets the layer too.
|
||||
- It logs one line per device: `droiddeck-mali-compat: emulating …`.
|
||||
|
||||
How it ships:
|
||||
- `build-apk.sh` copies `layer/` into the APK's `assets/linuxfs/usr/local/…`.
|
||||
- `SessionFiles.kt` stages both files into the guest at every session start (its `optional` list).
|
||||
- Guest paths: `usr/local/lib/droiddeck-mali/` and `usr/local/share/vulkan/implicit_layer.d/`.
|
||||
|
||||
Not done yet:
|
||||
- Unit tests for the SPIR-V rewriter. It is untested beyond DXVK's shaders, and unknown whether Silksong's shaders used clip distances at all.
|
||||
- Performance: BC decoding on the CPU makes loads slow. A compute-shader decoder would be the next step.
|
||||
|
||||
## Changes on the branch
|
||||
|
||||
App (Kotlin/C):
|
||||
- `session/VenusComponent.kt` (new): on a non-Adreno GPU, starts the vtest server and stages the ICD to `files/venus/`.
|
||||
- It sets the guest env: `VK_ICD_FILENAMES`, `VN_DEBUG=vtest`, `VTEST_SOCKET_NAME`, `MESA_VK_WSI_DEBUG=sw`.
|
||||
- `session/SessionService.kt`: uses the Venus env instead of the Turnip ICD, and adds the component.
|
||||
- `gpu/TurnipDriver.java`: the compositor uses the system Vulkan driver on non-Adreno.
|
||||
- `cpp/waylandcomp/src/vk_present.c`:
|
||||
- Enables only the dma-buf extensions the driver has.
|
||||
- Logs the driver's full extension list.
|
||||
- Gives a zero row pitch a packed 64-byte row (gamescope's 1x1 root buffer).
|
||||
- `gpu/GpuInfo.kt`, `MainActivity.kt`, `core/DeviceReport.kt`: wording, plus a "Venus" line in `device.txt`.
|
||||
- `session/SessionFiles.kt`: stages the Mali compatibility layer when the APK carries it.
|
||||
- `tools/linuxfs/preload/venus.c` (new, part of `libblsession`): unsets `LIBGL_KOPPER_DISABLE` when `VN_DEBUG` has `vtest`.
|
||||
- Steam's `steamwebhelper.sh` sets it unconditionally.
|
||||
- Without kopper and without DRI3, Zink gets no GL context, and the Steam UI crash-loops.
|
||||
- Steam restores that script when it verifies its install, so it cannot be edited.
|
||||
|
||||
`tools/venus/mesa-venus-vtest.patch` (Mesa 26.2.4, guest side):
|
||||
- No `VK_EXT_physical_device_drm` under vtest. gamescope otherwise demanded a primary node.
|
||||
- Sync-fd export for fences and semaphores under vtest: a CPU wait that returns -1 (already signaled). gamescope requires `VK_KHR_external_semaphore_fd`.
|
||||
- WSI skips attaching a -1 sync file to a dma-buf.
|
||||
- `vn_queue_submission_init_syncs` submits only the sync slots it filled.
|
||||
- Timeline semaphores free all `queue_count + 1` renderer syncs. Upstream freed one too few and leaked a vtest sync each.
|
||||
- `vn_queue_submit` runs under a per-queue `submit_mutex`. The async present thread raced the app's submits; see Status.
|
||||
- WSI's CPU readback buffer goes to Mali's hidden cached memory type; see Performance.
|
||||
- `vn_physical_device`: keeps the renderer's real memory flags, and picks the hidden type under vtest.
|
||||
- `vn_renderer_vtest.c`: flush and invalidate of incoherent memory are `DMA_BUF_IOCTL_SYNC` on the bo's dma-buf.
|
||||
- WSI common code: `vkInvalidateMappedMemoryRanges` before every CPU read of a frame.
|
||||
|
||||
`tools/venus/measure-present.patch`: per-frame present timings on stderr, applied on top for `MEASURE=1` builds only.
|
||||
|
||||
`tools/venus/virglrenderer-android.patch` (virglrenderer 1.3.0, host side):
|
||||
- Mali on Android can import dma-bufs but cannot export any memory.
|
||||
- Buffers report dma_buf features 0x4 (importable only); opaque fd reports nothing.
|
||||
- virglrenderer's minigbm fallback does not exist on Android.
|
||||
- On Android the server allocates the dma-buf itself and imports it.
|
||||
- Source for coherent types: `/dev/dma_heap/system-uncached`, then `/dev/dma_heap/system`, then an `AHardwareBuffer` fd.
|
||||
- Uncached because Mali here is not cache-coherent with the CPU, and nobody calls `DMA_BUF_IOCTL_SYNC` on coherent memory.
|
||||
- The guest maps coherent memory without syncs, and on the cached heap frames tore at cache-line granularity: the streaks.
|
||||
- Cached types (not coherent) come from `/dev/dma_heap/system`. Whoever maps them syncs through the dma-buf.
|
||||
- The fd rides the existing udmabuf plumbing.
|
||||
- Image and buffer queries report "importable dma-buf" as exportable too. gamescope keeps only exportable modifiers.
|
||||
- Exports of any memory type go through that allocator.
|
||||
- Logs what the driver reports, and failed allocations.
|
||||
|
||||
`tools/gamescope/patches/0114-shm-buffers-upload-every-commit.patch`:
|
||||
- Xwayland has no glamor here, so it reuses about three wl_shm buffers with new pixels.
|
||||
- gamescope cached one texture per buffer, copied at first import.
|
||||
- The screen cycled through three stale frames: the flicker. Input and audio still worked.
|
||||
- The patch caches dma-buf textures only, and uploads shm buffers on every commit.
|
||||
- See `tools/gamescope/PATCHES.md`.
|
||||
- The session stages gamescope from the APK assets every start, so it needs an APK rebuild.
|
||||
|
||||
## Build
|
||||
|
||||
Run each step after its inputs change:
|
||||
|
||||
1. Android side (WSL): `bash /mnt/c/Users/derab/source/repos/DroidDeck/tools/venus/build-virgl-android.sh`
|
||||
- It does a full clean rebuild; `ninja -C /home/delo/mali/virgl-build install` is enough for code changes.
|
||||
- After editing `/home/delo/mali/virglrenderer`, refresh the patch: `git -C /home/delo/mali/virglrenderer diff > .../tools/venus/virglrenderer-android.patch`.
|
||||
2. Guest ICD (Git Bash, Docker Desktop running): `MSYS_NO_PATHCONV=1 bash tools/venus/build-venus-icd.sh`
|
||||
- It clones Mesa fresh and applies `tools/venus/mesa-venus-vtest.patch`. About 5 minutes.
|
||||
- To change Venus: edit `/home/delo/mali/mesa`, then refresh the patch from Git Bash:
|
||||
`MSYS_NO_PATHCONV=1 wsl -d Ubuntu -u delo -- git -C /home/delo/mali/mesa diff > tools/venus/mesa-venus-vtest.patch`
|
||||
3. Mali compatibility layer (Git Bash, Docker): `MSYS_NO_PATHCONV=1 bash tools/venus/build-layer.sh`
|
||||
- Fetches Vulkan-Headers and SPIRV-Headers (vulkan-sdk-1.4.357.0) and `bcdec.h` at a pinned commit. Under a minute.
|
||||
4. Preload (Git Bash, Docker): `MSYS_NO_PATHCONV=1 bash tools/venus/build-libblsession.sh`
|
||||
5. gamescope (Git Bash, Docker): `MSYS_NO_PATHCONV=1 bash tools/venus/build-gamescope.sh`
|
||||
- Emulated arm64, so it takes most of an hour.
|
||||
- Prototype 11's binary came from the same steps run by hand; the script itself has not run yet.
|
||||
6. Source patch (Git Bash): `git diff 0.3.1 > ../droiddeck-mali/venus.patch`
|
||||
- Run `git add -N` on new files first.
|
||||
7. APK (WSL): `bash /mnt/c/Users/derab/source/repos/DroidDeck/tools/venus/build-apk.sh <n>`
|
||||
- It packs the outputs of steps 1-5. Rebuild those first if their sources changed.
|
||||
|
||||
Gotchas:
|
||||
- Run Docker from Git Bash, not WSL: Docker Desktop's WSL integration is off.
|
||||
- Prefix Git Bash commands with `MSYS_NO_PATHCONV=1`, or paths given to `wsl`, `docker` and `adb` get mangled.
|
||||
- `wsl -- bash -c '…'` loses `$VARIABLES`; put the commands in a script file and run `wsl -- bash /mnt/c/…/script.sh`.
|
||||
- `adb pull` needs a Windows path as its target.
|
||||
- The APK is signed with the project's public test key, so it installs over earlier prototypes but not over the official app.
|
||||
- Use `git -c core.autocrlf=false -c core.eol=lf archive` to export files for a Linux build; plain `git archive` writes CRLF.
|
||||
|
||||
## Test loop over ADB
|
||||
|
||||
```sh
|
||||
A=/c/Users/derab/tools/platform-tools/adb.exe; export MSYS_NO_PATHCONV=1
|
||||
$A mdns services # find the phone's connect port if it dropped
|
||||
timeout 300 $A install -r "C:/Users/derab/source/repos/droiddeck-mali/DroidDeck-0.3.1-mali-venus-<n>.apk"
|
||||
$A shell am force-stop com.droiddeck.launcher
|
||||
$A shell monkey -p com.droiddeck.launcher -c android.intent.category.LAUNCHER 1
|
||||
$A shell input tap 897 1064 # "Play Steam" on the main page
|
||||
$A exec-out screencap -p > shot.png
|
||||
```
|
||||
|
||||
- The phone must be awake and unlocked, or `adb install` hangs.
|
||||
- Tap "Play Steam" only once MainActivity is the top resumed activity; an earlier tap is lost.
|
||||
- Wrap a remote `run-as ... sh -c` command in double quotes as one argument, or adb splits it. Longer scripts: push a file and run it with `run-as … sh /data/local/tmp/x.sh`.
|
||||
- Session logs: `/sdcard/Download/DroidDeck/<newest>/`
|
||||
- `session.log`: gamescope, Steam and game stdout and stderr.
|
||||
- `venus.log`: the vtest and render servers.
|
||||
- `wayland.log`: the compositor; frames on screen and windows open.
|
||||
- `events.jsonl`: `frame.first` means the loading overlay lifted.
|
||||
- `crash.log`.
|
||||
- Steam's own logs, live: `$A shell run-as com.droiddeck.launcher sh -c 'cd files/linuxfs/root/.local/share/Steam/logs; ...'`
|
||||
- The useful ones are `webhelper.txt`, `webhelper_gpu.txt`, `cef_log.txt`, `console_log.txt` and `gameprocess_log.txt`.
|
||||
- The session script copies those logs into `<session>/steam/` only on a clean exit.
|
||||
- Clean exit: "Stop session" on the DroidDeck notification. Leaving the app only suspends the session.
|
||||
- `Download/droiddeck-env` (KEY=VALUE lines) adds guest env without a rebuild. It is read at session start only.
|
||||
- First Steam start downloads and unpacks about 670 MB. On later starts Steam "verifies" and re-extracts changed files.
|
||||
|
||||
Faster iteration on GPU code, without an APK (needs a debuggable build, see Status):
|
||||
- Venus ICD: push it, then replace `files/venus/libvulkan_virtio.so` with `cp` to a new name and `mv` over it.
|
||||
- `mv` keeps the running gamescope and Steam on their old copy; overwriting in place could crash them.
|
||||
- Layer: copy the two files to the guest paths above. New processes load it. The next session start restages the APK's copy.
|
||||
- What the guest sees: `MSYS_NO_PATHCONV=1 bash tools/venus/guest-vulkaninfo.sh [0|1]` with a session running.
|
||||
|
||||
Debugging a game:
|
||||
- Proton log: `PROTON_LOG=1` in `droiddeck-env`, restart the session, launch. The log is `files/linuxfs/root/steam-<appid>.log`.
|
||||
- DXVK's lines start with `info:`, `warn:`, `err:`. Proton otherwise turns DXVK logging off.
|
||||
- Unity games: `Player.log` in the prefix, `pfx/drive_c/users/steamuser/AppData/LocalLow/<company>/<game>/`.
|
||||
- A crash in Linux code shows in the Proton log as `handle_syscall_fault … pc=0x…`, then `Exception 0xc0000005 in Unix call`.
|
||||
1. Before the launch, run `tools/venus/watch-maps.sh '<game>.exe'` on the phone (see its header).
|
||||
2. After the crash, find the library whose range holds the pc in `cache/game-maps.txt`. Offset = pc - range start + file offset.
|
||||
3. Resolve it in WSL: `bash /mnt/c/…/tools/venus/addr2line.sh <library in droiddeck-mali> <offset>`.
|
||||
- The thread name is in the log: `Thread renamed to "dxvk-submit"`.
|
||||
- Untested idea for launching a game without the user: write `steam://rungameid/<appid>` into `files/linuxfs/root/.steam/steam.pipe`.
|
||||
|
||||
Measuring a frame (needs a debuggable build):
|
||||
1. `MEASURE=1 MSYS_NO_PATHCONV=1 bash tools/venus/build-venus-icd.sh` builds the ICD with `measure-present.patch` into `droiddeck-mali/venus-out-measure/`.
|
||||
2. Install it by hand (see "Faster iteration"), with `PROTON_LOG=1` in `droiddeck-env`.
|
||||
3. Every 120 presents the game's Proton log gets two lines:
|
||||
- `MEASURE wl`: frame interval, the `memcpy` out of the readback buffer, the whole Wayland present. Average/max in ms.
|
||||
- `MEASURE vn`: the present thread, its GPU fence waits, and how long the game blocked in `vn_wsi_flush`.
|
||||
4. Per-thread CPU while playing: `adb shell "top -H -b -n 2 -d 8 -o TID,PID,%CPU,S,CMD,NAME"`, sorted by the third column.
|
||||
5. `wayland.log` in the session folder has the compositor's fps and per-frame costs every 10 s, without any special build.
|
||||
|
||||
## Failure history (prototype → cause → fix)
|
||||
|
||||
1. Official APK installed → Turnip ICD, no GPU → install the prototype.
|
||||
2. gamescope: "physical device has no primary node" → Mesa: drop `EXT_physical_device_drm` under vtest.
|
||||
3. gamescope: missing `VK_KHR_external_semaphore_fd` → Mesa: CPU-wait sync-fd export.
|
||||
4. Hang on loading: server "minigbm_allocation is not enabled" → virgl: relax the export check. Not enough: Mali exports nothing.
|
||||
5. Same hang → virgl: allocate a dma-buf (dma-heap or AHB) and import it.
|
||||
6. gamescope assert `modifiers.size() > 0` → virgl: report importable dma-buf as exportable; route exports through the allocator.
|
||||
7. Updater "zink: could not create swapchain"; Xwayland has no glamor, so no DRI3 → `MESA_VK_WSI_DEBUG=sw`.
|
||||
8. steamwebhelper restart loop, "failed to acquire a gl context" → `venus.c` preload unsets `LIBGL_KOPPER_DISABLE`.
|
||||
9. Frames reach the compositor but "0 windows open" and the overlay stays → compositor: fix stride 0 on gamescope's 1x1 root buffer.
|
||||
10. Sign-in screen shows, with dash streaks across it → virgl: allocate from the uncached dma-heap.
|
||||
11. Picture looks frozen or flickers between old frames, though clicks play sounds → gamescope patch 0114.
|
||||
12. Steam sign-in and Slay the Spire 2 at about 40 fps. Silksong: "d3d11: failed to create factory"; DXVK skips the GPU for `fillModeNonSolid` → the Mali compatibility layer.
|
||||
13. Silksong: D3D11 starts, black screen, then a crash in Venus's `vtest_vcmd_submit_cmd2` → Mesa: serialize queue submits against the async present thread. Silksong plays at 35-40 fps.
|
||||
14. Silksong held at 35-40 fps; Venus's present thread spent half its time copying frames from uncached memory → cached readback buffer (prototype 13), 47-52 fps.
|
||||
|
||||
## Next steps
|
||||
|
||||
1. Performance, measured first with `MEASURE=1` (see Performance):
|
||||
- The two GPU fence waits and two submits per present (~10 ms on the present thread).
|
||||
- The `dxvk-frame` thread at 30% CPU, probably Venus polling in semaphore waits.
|
||||
2. Silksong: check BC textures look right and loading time is bearable.
|
||||
3. Test more games on different engines: GameMaker, FNA (Celeste, Stardew Valley), Unity D3D9, Godot. Fix shared gaps in the layer, never per game.
|
||||
4. Direct3D 12 games use VKD3D-Proton, which has its own requirement list. Check it the same way.
|
||||
5. Clean up: delete `droiddeck-env` when debugging is done.
|
||||
|
||||
Rules from the user:
|
||||
- Never enter credentials for the user. They type the password and handle Steam Guard themselves.
|
||||
- Test every build on the phone over wireless debugging.
|
||||
- Fixes go in shared layers (Venus, the compatibility layer), not per game.
|
||||
+1
Submodule external/MaliBridge added at 95a1e600a5.
@@ -41,6 +41,10 @@ if [[ ! -x "${java_dir}/bin/java" ]]; then
|
||||
echo "Java 17 not found at ${java_dir}; set JAVA_HOME." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -f "${repo_root}/external/MaliBridge/scripts/build-client-linux.sh" ]]; then
|
||||
echo "external/MaliBridge is empty; run: git submodule update --init" >&2
|
||||
exit 1
|
||||
fi
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
echo "Docker is required to cross-compile the glibc ARM64 preload libraries." >&2
|
||||
exit 1
|
||||
@@ -137,7 +141,15 @@ docker run --rm --platform "${docker_platform}" \
|
||||
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"
|
||||
external/MaliBridge/scripts/build-client-linux.sh "$d" aarch64-linux-gnu-gcc
|
||||
aarch64-linux-gnu-gcc -O2 -Wall -o "$d/usr/local/bin/droiddeck-glprobe" tools/venus/glprobe.c -ldl
|
||||
aarch64-linux-gnu-strip --strip-unneeded "$d/usr/local/bin/droiddeck-glprobe"
|
||||
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"
|
||||
for script in tools/linuxfs/overlay/usr/local/bin/droiddeck-* tools/linuxfs/overlay/usr/local/bin/steam-compatibility; do
|
||||
@@ -386,6 +398,7 @@ if ! restore_step comet "${comet_key}" "${comet_out}"; then
|
||||
DROIDDECK_BUILD_IMAGE="${image_name}" bash tools/comet/build-local.sh
|
||||
save_step comet "${comet_key}" "${comet_out}"
|
||||
fi
|
||||
python3 tools/powervr/fetch.py
|
||||
bash tools/packs/build.sh app/build/packs
|
||||
python3 tools/release/runtime_inputs.py record
|
||||
./gradlew "${gradle_task}" --console=plain -PndkVersion="${ndk_version}" ${gradle_rust_arg}
|
||||
|
||||
@@ -5,7 +5,7 @@ if [[ -z "${docker_platform}" ]]; then
|
||||
fi
|
||||
case "${docker_platform}" in linux/arm64|linux/arm64/*) docker_platform=linux/arm64 ;; esac
|
||||
if [[ -z "${DROIDDECK_BUILD_IMAGE:-}" ]]; then
|
||||
DROIDDECK_BUILD_IMAGE=droiddeck-local-cross:24.04-v3
|
||||
DROIDDECK_BUILD_IMAGE=droiddeck-local-cross:24.04-v4
|
||||
[[ "${docker_platform}" == linux/arm64 ]] && DROIDDECK_BUILD_IMAGE+=-arm64
|
||||
fi
|
||||
export DROIDDECK_DOCKER_PLATFORM=${docker_platform} DROIDDECK_BUILD_IMAGE
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# CI component build; this does not change the APK or an installed Proton depot.
|
||||
set -euo pipefail
|
||||
root=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
. "$root/tools/dxvk/source.env"
|
||||
mkdir -p "${1:?output directory required}"
|
||||
out=$(cd "$1" && pwd)
|
||||
# Refuse to mix a pinned build with prior DLLs or an incomplete previous build.
|
||||
# Include dotfiles in the check and leave all existing contents untouched.
|
||||
shopt -s nullglob dotglob
|
||||
existing=("$out"/*)
|
||||
if ((${#existing[@]})); then
|
||||
printf '%s\n' 'output directory must be empty; use a fresh build directory' >&2
|
||||
exit 1
|
||||
fi
|
||||
shopt -u nullglob dotglob
|
||||
work=$(mktemp -d)
|
||||
trap 'rm -rf "$work"' EXIT
|
||||
git init -q "$work/source"
|
||||
git -C "$work/source" fetch --depth=1 https://github.com/doitsujin/dxvk.git "$DXVK_REVISION"
|
||||
git -C "$work/source" checkout -q --detach FETCH_HEAD
|
||||
test "$(git -C "$work/source" rev-parse HEAD)" = "$DXVK_REVISION"
|
||||
git -C "$work/source" submodule update --init --recursive --depth=1
|
||||
for patch in "$root"/tools/dxvk/patches/*.patch; do
|
||||
git -C "$work/source" apply --check "$patch"
|
||||
git -C "$work/source" apply "$patch"
|
||||
done
|
||||
python3 "$root/tools/dxvk/check_present_sync.py" "$work/source/src/dxvk/dxvk_presenter.cpp"
|
||||
python3 "$root/tools/dxvk/check_hud_storage_format.py" "$work/source/src/dxvk/hud/shaders/hud_frame_time_eval.comp"
|
||||
python3 "$root/tools/dxvk/check_d3d9_single_sample.py" "$work/source"
|
||||
for arch in 32 64; do
|
||||
meson setup "$work/build$arch" "$work/source" --cross-file "$work/source/build-win$arch.txt" \
|
||||
--buildtype release --prefix "$out" --bindir "x$arch" --libdir "x$arch" -Db_ndebug=if-release --strip
|
||||
meson compile -C "$work/build$arch" -j 4
|
||||
meson install -C "$work/build$arch"
|
||||
done
|
||||
cp "$work/source/LICENSE" "$out/LICENSE"
|
||||
printf '%s\n' "$DXVK_REVISION" > "$out/source-commit"
|
||||
git -C "$work/source" submodule status --recursive > "$out/submodules.txt"
|
||||
git -C "$work/source" diff > "$out/downstream.patch"
|
||||
tar --exclude-vcs --zstd -cf "$out/source.tar.zst" -C "$work/source" .
|
||||
(cd "$out" && find x32 x64 -name '*.dll' -type f -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS)
|
||||
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile pinned DXVK's actual descriptor paths against a controlled backend.
|
||||
|
||||
This checks CPU control flow, not GPU rendering. No Wine/game/device is started.
|
||||
"""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
CASES = ('forced_msaa_depth', 'default_msaa_depth', 'forced_nonmaskable',
|
||||
'default_nonmaskable', 'forced_already_single', 'forced_no_depth',
|
||||
'forced_unsupported', 'forced_invalid_type', 'forced_lockable_msaa',
|
||||
'forced_lockable_single', 'forced_allocation_failure',
|
||||
'default_allocation_failure', 'forced_recreate', 'ordinary_surface',
|
||||
'ordinary_invalid_lockable')
|
||||
|
||||
|
||||
def function(text, signature):
|
||||
start = text.index(signature)
|
||||
opening = text.index('{', start)
|
||||
# Ignore braces in comments and strings while preserving source positions.
|
||||
stripped = re.sub(r'//[^\n]*|/\*.*?\*/|"(?:\\.|[^"\\])*"|\'(?:\\.|[^\'\\])*\'',
|
||||
lambda m: ' ' * len(m.group()), text, flags=re.S)
|
||||
depth = 0
|
||||
for index in range(opening, len(stripped)):
|
||||
depth += (stripped[index] == '{') - (stripped[index] == '}')
|
||||
if depth == 0:
|
||||
return text[start:index + 1]
|
||||
raise ValueError('Unterminated source function: ' + signature)
|
||||
|
||||
|
||||
def production(source):
|
||||
base = source / 'src/d3d9'
|
||||
common = (base / 'd3d9_common_texture.cpp').read_text()
|
||||
header = (base / 'd3d9_common_texture.h').read_text()
|
||||
swap = (base / 'd3d9_swapchain.cpp').read_text()
|
||||
device = (base / 'd3d9_device.cpp').read_text()
|
||||
util = (base / 'd3d9_util.cpp').read_text()
|
||||
pieces = {
|
||||
'decode': function(util, 'HRESULT DecodeMultiSampleType('),
|
||||
'normalize': function(common, 'HRESULT D3D9CommonTexture::NormalizeTextureProperties('),
|
||||
'backbuffers': function(swap, 'HRESULT D3D9SwapChainEx::CreateBackBuffers('),
|
||||
'uses_image': function(header, 'static bool TextureUsesImage('),
|
||||
}
|
||||
reset = function(device, 'HRESULT D3D9DeviceEx::ResetSwapChain(')
|
||||
begin = reset.index('D3D9_COMMON_TEXTURE_DESC desc;', reset.index('if (pPresentationParameters->EnableAutoDepthStencil)'))
|
||||
end = reset.index('m_autoDepthStencil =', begin)
|
||||
pieces['auto_depth'] = reset[begin:end].rstrip()
|
||||
framebuffer = function(device, 'void D3D9DeviceEx::BindFramebuffer(')
|
||||
begin = framebuffer.index('const bool mismatch =')
|
||||
end = framebuffer.index(';', framebuffer.index('const bool bindDS =', begin)) + 1
|
||||
pieces['depth_binding'] = framebuffer[begin:end]
|
||||
return pieces
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('source', type=Path, help='Pinned DXVK tree with downstream patches applied')
|
||||
parser.add_argument('--cxx', default=os.environ.get('CXX', 'c++'))
|
||||
parser.add_argument('--sanitize', action='store_true', help='Enable ASan/UBSan on the CPU harness')
|
||||
args = parser.parse_args()
|
||||
pieces = production(args.source)
|
||||
harness = (Path(__file__).parent / 'tests/d3d9_single_sample.cpp').read_text()
|
||||
harness = harness.replace('/* PRODUCTION_USES_IMAGE */', pieces['uses_image'])
|
||||
with tempfile.TemporaryDirectory(prefix='dxvk-d3d9-') as directory:
|
||||
out = Path(directory)
|
||||
(out / 'harness.cpp').write_text(harness)
|
||||
include = '\n\n'.join(pieces[key] for key in ('decode', 'normalize', 'backbuffers'))
|
||||
include += '\nHRESULT auto_depth(D3D9DeviceEx* device, D3DPRESENT_PARAMETERS* pPresentationParameters, D3D9_COMMON_TEXTURE_DESC* output) {\n'
|
||||
include += 'auto* self = device;\n' + pieces['auto_depth'].replace('(this,', '(self,')
|
||||
include += '\n*output = desc; return D3D_OK;\n}\n'
|
||||
include += '\nbool depth_binds(const ImageInfo& color, const ImageInfo& dsInfo) {\n'
|
||||
include += 'auto sampleCount = color.sampleCount; auto renderArea = color.extent;\n'
|
||||
include += 'const bool noRT0Bound = false, ignoreRT0 = false;\n'
|
||||
include += pieces['depth_binding'] + '\nreturn bindDS;\n}\n'
|
||||
(out / 'd3d9_production.inc').write_text(include)
|
||||
command = [args.cxx, '-std=c++17', '-Wall', '-Wextra', '-Werror',
|
||||
'-Wno-unused-parameter', str(out / 'harness.cpp'), '-o', str(out / 'check')]
|
||||
# The original CreateBackBuffers does not use Flags; that known baseline
|
||||
# warning must not turn a negative control into a compiler-fixture error.
|
||||
if args.sanitize:
|
||||
command[1:1] = ['-fsanitize=address,undefined', '-fno-omit-frame-pointer']
|
||||
compilation = subprocess.run(command, capture_output=True, text=True)
|
||||
if compilation.returncode:
|
||||
raise SystemExit(compilation.stderr)
|
||||
results = []
|
||||
for case in CASES:
|
||||
process = subprocess.run([str(out / 'check'), case], capture_output=True,
|
||||
text=True, timeout=10, cwd=out,
|
||||
env={'ASAN_OPTIONS': 'detect_leaks=' +
|
||||
('0' if sys.platform == 'darwin' else '1')})
|
||||
results.append({'case': case, 'passed': process.returncode == 0,
|
||||
'exit': process.returncode, 'detail': process.stderr.strip()[-800:]})
|
||||
result = {'cases': results, 'passed': sum(row['passed'] for row in results),
|
||||
'failed': sum(not row['passed'] for row in results),
|
||||
'production_sha256': {key: hashlib.sha256(value.encode()).hexdigest()
|
||||
for key, value in pieces.items()},
|
||||
'backend_and_adapter_mocked': True, 'GPU_test': False,
|
||||
'sanitizers': args.sanitize,
|
||||
'leak_detection': args.sanitize and sys.platform != 'darwin'}
|
||||
print(json.dumps(result, indent=2))
|
||||
return bool(result['failed'])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compile the actual HUD shader and verify its binding-3 R8_UINT contract.
|
||||
|
||||
The frame-time HUD binds an R8_UINT texel-buffer view. An Unknown SPIR-V image
|
||||
format requires STORAGE_WRITE_WITHOUT_FORMAT, which PowerVR does not report
|
||||
for that buffer format. Static spirv-val alone accepts both declarations;
|
||||
this check validates the shader against the known host-side binding contract.
|
||||
"""
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import struct
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def check(shader):
|
||||
compiler = shutil.which('glslangValidator')
|
||||
validator = shutil.which('spirv-val')
|
||||
if not compiler or not validator:
|
||||
raise RuntimeError('glslangValidator and spirv-val required')
|
||||
with tempfile.TemporaryDirectory(prefix='dxvk-hud-contract-') as directory:
|
||||
output = Path(directory) / 'hud.spv'
|
||||
for command in ([compiler, '-V', '--target-env', 'vulkan1.3', str(shader), '-o', str(output)],
|
||||
[validator, '--target-env', 'vulkan1.3', str(output)]):
|
||||
process = subprocess.run(command, capture_output=True, text=True, timeout=30)
|
||||
if process.returncode:
|
||||
raise RuntimeError('HUD shader compilation/SPIR-V validation failed')
|
||||
raw = output.read_bytes()
|
||||
if len(raw) < 20 or len(raw) % 4:
|
||||
raise RuntimeError('Malformed SPIR-V')
|
||||
words = struct.unpack('<' + str(len(raw) // 4) + 'I', raw)
|
||||
if words[0] != 0x07230203:
|
||||
raise RuntimeError('Unexpected SPIR-V magic')
|
||||
bindings, sets, variables, pointers, images = {}, {}, {}, {}, {}
|
||||
offset = 5
|
||||
while offset < len(words):
|
||||
size, opcode = words[offset] >> 16, words[offset] & 0xffff
|
||||
if not size or size > len(words) - offset:
|
||||
raise RuntimeError('Malformed SPIR-V instruction')
|
||||
instruction = words[offset:offset + size]
|
||||
if opcode == 71 and size == 4: # OpDecorate
|
||||
if instruction[2] == 33:
|
||||
bindings[instruction[1]] = instruction[3]
|
||||
elif instruction[2] == 34:
|
||||
sets[instruction[1]] = instruction[3]
|
||||
elif opcode == 59 and size >= 4: # OpVariable
|
||||
variables[instruction[2]] = instruction[1]
|
||||
elif opcode == 32 and size == 4: # OpTypePointer
|
||||
pointers[instruction[1]] = instruction[3]
|
||||
elif opcode == 25 and size >= 9: # OpTypeImage
|
||||
images[instruction[1]] = (instruction[3], instruction[7], instruction[8])
|
||||
offset += size
|
||||
targets = [images.get(pointers.get(variables.get(identifier)))
|
||||
for identifier, binding in bindings.items()
|
||||
if binding == 3 and sets.get(identifier) == 0]
|
||||
if targets != [(5, 2, 39)]: # DimBuffer, storage image, ImageFormatR8ui
|
||||
raise RuntimeError('HUD binding 3 must compile to a storage texel buffer with ImageFormatR8ui')
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('shader', type=Path)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
check(args.shader)
|
||||
except RuntimeError as error:
|
||||
parser.exit(1, str(error) + '\n')
|
||||
print('HUD binding 3: SPIR-V valid, explicit R8ui storage texel-buffer format')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -0,0 +1,116 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Replay asynchronous WSI ownership using the pinned presenter's actual selections.
|
||||
|
||||
This checks semaphore selection, not the full Vulkan presenter. Real Vulkan
|
||||
validation and device testing remain separate gates. Requires a native C++ compiler.
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
|
||||
|
||||
def selection_code(source):
|
||||
match = re.search(
|
||||
r"// Return relevant Vulkan objects for the acquired image\s*"
|
||||
r"(?P<acquire>.*?)\s*m_presentPending = true;", source, re.S)
|
||||
wait = re.search(r"info\.pWaitSemaphores\s*=.*?;", source, re.S)
|
||||
if not match or not wait:
|
||||
raise ValueError("unsupported pinned presenter layout")
|
||||
return match["acquire"], wait[0]
|
||||
|
||||
|
||||
HARNESS = r'''
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
#include <vector>
|
||||
using VkSemaphore = uint64_t;
|
||||
struct Sync { VkSemaphore acquire, present; };
|
||||
struct Info { const VkSemaphore* pWaitSemaphores; };
|
||||
|
||||
struct Presenter {
|
||||
std::vector<Sync> m_semaphores;
|
||||
std::vector<unsigned> m_images = {0, 1, 2, 3};
|
||||
unsigned m_frameIndex = 0, m_imageIndex = 0;
|
||||
bool m_hasSwapchainMaintenance1;
|
||||
explicit Presenter(bool maintenance): m_hasSwapchainMaintenance1(maintenance) {
|
||||
for (unsigned i = 0; i < (maintenance ? 4u : 8u); ++i)
|
||||
m_semaphores.push_back({100 + i, 1 + i});
|
||||
}
|
||||
Sync acquire() {
|
||||
Sync sync{}; unsigned image;
|
||||
ACQUIRE_SELECTION
|
||||
(void)image;
|
||||
return sync;
|
||||
}
|
||||
VkSemaphore present() {
|
||||
auto& currSync = m_semaphores.at(m_frameIndex);
|
||||
Info info{};
|
||||
PRESENT_SELECTION
|
||||
return *info.pWaitSemaphores;
|
||||
}
|
||||
};
|
||||
|
||||
int replay(bool maintenance) {
|
||||
Presenter p(maintenance);
|
||||
std::array<VkSemaphore, 4> outstandingByImage{};
|
||||
std::array<VkSemaphore, 4> outstandingByFence{};
|
||||
// Deliberately delay reacquisition of image 2 beyond a full frame-ring cycle.
|
||||
const std::array<unsigned, 21> imageOrder = {
|
||||
2,0,3,0,1,3,0,1,1,2,3,1,0,3,2,2,0,1,3,0,2
|
||||
};
|
||||
for (unsigned iteration = 0; iteration < 200; ++iteration) {
|
||||
p.m_imageIndex = imageOrder[iteration % imageOrder.size()];
|
||||
if (maintenance) {
|
||||
// The existing fence path waits this frame's previous present fence.
|
||||
const auto completed = outstandingByFence.at(p.m_frameIndex);
|
||||
for (auto& pending : outstandingByImage)
|
||||
if (pending == completed) pending = 0;
|
||||
}
|
||||
// Acquisition and its GPU wait complete the last present of THIS image.
|
||||
outstandingByImage.at(p.m_imageIndex) = 0;
|
||||
const auto signal = p.acquire().present;
|
||||
const auto wait = p.present();
|
||||
if (signal != wait) {
|
||||
std::fprintf(stderr, "FAIL: render signal differs from present wait\n");
|
||||
return 2;
|
||||
}
|
||||
for (auto pending : outstandingByImage) {
|
||||
if (pending == signal) {
|
||||
std::fprintf(stderr, "FAIL: semaphore reused before presentation completion at frame %u\n", iteration);
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
outstandingByImage.at(p.m_imageIndex) = signal;
|
||||
if (maintenance) outstandingByFence.at(p.m_frameIndex) = signal;
|
||||
p.m_frameIndex = (p.m_frameIndex + 1) % p.m_semaphores.size();
|
||||
}
|
||||
std::printf("PASS: %s, 200 out-of-order acquisitions\n", maintenance ? "present-fence path" : "no-present-fence path");
|
||||
return 0;
|
||||
}
|
||||
int main() {
|
||||
if (int status = replay(false)) return status;
|
||||
return replay(true);
|
||||
}
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("source", type=Path, help="pinned dxvk_presenter.cpp, after patching")
|
||||
args = parser.parse_args()
|
||||
acquire, present = selection_code(args.source.read_text())
|
||||
code = HARNESS.replace("ACQUIRE_SELECTION", acquire).replace("PRESENT_SELECTION", present)
|
||||
with tempfile.TemporaryDirectory(prefix="dxvk-present-sync-") as directory:
|
||||
cpp = Path(directory) / "replay.cpp"
|
||||
exe = Path(directory) / "replay"
|
||||
cpp.write_text(code)
|
||||
subprocess.run([os.environ.get("HOST_CXX", "c++"), "-std=c++17", "-Wall", "-Wextra", str(cpp), "-o", str(exe)], check=True)
|
||||
return subprocess.run([str(exe)]).returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,53 @@
|
||||
diff --git a/src/dxvk/dxvk_device_info.cpp b/src/dxvk/dxvk_device_info.cpp
|
||||
index db09fba..8e9a76e 100644
|
||||
--- a/src/dxvk/dxvk_device_info.cpp
|
||||
+++ b/src/dxvk/dxvk_device_info.cpp
|
||||
@@ -118,6 +118,17 @@ namespace dxvk {
|
||||
initQueueProperties(instance, adapter, deviceInfo);
|
||||
initMemoryProperties(instance, adapter);
|
||||
|
||||
+ m_hasBcFormats = true;
|
||||
+ for (uint32_t value = VK_FORMAT_BC1_RGBA_UNORM_BLOCK; value <= VK_FORMAT_BC7_SRGB_BLOCK; value++) {
|
||||
+ VkFormatProperties properties = { };
|
||||
+ vk->vkGetPhysicalDeviceFormatProperties(adapter, VkFormat(value), &properties);
|
||||
+ constexpr VkFormatFeatureFlags required = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT
|
||||
+ | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT
|
||||
+ | VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
|
||||
+ if ((properties.optimalTilingFeatures & required) != required)
|
||||
+ m_hasBcFormats = false;
|
||||
+ }
|
||||
+
|
||||
disableUnusedFeatures(instance, safeMode);
|
||||
|
||||
enableFeaturesAndExtensions();
|
||||
@@ -785,6 +796,9 @@ namespace dxvk {
|
||||
}
|
||||
}
|
||||
|
||||
+ if (!m_hasBcFormats)
|
||||
+ return std::string("Device does not support the BC formats required by Direct3D");
|
||||
+
|
||||
if (!m_featuresEnabled.extDescriptorHeap.descriptorHeap && m_properties.core.properties.limits.maxPushConstantsSize < MaxTotalPushDataSize)
|
||||
return str::format("Device does not support ", MaxTotalPushDataSize, " of push data");
|
||||
|
||||
@@ -886,7 +900,7 @@ namespace dxvk {
|
||||
ENABLE_FEATURE(core.features, shaderResourceResidency, false),
|
||||
ENABLE_FEATURE(core.features, shaderResourceMinLod, false),
|
||||
ENABLE_FEATURE(core.features, tessellationShader, false),
|
||||
- ENABLE_FEATURE(core.features, textureCompressionBC, true),
|
||||
+ ENABLE_FEATURE(core.features, textureCompressionBC, false),
|
||||
ENABLE_FEATURE(core.features, variableMultisampleRate, false),
|
||||
ENABLE_FEATURE(core.features, vertexPipelineStoresAndAtomics, false),
|
||||
ENABLE_FEATURE(core.features, wideLines, false),
|
||||
diff --git a/src/dxvk/dxvk_device_info.h b/src/dxvk/dxvk_device_info.h
|
||||
index 0a55f90..8bbc770 100644
|
||||
--- a/src/dxvk/dxvk_device_info.h
|
||||
+++ b/src/dxvk/dxvk_device_info.h
|
||||
@@ -394,6 +394,7 @@ namespace dxvk {
|
||||
|
||||
DxvkDeviceQueueMapping m_queueMapping = { };
|
||||
|
||||
+ bool m_hasBcFormats = false;
|
||||
bool m_hasMeshShader = false;
|
||||
bool m_hasFmask = false;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
diff --git a/src/dxvk/dxvk_presenter.cpp b/src/dxvk/dxvk_presenter.cpp
|
||||
index 643f7c5..4dc8c4d 100644
|
||||
--- a/src/dxvk/dxvk_presenter.cpp
|
||||
+++ b/src/dxvk/dxvk_presenter.cpp
|
||||
@@ -161,6 +161,10 @@ namespace dxvk {
|
||||
|
||||
// Return relevant Vulkan objects for the acquired image
|
||||
sync = m_semaphores.at(m_frameIndex);
|
||||
+ // Without a present fence, reacquiring this image is the only guarantee
|
||||
+ // that its previous presentation has consumed the wait semaphore.
|
||||
+ if (!m_hasSwapchainMaintenance1)
|
||||
+ sync.present = m_semaphores.at(m_imageIndex).present;
|
||||
image = m_images.at(m_imageIndex);
|
||||
|
||||
m_presentPending = true;
|
||||
@@ -239,7 +243,9 @@ namespace dxvk {
|
||||
|
||||
VkPresentInfoKHR info = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR };
|
||||
info.waitSemaphoreCount = 1;
|
||||
- info.pWaitSemaphores = &currSync.present;
|
||||
+ info.pWaitSemaphores = m_hasSwapchainMaintenance1
|
||||
+ ? &currSync.present
|
||||
+ : &m_semaphores.at(m_imageIndex).present;
|
||||
info.swapchainCount = 1;
|
||||
info.pSwapchains = &m_swapchain;
|
||||
info.pImageIndices = &m_imageIndex;
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/src/dxvk/hud/shaders/hud_frame_time_eval.comp
|
||||
+++ b/src/dxvk/hud/shaders/hud_frame_time_eval.comp
|
||||
@@ -41,7 +41,8 @@
|
||||
draw_info_t draw_infos[];
|
||||
};
|
||||
|
||||
-layout(binding = 3)
|
||||
+// The bound text view is VK_FORMAT_R8_UINT; do not require formatless writes.
|
||||
+layout(binding = 3, r8ui)
|
||||
uniform writeonly uimageBuffer text_buffer;
|
||||
|
||||
layout(push_constant)
|
||||
@@ -0,0 +1,86 @@
|
||||
diff --git a/dxvk.conf b/dxvk.conf
|
||||
index ba4bc20..26d3127 100644
|
||||
--- a/dxvk.conf
|
||||
+++ b/dxvk.conf
|
||||
@@ -336,6 +336,15 @@
|
||||
|
||||
# d3d11.disableMsaa = False
|
||||
|
||||
+# Forces D3D9 surfaces to single-sample after validating the original request.
|
||||
+# The effective surface description reports D3DMULTISAMPLE_NONE; MSAA quality,
|
||||
+# alpha-to-coverage and per-sample masks are consequently disabled. This is an
|
||||
+# opt-in compatibility override for games with broken MSAA rendering.
|
||||
+#
|
||||
+# Supported values: True, False
|
||||
+
|
||||
+# d3d9.forceSingleSample = False
|
||||
+
|
||||
|
||||
# Forces insertion of memory and control barriers after writes to group-shared
|
||||
# memory in compute shaders. This is only intended to be used as a workaround
|
||||
diff --git a/src/d3d9/d3d9_common_texture.cpp b/src/d3d9/d3d9_common_texture.cpp
|
||||
index 9d5fe38..629fea3 100644
|
||||
--- a/src/d3d9/d3d9_common_texture.cpp
|
||||
+++ b/src/d3d9/d3d9_common_texture.cpp
|
||||
@@ -212,6 +212,15 @@ namespace dxvk {
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
+ // Keep original request validation above. This opt-in override changes
|
||||
+ // the effective surface description as well as the backing image.
|
||||
+ // All surface descriptors and resolves then see the actual sample count.
|
||||
+ if (ResourceType == D3DRTYPE_SURFACE && options->forceSingleSample
|
||||
+ && sampleCount != VK_SAMPLE_COUNT_1_BIT) {
|
||||
+ pDesc->MultiSample = D3DMULTISAMPLE_NONE;
|
||||
+ pDesc->MultisampleQuality = 0;
|
||||
+ }
|
||||
+
|
||||
// Using MANAGED pool with DYNAMIC usage is illegal
|
||||
if (IsPoolManaged(pDesc->Pool) && (pDesc->Usage & D3DUSAGE_DYNAMIC))
|
||||
return D3DERR_INVALIDCALL;
|
||||
diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp
|
||||
index e46864e..0cab7dc 100644
|
||||
--- a/src/d3d9/d3d9_options.cpp
|
||||
+++ b/src/d3d9/d3d9_options.cpp
|
||||
@@ -59,6 +59,7 @@ namespace dxvk {
|
||||
this->memoryTrackTest = config.getOption<bool> ("d3d9.memoryTrackTest", false);
|
||||
this->forceSamplerTypeSpecConstants = config.getOption<bool> ("d3d9.forceSamplerTypeSpecConstants", false);
|
||||
this->forceSampleRateShading = config.getOption<bool> ("d3d9.forceSampleRateShading", false);
|
||||
+ this->forceSingleSample = config.getOption<bool> ("d3d9.forceSingleSample", false);
|
||||
this->forceAspectRatio = config.getOption<std::string> ("d3d9.forceAspectRatio", "");
|
||||
this->forceRefreshRate = config.getOption<int32_t> ("d3d9.forceRefreshRate", 0u);
|
||||
this->modeCountCompatibility = config.getOption<bool> ("d3d9.modeCountCompatibility", false);
|
||||
diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h
|
||||
index e69a39a..4478420 100644
|
||||
--- a/src/d3d9/d3d9_options.h
|
||||
+++ b/src/d3d9/d3d9_options.h
|
||||
@@ -113,6 +113,9 @@ namespace dxvk {
|
||||
/// Forces sample rate shading
|
||||
bool forceSampleRateShading;
|
||||
|
||||
+ /// Optional compatibility override: report and render surfaces as single-sample.
|
||||
+ bool forceSingleSample;
|
||||
+
|
||||
/// Allow D3DLOCK_DISCARD
|
||||
bool allowDiscard;
|
||||
|
||||
diff --git a/src/d3d9/d3d9_swapchain.cpp b/src/d3d9/d3d9_swapchain.cpp
|
||||
--- a/src/d3d9/d3d9_swapchain.cpp
|
||||
+++ b/src/d3d9/d3d9_swapchain.cpp
|
||||
@@ -1055,1 +1055,16 @@ namespace dxvk {
|
||||
+ if (m_parent->GetOptions()->forceSingleSample) {
|
||||
+ // Backbuffers bypass the normal surface-creation entry points. Validate
|
||||
+ // the application's request, then apply the same effective sample count.
|
||||
+ // IsLockable above is an internal GDI fallback requirement, not the
|
||||
+ // application's lockability request used by MSAA validation.
|
||||
+ auto requestedDesc = desc;
|
||||
+ requestedDesc.IsLockable = (Flags & D3DPRESENTFLAG_LOCKABLE_BACKBUFFER) != 0;
|
||||
+ HRESULT hr = D3D9CommonTexture::NormalizeTextureProperties(
|
||||
+ m_parent, D3DRTYPE_SURFACE, &requestedDesc);
|
||||
+ if (FAILED(hr))
|
||||
+ return hr;
|
||||
+ desc.MultiSample = requestedDesc.MultiSample;
|
||||
+ desc.MultisampleQuality = requestedDesc.MultisampleQuality;
|
||||
+ }
|
||||
+
|
||||
const bool isExtended = m_parent->IsD3DCompatibile(D3DCompatibility::D3D9Ex);
|
||||
@@ -0,0 +1 @@
|
||||
DXVK_REVISION=25ca63f17f34bdc05a39873ee63907d3cbbfa030
|
||||
@@ -0,0 +1,214 @@
|
||||
// Backend/adapter fixture for the verbatim DXVK functions in d3d9_production.inc.
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using HRESULT = int32_t;
|
||||
using DWORD = uint32_t;
|
||||
using UINT = uint32_t;
|
||||
using VkSampleCountFlagBits = uint32_t;
|
||||
constexpr HRESULT D3D_OK = 0, D3DERR_INVALIDCALL = -1,
|
||||
D3DERR_NOTAVAILABLE = -2, D3DERR_OUTOFVIDEOMEMORY = -3;
|
||||
constexpr uint32_t VK_SAMPLE_COUNT_1_BIT = 1, VK_IMAGE_ASPECT_COLOR_BIT = 1;
|
||||
constexpr bool FALSE = false, TRUE = true;
|
||||
#define FAILED(x) ((x) < 0)
|
||||
#define unlikely(x) (x)
|
||||
enum D3DMULTISAMPLE_TYPE { D3DMULTISAMPLE_NONE, D3DMULTISAMPLE_NONMASKABLE,
|
||||
D3DMULTISAMPLE_16_SAMPLES = 16 };
|
||||
enum D3DRESOURCETYPE { D3DRTYPE_SURFACE, D3DRTYPE_CUBETEXTURE, D3DRTYPE_VOLUMETEXTURE };
|
||||
enum D3DPOOL { D3DPOOL_DEFAULT, D3DPOOL_MANAGED, D3DPOOL_SYSTEMMEM, D3DPOOL_SCRATCH };
|
||||
enum class D3DCompatibility { D3D9Ex };
|
||||
enum class D3D9Format { X8R8G8B8, D24S8, A8, NULL_FORMAT, ATI2,
|
||||
D32_LOCKABLE, D32F_LOCKABLE, D16_LOCKABLE, S8_LOCKABLE };
|
||||
constexpr DWORD D3DUSAGE_RENDERTARGET = 1, D3DUSAGE_DEPTHSTENCIL = 2,
|
||||
D3DUSAGE_DYNAMIC = 4, D3DUSAGE_WRITEONLY = 8, D3DUSAGE_AUTOGENMIPMAP = 16;
|
||||
constexpr DWORD D3DPRESENTFLAG_LOCKABLE_BACKBUFFER = 1, D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL = 2;
|
||||
constexpr int D3DDEVTYPE_HAL = 1, VK_IMAGE_LAYOUT_UNDEFINED = 0;
|
||||
struct Extent { uint32_t width, height, depth = 1; };
|
||||
namespace util {
|
||||
uint32_t computeMipLevelCount(Extent e) {
|
||||
uint32_t n = std::max({e.width, e.height, e.depth}), levels = 0;
|
||||
do { ++levels; n >>= 1; } while (n);
|
||||
return levels;
|
||||
}
|
||||
}
|
||||
bool IsPoolManaged(D3DPOOL pool) { return pool == D3DPOOL_MANAGED; }
|
||||
bool IsDXTFormat(D3D9Format) { return false; }
|
||||
bool IsDepthStencilFormat(D3D9Format format) { return format == D3D9Format::D24S8; }
|
||||
bool IsLockableDepthStencilFormat(D3D9Format) { return false; }
|
||||
struct D3D9_FORMAT_BLOCK_SIZE { uint32_t Width, Height; };
|
||||
D3D9_FORMAT_BLOCK_SIZE GetFormatAlignedBlockSize(D3D9Format) { return {1, 1}; }
|
||||
D3D9Format EnumerateFormat(D3D9Format format) { return format; }
|
||||
struct D3D9_COMMON_TEXTURE_DESC {
|
||||
uint32_t Width = 1280, Height = 720, Depth = 1, MipLevels = 1, ArraySize = 1;
|
||||
D3D9Format Format = D3D9Format::X8R8G8B8;
|
||||
D3DMULTISAMPLE_TYPE MultiSample = D3DMULTISAMPLE_NONE;
|
||||
DWORD MultisampleQuality = 0;
|
||||
D3DPOOL Pool = D3DPOOL_DEFAULT;
|
||||
DWORD Usage = D3DUSAGE_RENDERTARGET;
|
||||
bool Discard = false, IsBackBuffer = false, IsAttachmentOnly = false, IsLockable = false;
|
||||
};
|
||||
struct D3DPRESENT_PARAMETERS {
|
||||
uint32_t BackBufferWidth = 1280, BackBufferHeight = 720;
|
||||
D3D9Format BackBufferFormat = D3D9Format::X8R8G8B8;
|
||||
D3DMULTISAMPLE_TYPE MultiSampleType = D3DMULTISAMPLE_TYPE(4);
|
||||
DWORD MultiSampleQuality = 0, Flags = 0;
|
||||
D3D9Format AutoDepthStencilFormat = D3D9Format::D24S8;
|
||||
};
|
||||
struct Options {
|
||||
bool forceSingleSample = false, extraFrontbuffer = false,
|
||||
disableA8RT = false, supportCubeDepthFormats = false;
|
||||
};
|
||||
struct FormatMapping {
|
||||
uint32_t Aspect;
|
||||
bool IsValid() const { return true; }
|
||||
};
|
||||
struct Adapter {
|
||||
bool supported = true;
|
||||
std::vector<D3DMULTISAMPLE_TYPE> checked;
|
||||
HRESULT CheckDeviceMultiSampleType(int, D3D9Format, bool, D3DMULTISAMPLE_TYPE samples, void*) {
|
||||
checked.push_back(samples);
|
||||
return supported ? D3D_OK : D3DERR_NOTAVAILABLE;
|
||||
}
|
||||
};
|
||||
struct ImageInfo { Extent extent; VkSampleCountFlagBits sampleCount; };
|
||||
struct DxvkImage { ImageInfo info; };
|
||||
template<typename T> using Rc = std::shared_ptr<T>;
|
||||
template<typename T, unsigned N> using small_vector = std::vector<T>;
|
||||
struct DxvkContext {
|
||||
unsigned initialized = 0;
|
||||
void initImage(const Rc<DxvkImage>&, int) { ++initialized; }
|
||||
};
|
||||
struct D3D9DeviceEx {
|
||||
Options options;
|
||||
Adapter adapter;
|
||||
DxvkContext context;
|
||||
unsigned attempts = 0, failAt = 0, losable = 0, live = 0, injected = 0;
|
||||
std::vector<D3D9_COMMON_TEXTURE_DESC> created;
|
||||
Options* GetOptions() { return &options; }
|
||||
Adapter* GetAdapter() { return &adapter; }
|
||||
FormatMapping LookupFormat(D3D9Format format) { return {IsDepthStencilFormat(format) ? 2u : 1u}; }
|
||||
struct Unsupported { unsigned elementSize = 0; };
|
||||
Unsupported unsupported;
|
||||
const Unsupported* UnsupportedFormatInfo(D3D9Format) { return &unsupported; }
|
||||
bool IsD3DCompatibile(D3DCompatibility) { return false; }
|
||||
void IncrementLosableCounter() { ++losable; }
|
||||
template<typename F> void InjectCs(F function) { ++injected; function(&context); }
|
||||
};
|
||||
HRESULT DecodeMultiSampleType(D3DMULTISAMPLE_TYPE, DWORD, VkSampleCountFlagBits*);
|
||||
struct D3D9CommonTexture {
|
||||
Rc<DxvkImage> image;
|
||||
const Rc<DxvkImage>& GetImage() const { return image; }
|
||||
static HRESULT NormalizeTextureProperties(D3D9DeviceEx*, D3DRESOURCETYPE, D3D9_COMMON_TEXTURE_DESC*);
|
||||
/* PRODUCTION_USES_IMAGE */
|
||||
};
|
||||
class DxvkError : public std::runtime_error {
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
std::string message() const { return what(); }
|
||||
};
|
||||
struct Logger { static void err(const std::string&) {} };
|
||||
struct D3D9SwapChainEx;
|
||||
struct D3D9Surface {
|
||||
D3D9CommonTexture texture;
|
||||
D3D9DeviceEx* device;
|
||||
D3D9Surface(D3D9DeviceEx* d, D3D9_COMMON_TEXTURE_DESC* desc, bool, D3D9SwapChainEx*, void*) : device(d) {
|
||||
if (++d->attempts == d->failAt) throw DxvkError("controlled allocation failure");
|
||||
VkSampleCountFlagBits samples;
|
||||
if (FAILED(DecodeMultiSampleType(desc->MultiSample, desc->MultisampleQuality, &samples)))
|
||||
throw DxvkError("invalid backend sample count");
|
||||
texture.image = std::make_shared<DxvkImage>(DxvkImage{{{desc->Width, desc->Height}, samples}});
|
||||
d->created.push_back(*desc); ++d->live;
|
||||
}
|
||||
~D3D9Surface() { --device->live; }
|
||||
D3D9CommonTexture* GetCommonTexture() { return &texture; }
|
||||
};
|
||||
struct D3D9SwapChainEx {
|
||||
D3D9DeviceEx* m_parent;
|
||||
D3DPRESENT_PARAMETERS m_presentParams;
|
||||
std::vector<std::unique_ptr<D3D9Surface>> m_backBuffers;
|
||||
bool flip = false;
|
||||
unsigned destroys = 0;
|
||||
bool SwapWithFrontBuffer() { return flip; }
|
||||
void DestroyBackBuffers() { ++destroys; m_backBuffers.clear(); }
|
||||
HRESULT CreateBackBuffers(uint32_t, DWORD);
|
||||
};
|
||||
#include "d3d9_production.inc"
|
||||
|
||||
void paired(bool enabled, D3DMULTISAMPLE_TYPE type, DWORD quality) {
|
||||
D3D9DeviceEx device; device.options.forceSingleSample = enabled;
|
||||
device.options.extraFrontbuffer = true;
|
||||
D3D9SwapChainEx chain{&device, {}, {}};
|
||||
chain.m_presentParams.MultiSampleType = type; chain.m_presentParams.MultiSampleQuality = quality;
|
||||
assert(chain.CreateBackBuffers(2, 0) == D3D_OK);
|
||||
D3D9_COMMON_TEXTURE_DESC depth;
|
||||
assert(auto_depth(&device, &chain.m_presentParams, &depth) == D3D_OK);
|
||||
VkSampleCountFlagBits requested, dsSamples;
|
||||
assert(DecodeMultiSampleType(type, quality, &requested) == D3D_OK);
|
||||
assert(DecodeMultiSampleType(depth.MultiSample, depth.MultisampleQuality, &dsSamples) == D3D_OK);
|
||||
assert(chain.m_backBuffers.size() == 3 && device.context.initialized == 3);
|
||||
for (const auto& surface : chain.m_backBuffers) {
|
||||
const auto& image = surface->GetCommonTexture()->GetImage()->info;
|
||||
assert(image.sampleCount == (enabled ? 1u : requested));
|
||||
assert(depth_binds(image, {{depth.Width, depth.Height}, dsSamples}));
|
||||
}
|
||||
for (const auto& desc : device.created) {
|
||||
assert(desc.IsLockable && desc.IsBackBuffer && !desc.IsAttachmentOnly);
|
||||
assert(desc.MultiSample == (enabled ? D3DMULTISAMPLE_NONE : type));
|
||||
assert(desc.MultisampleQuality == (enabled ? 0u : quality));
|
||||
}
|
||||
// Original presentation parameters remain available for reset/auto-depth validation.
|
||||
assert(chain.m_presentParams.MultiSampleType == type && chain.m_presentParams.MultiSampleQuality == quality);
|
||||
if (enabled && requested > 1) assert(device.adapter.checked.front() == D3DMULTISAMPLE_TYPE(requested));
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
assert(argc == 2); std::string name = argv[1];
|
||||
if (name == "forced_msaa_depth") paired(true, D3DMULTISAMPLE_TYPE(4), 0);
|
||||
else if (name == "default_msaa_depth") paired(false, D3DMULTISAMPLE_TYPE(4), 0);
|
||||
else if (name == "forced_nonmaskable") paired(true, D3DMULTISAMPLE_NONMASKABLE, 2);
|
||||
else if (name == "default_nonmaskable") paired(false, D3DMULTISAMPLE_NONMASKABLE, 2);
|
||||
else if (name == "forced_already_single") paired(true, D3DMULTISAMPLE_NONE, 0);
|
||||
else if (name == "forced_no_depth" || name == "forced_lockable_single") {
|
||||
D3D9DeviceEx d; d.options.forceSingleSample = true;
|
||||
D3D9SwapChainEx c{&d, {}, {}};
|
||||
if (name == "forced_lockable_single") c.m_presentParams.MultiSampleType = D3DMULTISAMPLE_NONE;
|
||||
assert(c.CreateBackBuffers(1, name == "forced_lockable_single" ? D3DPRESENTFLAG_LOCKABLE_BACKBUFFER : 0) == D3D_OK);
|
||||
assert(c.m_backBuffers.size() == 1 && d.created[0].MultiSample == D3DMULTISAMPLE_NONE);
|
||||
assert(d.created[0].IsLockable && d.context.initialized == 1);
|
||||
} else if (name == "forced_unsupported" || name == "forced_invalid_type" || name == "forced_lockable_msaa") {
|
||||
D3D9DeviceEx d; d.options.forceSingleSample = true;
|
||||
D3D9SwapChainEx c{&d, {}, {}};
|
||||
if (name == "forced_unsupported") d.adapter.supported = false;
|
||||
if (name == "forced_invalid_type") c.m_presentParams.MultiSampleType = D3DMULTISAMPLE_TYPE(17);
|
||||
HRESULT expected = name == "forced_unsupported" ? D3DERR_NOTAVAILABLE : D3DERR_INVALIDCALL;
|
||||
assert(c.CreateBackBuffers(2, name == "forced_lockable_msaa" ? D3DPRESENTFLAG_LOCKABLE_BACKBUFFER : 0) == expected);
|
||||
assert(d.attempts == 0 && d.losable == 0 && d.injected == 0 && c.m_backBuffers.empty());
|
||||
} else if (name == "forced_allocation_failure" || name == "default_allocation_failure") {
|
||||
D3D9DeviceEx d; d.options.forceSingleSample = name == "forced_allocation_failure"; d.failAt = 2;
|
||||
D3D9SwapChainEx c{&d, {}, {}};
|
||||
assert(c.CreateBackBuffers(3, 0) == D3DERR_OUTOFVIDEOMEMORY);
|
||||
assert(d.attempts == 2 && d.losable == 1 && d.live == 0 && d.injected == 0 && c.m_backBuffers.empty());
|
||||
} else if (name == "forced_recreate") {
|
||||
D3D9DeviceEx d; d.options.forceSingleSample = true;
|
||||
D3D9SwapChainEx c{&d, {}, {}};
|
||||
assert(c.CreateBackBuffers(3, 0) == D3D_OK);
|
||||
c.m_presentParams.MultiSampleType = D3DMULTISAMPLE_TYPE(8);
|
||||
assert(c.CreateBackBuffers(1, 0) == D3D_OK);
|
||||
assert(d.live == 1 && c.m_backBuffers.size() == 1 && c.destroys == 2);
|
||||
assert(d.adapter.checked.size() == 2 && d.adapter.checked.back() == D3DMULTISAMPLE_TYPE(8));
|
||||
assert(c.m_backBuffers[0]->GetCommonTexture()->GetImage()->info.sampleCount == 1);
|
||||
} else if (name == "ordinary_surface" || name == "ordinary_invalid_lockable") {
|
||||
D3D9DeviceEx d; d.options.forceSingleSample = true;
|
||||
D3D9_COMMON_TEXTURE_DESC desc; desc.MultiSample = D3DMULTISAMPLE_TYPE(4);
|
||||
desc.IsLockable = name == "ordinary_invalid_lockable";
|
||||
assert(D3D9CommonTexture::NormalizeTextureProperties(&d, D3DRTYPE_SURFACE, &desc)
|
||||
== (desc.IsLockable ? D3DERR_INVALIDCALL : D3D_OK));
|
||||
if (!desc.IsLockable) assert(desc.MultiSample == D3DMULTISAMPLE_NONE && desc.MultisampleQuality == 0);
|
||||
} else assert(false);
|
||||
return 0;
|
||||
}
|
||||
@@ -64,14 +64,79 @@ library list, before anything is published.
|
||||
refresh output they now wait for it too, for at most `external_overlay_hold_cycles` refreshes (4,
|
||||
so 30 fps at 120 Hz still merges), and are painted on their own after that.
|
||||
|
||||
The non-Adreno test branch's own patches are numbered 0920-0935 (0120-0135 until main took
|
||||
0121-0125), so they apply after DroidDeck's. Applied in either order the tree is the same.
|
||||
|
||||
The system PowerVR driver uses the existing SDL/Wayland swapchain backend. Its additional patches are:
|
||||
|
||||
- `0920-nested-swapchain-capability-fallback.patch`: negotiate the surface's usages, mutable-format
|
||||
support, image count, alpha and extent; use offscreen composition and GPU copies when required.
|
||||
- `0921-powervr-single-pixel-rcas.patch`: use the existing single-pixel RCAS shader on PowerVR,
|
||||
where the quad variant fails compilation.
|
||||
- `0922-powervr-linear-dmabuf-import.patch`: retain the explicit linear layout when PowerVR
|
||||
rejects the mutable-format query, and intersect imported-image and FD memory-type masks.
|
||||
- `0923-powervr-rgba-copy-surface.patch`: require an advertised RGBA SDR copy surface matching
|
||||
the shader's `rgba8` storage view. The tested workaround leaves other vendors, HDR and direct
|
||||
composition unchanged; it does not restrict game-facing BGRA formats.
|
||||
- `0924-sdl-preserve-explicit-refresh.patch` and `0925-sdl-wait-before-present.patch`: preserve
|
||||
configured refresh across SDL events and finish composition before presenting without a
|
||||
render-finished semaphore. The build runs the focused capability, format and refresh tests.
|
||||
|
||||
Sixteen more of Armada's patches are DRM/lease/HDR-on-KMS work for a native display, which this
|
||||
app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the runtime has.
|
||||
- `0926-explicit-sync-switch.patch`: `GAMESCOPE_DISABLE_EXPLICIT_SYNC=1` makes the nested
|
||||
(Wayland and SDL) backends report no explicit sync, so gamescope does not offer
|
||||
wp_linux_drm_syncobj_manager_v1 and clients use implicit sync. The app sets it on a GPU that is
|
||||
not an Adreno when the kernel is older than 6.6 (no DRM_IOCTL_SYNCOBJ_EVENTFD: an Exynos 2400e
|
||||
on 6.1 logged hundreds of "timeline: DRM_IOCTL_SYNCOBJ_EVENTFD failed" and a game hung at a
|
||||
black screen) or when the render node is Mali's stand-in (/dev/mali0 has no DRM syncobjs).
|
||||
- `0927-shm-buffers-upload-every-commit.patch` (David Cimo, for Mali through Venus; his `0114`): with
|
||||
no DRM node, Xwayland has no glamor and commits a few wl_shm buffers over and over with new pixels.
|
||||
gamescope memoizes one texture per `wlr_buffer`, and a shm buffer's texture is a copy taken at
|
||||
import, so the screen cycled through the first few frames forever while Steam ran on behind them.
|
||||
Only dma-buf textures are memoized now; a shm buffer is uploaded on every commit. Adreno never
|
||||
takes this path, since its Xwayland hands over dma-bufs. Also what XWAYLAND_NO_GLAMOR sessions need.
|
||||
- `0929-log-failing-compute-pipeline.patch`: when `vkCreateComputePipelines` fails, one extra line
|
||||
per shader type names the pipeline (shader type, layer count, ycbcr/colorspace masks, fp16) and the
|
||||
SPIR-V capabilities its shader declares. A Mali-G615 through Venus refused all 119 composite
|
||||
pipelines with VK_ERROR_INITIALIZATION_FAILED and nothing said which feature it objected to.
|
||||
- `0930-composite-without-immutable-ycbcr-samplers.patch`: one composite pipeline is compiled at
|
||||
start-up; when the driver refuses it, the descriptor layout is rebuilt without binding 4's immutable
|
||||
YCbCr samplers (that binding then takes the slot's ordinary sampler) and the probe tried again, with
|
||||
both outcomes in the log. `GAMESCOPE_NO_YCBCR_SAMPLERS=1` forces it. A Mali-G615 through Venus
|
||||
refused every composite shader (blit, blur, RCAS: SPIR-V capabilities Shader, Sampled1D,
|
||||
ImageQuery, no Float16) while EASU, NIS and the NV12 converter, which share the layout but never
|
||||
touch binding 4, compiled.
|
||||
- `0931-memory-type-fallback-keep-probe.patch`: `findMemoryType` asked for DEVICE_LOCAL|HOST_VISIBLE
|
||||
memory falls back to host-visible memory without DEVICE_LOCAL, and a failure logs the requested
|
||||
properties, the type bits and every memory type. The Mali bridge models a unified-memory GPU like a
|
||||
discrete one (host-visible types without DEVICE_LOCAL), so the upload buffer found nothing and the
|
||||
backend failed. Also: 0930's probe pipeline is kept instead of destroyed, and skipped when
|
||||
`GAMESCOPE_NO_YCBCR_SAMPLERS=1` (destroying a pipeline the Venus host had refused killed the
|
||||
render server).
|
||||
- `0932-name-hung-up-waitable.patch`: "IWaitable hung up. Aborting." now names the waitable's class,
|
||||
its fd and what the fd is (`/proc/self/fd`), and the Wayland backend's input thread says why the
|
||||
compositor connection ended (protocol error or errno) first. An S24 FE aborted there after 60/120 Hz
|
||||
flips and after a resume with nothing else in the log.
|
||||
- `0933-flippable-image-unexportable-modifiers.patch`: a flippable (dma-buf exported) image whose
|
||||
modifiers the driver supports but does not report EXPORTABLE uses them anyway, and an image with no
|
||||
usable modifier fails with a log line instead of asserting in `CVulkanTexture::BInit`. The Mali
|
||||
bridge forwards the phone driver's answer, which leaves EXPORTABLE out, though it exports dma-bufs.
|
||||
- `0934-flippable-image-no-backend-modifiers.patch`: when the nested backend offers no modifier at all
|
||||
for a flippable image's format, `CVulkanTexture::BInit` tries linear and logs it instead of asserting
|
||||
`!modifiers.empty()`. NieR Replicant ended the session there on a Pixel 9a under Venus.
|
||||
- `0935-flippable-image-linear-when-driver-rejects-all.patch`: when the driver answers every offered
|
||||
modifier with `VK_ERROR_FORMAT_NOT_SUPPORTED` and linear was among them, the flippable image tries
|
||||
linear anyway; if it cannot be made, `BInit` fails as before. An r32p1 Mali-G610 (Vulkan 1.1) behind
|
||||
the Mali bridge rejected both of the backend's modifiers for AR24, so the session ended at start
|
||||
(0933's "no usable modifier"); the bridge makes such images without the handle type and exports
|
||||
them through a dma-heap.
|
||||
|
||||
- `0116-release-cursor-shm-buffers.patch` - this app: pointer cursor surfaces have no
|
||||
X11/xdg window association, so routing their commits through `g_PendingCommits`
|
||||
retained every old SHM buffer until the surface was destroyed. Ignore cursor-role
|
||||
commits before taking the buffer lock; X11 cursor images still follow the existing
|
||||
MouseCursor path. Window commits awaiting association are unchanged.
|
||||
The shared DroidDeck patch also includes `0116-release-cursor-shm-buffers.patch`: pointer cursor
|
||||
surfaces have no X11/xdg window association, so routing their commits through `g_PendingCommits`
|
||||
retained every old SHM buffer until the surface was destroyed. It ignores cursor-role commits before
|
||||
taking the buffer lock; X11 cursor images still follow the existing MouseCursor path. Window commits
|
||||
awaiting association are unchanged.
|
||||
|
||||
The live regression probe is `tools/tests/test_gamescope_cursor_shm.py`. Run it
|
||||
inside an active Gamescope session with access to that process's `/proc` fd
|
||||
|
||||
@@ -43,9 +43,12 @@ meson test -C src/build --no-rebuild --print-errorlogs cursor_routing wayland_sc
|
||||
ls -l *.pkg.tar.*
|
||||
"
|
||||
cd "$WORK"
|
||||
g++ -std=c++17 -Wall -Wextra -Werror -UNDEBUG -I pkg/arch/src/gamescope/src \
|
||||
tools/gamescope/tests/nested-swapchain.cpp -o pkg/test-nested-swapchain
|
||||
pkg/test-nested-swapchain
|
||||
rm -rf out && mkdir -p out/usr/local/bin
|
||||
PKG=$(ls pkg/arch/gamescope-*.pkg.tar.* | grep -v -- '-debug-' | head -1)
|
||||
tar --use-compress-program=unzstd -xf "$PKG" -C out --strip-components=2 usr/bin/gamescope
|
||||
tar -xf "$PKG" -C out --strip-components=2 usr/bin/gamescope
|
||||
mv out/gamescope out/usr/local/bin/gamescope
|
||||
chmod 755 out/usr/local/bin/gamescope
|
||||
strip --strip-unneeded out/usr/local/bin/gamescope || true
|
||||
|
||||
@@ -0,0 +1,358 @@
|
||||
diff --git a/src/nested_swapchain.hpp b/src/nested_swapchain.hpp
|
||||
new file mode 100644
|
||||
index 0000000..06fc987
|
||||
--- /dev/null
|
||||
+++ b/src/nested_swapchain.hpp
|
||||
@@ -0,0 +1,53 @@
|
||||
+#pragma once
|
||||
+
|
||||
+#include <algorithm>
|
||||
+#include <vulkan/vulkan_core.h>
|
||||
+
|
||||
+namespace gamescope
|
||||
+{
|
||||
+struct NestedSwapchainConfig
|
||||
+{
|
||||
+ bool copy = false;
|
||||
+ uint32_t imageCount = 0;
|
||||
+ VkImageUsageFlags usage = 0;
|
||||
+ VkCompositeAlphaFlagBitsKHR alpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
|
||||
+ VkExtent2D extent = {};
|
||||
+};
|
||||
+
|
||||
+inline bool ChooseNestedSwapchainConfig( const VkSurfaceCapabilitiesKHR &caps,
|
||||
+ bool mutableFormat, uint32_t width, uint32_t height, NestedSwapchainConfig &config )
|
||||
+{
|
||||
+ constexpr VkImageUsageFlags direct = VK_IMAGE_USAGE_SAMPLED_BIT |
|
||||
+ VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
||||
+ config.copy = !mutableFormat || ( caps.supportedUsageFlags & direct ) != direct;
|
||||
+ config.usage = config.copy ? VkImageUsageFlags{VK_IMAGE_USAGE_TRANSFER_DST_BIT} : direct;
|
||||
+ if ( ( caps.supportedUsageFlags & config.usage ) != config.usage )
|
||||
+ return false;
|
||||
+
|
||||
+ bool foundAlpha = false;
|
||||
+ for ( auto alpha : { VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR, VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR,
|
||||
+ VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR, VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR } )
|
||||
+ {
|
||||
+ if ( caps.supportedCompositeAlpha & alpha )
|
||||
+ {
|
||||
+ config.alpha = alpha;
|
||||
+ foundAlpha = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ if ( !foundAlpha || caps.maxImageExtent.width < caps.minImageExtent.width ||
|
||||
+ caps.maxImageExtent.height < caps.minImageExtent.height )
|
||||
+ return false;
|
||||
+
|
||||
+ config.imageCount = caps.minImageCount + ( caps.minImageCount != UINT32_MAX );
|
||||
+ if ( caps.maxImageCount )
|
||||
+ config.imageCount = std::min( config.imageCount, caps.maxImageCount );
|
||||
+ if ( config.imageCount < caps.minImageCount )
|
||||
+ return false;
|
||||
+ config.extent = caps.currentExtent.width == UINT32_MAX
|
||||
+ ? VkExtent2D{ std::clamp( width, caps.minImageExtent.width, caps.maxImageExtent.width ),
|
||||
+ std::clamp( height, caps.minImageExtent.height, caps.maxImageExtent.height ) }
|
||||
+ : caps.currentExtent;
|
||||
+ return config.extent.width && config.extent.height;
|
||||
+}
|
||||
+}
|
||||
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
||||
index ffad695..ffc8e28 100644
|
||||
--- a/src/rendervulkan.cpp
|
||||
+++ b/src/rendervulkan.cpp
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <deque>
|
||||
#include <dlfcn.h>
|
||||
#include "vulkan_include.h"
|
||||
+#include "nested_swapchain.hpp"
|
||||
#include "Utils/Algorithm.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
@@ -450,6 +451,8 @@ bool CVulkanDevice::createDevice()
|
||||
bool hasDrmProps = vulkan_has_drm_props();
|
||||
bool supportsForeignQueue = false;
|
||||
bool supportsHDRMetadata = false;
|
||||
+ bool presentIdExtension = false;
|
||||
+ bool presentWaitExtension = false;
|
||||
for (const auto& ext : m_supportedExts) {
|
||||
if ( strcmp(ext.extensionName, VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME) == 0 )
|
||||
m_bSupportsModifiers = true;
|
||||
@@ -457,6 +460,13 @@ bool CVulkanDevice::createDevice()
|
||||
if ( strcmp(ext.extensionName, VK_EXT_QUEUE_FAMILY_FOREIGN_EXTENSION_NAME) == 0 )
|
||||
supportsForeignQueue = true;
|
||||
|
||||
+ if ( strcmp(ext.extensionName, VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME) == 0 )
|
||||
+ m_bSupportsMutableSwapchain = true;
|
||||
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_ID_EXTENSION_NAME) == 0 )
|
||||
+ presentIdExtension = true;
|
||||
+ if ( strcmp(ext.extensionName, VK_KHR_PRESENT_WAIT_EXTENSION_NAME) == 0 )
|
||||
+ presentWaitExtension = true;
|
||||
+
|
||||
if ( strcmp(ext.extensionName, VK_EXT_HDR_METADATA_EXTENSION_NAME) == 0 )
|
||||
supportsHDRMetadata = true;
|
||||
}
|
||||
@@ -576,10 +586,24 @@ bool CVulkanDevice::createDevice()
|
||||
if ( GetBackend()->UsesVulkanSwapchain() )
|
||||
{
|
||||
enabledExtensions.push_back( VK_KHR_SWAPCHAIN_EXTENSION_NAME );
|
||||
- enabledExtensions.push_back( VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME );
|
||||
+ if ( m_bSupportsMutableSwapchain )
|
||||
+ enabledExtensions.push_back( VK_KHR_SWAPCHAIN_MUTABLE_FORMAT_EXTENSION_NAME );
|
||||
|
||||
- enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
||||
- enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
||||
+ if ( presentIdExtension && presentWaitExtension )
|
||||
+ {
|
||||
+ VkPhysicalDevicePresentWaitFeaturesKHR wait = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_WAIT_FEATURES_KHR };
|
||||
+ VkPhysicalDevicePresentIdFeaturesKHR id = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PRESENT_ID_FEATURES_KHR, .pNext = &wait };
|
||||
+ VkPhysicalDeviceFeatures2 features = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2, .pNext = &id };
|
||||
+ vk.GetPhysicalDeviceFeatures2( physDev(), &features );
|
||||
+ m_bSupportsPresentWait = id.presentId && wait.presentWait;
|
||||
+ }
|
||||
+ if ( m_bSupportsPresentWait )
|
||||
+ {
|
||||
+ enabledExtensions.push_back( VK_KHR_PRESENT_ID_EXTENSION_NAME );
|
||||
+ enabledExtensions.push_back( VK_KHR_PRESENT_WAIT_EXTENSION_NAME );
|
||||
+ }
|
||||
+ else
|
||||
+ vk_log.infof( "Using FIFO acquire pacing; presentation timestamps unavailable" );
|
||||
|
||||
if ( supportsHDRMetadata )
|
||||
enabledExtensions.push_back( VK_EXT_HDR_METADATA_EXTENSION_NAME );
|
||||
@@ -654,7 +678,7 @@ bool CVulkanDevice::createDevice()
|
||||
|
||||
VkPhysicalDeviceFeatures2 features2 = {
|
||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
||||
- .pNext = &presentIdFeatures,
|
||||
+ .pNext = m_bSupportsPresentWait ? static_cast<void *>( &presentIdFeatures ) : static_cast<void *>( &features13 ),
|
||||
.features = {
|
||||
.shaderInt16 = m_bSupportsFp16,
|
||||
},
|
||||
@@ -2660,7 +2684,7 @@ bool CVulkanTexture::BInit( uint32_t width, uint32_t height, uint32_t depth, uin
|
||||
return true;
|
||||
}
|
||||
|
||||
-bool CVulkanTexture::BInitFromSwapchain( VkImage image, uint32_t width, uint32_t height, VkFormat format )
|
||||
+bool CVulkanTexture::BInitFromSwapchain( VkImage image, uint32_t width, uint32_t height, VkFormat format, bool transferOnly )
|
||||
{
|
||||
m_drmFormat = VulkanFormatToDRM( format );
|
||||
m_vkImage = image;
|
||||
@@ -2672,6 +2696,12 @@ bool CVulkanTexture::BInitFromSwapchain( VkImage image, uint32_t width, uint32_t
|
||||
m_contentWidth = width;
|
||||
m_contentHeight = height;
|
||||
m_bOutputImage = true;
|
||||
+ if ( transferOnly )
|
||||
+ {
|
||||
+ // A copy destination needs no views (and the swapchain need not be mutable).
|
||||
+ m_bInitialized = true;
|
||||
+ return true;
|
||||
+ }
|
||||
|
||||
VkImageViewCreateInfo createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||
@@ -3094,7 +3124,7 @@ void vulkan_present_to_window( void )
|
||||
|
||||
VkPresentInfoKHR presentInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
||||
- .pNext = &presentIdInfo,
|
||||
+ .pNext = g_device.supportsPresentWait() ? &presentIdInfo : nullptr,
|
||||
.swapchainCount = 1,
|
||||
.pSwapchains = &g_output.swapChain,
|
||||
.pImageIndices = &g_output.nOutImage,
|
||||
@@ -3102,14 +3132,22 @@ void vulkan_present_to_window( void )
|
||||
|
||||
if ( g_device.vk.QueuePresentKHR( g_device.queue(), &presentInfo ) == VK_SUCCESS )
|
||||
{
|
||||
- g_currentPresentWaitId = presentId;
|
||||
- g_currentPresentWaitId.notify_all();
|
||||
+ if ( g_device.supportsPresentWait() )
|
||||
+ {
|
||||
+ g_currentPresentWaitId = presentId;
|
||||
+ g_currentPresentWaitId.notify_all();
|
||||
+ }
|
||||
}
|
||||
else
|
||||
vulkan_remake_swapchain();
|
||||
|
||||
while ( !acquire_next_image() )
|
||||
vulkan_remake_swapchain();
|
||||
+ if ( !g_device.supportsPresentWait() )
|
||||
+ {
|
||||
+ // Estimated scheduling anchor after FIFO buffer acquisition, not presentation feedback.
|
||||
+ GetVBlankTimer().MarkVBlank( get_time_in_nanos(), true );
|
||||
+ }
|
||||
}
|
||||
|
||||
gamescope::Rc<CVulkanTexture> vulkan_create_1d_lut(uint32_t size)
|
||||
@@ -3219,7 +3257,19 @@ extern bool g_bOutputHDREnabled;
|
||||
|
||||
bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
{
|
||||
- uint32_t imageCount = pOutput->surfaceCaps.minImageCount + 1;
|
||||
+ // Re-query on resize as well as initial creation.
|
||||
+ if ( g_device.vk.GetPhysicalDeviceSurfaceCapabilitiesKHR( g_device.physDev(), pOutput->surface, &pOutput->surfaceCaps ) != VK_SUCCESS )
|
||||
+ return false;
|
||||
+ gamescope::NestedSwapchainConfig config;
|
||||
+ if ( !gamescope::ChooseNestedSwapchainConfig( pOutput->surfaceCaps, g_device.supportsMutableSwapchain(), g_nOutputWidth, g_nOutputHeight, config ) )
|
||||
+ {
|
||||
+ vk_log.errorf( "Surface supports neither direct composition nor transfer presentation" );
|
||||
+ return false;
|
||||
+ }
|
||||
+ pOutput->copyToSwapchain = config.copy;
|
||||
+ g_nOutputWidth = config.extent.width;
|
||||
+ g_nOutputHeight = config.extent.height;
|
||||
+ uint32_t imageCount = config.imageCount;
|
||||
uint32_t formatCount = pOutput->surfaceFormats.size();
|
||||
uint32_t surfaceFormat = formatCount;
|
||||
VkColorSpaceKHR preferredColorSpace = g_bOutputHDREnabled ? VK_COLOR_SPACE_HDR10_ST2084_EXT : VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
@@ -3254,6 +3304,13 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
}
|
||||
}
|
||||
|
||||
+ if ( surfaceFormat == formatCount )
|
||||
+ {
|
||||
+ for ( surfaceFormat = 0; surfaceFormat < formatCount; ++surfaceFormat )
|
||||
+ if ( pOutput->surfaceFormats[surfaceFormat].format == VK_FORMAT_R8G8B8A8_UNORM &&
|
||||
+ pOutput->surfaceFormats[surfaceFormat].colorSpace == preferredColorSpace )
|
||||
+ break;
|
||||
+ }
|
||||
if ( surfaceFormat == formatCount )
|
||||
return false;
|
||||
|
||||
@@ -3276,8 +3333,8 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
|
||||
VkSwapchainCreateInfoKHR createInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
|
||||
- .pNext = formats[0] != formats[1] ? &usageListInfo : nullptr,
|
||||
- .flags = formats[0] != formats[1] ? VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR : (VkSwapchainCreateFlagBitsKHR )0,
|
||||
+ .pNext = !config.copy && formats[0] != formats[1] ? &usageListInfo : nullptr,
|
||||
+ .flags = !config.copy && formats[0] != formats[1] ? VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR : (VkSwapchainCreateFlagBitsKHR )0,
|
||||
.surface = pOutput->surface,
|
||||
.minImageCount = imageCount,
|
||||
.imageFormat = eVkFormat,
|
||||
@@ -3287,10 +3344,10 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
.height = g_nOutputHeight,
|
||||
},
|
||||
.imageArrayLayers = 1,
|
||||
- .imageUsage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT,
|
||||
+ .imageUsage = config.usage,
|
||||
.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
|
||||
.preTransform = pOutput->surfaceCaps.currentTransform,
|
||||
- .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
|
||||
+ .compositeAlpha = config.alpha,
|
||||
.presentMode = VK_PRESENT_MODE_FIFO_KHR,
|
||||
.clipped = VK_TRUE,
|
||||
};
|
||||
@@ -3304,12 +3361,30 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
g_device.vk.GetSwapchainImagesKHR( g_device.device(), pOutput->swapChain, &imageCount, swapchainImages.data() );
|
||||
|
||||
pOutput->outputImages.resize(imageCount);
|
||||
+ pOutput->presentationImages.clear();
|
||||
+ if ( config.copy )
|
||||
+ {
|
||||
+ vk_log.infof( "Nested swapchain: composing offscreen and copying to FIFO presentation images" );
|
||||
+ pOutput->presentationImages.resize(imageCount);
|
||||
+ }
|
||||
|
||||
for ( uint32_t i = 0; i < pOutput->outputImages.size(); i++ )
|
||||
{
|
||||
pOutput->outputImages[i] = new CVulkanTexture();
|
||||
|
||||
- if ( !pOutput->outputImages[i]->BInitFromSwapchain(swapchainImages[i], g_nOutputWidth, g_nOutputHeight, eVkFormat))
|
||||
+ if ( config.copy )
|
||||
+ {
|
||||
+ CVulkanTexture::createFlags flags;
|
||||
+ flags.bStorage = true;
|
||||
+ flags.bSampled = true;
|
||||
+ flags.bTransferSrc = true;
|
||||
+ if ( !pOutput->outputImages[i]->BInit( g_nOutputWidth, g_nOutputHeight, 1, pOutput->uOutputFormat, flags ) )
|
||||
+ return false;
|
||||
+ pOutput->presentationImages[i] = new CVulkanTexture();
|
||||
+ if ( !pOutput->presentationImages[i]->BInitFromSwapchain( swapchainImages[i], g_nOutputWidth, g_nOutputHeight, eVkFormat, true ) )
|
||||
+ return false;
|
||||
+ }
|
||||
+ else if ( !pOutput->outputImages[i]->BInitFromSwapchain(swapchainImages[i], g_nOutputWidth, g_nOutputHeight, eVkFormat))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3335,6 +3410,10 @@ bool vulkan_remake_swapchain( void )
|
||||
g_device.vk.QueueWaitIdle( g_device.queue() );
|
||||
|
||||
pOutput->outputImages.clear();
|
||||
+ pOutput->presentationImages.clear();
|
||||
+ if ( pOutput->acquireFence )
|
||||
+ g_device.vk.DestroyFence( g_device.device(), pOutput->acquireFence, nullptr );
|
||||
+ pOutput->acquireFence = VK_NULL_HANDLE;
|
||||
|
||||
g_device.vk.DestroySwapchainKHR( g_device.device(), pOutput->swapChain, nullptr );
|
||||
|
||||
@@ -3670,7 +3749,7 @@ bool vulkan_init( VkInstance instance, VkSurfaceKHR surface )
|
||||
if (!init_nis_data())
|
||||
return false;
|
||||
|
||||
- if ( GetBackend()->UsesVulkanSwapchain() )
|
||||
+ if ( GetBackend()->UsesVulkanSwapchain() && g_device.supportsPresentWait() )
|
||||
{
|
||||
std::thread present_wait_thread( present_wait_thread_func );
|
||||
present_wait_thread.detach();
|
||||
@@ -4579,6 +4658,9 @@ std::optional<uint64_t> vulkan_composite( struct FrameInfo_t *frameInfo, gamesco
|
||||
CompositeTimingEnd( cmdBuffer.get(), *oTimingSlot, pszKey, pszKeyPre, pszKeyPost );
|
||||
}
|
||||
|
||||
+ if ( !pOutputOverride && g_output.copyToSwapchain )
|
||||
+ cmdBuffer->copyImage( compositeImage, g_output.presentationImages[g_output.nOutImage] );
|
||||
+
|
||||
uint64_t sequence = g_device.submit(std::move(cmdBuffer));
|
||||
if ( oTimingSlot )
|
||||
g_CompositeTiming.pending.back().ulSeqNo = sequence;
|
||||
diff --git a/src/rendervulkan.hpp b/src/rendervulkan.hpp
|
||||
index fa519db..674a3b4 100644
|
||||
--- a/src/rendervulkan.hpp
|
||||
+++ b/src/rendervulkan.hpp
|
||||
@@ -162,7 +162,7 @@ public:
|
||||
};
|
||||
|
||||
bool BInit( uint32_t width, uint32_t height, uint32_t depth, uint32_t drmFormat, createFlags flags, wlr_dmabuf_attributes *pDMA = nullptr, uint32_t contentWidth = 0, uint32_t contentHeight = 0, CVulkanTexture *pExistingImageToReuseMemory = nullptr, gamescope::OwningRc<gamescope::IBackendFb> pBackendFb = nullptr );
|
||||
- bool BInitFromSwapchain( VkImage image, uint32_t width, uint32_t height, VkFormat format );
|
||||
+ bool BInitFromSwapchain( VkImage image, uint32_t width, uint32_t height, VkFormat format, bool transferOnly = false );
|
||||
|
||||
uint32_t IncRef();
|
||||
uint32_t DecRef();
|
||||
@@ -586,7 +586,9 @@ struct VulkanOutput_t
|
||||
|
||||
std::shared_ptr<gamescope::BackendBlob> swapchainHDRMetadata;
|
||||
VkSwapchainKHR swapChain;
|
||||
- VkFence acquireFence;
|
||||
+ VkFence acquireFence = VK_NULL_HANDLE;
|
||||
+ bool copyToSwapchain = false;
|
||||
+ std::vector<gamescope::OwningRc<CVulkanTexture>> presentationImages;
|
||||
|
||||
uint32_t nOutImage; // swapchain index in nested mode, or ping/pong between two RTs
|
||||
std::vector<gamescope::OwningRc<CVulkanTexture>> outputImages;
|
||||
@@ -756,6 +758,7 @@ static inline uint32_t div_roundup(uint32_t x, uint32_t y)
|
||||
VK_FUNC(CreateDescriptorPool) \
|
||||
VK_FUNC(CreateDescriptorSetLayout) \
|
||||
VK_FUNC(CreateFence) \
|
||||
+ VK_FUNC(DestroyFence) \
|
||||
VK_FUNC(CreateGraphicsPipelines) \
|
||||
VK_FUNC(CreateImage) \
|
||||
VK_FUNC(CreateImageView) \
|
||||
@@ -862,6 +865,8 @@ public:
|
||||
inline VkPipelineLayout pipelineLayout() {return m_pipelineLayout;}
|
||||
inline int drmRenderFd() {return m_drmRendererFd;}
|
||||
inline bool supportsModifiers() {return m_bSupportsModifiers;}
|
||||
+ inline bool supportsMutableSwapchain() {return m_bSupportsMutableSwapchain;}
|
||||
+ inline bool supportsPresentWait() {return m_bSupportsPresentWait;}
|
||||
inline bool hasDrmPrimaryDevId() {return m_bHasDrmPrimaryDevId;}
|
||||
inline dev_t primaryDevId() {return m_drmPrimaryDevId;}
|
||||
inline bool supportsFp16() {return m_bSupportsFp16;}
|
||||
@@ -930,6 +935,8 @@ protected:
|
||||
uint32_t m_uVendorID = 0;
|
||||
bool m_bHasDrmPrimaryDevId = false;
|
||||
bool m_bSupportsModifiers = false;
|
||||
+ bool m_bSupportsMutableSwapchain = false;
|
||||
+ bool m_bSupportsPresentWait = false;
|
||||
bool m_bInitialized = false;
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
||||
--- a/src/rendervulkan.cpp
|
||||
+++ b/src/rendervulkan.cpp
|
||||
@@ -996,8 +996,9 @@
|
||||
SHADER(BLUR, cs_composite_blur);
|
||||
SHADER(BLUR_COND, cs_composite_blur_cond);
|
||||
SHADER(BLUR_FIRST_PASS, cs_gaussian_blur_horizontal);
|
||||
- // The one pixel layout is only measured on Adreno, every other vendor keeps the quad swizzle.
|
||||
- if (m_uVendorID == 0x5143) /* Qualcomm */
|
||||
+ // PowerVR rejects the quad-swizzled RCAS for 3+ layers with YCbCr mask 2.
|
||||
+ // The existing one-pixel shader compiles those variants and covers the same 16x16 tile.
|
||||
+ if (m_uVendorID == 0x5143 || m_uVendorID == 0x1010) /* Qualcomm or Imagination */
|
||||
{
|
||||
SHADER(RCAS, cs_composite_rcas_1px);
|
||||
}
|
||||
Loaded 100 of 197 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user