Repository navigation
gamescope: frames on the display's real vsync, FIFO under a cap, compositor and game placed by cluster, tuner counts repeated frames (payload 20261102.2) #2320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e85bd64
bc30861
04c5e73
41f7f6b
7306980
23c2d78
e696d2e
b9a041d
a1997fe
49e620d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # libgnaffinity.so provenance | ||
|
|
||
| `app/src/main/jniLibs/arm64-v8a/libgnaffinity.so` is a prebuilt (the app does not run CMake during packaging), | ||
| built from `jni/gnaffinity.c`: | ||
|
|
||
| - sha256: `61272eb70f568de532333ebc6574866eb23b7bd88119975aba2cc16c526650b9` | ||
| - NDK 27.3.13750724, arm64-v8a, android-26, MinSizeRel, `-z max-page-size=16384`, stripped; a rebuild yields the same sha256 | ||
| - build: `app/src/main/cpp/gnaffinity/build.sh`, then | ||
| `cp app/src/main/cpp/gnaffinity/out/libgnaffinity.so app/src/main/jniLibs/arm64-v8a/` | ||
|
|
||
| Exports only `Java_app_gamenative_powercontrol_TaskAffinity_nativeSetTaskAffinity`. Only dependencies: libc, libm, libdl. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/env bash | ||
| # Builds out/libgnaffinity.so (arm64-v8a, stripped, 16 KB pages), then | ||
| # cp out/libgnaffinity.so ../../jniLibs/arm64-v8a/ | ||
| set -euo pipefail | ||
| cd "$(dirname "$0")" | ||
| NDK=${ANDROID_NDK:-$HOME/Library/Android/sdk/ndk/27.3.13750724} | ||
| rm -rf build out; mkdir -p out | ||
| cmake -S jni -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE="$NDK/build/cmake/android.toolchain.cmake" \ | ||
| -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-26 -DCMAKE_BUILD_TYPE=MinSizeRel \ | ||
| -DCMAKE_C_FLAGS="-ffile-prefix-map=$PWD=." | ||
| cmake --build build | ||
| HOST=$(ls "$NDK/toolchains/llvm/prebuilt/") | ||
| "$NDK/toolchains/llvm/prebuilt/$HOST/bin/llvm-strip" --strip-all -o out/libgnaffinity.so build/libgnaffinity.so | ||
| shasum -a 256 out/libgnaffinity.so | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| cmake_minimum_required(VERSION 3.13.5) | ||
| project(gnaffinity C) | ||
| add_library(gnaffinity SHARED gnaffinity.c) | ||
| set_target_properties(gnaffinity PROPERTIES C_VISIBILITY_PRESET hidden) | ||
| target_link_options(gnaffinity PRIVATE -Wl,-z,max-page-size=16384 -Wl,--build-id=none) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #define _GNU_SOURCE | ||
| #include <errno.h> | ||
| #include <jni.h> | ||
| #include <sched.h> | ||
|
|
||
| /* | ||
| * sched_setaffinity on one task (a thread id, or a pid for its main thread). Linux allows it on | ||
| * any task of the caller's uid without CAP_SYS_NICE: the app's own threads and the processes it | ||
| * spawned. Returns 0, or the errno (EPERM, ESRCH, EINVAL). | ||
| */ | ||
| JNIEXPORT jint JNICALL | ||
| Java_app_gamenative_powercontrol_TaskAffinity_nativeSetTaskAffinity(JNIEnv *env, jclass clazz, jint tid, jint mask) { | ||
| (void) env; | ||
| (void) clazz; | ||
| cpu_set_t set; | ||
| CPU_ZERO(&set); | ||
| for (int cpu = 0; cpu < 32; cpu++) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: The affinity bridge truncates CPU sets at 32 CPUs, so cores numbered 32 or higher are silently ignored. Use a dynamically sized Prompt for AI agents |
||
| if ((unsigned) mask & (1u << cpu)) CPU_SET(cpu, &set); | ||
| } | ||
| return sched_setaffinity(tid, sizeof(set), &set) == 0 ? 0 : errno; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| package app.gamenative.display; | ||
|
|
||
| import app.gamenative.powercontrol.PowerManager; | ||
| import com.winlator.container.Container; | ||
| import com.winlator.xenvironment.EnvironmentComponent; | ||
| import com.winlator.xenvironment.ImageFs; | ||
|
|
@@ -52,6 +53,7 @@ private void awaitConnected() { | |
| for (int i = 0; i < START_POLL_TRIES && !stopped; i++) { | ||
| if (gamescopeAnswered()) { | ||
| GamescopeCommandQueue.setApplicable(sessionId, true); | ||
| PowerManager.applyCompositorAffinity("gamescope session start"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: This apply can run after Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return; | ||
| } | ||
| try { | ||
|
|
@@ -83,6 +85,7 @@ public void stop() { | |
| stopped = true; | ||
| GamescopeCommandQueue.reset(); | ||
| GameNativeDrm.nativeInjectorStop(); | ||
| PowerManager.releaseCompositorAffinity("gamescope session end"); | ||
| } | ||
|
|
||
| public void pause() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P3: This reads the NDK override from
ANDROID_NDK, but the rest of the repo documents and usesANDROID_NDK_HOME. A developer who setsANDROID_NDK_HOMEas the README describes gets the default path silently. ReadANDROID_NDK_HOMEhere, withANDROID_NDKas a fallback if you want to keep it.Prompt for AI agents