mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Compare commits
92
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f5c35f088 | ||
|
|
7d95564f7b | ||
|
|
501148e542 | ||
|
|
897e108d8a | ||
|
|
2b9ebd8aee | ||
|
|
0ef9c7924a | ||
|
|
afbd1f2bba | ||
|
|
f89326c709 | ||
|
|
d7f0ce82d8 | ||
|
|
80ec4d7517 | ||
|
|
d2f270d93c | ||
|
|
be7f59d983 | ||
|
|
081e4e1223 | ||
|
|
dfcd07c24d | ||
|
|
1c888d88e9 | ||
|
|
5b07d85296 | ||
|
|
5eea46b9c6 | ||
|
|
1b3c2a77d9 | ||
|
|
8c9904d016 | ||
|
|
ab3d7d96fe | ||
|
|
441773012f | ||
|
|
b1dbfb54da | ||
|
|
61bc8e03b2 | ||
|
|
de573892f2 | ||
|
|
68706c544a | ||
|
|
13a327cfa7 | ||
|
|
8fa2e65a42 | ||
|
|
c16515fc49 | ||
|
|
adb0a27a68 | ||
|
|
056be5f3a1 | ||
|
|
63f5ac5b5e | ||
|
|
7221782940 | ||
|
|
4c90e9175d | ||
|
|
b65af1fa9f | ||
|
|
f7a90151ec | ||
|
|
2748ae9f5a | ||
|
|
784df6260a | ||
|
|
87fbe91940 | ||
|
|
b47a2c9c0e | ||
|
|
597f083ab9 | ||
|
|
4475a122bf | ||
|
|
68a3fa1d52 | ||
|
|
f1dd51f0aa | ||
|
|
1b8187c94a | ||
|
|
60175ec3ec | ||
|
|
9463765104 | ||
|
|
a77abf3293 | ||
|
|
3e0e13468e | ||
|
|
3754f505f4 | ||
|
|
98663031ca | ||
|
|
b581fc8bdc | ||
|
|
574f1f8700 | ||
|
|
b801fb820f | ||
|
|
3c9ba04b23 | ||
|
|
3565752fe9 | ||
|
|
b68437ab63 | ||
|
|
1dfefac571 | ||
|
|
25d97a414b | ||
|
|
12a15a5526 | ||
|
|
d629f83b8c | ||
|
|
404f540709 | ||
|
|
a91c2e8cfd | ||
|
|
9940445ac1 | ||
|
|
6906c65446 | ||
|
|
e559535ca2 | ||
|
|
e9444a0ddc | ||
|
|
41ba1f47c4 | ||
|
|
144a85114e | ||
|
|
7c10d1fa85 | ||
|
|
25dbc97e68 | ||
|
|
536759fca7 | ||
|
|
445a13abf4 | ||
|
|
6f42e1cf1a | ||
|
|
2ba290c2f1 | ||
|
|
5aac22f277 | ||
|
|
ca1f12ebb4 | ||
|
|
af481e5159 | ||
|
|
f90d91bfa1 | ||
|
|
4e2bfa5cdc | ||
|
|
924ad4e9a3 | ||
|
|
ba9b0b0422 | ||
|
|
ae6863d016 | ||
|
|
e418f99aa0 | ||
|
|
a969998075 | ||
|
|
9b673f59fa | ||
|
|
bbb4d11bf0 | ||
|
|
592d03f69a | ||
|
|
146b93dd6c | ||
|
|
aedac67f6d | ||
|
|
1e022e2430 | ||
|
|
1c20437fe6 | ||
|
|
2e170ae12b |
No files matched your search
@@ -7,7 +7,7 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
workflow_run:
|
workflow_run:
|
||||||
workflows: [Build APK, Unit tests]
|
workflows: [Build APK]
|
||||||
types: [completed]
|
types: [completed]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -21,12 +21,6 @@ permissions:
|
|||||||
pull-requests: read
|
pull-requests: read
|
||||||
statuses: write
|
statuses: write
|
||||||
|
|
||||||
# Build APK and Unit tests each trigger a validation, and the last one to post sets the status. Queued runs for a
|
|
||||||
# commit wait, so the newest one reads both results and posts last.
|
|
||||||
concurrency:
|
|
||||||
group: build-validation-${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha || inputs.pr_number || github.sha }}
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
name: Validate source and build result
|
name: Validate source and build result
|
||||||
|
|||||||
+120
-10
@@ -1,5 +1,5 @@
|
|||||||
name: Build APK
|
name: Build APK
|
||||||
run-name: ${{ github.event_name == 'pull_request' && format('building pr {0} on {1} against {2}', github.event.pull_request.number, github.event.pull_request.head.sha, github.event.pull_request.base.sha) || format('building {0} on {1}', github.ref_name, github.sha) }}
|
run-name: ${{ github.event_name == 'pull_request' && format('building pr {0} on {1}', github.event.pull_request.number, github.event.pull_request.head.sha) || format('building {0} on {1}', github.ref_name, github.sha) }}
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@@ -57,18 +57,15 @@ jobs:
|
|||||||
- name: Pin and merge the APK source
|
- name: Pin and merge the APK source
|
||||||
id: merge
|
id: merge
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
env:
|
|
||||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
# Unit tests uses the same event snapshot, including when either workflow is rerun.
|
git fetch --no-tags origin main
|
||||||
git fetch --no-tags origin "$PR_BASE_SHA"
|
echo "base-sha=$(git rev-parse origin/main)" >> "$GITHUB_OUTPUT"
|
||||||
echo "base-sha=$PR_BASE_SHA" >> "$GITHUB_OUTPUT"
|
|
||||||
git config user.name "ci"
|
git config user.name "ci"
|
||||||
git config user.email "ci@users.noreply.github.com"
|
git config user.email "ci@users.noreply.github.com"
|
||||||
# Partial clone: a merged blob that only exists in a fork's history can't be lazily fetched (GitHub: "not our ref"); merge-tree writes it locally first.
|
# Partial clone: a merged blob that only exists in a fork's history can't be lazily fetched (GitHub: "not our ref"); merge-tree writes it locally first.
|
||||||
git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true
|
git merge-tree --write-tree HEAD origin/main >/dev/null || true
|
||||||
git merge --no-ff --no-edit FETCH_HEAD
|
git merge --no-ff --no-edit origin/main
|
||||||
- name: Resolve trusted manifest base
|
- name: Resolve trusted manifest base
|
||||||
id: trusted
|
id: trusted
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
@@ -352,7 +349,7 @@ jobs:
|
|||||||
|
|
||||||
build:
|
build:
|
||||||
needs: [source, components, xbox, build-runner]
|
needs: [source, components, xbox, build-runner]
|
||||||
name: Compile APK
|
name: Compile APK and Android tests
|
||||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
||||||
runs-on: ${{ fromJSON(needs.build-runner.outputs.labels) }}
|
runs-on: ${{ fromJSON(needs.build-runner.outputs.labels) }}
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
@@ -510,7 +507,23 @@ jobs:
|
|||||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||||
BUILD_REF: ${{ github.ref_name }}
|
BUILD_REF: ${{ github.ref_name }}
|
||||||
BUILD_SHA: ${{ github.sha }}
|
BUILD_SHA: ${{ github.sha }}
|
||||||
run: bash tools/ci/build-label.sh
|
run: |
|
||||||
|
if [[ -n "$(git status --porcelain)" ]]; then
|
||||||
|
tree_state=dirty
|
||||||
|
else
|
||||||
|
tree_state=clean
|
||||||
|
fi
|
||||||
|
echo "DROIDDECK_BUILD_TREE_STATE=$tree_state" >> "$GITHUB_ENV"
|
||||||
|
if [[ -n "$PR_NUMBER" ]]; then
|
||||||
|
label="pr${PR_NUMBER} at ${PR_HEAD_SHA:0:7}"
|
||||||
|
else
|
||||||
|
label="${BUILD_REF} at ${BUILD_SHA:0:7}"
|
||||||
|
fi
|
||||||
|
echo "label=$label" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "DROIDDECK_SOURCE_COMMIT=${PR_HEAD_SHA:-$BUILD_SHA}" >> "$GITHUB_ENV"
|
||||||
|
echo "DROIDDECK_PR_NUMBER=${PR_NUMBER:-0}" >> "$GITHUB_ENV"
|
||||||
|
echo "DROIDDECK_PR_TITLE=${PR_TITLE//$'\n'/ }" >> "$GITHUB_ENV"
|
||||||
|
echo "Build: \`$label\`" >> "$GITHUB_STEP_SUMMARY"
|
||||||
|
|
||||||
- name: Rust toolchain for the store engines (aarch64-linux-android)
|
- name: Rust toolchain for the store engines (aarch64-linux-android)
|
||||||
id: rust
|
id: rust
|
||||||
@@ -721,6 +734,101 @@ jobs:
|
|||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
overwrite: true
|
overwrite: true
|
||||||
|
|
||||||
|
- name: Resolve the Robolectric version
|
||||||
|
id: robolectric
|
||||||
|
run: |
|
||||||
|
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
||||||
|
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
||||||
|
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
||||||
|
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
||||||
|
# "..". Runners that keep their own ~/.m2 skip the cache.
|
||||||
|
- name: Place Robolectric's Android jars beside the workspace
|
||||||
|
id: robolectric-jars
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
||||||
|
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
||||||
|
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
||||||
|
echo "cache=false" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
mkdir -p "$jars" "$(dirname "$m2")"
|
||||||
|
jars=$(cd "$jars" && pwd)
|
||||||
|
ln -sfn "$jars" "$m2"
|
||||||
|
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "cache=true" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
- name: Restore Robolectric's Android jars
|
||||||
|
id: robolectric-cache
|
||||||
|
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||||
|
uses: actions/cache/restore@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||||
|
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||||
|
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
||||||
|
- name: Count the restored Robolectric jars
|
||||||
|
if: steps.robolectric-jars.outputs.cache == 'true'
|
||||||
|
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
||||||
|
- name: Unit tests
|
||||||
|
id: unit-tests
|
||||||
|
env:
|
||||||
|
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
||||||
|
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
||||||
|
run: |
|
||||||
|
set -o pipefail
|
||||||
|
mkdir -p app/build
|
||||||
|
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
||||||
|
for wait in 60 180 0; do
|
||||||
|
status=0
|
||||||
|
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PndkVersion="$NDK_VERSION" 2>&1 | tee app/build/unit-tests.log || status=$?
|
||||||
|
if [ "$status" = 0 ] || [ "$wait" = 0 ] || ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://repo\.maven\.apache\.org/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://repo\.maven\.apache\.org/)' app/build/unit-tests.log; then
|
||||||
|
exit "$status"
|
||||||
|
fi
|
||||||
|
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s"
|
||||||
|
sleep "$wait"
|
||||||
|
done
|
||||||
|
|
||||||
|
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
||||||
|
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
||||||
|
- name: Save Robolectric's Android jars
|
||||||
|
id: robolectric-jars-final
|
||||||
|
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import glob, os, zipfile
|
||||||
|
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
||||||
|
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
||||||
|
if not os.path.isfile(f):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
||||||
|
except Exception:
|
||||||
|
ok = False
|
||||||
|
if not ok:
|
||||||
|
os.remove(f)
|
||||||
|
PY
|
||||||
|
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
||||||
|
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
||||||
|
- name: Store Robolectric's Android jars
|
||||||
|
if: always() && steps.robolectric-jars-final.outputs.save == 'true'
|
||||||
|
uses: actions/cache/save@v4
|
||||||
|
with:
|
||||||
|
path: ${{ steps.robolectric-jars.outputs.path }}
|
||||||
|
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
||||||
|
|
||||||
|
- name: Upload unit test diagnostics
|
||||||
|
id: unit-test-diagnostics
|
||||||
|
if: always() && steps.unit-tests.outcome != 'skipped'
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: unit-test-results
|
||||||
|
path: |
|
||||||
|
app/build/unit-tests.log
|
||||||
|
app/build/test-results/testReleaseUnitTest/
|
||||||
|
app/build/reports/tests/testReleaseUnitTest/
|
||||||
|
if-no-files-found: ignore
|
||||||
|
retention-days: 14
|
||||||
|
overwrite: true
|
||||||
|
|
||||||
- name: Sign with the testkey (v1 + v2 + v3)
|
- name: Sign with the testkey (v1 + v2 + v3)
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
@@ -776,6 +884,8 @@ jobs:
|
|||||||
PR: ${{ github.event.pull_request.number }}
|
PR: ${{ github.event.pull_request.number }}
|
||||||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
|
||||||
BUILD_OUTCOME: ${{ steps.build.outcome }}
|
BUILD_OUTCOME: ${{ steps.build.outcome }}
|
||||||
|
UNIT_TEST_OUTCOME: ${{ steps.unit-tests.outcome }}
|
||||||
|
TEST_DIAGNOSTICS_URL: ${{ steps.unit-test-diagnostics.outputs.artifact-url }}
|
||||||
APK_OUTCOME: ${{ steps.apk-upload.outcome }}
|
APK_OUTCOME: ${{ steps.apk-upload.outcome }}
|
||||||
run: bash tools/release/report-build.sh
|
run: bash tools/release/report-build.sh
|
||||||
|
|
||||||
|
|||||||
@@ -47,13 +47,6 @@ jobs:
|
|||||||
echo "::error::main ${GITHUB_SHA::7} has no successful Build APK run yet: wait for it, then release"
|
echo "::error::main ${GITHUB_SHA::7} has no successful Build APK run yet: wait for it, then release"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
tests=$(gh run list -R "$GITHUB_REPOSITORY" --workflow unit-tests.yml --branch main --commit "$GITHUB_SHA" \
|
|
||||||
--json conclusion,event,headSha -L 20 |
|
|
||||||
jq -r --arg sha "$GITHUB_SHA" '[.[] | select(.headSha == $sha and (.event == "push" or .event == "workflow_dispatch"))][0].conclusion // empty')
|
|
||||||
if [ "$tests" != success ]; then
|
|
||||||
echo "::error::main ${GITHUB_SHA::7} has no passing Unit tests run (${tests:-none yet}): fix or wait for it, then release"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
variants=$(awk '!/^#/ && NF { print $1 }' tools/release/variants.txt | jq -R . | jq -sc .)
|
variants=$(awk '!/^#/ && NF { print $1 }' tools/release/variants.txt | jq -R . | jq -sc .)
|
||||||
echo "run_id=$id" >> "$GITHUB_OUTPUT"
|
echo "run_id=$id" >> "$GITHUB_OUTPUT"
|
||||||
echo "variants=$variants" >> "$GITHUB_OUTPUT"
|
echo "variants=$variants" >> "$GITHUB_OUTPUT"
|
||||||
|
|||||||
@@ -1,202 +0,0 @@
|
|||||||
name: Unit tests
|
|
||||||
run-name: ${{ github.event_name == 'pull_request' && format('unit tests for pr {0} on {1} against {2}', github.event.pull_request.number, github.event.pull_request.head.sha, github.event.pull_request.base.sha) || format('unit tests for {0} on {1}', github.ref_name, github.sha) }}
|
|
||||||
|
|
||||||
# Runs beside Build APK rather than inside it, so a test build is published as soon as the APK compiles.
|
|
||||||
# Build validation folds this workflow's result into the "Build APK" commit status, and Release APKs requires it.
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
paths-ignore:
|
|
||||||
- '**/*.md'
|
|
||||||
- 'LICENSE'
|
|
||||||
- '.gitignore'
|
|
||||||
- 'docs/**'
|
|
||||||
- '.github/ISSUE_TEMPLATE/**'
|
|
||||||
pull_request:
|
|
||||||
branches: [ main ]
|
|
||||||
types: [ opened, synchronize, reopened, ready_for_review ]
|
|
||||||
paths-ignore:
|
|
||||||
- '**/*.md'
|
|
||||||
- 'LICENSE'
|
|
||||||
- '.gitignore'
|
|
||||||
- 'docs/**'
|
|
||||||
- '.github/ISSUE_TEMPLATE/**'
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
actions: read
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: unit-tests-${{ github.event.pull_request.number || (github.event_name == 'push' && 'main') || github.run_id }}
|
|
||||||
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
unit-tests:
|
|
||||||
name: Unit tests
|
|
||||||
if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.draft }}
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
timeout-minutes: 45
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.sha }}
|
|
||||||
fetch-depth: 0
|
|
||||||
sparse-checkout: |
|
|
||||||
/*
|
|
||||||
!/docs/releases/media/
|
|
||||||
sparse-checkout-cone-mode: false
|
|
||||||
persist-credentials: false
|
|
||||||
|
|
||||||
- name: Merge the pinned APK base
|
|
||||||
if: github.event_name == 'pull_request'
|
|
||||||
env:
|
|
||||||
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
git config user.name "ci"
|
|
||||||
git config user.email "ci@users.noreply.github.com"
|
|
||||||
git fetch --no-tags origin "$PR_BASE_SHA"
|
|
||||||
git merge-tree --write-tree HEAD FETCH_HEAD >/dev/null || true
|
|
||||||
git merge --no-ff --no-edit FETCH_HEAD || { echo "::error::the pull request conflicts with main; Build APK lists the files"; exit 1; }
|
|
||||||
|
|
||||||
- name: Check out MaliBridge
|
|
||||||
run: git submodule update --init external/MaliBridge
|
|
||||||
|
|
||||||
- uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: temurin
|
|
||||||
java-version: '17'
|
|
||||||
|
|
||||||
- uses: gradle/actions/setup-gradle@v4
|
|
||||||
with:
|
|
||||||
cache-read-only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
|
|
||||||
cache-cleanup: ${{ github.event_name == 'pull_request' && 'never' || 'on-success' }}
|
|
||||||
|
|
||||||
- name: Resolve the pinned Android NDK
|
|
||||||
run: bash tools/ci/resolve-ndk.sh
|
|
||||||
|
|
||||||
- name: Set the APK build label
|
|
||||||
id: build-label
|
|
||||||
env:
|
|
||||||
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
||||||
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
||||||
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
|
||||||
BUILD_REF: ${{ github.ref_name }}
|
|
||||||
BUILD_SHA: ${{ github.sha }}
|
|
||||||
run: bash tools/ci/build-label.sh
|
|
||||||
|
|
||||||
- name: Resolve the Robolectric version
|
|
||||||
id: robolectric
|
|
||||||
run: |
|
|
||||||
echo "version=$(grep -o "org.robolectric:robolectric:[0-9.]*" app/build.gradle | cut -d: -f3)" >> "$GITHUB_OUTPUT"
|
|
||||||
# Robolectric downloads these from Maven Central on first use without retrying, and 429s fail whole test classes.
|
|
||||||
# The cache path sits beside the workspace because runner homes are at different depths from it, and
|
|
||||||
# actions/cache stores paths relative to the workspace. It is passed as an absolute path: the save action rejects
|
|
||||||
# "..". Runners that keep their own ~/.m2 skip the cache.
|
|
||||||
- name: Place Robolectric's Android jars beside the workspace
|
|
||||||
id: robolectric-jars
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
jars="$GITHUB_WORKSPACE/../robolectric-jars"
|
|
||||||
m2="$HOME/.m2/repository/org/robolectric/android-all-instrumented"
|
|
||||||
if [ -d "$m2" ] && [ ! -L "$m2" ]; then
|
|
||||||
echo "cache=false" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
mkdir -p "$jars" "$(dirname "$m2")"
|
|
||||||
jars=$(cd "$jars" && pwd)
|
|
||||||
ln -sfn "$jars" "$m2"
|
|
||||||
echo "path=$jars" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "cache=true" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
- name: Restore Robolectric's Android jars
|
|
||||||
id: robolectric-cache
|
|
||||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
|
||||||
uses: actions/cache/restore@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
|
||||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
|
||||||
restore-keys: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-
|
|
||||||
- name: Count the restored Robolectric jars
|
|
||||||
if: steps.robolectric-jars.outputs.cache == 'true'
|
|
||||||
run: echo "ROBOLECTRIC_JARS_BEFORE=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)" >> "$GITHUB_ENV"
|
|
||||||
- name: Unit tests
|
|
||||||
id: unit-tests
|
|
||||||
env:
|
|
||||||
DROIDDECK_BUILD_LABEL: ${{ steps.build-label.outputs.label }}
|
|
||||||
SGDB_API_KEY: ${{ secrets.SGDB_API_KEY }}
|
|
||||||
run: |
|
|
||||||
set -o pipefail
|
|
||||||
mkdir -p app/build
|
|
||||||
log=app/build/unit-tests.log
|
|
||||||
attempt_log=app/build/unit-tests-attempt.log
|
|
||||||
: > "$log"
|
|
||||||
mirror=()
|
|
||||||
central='https://(repo1\.maven\.org|repo\.maven\.apache\.org)/maven2/org/robolectric/'
|
|
||||||
gradle_error='((Caused by: )?org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: |>[[:space:]]+)?'
|
|
||||||
java_error='((Caused by: )?java\.io\.IOException: )?'
|
|
||||||
# A Maven 429 fails every test class that needs the missing jar. The jars an attempt did get stay for the next.
|
|
||||||
for wait in 60 180 0; do
|
|
||||||
status=0
|
|
||||||
./gradlew testReleaseUnitTest --console=plain --info --stacktrace -Drobolectric.logging=stderr -PskipRust=true -PunitTestsOnly=true -PndkVersion="$NDK_VERSION" "${mirror[@]}" 2>&1 | tee "$attempt_log" || status=$?
|
|
||||||
cat "$attempt_log" >> "$log"
|
|
||||||
if [ "$status" = 0 ] || [ "$wait" = 0 ]; then
|
|
||||||
exit "$status"
|
|
||||||
fi
|
|
||||||
if [ "${#mirror[@]}" = 0 ] && grep -qE \
|
|
||||||
-e "^[[:space:]]*${gradle_error}Could not (GET|HEAD) '?${central}[^'[:space:]]+'?\. Received status code 429([[:space:]]|$)" \
|
|
||||||
-e "^[[:space:]]*${java_error}Server returned HTTP response code: 429 for URL: ${central}[^[:space:]]+" "$attempt_log"; then
|
|
||||||
mirror=(-ProbolectricMavenMirror=https://maven-central.storage-download.googleapis.com/maven2)
|
|
||||||
echo "::notice::Maven Central rate limited Robolectric. Retrying unit tests with the Google Cloud mirror." | tee -a "$log"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if ! grep -Eq '^[[:space:]]*(Caused by: org\.gradle\.internal\.resource\.transport\.http\.HttpErrorStatusCodeException: Could not GET .*https://(repo\.maven\.apache\.org|repo1\.maven\.org)/.*Received status code 429 from server|Caused by: java\.io\.IOException: Server returned HTTP response code: 429 for URL: https://(repo\.maven\.apache\.org|repo1\.maven\.org)/)' "$attempt_log"; then
|
|
||||||
exit "$status"
|
|
||||||
fi
|
|
||||||
echo "::warning::Maven Central answered 429; running the unit tests again in ${wait}s" | tee -a "$log"
|
|
||||||
sleep "$wait"
|
|
||||||
done
|
|
||||||
|
|
||||||
# actions/cache only saves when the job succeeds, so a run whose tests died on a Maven 429 never filled the cache.
|
|
||||||
# Save the complete jars even after a failed test step, when this run added some; a partial download is dropped first.
|
|
||||||
- name: Save Robolectric's Android jars
|
|
||||||
id: robolectric-jars-final
|
|
||||||
if: always() && steps.robolectric-jars.outputs.cache == 'true'
|
|
||||||
run: |
|
|
||||||
python3 - <<'PY'
|
|
||||||
import glob, os, zipfile
|
|
||||||
root = os.path.join(os.environ['GITHUB_WORKSPACE'], '..', 'robolectric-jars')
|
|
||||||
for f in glob.glob(os.path.join(root, '**', '*'), recursive=True):
|
|
||||||
if not os.path.isfile(f):
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
ok = f.endswith('.jar') and zipfile.ZipFile(f).testzip() is None
|
|
||||||
except Exception:
|
|
||||||
ok = False
|
|
||||||
if not ok:
|
|
||||||
os.remove(f)
|
|
||||||
PY
|
|
||||||
after=$(find "$GITHUB_WORKSPACE/../robolectric-jars" -name '*.jar' | wc -l)
|
|
||||||
[ "$after" -gt "${ROBOLECTRIC_JARS_BEFORE:-0}" ] && echo "save=true" >> "$GITHUB_OUTPUT" || true
|
|
||||||
# A pull request's cache is visible only to that pull request, and each copy is hundreds of megabytes against the
|
|
||||||
# repository's 10 GB cache limit. Only main saves, so every pull request restores main's set.
|
|
||||||
- name: Store Robolectric's Android jars
|
|
||||||
if: always() && github.event_name != 'pull_request' && steps.robolectric-jars-final.outputs.save == 'true'
|
|
||||||
uses: actions/cache/save@v4
|
|
||||||
with:
|
|
||||||
path: ${{ steps.robolectric-jars.outputs.path }}
|
|
||||||
key: robolectric-android-all-v3-${{ steps.robolectric.outputs.version }}-${{ github.run_id }}
|
|
||||||
|
|
||||||
- name: Upload unit test diagnostics
|
|
||||||
id: unit-test-diagnostics
|
|
||||||
if: always() && steps.unit-tests.outcome != 'skipped'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: unit-test-results
|
|
||||||
path: |
|
|
||||||
app/build/unit-tests.log
|
|
||||||
app/build/test-results/testReleaseUnitTest/
|
|
||||||
app/build/reports/tests/testReleaseUnitTest/
|
|
||||||
if-no-files-found: ignore
|
|
||||||
retention-days: 14
|
|
||||||
overwrite: true
|
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
- For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step.
|
- For an install-and-look iteration, use `tools/quick_deploy.sh` (build without lint, sign, install, about 30 s). Run `tools/build_local.sh` once to prepare the runtime and again only before a PR. It is not a per-change step.
|
||||||
- `tools/build_local.sh` reuses the components a main CI run prepared when every recipe identity matches the local tree (it prints `components: … reusing`). It builds them locally when no usable CI artifact matches (after you change their inputs, or when the lookup fails) or with `DROIDDECK_CI_COMPONENTS=0`.
|
- `tools/build_local.sh` reuses the components a main CI run prepared when every recipe identity matches the local tree (it prints `components: … reusing`). It builds them locally when no usable CI artifact matches (after you change their inputs, or when the lookup fails) or with `DROIDDECK_CI_COMPONENTS=0`.
|
||||||
- Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout.
|
- Helper scripts (`tools/linuxfs/overlay`, `tools/linuxfs/desktop`) are staged on every Gradle build, so editing them needs no `build_local.sh`. After preloads or other runtime components change, the fast loop warns and reuses the old binaries; run `tools/build_local.sh` when those matter. "Missing or changed runtime input" means the prepared files themselves changed: run `tools/build_local.sh` once. Do not revert scripts or copy `app/build` between checkouts; `tools/seed_worktree.sh` seeds a new worktree from the main checkout.
|
||||||
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest` in the `Unit tests` workflow, beside Build APK; when a test fails only in CI, run the release variant locally.
|
- Every build defaults to the NDK in `tools/ci/toolchains.env`, as CI does. CI runs `testReleaseUnitTest`; when a test fails only in CI, run the release variant locally.
|
||||||
- Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI.
|
- Run the tests that cover what you changed, including unchanged tests of code you edited: `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '<class>'` and `python3 -m unittest discover -s tools/tests -p 'test_<area>*.py'`. The full Python suite takes about 9 minutes, and some preload tests fail on any host without zram/ntsync. Leave full runs to CI.
|
||||||
- For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape.
|
- For UI screenshots without a device, run `./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*PreviewRenderTest'` and read `app/build/preview-renders/{handheld,portrait}/`. Add cases per `docs/compose-previews.md`. Check portrait, not just landscape.
|
||||||
- After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`.
|
- After changing `SettingsIndex`, regenerate the doc: `UPDATE_SETTINGS_MAP=1 ./gradlew -PskipRust=true :app:testDebugUnitTest --tests '*SettingsMapTest*'`.
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
- CI builds the PR merged onto `main`. Before pushing, merge or rebase onto `origin/main` and compile: most "works locally" Kotlin failures come from that merge.
|
- CI builds the PR merged onto `main`. Before pushing, merge or rebase onto `origin/main` and compile: most "works locally" Kotlin failures come from that merge.
|
||||||
- Before a PR that touches strings or resources, run `./gradlew :app:lintVitalRelease`. The fast loop skips lint, and lint catches `ExtraTranslation` and missing-locale errors.
|
- Before a PR that touches strings or resources, run `./gradlew :app:lintVitalRelease`. The fast loop skips lint, and lint catches `ExtraTranslation` and missing-locale errors.
|
||||||
- Commit messages and PR bodies must not carry `Co-Authored-By` or other bot trailers. `tools/release/check_authorship.py` fails the build on them.
|
- Commit messages and PR bodies must not carry `Co-Authored-By` or other bot trailers. `tools/release/check_authorship.py` fails the build on them.
|
||||||
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results` from the `Unit tests` workflow run. Don't call a failure a runner problem until you have read it.
|
- `gh run view --log-failed` truncates the unit-test log, so the failing test may not show. Read the whole job log with `gh api repos/Droid-Deck/DroidDeck/actions/jobs/<job-id>/logs`, or `gh run download <run> -n unit-test-results`. Don't call a failure a runner problem until you have read it.
|
||||||
- Only these are known flakes worth a `gh run rerun <run> --failed`: `ProtonMenuAutoTest` "Proton work did not finish", Robolectric `HTTP response code: 429` from Maven, `Gradle Test Executor N finished with non-zero exit value 2`, apt mirror and GitHub API rate-limit errors. Treat any other failure as real.
|
- Only these are known flakes worth a `gh run rerun <run> --failed`: `ProtonMenuAutoTest` "Proton work did not finish", Robolectric `HTTP response code: 429` from Maven, `Gradle Test Executor N finished with non-zero exit value 2`, apt mirror and GitHub API rate-limit errors. Treat any other failure as real.
|
||||||
- A workflow step that names a script your branch lacks means the branch predates a CI change. Rebase onto `main`.
|
- A workflow step that names a script your branch lacks means the branch predates a CI change. Rebase onto `main`.
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
|||||||
- Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05.
|
- Runtime, shim, input and controller work build on WinNative and Bannerlator by maxjivi05.
|
||||||
- mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)).
|
- mmap ring buffer controller input by ribbit384 ([WinNative #345](https://github.com/WinNative-Emu/WinNative/pull/345)).
|
||||||
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source. The fix for host stack left behind when a program leaves a signal handler without returning follows the approach suggested in [FEX-Emu/FEX#2487](https://github.com/FEX-Emu/FEX/issues/2487). The host stack fix for system calls that end a block is a backport of Ryan Houdek's [FEX-Emu/FEX#6122](https://github.com/FEX-Emu/FEX/pull/6122).
|
- [FEX](https://github.com/FEX-Emu/FEX) (MIT) runs x86 code. DroidDeck's build puts the platform name under `AT_PLATFORM` so [sharun](https://github.com/VHSgunzo/sharun) AppImages by VHSgunzo (MIT) start through its [userland-execve](https://crates.io/crates/userland-execve) loader (MIT), and its GL thunk hands X errors to the program's own error handler. FEX's code disk cache was checked in its source. The fix for host stack left behind when a program leaves a signal handler without returning follows the approach suggested in [FEX-Emu/FEX#2487](https://github.com/FEX-Emu/FEX/issues/2487). The host stack fix for system calls that end a block is a backport of Ryan Houdek's [FEX-Emu/FEX#6122](https://github.com/FEX-Emu/FEX/pull/6122).
|
||||||
- Anti-cheat support under FEX is the work of [StonkGuy](https://github.com/StonkGuy): the x86-64 ptrace, seccomp and `/proc` emulation from his [FEX fork](https://github.com/StonkGuy/FEX) (`eac-2611` branch, MIT) is carried as build patch 0021 with his authorship, patches 0022 to 0029 build on it, and his `eac-tests` regression suite verifies them.
|
|
||||||
- x86-64 programs on Wayland reach the GPU through FEX's Wayland client, wayland-egl and EGL thunks. The guest `wl_list` and `wl_array` helpers follow [libwayland](https://gitlab.freedesktop.org/wayland/wayland)'s `src/wayland-util.c` (MIT). The EGL extension table comes from the [Khronos EGL registry](https://github.com/KhronosGroup/EGL-Registry) (Apache-2.0) and Mesa's `egl_other.xml` (MIT).
|
- x86-64 programs on Wayland reach the GPU through FEX's Wayland client, wayland-egl and EGL thunks. The guest `wl_list` and `wl_array` helpers follow [libwayland](https://gitlab.freedesktop.org/wayland/wayland)'s `src/wayland-util.c` (MIT). The EGL extension table comes from the [Khronos EGL registry](https://github.com/KhronosGroup/EGL-Registry) (Apache-2.0) and Mesa's `egl_other.xml` (MIT).
|
||||||
- x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence.
|
- x86 AppImages, and arm64 ones whose runtime can't unpack on Android, are unpacked with [uruntime](https://github.com/VHSgunzo/uruntime) by VHSgunzo (MIT), shipped unmodified with its licence.
|
||||||
- DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence.
|
- DwarFS AppImages are unpacked without proot by `dwarfsextract` from [DwarFS](https://github.com/mhx/dwarfs) by Marcus Holland-Moritz (MIT), the release binary uruntime embeds, taken out of its self-extracting wrapper and shipped with its licence.
|
||||||
@@ -114,7 +113,7 @@ DroidDeck is [GPL-3.0](LICENSE). Steam and Proton belong to Valve Corporation. V
|
|||||||
- Steam audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink`.
|
- Steam audio goes through [@The412Banner](https://github.com/The412Banner)'s [DirectAudio](https://github.com/The412Banner/directaudio) PulseAudio sink (LGPL-2.1-or-later), built from `tools/directaudio/sink`.
|
||||||
- The DroidDeck HUD is [@The412Banner](https://github.com/The412Banner)'s [FusionHUD](https://github.com/The412Banner/FusionHUD) (GPL-3.0 with an attribution term). Its readings match Valve's [MangoHud](https://github.com/flightlessmango/MangoHud) build (MIT), with frame times from gamescope patch 0125.
|
- The DroidDeck HUD is [@The412Banner](https://github.com/The412Banner)'s [FusionHUD](https://github.com/The412Banner/FusionHUD) (GPL-3.0 with an attribution term). Its readings match Valve's [MangoHud](https://github.com/flightlessmango/MangoHud) build (MIT), with frame times from gamescope patch 0125.
|
||||||
- The HUD's CPU, GPU load, thermal and battery readers come from [@xXJSONDeruloXx](https://github.com/xXJSONDeruloXx)'s work.
|
- The HUD's CPU, GPU load, thermal and battery readers come from [@xXJSONDeruloXx](https://github.com/xXJSONDeruloXx)'s work.
|
||||||
- LSFG frame generation comes from Camille LaVey and the [Eden](https://eden-emu.dev) project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported by [@maxjivi05](https://github.com/maxjivi05). It requires [Lossless Scaling](https://store.steampowered.com/app/993090/) installed through Steam and ships none of its shaders.
|
- LSFG frame generation comes from Camille LaVey and the [Eden](https://eden-emu.dev) project, following [lsfg-vk](https://github.com/PancakeTAS/lsfg-vk), ported by [@maxjivi05](https://github.com/maxjivi05). It needs your own copy of [Lossless Scaling](https://store.steampowered.com/app/993090/) and ships none of its shaders.
|
||||||
- Black frame insertion follows the design of [@artzox](https://github.com/artzox)'s [BFI Presenter](https://github.com/artzox/BFI-Presenter) (GPL-3.0): the strobe runs on the display's refresh clock and the game is paced to the lit refresh. Both build on [Blur Busters](https://blurbusters.com)' research on MPRT and motion blur. No BFI Presenter code is used.
|
- Black frame insertion follows the design of [@artzox](https://github.com/artzox)'s [BFI Presenter](https://github.com/artzox/BFI-Presenter) (GPL-3.0): the strobe runs on the display's refresh clock and the game is paced to the lit refresh. Both build on [Blur Busters](https://blurbusters.com)' research on MPRT and motion blur. No BFI Presenter code is used.
|
||||||
- Remote Play decodes through Android's MediaCodec or the [FFmpeg](https://ffmpeg.org) (LGPL-2.1-or-later) in Steam's runtime. Qualcomm low latency settings follow [Moonlight](https://github.com/moonlight-stream/moonlight-android) (GPL-3.0).
|
- Remote Play decodes through Android's MediaCodec or the [FFmpeg](https://ffmpeg.org) (LGPL-2.1-or-later) in Steam's runtime. Qualcomm low latency settings follow [Moonlight](https://github.com/moonlight-stream/moonlight-android) (GPL-3.0).
|
||||||
- [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) sockets use the settings in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions.
|
- [PipeWire](https://gitlab.freedesktop.org/pipewire/pipewire) (MIT) sockets use the settings in its `module-access.c`, and [WirePlumber](https://gitlab.freedesktop.org/pipewire/wireplumber) (MIT) keeps those clients at full permissions.
|
||||||
|
|||||||
+1
-8
@@ -82,8 +82,6 @@ def buildBranch = providers.environmentVariable('GITHUB_HEAD_REF').getOrNull()?.
|
|||||||
?: gitValue(['branch', '--show-current']) ?: ''
|
?: gitValue(['branch', '--show-current']) ?: ''
|
||||||
def escapeJava = { String value -> value.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ' ').replace('\r', ' ') }
|
def escapeJava = { String value -> value.replace('\\', '\\\\').replace('"', '\\"').replace('\n', ' ').replace('\r', ' ') }
|
||||||
def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true'
|
def ciBuild = providers.environmentVariable('GITHUB_ACTIONS').getOrNull() == 'true'
|
||||||
// The Unit tests workflow compiles no APK, so it has no add-on packs to pin.
|
|
||||||
def unitTestsOnly = project.findProperty('unitTestsOnly')?.toString()?.toBoolean() ?: false
|
|
||||||
def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim()
|
def releaseSigner = rootProject.file('keystore/release-signer.sha256').text.trim()
|
||||||
def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' }
|
def commitTime = (gitValue(['show', '-s', '--format=%ct', '--end-of-options', sourceCommit]) ?: '0').with { it.isLong() ? it : '0' }
|
||||||
def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines()
|
def desktopKde = rootProject.file('tools/desktop-kde/release.env').readLines()
|
||||||
@@ -98,12 +96,10 @@ def prootPackPin = rootProject.file('tools/packs/proot/release.env').readLines()
|
|||||||
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
def addonPacks = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt', 'epic'].collectEntries { name ->
|
||||||
def pack = file("build/packs/${name}.tar.zst")
|
def pack = file("build/packs/${name}.tar.zst")
|
||||||
if (!pack.isFile()) {
|
if (!pack.isFile()) {
|
||||||
if (ciBuild && !unitTestsOnly) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
if (ciBuild) throw new GradleException("Add-on pack ${pack} is missing: run tools/packs/build.sh app/build/packs")
|
||||||
if (name == 'proot' && prootPackPin.PROOT_PACK_SHA256) {
|
if (name == 'proot' && prootPackPin.PROOT_PACK_SHA256) {
|
||||||
return [(name): [sha256: prootPackPin.PROOT_PACK_SHA256, size: (prootPackPin.PROOT_PACK_SIZE ?: '0') as long]]
|
return [(name): [sha256: prootPackPin.PROOT_PACK_SHA256, size: (prootPackPin.PROOT_PACK_SIZE ?: '0') as long]]
|
||||||
}
|
}
|
||||||
// A CI APK pins every pack, and CI_BUILD code assumes that, so the tests see a placeholder pin.
|
|
||||||
if (unitTestsOnly) return [(name): [sha256: '0' * 64, size: 0L]]
|
|
||||||
return [(name): [sha256: '', size: 0L]]
|
return [(name): [sha256: '', size: 0L]]
|
||||||
}
|
}
|
||||||
def digest = java.security.MessageDigest.getInstance('SHA-256')
|
def digest = java.security.MessageDigest.getInstance('SHA-256')
|
||||||
@@ -242,9 +238,6 @@ android {
|
|||||||
doFirst { jvmTemp.mkdirs() }
|
doFirst { jvmTemp.mkdirs() }
|
||||||
def logTarget = providers.systemProperty('robolectric.logging').orNull
|
def logTarget = providers.systemProperty('robolectric.logging').orNull
|
||||||
if (logTarget != null) systemProperty 'robolectric.logging', logTarget
|
if (logTarget != null) systemProperty 'robolectric.logging', logTarget
|
||||||
// Robolectric resolves Android SDK jars inside the test JVM independently of Gradle.
|
|
||||||
def robolectricMirror = providers.gradleProperty('robolectricMavenMirror').orNull
|
|
||||||
if (robolectricMirror) systemProperty 'robolectric.dependency.repo.url', robolectricMirror
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,13 @@
|
|||||||
package com.droiddeck.launcher.ui
|
package com.droiddeck.launcher.ui
|
||||||
|
|
||||||
import androidx.compose.foundation.background
|
import androidx.compose.foundation.background
|
||||||
import androidx.compose.foundation.layout.Box
|
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
import androidx.compose.foundation.layout.fillMaxSize
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
|
||||||
import androidx.compose.material.icons.filled.Settings
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Brush
|
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import com.droiddeck.launcher.R
|
import com.droiddeck.launcher.R
|
||||||
import com.droiddeck.launcher.input.SecondScreenMode
|
import com.droiddeck.launcher.input.SecondScreenMode
|
||||||
@@ -30,50 +26,6 @@ private fun Launcher(tab: String, games: List<com.droiddeck.launcher.frontend.Li
|
|||||||
@DroidDeckPreviews @Composable private fun SettingsPreview() = Launcher("setup")
|
@DroidDeckPreviews @Composable private fun SettingsPreview() = Launcher("setup")
|
||||||
@DroidDeckPreviews @Composable private fun RuntimeMissingPreview() = Launcher("setup", ready = false)
|
@DroidDeckPreviews @Composable private fun RuntimeMissingPreview() = Launcher("setup", ready = false)
|
||||||
|
|
||||||
/** [content] over a stand-in wallpaper as the frost shows it, with see-through [cards] or solid ones. */
|
|
||||||
@Composable
|
|
||||||
private fun Frosted(transparency: Int = FROST_WALLPAPER_DEFAULT, cards: Boolean = false, cardTransparency: Int = FROST_DEFAULT, content: @Composable () -> Unit) =
|
|
||||||
DroidDeckTheme(frost = FrostChoice(transparency, cards, cardTransparency)) {
|
|
||||||
val wallpaper = Brush.linearGradient(listOf(Color(0xFFE2725B), Color(0xFF7A4BC2), Color(0xFF2A9D8F)))
|
|
||||||
Box(Modifier.fillMaxSize().background(wallpaper).background(LocalFrost.current ?: Color.Transparent)) { content() }
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun FrostedLauncher(tab: String, transparency: Int = FROST_WALLPAPER_DEFAULT, cards: Boolean = false, cardTransparency: Int = FROST_DEFAULT) =
|
|
||||||
Frosted(transparency, cards, cardTransparency) { FrontEndScreen(sampleState(navigate = tab), sampleActions) }
|
|
||||||
|
|
||||||
/** A settings step opened over frosted page text with see-through cards: the step is solid, so none of the text shows through it. */
|
|
||||||
@Composable
|
|
||||||
private fun FrostedStepOut() = Frosted(cards = true) {
|
|
||||||
val text: @Composable (Int) -> String = { androidx.compose.ui.res.stringResource(it) }
|
|
||||||
Column(Modifier.padding(24.dp)) {
|
|
||||||
val line = List(8) { text(R.string.stores_shelf_new) }.joinToString(" ")
|
|
||||||
repeat(14) { androidx.compose.material3.Text(line, fontSize = 24.sp, color = LocalPalette.current.onBackground, maxLines = 1, softWrap = false) }
|
|
||||||
}
|
|
||||||
androidx.compose.foundation.layout.BoxWithConstraints(Modifier.fillMaxSize()) {
|
|
||||||
val pill = with(androidx.compose.ui.platform.LocalDensity.current) {
|
|
||||||
androidx.compose.ui.geometry.Rect(androidx.compose.ui.geometry.Offset((maxWidth - 68.dp).toPx(), 16.dp.toPx()), androidx.compose.ui.geometry.Size(44.dp.toPx(), 44.dp.toPx()))
|
|
||||||
}
|
|
||||||
val accent = LocalPalette.current.signal
|
|
||||||
StepOut(
|
|
||||||
open = true, pill = pill, preferredSide = StepSide.Left, accent = accent, onDismiss = {}, onClosed = {}, items = 2, maxWidth = 440.dp,
|
|
||||||
handle = { androidx.compose.material3.Icon(androidx.compose.material.icons.Icons.Filled.Settings, null, tint = accent, modifier = Modifier.size(20.dp)) },
|
|
||||||
) {
|
|
||||||
StepTitle(text(R.string.stores_settings_eyebrow))
|
|
||||||
Column(Modifier.stepItem(1)) {
|
|
||||||
SettingsRow(text(R.string.stores_show_mature), null) { ToggleSwitch(true, label = text(R.string.stores_show_mature)) {} }
|
|
||||||
SettingsRow(text(R.string.gog_achievements), text(R.string.gog_achievements_hint)) { ToggleSwitch(false, label = text(R.string.gog_achievements)) {} }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@DroidDeckPreviews @Composable private fun FrostedSteamTabPreview() = FrostedLauncher("steam")
|
|
||||||
@DroidDeckPreviews @Composable private fun FrostedLibraryPreview() = FrostedLauncher("games")
|
|
||||||
@DroidDeckPreviews @Composable private fun FrostedSettingsCardsPreview() = FrostedLauncher("setup", cards = true)
|
|
||||||
@DroidDeckPreviews @Composable private fun FrostedSettingsClearestPreview() = FrostedLauncher("setup", transparency = FROST_MAX, cards = true, cardTransparency = FROST_MAX)
|
|
||||||
@DroidDeckPreviews @Composable private fun FrostedStepOutPreview() = FrostedStepOut()
|
|
||||||
|
|
||||||
/** The in-game menu on one page, as a session shows it. */
|
/** The in-game menu on one page, as a session shows it. */
|
||||||
@Composable
|
@Composable
|
||||||
private fun SessionMenu(page: SessionDrawerPage, steam: Boolean = true, desktop: Boolean = false) = PreviewHost {
|
private fun SessionMenu(page: SessionDrawerPage, steam: Boolean = true, desktop: Boolean = false) = PreviewHost {
|
||||||
@@ -120,11 +72,6 @@ internal val previewCases: List<PreviewCase> = listOf(
|
|||||||
PreviewCase("downloads") { Launcher("downloads") },
|
PreviewCase("downloads") { Launcher("downloads") },
|
||||||
PreviewCase("settings") { Launcher("setup") },
|
PreviewCase("settings") { Launcher("setup") },
|
||||||
PreviewCase("runtime-missing") { Launcher("setup", ready = false) },
|
PreviewCase("runtime-missing") { Launcher("setup", ready = false) },
|
||||||
PreviewCase("frosted-steam-tab") { FrostedLauncher("steam") },
|
|
||||||
PreviewCase("frosted-library", storesLoaded) { FrostedLauncher("games") },
|
|
||||||
PreviewCase("frosted-settings-cards") { FrostedLauncher("setup", cards = true) },
|
|
||||||
PreviewCase("frosted-settings-clearest") { FrostedLauncher("setup", transparency = FROST_MAX, cards = true, cardTransparency = FROST_MAX) },
|
|
||||||
PreviewCase("frosted-step-out") { FrostedStepOut() },
|
|
||||||
PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) },
|
PreviewCase("session-menu-controller") { SessionMenu(SessionDrawerPage.CONTROLLER) },
|
||||||
PreviewCase("session-menu-display") { SessionMenu(SessionDrawerPage.DISPLAY) },
|
PreviewCase("session-menu-display") { SessionMenu(SessionDrawerPage.DISPLAY) },
|
||||||
PreviewCase("session-menu-hud") { SessionMenu(SessionDrawerPage.HUD) },
|
PreviewCase("session-menu-hud") { SessionMenu(SessionDrawerPage.HUD) },
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ internal fun sampleState(
|
|||||||
internal val sampleActions: FrontEndActions = FrontEndActions(
|
internal val sampleActions: FrontEndActions = FrontEndActions(
|
||||||
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {},
|
onPlay = {}, onPlayDesktopUi = {}, onSteamGame = {}, onDesktop = {}, onEmulator = {}, onRom = {}, onResume = {},
|
||||||
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {},
|
onSteamSettings = {}, onDesktopSettings = {}, onInstallPackage = {}, onRemovePackage = {}, onRuntime = {},
|
||||||
onFrameGenPick = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {},
|
onFrameGenPick = {}, onImportLossless = {}, onProtons = {}, onComponents = {}, onPerformance = {}, onRoms = {},
|
||||||
onFiles = {}, onLogs = {}, onOffline = {},
|
onFiles = {}, onLogs = {}, onOffline = {},
|
||||||
onSetPhantomProcessLimit = { _, _ -> },
|
onSetPhantomProcessLimit = { _, _ -> },
|
||||||
)
|
)
|
||||||
@@ -82,7 +82,7 @@ internal fun sampleDrawerActions(
|
|||||||
secondScreenDisplays = listOfNotNull(secondScreen?.let { SecondScreenDisplay(2, "Built-in · 1240×1080") }),
|
secondScreenDisplays = listOfNotNull(secondScreen?.let { SecondScreenDisplay(2, "Built-in · 1240×1080") }),
|
||||||
selectedSecondScreenDisplay = if (secondScreen != null) 2 else -1, onSecondScreenDisplay = {},
|
selectedSecondScreenDisplay = if (secondScreen != null) 2 else -1, onSecondScreenDisplay = {},
|
||||||
gameSwapAvailable = secondScreen != null, dashboardAvailable = secondScreen != null,
|
gameSwapAvailable = secondScreen != null, dashboardAvailable = secondScreen != null,
|
||||||
onKeyboard = {}, onHardwareKeyboard = {},
|
onImportLossless = {}, onKeyboard = {}, onHardwareKeyboard = {},
|
||||||
onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null,
|
onSteamMenu = if (steam) ({}) else null, onQam = if (steam) ({}) else null,
|
||||||
onLaunchAndroidApp = { _, _ -> }, onBackground = {}, onShareLogs = {}, onStop = {}, onClose = {},
|
onLaunchAndroidApp = { _, _ -> }, onBackground = {}, onShareLogs = {}, onStop = {}, onClose = {},
|
||||||
)
|
)
|
||||||
@@ -40,8 +40,6 @@
|
|||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
||||||
<uses-permission android:name="android.permission.READ_MEDIA_VISUAL_USER_SELECTED" />
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
|
<uses-permission android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS" />
|
||||||
@@ -279,17 +277,6 @@
|
|||||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density"
|
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|density"
|
||||||
android:theme="@style/AppTheme" />
|
android:theme="@style/AppTheme" />
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".agent.AgentChatActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:launchMode="singleTask"
|
|
||||||
android:taskAffinity="${applicationId}.agentchat"
|
|
||||||
android:resizeableActivity="true"
|
|
||||||
android:theme="@style/AppTheme"
|
|
||||||
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize|keyboard|keyboardHidden|navigation|uiMode|density">
|
|
||||||
<layout android:defaultWidth="720dp" android:defaultHeight="800dp" />
|
|
||||||
</activity>
|
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".agent.AgentStartActivity"
|
android:name=".agent.AgentStartActivity"
|
||||||
android:exported="true"
|
android:exported="true"
|
||||||
@@ -494,69 +481,5 @@
|
|||||||
<service android:name=".runtime.GuestWorker61" android:exported="false" android:process=":g61" />
|
<service android:name=".runtime.GuestWorker61" android:exported="false" android:process=":g61" />
|
||||||
<service android:name=".runtime.GuestWorker62" android:exported="false" android:process=":g62" />
|
<service android:name=".runtime.GuestWorker62" android:exported="false" android:process=":g62" />
|
||||||
<service android:name=".runtime.GuestWorker63" android:exported="false" android:process=":g63" />
|
<service android:name=".runtime.GuestWorker63" android:exported="false" android:process=":g63" />
|
||||||
<service android:name=".runtime.GuestWorker64" android:exported="false" android:process=":g64" />
|
|
||||||
<service android:name=".runtime.GuestWorker65" android:exported="false" android:process=":g65" />
|
|
||||||
<service android:name=".runtime.GuestWorker66" android:exported="false" android:process=":g66" />
|
|
||||||
<service android:name=".runtime.GuestWorker67" android:exported="false" android:process=":g67" />
|
|
||||||
<service android:name=".runtime.GuestWorker68" android:exported="false" android:process=":g68" />
|
|
||||||
<service android:name=".runtime.GuestWorker69" android:exported="false" android:process=":g69" />
|
|
||||||
<service android:name=".runtime.GuestWorker70" android:exported="false" android:process=":g70" />
|
|
||||||
<service android:name=".runtime.GuestWorker71" android:exported="false" android:process=":g71" />
|
|
||||||
<service android:name=".runtime.GuestWorker72" android:exported="false" android:process=":g72" />
|
|
||||||
<service android:name=".runtime.GuestWorker73" android:exported="false" android:process=":g73" />
|
|
||||||
<service android:name=".runtime.GuestWorker74" android:exported="false" android:process=":g74" />
|
|
||||||
<service android:name=".runtime.GuestWorker75" android:exported="false" android:process=":g75" />
|
|
||||||
<service android:name=".runtime.GuestWorker76" android:exported="false" android:process=":g76" />
|
|
||||||
<service android:name=".runtime.GuestWorker77" android:exported="false" android:process=":g77" />
|
|
||||||
<service android:name=".runtime.GuestWorker78" android:exported="false" android:process=":g78" />
|
|
||||||
<service android:name=".runtime.GuestWorker79" android:exported="false" android:process=":g79" />
|
|
||||||
<service android:name=".runtime.GuestWorker80" android:exported="false" android:process=":g80" />
|
|
||||||
<service android:name=".runtime.GuestWorker81" android:exported="false" android:process=":g81" />
|
|
||||||
<service android:name=".runtime.GuestWorker82" android:exported="false" android:process=":g82" />
|
|
||||||
<service android:name=".runtime.GuestWorker83" android:exported="false" android:process=":g83" />
|
|
||||||
<service android:name=".runtime.GuestWorker84" android:exported="false" android:process=":g84" />
|
|
||||||
<service android:name=".runtime.GuestWorker85" android:exported="false" android:process=":g85" />
|
|
||||||
<service android:name=".runtime.GuestWorker86" android:exported="false" android:process=":g86" />
|
|
||||||
<service android:name=".runtime.GuestWorker87" android:exported="false" android:process=":g87" />
|
|
||||||
<service android:name=".runtime.GuestWorker88" android:exported="false" android:process=":g88" />
|
|
||||||
<service android:name=".runtime.GuestWorker89" android:exported="false" android:process=":g89" />
|
|
||||||
<service android:name=".runtime.GuestWorker90" android:exported="false" android:process=":g90" />
|
|
||||||
<service android:name=".runtime.GuestWorker91" android:exported="false" android:process=":g91" />
|
|
||||||
<service android:name=".runtime.GuestWorker92" android:exported="false" android:process=":g92" />
|
|
||||||
<service android:name=".runtime.GuestWorker93" android:exported="false" android:process=":g93" />
|
|
||||||
<service android:name=".runtime.GuestWorker94" android:exported="false" android:process=":g94" />
|
|
||||||
<service android:name=".runtime.GuestWorker95" android:exported="false" android:process=":g95" />
|
|
||||||
<service android:name=".runtime.GuestWorker96" android:exported="false" android:process=":g96" />
|
|
||||||
<service android:name=".runtime.GuestWorker97" android:exported="false" android:process=":g97" />
|
|
||||||
<service android:name=".runtime.GuestWorker98" android:exported="false" android:process=":g98" />
|
|
||||||
<service android:name=".runtime.GuestWorker99" android:exported="false" android:process=":g99" />
|
|
||||||
<service android:name=".runtime.GuestWorker100" android:exported="false" android:process=":g100" />
|
|
||||||
<service android:name=".runtime.GuestWorker101" android:exported="false" android:process=":g101" />
|
|
||||||
<service android:name=".runtime.GuestWorker102" android:exported="false" android:process=":g102" />
|
|
||||||
<service android:name=".runtime.GuestWorker103" android:exported="false" android:process=":g103" />
|
|
||||||
<service android:name=".runtime.GuestWorker104" android:exported="false" android:process=":g104" />
|
|
||||||
<service android:name=".runtime.GuestWorker105" android:exported="false" android:process=":g105" />
|
|
||||||
<service android:name=".runtime.GuestWorker106" android:exported="false" android:process=":g106" />
|
|
||||||
<service android:name=".runtime.GuestWorker107" android:exported="false" android:process=":g107" />
|
|
||||||
<service android:name=".runtime.GuestWorker108" android:exported="false" android:process=":g108" />
|
|
||||||
<service android:name=".runtime.GuestWorker109" android:exported="false" android:process=":g109" />
|
|
||||||
<service android:name=".runtime.GuestWorker110" android:exported="false" android:process=":g110" />
|
|
||||||
<service android:name=".runtime.GuestWorker111" android:exported="false" android:process=":g111" />
|
|
||||||
<service android:name=".runtime.GuestWorker112" android:exported="false" android:process=":g112" />
|
|
||||||
<service android:name=".runtime.GuestWorker113" android:exported="false" android:process=":g113" />
|
|
||||||
<service android:name=".runtime.GuestWorker114" android:exported="false" android:process=":g114" />
|
|
||||||
<service android:name=".runtime.GuestWorker115" android:exported="false" android:process=":g115" />
|
|
||||||
<service android:name=".runtime.GuestWorker116" android:exported="false" android:process=":g116" />
|
|
||||||
<service android:name=".runtime.GuestWorker117" android:exported="false" android:process=":g117" />
|
|
||||||
<service android:name=".runtime.GuestWorker118" android:exported="false" android:process=":g118" />
|
|
||||||
<service android:name=".runtime.GuestWorker119" android:exported="false" android:process=":g119" />
|
|
||||||
<service android:name=".runtime.GuestWorker120" android:exported="false" android:process=":g120" />
|
|
||||||
<service android:name=".runtime.GuestWorker121" android:exported="false" android:process=":g121" />
|
|
||||||
<service android:name=".runtime.GuestWorker122" android:exported="false" android:process=":g122" />
|
|
||||||
<service android:name=".runtime.GuestWorker123" android:exported="false" android:process=":g123" />
|
|
||||||
<service android:name=".runtime.GuestWorker124" android:exported="false" android:process=":g124" />
|
|
||||||
<service android:name=".runtime.GuestWorker125" android:exported="false" android:process=":g125" />
|
|
||||||
<service android:name=".runtime.GuestWorker126" android:exported="false" android:process=":g126" />
|
|
||||||
<service android:name=".runtime.GuestWorker127" android:exported="false" android:process=":g127" />
|
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -28,19 +28,6 @@ float_code() {
|
|||||||
[ "$result" = ok ]
|
[ "$result" = ok ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# git pushes through gh's sign-in and commits as the signed-in account, with its no-reply address.
|
|
||||||
configure_git() {
|
|
||||||
gh auth setup-git || return 1
|
|
||||||
[ -n "$(git config --global user.name)" ] && [ -n "$(git config --global user.email)" ] && return 0
|
|
||||||
local user id login name
|
|
||||||
user=$(gh api user -q '"\(.id) \(.login) \(.name // .login)"') || return 1
|
|
||||||
read -r id login name <<<"$user"
|
|
||||||
[ -n "$id" ] && [ -n "$login" ] || return 1
|
|
||||||
[ -n "$(git config --global user.name)" ] || git config --global user.name "${name:-$login}"
|
|
||||||
[ -n "$(git config --global user.email)" ] || git config --global user.email "$id+$login@users.noreply.github.com"
|
|
||||||
}
|
|
||||||
if [ "${1:-}" = --git ]; then configure_git; exit; fi
|
|
||||||
|
|
||||||
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
|
coproc GH { BROWSER=true gh auth login --hostname github.com --git-protocol https --web 2>&1; }
|
||||||
gh_pid=$GH_PID
|
gh_pid=$GH_PID
|
||||||
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
|
exec {ghout}<&"${GH[0]}" {ghin}>&"${GH[1]}"
|
||||||
@@ -61,9 +48,5 @@ while IFS= read -r line <&"$ghout"; do
|
|||||||
done
|
done
|
||||||
wait "$gh_pid"
|
wait "$gh_pid"
|
||||||
status=$?
|
status=$?
|
||||||
if [ $status = 0 ] && ! configure_git; then
|
|
||||||
echo "Signed in, but git could not be set up: run dd-gh-login --git"
|
|
||||||
status=1
|
|
||||||
fi
|
|
||||||
[ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code"
|
[ -n "$shown" ] && [ -n "$inbox" ] && [ -d "$inbox" ] && : > "$inbox/device-code"
|
||||||
exit $status
|
exit $status
|
||||||
@@ -10,17 +10,6 @@ add_subdirectory(adrenotools)
|
|||||||
|
|
||||||
add_subdirectory(thirdparty/dxbc)
|
add_subdirectory(thirdparty/dxbc)
|
||||||
|
|
||||||
# Pin ZeroFG to a fixed revision instead of vendoring thousands of generated shader lines.
|
|
||||||
include(FetchContent)
|
|
||||||
set(ZEROFG_VULKAN_HEADERS_DIR "${CMAKE_SYSROOT}/usr/include" CACHE PATH "" FORCE)
|
|
||||||
set(ZEROFG_PREBUILT_SHADERS ON CACHE STRING "" FORCE)
|
|
||||||
FetchContent_Declare(zerofg
|
|
||||||
GIT_REPOSITORY https://github.com/hy300leosquizz-ctrl/ZeroFG.git
|
|
||||||
GIT_TAG e6ca7ef9f9765db89847b6d8eed352e458f1a8bb
|
|
||||||
GIT_PROGRESS TRUE
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(zerofg)
|
|
||||||
|
|
||||||
set(DDFG_UPSTREAM "v0.3.0")
|
set(DDFG_UPSTREAM "v0.3.0")
|
||||||
set(DDFG_CHAIN_SRC
|
set(DDFG_CHAIN_SRC
|
||||||
framegen/ddfg/framegen.cpp
|
framegen/ddfg/framegen.cpp
|
||||||
|
|||||||
@@ -329,28 +329,16 @@ static constexpr int kWatchedFds = 1 << 16;
|
|||||||
static constexpr int kWatchedBits = sizeof(unsigned long) * 8;
|
static constexpr int kWatchedBits = sizeof(unsigned long) * 8;
|
||||||
static std::atomic<unsigned long> watched_fds[kWatchedFds / kWatchedBits];
|
static std::atomic<unsigned long> watched_fds[kWatchedFds / kWatchedBits];
|
||||||
static std::atomic<bool> watched_beyond{false};
|
static std::atomic<bool> watched_beyond{false};
|
||||||
static std::atomic<int> watched_count{0};
|
|
||||||
|
|
||||||
static void watch_fd(int fd) {
|
static void watch_fd(int fd) {
|
||||||
if (fd < 0) return;
|
if (fd < 0) return;
|
||||||
if (fd >= kWatchedFds) {
|
if (fd >= kWatchedFds) watched_beyond.store(true, std::memory_order_release);
|
||||||
watched_beyond.store(true, std::memory_order_release);
|
else watched_fds[fd / kWatchedBits].fetch_or(1UL << (fd % kWatchedBits), std::memory_order_release);
|
||||||
return;
|
|
||||||
}
|
|
||||||
const unsigned long bit = 1UL << (fd % kWatchedBits);
|
|
||||||
if (!(watched_fds[fd / kWatchedBits].fetch_or(bit, std::memory_order_acq_rel) & bit))
|
|
||||||
watched_count.fetch_add(1, std::memory_order_acq_rel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unwatch_fd(int fd) {
|
static void unwatch_fd(int fd) {
|
||||||
if (fd < 0 || fd >= kWatchedFds) return;
|
if (fd >= 0 && fd < kWatchedFds)
|
||||||
const unsigned long bit = 1UL << (fd % kWatchedBits);
|
watched_fds[fd / kWatchedBits].fetch_and(~(1UL << (fd % kWatchedBits)), std::memory_order_release);
|
||||||
if (watched_fds[fd / kWatchedBits].fetch_and(~bit, std::memory_order_acq_rel) & bit)
|
|
||||||
watched_count.fetch_sub(1, std::memory_order_acq_rel);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool any_watched() {
|
|
||||||
return watched_count.load(std::memory_order_acquire) > 0 || watched_beyond.load(std::memory_order_acquire);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool watched(int fd) {
|
static bool watched(int fd) {
|
||||||
@@ -4281,7 +4269,7 @@ static int poll_fake(struct pollfd *fds, nfds_t nfds, int timeout,
|
|||||||
const auto my_poll = next_symbol<decltype(&::poll)>(Next::poll);
|
const auto my_poll = next_symbol<decltype(&::poll)>(Next::poll);
|
||||||
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
||||||
|
|
||||||
nfds_t first = any_watched() ? 0 : nfds;
|
nfds_t first = 0;
|
||||||
while (first < nfds && !watched(fds[first].fd)) first++;
|
while (first < nfds && !watched(fds[first].fd)) first++;
|
||||||
bool has_fake_fds = false;
|
bool has_fake_fds = false;
|
||||||
std::vector<struct pollfd> real_fds;
|
std::vector<struct pollfd> real_fds;
|
||||||
@@ -4384,12 +4372,12 @@ EXPORT int poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
|||||||
EXPORT int ppoll(struct pollfd *fds, nfds_t nfds,
|
EXPORT int ppoll(struct pollfd *fds, nfds_t nfds,
|
||||||
const struct timespec *timeout, const sigset_t *sigmask) {
|
const struct timespec *timeout, const sigset_t *sigmask) {
|
||||||
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
const auto my_ppoll = next_symbol<decltype(&::ppoll)>(Next::ppoll);
|
||||||
for (nfds_t i = 0; any_watched() && i < nfds; ++i) {
|
if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for (nfds_t i = 0; i < nfds; ++i) {
|
||||||
if (!is_fake_input_fd(fds[i].fd)) continue;
|
if (!is_fake_input_fd(fds[i].fd)) continue;
|
||||||
if (timeout && (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || timeout->tv_nsec >= 1000000000L)) {
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (!sigmask)
|
if (!sigmask)
|
||||||
return poll_fake(fds, nfds, static_cast<int>(timespec_to_ms(timeout)), nullptr);
|
return poll_fake(fds, nfds, static_cast<int>(timespec_to_ms(timeout)), nullptr);
|
||||||
sigset_t all_signals, original_mask;
|
sigset_t all_signals, original_mask;
|
||||||
@@ -4422,8 +4410,6 @@ EXPORT int __ppoll_chk(struct pollfd *fds, nfds_t nfds, const struct timespec *t
|
|||||||
EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds,
|
EXPORT int select(int nfds, fd_set *readfds, fd_set *writefds,
|
||||||
fd_set *exceptfds, struct timeval *timeout) {
|
fd_set *exceptfds, struct timeval *timeout) {
|
||||||
const auto my_select = next_symbol<decltype(&::select)>(Next::select);
|
const auto my_select = next_symbol<decltype(&::select)>(Next::select);
|
||||||
if (!any_watched())
|
|
||||||
return my_select ? my_select(nfds, readfds, writefds, exceptfds, timeout) : -1;
|
|
||||||
|
|
||||||
fd_set original_readfds;
|
fd_set original_readfds;
|
||||||
fd_set original_writefds;
|
fd_set original_writefds;
|
||||||
|
|||||||
@@ -8,6 +8,6 @@ target_compile_features(droiddeckxr PRIVATE cxx_std_17)
|
|||||||
target_compile_definitions(droiddeckxr PRIVATE XR_USE_PLATFORM_ANDROID XR_USE_GRAPHICS_API_OPENGL_ES XR_USE_TIMESPEC)
|
target_compile_definitions(droiddeckxr PRIVATE XR_USE_PLATFORM_ANDROID XR_USE_GRAPHICS_API_OPENGL_ES XR_USE_TIMESPEC)
|
||||||
target_compile_options(droiddeckxr PRIVATE -Wall -Wextra -Wno-missing-field-initializers -Werror=return-type)
|
target_compile_options(droiddeckxr PRIVATE -Wall -Wextra -Wno-missing-field-initializers -Werror=return-type)
|
||||||
target_link_options(droiddeckxr PRIVATE -Wl,-z,max-page-size=16384 -uANativeActivity_onCreate)
|
target_link_options(droiddeckxr PRIVATE -Wl,-z,max-page-size=16384 -uANativeActivity_onCreate)
|
||||||
target_link_libraries(droiddeckxr PRIVATE droiddeckxr_glue OpenXR::openxr_loader EGL GLESv3 android jnigraphics log)
|
target_link_libraries(droiddeckxr PRIVATE droiddeckxr_glue OpenXR::openxr_loader EGL GLESv3 android log)
|
||||||
|
|
||||||
target_include_directories(droiddeckxr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../tools/vr/src)
|
target_include_directories(droiddeckxr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../tools/vr/src)
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
#include <GLES3/gl3.h>
|
#include <GLES3/gl3.h>
|
||||||
#include <android/bitmap.h>
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <android_native_app_glue.h>
|
#include <android_native_app_glue.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -23,14 +22,10 @@
|
|||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
#include <pthread.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include "xr_tracking.h"
|
#include "xr_tracking.h"
|
||||||
#include "xr_frame_channel.h"
|
#include "xr_frame_channel.h"
|
||||||
#include "xr_frame_math.h"
|
#include "xr_frame_math.h"
|
||||||
#include "gpu_frames.h"
|
#include "gpu_frames.h"
|
||||||
#include "xr_host.h"
|
|
||||||
#include "xr_overlay.h"
|
|
||||||
|
|
||||||
static void check(XrResult result, const char *operation) {
|
static void check(XrResult result, const char *operation) {
|
||||||
if (XR_FAILED(result)) throw std::runtime_error(std::string(operation) + ": " + std::to_string(result));
|
if (XR_FAILED(result)) throw std::runtime_error(std::string(operation) + ": " + std::to_string(result));
|
||||||
@@ -42,15 +37,6 @@ struct Eye {
|
|||||||
std::vector<XrSwapchainImageOpenGLESKHR> images;
|
std::vector<XrSwapchainImageOpenGLESKHR> images;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SurfaceLayer {
|
|
||||||
XrSwapchain swapchain = XR_NULL_HANDLE;
|
|
||||||
jobject surface = nullptr;
|
|
||||||
int width = 0, height = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class QuestXR;
|
|
||||||
static QuestXR *g_runtime = nullptr;
|
|
||||||
|
|
||||||
class QuestXR {
|
class QuestXR {
|
||||||
public:
|
public:
|
||||||
explicit QuestXR(android_app *app) : app_(app) {}
|
explicit QuestXR(android_app *app) : app_(app) {}
|
||||||
@@ -90,74 +76,21 @@ public:
|
|||||||
"\"headPosition\":[%.6f,%.6f,%.6f],\"controllersActive\":[%s,%s],"
|
"\"headPosition\":[%.6f,%.6f,%.6f],\"controllersActive\":[%s,%s],"
|
||||||
"\"periodNs\":%lld,\"surfaceSwapchain\":%s,\"source\":\"%s\",\"guestFrames\":%lld,\"steamvrState\":%d,"
|
"\"periodNs\":%lld,\"surfaceSwapchain\":%s,\"source\":\"%s\",\"guestFrames\":%lld,\"steamvrState\":%d,"
|
||||||
"\"receivedFrames\":%llu,\"rejectedFrames\":%llu,\"uploadedFrames\":%llu,\"sourceFrameId\":%llu,"
|
"\"receivedFrames\":%llu,\"rejectedFrames\":%llu,\"uploadedFrames\":%llu,\"sourceFrameId\":%llu,"
|
||||||
"\"gpuReceivedFrames\":%llu,\"gpuDroppedFrames\":%llu,\"gpuVerifiedFrameId\":%llu,\"gpuChecksum\":%u,"
|
"\"gpuReceivedFrames\":%llu,\"gpuDroppedFrames\":%llu,\"gpuVerifiedFrameId\":%llu,\"gpuChecksum\":%u,\"error\":\"%s\"}\n",
|
||||||
"\"hostVersion\":%u,\"visibleLayers\":%d,\"overlay\":%s,\"error\":\"%s\"}\n",
|
|
||||||
(unsigned long long)frames_, (unsigned long long)rendered_, state_,
|
(unsigned long long)frames_, (unsigned long long)rendered_, state_,
|
||||||
(unsigned long long)head_.locationFlags,
|
(unsigned long long)head_.locationFlags,
|
||||||
head_.pose.position.x, head_.pose.position.y, head_.pose.position.z,
|
head_.pose.position.x, head_.pose.position.y, head_.pose.position.z,
|
||||||
handActive_[0] ? "true" : "false", handActive_[1] ? "true" : "false",
|
handActive_[0] ? "true" : "false", handActive_[1] ? "true" : "false",
|
||||||
(long long)period_, surfaceSupported_ ? "true" : "false", "frames",
|
(long long)period_, "false", "frames",
|
||||||
0LL, steamvrState, (unsigned long long)(receiver_.Received() + gpuFrames_.Received()),
|
0LL, steamvrState, (unsigned long long)(receiver_.Received() + gpuFrames_.Received()),
|
||||||
(unsigned long long)(receiver_.Rejected() + gpuFrames_.Rejected()),
|
(unsigned long long)(receiver_.Rejected() + gpuFrames_.Rejected()),
|
||||||
(unsigned long long)uploadedFrames_, (unsigned long long)sourceHeader_.frame_id,
|
(unsigned long long)uploadedFrames_, (unsigned long long)sourceHeader_.frame_id,
|
||||||
(unsigned long long)gpuFrames_.Received(), (unsigned long long)gpuFrames_.Dropped(),
|
(unsigned long long)gpuFrames_.Received(), (unsigned long long)gpuFrames_.Dropped(),
|
||||||
(unsigned long long)verifiedFrame_, gpuChecksum_,
|
(unsigned long long)verifiedFrame_, gpuChecksum_, error);
|
||||||
hostBuffers_ ? DROIDDECK_XR_HOST_VERSION : 0u, visibleLayers_,
|
|
||||||
XrOverlay::active(hostControl_) ? "true" : "false", error);
|
|
||||||
std::fclose(file);
|
std::fclose(file);
|
||||||
std::rename(temp.c_str(), path.c_str());
|
std::rename(temp.c_str(), path.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool onXrThread() const { return pthread_equal(pthread_self(), xrThread_); }
|
|
||||||
|
|
||||||
int createLayer(JNIEnv *env, int width, int height) {
|
|
||||||
if (!onXrThread() || !createSurfaceSwapchain_ || session_ == XR_NULL_HANDLE || width <= 0 || height <= 0) return -1;
|
|
||||||
for (int index = 0; index < DROIDDECK_XR_HOST_LAYERS; index++) {
|
|
||||||
SurfaceLayer &layer = layers_[index];
|
|
||||||
if (layer.swapchain) continue;
|
|
||||||
XrSwapchainCreateInfo create{XR_TYPE_SWAPCHAIN_CREATE_INFO};
|
|
||||||
create.usageFlags = XR_SWAPCHAIN_USAGE_SAMPLED_BIT | XR_SWAPCHAIN_USAGE_COLOR_ATTACHMENT_BIT;
|
|
||||||
create.width = width; create.height = height;
|
|
||||||
jobject surface = nullptr;
|
|
||||||
XrResult result = createSurfaceSwapchain_(session_, &create, &layer.swapchain, &surface);
|
|
||||||
if (XR_FAILED(result) || !surface) {
|
|
||||||
__android_log_print(ANDROID_LOG_ERROR, "DroidDeckXR", "surface layer %dx%d failed: %d", width, height, result);
|
|
||||||
if (layer.swapchain) xrDestroySwapchain(layer.swapchain);
|
|
||||||
layer = {};
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
layer.surface = env->NewGlobalRef(surface);
|
|
||||||
layer.width = width; layer.height = height;
|
|
||||||
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "surface layer %d created %dx%d", index, width, height);
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
jobject layerSurface(JNIEnv *env, int index) {
|
|
||||||
if (!onXrThread() || index < 0 || index >= DROIDDECK_XR_HOST_LAYERS || !layers_[index].surface) return nullptr;
|
|
||||||
return env->NewLocalRef(layers_[index].surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setOrbImage(JNIEnv *env, jobject bitmap) {
|
|
||||||
if (!onXrThread() || !bitmap) return;
|
|
||||||
AndroidBitmapInfo info{};
|
|
||||||
void *pixels = nullptr;
|
|
||||||
if (AndroidBitmap_getInfo(env, bitmap, &info) != ANDROID_BITMAP_RESULT_SUCCESS
|
|
||||||
|| info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) return;
|
|
||||||
if (AndroidBitmap_lockPixels(env, bitmap, &pixels) != ANDROID_BITMAP_RESULT_SUCCESS) return;
|
|
||||||
overlay_.setLogo(pixels, (int)info.width, (int)info.height, (int)info.stride);
|
|
||||||
AndroidBitmap_unlockPixels(env, bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroyLayer(JNIEnv *env, int index) {
|
|
||||||
if (!onXrThread() || index < 0 || index >= DROIDDECK_XR_HOST_LAYERS) return;
|
|
||||||
SurfaceLayer &layer = layers_[index];
|
|
||||||
if (layer.swapchain) xrDestroySwapchain(layer.swapchain);
|
|
||||||
if (layer.surface) env->DeleteGlobalRef(layer.surface);
|
|
||||||
layer = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
android_app *app_;
|
android_app *app_;
|
||||||
JNIEnv *env_ = nullptr;
|
JNIEnv *env_ = nullptr;
|
||||||
@@ -171,20 +104,6 @@ private:
|
|||||||
XrAction primary_ = XR_NULL_HANDLE, secondary_ = XR_NULL_HANDLE, menu_ = XR_NULL_HANDLE;
|
XrAction primary_ = XR_NULL_HANDLE, secondary_ = XR_NULL_HANDLE, menu_ = XR_NULL_HANDLE;
|
||||||
XrAction triggerTouch_ = XR_NULL_HANDLE, stickTouch_ = XR_NULL_HANDLE, primaryTouch_ = XR_NULL_HANDLE;
|
XrAction triggerTouch_ = XR_NULL_HANDLE, stickTouch_ = XR_NULL_HANDLE, primaryTouch_ = XR_NULL_HANDLE;
|
||||||
XrAction secondaryTouch_ = XR_NULL_HANDLE, thumbrestTouch_ = XR_NULL_HANDLE;
|
XrAction secondaryTouch_ = XR_NULL_HANDLE, thumbrestTouch_ = XR_NULL_HANDLE;
|
||||||
PFN_xrCreateSwapchainAndroidSurfaceKHR createSurfaceSwapchain_ = nullptr;
|
|
||||||
bool surfaceSupported_ = false;
|
|
||||||
bool imageLayoutSupported_ = false;
|
|
||||||
pthread_t xrThread_{};
|
|
||||||
SurfaceLayer layers_[DROIDDECK_XR_HOST_LAYERS];
|
|
||||||
DroidDeckXrHostState hostState_{};
|
|
||||||
DroidDeckXrHostControl hostControl_{};
|
|
||||||
bool hostBuffers_ = false;
|
|
||||||
jmethodID hostFrameCallback_ = nullptr;
|
|
||||||
uint64_t hostPulse_[2]{};
|
|
||||||
int visibleLayers_ = 0;
|
|
||||||
XrOverlay overlay_;
|
|
||||||
Eye overlayEyes_[2];
|
|
||||||
GLuint overlayDepth_[2]{};
|
|
||||||
DroidDeckXrHand inputs_[2]{};
|
DroidDeckXrHand inputs_[2]{};
|
||||||
PFN_xrConvertTimeToTimespecTimeKHR convertTime_ = nullptr;
|
PFN_xrConvertTimeToTimespecTimeKHR convertTime_ = nullptr;
|
||||||
bool timespecSupported_ = false;
|
bool timespecSupported_ = false;
|
||||||
@@ -301,8 +220,6 @@ private:
|
|||||||
|
|
||||||
void initialize() {
|
void initialize() {
|
||||||
app_->userData = this;
|
app_->userData = this;
|
||||||
xrThread_ = pthread_self();
|
|
||||||
g_runtime = this;
|
|
||||||
app_->onInputEvent = [](android_app *app, AInputEvent *event) -> int32_t {
|
app_->onInputEvent = [](android_app *app, AInputEvent *event) -> int32_t {
|
||||||
if (AInputEvent_getType(event) != AINPUT_EVENT_TYPE_KEY || AKeyEvent_getKeyCode(event) != AKEYCODE_BACK
|
if (AInputEvent_getType(event) != AINPUT_EVENT_TYPE_KEY || AKeyEvent_getKeyCode(event) != AKEYCODE_BACK
|
||||||
|| AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) return 0;
|
|| AKeyEvent_getAction(event) != AKEY_EVENT_ACTION_UP) return 0;
|
||||||
@@ -327,10 +244,6 @@ private:
|
|||||||
frameCallback_ = env_->GetMethodID(activityClass, "onXrFrame", "(J)V");
|
frameCallback_ = env_->GetMethodID(activityClass, "onXrFrame", "(J)V");
|
||||||
statusCallback_ = env_->GetMethodID(activityClass, "onXrStatus", "()I");
|
statusCallback_ = env_->GetMethodID(activityClass, "onXrStatus", "()I");
|
||||||
if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("XR activity bridge methods unavailable"); }
|
if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("XR activity bridge methods unavailable"); }
|
||||||
hostFrameCallback_ = env_->GetMethodID(activityClass, "onXrHostFrame", "()V");
|
|
||||||
jmethodID hostBuffersCallback = hostFrameCallback_ ?
|
|
||||||
env_->GetMethodID(activityClass, "onXrHostBuffers", "(Ljava/nio/ByteBuffer;Ljava/nio/ByteBuffer;)V") : nullptr;
|
|
||||||
if (env_->ExceptionCheck()) { env_->ExceptionClear(); hostFrameCallback_ = nullptr; hostBuffersCallback = nullptr; }
|
|
||||||
env_->DeleteLocalRef(intentClass); env_->DeleteLocalRef(intent); env_->DeleteLocalRef(activityClass);
|
env_->DeleteLocalRef(intentClass); env_->DeleteLocalRef(intent); env_->DeleteLocalRef(activityClass);
|
||||||
PFN_xrInitializeLoaderKHR initializeLoader = nullptr;
|
PFN_xrInitializeLoaderKHR initializeLoader = nullptr;
|
||||||
check(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR",
|
check(xrGetInstanceProcAddr(XR_NULL_HANDLE, "xrInitializeLoaderKHR",
|
||||||
@@ -348,21 +261,10 @@ private:
|
|||||||
timespecSupported_ = true;
|
timespecSupported_ = true;
|
||||||
if (!std::strcmp(extension.extensionName, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
|
if (!std::strcmp(extension.extensionName, XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME))
|
||||||
performanceSupported_ = true;
|
performanceSupported_ = true;
|
||||||
if (!std::strcmp(extension.extensionName, XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME))
|
|
||||||
surfaceSupported_ = true;
|
|
||||||
if (!std::strcmp(extension.extensionName, XR_FB_COMPOSITION_LAYER_IMAGE_LAYOUT_EXTENSION_NAME))
|
|
||||||
imageLayoutSupported_ = true;
|
|
||||||
}
|
}
|
||||||
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "surface swapchain available=%d image layout=%d",
|
|
||||||
surfaceSupported_, imageLayoutSupported_);
|
|
||||||
// A surface swapchain's image arrives upside down, and a quad's back face is not drawn, so
|
|
||||||
// panels need the layout flag to flip it.
|
|
||||||
surfaceSupported_ = surfaceSupported_ && imageLayoutSupported_;
|
|
||||||
std::vector<const char *> enabled{XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME, XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME};
|
std::vector<const char *> enabled{XR_KHR_ANDROID_CREATE_INSTANCE_EXTENSION_NAME, XR_KHR_OPENGL_ES_ENABLE_EXTENSION_NAME};
|
||||||
if (timespecSupported_) enabled.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME);
|
if (timespecSupported_) enabled.push_back(XR_KHR_CONVERT_TIMESPEC_TIME_EXTENSION_NAME);
|
||||||
if (performanceSupported_) enabled.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
|
if (performanceSupported_) enabled.push_back(XR_EXT_PERFORMANCE_SETTINGS_EXTENSION_NAME);
|
||||||
if (surfaceSupported_) enabled.push_back(XR_KHR_ANDROID_SURFACE_SWAPCHAIN_EXTENSION_NAME);
|
|
||||||
if (surfaceSupported_) enabled.push_back(XR_FB_COMPOSITION_LAYER_IMAGE_LAYOUT_EXTENSION_NAME);
|
|
||||||
XrInstanceCreateInfoAndroidKHR androidInfo{XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
XrInstanceCreateInfoAndroidKHR androidInfo{XR_TYPE_INSTANCE_CREATE_INFO_ANDROID_KHR};
|
||||||
androidInfo.applicationVM = app_->activity->vm;
|
androidInfo.applicationVM = app_->activity->vm;
|
||||||
androidInfo.applicationActivity = app_->activity->clazz;
|
androidInfo.applicationActivity = app_->activity->clazz;
|
||||||
@@ -379,11 +281,6 @@ private:
|
|||||||
reinterpret_cast<PFN_xrVoidFunction *>(&setPerformance_));
|
reinterpret_cast<PFN_xrVoidFunction *>(&setPerformance_));
|
||||||
if (XR_FAILED(result)) setPerformance_ = nullptr;
|
if (XR_FAILED(result)) setPerformance_ = nullptr;
|
||||||
}
|
}
|
||||||
if (surfaceSupported_ && XR_FAILED(xrGetInstanceProcAddr(instance_, "xrCreateSwapchainAndroidSurfaceKHR",
|
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(&createSurfaceSwapchain_)))) {
|
|
||||||
createSurfaceSwapchain_ = nullptr;
|
|
||||||
surfaceSupported_ = false;
|
|
||||||
}
|
|
||||||
if (timespecSupported_) check(xrGetInstanceProcAddr(instance_, "xrConvertTimeToTimespecTimeKHR",
|
if (timespecSupported_) check(xrGetInstanceProcAddr(instance_, "xrConvertTimeToTimespecTimeKHR",
|
||||||
reinterpret_cast<PFN_xrVoidFunction *>(&convertTime_)), "time conversion entrypoint");
|
reinterpret_cast<PFN_xrVoidFunction *>(&convertTime_)), "time conversion entrypoint");
|
||||||
XrSystemGetInfo systemInfo{XR_TYPE_SYSTEM_GET_INFO};
|
XrSystemGetInfo systemInfo{XR_TYPE_SYSTEM_GET_INFO};
|
||||||
@@ -437,16 +334,6 @@ private:
|
|||||||
bool gpu = !verifyPixels_ && gpuFrames_.Start(std::string(app_->activity->internalDataPath) + "/.wayland-rt/" DROIDDECK_XR_GPU_SOCKET, display_);
|
bool gpu = !verifyPixels_ && gpuFrames_.Start(std::string(app_->activity->internalDataPath) + "/.wayland-rt/" DROIDDECK_XR_GPU_SOCKET, display_);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "GPU frame channel available=%d", gpu);
|
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "GPU frame channel available=%d", gpu);
|
||||||
}
|
}
|
||||||
overlay_.initialize();
|
|
||||||
hostState_.version = DROIDDECK_XR_HOST_VERSION;
|
|
||||||
if (hostBuffersCallback) {
|
|
||||||
jobject state = env_->NewDirectByteBuffer(&hostState_, sizeof(hostState_));
|
|
||||||
jobject control = env_->NewDirectByteBuffer(&hostControl_, sizeof(hostControl_));
|
|
||||||
env_->CallVoidMethod(app_->activity->clazz, hostBuffersCallback, state, control);
|
|
||||||
if (env_->ExceptionCheck()) { env_->ExceptionDescribe(); env_->ExceptionClear(); hostFrameCallback_ = nullptr; }
|
|
||||||
else hostBuffers_ = true;
|
|
||||||
env_->DeleteLocalRef(state); env_->DeleteLocalRef(control);
|
|
||||||
}
|
|
||||||
health();
|
health();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,13 +422,6 @@ private:
|
|||||||
target.images.resize(count, {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR});
|
target.images.resize(count, {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR});
|
||||||
check(xrEnumerateSwapchainImages(target.swapchain, count, &count,
|
check(xrEnumerateSwapchainImages(target.swapchain, count, &count,
|
||||||
reinterpret_cast<XrSwapchainImageBaseHeader *>(target.images.data())), "images");
|
reinterpret_cast<XrSwapchainImageBaseHeader *>(target.images.data())), "images");
|
||||||
Eye &overlay = overlayEyes_[eye];
|
|
||||||
overlay.width = target.width; overlay.height = target.height;
|
|
||||||
check(xrCreateSwapchain(session_, &create, &overlay.swapchain), "overlay swapchain");
|
|
||||||
check(xrEnumerateSwapchainImages(overlay.swapchain, 0, &count, nullptr), "overlay image count");
|
|
||||||
overlay.images.resize(count, {XR_TYPE_SWAPCHAIN_IMAGE_OPENGL_ES_KHR});
|
|
||||||
check(xrEnumerateSwapchainImages(overlay.swapchain, count, &count,
|
|
||||||
reinterpret_cast<XrSwapchainImageBaseHeader *>(overlay.images.data())), "overlay images");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -650,12 +530,6 @@ private:
|
|||||||
|
|
||||||
void initializeGraphics() {
|
void initializeGraphics() {
|
||||||
glGenFramebuffers(1, &framebuffer_);
|
glGenFramebuffers(1, &framebuffer_);
|
||||||
glGenRenderbuffers(2, overlayDepth_);
|
|
||||||
for (int eye = 0; eye < 2; eye++) {
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, overlayDepth_[eye]);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, overlayEyes_[eye].width, overlayEyes_[eye].height);
|
|
||||||
}
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
|
||||||
glGenVertexArrays(1, &vertexArray_);
|
glGenVertexArrays(1, &vertexArray_);
|
||||||
GLuint vertex = shader(GL_VERTEX_SHADER,
|
GLuint vertex = shader(GL_VERTEX_SHADER,
|
||||||
"#version 300 es\nout vec2 uv; uniform float eye; void main(){vec2 coordinate=vec2(float((gl_VertexID<<1)&2),float(gl_VertexID&2));uv=vec2(coordinate.x*0.5+eye*0.5,1.0-coordinate.y);gl_Position=vec4(coordinate*2.0-1.0,0.0,1.0);}");
|
"#version 300 es\nout vec2 uv; uniform float eye; void main(){vec2 coordinate=vec2(float((gl_VertexID<<1)&2),float(gl_VertexID&2));uv=vec2(coordinate.x*0.5+eye*0.5,1.0-coordinate.y);gl_Position=vec4(coordinate*2.0-1.0,0.0,1.0);}");
|
||||||
@@ -710,46 +584,24 @@ private:
|
|||||||
if (verifyPixels_ || uploadedFrames_ % 72 == 1) health();
|
if (verifyPixels_ || uploadedFrames_ % 72 == 1) health();
|
||||||
}
|
}
|
||||||
|
|
||||||
void render(Eye &eye, uint32_t image, bool source, const XrPosef &pose, const XrFovf &fov, float seconds) {
|
void render(Eye &eye, uint32_t image) {
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eye.images[image].image, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eye.images[image].image, 0);
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||||
throw std::runtime_error("Incomplete eye framebuffer");
|
throw std::runtime_error("Incomplete eye framebuffer");
|
||||||
glViewport(0, 0, eye.width, eye.height); glDisable(GL_DEPTH_TEST);
|
{
|
||||||
if (source) {
|
glViewport(0, 0, eye.width, eye.height); glDisable(GL_DEPTH_TEST);
|
||||||
glUseProgram(sourceProgram_); glBindVertexArray(vertexArray_);
|
glUseProgram(sourceProgram_); glBindVertexArray(vertexArray_);
|
||||||
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sourceTexture_);
|
glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, sourceTexture_);
|
||||||
glUniform1i(glGetUniformLocation(sourceProgram_, "source"), 0);
|
glUniform1i(glGetUniformLocation(sourceProgram_, "source"), 0);
|
||||||
glUniform1f(glGetUniformLocation(sourceProgram_, "eye"), &eye == &eyes_[1] ? 1.f : 0.f);
|
glUniform1f(glGetUniformLocation(sourceProgram_, "eye"), &eye == &eyes_[1] ? 1.f : 0.f);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||||
} else {
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
}
|
}
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
if (glGetError() != GL_NO_ERROR) throw std::runtime_error("OpenGL render error");
|
if (glGetError() != GL_NO_ERROR) throw std::runtime_error("OpenGL render error");
|
||||||
glFlush();
|
glFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lasers and the orb go in their own layer above the panels, which only the panels' depth hides.
|
|
||||||
void renderOverlay(int index, uint32_t image, const XrPosef &pose, const XrFovf &fov, float seconds) {
|
|
||||||
Eye &eye = overlayEyes_[index];
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_);
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eye.images[image].image, 0);
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, overlayDepth_[index]);
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
||||||
throw std::runtime_error("Incomplete overlay framebuffer");
|
|
||||||
glViewport(0, 0, eye.width, eye.height);
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f); glClearDepthf(1.f);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
overlay_.draw(pose, fov, hostControl_, hostState_, seconds);
|
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
if (glGetError() != GL_NO_ERROR) throw std::runtime_error("OpenGL overlay error");
|
|
||||||
glFlush();
|
|
||||||
}
|
|
||||||
|
|
||||||
void pollEvents() {
|
void pollEvents() {
|
||||||
XrEventDataBuffer event{XR_TYPE_EVENT_DATA_BUFFER};
|
XrEventDataBuffer event{XR_TYPE_EVENT_DATA_BUFFER};
|
||||||
XrResult result;
|
XrResult result;
|
||||||
@@ -833,7 +685,6 @@ private:
|
|||||||
XrViewState viewState{XR_TYPE_VIEW_STATE}; uint32_t count = 0;
|
XrViewState viewState{XR_TYPE_VIEW_STATE}; uint32_t count = 0;
|
||||||
XrView views[2]{{XR_TYPE_VIEW}, {XR_TYPE_VIEW}};
|
XrView views[2]{{XR_TYPE_VIEW}, {XR_TYPE_VIEW}};
|
||||||
check(xrLocateViews(session_, &locate, &viewState, 2, &count, views), "xrLocateViews");
|
check(xrLocateViews(session_, &locate, &viewState, 2, &count, views), "xrLocateViews");
|
||||||
hostFrame(frameState.predictedDisplayTime);
|
|
||||||
publishTracking(views, frameState.predictedDisplayTime);
|
publishTracking(views, frameState.predictedDisplayTime);
|
||||||
if (guestAttached_) {
|
if (guestAttached_) {
|
||||||
timespec now{}; clock_gettime(CLOCK_MONOTONIC, &now);
|
timespec now{}; clock_gettime(CLOCK_MONOTONIC, &now);
|
||||||
@@ -841,34 +692,29 @@ private:
|
|||||||
if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("Guest frame callback failed"); }
|
if (env_->ExceptionCheck()) { env_->ExceptionClear(); throw std::runtime_error("Guest frame callback failed"); }
|
||||||
}
|
}
|
||||||
XrCompositionLayerProjectionView projection[2]{{XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}, {XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}};
|
XrCompositionLayerProjectionView projection[2]{{XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}, {XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}};
|
||||||
const bool viewsValid = frameState.shouldRender && count == 2 &&
|
bool valid = frameState.shouldRender && count == 2 &&
|
||||||
(viewState.viewStateFlags & (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT))
|
(viewState.viewStateFlags & (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT))
|
||||||
== (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT);
|
== (XR_VIEW_STATE_ORIENTATION_VALID_BIT | XR_VIEW_STATE_POSITION_VALID_BIT);
|
||||||
bool valid = viewsValid && sourceHeader_.frame_id && xr_frame_now() - sourceHeader_.captured_ns < 500000000LL;
|
{
|
||||||
if (valid) for (int eye = 0; eye < 2; eye++) {
|
valid = valid && sourceHeader_.frame_id && xr_frame_now() - sourceHeader_.captured_ns < 500000000LL;
|
||||||
auto source = xr_frame_view(sourceHeader_, eye);
|
if (valid) for (int eye = 0; eye < 2; eye++) {
|
||||||
views[eye].pose.orientation = {source.orientation[0], source.orientation[1], source.orientation[2], source.orientation[3]};
|
auto source = xr_frame_view(sourceHeader_, eye);
|
||||||
views[eye].pose.position = {source.position[0], source.position[1], source.position[2]};
|
views[eye].pose.orientation = {source.orientation[0], source.orientation[1], source.orientation[2], source.orientation[3]};
|
||||||
views[eye].fov = {source.fov[0], source.fov[1], source.fov[2], source.fov[3]};
|
views[eye].pose.position = {source.position[0], source.position[1], source.position[2]};
|
||||||
|
views[eye].fov = {source.fov[0], source.fov[1], source.fov[2], source.fov[3]};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::vector<XrCompositionLayerQuad> quads;
|
|
||||||
std::vector<XrCompositionLayerImageLayoutFB> layouts;
|
|
||||||
if (viewsValid) collectQuads(quads, layouts);
|
|
||||||
const bool uiOnly = !valid && viewsValid && !quads.empty();
|
|
||||||
const bool draw = valid || uiOnly;
|
|
||||||
const std::string capture = captureRequest();
|
const std::string capture = captureRequest();
|
||||||
bool captured = valid;
|
bool captured = valid;
|
||||||
if (!capture.empty() && valid)
|
if (!capture.empty() && valid)
|
||||||
captured = captureTexture(sourceTexture_, sourceHeader_.width, sourceHeader_.height, "source");
|
captured = captureTexture(sourceTexture_, sourceHeader_.width, sourceHeader_.height, "source");
|
||||||
timespec clock{}; clock_gettime(CLOCK_MONOTONIC, &clock);
|
if (valid) for (int eye = 0; eye < 2; eye++) {
|
||||||
const float seconds = (float)(clock.tv_sec % 3600) + clock.tv_nsec * 1e-9f;
|
|
||||||
if (draw) for (int eye = 0; eye < 2; eye++) {
|
|
||||||
uint32_t image = 0;
|
uint32_t image = 0;
|
||||||
XrSwapchainImageAcquireInfo acquire{XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO};
|
XrSwapchainImageAcquireInfo acquire{XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO};
|
||||||
check(xrAcquireSwapchainImage(eyes_[eye].swapchain, &acquire, &image), "acquire image");
|
check(xrAcquireSwapchainImage(eyes_[eye].swapchain, &acquire, &image), "acquire image");
|
||||||
XrSwapchainImageWaitInfo imageWait{XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO}; imageWait.timeout = XR_INFINITE_DURATION;
|
XrSwapchainImageWaitInfo imageWait{XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO}; imageWait.timeout = XR_INFINITE_DURATION;
|
||||||
check(xrWaitSwapchainImage(eyes_[eye].swapchain, &imageWait), "wait image");
|
check(xrWaitSwapchainImage(eyes_[eye].swapchain, &imageWait), "wait image");
|
||||||
render(eyes_[eye], image, valid, views[eye].pose, views[eye].fov, seconds);
|
render(eyes_[eye], image);
|
||||||
if (!capture.empty()) captured = captureTexture(eyes_[eye].images[image].image, eyes_[eye].width, eyes_[eye].height, eye ? "right" : "left") && captured;
|
if (!capture.empty()) captured = captureTexture(eyes_[eye].images[image].image, eyes_[eye].width, eyes_[eye].height, eye ? "right" : "left") && captured;
|
||||||
XrSwapchainImageReleaseInfo release{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO};
|
XrSwapchainImageReleaseInfo release{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO};
|
||||||
check(xrReleaseSwapchainImage(eyes_[eye].swapchain, &release), "release image");
|
check(xrReleaseSwapchainImage(eyes_[eye].swapchain, &release), "release image");
|
||||||
@@ -876,143 +722,19 @@ private:
|
|||||||
projection[eye].subImage.swapchain = eyes_[eye].swapchain;
|
projection[eye].subImage.swapchain = eyes_[eye].swapchain;
|
||||||
projection[eye].subImage.imageRect.extent = {eyes_[eye].width, eyes_[eye].height};
|
projection[eye].subImage.imageRect.extent = {eyes_[eye].width, eyes_[eye].height};
|
||||||
}
|
}
|
||||||
const bool overlay = viewsValid && hostBuffers_ && XrOverlay::active(hostControl_);
|
|
||||||
XrCompositionLayerProjectionView overlayViews[2]{{XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}, {XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW}};
|
|
||||||
if (overlay) for (int eye = 0; eye < 2; eye++) {
|
|
||||||
uint32_t image = 0;
|
|
||||||
XrSwapchainImageAcquireInfo acquire{XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO};
|
|
||||||
check(xrAcquireSwapchainImage(overlayEyes_[eye].swapchain, &acquire, &image), "acquire overlay image");
|
|
||||||
XrSwapchainImageWaitInfo imageWait{XR_TYPE_SWAPCHAIN_IMAGE_WAIT_INFO}; imageWait.timeout = XR_INFINITE_DURATION;
|
|
||||||
check(xrWaitSwapchainImage(overlayEyes_[eye].swapchain, &imageWait), "wait overlay image");
|
|
||||||
renderOverlay(eye, image, views[eye].pose, views[eye].fov, seconds);
|
|
||||||
XrSwapchainImageReleaseInfo release{XR_TYPE_SWAPCHAIN_IMAGE_RELEASE_INFO};
|
|
||||||
check(xrReleaseSwapchainImage(overlayEyes_[eye].swapchain, &release), "release overlay image");
|
|
||||||
overlayViews[eye].pose = views[eye].pose; overlayViews[eye].fov = views[eye].fov;
|
|
||||||
overlayViews[eye].subImage.swapchain = overlayEyes_[eye].swapchain;
|
|
||||||
overlayViews[eye].subImage.imageRect.extent = {overlayEyes_[eye].width, overlayEyes_[eye].height};
|
|
||||||
}
|
|
||||||
XrCompositionLayerProjection layer{XR_TYPE_COMPOSITION_LAYER_PROJECTION};
|
XrCompositionLayerProjection layer{XR_TYPE_COMPOSITION_LAYER_PROJECTION};
|
||||||
layer.space = world_; layer.viewCount = 2; layer.views = projection;
|
layer.space = world_; layer.viewCount = 2; layer.views = projection;
|
||||||
XrCompositionLayerProjection overlayLayer{XR_TYPE_COMPOSITION_LAYER_PROJECTION};
|
const XrCompositionLayerBaseHeader *layers[] = {reinterpret_cast<XrCompositionLayerBaseHeader *>(&layer)};
|
||||||
overlayLayer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT;
|
|
||||||
overlayLayer.space = world_; overlayLayer.viewCount = 2; overlayLayer.views = overlayViews;
|
|
||||||
std::vector<const XrCompositionLayerBaseHeader *> layers;
|
|
||||||
if (draw) layers.push_back(reinterpret_cast<XrCompositionLayerBaseHeader *>(&layer));
|
|
||||||
for (auto &quad : quads) layers.push_back(reinterpret_cast<XrCompositionLayerBaseHeader *>(&quad));
|
|
||||||
if (overlay) layers.push_back(reinterpret_cast<XrCompositionLayerBaseHeader *>(&overlayLayer));
|
|
||||||
visibleLayers_ = (int)quads.size();
|
|
||||||
XrFrameEndInfo end{XR_TYPE_FRAME_END_INFO}; end.displayTime = frameState.predictedDisplayTime;
|
XrFrameEndInfo end{XR_TYPE_FRAME_END_INFO}; end.displayTime = frameState.predictedDisplayTime;
|
||||||
end.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
|
end.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE; end.layerCount = valid ? 1 : 0; end.layers = layers;
|
||||||
end.layerCount = (uint32_t)layers.size(); end.layers = layers.data();
|
|
||||||
check(xrEndFrame(session_, &end), "xrEndFrame");
|
check(xrEndFrame(session_, &end), "xrEndFrame");
|
||||||
if (!capture.empty()) captureResult(capture, captured, valid, projection, frameState.predictedDisplayTime);
|
if (!capture.empty()) captureResult(capture, captured, valid, projection, frameState.predictedDisplayTime);
|
||||||
frames_++; if (valid) rendered_++;
|
frames_++; if (valid) rendered_++;
|
||||||
if (frames_ % 72 == 0) {
|
if (frames_ % 72 == 0) {
|
||||||
health();
|
health();
|
||||||
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "frames=%llu rendered=%llu head=%llu hands=%d,%d period=%lld layers=%d",
|
__android_log_print(ANDROID_LOG_INFO, "DroidDeckXR", "frames=%llu rendered=%llu head=%llu hands=%d,%d period=%lld",
|
||||||
(unsigned long long)frames_, (unsigned long long)rendered_, (unsigned long long)head_.locationFlags,
|
(unsigned long long)frames_, (unsigned long long)rendered_, (unsigned long long)head_.locationFlags,
|
||||||
handActive_[0], handActive_[1], (long long)period_, visibleLayers_);
|
handActive_[0], handActive_[1], (long long)period_);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Android surfaces are stored top row first, while OpenXR samples images bottom row first.
|
|
||||||
void collectQuads(std::vector<XrCompositionLayerQuad> &quads, std::vector<XrCompositionLayerImageLayoutFB> &layouts) {
|
|
||||||
if (!hostBuffers_) return;
|
|
||||||
quads.reserve(DROIDDECK_XR_HOST_LAYERS);
|
|
||||||
layouts.reserve(DROIDDECK_XR_HOST_LAYERS);
|
|
||||||
const DroidDeckXrHostLayer *ordered[DROIDDECK_XR_HOST_LAYERS];
|
|
||||||
int visible = 0;
|
|
||||||
for (const auto &layer : hostControl_.layers) {
|
|
||||||
if (!layer.visible || layer.id < 0 || layer.id >= DROIDDECK_XR_HOST_LAYERS || !layers_[layer.id].swapchain) continue;
|
|
||||||
if (!(layer.width > 0.f) || !(layer.height > 0.f)) continue;
|
|
||||||
ordered[visible++] = &layer;
|
|
||||||
}
|
|
||||||
std::sort(ordered, ordered + visible, [](const DroidDeckXrHostLayer *a, const DroidDeckXrHostLayer *b) { return a->order < b->order; });
|
|
||||||
for (int index = 0; index < visible; index++) {
|
|
||||||
const auto &layer = *ordered[index];
|
|
||||||
const SurfaceLayer &surface = layers_[layer.id];
|
|
||||||
XrCompositionLayerQuad quad{XR_TYPE_COMPOSITION_LAYER_QUAD};
|
|
||||||
quad.layerFlags = (layer.flags & DROIDDECK_XR_HOST_LAYER_ALPHA) ? XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT : 0;
|
|
||||||
quad.space = (layer.flags & DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED) ? view_ : world_;
|
|
||||||
quad.eyeVisibility = XR_EYE_VISIBILITY_BOTH;
|
|
||||||
quad.subImage.swapchain = surface.swapchain;
|
|
||||||
quad.subImage.imageRect.extent = {surface.width, surface.height};
|
|
||||||
quad.pose.orientation = {layer.pose.orientation[0], layer.pose.orientation[1], layer.pose.orientation[2], layer.pose.orientation[3]};
|
|
||||||
quad.pose.position = {layer.pose.position[0], layer.pose.position[1], layer.pose.position[2]};
|
|
||||||
quad.size = {layer.width, layer.height};
|
|
||||||
layouts.push_back({XR_TYPE_COMPOSITION_LAYER_IMAGE_LAYOUT_FB, nullptr, XR_COMPOSITION_LAYER_IMAGE_LAYOUT_VERTICAL_FLIP_BIT_FB});
|
|
||||||
quad.next = &layouts.back();
|
|
||||||
quads.push_back(quad);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// SteamVR draws its laser from the "tip" of the Quest Touch render model the driver names
|
|
||||||
// (resources/rendermodels/oculus_quest_plus_controller_*), placed on the raw grip pose; panels
|
|
||||||
// use the same ray so there is one laser per controller.
|
|
||||||
static DroidDeckXrPose steamVrPointer(const XrSpaceLocation &grip, int hand) {
|
|
||||||
const float q[4] = {grip.pose.orientation.x, grip.pose.orientation.y, grip.pose.orientation.z, grip.pose.orientation.w};
|
|
||||||
const XrVec3 tip{hand == 0 ? 0.016694f : -0.016694f, -0.02522f, 0.024687f};
|
|
||||||
const XrVec3 at = XrVec3{grip.pose.position.x, grip.pose.position.y, grip.pose.position.z} + rotate(q, tip);
|
|
||||||
const float tx = -0.320613f, tw = 0.947210f;
|
|
||||||
DroidDeckXrPose pose{};
|
|
||||||
pose.orientation[0] = q[3] * tx + q[0] * tw;
|
|
||||||
pose.orientation[1] = q[1] * tw + q[2] * tx;
|
|
||||||
pose.orientation[2] = q[2] * tw - q[1] * tx;
|
|
||||||
pose.orientation[3] = q[3] * tw - q[0] * tx;
|
|
||||||
pose.position[0] = at.x; pose.position[1] = at.y; pose.position[2] = at.z;
|
|
||||||
pose.flags = (uint32_t)grip.locationFlags;
|
|
||||||
return pose;
|
|
||||||
}
|
|
||||||
|
|
||||||
void hostFrame(XrTime predicted) {
|
|
||||||
if (!hostBuffers_ || !hostFrameCallback_) return;
|
|
||||||
hostState_.version = DROIDDECK_XR_HOST_VERSION;
|
|
||||||
hostState_.session_state = state_;
|
|
||||||
hostState_.flags = (surfaceSupported_ ? DROIDDECK_XR_HOST_SURFACE_SWAPCHAIN : 0u) |
|
|
||||||
(state_ == XR_SESSION_STATE_FOCUSED ? DROIDDECK_XR_HOST_FOCUSED : 0u);
|
|
||||||
hostState_.frame = (int64_t)frames_;
|
|
||||||
hostState_.display_time_ns = 0;
|
|
||||||
if (convertTime_) {
|
|
||||||
timespec displayTime{};
|
|
||||||
if (XR_SUCCEEDED(convertTime_(instance_, predicted, &displayTime)))
|
|
||||||
hostState_.display_time_ns = (int64_t)displayTime.tv_sec * 1000000000LL + displayTime.tv_nsec;
|
|
||||||
}
|
|
||||||
hostState_.head = posePacket(head_.pose, head_.locationFlags);
|
|
||||||
const XrSpaceLocationFlags tracked = XR_SPACE_LOCATION_ORIENTATION_VALID_BIT | XR_SPACE_LOCATION_POSITION_VALID_BIT;
|
|
||||||
for (int hand = 0; hand < 2; hand++) {
|
|
||||||
auto &out = hostState_.hands[hand];
|
|
||||||
out.grip = posePacket(handLocations_[hand].pose, handLocations_[hand].locationFlags);
|
|
||||||
out.aim = steamVrPointer(handLocations_[hand], hand);
|
|
||||||
out.trigger = inputs_[hand].trigger; out.squeeze = inputs_[hand].squeeze;
|
|
||||||
out.stick[0] = inputs_[hand].stick[0]; out.stick[1] = inputs_[hand].stick[1];
|
|
||||||
out.buttons = inputs_[hand].buttons;
|
|
||||||
out.active = handActive_[hand] && (handLocations_[hand].locationFlags & tracked) == tracked;
|
|
||||||
}
|
|
||||||
env_->CallVoidMethod(app_->activity->clazz, hostFrameCallback_);
|
|
||||||
if (env_->ExceptionCheck()) {
|
|
||||||
env_->ExceptionDescribe(); env_->ExceptionClear();
|
|
||||||
hostControl_ = {};
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (hostControl_.version != DROIDDECK_XR_HOST_VERSION) { hostControl_ = {}; return; }
|
|
||||||
for (int hand = 0; hand < 2; hand++) {
|
|
||||||
const auto &control = hostControl_.hands[hand];
|
|
||||||
if (control.mask & DROIDDECK_XR_HOST_MASK_INPUT) {
|
|
||||||
inputs_[hand].trigger = 0; inputs_[hand].squeeze = 0;
|
|
||||||
inputs_[hand].stick[0] = inputs_[hand].stick[1] = 0;
|
|
||||||
inputs_[hand].buttons = 0;
|
|
||||||
}
|
|
||||||
const auto &pulse = control.haptic;
|
|
||||||
if (pulse.id == hostPulse_[hand]) continue;
|
|
||||||
hostPulse_[hand] = pulse.id;
|
|
||||||
if (state_ != XR_SESSION_STATE_FOCUSED || !handActive_[hand]
|
|
||||||
|| pulse.duration_ns < 1000000 || pulse.duration_ns > 1000000000
|
|
||||||
|| !std::isfinite(pulse.amplitude) || pulse.amplitude < 0 || pulse.amplitude > 1
|
|
||||||
|| !std::isfinite(pulse.frequency) || pulse.frequency < 0) continue;
|
|
||||||
XrHapticActionInfo info{XR_TYPE_HAPTIC_ACTION_INFO}; info.action = vibration_; info.subactionPath = hands_[hand];
|
|
||||||
XrHapticVibration vibration{XR_TYPE_HAPTIC_VIBRATION};
|
|
||||||
vibration.duration = pulse.duration_ns; vibration.amplitude = pulse.amplitude; vibration.frequency = pulse.frequency;
|
|
||||||
check(xrApplyHapticFeedback(session_, &info, reinterpret_cast<XrHapticBaseHeader *>(&vibration)), "host haptics");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1027,17 +749,11 @@ private:
|
|||||||
munmap(tracking_, sizeof(DroidDeckXrTracking));
|
munmap(tracking_, sizeof(DroidDeckXrTracking));
|
||||||
}
|
}
|
||||||
if (haptics_) munmap(haptics_, sizeof(DroidDeckXrHaptics));
|
if (haptics_) munmap(haptics_, sizeof(DroidDeckXrHaptics));
|
||||||
g_runtime = nullptr;
|
|
||||||
hostBuffers_ = false;
|
|
||||||
if (display_ != EGL_NO_DISPLAY && context_ != EGL_NO_CONTEXT) {
|
if (display_ != EGL_NO_DISPLAY && context_ != EGL_NO_CONTEXT) {
|
||||||
glDeleteFramebuffers(1, &framebuffer_); glDeleteVertexArrays(1, &vertexArray_);
|
glDeleteFramebuffers(1, &framebuffer_); glDeleteVertexArrays(1, &vertexArray_);
|
||||||
glDeleteTextures(1, &cpuTexture_); glDeleteProgram(sourceProgram_);
|
glDeleteTextures(1, &cpuTexture_); glDeleteProgram(sourceProgram_);
|
||||||
glDeleteRenderbuffers(2, overlayDepth_);
|
|
||||||
overlay_.destroy();
|
|
||||||
}
|
}
|
||||||
if (env_) for (int index = 0; index < DROIDDECK_XR_HOST_LAYERS; index++) destroyLayer(env_, index);
|
|
||||||
for (auto &eye : eyes_) if (eye.swapchain) xrDestroySwapchain(eye.swapchain);
|
for (auto &eye : eyes_) if (eye.swapchain) xrDestroySwapchain(eye.swapchain);
|
||||||
for (auto &eye : overlayEyes_) if (eye.swapchain) xrDestroySwapchain(eye.swapchain);
|
|
||||||
for (auto space : handSpaces_) if (space) xrDestroySpace(space);
|
for (auto space : handSpaces_) if (space) xrDestroySpace(space);
|
||||||
if (view_) xrDestroySpace(view_); if (world_) xrDestroySpace(world_);
|
if (view_) xrDestroySpace(view_); if (world_) xrDestroySpace(world_);
|
||||||
if (session_) xrDestroySession(session_);
|
if (session_) xrDestroySession(session_);
|
||||||
@@ -1053,26 +769,6 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern "C" JNIEXPORT jint JNICALL
|
|
||||||
Java_com_droiddeck_launcher_QuestXrActivity_nativeCreateLayer(JNIEnv *env, jobject, jint width, jint height) {
|
|
||||||
return g_runtime ? g_runtime->createLayer(env, width, height) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jobject JNICALL
|
|
||||||
Java_com_droiddeck_launcher_QuestXrActivity_nativeLayerSurface(JNIEnv *env, jobject, jint index) {
|
|
||||||
return g_runtime ? g_runtime->layerSurface(env, index) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_QuestXrActivity_nativeDestroyLayer(JNIEnv *env, jobject, jint index) {
|
|
||||||
if (g_runtime) g_runtime->destroyLayer(env, index);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_QuestXrActivity_nativeSetOrbImage(JNIEnv *env, jobject, jobject bitmap) {
|
|
||||||
if (g_runtime) g_runtime->setOrbImage(env, bitmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
void android_main(android_app *app) {
|
void android_main(android_app *app) {
|
||||||
QuestXR runtime(app);
|
QuestXR runtime(app);
|
||||||
try { runtime.run(); }
|
try { runtime.run(); }
|
||||||
|
|||||||
@@ -1,91 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "xr_tracking.h"
|
|
||||||
|
|
||||||
// Shared with com.droiddeck.launcher.session.xr.XrHost, which reads and writes these through direct
|
|
||||||
// ByteBuffers by fixed offset: any layout change must bump the version and update both sides.
|
|
||||||
#define DROIDDECK_XR_HOST_VERSION 1u
|
|
||||||
#define DROIDDECK_XR_HOST_LAYERS 6
|
|
||||||
|
|
||||||
#define DROIDDECK_XR_HOST_SURFACE_SWAPCHAIN (1u << 0)
|
|
||||||
#define DROIDDECK_XR_HOST_FOCUSED (1u << 1)
|
|
||||||
|
|
||||||
#define DROIDDECK_XR_HOST_MASK_INPUT (1u << 0)
|
|
||||||
|
|
||||||
#define DROIDDECK_XR_HOST_LAYER_ALPHA (1u << 0)
|
|
||||||
#define DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED (1u << 1)
|
|
||||||
|
|
||||||
struct DroidDeckXrHostHand {
|
|
||||||
DroidDeckXrPose grip;
|
|
||||||
DroidDeckXrPose aim;
|
|
||||||
float trigger, squeeze, stick[2];
|
|
||||||
uint32_t buttons, active;
|
|
||||||
uint32_t reserved[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostState {
|
|
||||||
uint32_t version, session_state, flags, reserved0;
|
|
||||||
int64_t frame, display_time_ns;
|
|
||||||
DroidDeckXrPose head;
|
|
||||||
DroidDeckXrHostHand hands[2];
|
|
||||||
uint32_t reserved[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostHaptic {
|
|
||||||
uint64_t id;
|
|
||||||
int64_t duration_ns;
|
|
||||||
float amplitude, frequency;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostHandControl {
|
|
||||||
uint32_t mask;
|
|
||||||
float laser;
|
|
||||||
DroidDeckXrHostHaptic haptic;
|
|
||||||
uint32_t reserved[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostOrb {
|
|
||||||
uint32_t visible;
|
|
||||||
float progress, burst, radius;
|
|
||||||
DroidDeckXrPose pose;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostLayer {
|
|
||||||
int32_t id;
|
|
||||||
uint32_t visible, flags;
|
|
||||||
int32_t order;
|
|
||||||
DroidDeckXrPose pose;
|
|
||||||
float width, height;
|
|
||||||
uint32_t reserved[2];
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DroidDeckXrHostControl {
|
|
||||||
uint32_t version, reserved0;
|
|
||||||
DroidDeckXrHostHandControl hands[2];
|
|
||||||
DroidDeckXrHostOrb orb;
|
|
||||||
DroidDeckXrHostLayer layers[DROIDDECK_XR_HOST_LAYERS];
|
|
||||||
uint32_t reserved[8];
|
|
||||||
};
|
|
||||||
|
|
||||||
static_assert(sizeof(DroidDeckXrHostHand) == 96, "XR host hand layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostHand, aim) == 32 && offsetof(DroidDeckXrHostHand, trigger) == 64 &&
|
|
||||||
offsetof(DroidDeckXrHostHand, stick) == 72 && offsetof(DroidDeckXrHostHand, buttons) == 80 &&
|
|
||||||
offsetof(DroidDeckXrHostHand, active) == 84, "XR host hand layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostState, flags) == 8 && offsetof(DroidDeckXrHostState, frame) == 16 &&
|
|
||||||
offsetof(DroidDeckXrHostState, head) == 32, "XR host state layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostHandControl, laser) == 4 && offsetof(DroidDeckXrHostHandControl, haptic) == 8,
|
|
||||||
"XR host hand control layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostHaptic, duration_ns) == 8 && offsetof(DroidDeckXrHostHaptic, amplitude) == 16,
|
|
||||||
"XR host haptic layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostOrb, progress) == 4 && offsetof(DroidDeckXrHostOrb, pose) == 16, "XR host orb layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostLayer, order) == 12 && offsetof(DroidDeckXrHostLayer, pose) == 16 &&
|
|
||||||
offsetof(DroidDeckXrHostLayer, width) == 48, "XR host layer layout");
|
|
||||||
static_assert(sizeof(DroidDeckXrHostState) == 288, "XR host state layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostState, hands) == 64, "XR host state layout");
|
|
||||||
static_assert(sizeof(DroidDeckXrHostHandControl) == 40, "XR host hand control layout");
|
|
||||||
static_assert(sizeof(DroidDeckXrHostOrb) == 48, "XR host orb layout");
|
|
||||||
static_assert(sizeof(DroidDeckXrHostLayer) == 64, "XR host layer layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostControl, orb) == 88, "XR host control layout");
|
|
||||||
static_assert(offsetof(DroidDeckXrHostControl, layers) == 136, "XR host control layout");
|
|
||||||
static_assert(sizeof(DroidDeckXrHostControl) == 552, "XR host control layout");
|
|
||||||
@@ -1,229 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
#include <GLES3/gl3.h>
|
|
||||||
#include <openxr/openxr.h>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cmath>
|
|
||||||
#include <stdexcept>
|
|
||||||
#include "xr_host.h"
|
|
||||||
|
|
||||||
struct XrVec3 { float x, y, z; };
|
|
||||||
|
|
||||||
static inline XrVec3 xrv(float x, float y, float z) { return {x, y, z}; }
|
|
||||||
static inline XrVec3 operator+(XrVec3 a, XrVec3 b) { return {a.x + b.x, a.y + b.y, a.z + b.z}; }
|
|
||||||
static inline XrVec3 operator-(XrVec3 a, XrVec3 b) { return {a.x - b.x, a.y - b.y, a.z - b.z}; }
|
|
||||||
static inline XrVec3 operator*(XrVec3 a, float s) { return {a.x * s, a.y * s, a.z * s}; }
|
|
||||||
static inline float dot(XrVec3 a, XrVec3 b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
|
|
||||||
static inline XrVec3 cross(XrVec3 a, XrVec3 b) { return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
|
|
||||||
static inline XrVec3 normalized(XrVec3 a) {
|
|
||||||
float length = std::sqrt(dot(a, a));
|
|
||||||
return length > 1e-6f ? a * (1.f / length) : xrv(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline XrVec3 rotate(const float q[4], XrVec3 v) {
|
|
||||||
XrVec3 u{q[0], q[1], q[2]};
|
|
||||||
float s = q[3];
|
|
||||||
return u * (2.f * dot(u, v)) + v * (s * s - dot(u, u)) + cross(u, v) * (2.f * s);
|
|
||||||
}
|
|
||||||
|
|
||||||
class XrOverlay {
|
|
||||||
public:
|
|
||||||
void initialize() {
|
|
||||||
GLuint vertex = compile(GL_VERTEX_SHADER,
|
|
||||||
"#version 300 es\nlayout(location=0) in vec3 position; layout(location=1) in vec2 coordinate;"
|
|
||||||
"uniform mat4 viewProjection; out vec2 uv;"
|
|
||||||
"void main(){uv=coordinate;gl_Position=viewProjection*vec4(position,1.0);}");
|
|
||||||
GLuint fragment = compile(GL_FRAGMENT_SHADER,
|
|
||||||
"#version 300 es\nprecision highp float; in vec2 uv; uniform int mode; uniform float progress, burst, time;"
|
|
||||||
"uniform vec3 color; uniform sampler2D logo; uniform int hasLogo; out vec4 outputColor;"
|
|
||||||
"void main(){"
|
|
||||||
" if(mode==0){float across=1.0-abs(uv.y); float a=smoothstep(0.0,0.7,across)*mix(0.95,0.35,uv.x);"
|
|
||||||
" outputColor=vec4(color*a,a);return;}"
|
|
||||||
" if(mode==1){float r=length(uv); float a=1.0-smoothstep(0.55,1.0,r); outputColor=vec4(vec3(1.0)*a,a);return;}"
|
|
||||||
" float r=length(uv); vec3 c=vec3(0.0); float a=0.0;"
|
|
||||||
" float pulse=0.5+0.5*sin(time*6.0);"
|
|
||||||
" float glow=exp(-pow(max(r-0.45,0.0)*6.0,2.0))*(0.25+0.2*pulse)*step(0.5,r); c+=color*glow; a=max(a,glow*0.7);"
|
|
||||||
" if(hasLogo==1&&r<0.52){vec4 l=texture(logo,vec2(0.5+uv.x/1.04,0.5-uv.y/1.04)); c=c*(1.0-l.a)+l.rgb; a=a*(1.0-l.a)+l.a;}"
|
|
||||||
" else if(r<0.5){float core=1.0-smoothstep(0.46,0.5,r); c+=color*core; a=max(a,core);}"
|
|
||||||
" float angle=atan(uv.x,uv.y); float sweep=(angle<0.0?angle+6.2831853:angle)/6.2831853;"
|
|
||||||
" float band=1.0-smoothstep(0.0,0.03,abs(r-0.64));"
|
|
||||||
" float track=band*0.25; float fill=band*step(sweep,progress);"
|
|
||||||
" c+=vec3(1.0)*track+color*fill*1.4; a=max(a,max(track,fill));"
|
|
||||||
" if(burst>0.0){float ring=(1.0-smoothstep(0.0,0.06,abs(r-(0.64+burst*0.3))))*(1.0-burst); c+=color*ring*2.0; a=max(a,ring);}"
|
|
||||||
" a=clamp(a,0.0,1.0); outputColor=vec4(c*a,a);"
|
|
||||||
"}");
|
|
||||||
program_ = glCreateProgram();
|
|
||||||
glAttachShader(program_, vertex); glAttachShader(program_, fragment);
|
|
||||||
glLinkProgram(program_); glDeleteShader(vertex); glDeleteShader(fragment);
|
|
||||||
GLint linked = 0; glGetProgramiv(program_, GL_LINK_STATUS, &linked);
|
|
||||||
if (!linked) throw std::runtime_error("Overlay shader link failed");
|
|
||||||
viewProjection_ = glGetUniformLocation(program_, "viewProjection");
|
|
||||||
mode_ = glGetUniformLocation(program_, "mode");
|
|
||||||
progress_ = glGetUniformLocation(program_, "progress");
|
|
||||||
burst_ = glGetUniformLocation(program_, "burst");
|
|
||||||
time_ = glGetUniformLocation(program_, "time");
|
|
||||||
color_ = glGetUniformLocation(program_, "color");
|
|
||||||
logoSampler_ = glGetUniformLocation(program_, "logo");
|
|
||||||
hasLogo_ = glGetUniformLocation(program_, "hasLogo");
|
|
||||||
glGenVertexArrays(1, &vertexArray_);
|
|
||||||
glGenBuffers(1, &buffer_);
|
|
||||||
glBindVertexArray(vertexArray_);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer_);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 5 * 6, nullptr, GL_DYNAMIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(float) * 5, nullptr);
|
|
||||||
glEnableVertexAttribArray(1);
|
|
||||||
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(float) * 5, reinterpret_cast<void *>(sizeof(float) * 3));
|
|
||||||
glBindVertexArray(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** [pixels] are premultiplied RGBA rows, top row first, as an Android ARGB_8888 bitmap holds them. */
|
|
||||||
void setLogo(const void *pixels, int width, int height, int stride) {
|
|
||||||
if (!logo_) glGenTextures(1, &logo_);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, logo_);
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, stride / 4);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroy() {
|
|
||||||
if (logo_) glDeleteTextures(1, &logo_);
|
|
||||||
logo_ = 0;
|
|
||||||
if (program_) glDeleteProgram(program_);
|
|
||||||
if (buffer_) glDeleteBuffers(1, &buffer_);
|
|
||||||
if (vertexArray_) glDeleteVertexArrays(1, &vertexArray_);
|
|
||||||
program_ = buffer_ = vertexArray_ = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool active(const DroidDeckXrHostControl &control) {
|
|
||||||
return control.orb.visible || control.hands[0].laser > 0.f || control.hands[1].laser > 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void draw(const XrPosef &eye, const XrFovf &fov, const DroidDeckXrHostControl &control,
|
|
||||||
const DroidDeckXrHostState &state, float seconds) {
|
|
||||||
if (!active(control)) return;
|
|
||||||
float matrix[16];
|
|
||||||
viewProjectionOf(eye, fov, matrix);
|
|
||||||
const float eyeOrientation[4] = {eye.orientation.x, eye.orientation.y, eye.orientation.z, eye.orientation.w};
|
|
||||||
const XrVec3 eyePosition{eye.position.x, eye.position.y, eye.position.z};
|
|
||||||
glUseProgram(program_);
|
|
||||||
glUniformMatrix4fv(viewProjection_, 1, GL_FALSE, matrix);
|
|
||||||
glUniform3f(color_, 0.12f, 0.62f, 1.0f);
|
|
||||||
glUniform1f(time_, seconds);
|
|
||||||
glBindVertexArray(vertexArray_);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, buffer_);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glUniform1i(mode_, 0);
|
|
||||||
for (const auto &layer : control.layers) {
|
|
||||||
if (!layer.visible || !(layer.width > 0.f) || !(layer.height > 0.f)) continue;
|
|
||||||
if (layer.flags & DROIDDECK_XR_HOST_LAYER_HEAD_LOCKED) continue;
|
|
||||||
XrVec3 center{layer.pose.position[0], layer.pose.position[1], layer.pose.position[2]};
|
|
||||||
XrVec3 right = rotate(layer.pose.orientation, xrv(layer.width / 2.f, 0, 0));
|
|
||||||
XrVec3 up = rotate(layer.pose.orientation, xrv(0, layer.height / 2.f, 0));
|
|
||||||
quad(center - right - up, center + right - up, center - right + up, center + right + up, 0.f, 1.f);
|
|
||||||
}
|
|
||||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
for (int hand = 0; hand < 2; hand++) {
|
|
||||||
float length = control.hands[hand].laser;
|
|
||||||
if (!(length > 0.f) || !state.hands[hand].active) continue;
|
|
||||||
const auto &aim = state.hands[hand].aim;
|
|
||||||
XrVec3 start{aim.position[0], aim.position[1], aim.position[2]};
|
|
||||||
XrVec3 direction = normalized(rotate(aim.orientation, xrv(0, 0, -1)));
|
|
||||||
XrVec3 end = start + direction * std::max(length - 0.004f, 0.f);
|
|
||||||
XrVec3 side = normalized(cross(direction, eyePosition - start)) * 0.0022f;
|
|
||||||
glUniform1i(mode_, 0);
|
|
||||||
quad(start - side, start + side, end - side, end + side, 0.f, 1.f);
|
|
||||||
XrVec3 right = rotate(eyeOrientation, xrv(1, 0, 0)) * 0.007f;
|
|
||||||
XrVec3 up = rotate(eyeOrientation, xrv(0, 1, 0)) * 0.007f;
|
|
||||||
glUniform1i(mode_, 1);
|
|
||||||
billboard(end + normalized(eyePosition - end) * 0.008f, right, up);
|
|
||||||
}
|
|
||||||
if (control.orb.visible) {
|
|
||||||
const auto &pose = control.orb.pose;
|
|
||||||
XrVec3 center{pose.position[0], pose.position[1], pose.position[2]};
|
|
||||||
float size = control.orb.radius * 1.25f;
|
|
||||||
XrVec3 right = rotate(eyeOrientation, xrv(1, 0, 0)) * size;
|
|
||||||
XrVec3 up = rotate(eyeOrientation, xrv(0, 1, 0)) * size;
|
|
||||||
glUniform1i(mode_, 2);
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, logo_);
|
|
||||||
glUniform1i(logoSampler_, 0);
|
|
||||||
glUniform1i(hasLogo_, logo_ ? 1 : 0);
|
|
||||||
glUniform1f(progress_, control.orb.progress);
|
|
||||||
glUniform1f(burst_, control.orb.burst);
|
|
||||||
billboard(center, right, up);
|
|
||||||
}
|
|
||||||
glBindVertexArray(0);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
GLuint program_ = 0, buffer_ = 0, vertexArray_ = 0, logo_ = 0;
|
|
||||||
GLint viewProjection_ = -1, mode_ = -1, progress_ = -1, burst_ = -1, time_ = -1, color_ = -1;
|
|
||||||
GLint logoSampler_ = -1, hasLogo_ = -1;
|
|
||||||
|
|
||||||
static GLuint compile(GLenum type, const char *text) {
|
|
||||||
GLuint handle = glCreateShader(type);
|
|
||||||
glShaderSource(handle, 1, &text, nullptr); glCompileShader(handle);
|
|
||||||
GLint success = 0; glGetShaderiv(handle, GL_COMPILE_STATUS, &success);
|
|
||||||
if (!success) { glDeleteShader(handle); throw std::runtime_error("Overlay shader compile failed"); }
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
void billboard(XrVec3 center, XrVec3 right, XrVec3 up) {
|
|
||||||
quadUv(center - right - up, center + right - up, center - right + up, center + right + up);
|
|
||||||
}
|
|
||||||
|
|
||||||
void quad(XrVec3 a0, XrVec3 a1, XrVec3 b0, XrVec3 b1, float from, float to) {
|
|
||||||
const float vertices[] = {
|
|
||||||
a0.x, a0.y, a0.z, from, -1, a1.x, a1.y, a1.z, from, 1, b0.x, b0.y, b0.z, to, -1,
|
|
||||||
b0.x, b0.y, b0.z, to, -1, a1.x, a1.y, a1.z, from, 1, b1.x, b1.y, b1.z, to, 1};
|
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
void quadUv(XrVec3 bottomLeft, XrVec3 bottomRight, XrVec3 topLeft, XrVec3 topRight) {
|
|
||||||
const float vertices[] = {
|
|
||||||
bottomLeft.x, bottomLeft.y, bottomLeft.z, -1, -1, bottomRight.x, bottomRight.y, bottomRight.z, 1, -1,
|
|
||||||
topLeft.x, topLeft.y, topLeft.z, -1, 1, topLeft.x, topLeft.y, topLeft.z, -1, 1,
|
|
||||||
bottomRight.x, bottomRight.y, bottomRight.z, 1, -1, topRight.x, topRight.y, topRight.z, 1, 1};
|
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void viewProjectionOf(const XrPosef &pose, const XrFovf &fov, float out[16]) {
|
|
||||||
const float q[4] = {pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w};
|
|
||||||
XrVec3 xAxis = rotate(q, xrv(1, 0, 0)), yAxis = rotate(q, xrv(0, 1, 0)), zAxis = rotate(q, xrv(0, 0, 1));
|
|
||||||
XrVec3 position{pose.position.x, pose.position.y, pose.position.z};
|
|
||||||
float view[16] = {
|
|
||||||
xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0,
|
|
||||||
-dot(xAxis, position), -dot(yAxis, position), -dot(zAxis, position), 1};
|
|
||||||
const float nearZ = 0.05f, farZ = 100.f;
|
|
||||||
float left = std::tan(fov.angleLeft), right = std::tan(fov.angleRight);
|
|
||||||
float up = std::tan(fov.angleUp), down = std::tan(fov.angleDown);
|
|
||||||
float width = right - left, height = up - down;
|
|
||||||
float projection[16] = {
|
|
||||||
2.f / width, 0, 0, 0, 0, 2.f / height, 0, 0,
|
|
||||||
(right + left) / width, (up + down) / height, -(farZ + nearZ) / (farZ - nearZ), -1,
|
|
||||||
0, 0, -2.f * farZ * nearZ / (farZ - nearZ), 0};
|
|
||||||
for (int column = 0; column < 4; column++)
|
|
||||||
for (int row = 0; row < 4; row++) {
|
|
||||||
float sum = 0;
|
|
||||||
for (int k = 0; k < 4; k++) sum += projection[k * 4 + row] * view[column * 4 + k];
|
|
||||||
out[column * 4 + row] = sum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <linux/futex.h>
|
#include <linux/futex.h>
|
||||||
@@ -28,16 +27,3 @@ Java_com_droiddeck_launcher_session_ThreadSignals_tgkill(JNIEnv *env, jclass cla
|
|||||||
(void)clazz;
|
(void)clazz;
|
||||||
return syscall(SYS_tgkill, tgid, tid, signal) == 0 ? 0 : errno;
|
return syscall(SYS_tgkill, tgid, tid, signal) == 0 ? 0 : errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jint JNICALL
|
|
||||||
Java_com_droiddeck_launcher_session_PageCacheNative_fadviseDontNeed(JNIEnv *env, jclass clazz, jstring path) {
|
|
||||||
(void)clazz;
|
|
||||||
const char *chars = (*env)->GetStringUTFChars(env, path, NULL);
|
|
||||||
if (!chars) return ENOMEM;
|
|
||||||
int fd = open(chars, O_RDONLY | O_CLOEXEC | O_NOFOLLOW);
|
|
||||||
(*env)->ReleaseStringUTFChars(env, path, chars);
|
|
||||||
if (fd < 0) return errno;
|
|
||||||
int rc = posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
|
|
||||||
close(fd);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -124,33 +124,3 @@ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|||||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGE.
|
POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
SMAA (Enhanced Subpixel Morphological Antialiasing)
|
|
||||||
---------------------------------------------------
|
|
||||||
SMAA.hlsl and the lookup tables in smaa_tables.h are from the authors' reference
|
|
||||||
implementation (github.com/iryoku/smaa).
|
|
||||||
|
|
||||||
Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com)
|
|
||||||
Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com)
|
|
||||||
Copyright (C) 2013 Belen Masia (bmasia@unizar.es)
|
|
||||||
Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com)
|
|
||||||
Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es)
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
this software and associated documentation files (the "Software"), to deal in
|
|
||||||
the Software without restriction, including without limitation the rights to
|
|
||||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software. As clarification, there is no
|
|
||||||
requirement that the copyright notice and permission be included in binary
|
|
||||||
distributions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
// - Same push constants as cas.frag: ndc, input size, sharpness [0..1].
|
// - Same push constants as cas.frag: ndc, input size, sharpness [0..1].
|
||||||
// CasSetup's const1.x = -1 / lerp(8, 5, sharpness) is computed here.
|
// CasSetup's const1.x = -1 / lerp(8, 5, sharpness) is computed here.
|
||||||
// - The input is the effect chain's previous target at the same size, so the
|
// - The input is the effect chain's previous target at the same size, so the
|
||||||
// output pixel reads the input pixel 1:1 (texel centres, edges clamped).
|
// output pixel reads the input pixel 1:1 (texelFetch, edges clamped).
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and
|
// DD_HALF is set for the *_half_frag.h build (gen_shaders.sh): colour and
|
||||||
@@ -64,8 +64,8 @@ layout(location = 0) in highp vec2 fragTexCoord;
|
|||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
|
|
||||||
vec3 CasLoad(ivec2 p) {
|
vec3 CasLoad(ivec2 p) {
|
||||||
highp vec2 uv = (vec2(p) + 0.5) / pc.resolution;
|
ivec2 sz = textureSize(InputTexture, 0);
|
||||||
return textureLod(InputTexture, uv, 0.0).rgb;
|
return texelFetch(InputTexture, clamp(p, ivec2(0), sz - ivec2(1)), 0).rgb;
|
||||||
}
|
}
|
||||||
|
|
||||||
float AMin3F1(float x, float y, float z) { return min(x, min(y, z)); }
|
float AMin3F1(float x, float y, float z) { return min(x, min(y, z)); }
|
||||||
|
|||||||
@@ -1,213 +1,214 @@
|
|||||||
// 1115.1.0
|
// 1116.2.0
|
||||||
#pragma once
|
#pragma once
|
||||||
const uint32_t cas_ffx_half_code[] = {
|
const uint32_t cas_ffx_half_code[] = {
|
||||||
0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x0008000b,0x000000d7,0x00000000,0x00020011,0x00000001,0x00020011,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000032,0x0006000b,0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,
|
||||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000047,0x000000d1,0x00030010,
|
0x00000000,0x00000001,0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000043,
|
||||||
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
0x000000d1,0x00030010,0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,
|
||||||
0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976,0x00000000,0x00030005,
|
0x00000004,0x6e69616d,0x00000000,0x00060005,0x0000000d,0x4c736143,0x2864616f,0x3b326976,
|
||||||
0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633,0x663b3166,0x31663b31,
|
0x00000000,0x00030005,0x0000000c,0x00000070,0x00070005,0x00000014,0x6e694d41,0x28314633,
|
||||||
0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012,0x00000079,0x00030005,
|
0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000011,0x00000078,0x00030005,0x00000012,
|
||||||
0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633,0x663b3166,0x31663b31,
|
0x00000079,0x00030005,0x00000013,0x0000007a,0x00070005,0x00000019,0x78614d41,0x28314633,
|
||||||
0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017,0x00000079,0x00030005,
|
0x663b3166,0x31663b31,0x0000003b,0x00030005,0x00000016,0x00000078,0x00030005,0x00000017,
|
||||||
0x00000018,0x0000007a,0x00030005,0x0000001d,0x00007675,0x00030005,0x00000024,0x00004350,
|
0x00000079,0x00030005,0x00000018,0x0000007a,0x00030005,0x0000001b,0x00007a73,0x00060005,
|
||||||
0x00040006,0x00000024,0x00000000,0x0063646e,0x00060006,0x00000024,0x00000001,0x6f736572,
|
0x0000001f,0x75706e49,0x78655474,0x65727574,0x00000000,0x00030005,0x00000040,0x00007073,
|
||||||
0x6974756c,0x00006e6f,0x00060006,0x00000024,0x00000002,0x72616873,0x73656e70,0x00000073,
|
0x00060005,0x00000043,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00030005,0x00000045,
|
||||||
0x00030005,0x00000026,0x00006370,0x00060005,0x0000002f,0x75706e49,0x78655474,0x65727574,
|
0x00004350,0x00040006,0x00000045,0x00000000,0x0063646e,0x00060006,0x00000045,0x00000001,
|
||||||
0x00000000,0x00030005,0x00000045,0x00007073,0x00060005,0x00000047,0x67617266,0x43786554,
|
0x6f736572,0x6974756c,0x00006e6f,0x00060006,0x00000045,0x00000002,0x72616873,0x73656e70,
|
||||||
0x64726f6f,0x00000000,0x00040005,0x0000004d,0x6b616570,0x00000000,0x00030005,0x0000005a,
|
0x00000073,0x00030005,0x00000047,0x00006370,0x00040005,0x0000004d,0x6b616570,0x00000000,
|
||||||
0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005,0x00000062,0x00000064,
|
0x00030005,0x0000005b,0x00000062,0x00040005,0x00000060,0x61726170,0x0000006d,0x00030005,
|
||||||
0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068,0x00000065,0x00040005,
|
0x00000062,0x00000064,0x00040005,0x00000066,0x61726170,0x0000006d,0x00030005,0x00000068,
|
||||||
0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066,0x00040005,0x00000070,
|
0x00000065,0x00040005,0x00000069,0x61726170,0x0000006d,0x00030005,0x0000006c,0x00000066,
|
||||||
0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005,0x00000076,0x61726170,
|
0x00040005,0x00000070,0x61726170,0x0000006d,0x00030005,0x00000072,0x00000068,0x00040005,
|
||||||
0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079,0x61726170,0x0000006d,
|
0x00000076,0x61726170,0x0000006d,0x00030005,0x00000078,0x00476e6d,0x00040005,0x00000079,
|
||||||
0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081,0x61726170,0x0000006d,
|
0x61726170,0x0000006d,0x00040005,0x0000007e,0x61726170,0x0000006d,0x00040005,0x00000081,
|
||||||
0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086,0x61726170,0x0000006d,
|
0x61726170,0x0000006d,0x00040005,0x00000085,0x61726170,0x0000006d,0x00040005,0x00000086,
|
||||||
0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d,0x0047786d,0x00040005,
|
0x61726170,0x0000006d,0x00040005,0x00000089,0x61726170,0x0000006d,0x00030005,0x0000008d,
|
||||||
0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170,0x0000006d,0x00040005,
|
0x0047786d,0x00040005,0x0000008e,0x61726170,0x0000006d,0x00040005,0x00000091,0x61726170,
|
||||||
0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170,0x0000006d,0x00040005,
|
0x0000006d,0x00040005,0x00000094,0x61726170,0x0000006d,0x00040005,0x00000098,0x61726170,
|
||||||
0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170,0x0000006d,0x00040005,
|
0x0000006d,0x00040005,0x00000099,0x61726170,0x0000006d,0x00040005,0x0000009c,0x61726170,
|
||||||
0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61,0x00000000,0x00030005,
|
0x0000006d,0x00040005,0x000000a0,0x4d706372,0x00000047,0x00040005,0x000000a5,0x47706d61,
|
||||||
0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965,0x00000074,0x00030005,
|
0x00000000,0x00030005,0x000000af,0x00004777,0x00050005,0x000000b3,0x57706372,0x68676965,
|
||||||
0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f,0x00000000,0x00030047,
|
0x00000074,0x00030005,0x000000b9,0x00786970,0x00050005,0x000000d1,0x4374756f,0x726f6c6f,
|
||||||
0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,0x00000012,0x00000000,
|
0x00000000,0x00030047,0x0000000d,0x00000000,0x00030047,0x00000011,0x00000000,0x00030047,
|
||||||
0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,0x00030047,0x00000016,
|
0x00000012,0x00000000,0x00030047,0x00000013,0x00000000,0x00030047,0x00000014,0x00000000,
|
||||||
0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,0x00000000,0x00030047,
|
0x00030047,0x00000016,0x00000000,0x00030047,0x00000017,0x00000000,0x00030047,0x00000018,
|
||||||
0x00000019,0x00000000,0x00030047,0x00000024,0x00000002,0x00050048,0x00000024,0x00000000,
|
0x00000000,0x00030047,0x00000019,0x00000000,0x00030047,0x0000001f,0x00000000,0x00040047,
|
||||||
0x00000023,0x00000000,0x00050048,0x00000024,0x00000001,0x00000023,0x00000010,0x00040048,
|
0x0000001f,0x00000021,0x00000000,0x00040047,0x0000001f,0x00000022,0x00000000,0x00030047,
|
||||||
0x00000024,0x00000002,0x00000000,0x00050048,0x00000024,0x00000002,0x00000023,0x00000018,
|
0x00000020,0x00000000,0x00030047,0x00000024,0x00000000,0x00030047,0x0000002e,0x00000000,
|
||||||
0x00030047,0x0000002f,0x00000000,0x00040047,0x0000002f,0x00000021,0x00000000,0x00040047,
|
0x00030047,0x0000002f,0x00000000,0x00030047,0x00000032,0x00000000,0x00030047,0x00000033,
|
||||||
0x0000002f,0x00000022,0x00000000,0x00030047,0x00000030,0x00000000,0x00030047,0x00000033,
|
0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000035,0x00000000,0x00030047,
|
||||||
0x00000000,0x00030047,0x00000034,0x00000000,0x00030047,0x00000037,0x00000000,0x00030047,
|
0x00000036,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000,
|
||||||
0x00000038,0x00000000,0x00030047,0x00000039,0x00000000,0x00030047,0x0000003a,0x00000000,
|
0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003c,0x00000000,0x00030047,0x0000003d,
|
||||||
0x00030047,0x0000003b,0x00000000,0x00030047,0x0000003e,0x00000000,0x00030047,0x0000003f,
|
0x00000000,0x00040047,0x00000043,0x0000001e,0x00000000,0x00030047,0x00000045,0x00000002,
|
||||||
0x00000000,0x00030047,0x00000040,0x00000000,0x00030047,0x00000041,0x00000000,0x00030047,
|
0x00050048,0x00000045,0x00000000,0x00000023,0x00000000,0x00050048,0x00000045,0x00000001,
|
||||||
0x00000042,0x00000000,0x00040047,0x00000047,0x0000001e,0x00000000,0x00030047,0x0000004d,
|
0x00000023,0x00000010,0x00040048,0x00000045,0x00000002,0x00000000,0x00050048,0x00000045,
|
||||||
0x00000000,0x00030047,0x00000054,0x00000000,0x00030047,0x00000056,0x00000000,0x00030047,
|
0x00000002,0x00000023,0x00000018,0x00030047,0x0000004d,0x00000000,0x00030047,0x00000054,
|
||||||
0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,0x0000005a,0x00000000,
|
0x00000000,0x00030047,0x00000057,0x00000000,0x00030047,0x00000058,0x00000000,0x00030047,
|
||||||
0x00030047,0x00000061,0x00000000,0x00030047,0x00000062,0x00000000,0x00030047,0x00000067,
|
0x00000059,0x00000000,0x00030047,0x0000005b,0x00000000,0x00030047,0x00000061,0x00000000,
|
||||||
0x00000000,0x00030047,0x00000068,0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,
|
0x00030047,0x00000062,0x00000000,0x00030047,0x00000067,0x00000000,0x00030047,0x00000068,
|
||||||
0x0000006c,0x00000000,0x00030047,0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,
|
0x00000000,0x00030047,0x0000006b,0x00000000,0x00030047,0x0000006c,0x00000000,0x00030047,
|
||||||
0x00030047,0x00000077,0x00000000,0x00030047,0x00000078,0x00000000,0x00030047,0x00000079,
|
0x00000071,0x00000000,0x00030047,0x00000072,0x00000000,0x00030047,0x00000077,0x00000000,
|
||||||
0x00000000,0x00030047,0x0000007d,0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,
|
0x00030047,0x00000078,0x00000000,0x00030047,0x00000079,0x00000000,0x00030047,0x0000007d,
|
||||||
0x00000080,0x00000000,0x00030047,0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,
|
0x00000000,0x00030047,0x0000007e,0x00000000,0x00030047,0x00000080,0x00000000,0x00030047,
|
||||||
0x00030047,0x00000084,0x00000000,0x00030047,0x00000085,0x00000000,0x00030047,0x00000086,
|
0x00000081,0x00000000,0x00030047,0x00000083,0x00000000,0x00030047,0x00000084,0x00000000,
|
||||||
0x00000000,0x00030047,0x00000088,0x00000000,0x00030047,0x00000089,0x00000000,0x00030047,
|
0x00030047,0x00000085,0x00000000,0x00030047,0x00000086,0x00000000,0x00030047,0x00000088,
|
||||||
0x0000008b,0x00000000,0x00030047,0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,
|
0x00000000,0x00030047,0x00000089,0x00000000,0x00030047,0x0000008b,0x00000000,0x00030047,
|
||||||
0x00030047,0x0000008e,0x00000000,0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,
|
0x0000008c,0x00000000,0x00030047,0x0000008d,0x00000000,0x00030047,0x0000008e,0x00000000,
|
||||||
0x00000000,0x00030047,0x00000093,0x00000000,0x00030047,0x00000094,0x00000000,0x00030047,
|
0x00030047,0x00000090,0x00000000,0x00030047,0x00000091,0x00000000,0x00030047,0x00000093,
|
||||||
0x00000096,0x00000000,0x00030047,0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,
|
0x00000000,0x00030047,0x00000094,0x00000000,0x00030047,0x00000096,0x00000000,0x00030047,
|
||||||
0x00030047,0x00000099,0x00000000,0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c,
|
0x00000097,0x00000000,0x00030047,0x00000098,0x00000000,0x00030047,0x00000099,0x00000000,
|
||||||
0x00000000,0x00030047,0x0000009e,0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,
|
0x00030047,0x0000009b,0x00000000,0x00030047,0x0000009c,0x00000000,0x00030047,0x0000009e,
|
||||||
0x000000a0,0x00000000,0x00030047,0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000,
|
0x00000000,0x00030047,0x0000009f,0x00000000,0x00030047,0x000000a0,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000a4,0x00000000,0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6,
|
0x000000a1,0x00000000,0x00030047,0x000000a3,0x00000000,0x00030047,0x000000a4,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000a7,0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047,
|
0x00030047,0x000000a5,0x00000000,0x00030047,0x000000a6,0x00000000,0x00030047,0x000000a7,
|
||||||
0x000000a9,0x00000000,0x00030047,0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000,
|
0x00000000,0x00030047,0x000000a8,0x00000000,0x00030047,0x000000a9,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000ac,0x00000000,0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae,
|
0x000000aa,0x00000000,0x00030047,0x000000ab,0x00000000,0x00030047,0x000000ac,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000af,0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047,
|
0x00030047,0x000000ad,0x00000000,0x00030047,0x000000ae,0x00000000,0x00030047,0x000000af,
|
||||||
0x000000b1,0x00000000,0x00030047,0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000,
|
0x00000000,0x00030047,0x000000b0,0x00000000,0x00030047,0x000000b1,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000b5,0x00000000,0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7,
|
0x000000b2,0x00000000,0x00030047,0x000000b3,0x00000000,0x00030047,0x000000b5,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000b8,0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,
|
0x00030047,0x000000b6,0x00000000,0x00030047,0x000000b7,0x00000000,0x00030047,0x000000b8,
|
||||||
0x000000ba,0x00000000,0x00030047,0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,
|
0x00000000,0x00030047,0x000000b9,0x00000000,0x00030047,0x000000ba,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000bd,0x00000000,0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,
|
0x000000bb,0x00000000,0x00030047,0x000000bc,0x00000000,0x00030047,0x000000bd,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000c0,0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047,
|
0x00030047,0x000000be,0x00000000,0x00030047,0x000000bf,0x00000000,0x00030047,0x000000c0,
|
||||||
0x000000c2,0x00000000,0x00030047,0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000,
|
0x00000000,0x00030047,0x000000c1,0x00000000,0x00030047,0x000000c2,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000c5,0x00000000,0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7,
|
0x000000c3,0x00000000,0x00030047,0x000000c4,0x00000000,0x00030047,0x000000c5,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000c8,0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,
|
0x00030047,0x000000c6,0x00000000,0x00030047,0x000000c7,0x00000000,0x00030047,0x000000c8,
|
||||||
0x000000ca,0x00000000,0x00030047,0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000,
|
0x00000000,0x00030047,0x000000c9,0x00000000,0x00030047,0x000000ca,0x00000000,0x00030047,
|
||||||
0x00030047,0x000000cd,0x00000000,0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,
|
0x000000cb,0x00000000,0x00030047,0x000000cc,0x00000000,0x00030047,0x000000cd,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000d1,0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000,
|
0x00030047,0x000000ce,0x00000000,0x00030047,0x000000cf,0x00000000,0x00030047,0x000000d1,
|
||||||
0x00030047,0x000000d2,0x00000000,0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,
|
0x00000000,0x00040047,0x000000d1,0x0000001e,0x00000000,0x00030047,0x000000d2,0x00000000,
|
||||||
0x00000000,0x00030047,0x000000d5,0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013,
|
0x00030047,0x000000d3,0x00000000,0x00030047,0x000000d4,0x00000000,0x00030047,0x000000d5,
|
||||||
0x00000002,0x00030021,0x00000003,0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,
|
0x00000000,0x00030047,0x000000d6,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,
|
||||||
0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,
|
0x00000002,0x00040015,0x00000006,0x00000020,0x00000001,0x00040017,0x00000007,0x00000006,
|
||||||
0x00030016,0x00000009,0x00000020,0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021,
|
0x00000002,0x00040020,0x00000008,0x00000007,0x00000007,0x00030016,0x00000009,0x00000020,
|
||||||
0x0000000b,0x0000000a,0x00000008,0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021,
|
0x00040017,0x0000000a,0x00000009,0x00000003,0x00040021,0x0000000b,0x0000000a,0x00000008,
|
||||||
0x00000010,0x00000009,0x0000000f,0x0000000f,0x0000000f,0x00040017,0x0000001b,0x00000009,
|
0x00040020,0x0000000f,0x00000007,0x00000009,0x00060021,0x00000010,0x00000009,0x0000000f,
|
||||||
0x00000002,0x00040020,0x0000001c,0x00000007,0x0000001b,0x0004002b,0x00000009,0x00000020,
|
0x0000000f,0x0000000f,0x00090019,0x0000001c,0x00000009,0x00000001,0x00000000,0x00000000,
|
||||||
0x3f000000,0x00040017,0x00000023,0x00000009,0x00000004,0x0005001e,0x00000024,0x00000023,
|
0x00000000,0x00000001,0x00000000,0x0003001b,0x0000001d,0x0000001c,0x00040020,0x0000001e,
|
||||||
0x0000001b,0x00000009,0x00040020,0x00000025,0x00000009,0x00000024,0x0004003b,0x00000025,
|
0x00000000,0x0000001d,0x0004003b,0x0000001e,0x0000001f,0x00000000,0x0004002b,0x00000006,
|
||||||
0x00000026,0x00000009,0x0004002b,0x00000006,0x00000027,0x00000001,0x00040020,0x00000028,
|
0x00000021,0x00000000,0x0005002c,0x00000007,0x00000026,0x00000021,0x00000021,0x0004002b,
|
||||||
0x00000009,0x0000001b,0x00090019,0x0000002c,0x00000009,0x00000001,0x00000000,0x00000000,
|
0x00000006,0x00000028,0x00000001,0x0005002c,0x00000007,0x00000029,0x00000028,0x00000028,
|
||||||
0x00000000,0x00000001,0x00000000,0x0003001b,0x0000002d,0x0000002c,0x00040020,0x0000002e,
|
0x00040017,0x0000002d,0x00000009,0x00000004,0x00040017,0x00000041,0x00000009,0x00000002,
|
||||||
0x00000000,0x0000002d,0x0004003b,0x0000002e,0x0000002f,0x00000000,0x0004002b,0x00000009,
|
0x00040020,0x00000042,0x00000001,0x00000041,0x0004003b,0x00000042,0x00000043,0x00000001,
|
||||||
0x00000032,0x00000000,0x00040020,0x00000046,0x00000001,0x0000001b,0x0004003b,0x00000046,
|
0x0005001e,0x00000045,0x0000002d,0x00000041,0x00000009,0x00040020,0x00000046,0x00000009,
|
||||||
0x00000047,0x00000001,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009,
|
0x00000045,0x0004003b,0x00000046,0x00000047,0x00000009,0x00040020,0x00000048,0x00000009,
|
||||||
0x0000004f,0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006,
|
0x00000041,0x0004002b,0x00000009,0x0000004e,0xbf800000,0x0004002b,0x00000009,0x0000004f,
|
||||||
0x00000051,0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009,
|
0x41000000,0x0004002b,0x00000009,0x00000050,0x40a00000,0x0004002b,0x00000006,0x00000051,
|
||||||
0x00000055,0x3f800000,0x00040020,0x00000059,0x00000007,0x0000000a,0x0004002b,0x00000006,
|
0x00000002,0x00040020,0x00000052,0x00000009,0x00000009,0x0004002b,0x00000009,0x00000055,
|
||||||
0x0000005c,0x00000000,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007,
|
0x00000000,0x0004002b,0x00000009,0x00000056,0x3f800000,0x00040020,0x0000005a,0x00000007,
|
||||||
0x0000005e,0x0000005c,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x0000005c,
|
0x0000000a,0x0004002b,0x00000006,0x0000005d,0xffffffff,0x0005002c,0x00000007,0x0000005e,
|
||||||
0x0005002c,0x00000007,0x0000006e,0x00000027,0x0000005c,0x0005002c,0x00000007,0x00000074,
|
0x00000021,0x0000005d,0x0005002c,0x00000007,0x00000064,0x0000005d,0x00000021,0x0005002c,
|
||||||
0x0000005c,0x00000027,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a,
|
0x00000007,0x0000006e,0x00000028,0x00000021,0x0005002c,0x00000007,0x00000074,0x00000021,
|
||||||
0x0000007b,0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009,
|
0x00000028,0x00040015,0x0000007a,0x00000020,0x00000000,0x0004002b,0x0000007a,0x0000007b,
|
||||||
0x000000b4,0x40800000,0x00040020,0x000000d0,0x00000003,0x00000023,0x0004003b,0x000000d0,
|
0x00000001,0x0004002b,0x00000009,0x000000a2,0x3a800000,0x0004002b,0x00000009,0x000000b4,
|
||||||
0x000000d1,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
|
0x40800000,0x00040020,0x000000d0,0x00000003,0x0000002d,0x0004003b,0x000000d0,0x000000d1,
|
||||||
0x00000005,0x0004003b,0x00000008,0x00000045,0x00000007,0x0004003b,0x0000000f,0x0000004d,
|
0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,
|
||||||
0x00000007,0x0004003b,0x00000059,0x0000005a,0x00000007,0x0004003b,0x00000008,0x00000060,
|
0x0004003b,0x00000008,0x00000040,0x00000007,0x0004003b,0x0000000f,0x0000004d,0x00000007,
|
||||||
0x00000007,0x0004003b,0x00000059,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066,
|
0x0004003b,0x0000005a,0x0000005b,0x00000007,0x0004003b,0x00000008,0x00000060,0x00000007,
|
||||||
0x00000007,0x0004003b,0x00000059,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069,
|
0x0004003b,0x0000005a,0x00000062,0x00000007,0x0004003b,0x00000008,0x00000066,0x00000007,
|
||||||
0x00000007,0x0004003b,0x00000059,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070,
|
0x0004003b,0x0000005a,0x00000068,0x00000007,0x0004003b,0x00000008,0x00000069,0x00000007,
|
||||||
0x00000007,0x0004003b,0x00000059,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076,
|
0x0004003b,0x0000005a,0x0000006c,0x00000007,0x0004003b,0x00000008,0x00000070,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079,
|
0x0004003b,0x0000005a,0x00000072,0x00000007,0x0004003b,0x00000008,0x00000076,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081,
|
0x0004003b,0x0000000f,0x00000078,0x00000007,0x0004003b,0x0000000f,0x00000079,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086,
|
0x0004003b,0x0000000f,0x0000007e,0x00000007,0x0004003b,0x0000000f,0x00000081,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d,
|
0x0004003b,0x0000000f,0x00000085,0x00000007,0x0004003b,0x0000000f,0x00000086,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091,
|
0x0004003b,0x0000000f,0x00000089,0x00000007,0x0004003b,0x0000000f,0x0000008d,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098,
|
0x0004003b,0x0000000f,0x0000008e,0x00000007,0x0004003b,0x0000000f,0x00000091,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c,
|
0x0004003b,0x0000000f,0x00000094,0x00000007,0x0004003b,0x0000000f,0x00000098,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5,
|
0x0004003b,0x0000000f,0x00000099,0x00000007,0x0004003b,0x0000000f,0x0000009c,0x00000007,
|
||||||
0x00000007,0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3,
|
0x0004003b,0x0000000f,0x000000a0,0x00000007,0x0004003b,0x0000000f,0x000000a5,0x00000007,
|
||||||
0x00000007,0x0004003b,0x00000059,0x000000b9,0x00000007,0x0004003d,0x0000001b,0x00000048,
|
0x0004003b,0x0000000f,0x000000af,0x00000007,0x0004003b,0x0000000f,0x000000b3,0x00000007,
|
||||||
0x00000047,0x00050041,0x00000028,0x00000049,0x00000026,0x00000027,0x0004003d,0x0000001b,
|
0x0004003b,0x0000005a,0x000000b9,0x00000007,0x0004003d,0x00000041,0x00000044,0x00000043,
|
||||||
0x0000004a,0x00000049,0x00050085,0x0000001b,0x0000004b,0x00000048,0x0000004a,0x0004006e,
|
0x00050041,0x00000048,0x00000049,0x00000047,0x00000028,0x0004003d,0x00000041,0x0000004a,
|
||||||
0x00000007,0x0000004c,0x0000004b,0x0003003e,0x00000045,0x0000004c,0x00050041,0x00000052,
|
0x00000049,0x00050085,0x00000041,0x0000004b,0x00000044,0x0000004a,0x0004006e,0x00000007,
|
||||||
0x00000053,0x00000026,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c,
|
0x0000004c,0x0000004b,0x0003003e,0x00000040,0x0000004c,0x00050041,0x00000052,0x00000053,
|
||||||
0x00000009,0x00000056,0x00000001,0x0000002b,0x00000054,0x00000032,0x00000055,0x0008000c,
|
0x00000047,0x00000051,0x0004003d,0x00000009,0x00000054,0x00000053,0x0008000c,0x00000009,
|
||||||
0x00000009,0x00000057,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000056,0x00050088,
|
0x00000057,0x00000001,0x0000002b,0x00000054,0x00000055,0x00000056,0x0008000c,0x00000009,
|
||||||
0x00000009,0x00000058,0x0000004e,0x00000057,0x0003003e,0x0000004d,0x00000058,0x0004003d,
|
0x00000058,0x00000001,0x0000002e,0x0000004f,0x00000050,0x00000057,0x00050088,0x00000009,
|
||||||
0x00000007,0x0000005b,0x00000045,0x00050080,0x00000007,0x0000005f,0x0000005b,0x0000005e,
|
0x00000059,0x0000004e,0x00000058,0x0003003e,0x0000004d,0x00000059,0x0004003d,0x00000007,
|
||||||
0x0003003e,0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060,
|
0x0000005c,0x00000040,0x00050080,0x00000007,0x0000005f,0x0000005c,0x0000005e,0x0003003e,
|
||||||
0x0003003e,0x0000005a,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000045,0x00050080,
|
0x00000060,0x0000005f,0x00050039,0x0000000a,0x00000061,0x0000000d,0x00000060,0x0003003e,
|
||||||
0x00000007,0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039,
|
0x0000005b,0x00000061,0x0004003d,0x00000007,0x00000063,0x00000040,0x00050080,0x00000007,
|
||||||
0x0000000a,0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d,
|
0x00000065,0x00000063,0x00000064,0x0003003e,0x00000066,0x00000065,0x00050039,0x0000000a,
|
||||||
0x00000007,0x0000006a,0x00000045,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a,
|
0x00000067,0x0000000d,0x00000066,0x0003003e,0x00000062,0x00000067,0x0004003d,0x00000007,
|
||||||
0x0000006b,0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007,
|
0x0000006a,0x00000040,0x0003003e,0x00000069,0x0000006a,0x00050039,0x0000000a,0x0000006b,
|
||||||
0x0000006d,0x00000045,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e,
|
0x0000000d,0x00000069,0x0003003e,0x00000068,0x0000006b,0x0004003d,0x00000007,0x0000006d,
|
||||||
0x00000070,0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e,
|
0x00000040,0x00050080,0x00000007,0x0000006f,0x0000006d,0x0000006e,0x0003003e,0x00000070,
|
||||||
0x0000006c,0x00000071,0x0004003d,0x00000007,0x00000073,0x00000045,0x00050080,0x00000007,
|
0x0000006f,0x00050039,0x0000000a,0x00000071,0x0000000d,0x00000070,0x0003003e,0x0000006c,
|
||||||
0x00000075,0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a,
|
0x00000071,0x0004003d,0x00000007,0x00000073,0x00000040,0x00050080,0x00000007,0x00000075,
|
||||||
0x00000077,0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f,
|
0x00000073,0x00000074,0x0003003e,0x00000076,0x00000075,0x00050039,0x0000000a,0x00000077,
|
||||||
0x0000007c,0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e,
|
0x0000000d,0x00000076,0x0003003e,0x00000072,0x00000077,0x00050041,0x0000000f,0x0000007c,
|
||||||
0x00000079,0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d,
|
0x00000062,0x0000007b,0x0004003d,0x00000009,0x0000007d,0x0000007c,0x0003003e,0x00000079,
|
||||||
0x00000009,0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f,
|
0x0000007d,0x00050041,0x0000000f,0x0000007f,0x00000068,0x0000007b,0x0004003d,0x00000009,
|
||||||
0x00000082,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e,
|
0x00000080,0x0000007f,0x0003003e,0x0000007e,0x00000080,0x00050041,0x0000000f,0x00000082,
|
||||||
0x00000081,0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e,
|
0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000083,0x00000082,0x0003003e,0x00000081,
|
||||||
0x00000081,0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005a,
|
0x00000083,0x00070039,0x00000009,0x00000084,0x00000014,0x00000079,0x0000007e,0x00000081,
|
||||||
0x0000007b,0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088,
|
0x0003003e,0x00000085,0x00000084,0x00050041,0x0000000f,0x00000087,0x0000005b,0x0000007b,
|
||||||
0x00050041,0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b,
|
0x0004003d,0x00000009,0x00000088,0x00000087,0x0003003e,0x00000086,0x00000088,0x00050041,
|
||||||
0x0000008a,0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014,
|
0x0000000f,0x0000008a,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000008b,0x0000008a,
|
||||||
0x00000085,0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f,
|
0x0003003e,0x00000089,0x0000008b,0x00070039,0x00000009,0x0000008c,0x00000014,0x00000085,
|
||||||
0x0000008f,0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e,
|
0x00000086,0x00000089,0x0003003e,0x00000078,0x0000008c,0x00050041,0x0000000f,0x0000008f,
|
||||||
0x0000008e,0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d,
|
0x00000062,0x0000007b,0x0004003d,0x00000009,0x00000090,0x0000008f,0x0003003e,0x0000008e,
|
||||||
0x00000009,0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f,
|
0x00000090,0x00050041,0x0000000f,0x00000092,0x00000068,0x0000007b,0x0004003d,0x00000009,
|
||||||
0x00000095,0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e,
|
0x00000093,0x00000092,0x0003003e,0x00000091,0x00000093,0x00050041,0x0000000f,0x00000095,
|
||||||
0x00000094,0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091,
|
0x0000006c,0x0000007b,0x0004003d,0x00000009,0x00000096,0x00000095,0x0003003e,0x00000094,
|
||||||
0x00000094,0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005a,
|
0x00000096,0x00070039,0x00000009,0x00000097,0x00000019,0x0000008e,0x00000091,0x00000094,
|
||||||
0x0000007b,0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b,
|
0x0003003e,0x00000098,0x00000097,0x00050041,0x0000000f,0x0000009a,0x0000005b,0x0000007b,
|
||||||
0x00050041,0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e,
|
0x0004003d,0x00000009,0x0000009b,0x0000009a,0x0003003e,0x00000099,0x0000009b,0x00050041,
|
||||||
0x0000009d,0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019,
|
0x0000000f,0x0000009d,0x00000072,0x0000007b,0x0004003d,0x00000009,0x0000009e,0x0000009d,
|
||||||
0x00000098,0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009,
|
0x0003003e,0x0000009c,0x0000009e,0x00070039,0x00000009,0x0000009f,0x00000019,0x00000098,
|
||||||
0x000000a1,0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1,
|
0x00000099,0x0000009c,0x0003003e,0x0000008d,0x0000009f,0x0004003d,0x00000009,0x000000a1,
|
||||||
0x000000a2,0x00050088,0x00000009,0x000000a4,0x00000055,0x000000a3,0x0003003e,0x000000a0,
|
0x0000008d,0x0007000c,0x00000009,0x000000a3,0x00000001,0x00000028,0x000000a1,0x000000a2,
|
||||||
0x000000a4,0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7,
|
0x00050088,0x00000009,0x000000a4,0x00000056,0x000000a3,0x0003003e,0x000000a0,0x000000a4,
|
||||||
0x0000008d,0x00050083,0x00000009,0x000000a8,0x00000055,0x000000a7,0x0007000c,0x00000009,
|
0x0004003d,0x00000009,0x000000a6,0x00000078,0x0004003d,0x00000009,0x000000a7,0x0000008d,
|
||||||
0x000000a9,0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa,
|
0x00050083,0x00000009,0x000000a8,0x00000056,0x000000a7,0x0007000c,0x00000009,0x000000a9,
|
||||||
0x000000a0,0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009,
|
0x00000001,0x00000025,0x000000a6,0x000000a8,0x0004003d,0x00000009,0x000000aa,0x000000a0,
|
||||||
0x000000ac,0x00000001,0x0000002b,0x000000ab,0x00000032,0x00000055,0x0003003e,0x000000a5,
|
0x00050085,0x00000009,0x000000ab,0x000000a9,0x000000aa,0x0008000c,0x00000009,0x000000ac,
|
||||||
0x000000ac,0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae,
|
0x00000001,0x0000002b,0x000000ab,0x00000055,0x00000056,0x0003003e,0x000000a5,0x000000ac,
|
||||||
0x00000001,0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009,
|
0x0004003d,0x00000009,0x000000ad,0x000000a5,0x0006000c,0x00000009,0x000000ae,0x00000001,
|
||||||
0x000000b0,0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009,
|
0x0000001f,0x000000ad,0x0003003e,0x000000a5,0x000000ae,0x0004003d,0x00000009,0x000000b0,
|
||||||
0x000000b2,0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009,
|
0x000000a5,0x0004003d,0x00000009,0x000000b1,0x0000004d,0x00050085,0x00000009,0x000000b2,
|
||||||
0x000000b5,0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081,
|
0x000000b0,0x000000b1,0x0003003e,0x000000af,0x000000b2,0x0004003d,0x00000009,0x000000b5,
|
||||||
0x00000009,0x000000b7,0x00000055,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000055,
|
0x000000af,0x00050085,0x00000009,0x000000b6,0x000000b4,0x000000b5,0x00050081,0x00000009,
|
||||||
0x000000b7,0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005a,
|
0x000000b7,0x00000056,0x000000b6,0x00050088,0x00000009,0x000000b8,0x00000056,0x000000b7,
|
||||||
0x0004003d,0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba,
|
0x0003003e,0x000000b3,0x000000b8,0x0004003d,0x0000000a,0x000000ba,0x0000005b,0x0004003d,
|
||||||
0x000000bb,0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be,
|
0x00000009,0x000000bb,0x000000af,0x0005008e,0x0000000a,0x000000bc,0x000000ba,0x000000bb,
|
||||||
0x000000af,0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a,
|
0x0004003d,0x0000000a,0x000000bd,0x00000062,0x0004003d,0x00000009,0x000000be,0x000000af,
|
||||||
0x000000c0,0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d,
|
0x0005008e,0x0000000a,0x000000bf,0x000000bd,0x000000be,0x00050081,0x0000000a,0x000000c0,
|
||||||
0x00000009,0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2,
|
0x000000bc,0x000000bf,0x0004003d,0x0000000a,0x000000c1,0x0000006c,0x0004003d,0x00000009,
|
||||||
0x00050081,0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5,
|
0x000000c2,0x000000af,0x0005008e,0x0000000a,0x000000c3,0x000000c1,0x000000c2,0x00050081,
|
||||||
0x00000072,0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7,
|
0x0000000a,0x000000c4,0x000000c0,0x000000c3,0x0004003d,0x0000000a,0x000000c5,0x00000072,
|
||||||
0x000000c5,0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d,
|
0x0004003d,0x00000009,0x000000c6,0x000000af,0x0005008e,0x0000000a,0x000000c7,0x000000c5,
|
||||||
0x0000000a,0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9,
|
0x000000c6,0x00050081,0x0000000a,0x000000c8,0x000000c4,0x000000c7,0x0004003d,0x0000000a,
|
||||||
0x0004003d,0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca,
|
0x000000c9,0x00000068,0x00050081,0x0000000a,0x000000ca,0x000000c8,0x000000c9,0x0004003d,
|
||||||
0x000000cb,0x00060050,0x0000000a,0x000000cd,0x00000032,0x00000032,0x00000032,0x00060050,
|
0x00000009,0x000000cb,0x000000b3,0x0005008e,0x0000000a,0x000000cc,0x000000ca,0x000000cb,
|
||||||
0x0000000a,0x000000ce,0x00000055,0x00000055,0x00000055,0x0008000c,0x0000000a,0x000000cf,
|
0x00060050,0x0000000a,0x000000cd,0x00000055,0x00000055,0x00000055,0x00060050,0x0000000a,
|
||||||
0x00000001,0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf,
|
0x000000ce,0x00000056,0x00000056,0x00000056,0x0008000c,0x0000000a,0x000000cf,0x00000001,
|
||||||
0x0004003d,0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2,
|
0x0000002b,0x000000cc,0x000000cd,0x000000ce,0x0003003e,0x000000b9,0x000000cf,0x0004003d,
|
||||||
0x00000000,0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009,
|
0x0000000a,0x000000d2,0x000000b9,0x00050051,0x00000009,0x000000d3,0x000000d2,0x00000000,
|
||||||
0x000000d5,0x000000d2,0x00000002,0x00070050,0x00000023,0x000000d6,0x000000d3,0x000000d4,
|
0x00050051,0x00000009,0x000000d4,0x000000d2,0x00000001,0x00050051,0x00000009,0x000000d5,
|
||||||
0x000000d5,0x00000055,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036,
|
0x000000d2,0x00000002,0x00070050,0x0000002d,0x000000d6,0x000000d3,0x000000d4,0x000000d5,
|
||||||
0x0000000a,0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,
|
0x00000056,0x0003003e,0x000000d1,0x000000d6,0x000100fd,0x00010038,0x00050036,0x0000000a,
|
||||||
0x0000000e,0x0004003b,0x0000001c,0x0000001d,0x00000007,0x0004003d,0x00000007,0x0000001e,
|
0x0000000d,0x00000000,0x0000000b,0x00030037,0x00000008,0x0000000c,0x000200f8,0x0000000e,
|
||||||
0x0000000c,0x0004006f,0x0000001b,0x0000001f,0x0000001e,0x00050050,0x0000001b,0x00000021,
|
0x0004003b,0x00000008,0x0000001b,0x00000007,0x0004003d,0x0000001d,0x00000020,0x0000001f,
|
||||||
0x00000020,0x00000020,0x00050081,0x0000001b,0x00000022,0x0000001f,0x00000021,0x00050041,
|
0x00040064,0x0000001c,0x00000022,0x00000020,0x00050067,0x00000007,0x00000023,0x00000022,
|
||||||
0x00000028,0x00000029,0x00000026,0x00000027,0x0004003d,0x0000001b,0x0000002a,0x00000029,
|
0x00000021,0x0003003e,0x0000001b,0x00000023,0x0004003d,0x0000001d,0x00000024,0x0000001f,
|
||||||
0x00050088,0x0000001b,0x0000002b,0x00000022,0x0000002a,0x0003003e,0x0000001d,0x0000002b,
|
0x0004003d,0x00000007,0x00000025,0x0000000c,0x0004003d,0x00000007,0x00000027,0x0000001b,
|
||||||
0x0004003d,0x0000002d,0x00000030,0x0000002f,0x0004003d,0x0000001b,0x00000031,0x0000001d,
|
0x00050082,0x00000007,0x0000002a,0x00000027,0x00000029,0x0008000c,0x00000007,0x0000002b,
|
||||||
0x00070058,0x00000023,0x00000033,0x00000030,0x00000031,0x00000002,0x00000032,0x0008004f,
|
0x00000001,0x0000002d,0x00000025,0x00000026,0x0000002a,0x00040064,0x0000001c,0x0000002c,
|
||||||
0x0000000a,0x00000034,0x00000033,0x00000033,0x00000000,0x00000001,0x00000002,0x000200fe,
|
0x00000024,0x0007005f,0x0000002d,0x0000002e,0x0000002c,0x0000002b,0x00000002,0x00000021,
|
||||||
0x00000034,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010,0x00030037,
|
0x0008004f,0x0000000a,0x0000002f,0x0000002e,0x0000002e,0x00000000,0x00000001,0x00000002,
|
||||||
0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f,0x00000013,
|
0x000200fe,0x0000002f,0x00010038,0x00050036,0x00000009,0x00000014,0x00000000,0x00000010,
|
||||||
0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000037,0x00000011,0x0004003d,0x00000009,
|
0x00030037,0x0000000f,0x00000011,0x00030037,0x0000000f,0x00000012,0x00030037,0x0000000f,
|
||||||
0x00000038,0x00000012,0x0004003d,0x00000009,0x00000039,0x00000013,0x0007000c,0x00000009,
|
0x00000013,0x000200f8,0x00000015,0x0004003d,0x00000009,0x00000032,0x00000011,0x0004003d,
|
||||||
0x0000003a,0x00000001,0x00000025,0x00000038,0x00000039,0x0007000c,0x00000009,0x0000003b,
|
0x00000009,0x00000033,0x00000012,0x0004003d,0x00000009,0x00000034,0x00000013,0x0007000c,
|
||||||
0x00000001,0x00000025,0x00000037,0x0000003a,0x000200fe,0x0000003b,0x00010038,0x00050036,
|
0x00000009,0x00000035,0x00000001,0x00000025,0x00000033,0x00000034,0x0007000c,0x00000009,
|
||||||
0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016,0x00030037,
|
0x00000036,0x00000001,0x00000025,0x00000032,0x00000035,0x000200fe,0x00000036,0x00010038,
|
||||||
0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a,0x0004003d,
|
0x00050036,0x00000009,0x00000019,0x00000000,0x00000010,0x00030037,0x0000000f,0x00000016,
|
||||||
0x00000009,0x0000003e,0x00000016,0x0004003d,0x00000009,0x0000003f,0x00000017,0x0004003d,
|
0x00030037,0x0000000f,0x00000017,0x00030037,0x0000000f,0x00000018,0x000200f8,0x0000001a,
|
||||||
0x00000009,0x00000040,0x00000018,0x0007000c,0x00000009,0x00000041,0x00000001,0x00000028,
|
0x0004003d,0x00000009,0x00000039,0x00000016,0x0004003d,0x00000009,0x0000003a,0x00000017,
|
||||||
0x0000003f,0x00000040,0x0007000c,0x00000009,0x00000042,0x00000001,0x00000028,0x0000003e,
|
0x0004003d,0x00000009,0x0000003b,0x00000018,0x0007000c,0x00000009,0x0000003c,0x00000001,
|
||||||
0x00000041,0x000200fe,0x00000042,0x00010038
|
0x00000028,0x0000003a,0x0000003b,0x0007000c,0x00000009,0x0000003d,0x00000001,0x00000028,
|
||||||
|
0x00000039,0x0000003c,0x000200fe,0x0000003d,0x00010038
|
||||||
};
|
};
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#version 450
|
#version 450
|
||||||
#extension GL_GOOGLE_include_directive : require
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 fragTexCoord;
|
layout(location = 0) in vec2 fragTexCoord;
|
||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
@@ -7,16 +6,25 @@ layout(set = 0, binding = 0) uniform sampler2D InputTexture;
|
|||||||
layout(set = 1, binding = 0) uniform sampler2D WeightTexture;
|
layout(set = 1, binding = 0) uniform sampler2D WeightTexture;
|
||||||
layout(push_constant) uniform Constants {
|
layout(push_constant) uniform Constants {
|
||||||
vec4 ndc;
|
vec4 ndc;
|
||||||
vec4 metrics; // 1/width, 1/height, width, height
|
vec2 resolution;
|
||||||
|
float extra;
|
||||||
|
float pad;
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS pc.metrics
|
|
||||||
#define SMAA_GLSL_4
|
|
||||||
#define SMAA_PRESET_HIGH
|
|
||||||
#include "SMAA.hlsl"
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 offset;
|
vec2 px = 1.0 / max(pc.resolution, vec2(1.0));
|
||||||
SMAANeighborhoodBlendingVS(fragTexCoord, offset);
|
vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5);
|
||||||
outColor = SMAANeighborhoodBlendingPS(fragTexCoord, offset, InputTexture, WeightTexture);
|
vec4 center = texture(InputTexture, uv);
|
||||||
|
vec4 weights = texture(WeightTexture, uv);
|
||||||
|
float weight = clamp(weights.r, 0.0, 0.42);
|
||||||
|
|
||||||
|
if (weight <= 0.001) {
|
||||||
|
outColor = center;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 normal = weights.gb * 2.0 - 1.0;
|
||||||
|
vec2 acrossUv = clamp(uv + normal * px, px * 0.5, vec2(1.0) - px * 0.5);
|
||||||
|
vec3 across = texture(InputTexture, acrossUv).rgb;
|
||||||
|
outColor = vec4(mix(center.rgb, across, weight), center.a);
|
||||||
}
|
}
|
||||||
@@ -1,204 +1,88 @@
|
|||||||
// 1116.6.0
|
// 1116.3.0
|
||||||
#pragma once
|
#pragma once
|
||||||
const uint32_t smaa_blend_code[] = {
|
const uint32_t smaa_blend_code[] = {
|
||||||
0x07230203,0x00010000,0x0008000b,0x000000f8,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x0008000b,0x0000006b,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000e8,0x000000f0,0x00030010,
|
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x0000001a,0x00000041,0x00030010,
|
||||||
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f,
|
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
||||||
0x70635f45,0x74735f70,0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004,
|
0x00000000,0x00030005,0x00000009,0x00007870,0x00050005,0x0000000c,0x736e6f43,0x746e6174,
|
||||||
0x475f4c47,0x4c474f4f,0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005,
|
0x00000073,0x00040006,0x0000000c,0x00000000,0x0063646e,0x00060006,0x0000000c,0x00000001,
|
||||||
0x00000004,0x6e69616d,0x00000000,0x00080005,0x00000010,0x41414d53,0x63766f4d,0x32627628,
|
0x6f736572,0x6974756c,0x00006e6f,0x00050006,0x0000000c,0x00000002,0x72747865,0x00000061,
|
||||||
0x3266763b,0x3266763b,0x0000003b,0x00040005,0x0000000d,0x646e6f63,0x00000000,0x00050005,
|
0x00040006,0x0000000c,0x00000003,0x00646170,0x00030005,0x0000000e,0x00006370,0x00030005,
|
||||||
0x0000000e,0x69726176,0x656c6261,0x00000000,0x00040005,0x0000000f,0x756c6176,0x00000065,
|
0x00000018,0x00007675,0x00060005,0x0000001a,0x67617266,0x43786554,0x64726f6f,0x00000000,
|
||||||
0x00080005,0x0000001a,0x41414d53,0x63766f4d,0x34627628,0x3466763b,0x3466763b,0x0000003b,
|
0x00040005,0x00000024,0x746e6563,0x00007265,0x00060005,0x00000028,0x75706e49,0x78655474,
|
||||||
0x00040005,0x00000017,0x646e6f63,0x00000000,0x00050005,0x00000018,0x69726176,0x656c6261,
|
0x65727574,0x00000000,0x00040005,0x0000002c,0x67696577,0x00737468,0x00060005,0x0000002d,
|
||||||
0x00000000,0x00040005,0x00000019,0x756c6176,0x00000065,0x000b0005,0x0000001f,0x41414d53,
|
0x67696557,0x65547468,0x72757478,0x00000065,0x00040005,0x00000032,0x67696577,0x00007468,
|
||||||
0x6769654e,0x726f6268,0x646f6f68,0x6e656c42,0x676e6964,0x76285356,0x763b3266,0x003b3466,
|
0x00050005,0x00000041,0x4374756f,0x726f6c6f,0x00000000,0x00040005,0x00000044,0x6d726f6e,
|
||||||
0x00050005,0x0000001d,0x63786574,0x64726f6f,0x00000000,0x00040005,0x0000001e,0x7366666f,
|
0x00006c61,0x00050005,0x0000004b,0x6f726361,0x76557373,0x00000000,0x00040005,0x00000059,
|
||||||
0x00007465,0x000d0005,0x00000029,0x41414d53,0x6769654e,0x726f6268,0x646f6f68,0x6e656c42,
|
0x6f726361,0x00007373,0x00030047,0x0000000c,0x00000002,0x00050048,0x0000000c,0x00000000,
|
||||||
0x676e6964,0x76285350,0x763b3266,0x733b3466,0x733b3132,0x003b3132,0x00050005,0x00000025,
|
0x00000023,0x00000000,0x00050048,0x0000000c,0x00000001,0x00000023,0x00000010,0x00050048,
|
||||||
0x63786574,0x64726f6f,0x00000000,0x00040005,0x00000026,0x7366666f,0x00007465,0x00050005,
|
0x0000000c,0x00000002,0x00000023,0x00000018,0x00050048,0x0000000c,0x00000003,0x00000023,
|
||||||
0x00000027,0x6f6c6f63,0x78655472,0x00000000,0x00050005,0x00000028,0x6e656c62,0x78655464,
|
0x0000001c,0x00040047,0x0000001a,0x0000001e,0x00000000,0x00040047,0x00000028,0x00000021,
|
||||||
0x00000000,0x00040005,0x0000003e,0x61726170,0x0000006d,0x00040005,0x00000041,0x61726170,
|
0x00000000,0x00040047,0x00000028,0x00000022,0x00000000,0x00040047,0x0000002d,0x00000021,
|
||||||
0x0000006d,0x00040005,0x00000044,0x61726170,0x0000006d,0x00040005,0x0000004d,0x61726170,
|
0x00000000,0x00040047,0x0000002d,0x00000022,0x00000001,0x00040047,0x00000041,0x0000001e,
|
||||||
0x0000006d,0x00040005,0x00000050,0x61726170,0x0000006d,0x00040005,0x00000053,0x61726170,
|
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
|
||||||
0x0000006d,0x00050005,0x0000005e,0x736e6f43,0x746e6174,0x00000073,0x00040006,0x0000005e,
|
0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,
|
||||||
0x00000000,0x0063646e,0x00050006,0x0000005e,0x00000001,0x7274656d,0x00736369,0x00030005,
|
0x00000007,0x0004002b,0x00000006,0x0000000a,0x3f800000,0x00040017,0x0000000b,0x00000006,
|
||||||
0x00000060,0x00006370,0x00030005,0x0000006d,0x00000061,0x00040005,0x00000089,0x6f6c6f63,
|
0x00000004,0x0006001e,0x0000000c,0x0000000b,0x00000007,0x00000006,0x00000006,0x00040020,
|
||||||
0x00000072,0x00030005,0x00000090,0x00000068,0x00060005,0x0000009c,0x6e656c62,0x676e6964,
|
0x0000000d,0x00000009,0x0000000c,0x0004003b,0x0000000d,0x0000000e,0x00000009,0x00040015,
|
||||||
0x7366664f,0x00007465,0x00060005,0x000000a2,0x6e656c62,0x676e6964,0x67696557,0x00007468,
|
0x0000000f,0x00000020,0x00000001,0x0004002b,0x0000000f,0x00000010,0x00000001,0x00040020,
|
||||||
0x00040005,0x000000ac,0x61726170,0x0000006d,0x00040005,0x000000ad,0x61726170,0x0000006d,
|
0x00000011,0x00000009,0x00000007,0x0005002c,0x00000007,0x00000014,0x0000000a,0x0000000a,
|
||||||
0x00040005,0x000000af,0x61726170,0x0000006d,0x00040005,0x000000b4,0x61726170,0x0000006d,
|
0x00040020,0x00000019,0x00000001,0x00000007,0x0004003b,0x00000019,0x0000001a,0x00000001,
|
||||||
0x00040005,0x000000b5,0x61726170,0x0000006d,0x00040005,0x000000b7,0x61726170,0x0000006d,
|
0x0004002b,0x00000006,0x0000001d,0x3f000000,0x00040020,0x00000023,0x00000007,0x0000000b,
|
||||||
0x00060005,0x000000c2,0x6e656c62,0x676e6964,0x726f6f43,0x00000064,0x00040005,0x000000d3,
|
0x00090019,0x00000025,0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,
|
||||||
0x6f6c6f63,0x00000072,0x00060005,0x000000e8,0x67617266,0x43786554,0x64726f6f,0x00000000,
|
0x00000000,0x0003001b,0x00000026,0x00000025,0x00040020,0x00000027,0x00000000,0x00000026,
|
||||||
0x00040005,0x000000e9,0x7366666f,0x00007465,0x00040005,0x000000ea,0x61726170,0x0000006d,
|
0x0004003b,0x00000027,0x00000028,0x00000000,0x0004003b,0x00000027,0x0000002d,0x00000000,
|
||||||
0x00040005,0x000000ec,0x61726170,0x0000006d,0x00050005,0x000000f0,0x4374756f,0x726f6c6f,
|
0x00040020,0x00000031,0x00000007,0x00000006,0x00040015,0x00000033,0x00000020,0x00000000,
|
||||||
0x00000000,0x00060005,0x000000f1,0x75706e49,0x78655474,0x65727574,0x00000000,0x00060005,
|
0x0004002b,0x00000033,0x00000034,0x00000000,0x0004002b,0x00000006,0x00000037,0x00000000,
|
||||||
0x000000f2,0x67696557,0x65547468,0x72757478,0x00000065,0x00040005,0x000000f3,0x61726170,
|
0x0004002b,0x00000006,0x00000038,0x3ed70a3d,0x0004002b,0x00000006,0x0000003b,0x3a83126f,
|
||||||
0x0000006d,0x00040005,0x000000f5,0x61726170,0x0000006d,0x00030047,0x0000005e,0x00000002,
|
0x00020014,0x0000003c,0x00040020,0x00000040,0x00000003,0x0000000b,0x0004003b,0x00000040,
|
||||||
0x00050048,0x0000005e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000005e,0x00000001,
|
0x00000041,0x00000003,0x0004002b,0x00000006,0x00000047,0x40000000,0x00040017,0x00000057,
|
||||||
0x00000023,0x00000010,0x00040047,0x000000e8,0x0000001e,0x00000000,0x00040047,0x000000f0,
|
0x00000006,0x00000003,0x00040020,0x00000058,0x00000007,0x00000057,0x0004002b,0x00000033,
|
||||||
0x0000001e,0x00000000,0x00040047,0x000000f1,0x00000021,0x00000000,0x00040047,0x000000f1,
|
0x00000064,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
|
||||||
0x00000022,0x00000000,0x00040047,0x000000f2,0x00000021,0x00000000,0x00040047,0x000000f2,
|
0x00000005,0x0004003b,0x00000008,0x00000009,0x00000007,0x0004003b,0x00000008,0x00000018,
|
||||||
0x00000022,0x00000001,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00020014,
|
0x00000007,0x0004003b,0x00000023,0x00000024,0x00000007,0x0004003b,0x00000023,0x0000002c,
|
||||||
0x00000006,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,0x00000007,
|
0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000008,0x00000044,
|
||||||
0x00000007,0x00030016,0x00000009,0x00000020,0x00040017,0x0000000a,0x00000009,0x00000002,
|
0x00000007,0x0004003b,0x00000008,0x0000004b,0x00000007,0x0004003b,0x00000058,0x00000059,
|
||||||
0x00040020,0x0000000b,0x00000007,0x0000000a,0x00060021,0x0000000c,0x00000002,0x00000008,
|
0x00000007,0x00050041,0x00000011,0x00000012,0x0000000e,0x00000010,0x0004003d,0x00000007,
|
||||||
0x0000000b,0x0000000b,0x00040017,0x00000012,0x00000006,0x00000004,0x00040020,0x00000013,
|
0x00000013,0x00000012,0x0007000c,0x00000007,0x00000015,0x00000001,0x00000028,0x00000013,
|
||||||
0x00000007,0x00000012,0x00040017,0x00000014,0x00000009,0x00000004,0x00040020,0x00000015,
|
0x00000014,0x00050050,0x00000007,0x00000016,0x0000000a,0x0000000a,0x00050088,0x00000007,
|
||||||
0x00000007,0x00000014,0x00060021,0x00000016,0x00000002,0x00000013,0x00000015,0x00000015,
|
0x00000017,0x00000016,0x00000015,0x0003003e,0x00000009,0x00000017,0x0004003d,0x00000007,
|
||||||
0x00050021,0x0000001c,0x00000002,0x0000000b,0x00000015,0x00090019,0x00000021,0x00000009,
|
0x0000001b,0x0000001a,0x0004003d,0x00000007,0x0000001c,0x00000009,0x0005008e,0x00000007,
|
||||||
0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000022,
|
0x0000001e,0x0000001c,0x0000001d,0x0004003d,0x00000007,0x0000001f,0x00000009,0x0005008e,
|
||||||
0x00000021,0x00040020,0x00000023,0x00000000,0x00000022,0x00070021,0x00000024,0x00000014,
|
0x00000007,0x00000020,0x0000001f,0x0000001d,0x00050083,0x00000007,0x00000021,0x00000014,
|
||||||
0x0000000b,0x00000015,0x00000023,0x00000023,0x00040015,0x0000002b,0x00000020,0x00000000,
|
0x00000020,0x0008000c,0x00000007,0x00000022,0x00000001,0x0000002b,0x0000001b,0x0000001e,
|
||||||
0x0004002b,0x0000002b,0x0000002c,0x00000000,0x00040020,0x0000002d,0x00000007,0x00000006,
|
0x00000021,0x0003003e,0x00000018,0x00000022,0x0004003d,0x00000026,0x00000029,0x00000028,
|
||||||
0x00040020,0x00000032,0x00000007,0x00000009,0x0004002b,0x0000002b,0x00000036,0x00000001,
|
0x0004003d,0x00000007,0x0000002a,0x00000018,0x00050057,0x0000000b,0x0000002b,0x00000029,
|
||||||
0x0004002b,0x0000002b,0x00000058,0x00000002,0x0004002b,0x0000002b,0x0000005b,0x00000003,
|
0x0000002a,0x0003003e,0x00000024,0x0000002b,0x0004003d,0x00000026,0x0000002e,0x0000002d,
|
||||||
0x0004001e,0x0000005e,0x00000014,0x00000014,0x00040020,0x0000005f,0x00000009,0x0000005e,
|
0x0004003d,0x00000007,0x0000002f,0x00000018,0x00050057,0x0000000b,0x00000030,0x0000002e,
|
||||||
0x0004003b,0x0000005f,0x00000060,0x00000009,0x00040015,0x00000061,0x00000020,0x00000001,
|
0x0000002f,0x0003003e,0x0000002c,0x00000030,0x00050041,0x00000031,0x00000035,0x0000002c,
|
||||||
0x0004002b,0x00000061,0x00000062,0x00000001,0x00040020,0x00000063,0x00000009,0x00000014,
|
0x00000034,0x0004003d,0x00000006,0x00000036,0x00000035,0x0008000c,0x00000006,0x00000039,
|
||||||
0x0004002b,0x00000009,0x00000067,0x3f800000,0x0004002b,0x00000009,0x00000068,0x00000000,
|
0x00000001,0x0000002b,0x00000036,0x00000037,0x00000038,0x0003003e,0x00000032,0x00000039,
|
||||||
0x0007002c,0x00000014,0x00000069,0x00000067,0x00000068,0x00000068,0x00000067,0x0007002c,
|
0x0004003d,0x00000006,0x0000003a,0x00000032,0x000500bc,0x0000003c,0x0000003d,0x0000003a,
|
||||||
0x00000014,0x00000083,0x00000067,0x00000067,0x00000067,0x00000067,0x0004002b,0x00000009,
|
0x0000003b,0x000300f7,0x0000003f,0x00000000,0x000400fa,0x0000003d,0x0000003e,0x0000003f,
|
||||||
0x00000085,0x3727c5ac,0x0005002c,0x0000000a,0x000000bd,0x00000067,0x00000067,0x00040020,
|
0x000200f8,0x0000003e,0x0004003d,0x0000000b,0x00000042,0x00000024,0x0003003e,0x00000041,
|
||||||
0x000000e7,0x00000001,0x0000000a,0x0004003b,0x000000e7,0x000000e8,0x00000001,0x00040020,
|
0x00000042,0x000100fd,0x000200f8,0x0000003f,0x0004003d,0x0000000b,0x00000045,0x0000002c,
|
||||||
0x000000ef,0x00000003,0x00000014,0x0004003b,0x000000ef,0x000000f0,0x00000003,0x0004003b,
|
0x0007004f,0x00000007,0x00000046,0x00000045,0x00000045,0x00000001,0x00000002,0x0005008e,
|
||||||
0x00000023,0x000000f1,0x00000000,0x0004003b,0x00000023,0x000000f2,0x00000000,0x00050036,
|
0x00000007,0x00000048,0x00000046,0x00000047,0x00050050,0x00000007,0x00000049,0x0000000a,
|
||||||
0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,0x00000005,0x0004003b,0x00000015,
|
0x0000000a,0x00050083,0x00000007,0x0000004a,0x00000048,0x00000049,0x0003003e,0x00000044,
|
||||||
0x000000e9,0x00000007,0x0004003b,0x0000000b,0x000000ea,0x00000007,0x0004003b,0x00000015,
|
0x0000004a,0x0004003d,0x00000007,0x0000004c,0x00000018,0x0004003d,0x00000007,0x0000004d,
|
||||||
0x000000ec,0x00000007,0x0004003b,0x0000000b,0x000000f3,0x00000007,0x0004003b,0x00000015,
|
0x00000044,0x0004003d,0x00000007,0x0000004e,0x00000009,0x00050085,0x00000007,0x0000004f,
|
||||||
0x000000f5,0x00000007,0x0004003d,0x0000000a,0x000000eb,0x000000e8,0x0003003e,0x000000ea,
|
0x0000004d,0x0000004e,0x00050081,0x00000007,0x00000050,0x0000004c,0x0000004f,0x0004003d,
|
||||||
0x000000eb,0x00060039,0x00000002,0x000000ed,0x0000001f,0x000000ea,0x000000ec,0x0004003d,
|
0x00000007,0x00000051,0x00000009,0x0005008e,0x00000007,0x00000052,0x00000051,0x0000001d,
|
||||||
0x00000014,0x000000ee,0x000000ec,0x0003003e,0x000000e9,0x000000ee,0x0004003d,0x0000000a,
|
0x0004003d,0x00000007,0x00000053,0x00000009,0x0005008e,0x00000007,0x00000054,0x00000053,
|
||||||
0x000000f4,0x000000e8,0x0003003e,0x000000f3,0x000000f4,0x0004003d,0x00000014,0x000000f6,
|
0x0000001d,0x00050083,0x00000007,0x00000055,0x00000014,0x00000054,0x0008000c,0x00000007,
|
||||||
0x000000e9,0x0003003e,0x000000f5,0x000000f6,0x00080039,0x00000014,0x000000f7,0x00000029,
|
0x00000056,0x00000001,0x0000002b,0x00000050,0x00000052,0x00000055,0x0003003e,0x0000004b,
|
||||||
0x000000f3,0x000000f5,0x000000f1,0x000000f2,0x0003003e,0x000000f0,0x000000f7,0x000100fd,
|
0x00000056,0x0004003d,0x00000026,0x0000005a,0x00000028,0x0004003d,0x00000007,0x0000005b,
|
||||||
0x00010038,0x00050036,0x00000002,0x00000010,0x00000000,0x0000000c,0x00030037,0x00000008,
|
0x0000004b,0x00050057,0x0000000b,0x0000005c,0x0000005a,0x0000005b,0x0008004f,0x00000057,
|
||||||
0x0000000d,0x00030037,0x0000000b,0x0000000e,0x00030037,0x0000000b,0x0000000f,0x000200f8,
|
0x0000005d,0x0000005c,0x0000005c,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000059,
|
||||||
0x00000011,0x00050041,0x0000002d,0x0000002e,0x0000000d,0x0000002c,0x0004003d,0x00000006,
|
0x0000005d,0x0004003d,0x0000000b,0x0000005e,0x00000024,0x0008004f,0x00000057,0x0000005f,
|
||||||
0x0000002f,0x0000002e,0x000300f7,0x00000031,0x00000000,0x000400fa,0x0000002f,0x00000030,
|
0x0000005e,0x0000005e,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000057,0x00000060,
|
||||||
0x00000031,0x000200f8,0x00000030,0x00050041,0x00000032,0x00000033,0x0000000f,0x0000002c,
|
0x00000059,0x0004003d,0x00000006,0x00000061,0x00000032,0x00060050,0x00000057,0x00000062,
|
||||||
0x0004003d,0x00000009,0x00000034,0x00000033,0x00050041,0x00000032,0x00000035,0x0000000e,
|
0x00000061,0x00000061,0x00000061,0x0008000c,0x00000057,0x00000063,0x00000001,0x0000002e,
|
||||||
0x0000002c,0x0003003e,0x00000035,0x00000034,0x000200f9,0x00000031,0x000200f8,0x00000031,
|
0x0000005f,0x00000060,0x00000062,0x00050041,0x00000031,0x00000065,0x00000024,0x00000064,
|
||||||
0x00050041,0x0000002d,0x00000037,0x0000000d,0x00000036,0x0004003d,0x00000006,0x00000038,
|
0x0004003d,0x00000006,0x00000066,0x00000065,0x00050051,0x00000006,0x00000067,0x00000063,
|
||||||
0x00000037,0x000300f7,0x0000003a,0x00000000,0x000400fa,0x00000038,0x00000039,0x0000003a,
|
0x00000000,0x00050051,0x00000006,0x00000068,0x00000063,0x00000001,0x00050051,0x00000006,
|
||||||
0x000200f8,0x00000039,0x00050041,0x00000032,0x0000003b,0x0000000f,0x00000036,0x0004003d,
|
0x00000069,0x00000063,0x00000002,0x00070050,0x0000000b,0x0000006a,0x00000067,0x00000068,
|
||||||
0x00000009,0x0000003c,0x0000003b,0x00050041,0x00000032,0x0000003d,0x0000000e,0x00000036,
|
0x00000069,0x00000066,0x0003003e,0x00000041,0x0000006a,0x000100fd,0x00010038
|
||||||
0x0003003e,0x0000003d,0x0000003c,0x000200f9,0x0000003a,0x000200f8,0x0000003a,0x000100fd,
|
|
||||||
0x00010038,0x00050036,0x00000002,0x0000001a,0x00000000,0x00000016,0x00030037,0x00000013,
|
|
||||||
0x00000017,0x00030037,0x00000015,0x00000018,0x00030037,0x00000015,0x00000019,0x000200f8,
|
|
||||||
0x0000001b,0x0004003b,0x00000008,0x0000003e,0x00000007,0x0004003b,0x0000000b,0x00000041,
|
|
||||||
0x00000007,0x0004003b,0x0000000b,0x00000044,0x00000007,0x0004003b,0x00000008,0x0000004d,
|
|
||||||
0x00000007,0x0004003b,0x0000000b,0x00000050,0x00000007,0x0004003b,0x0000000b,0x00000053,
|
|
||||||
0x00000007,0x0004003d,0x00000012,0x0000003f,0x00000017,0x0007004f,0x00000007,0x00000040,
|
|
||||||
0x0000003f,0x0000003f,0x00000000,0x00000001,0x0003003e,0x0000003e,0x00000040,0x0004003d,
|
|
||||||
0x00000014,0x00000042,0x00000018,0x0007004f,0x0000000a,0x00000043,0x00000042,0x00000042,
|
|
||||||
0x00000000,0x00000001,0x0003003e,0x00000041,0x00000043,0x0004003d,0x00000014,0x00000045,
|
|
||||||
0x00000019,0x0007004f,0x0000000a,0x00000046,0x00000045,0x00000045,0x00000000,0x00000001,
|
|
||||||
0x0003003e,0x00000044,0x00000046,0x00070039,0x00000002,0x00000047,0x00000010,0x0000003e,
|
|
||||||
0x00000041,0x00000044,0x0004003d,0x0000000a,0x00000048,0x00000041,0x00050041,0x00000032,
|
|
||||||
0x00000049,0x00000018,0x0000002c,0x00050051,0x00000009,0x0000004a,0x00000048,0x00000000,
|
|
||||||
0x0003003e,0x00000049,0x0000004a,0x00050041,0x00000032,0x0000004b,0x00000018,0x00000036,
|
|
||||||
0x00050051,0x00000009,0x0000004c,0x00000048,0x00000001,0x0003003e,0x0000004b,0x0000004c,
|
|
||||||
0x0004003d,0x00000012,0x0000004e,0x00000017,0x0007004f,0x00000007,0x0000004f,0x0000004e,
|
|
||||||
0x0000004e,0x00000002,0x00000003,0x0003003e,0x0000004d,0x0000004f,0x0004003d,0x00000014,
|
|
||||||
0x00000051,0x00000018,0x0007004f,0x0000000a,0x00000052,0x00000051,0x00000051,0x00000002,
|
|
||||||
0x00000003,0x0003003e,0x00000050,0x00000052,0x0004003d,0x00000014,0x00000054,0x00000019,
|
|
||||||
0x0007004f,0x0000000a,0x00000055,0x00000054,0x00000054,0x00000002,0x00000003,0x0003003e,
|
|
||||||
0x00000053,0x00000055,0x00070039,0x00000002,0x00000056,0x00000010,0x0000004d,0x00000050,
|
|
||||||
0x00000053,0x0004003d,0x0000000a,0x00000057,0x00000050,0x00050041,0x00000032,0x00000059,
|
|
||||||
0x00000018,0x00000058,0x00050051,0x00000009,0x0000005a,0x00000057,0x00000000,0x0003003e,
|
|
||||||
0x00000059,0x0000005a,0x00050041,0x00000032,0x0000005c,0x00000018,0x0000005b,0x00050051,
|
|
||||||
0x00000009,0x0000005d,0x00000057,0x00000001,0x0003003e,0x0000005c,0x0000005d,0x000100fd,
|
|
||||||
0x00010038,0x00050036,0x00000002,0x0000001f,0x00000000,0x0000001c,0x00030037,0x0000000b,
|
|
||||||
0x0000001d,0x00030037,0x00000015,0x0000001e,0x000200f8,0x00000020,0x00050041,0x00000063,
|
|
||||||
0x00000064,0x00000060,0x00000062,0x0004003d,0x00000014,0x00000065,0x00000064,0x0009004f,
|
|
||||||
0x00000014,0x00000066,0x00000065,0x00000065,0x00000000,0x00000001,0x00000000,0x00000001,
|
|
||||||
0x0004003d,0x0000000a,0x0000006a,0x0000001d,0x0009004f,0x00000014,0x0000006b,0x0000006a,
|
|
||||||
0x0000006a,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000014,0x0000006c,
|
|
||||||
0x00000001,0x00000032,0x00000066,0x00000069,0x0000006b,0x0003003e,0x0000001e,0x0000006c,
|
|
||||||
0x000100fd,0x00010038,0x00050036,0x00000014,0x00000029,0x00000000,0x00000024,0x00030037,
|
|
||||||
0x0000000b,0x00000025,0x00030037,0x00000015,0x00000026,0x00030037,0x00000023,0x00000027,
|
|
||||||
0x00030037,0x00000023,0x00000028,0x000200f8,0x0000002a,0x0004003b,0x00000015,0x0000006d,
|
|
||||||
0x00000007,0x0004003b,0x00000015,0x00000089,0x00000007,0x0004003b,0x0000002d,0x00000090,
|
|
||||||
0x00000007,0x0004003b,0x00000015,0x0000009c,0x00000007,0x0004003b,0x0000000b,0x000000a2,
|
|
||||||
0x00000007,0x0004003b,0x00000013,0x000000ac,0x00000007,0x0004003b,0x00000015,0x000000ad,
|
|
||||||
0x00000007,0x0004003b,0x00000015,0x000000af,0x00000007,0x0004003b,0x00000008,0x000000b4,
|
|
||||||
0x00000007,0x0004003b,0x0000000b,0x000000b5,0x00000007,0x0004003b,0x0000000b,0x000000b7,
|
|
||||||
0x00000007,0x0004003b,0x00000015,0x000000c2,0x00000007,0x0004003b,0x00000015,0x000000d3,
|
|
||||||
0x00000007,0x0004003d,0x00000022,0x0000006e,0x00000028,0x0004003d,0x00000014,0x0000006f,
|
|
||||||
0x00000026,0x0007004f,0x0000000a,0x00000070,0x0000006f,0x0000006f,0x00000000,0x00000001,
|
|
||||||
0x00050057,0x00000014,0x00000071,0x0000006e,0x00000070,0x00050051,0x00000009,0x00000072,
|
|
||||||
0x00000071,0x00000003,0x00050041,0x00000032,0x00000073,0x0000006d,0x0000002c,0x0003003e,
|
|
||||||
0x00000073,0x00000072,0x0004003d,0x00000022,0x00000074,0x00000028,0x0004003d,0x00000014,
|
|
||||||
0x00000075,0x00000026,0x0007004f,0x0000000a,0x00000076,0x00000075,0x00000075,0x00000002,
|
|
||||||
0x00000003,0x00050057,0x00000014,0x00000077,0x00000074,0x00000076,0x00050051,0x00000009,
|
|
||||||
0x00000078,0x00000077,0x00000001,0x00050041,0x00000032,0x00000079,0x0000006d,0x00000036,
|
|
||||||
0x0003003e,0x00000079,0x00000078,0x0004003d,0x00000022,0x0000007a,0x00000028,0x0004003d,
|
|
||||||
0x0000000a,0x0000007b,0x00000025,0x00050057,0x00000014,0x0000007c,0x0000007a,0x0000007b,
|
|
||||||
0x0007004f,0x0000000a,0x0000007d,0x0000007c,0x0000007c,0x00000000,0x00000002,0x00050041,
|
|
||||||
0x00000032,0x0000007e,0x0000006d,0x0000005b,0x00050051,0x00000009,0x0000007f,0x0000007d,
|
|
||||||
0x00000000,0x0003003e,0x0000007e,0x0000007f,0x00050041,0x00000032,0x00000080,0x0000006d,
|
|
||||||
0x00000058,0x00050051,0x00000009,0x00000081,0x0000007d,0x00000001,0x0003003e,0x00000080,
|
|
||||||
0x00000081,0x0004003d,0x00000014,0x00000082,0x0000006d,0x00050094,0x00000009,0x00000084,
|
|
||||||
0x00000082,0x00000083,0x000500b8,0x00000006,0x00000086,0x00000084,0x00000085,0x000300f7,
|
|
||||||
0x00000088,0x00000000,0x000400fa,0x00000086,0x00000087,0x0000008f,0x000200f8,0x00000087,
|
|
||||||
0x0004003d,0x00000022,0x0000008a,0x00000027,0x0004003d,0x0000000a,0x0000008b,0x00000025,
|
|
||||||
0x00070058,0x00000014,0x0000008c,0x0000008a,0x0000008b,0x00000002,0x00000068,0x0003003e,
|
|
||||||
0x00000089,0x0000008c,0x0004003d,0x00000014,0x0000008d,0x00000089,0x000200fe,0x0000008d,
|
|
||||||
0x000200f8,0x0000008f,0x00050041,0x00000032,0x00000091,0x0000006d,0x0000002c,0x0004003d,
|
|
||||||
0x00000009,0x00000092,0x00000091,0x00050041,0x00000032,0x00000093,0x0000006d,0x00000058,
|
|
||||||
0x0004003d,0x00000009,0x00000094,0x00000093,0x0007000c,0x00000009,0x00000095,0x00000001,
|
|
||||||
0x00000028,0x00000092,0x00000094,0x00050041,0x00000032,0x00000096,0x0000006d,0x00000036,
|
|
||||||
0x0004003d,0x00000009,0x00000097,0x00000096,0x00050041,0x00000032,0x00000098,0x0000006d,
|
|
||||||
0x0000005b,0x0004003d,0x00000009,0x00000099,0x00000098,0x0007000c,0x00000009,0x0000009a,
|
|
||||||
0x00000001,0x00000028,0x00000097,0x00000099,0x000500ba,0x00000006,0x0000009b,0x00000095,
|
|
||||||
0x0000009a,0x0003003e,0x00000090,0x0000009b,0x00050041,0x00000032,0x0000009d,0x0000006d,
|
|
||||||
0x00000036,0x0004003d,0x00000009,0x0000009e,0x0000009d,0x00050041,0x00000032,0x0000009f,
|
|
||||||
0x0000006d,0x0000005b,0x0004003d,0x00000009,0x000000a0,0x0000009f,0x00070050,0x00000014,
|
|
||||||
0x000000a1,0x00000068,0x0000009e,0x00000068,0x000000a0,0x0003003e,0x0000009c,0x000000a1,
|
|
||||||
0x0004003d,0x00000014,0x000000a3,0x0000006d,0x0007004f,0x0000000a,0x000000a4,0x000000a3,
|
|
||||||
0x000000a3,0x00000001,0x00000003,0x0003003e,0x000000a2,0x000000a4,0x0004003d,0x00000006,
|
|
||||||
0x000000a5,0x00000090,0x00070050,0x00000012,0x000000a6,0x000000a5,0x000000a5,0x000000a5,
|
|
||||||
0x000000a5,0x00050041,0x00000032,0x000000a7,0x0000006d,0x0000002c,0x0004003d,0x00000009,
|
|
||||||
0x000000a8,0x000000a7,0x00050041,0x00000032,0x000000a9,0x0000006d,0x00000058,0x0004003d,
|
|
||||||
0x00000009,0x000000aa,0x000000a9,0x00070050,0x00000014,0x000000ab,0x000000a8,0x00000068,
|
|
||||||
0x000000aa,0x00000068,0x0003003e,0x000000ac,0x000000a6,0x0004003d,0x00000014,0x000000ae,
|
|
||||||
0x0000009c,0x0003003e,0x000000ad,0x000000ae,0x0003003e,0x000000af,0x000000ab,0x00070039,
|
|
||||||
0x00000002,0x000000b0,0x0000001a,0x000000ac,0x000000ad,0x000000af,0x0004003d,0x00000014,
|
|
||||||
0x000000b1,0x000000ad,0x0003003e,0x0000009c,0x000000b1,0x0004003d,0x00000006,0x000000b2,
|
|
||||||
0x00000090,0x00050050,0x00000007,0x000000b3,0x000000b2,0x000000b2,0x0003003e,0x000000b4,
|
|
||||||
0x000000b3,0x0004003d,0x0000000a,0x000000b6,0x000000a2,0x0003003e,0x000000b5,0x000000b6,
|
|
||||||
0x0004003d,0x00000014,0x000000b8,0x0000006d,0x0007004f,0x0000000a,0x000000b9,0x000000b8,
|
|
||||||
0x000000b8,0x00000000,0x00000002,0x0003003e,0x000000b7,0x000000b9,0x00070039,0x00000002,
|
|
||||||
0x000000ba,0x00000010,0x000000b4,0x000000b5,0x000000b7,0x0004003d,0x0000000a,0x000000bb,
|
|
||||||
0x000000b5,0x0003003e,0x000000a2,0x000000bb,0x0004003d,0x0000000a,0x000000bc,0x000000a2,
|
|
||||||
0x00050094,0x00000009,0x000000be,0x000000bc,0x000000bd,0x0004003d,0x0000000a,0x000000bf,
|
|
||||||
0x000000a2,0x00050050,0x0000000a,0x000000c0,0x000000be,0x000000be,0x00050088,0x0000000a,
|
|
||||||
0x000000c1,0x000000bf,0x000000c0,0x0003003e,0x000000a2,0x000000c1,0x0004003d,0x00000014,
|
|
||||||
0x000000c3,0x0000009c,0x00050041,0x00000063,0x000000c4,0x00000060,0x00000062,0x0004003d,
|
|
||||||
0x00000014,0x000000c5,0x000000c4,0x0007004f,0x0000000a,0x000000c6,0x000000c5,0x000000c5,
|
|
||||||
0x00000000,0x00000001,0x00050041,0x00000063,0x000000c7,0x00000060,0x00000062,0x0004003d,
|
|
||||||
0x00000014,0x000000c8,0x000000c7,0x0007004f,0x0000000a,0x000000c9,0x000000c8,0x000000c8,
|
|
||||||
0x00000000,0x00000001,0x0004007f,0x0000000a,0x000000ca,0x000000c9,0x00050051,0x00000009,
|
|
||||||
0x000000cb,0x000000c6,0x00000000,0x00050051,0x00000009,0x000000cc,0x000000c6,0x00000001,
|
|
||||||
0x00050051,0x00000009,0x000000cd,0x000000ca,0x00000000,0x00050051,0x00000009,0x000000ce,
|
|
||||||
0x000000ca,0x00000001,0x00070050,0x00000014,0x000000cf,0x000000cb,0x000000cc,0x000000cd,
|
|
||||||
0x000000ce,0x0004003d,0x0000000a,0x000000d0,0x00000025,0x0009004f,0x00000014,0x000000d1,
|
|
||||||
0x000000d0,0x000000d0,0x00000000,0x00000001,0x00000000,0x00000001,0x0008000c,0x00000014,
|
|
||||||
0x000000d2,0x00000001,0x00000032,0x000000c3,0x000000cf,0x000000d1,0x0003003e,0x000000c2,
|
|
||||||
0x000000d2,0x00050041,0x00000032,0x000000d4,0x000000a2,0x0000002c,0x0004003d,0x00000009,
|
|
||||||
0x000000d5,0x000000d4,0x0004003d,0x00000022,0x000000d6,0x00000027,0x0004003d,0x00000014,
|
|
||||||
0x000000d7,0x000000c2,0x0007004f,0x0000000a,0x000000d8,0x000000d7,0x000000d7,0x00000000,
|
|
||||||
0x00000001,0x00070058,0x00000014,0x000000d9,0x000000d6,0x000000d8,0x00000002,0x00000068,
|
|
||||||
0x0005008e,0x00000014,0x000000da,0x000000d9,0x000000d5,0x0003003e,0x000000d3,0x000000da,
|
|
||||||
0x00050041,0x00000032,0x000000db,0x000000a2,0x00000036,0x0004003d,0x00000009,0x000000dc,
|
|
||||||
0x000000db,0x0004003d,0x00000022,0x000000dd,0x00000027,0x0004003d,0x00000014,0x000000de,
|
|
||||||
0x000000c2,0x0007004f,0x0000000a,0x000000df,0x000000de,0x000000de,0x00000002,0x00000003,
|
|
||||||
0x00070058,0x00000014,0x000000e0,0x000000dd,0x000000df,0x00000002,0x00000068,0x0005008e,
|
|
||||||
0x00000014,0x000000e1,0x000000e0,0x000000dc,0x0004003d,0x00000014,0x000000e2,0x000000d3,
|
|
||||||
0x00050081,0x00000014,0x000000e3,0x000000e2,0x000000e1,0x0003003e,0x000000d3,0x000000e3,
|
|
||||||
0x0004003d,0x00000014,0x000000e4,0x000000d3,0x000200fe,0x000000e4,0x000200f8,0x00000088,
|
|
||||||
0x000100ff,0x00010038
|
|
||||||
};
|
};
|
||||||
@@ -1,21 +1,29 @@
|
|||||||
#version 450
|
#version 450
|
||||||
#extension GL_GOOGLE_include_directive : require
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 fragTexCoord;
|
layout(location = 0) in vec2 fragTexCoord;
|
||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
layout(set = 0, binding = 0) uniform sampler2D InputTexture;
|
layout(set = 0, binding = 0) uniform sampler2D InputTexture;
|
||||||
layout(push_constant) uniform Constants {
|
layout(push_constant) uniform Constants {
|
||||||
vec4 ndc;
|
vec4 ndc;
|
||||||
vec4 metrics; // 1/width, 1/height, width, height
|
vec2 resolution;
|
||||||
|
float extra;
|
||||||
|
float pad;
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS pc.metrics
|
float luma(vec3 c) {
|
||||||
#define SMAA_GLSL_4
|
return dot(c, vec3(0.2126, 0.7152, 0.0722));
|
||||||
#define SMAA_PRESET_HIGH
|
}
|
||||||
#include "SMAA.hlsl"
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 offset[3];
|
vec2 px = 1.0 / max(pc.resolution, vec2(1.0));
|
||||||
SMAAEdgeDetectionVS(fragTexCoord, offset);
|
vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5);
|
||||||
outColor = vec4(SMAALumaEdgeDetectionPS(fragTexCoord, offset, InputTexture), 0.0, 0.0);
|
float center = luma(texture(InputTexture, uv).rgb);
|
||||||
|
float left = luma(texture(InputTexture, uv - vec2(px.x, 0.0)).rgb);
|
||||||
|
float right = luma(texture(InputTexture, uv + vec2(px.x, 0.0)).rgb);
|
||||||
|
float up = luma(texture(InputTexture, uv - vec2(0.0, px.y)).rgb);
|
||||||
|
float down = luma(texture(InputTexture, uv + vec2(0.0, px.y)).rgb);
|
||||||
|
|
||||||
|
// Store directional edge strengths for the weight pass.
|
||||||
|
outColor = vec4(abs(center - left), abs(center - right),
|
||||||
|
abs(center - up), abs(center - down));
|
||||||
}
|
}
|
||||||
@@ -1,185 +1,102 @@
|
|||||||
// 1116.6.0
|
// 1116.3.0
|
||||||
#pragma once
|
#pragma once
|
||||||
const uint32_t smaa_edge_code[] = {
|
const uint32_t smaa_edge_code[] = {
|
||||||
0x07230203,0x00010000,0x0008000b,0x000000eb,0x00000000,0x00020011,0x00000001,0x0006000b,
|
0x07230203,0x00010000,0x0008000b,0x00000080,0x00000000,0x00020011,0x00000001,0x0006000b,
|
||||||
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
0x00000001,0x4c534c47,0x6474732e,0x3035342e,0x00000000,0x0003000e,0x00000000,0x00000001,
|
||||||
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x000000d9,0x000000e1,0x00030010,
|
0x0007000f,0x00000004,0x00000004,0x6e69616d,0x00000000,0x00000028,0x0000006e,0x00030010,
|
||||||
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x000a0004,0x475f4c47,0x4c474f4f,
|
0x00000004,0x00000007,0x00030003,0x00000002,0x000001c2,0x00040005,0x00000004,0x6e69616d,
|
||||||
0x70635f45,0x74735f70,0x5f656c79,0x656e696c,0x7269645f,0x69746365,0x00006576,0x00080004,
|
0x00000000,0x00050005,0x0000000b,0x616d756c,0x33667628,0x0000003b,0x00030005,0x0000000a,
|
||||||
0x475f4c47,0x4c474f4f,0x6e695f45,0x64756c63,0x69645f65,0x74636572,0x00657669,0x00040005,
|
0x00000063,0x00030005,0x00000017,0x00007870,0x00050005,0x0000001a,0x736e6f43,0x746e6174,
|
||||||
0x00000004,0x6e69616d,0x00000000,0x000a0005,0x00000011,0x41414d53,0x65676445,0x65746544,
|
0x00000073,0x00040006,0x0000001a,0x00000000,0x0063646e,0x00060006,0x0000001a,0x00000001,
|
||||||
0x6f697463,0x2853566e,0x3b326676,0x5b346676,0x003b5d33,0x00050005,0x0000000f,0x63786574,
|
0x6f736572,0x6974756c,0x00006e6f,0x00050006,0x0000001a,0x00000002,0x72747865,0x00000061,
|
||||||
0x64726f6f,0x00000000,0x00040005,0x00000010,0x7366666f,0x00007465,0x000c0005,0x0000001a,
|
0x00040006,0x0000001a,0x00000003,0x00646170,0x00030005,0x0000001c,0x00006370,0x00030005,
|
||||||
0x41414d53,0x616d754c,0x65676445,0x65746544,0x6f697463,0x2853506e,0x3b326676,0x5b346676,
|
0x00000026,0x00007675,0x00060005,0x00000028,0x67617266,0x43786554,0x64726f6f,0x00000000,
|
||||||
0x733b5d33,0x003b3132,0x00050005,0x00000017,0x63786574,0x64726f6f,0x00000000,0x00040005,
|
0x00040005,0x00000032,0x746e6563,0x00007265,0x00060005,0x00000036,0x75706e49,0x78655474,
|
||||||
0x00000018,0x7366666f,0x00007465,0x00050005,0x00000019,0x6f6c6f63,0x78655472,0x00000000,
|
0x65727574,0x00000000,0x00040005,0x0000003a,0x61726170,0x0000006d,0x00040005,0x0000003d,
|
||||||
0x00050005,0x0000001e,0x736e6f43,0x746e6174,0x00000073,0x00040006,0x0000001e,0x00000000,
|
0x7466656c,0x00000000,0x00040005,0x00000048,0x61726170,0x0000006d,0x00040005,0x0000004b,
|
||||||
0x0063646e,0x00050006,0x0000001e,0x00000001,0x7274656d,0x00736369,0x00030005,0x00000020,
|
0x68676972,0x00000074,0x00040005,0x00000053,0x61726170,0x0000006d,0x00030005,0x00000056,
|
||||||
0x00006370,0x00050005,0x00000041,0x65726874,0x6c6f6873,0x00000064,0x00040005,0x00000046,
|
0x00007075,0x00040005,0x0000005f,0x61726170,0x0000006d,0x00040005,0x00000062,0x6e776f64,
|
||||||
0x67696577,0x00737468,0x00030005,0x0000004c,0x0000004c,0x00040005,0x00000053,0x66656c4c,
|
0x00000000,0x00040005,0x0000006a,0x61726170,0x0000006d,0x00050005,0x0000006e,0x4374756f,
|
||||||
0x00000074,0x00040005,0x0000005c,0x706f744c,0x00000000,0x00040005,0x00000065,0x746c6564,
|
0x726f6c6f,0x00000000,0x00030047,0x0000001a,0x00000002,0x00050048,0x0000001a,0x00000000,
|
||||||
0x00000061,0x00040005,0x00000073,0x65676465,0x00000073,0x00040005,0x00000080,0x6769724c,
|
0x00000023,0x00000000,0x00050048,0x0000001a,0x00000001,0x00000023,0x00000010,0x00050048,
|
||||||
0x00007468,0x00040005,0x00000089,0x746f624c,0x006d6f74,0x00050005,0x0000009e,0x4478616d,
|
0x0000001a,0x00000002,0x00000023,0x00000018,0x00050048,0x0000001a,0x00000003,0x00000023,
|
||||||
0x61746c65,0x00000000,0x00050005,0x000000a4,0x66656c4c,0x66656c74,0x00000074,0x00040005,
|
0x0000001c,0x00040047,0x00000028,0x0000001e,0x00000000,0x00040047,0x00000036,0x00000021,
|
||||||
0x000000ad,0x706f744c,0x00706f74,0x00050005,0x000000c6,0x616e6966,0x6c65446c,0x00006174,
|
0x00000000,0x00040047,0x00000036,0x00000022,0x00000000,0x00040047,0x0000006e,0x0000001e,
|
||||||
0x00060005,0x000000d9,0x67617266,0x43786554,0x64726f6f,0x00000000,0x00040005,0x000000da,
|
0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,0x00000006,
|
||||||
0x7366666f,0x00007465,0x00040005,0x000000db,0x61726170,0x0000006d,0x00040005,0x000000dd,
|
0x00000020,0x00040017,0x00000007,0x00000006,0x00000003,0x00040020,0x00000008,0x00000007,
|
||||||
0x61726170,0x0000006d,0x00050005,0x000000e1,0x4374756f,0x726f6c6f,0x00000000,0x00060005,
|
0x00000007,0x00040021,0x00000009,0x00000006,0x00000008,0x0004002b,0x00000006,0x0000000e,
|
||||||
0x000000e2,0x75706e49,0x78655474,0x65727574,0x00000000,0x00040005,0x000000e3,0x61726170,
|
0x3e59b3d0,0x0004002b,0x00000006,0x0000000f,0x3f371759,0x0004002b,0x00000006,0x00000010,
|
||||||
0x0000006d,0x00040005,0x000000e5,0x61726170,0x0000006d,0x00030047,0x0000001e,0x00000002,
|
0x3d93dd98,0x0006002c,0x00000007,0x00000011,0x0000000e,0x0000000f,0x00000010,0x00040017,
|
||||||
0x00050048,0x0000001e,0x00000000,0x00000023,0x00000000,0x00050048,0x0000001e,0x00000001,
|
0x00000015,0x00000006,0x00000002,0x00040020,0x00000016,0x00000007,0x00000015,0x0004002b,
|
||||||
0x00000023,0x00000010,0x00040047,0x000000d9,0x0000001e,0x00000000,0x00040047,0x000000e1,
|
0x00000006,0x00000018,0x3f800000,0x00040017,0x00000019,0x00000006,0x00000004,0x0006001e,
|
||||||
0x0000001e,0x00000000,0x00040047,0x000000e2,0x00000021,0x00000000,0x00040047,0x000000e2,
|
0x0000001a,0x00000019,0x00000015,0x00000006,0x00000006,0x00040020,0x0000001b,0x00000009,
|
||||||
0x00000022,0x00000000,0x00020013,0x00000002,0x00030021,0x00000003,0x00000002,0x00030016,
|
0x0000001a,0x0004003b,0x0000001b,0x0000001c,0x00000009,0x00040015,0x0000001d,0x00000020,
|
||||||
0x00000006,0x00000020,0x00040017,0x00000007,0x00000006,0x00000002,0x00040020,0x00000008,
|
0x00000001,0x0004002b,0x0000001d,0x0000001e,0x00000001,0x00040020,0x0000001f,0x00000009,
|
||||||
0x00000007,0x00000007,0x00040017,0x00000009,0x00000006,0x00000004,0x00040015,0x0000000a,
|
0x00000015,0x0005002c,0x00000015,0x00000022,0x00000018,0x00000018,0x00040020,0x00000027,
|
||||||
0x00000020,0x00000000,0x0004002b,0x0000000a,0x0000000b,0x00000003,0x0004001c,0x0000000c,
|
0x00000001,0x00000015,0x0004003b,0x00000027,0x00000028,0x00000001,0x0004002b,0x00000006,
|
||||||
0x00000009,0x0000000b,0x00040020,0x0000000d,0x00000007,0x0000000c,0x00050021,0x0000000e,
|
0x0000002b,0x3f000000,0x00040020,0x00000031,0x00000007,0x00000006,0x00090019,0x00000033,
|
||||||
0x00000002,0x00000008,0x0000000d,0x00090019,0x00000013,0x00000006,0x00000001,0x00000000,
|
0x00000006,0x00000001,0x00000000,0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,
|
||||||
0x00000000,0x00000000,0x00000001,0x00000000,0x0003001b,0x00000014,0x00000013,0x00040020,
|
0x00000034,0x00000033,0x00040020,0x00000035,0x00000000,0x00000034,0x0004003b,0x00000035,
|
||||||
0x00000015,0x00000000,0x00000014,0x00060021,0x00000016,0x00000007,0x00000008,0x0000000d,
|
0x00000036,0x00000000,0x00040015,0x00000040,0x00000020,0x00000000,0x0004002b,0x00000040,
|
||||||
0x00000015,0x00040015,0x0000001c,0x00000020,0x00000001,0x0004002b,0x0000001c,0x0000001d,
|
0x00000041,0x00000000,0x0004002b,0x00000006,0x00000044,0x00000000,0x0004002b,0x00000040,
|
||||||
0x00000000,0x0004001e,0x0000001e,0x00000009,0x00000009,0x00040020,0x0000001f,0x00000009,
|
0x00000059,0x00000001,0x00040020,0x0000006d,0x00000003,0x00000019,0x0004003b,0x0000006d,
|
||||||
0x0000001e,0x0004003b,0x0000001f,0x00000020,0x00000009,0x0004002b,0x0000001c,0x00000021,
|
0x0000006e,0x00000003,0x00050036,0x00000002,0x00000004,0x00000000,0x00000003,0x000200f8,
|
||||||
0x00000001,0x00040020,0x00000022,0x00000009,0x00000009,0x0004002b,0x00000006,0x00000026,
|
0x00000005,0x0004003b,0x00000016,0x00000017,0x00000007,0x0004003b,0x00000016,0x00000026,
|
||||||
0xbf800000,0x0004002b,0x00000006,0x00000027,0x00000000,0x0007002c,0x00000009,0x00000028,
|
0x00000007,0x0004003b,0x00000031,0x00000032,0x00000007,0x0004003b,0x00000008,0x0000003a,
|
||||||
0x00000026,0x00000027,0x00000027,0x00000026,0x00040020,0x0000002c,0x00000007,0x00000009,
|
0x00000007,0x0004003b,0x00000031,0x0000003d,0x00000007,0x0004003b,0x00000008,0x00000048,
|
||||||
0x0004002b,0x00000006,0x00000031,0x3f800000,0x0007002c,0x00000009,0x00000032,0x00000031,
|
0x00000007,0x0004003b,0x00000031,0x0000004b,0x00000007,0x0004003b,0x00000008,0x00000053,
|
||||||
0x00000027,0x00000027,0x00000031,0x0004002b,0x0000001c,0x00000037,0x00000002,0x0004002b,
|
0x00000007,0x0004003b,0x00000031,0x00000056,0x00000007,0x0004003b,0x00000008,0x0000005f,
|
||||||
0x00000006,0x0000003b,0xc0000000,0x0007002c,0x00000009,0x0000003c,0x0000003b,0x00000027,
|
0x00000007,0x0004003b,0x00000031,0x00000062,0x00000007,0x0004003b,0x00000008,0x0000006a,
|
||||||
0x00000027,0x0000003b,0x0004002b,0x00000006,0x00000042,0x3dcccccd,0x0005002c,0x00000007,
|
0x00000007,0x00050041,0x0000001f,0x00000020,0x0000001c,0x0000001e,0x0004003d,0x00000015,
|
||||||
0x00000043,0x00000042,0x00000042,0x00040017,0x00000044,0x00000006,0x00000003,0x00040020,
|
0x00000021,0x00000020,0x0007000c,0x00000015,0x00000023,0x00000001,0x00000028,0x00000021,
|
||||||
0x00000045,0x00000007,0x00000044,0x0004002b,0x00000006,0x00000047,0x3e59b3d0,0x0004002b,
|
0x00000022,0x00050050,0x00000015,0x00000024,0x00000018,0x00000018,0x00050088,0x00000015,
|
||||||
0x00000006,0x00000048,0x3f371759,0x0004002b,0x00000006,0x00000049,0x3d93dd98,0x0006002c,
|
0x00000025,0x00000024,0x00000023,0x0003003e,0x00000017,0x00000025,0x0004003d,0x00000015,
|
||||||
0x00000044,0x0000004a,0x00000047,0x00000048,0x00000049,0x00040020,0x0000004b,0x00000007,
|
0x00000029,0x00000028,0x0004003d,0x00000015,0x0000002a,0x00000017,0x0005008e,0x00000015,
|
||||||
0x00000006,0x0004002b,0x0000000a,0x0000006d,0x00000000,0x0004002b,0x0000000a,0x00000070,
|
0x0000002c,0x0000002a,0x0000002b,0x0004003d,0x00000015,0x0000002d,0x00000017,0x0005008e,
|
||||||
0x00000001,0x0005002c,0x00000007,0x00000079,0x00000031,0x00000031,0x00020014,0x0000007b,
|
0x00000015,0x0000002e,0x0000002d,0x0000002b,0x00050083,0x00000015,0x0000002f,0x00000022,
|
||||||
0x0004002b,0x0000000a,0x00000099,0x00000002,0x0004002b,0x00000006,0x000000cd,0x40000000,
|
0x0000002e,0x0008000c,0x00000015,0x00000030,0x00000001,0x0000002b,0x00000029,0x0000002c,
|
||||||
0x00040020,0x000000d8,0x00000001,0x00000007,0x0004003b,0x000000d8,0x000000d9,0x00000001,
|
0x0000002f,0x0003003e,0x00000026,0x00000030,0x0004003d,0x00000034,0x00000037,0x00000036,
|
||||||
0x00040020,0x000000e0,0x00000003,0x00000009,0x0004003b,0x000000e0,0x000000e1,0x00000003,
|
0x0004003d,0x00000015,0x00000038,0x00000026,0x00050057,0x00000019,0x00000039,0x00000037,
|
||||||
0x0004003b,0x00000015,0x000000e2,0x00000000,0x00050036,0x00000002,0x00000004,0x00000000,
|
0x00000038,0x0008004f,0x00000007,0x0000003b,0x00000039,0x00000039,0x00000000,0x00000001,
|
||||||
0x00000003,0x000200f8,0x00000005,0x0004003b,0x0000000d,0x000000da,0x00000007,0x0004003b,
|
0x00000002,0x0003003e,0x0000003a,0x0000003b,0x00050039,0x00000006,0x0000003c,0x0000000b,
|
||||||
0x00000008,0x000000db,0x00000007,0x0004003b,0x0000000d,0x000000dd,0x00000007,0x0004003b,
|
0x0000003a,0x0003003e,0x00000032,0x0000003c,0x0004003d,0x00000034,0x0000003e,0x00000036,
|
||||||
0x00000008,0x000000e3,0x00000007,0x0004003b,0x0000000d,0x000000e5,0x00000007,0x0004003d,
|
0x0004003d,0x00000015,0x0000003f,0x00000026,0x00050041,0x00000031,0x00000042,0x00000017,
|
||||||
0x00000007,0x000000dc,0x000000d9,0x0003003e,0x000000db,0x000000dc,0x00060039,0x00000002,
|
0x00000041,0x0004003d,0x00000006,0x00000043,0x00000042,0x00050050,0x00000015,0x00000045,
|
||||||
0x000000de,0x00000011,0x000000db,0x000000dd,0x0004003d,0x0000000c,0x000000df,0x000000dd,
|
0x00000043,0x00000044,0x00050083,0x00000015,0x00000046,0x0000003f,0x00000045,0x00050057,
|
||||||
0x0003003e,0x000000da,0x000000df,0x0004003d,0x00000007,0x000000e4,0x000000d9,0x0003003e,
|
0x00000019,0x00000047,0x0000003e,0x00000046,0x0008004f,0x00000007,0x00000049,0x00000047,
|
||||||
0x000000e3,0x000000e4,0x0004003d,0x0000000c,0x000000e6,0x000000da,0x0003003e,0x000000e5,
|
0x00000047,0x00000000,0x00000001,0x00000002,0x0003003e,0x00000048,0x00000049,0x00050039,
|
||||||
0x000000e6,0x00070039,0x00000007,0x000000e7,0x0000001a,0x000000e3,0x000000e5,0x000000e2,
|
0x00000006,0x0000004a,0x0000000b,0x00000048,0x0003003e,0x0000003d,0x0000004a,0x0004003d,
|
||||||
0x00050051,0x00000006,0x000000e8,0x000000e7,0x00000000,0x00050051,0x00000006,0x000000e9,
|
0x00000034,0x0000004c,0x00000036,0x0004003d,0x00000015,0x0000004d,0x00000026,0x00050041,
|
||||||
0x000000e7,0x00000001,0x00070050,0x00000009,0x000000ea,0x000000e8,0x000000e9,0x00000027,
|
0x00000031,0x0000004e,0x00000017,0x00000041,0x0004003d,0x00000006,0x0000004f,0x0000004e,
|
||||||
0x00000027,0x0003003e,0x000000e1,0x000000ea,0x000100fd,0x00010038,0x00050036,0x00000002,
|
0x00050050,0x00000015,0x00000050,0x0000004f,0x00000044,0x00050081,0x00000015,0x00000051,
|
||||||
0x00000011,0x00000000,0x0000000e,0x00030037,0x00000008,0x0000000f,0x00030037,0x0000000d,
|
0x0000004d,0x00000050,0x00050057,0x00000019,0x00000052,0x0000004c,0x00000051,0x0008004f,
|
||||||
0x00000010,0x000200f8,0x00000012,0x00050041,0x00000022,0x00000023,0x00000020,0x00000021,
|
0x00000007,0x00000054,0x00000052,0x00000052,0x00000000,0x00000001,0x00000002,0x0003003e,
|
||||||
0x0004003d,0x00000009,0x00000024,0x00000023,0x0009004f,0x00000009,0x00000025,0x00000024,
|
0x00000053,0x00000054,0x00050039,0x00000006,0x00000055,0x0000000b,0x00000053,0x0003003e,
|
||||||
0x00000024,0x00000000,0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x00000029,
|
0x0000004b,0x00000055,0x0004003d,0x00000034,0x00000057,0x00000036,0x0004003d,0x00000015,
|
||||||
0x0000000f,0x0009004f,0x00000009,0x0000002a,0x00000029,0x00000029,0x00000000,0x00000001,
|
0x00000058,0x00000026,0x00050041,0x00000031,0x0000005a,0x00000017,0x00000059,0x0004003d,
|
||||||
0x00000000,0x00000001,0x0008000c,0x00000009,0x0000002b,0x00000001,0x00000032,0x00000025,
|
0x00000006,0x0000005b,0x0000005a,0x00050050,0x00000015,0x0000005c,0x00000044,0x0000005b,
|
||||||
0x00000028,0x0000002a,0x00050041,0x0000002c,0x0000002d,0x00000010,0x0000001d,0x0003003e,
|
0x00050083,0x00000015,0x0000005d,0x00000058,0x0000005c,0x00050057,0x00000019,0x0000005e,
|
||||||
0x0000002d,0x0000002b,0x00050041,0x00000022,0x0000002e,0x00000020,0x00000021,0x0004003d,
|
0x00000057,0x0000005d,0x0008004f,0x00000007,0x00000060,0x0000005e,0x0000005e,0x00000000,
|
||||||
0x00000009,0x0000002f,0x0000002e,0x0009004f,0x00000009,0x00000030,0x0000002f,0x0000002f,
|
0x00000001,0x00000002,0x0003003e,0x0000005f,0x00000060,0x00050039,0x00000006,0x00000061,
|
||||||
0x00000000,0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x00000033,0x0000000f,
|
0x0000000b,0x0000005f,0x0003003e,0x00000056,0x00000061,0x0004003d,0x00000034,0x00000063,
|
||||||
0x0009004f,0x00000009,0x00000034,0x00000033,0x00000033,0x00000000,0x00000001,0x00000000,
|
0x00000036,0x0004003d,0x00000015,0x00000064,0x00000026,0x00050041,0x00000031,0x00000065,
|
||||||
0x00000001,0x0008000c,0x00000009,0x00000035,0x00000001,0x00000032,0x00000030,0x00000032,
|
0x00000017,0x00000059,0x0004003d,0x00000006,0x00000066,0x00000065,0x00050050,0x00000015,
|
||||||
0x00000034,0x00050041,0x0000002c,0x00000036,0x00000010,0x00000021,0x0003003e,0x00000036,
|
0x00000067,0x00000044,0x00000066,0x00050081,0x00000015,0x00000068,0x00000064,0x00000067,
|
||||||
0x00000035,0x00050041,0x00000022,0x00000038,0x00000020,0x00000021,0x0004003d,0x00000009,
|
0x00050057,0x00000019,0x00000069,0x00000063,0x00000068,0x0008004f,0x00000007,0x0000006b,
|
||||||
0x00000039,0x00000038,0x0009004f,0x00000009,0x0000003a,0x00000039,0x00000039,0x00000000,
|
0x00000069,0x00000069,0x00000000,0x00000001,0x00000002,0x0003003e,0x0000006a,0x0000006b,
|
||||||
0x00000001,0x00000000,0x00000001,0x0004003d,0x00000007,0x0000003d,0x0000000f,0x0009004f,
|
0x00050039,0x00000006,0x0000006c,0x0000000b,0x0000006a,0x0003003e,0x00000062,0x0000006c,
|
||||||
0x00000009,0x0000003e,0x0000003d,0x0000003d,0x00000000,0x00000001,0x00000000,0x00000001,
|
0x0004003d,0x00000006,0x0000006f,0x00000032,0x0004003d,0x00000006,0x00000070,0x0000003d,
|
||||||
0x0008000c,0x00000009,0x0000003f,0x00000001,0x00000032,0x0000003a,0x0000003c,0x0000003e,
|
0x00050083,0x00000006,0x00000071,0x0000006f,0x00000070,0x0006000c,0x00000006,0x00000072,
|
||||||
0x00050041,0x0000002c,0x00000040,0x00000010,0x00000037,0x0003003e,0x00000040,0x0000003f,
|
0x00000001,0x00000004,0x00000071,0x0004003d,0x00000006,0x00000073,0x00000032,0x0004003d,
|
||||||
0x000100fd,0x00010038,0x00050036,0x00000007,0x0000001a,0x00000000,0x00000016,0x00030037,
|
0x00000006,0x00000074,0x0000004b,0x00050083,0x00000006,0x00000075,0x00000073,0x00000074,
|
||||||
0x00000008,0x00000017,0x00030037,0x0000000d,0x00000018,0x00030037,0x00000015,0x00000019,
|
0x0006000c,0x00000006,0x00000076,0x00000001,0x00000004,0x00000075,0x0004003d,0x00000006,
|
||||||
0x000200f8,0x0000001b,0x0004003b,0x00000008,0x00000041,0x00000007,0x0004003b,0x00000045,
|
0x00000077,0x00000032,0x0004003d,0x00000006,0x00000078,0x00000056,0x00050083,0x00000006,
|
||||||
0x00000046,0x00000007,0x0004003b,0x0000004b,0x0000004c,0x00000007,0x0004003b,0x0000004b,
|
0x00000079,0x00000077,0x00000078,0x0006000c,0x00000006,0x0000007a,0x00000001,0x00000004,
|
||||||
0x00000053,0x00000007,0x0004003b,0x0000004b,0x0000005c,0x00000007,0x0004003b,0x0000002c,
|
0x00000079,0x0004003d,0x00000006,0x0000007b,0x00000032,0x0004003d,0x00000006,0x0000007c,
|
||||||
0x00000065,0x00000007,0x0004003b,0x00000008,0x00000073,0x00000007,0x0004003b,0x0000004b,
|
0x00000062,0x00050083,0x00000006,0x0000007d,0x0000007b,0x0000007c,0x0006000c,0x00000006,
|
||||||
0x00000080,0x00000007,0x0004003b,0x0000004b,0x00000089,0x00000007,0x0004003b,0x00000008,
|
0x0000007e,0x00000001,0x00000004,0x0000007d,0x00070050,0x00000019,0x0000007f,0x00000072,
|
||||||
0x0000009e,0x00000007,0x0004003b,0x0000004b,0x000000a4,0x00000007,0x0004003b,0x0000004b,
|
0x00000076,0x0000007a,0x0000007e,0x0003003e,0x0000006e,0x0000007f,0x000100fd,0x00010038,
|
||||||
0x000000ad,0x00000007,0x0004003b,0x0000004b,0x000000c6,0x00000007,0x0003003e,0x00000041,
|
0x00050036,0x00000006,0x0000000b,0x00000000,0x00000009,0x00030037,0x00000008,0x0000000a,
|
||||||
0x00000043,0x0003003e,0x00000046,0x0000004a,0x0004003d,0x00000014,0x0000004d,0x00000019,
|
0x000200f8,0x0000000c,0x0004003d,0x00000007,0x0000000d,0x0000000a,0x00050094,0x00000006,
|
||||||
0x0004003d,0x00000007,0x0000004e,0x00000017,0x00050057,0x00000009,0x0000004f,0x0000004d,
|
0x00000012,0x0000000d,0x00000011,0x000200fe,0x00000012,0x00010038
|
||||||
0x0000004e,0x0008004f,0x00000044,0x00000050,0x0000004f,0x0000004f,0x00000000,0x00000001,
|
|
||||||
0x00000002,0x0004003d,0x00000044,0x00000051,0x00000046,0x00050094,0x00000006,0x00000052,
|
|
||||||
0x00000050,0x00000051,0x0003003e,0x0000004c,0x00000052,0x0004003d,0x00000014,0x00000054,
|
|
||||||
0x00000019,0x00050041,0x0000002c,0x00000055,0x00000018,0x0000001d,0x0004003d,0x00000009,
|
|
||||||
0x00000056,0x00000055,0x0007004f,0x00000007,0x00000057,0x00000056,0x00000056,0x00000000,
|
|
||||||
0x00000001,0x00050057,0x00000009,0x00000058,0x00000054,0x00000057,0x0008004f,0x00000044,
|
|
||||||
0x00000059,0x00000058,0x00000058,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,
|
|
||||||
0x0000005a,0x00000046,0x00050094,0x00000006,0x0000005b,0x00000059,0x0000005a,0x0003003e,
|
|
||||||
0x00000053,0x0000005b,0x0004003d,0x00000014,0x0000005d,0x00000019,0x00050041,0x0000002c,
|
|
||||||
0x0000005e,0x00000018,0x0000001d,0x0004003d,0x00000009,0x0000005f,0x0000005e,0x0007004f,
|
|
||||||
0x00000007,0x00000060,0x0000005f,0x0000005f,0x00000002,0x00000003,0x00050057,0x00000009,
|
|
||||||
0x00000061,0x0000005d,0x00000060,0x0008004f,0x00000044,0x00000062,0x00000061,0x00000061,
|
|
||||||
0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x00000063,0x00000046,0x00050094,
|
|
||||||
0x00000006,0x00000064,0x00000062,0x00000063,0x0003003e,0x0000005c,0x00000064,0x0004003d,
|
|
||||||
0x00000006,0x00000066,0x0000004c,0x0004003d,0x00000006,0x00000067,0x00000053,0x0004003d,
|
|
||||||
0x00000006,0x00000068,0x0000005c,0x00050050,0x00000007,0x00000069,0x00000067,0x00000068,
|
|
||||||
0x00050050,0x00000007,0x0000006a,0x00000066,0x00000066,0x00050083,0x00000007,0x0000006b,
|
|
||||||
0x0000006a,0x00000069,0x0006000c,0x00000007,0x0000006c,0x00000001,0x00000004,0x0000006b,
|
|
||||||
0x00050041,0x0000004b,0x0000006e,0x00000065,0x0000006d,0x00050051,0x00000006,0x0000006f,
|
|
||||||
0x0000006c,0x00000000,0x0003003e,0x0000006e,0x0000006f,0x00050041,0x0000004b,0x00000071,
|
|
||||||
0x00000065,0x00000070,0x00050051,0x00000006,0x00000072,0x0000006c,0x00000001,0x0003003e,
|
|
||||||
0x00000071,0x00000072,0x0004003d,0x00000007,0x00000074,0x00000041,0x0004003d,0x00000009,
|
|
||||||
0x00000075,0x00000065,0x0007004f,0x00000007,0x00000076,0x00000075,0x00000075,0x00000000,
|
|
||||||
0x00000001,0x0007000c,0x00000007,0x00000077,0x00000001,0x00000030,0x00000074,0x00000076,
|
|
||||||
0x0003003e,0x00000073,0x00000077,0x0004003d,0x00000007,0x00000078,0x00000073,0x00050094,
|
|
||||||
0x00000006,0x0000007a,0x00000078,0x00000079,0x000500b4,0x0000007b,0x0000007c,0x0000007a,
|
|
||||||
0x00000027,0x000300f7,0x0000007e,0x00000000,0x000400fa,0x0000007c,0x0000007d,0x0000007e,
|
|
||||||
0x000200f8,0x0000007d,0x000100fc,0x000200f8,0x0000007e,0x0004003d,0x00000014,0x00000081,
|
|
||||||
0x00000019,0x00050041,0x0000002c,0x00000082,0x00000018,0x00000021,0x0004003d,0x00000009,
|
|
||||||
0x00000083,0x00000082,0x0007004f,0x00000007,0x00000084,0x00000083,0x00000083,0x00000000,
|
|
||||||
0x00000001,0x00050057,0x00000009,0x00000085,0x00000081,0x00000084,0x0008004f,0x00000044,
|
|
||||||
0x00000086,0x00000085,0x00000085,0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,
|
|
||||||
0x00000087,0x00000046,0x00050094,0x00000006,0x00000088,0x00000086,0x00000087,0x0003003e,
|
|
||||||
0x00000080,0x00000088,0x0004003d,0x00000014,0x0000008a,0x00000019,0x00050041,0x0000002c,
|
|
||||||
0x0000008b,0x00000018,0x00000021,0x0004003d,0x00000009,0x0000008c,0x0000008b,0x0007004f,
|
|
||||||
0x00000007,0x0000008d,0x0000008c,0x0000008c,0x00000002,0x00000003,0x00050057,0x00000009,
|
|
||||||
0x0000008e,0x0000008a,0x0000008d,0x0008004f,0x00000044,0x0000008f,0x0000008e,0x0000008e,
|
|
||||||
0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x00000090,0x00000046,0x00050094,
|
|
||||||
0x00000006,0x00000091,0x0000008f,0x00000090,0x0003003e,0x00000089,0x00000091,0x0004003d,
|
|
||||||
0x00000006,0x00000092,0x0000004c,0x0004003d,0x00000006,0x00000093,0x00000080,0x0004003d,
|
|
||||||
0x00000006,0x00000094,0x00000089,0x00050050,0x00000007,0x00000095,0x00000093,0x00000094,
|
|
||||||
0x00050050,0x00000007,0x00000096,0x00000092,0x00000092,0x00050083,0x00000007,0x00000097,
|
|
||||||
0x00000096,0x00000095,0x0006000c,0x00000007,0x00000098,0x00000001,0x00000004,0x00000097,
|
|
||||||
0x00050041,0x0000004b,0x0000009a,0x00000065,0x00000099,0x00050051,0x00000006,0x0000009b,
|
|
||||||
0x00000098,0x00000000,0x0003003e,0x0000009a,0x0000009b,0x00050041,0x0000004b,0x0000009c,
|
|
||||||
0x00000065,0x0000000b,0x00050051,0x00000006,0x0000009d,0x00000098,0x00000001,0x0003003e,
|
|
||||||
0x0000009c,0x0000009d,0x0004003d,0x00000009,0x0000009f,0x00000065,0x0007004f,0x00000007,
|
|
||||||
0x000000a0,0x0000009f,0x0000009f,0x00000000,0x00000001,0x0004003d,0x00000009,0x000000a1,
|
|
||||||
0x00000065,0x0007004f,0x00000007,0x000000a2,0x000000a1,0x000000a1,0x00000002,0x00000003,
|
|
||||||
0x0007000c,0x00000007,0x000000a3,0x00000001,0x00000028,0x000000a0,0x000000a2,0x0003003e,
|
|
||||||
0x0000009e,0x000000a3,0x0004003d,0x00000014,0x000000a5,0x00000019,0x00050041,0x0000002c,
|
|
||||||
0x000000a6,0x00000018,0x00000037,0x0004003d,0x00000009,0x000000a7,0x000000a6,0x0007004f,
|
|
||||||
0x00000007,0x000000a8,0x000000a7,0x000000a7,0x00000000,0x00000001,0x00050057,0x00000009,
|
|
||||||
0x000000a9,0x000000a5,0x000000a8,0x0008004f,0x00000044,0x000000aa,0x000000a9,0x000000a9,
|
|
||||||
0x00000000,0x00000001,0x00000002,0x0004003d,0x00000044,0x000000ab,0x00000046,0x00050094,
|
|
||||||
0x00000006,0x000000ac,0x000000aa,0x000000ab,0x0003003e,0x000000a4,0x000000ac,0x0004003d,
|
|
||||||
0x00000014,0x000000ae,0x00000019,0x00050041,0x0000002c,0x000000af,0x00000018,0x00000037,
|
|
||||||
0x0004003d,0x00000009,0x000000b0,0x000000af,0x0007004f,0x00000007,0x000000b1,0x000000b0,
|
|
||||||
0x000000b0,0x00000002,0x00000003,0x00050057,0x00000009,0x000000b2,0x000000ae,0x000000b1,
|
|
||||||
0x0008004f,0x00000044,0x000000b3,0x000000b2,0x000000b2,0x00000000,0x00000001,0x00000002,
|
|
||||||
0x0004003d,0x00000044,0x000000b4,0x00000046,0x00050094,0x00000006,0x000000b5,0x000000b3,
|
|
||||||
0x000000b4,0x0003003e,0x000000ad,0x000000b5,0x0004003d,0x00000006,0x000000b6,0x00000053,
|
|
||||||
0x0004003d,0x00000006,0x000000b7,0x0000005c,0x00050050,0x00000007,0x000000b8,0x000000b6,
|
|
||||||
0x000000b7,0x0004003d,0x00000006,0x000000b9,0x000000a4,0x0004003d,0x00000006,0x000000ba,
|
|
||||||
0x000000ad,0x00050050,0x00000007,0x000000bb,0x000000b9,0x000000ba,0x00050083,0x00000007,
|
|
||||||
0x000000bc,0x000000b8,0x000000bb,0x0006000c,0x00000007,0x000000bd,0x00000001,0x00000004,
|
|
||||||
0x000000bc,0x00050041,0x0000004b,0x000000be,0x00000065,0x00000099,0x00050051,0x00000006,
|
|
||||||
0x000000bf,0x000000bd,0x00000000,0x0003003e,0x000000be,0x000000bf,0x00050041,0x0000004b,
|
|
||||||
0x000000c0,0x00000065,0x0000000b,0x00050051,0x00000006,0x000000c1,0x000000bd,0x00000001,
|
|
||||||
0x0003003e,0x000000c0,0x000000c1,0x0004003d,0x00000007,0x000000c2,0x0000009e,0x0004003d,
|
|
||||||
0x00000009,0x000000c3,0x00000065,0x0007004f,0x00000007,0x000000c4,0x000000c3,0x000000c3,
|
|
||||||
0x00000002,0x00000003,0x0007000c,0x00000007,0x000000c5,0x00000001,0x00000028,0x000000c2,
|
|
||||||
0x000000c4,0x0003003e,0x0000009e,0x000000c5,0x00050041,0x0000004b,0x000000c7,0x0000009e,
|
|
||||||
0x0000006d,0x0004003d,0x00000006,0x000000c8,0x000000c7,0x00050041,0x0000004b,0x000000c9,
|
|
||||||
0x0000009e,0x00000070,0x0004003d,0x00000006,0x000000ca,0x000000c9,0x0007000c,0x00000006,
|
|
||||||
0x000000cb,0x00000001,0x00000028,0x000000c8,0x000000ca,0x0003003e,0x000000c6,0x000000cb,
|
|
||||||
0x0004003d,0x00000006,0x000000cc,0x000000c6,0x0004003d,0x00000009,0x000000ce,0x00000065,
|
|
||||||
0x0007004f,0x00000007,0x000000cf,0x000000ce,0x000000ce,0x00000000,0x00000001,0x0005008e,
|
|
||||||
0x00000007,0x000000d0,0x000000cf,0x000000cd,0x00050050,0x00000007,0x000000d1,0x000000cc,
|
|
||||||
0x000000cc,0x0007000c,0x00000007,0x000000d2,0x00000001,0x00000030,0x000000d1,0x000000d0,
|
|
||||||
0x0004003d,0x00000007,0x000000d3,0x00000073,0x00050085,0x00000007,0x000000d4,0x000000d3,
|
|
||||||
0x000000d2,0x0003003e,0x00000073,0x000000d4,0x0004003d,0x00000007,0x000000d5,0x00000073,
|
|
||||||
0x000200fe,0x000000d5,0x00010038
|
|
||||||
};
|
};
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,25 +1,153 @@
|
|||||||
#version 450
|
#version 450
|
||||||
#extension GL_GOOGLE_include_directive : require
|
|
||||||
|
|
||||||
layout(location = 0) in vec2 fragTexCoord;
|
layout(location = 0) in vec2 fragTexCoord;
|
||||||
layout(location = 0) out vec4 outColor;
|
layout(location = 0) out vec4 outColor;
|
||||||
layout(set = 0, binding = 0) uniform sampler2D EdgeTexture;
|
layout(set = 0, binding = 0) uniform sampler2D EdgeTexture;
|
||||||
layout(set = 1, binding = 0) uniform sampler2D AreaTexture;
|
|
||||||
layout(set = 2, binding = 0) uniform sampler2D SearchTexture;
|
|
||||||
layout(push_constant) uniform Constants {
|
layout(push_constant) uniform Constants {
|
||||||
vec4 ndc;
|
vec4 ndc;
|
||||||
vec4 metrics; // 1/width, 1/height, width, height
|
vec2 resolution;
|
||||||
|
float extra;
|
||||||
|
float pad;
|
||||||
} pc;
|
} pc;
|
||||||
|
|
||||||
#define SMAA_RT_METRICS pc.metrics
|
vec4 edgeAt(vec2 uv, vec2 px) {
|
||||||
#define SMAA_GLSL_4
|
vec2 edgeUV = clamp(uv, px * 0.5, vec2(1.0) - px * 0.5);
|
||||||
#define SMAA_PRESET_HIGH
|
vec4 e = textureLod(EdgeTexture, edgeUV, 0.0);
|
||||||
#include "SMAA.hlsl"
|
e.a = edgeUV.y >= 1.0 - px.y ? 0.0 : e.a;
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
float verticalEdge(vec2 uv, vec2 px) {
|
||||||
|
vec4 e = edgeAt(uv, px);
|
||||||
|
return max(e.r, e.g);
|
||||||
|
}
|
||||||
|
|
||||||
|
float horizontalEdge(vec2 uv, vec2 px) {
|
||||||
|
vec4 e = edgeAt(uv, px);
|
||||||
|
return max(e.b, e.a);
|
||||||
|
}
|
||||||
|
|
||||||
|
float measureRun(vec2 origin, vec2 texel, vec2 tangent,
|
||||||
|
bool verticalLine, float limit, bool positive) {
|
||||||
|
float run = 0.0;
|
||||||
|
for (int i = 1; i <= 6; ++i) {
|
||||||
|
vec2 probe = origin + tangent * float(i) * (positive ? 1.0 : -1.0);
|
||||||
|
ivec2 index = ivec2(floor(probe * pc.resolution));
|
||||||
|
ivec2 size = ivec2(pc.resolution);
|
||||||
|
if (any(lessThan(index, ivec2(0))) ||
|
||||||
|
any(greaterThanEqual(index, size))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
float edge = verticalLine
|
||||||
|
? verticalEdge(probe, texel)
|
||||||
|
: horizontalEdge(probe, texel);
|
||||||
|
if (edge <= limit * 0.65) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
run = float(i);
|
||||||
|
}
|
||||||
|
return run;
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 pixcoord;
|
vec2 px = 1.0 / max(pc.resolution, vec2(1.0));
|
||||||
vec4 offset[3];
|
vec2 uv = clamp(fragTexCoord, px * 0.5, vec2(1.0) - px * 0.5);
|
||||||
SMAABlendingWeightCalculationVS(fragTexCoord, pixcoord, offset);
|
vec4 e = edgeAt(uv, px);
|
||||||
outColor = SMAABlendingWeightCalculationPS(fragTexCoord, pixcoord, offset, EdgeTexture,
|
|
||||||
AreaTexture, SearchTexture, vec4(0.0));
|
float dL = e.r;
|
||||||
|
float dR = e.g;
|
||||||
|
float dU = e.b;
|
||||||
|
float dD = e.a;
|
||||||
|
float vertical = max(dL, dR);
|
||||||
|
float horizontal = max(dU, dD);
|
||||||
|
float strongest = max(vertical, horizontal);
|
||||||
|
float threshold = max(0.045, strongest * 0.12);
|
||||||
|
|
||||||
|
if (strongest <= threshold) {
|
||||||
|
outColor = vec4(0.0, 0.5, 0.5, 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool verticalLine;
|
||||||
|
float negativeRun = 0.0;
|
||||||
|
float positiveRun = 0.0;
|
||||||
|
bool runsMeasured = false;
|
||||||
|
|
||||||
|
if (vertical > horizontal) {
|
||||||
|
verticalLine = true;
|
||||||
|
} else if (horizontal > vertical) {
|
||||||
|
verticalLine = false;
|
||||||
|
} else {
|
||||||
|
float vNeg = measureRun(uv, px, vec2(0.0, px.y), true, threshold, false);
|
||||||
|
float vPos = measureRun(uv, px, vec2(0.0, px.y), true, threshold, true);
|
||||||
|
float hNeg = measureRun(uv, px, vec2(px.x, 0.0), false, threshold, false);
|
||||||
|
float hPos = measureRun(uv, px, vec2(px.x, 0.0), false, threshold, true);
|
||||||
|
verticalLine = (vNeg + vPos) >= (hNeg + hPos);
|
||||||
|
negativeRun = verticalLine ? vNeg : hNeg;
|
||||||
|
positiveRun = verticalLine ? vPos : hPos;
|
||||||
|
runsMeasured = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 tangent = verticalLine ? vec2(0.0, px.y) : vec2(px.x, 0.0);
|
||||||
|
vec2 normal = verticalLine
|
||||||
|
? vec2(dL >= dR ? -1.0 : 1.0, 0.0)
|
||||||
|
: vec2(0.0, dU >= dD ? -1.0 : 1.0);
|
||||||
|
|
||||||
|
if (!runsMeasured) {
|
||||||
|
negativeRun = measureRun(uv, px, tangent, verticalLine, threshold, false);
|
||||||
|
positiveRun = measureRun(uv, px, tangent, verticalLine, threshold, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
float span = negativeRun + positiveRun;
|
||||||
|
float edgeConfidence = smoothstep(threshold, threshold * 2.5, strongest);
|
||||||
|
|
||||||
|
vec4 nw = edgeAt(uv + vec2(-px.x, -px.y), px);
|
||||||
|
vec4 ne = edgeAt(uv + vec2(px.x, -px.y), px);
|
||||||
|
vec4 sw = edgeAt(uv + vec2(-px.x, px.y), px);
|
||||||
|
vec4 se = edgeAt(uv + vec2(px.x, px.y), px);
|
||||||
|
|
||||||
|
float runEndpointPattern = clamp(
|
||||||
|
abs(negativeRun - positiveRun) / max(span, 1.0), 0.0, 1.0);
|
||||||
|
float crossingA = verticalLine
|
||||||
|
? abs(nw.a - ne.a)
|
||||||
|
: abs(nw.g - sw.g);
|
||||||
|
float crossingB = verticalLine
|
||||||
|
? abs(sw.b - se.b)
|
||||||
|
: abs(ne.r - se.r);
|
||||||
|
float crossingContrast = abs(crossingA - crossingB);
|
||||||
|
float crossingPattern = smoothstep(threshold, threshold * 2.5, crossingContrast);
|
||||||
|
vec4 edgeMin = min(min(nw, ne), min(sw, se));
|
||||||
|
vec4 edgeMax = max(max(nw, ne), max(sw, se));
|
||||||
|
float edgeVariation = max(
|
||||||
|
max(edgeMax.r - edgeMin.r, edgeMax.g - edgeMin.g),
|
||||||
|
max(edgeMax.b - edgeMin.b, edgeMax.a - edgeMin.a));
|
||||||
|
float balancedCrossing = edgeVariation > 0.01
|
||||||
|
? smoothstep(threshold, threshold * 2.5, min(crossingA, crossingB))
|
||||||
|
: 0.0;
|
||||||
|
float endpointPattern = runEndpointPattern > 0.01
|
||||||
|
? max(runEndpointPattern, balancedCrossing)
|
||||||
|
: runEndpointPattern;
|
||||||
|
float endpointArea = endpointPattern / (1.0 + span * 0.055);
|
||||||
|
float areaWeight = 0.38 * crossingPattern * clamp(span / 4.0, 0.0, 1.0);
|
||||||
|
float diagonalContrast = max(
|
||||||
|
max(max(abs(nw.r - se.r), abs(nw.g - se.g)),
|
||||||
|
max(abs(nw.b - se.b), abs(nw.a - se.a))),
|
||||||
|
max(max(abs(ne.r - sw.r), abs(ne.g - sw.g)),
|
||||||
|
max(abs(ne.b - sw.b), abs(ne.a - sw.a))));
|
||||||
|
float cornerFactor = 1.0 - 0.35 * smoothstep(threshold, threshold * 3.0, diagonalContrast);
|
||||||
|
float baseWeight = areaWeight * endpointArea * edgeConfidence * cornerFactor;
|
||||||
|
|
||||||
|
float diagonalStrength = min(vertical, horizontal);
|
||||||
|
float diagonalPattern = smoothstep(threshold, threshold * 2.5, diagonalStrength);
|
||||||
|
float diagonalContinuity = smoothstep(1.0, 3.0, span);
|
||||||
|
float shortDiagonalFallback =
|
||||||
|
(span > 0.0 && span <= 1.0 && crossingContrast <= threshold && diagonalStrength > threshold)
|
||||||
|
? 1.0 : 0.0;
|
||||||
|
float diagonalFallback = 0.16 * diagonalPattern * edgeConfidence
|
||||||
|
* cornerFactor * max(
|
||||||
|
diagonalContinuity * max(crossingPattern, balancedCrossing),
|
||||||
|
shortDiagonalFallback);
|
||||||
|
|
||||||
|
float weight = clamp(max(baseWeight, diagonalFallback), 0.0, 0.42);
|
||||||
|
outColor = vec4(weight, normal.x * 0.5 + 0.5, normal.y * 0.5 + 0.5, 1.0);
|
||||||
}
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1 +0,0 @@
|
|||||||
ZeroFG is fetched by CMake from hy300leosquizz-ctrl/ZeroFG (the upstream repository) at pinned commit e6ca7ef9f9765db89847b6d8eed352e458f1a8bb. DroidDeck keeps ownership of presentation; the independent presenter is not used. License: Apache-2.0 OR GPL-2.0-or-later; see the fetched ZeroFG source tree for the license text.
|
|
||||||
@@ -42,11 +42,6 @@ add_library(droiddeckwayland SHARED
|
|||||||
src/hudframes.c
|
src/hudframes.c
|
||||||
src/hudframes_jni.c
|
src/hudframes_jni.c
|
||||||
)
|
)
|
||||||
option(DROIDDECK_FRAME_ACQUIRE_PROBE "Build opt-in signaled producer acquire protocol support" ON)
|
|
||||||
if (DROIDDECK_FRAME_ACQUIRE_PROBE)
|
|
||||||
target_sources(droiddeckwayland PRIVATE generated/droiddeck-frame-acquire-v1-protocol.c)
|
|
||||||
target_compile_definitions(droiddeckwayland PRIVATE DROIDDECK_FRAME_ACQUIRE_PROBE=1)
|
|
||||||
endif()
|
|
||||||
target_compile_options(droiddeckwayland PRIVATE
|
target_compile_options(droiddeckwayland PRIVATE
|
||||||
$<$<COMPILE_LANGUAGE:C>:-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers>)
|
$<$<COMPILE_LANGUAGE:C>:-Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers>)
|
||||||
target_include_directories(droiddeckwayland PRIVATE
|
target_include_directories(droiddeckwayland PRIVATE
|
||||||
@@ -64,7 +59,6 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
|||||||
message(STATUS "droiddeckwayland: frame-generation engines built in (LSFG Native, DD-FG Native)")
|
message(STATUS "droiddeckwayland: frame-generation engines built in (LSFG Native, DD-FG Native)")
|
||||||
target_sources(droiddeckwayland PRIVATE
|
target_sources(droiddeckwayland PRIVATE
|
||||||
src/framegen_engine.cpp
|
src/framegen_engine.cpp
|
||||||
src/framegen_zerofg.cpp
|
|
||||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_probe.cpp
|
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_probe.cpp
|
||||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dll.cpp
|
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dll.cpp
|
||||||
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dxbc.cpp
|
${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_dxbc.cpp
|
||||||
@@ -91,12 +85,12 @@ if (TARGET dxbc AND EXISTS ${DROIDDECK_FRAMEGEN_LSFG_DIR}/lsfg_engine.cpp
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/../framegen
|
${CMAKE_CURRENT_SOURCE_DIR}/../framegen
|
||||||
)
|
)
|
||||||
target_compile_options(droiddeckwayland PRIVATE
|
target_compile_options(droiddeckwayland PRIVATE
|
||||||
$<$<COMPILE_LANGUAGE:CXX>:-std=c++20 -fvisibility=hidden>)
|
$<$<COMPILE_LANGUAGE:CXX>:-std=c++17 -fvisibility=hidden>)
|
||||||
target_compile_definitions(droiddeckwayland PRIVATE
|
target_compile_definitions(droiddeckwayland PRIVATE
|
||||||
DDFG_UPSTREAM="${DDFG_UPSTREAM}"
|
DDFG_UPSTREAM="${DDFG_UPSTREAM}"
|
||||||
DDFG_CHAIN_HASH="${DDFG_CHAIN_HASH}"
|
DDFG_CHAIN_HASH="${DDFG_CHAIN_HASH}"
|
||||||
)
|
)
|
||||||
target_link_libraries(droiddeckwayland dxbc atomic zerofg::zerofg)
|
target_link_libraries(droiddeckwayland dxbc atomic)
|
||||||
else()
|
else()
|
||||||
message(STATUS "droiddeckwayland: frame-generation engines NOT built in (standalone build): stub")
|
message(STATUS "droiddeckwayland: frame-generation engines NOT built in (standalone build): stub")
|
||||||
target_sources(droiddeckwayland PRIVATE src/framegen_engine_stub.c)
|
target_sources(droiddeckwayland PRIVATE src/framegen_engine_stub.c)
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
/* Generated by wayland-scanner 1.22.0 */
|
|
||||||
|
|
||||||
#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 wl_buffer_interface;
|
|
||||||
extern const struct wl_interface wl_surface_interface;
|
|
||||||
|
|
||||||
static const struct wl_interface *droiddeck_frame_acquire_v1_types[] = {
|
|
||||||
&wl_surface_interface,
|
|
||||||
&wl_buffer_interface,
|
|
||||||
NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct wl_message droiddeck_frame_acquire_v1_requests[] = {
|
|
||||||
{ "destroy", "", droiddeck_frame_acquire_v1_types + 0 },
|
|
||||||
{ "set_acquire_fence", "ooh", droiddeck_frame_acquire_v1_types + 0 },
|
|
||||||
};
|
|
||||||
|
|
||||||
WL_PRIVATE const struct wl_interface droiddeck_frame_acquire_v1_interface = {
|
|
||||||
"droiddeck_frame_acquire_v1", 1,
|
|
||||||
2, droiddeck_frame_acquire_v1_requests,
|
|
||||||
0, NULL,
|
|
||||||
};
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
/* Generated by wayland-scanner 1.22.0 */
|
|
||||||
|
|
||||||
#ifndef DROIDDECK_FRAME_ACQUIRE_V1_SERVER_PROTOCOL_H
|
|
||||||
#define DROIDDECK_FRAME_ACQUIRE_V1_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_droiddeck_frame_acquire_v1 The droiddeck_frame_acquire_v1 protocol
|
|
||||||
* @section page_ifaces_droiddeck_frame_acquire_v1 Interfaces
|
|
||||||
* - @subpage page_iface_droiddeck_frame_acquire_v1 - DroidDeck producer write completion for a single Wayland attachment
|
|
||||||
*/
|
|
||||||
struct droiddeck_frame_acquire_v1;
|
|
||||||
struct wl_buffer;
|
|
||||||
struct wl_surface;
|
|
||||||
|
|
||||||
#ifndef DROIDDECK_FRAME_ACQUIRE_V1_INTERFACE
|
|
||||||
#define DROIDDECK_FRAME_ACQUIRE_V1_INTERFACE
|
|
||||||
/**
|
|
||||||
* @page page_iface_droiddeck_frame_acquire_v1 droiddeck_frame_acquire_v1
|
|
||||||
* @section page_iface_droiddeck_frame_acquire_v1_desc Description
|
|
||||||
*
|
|
||||||
* Optional explicit acquire sideband independent of DRM syncobj and buffer
|
|
||||||
* allocation. Binding does not opt the client out of ordinary wl_buffer
|
|
||||||
* release or existing synchronization protocols. The server advertises it
|
|
||||||
* only when it implements all semantics for the selected display path.
|
|
||||||
* @section page_iface_droiddeck_frame_acquire_v1_api API
|
|
||||||
* See @ref iface_droiddeck_frame_acquire_v1.
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @defgroup iface_droiddeck_frame_acquire_v1 The droiddeck_frame_acquire_v1 interface
|
|
||||||
*
|
|
||||||
* Optional explicit acquire sideband independent of DRM syncobj and buffer
|
|
||||||
* allocation. Binding does not opt the client out of ordinary wl_buffer
|
|
||||||
* release or existing synchronization protocols. The server advertises it
|
|
||||||
* only when it implements all semantics for the selected display path.
|
|
||||||
*/
|
|
||||||
extern const struct wl_interface droiddeck_frame_acquire_v1_interface;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM
|
|
||||||
#define DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM
|
|
||||||
enum droiddeck_frame_acquire_v1_error {
|
|
||||||
/**
|
|
||||||
* not the same client's pending DMA-BUF attachment
|
|
||||||
*/
|
|
||||||
DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_ATTACHMENT = 0,
|
|
||||||
/**
|
|
||||||
* that attachment already has an acquire fence
|
|
||||||
*/
|
|
||||||
DROIDDECK_FRAME_ACQUIRE_V1_ERROR_DUPLICATE_FENCE = 1,
|
|
||||||
/**
|
|
||||||
* not a real successfully signaled Linux sync_file
|
|
||||||
*/
|
|
||||||
DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_FENCE = 2,
|
|
||||||
/**
|
|
||||||
* not the paired test peer
|
|
||||||
*/
|
|
||||||
DROIDDECK_FRAME_ACQUIRE_V1_ERROR_UNAUTHORIZED_PEER = 3,
|
|
||||||
};
|
|
||||||
#endif /* DROIDDECK_FRAME_ACQUIRE_V1_ERROR_ENUM */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup iface_droiddeck_frame_acquire_v1
|
|
||||||
* @struct droiddeck_frame_acquire_v1_interface
|
|
||||||
*/
|
|
||||||
struct droiddeck_frame_acquire_v1_interface {
|
|
||||||
/**
|
|
||||||
*/
|
|
||||||
void (*destroy)(struct wl_client *client,
|
|
||||||
struct wl_resource *resource);
|
|
||||||
/**
|
|
||||||
* set a one-shot kernel sync_file for the pending attachment
|
|
||||||
*
|
|
||||||
* After wl_surface.attach of a non-null buffer, and before its
|
|
||||||
* next wl_surface.commit, send the producer's final writer fence
|
|
||||||
* for that exact attachment. This outer probe requires that fence
|
|
||||||
* to have already successfully signaled. The fence must be a real
|
|
||||||
* Linux sync_file, not a dma-buf, eventfd, or Vulkan OPAQUE_FD.
|
|
||||||
* The server consumes its received descriptor once for that
|
|
||||||
* attachment; the caller closes its local FD after marshalling.
|
|
||||||
*
|
|
||||||
* The receiver validates the matching pending surface and buffer
|
|
||||||
* and validates the descriptor. A duplicate, invalid, pending or
|
|
||||||
* mismatched request is a protocol error; it is never downgraded
|
|
||||||
* to implicit sync. Another attach (even the same wl_buffer),
|
|
||||||
* detach, surface/resource loss or supersession makes the old
|
|
||||||
* proof inapplicable. Metadata-only commits may amend
|
|
||||||
* receiver-side still-pending state but cannot introduce or re-use
|
|
||||||
* a fence themselves. If no request was made, the receiver keeps
|
|
||||||
* its established safe path. If a valid fence has been accepted
|
|
||||||
* and later the layer is ineligible, the buffer must not be
|
|
||||||
* copied/read before that fence is satisfied or imported as the
|
|
||||||
* source dependency. Transport never implies readiness on missed
|
|
||||||
* deadlines and never changes release/retirement requirements.
|
|
||||||
* @param fence producer's native acquire sync_file
|
|
||||||
*/
|
|
||||||
void (*set_acquire_fence)(struct wl_client *client,
|
|
||||||
struct wl_resource *resource,
|
|
||||||
struct wl_resource *surface,
|
|
||||||
struct wl_resource *buffer,
|
|
||||||
int32_t fence);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ingroup iface_droiddeck_frame_acquire_v1
|
|
||||||
*/
|
|
||||||
#define DROIDDECK_FRAME_ACQUIRE_V1_DESTROY_SINCE_VERSION 1
|
|
||||||
/**
|
|
||||||
* @ingroup iface_droiddeck_frame_acquire_v1
|
|
||||||
*/
|
|
||||||
#define DROIDDECK_FRAME_ACQUIRE_V1_SET_ACQUIRE_FENCE_SINCE_VERSION 1
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<protocol name="droiddeck_frame_acquire_v1">
|
|
||||||
<interface name="droiddeck_frame_acquire_v1" version="1">
|
|
||||||
<description summary="DroidDeck producer write completion for a single Wayland attachment">
|
|
||||||
Optional explicit acquire sideband independent of DRM syncobj and buffer
|
|
||||||
allocation. Binding does not opt the client out of ordinary wl_buffer
|
|
||||||
release or existing synchronization protocols. The server advertises it
|
|
||||||
only when it implements all semantics for the selected display path and
|
|
||||||
only to the test fixture's app-authorized Gamescope worker.
|
|
||||||
</description>
|
|
||||||
<request name="destroy" type="destructor"/>
|
|
||||||
<enum name="error">
|
|
||||||
<entry name="invalid_attachment" value="0" summary="not the same client's pending DMA-BUF attachment"/>
|
|
||||||
<entry name="duplicate_fence" value="1" summary="that attachment already has an acquire fence"/>
|
|
||||||
<entry name="invalid_fence" value="2" summary="not a real successfully signaled Linux sync_file"/>
|
|
||||||
<entry name="unauthorized_peer" value="3" summary="not the paired test peer"/>
|
|
||||||
</enum>
|
|
||||||
<request name="set_acquire_fence">
|
|
||||||
<description summary="set a one-shot kernel sync_file for the pending attachment">
|
|
||||||
After wl_surface.attach of a non-null buffer, and before its next
|
|
||||||
wl_surface.commit, send the producer's final writer fence for that
|
|
||||||
exact attachment. This outer probe requires that fence to have already
|
|
||||||
successfully signaled. The fence must be a real Linux sync_file, not a
|
|
||||||
dma-buf, eventfd, or Vulkan OPAQUE_FD. The server consumes its received
|
|
||||||
descriptor once for that attachment; the caller closes its local FD
|
|
||||||
after marshalling.
|
|
||||||
|
|
||||||
The receiver validates the matching pending surface and buffer and
|
|
||||||
validates the descriptor. A duplicate, invalid, pending or mismatched
|
|
||||||
request is a protocol error; it is never downgraded to implicit sync. Another attach (even the same
|
|
||||||
wl_buffer), detach, surface/resource loss or supersession makes the
|
|
||||||
old proof inapplicable. Metadata-only commits may amend receiver-side
|
|
||||||
still-pending state but cannot introduce or re-use a fence themselves.
|
|
||||||
If no request was made, the receiver keeps its established safe path.
|
|
||||||
If a valid fence has been accepted and later the layer is ineligible,
|
|
||||||
the buffer must not be copied/read before that fence is satisfied or
|
|
||||||
imported as the source dependency. Transport never implies readiness
|
|
||||||
on missed deadlines and never changes release/retirement requirements.
|
|
||||||
</description>
|
|
||||||
<arg name="surface" type="object" interface="wl_surface"/>
|
|
||||||
<arg name="buffer" type="object" interface="wl_buffer"/>
|
|
||||||
<arg name="fence" type="fd" summary="producer's native acquire sync_file"/>
|
|
||||||
</request>
|
|
||||||
</interface>
|
|
||||||
</protocol>
|
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "droiddeck-ahb-v1-server-protocol.h"
|
#include "droiddeck-ahb-v1-server-protocol.h"
|
||||||
#include <android/hardware_buffer.h>
|
#include <android/hardware_buffer.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <linux/sync_file.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
@@ -54,7 +53,6 @@ static struct wl_list g_clients;
|
|||||||
static uint64_t g_next_id = 1;
|
static uint64_t g_next_id = 1;
|
||||||
static struct wl_event_loop *g_loop;
|
static struct wl_event_loop *g_loop;
|
||||||
static unsigned g_stat_zero_copy;
|
static unsigned g_stat_zero_copy;
|
||||||
static unsigned g_stat_producer_fence;
|
|
||||||
static int g_export_failed_logged, g_import_failed_logged;
|
static int g_export_failed_logged, g_import_failed_logged;
|
||||||
static int g_advertised;
|
static int g_advertised;
|
||||||
static int g_mode_sent = -1;
|
static int g_mode_sent = -1;
|
||||||
@@ -147,12 +145,6 @@ static void handle_released(uint64_t id, int fd) {
|
|||||||
if (poll(&p, 1, 0) > 0) {
|
if (poll(&p, 1, 0) > 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
} else {
|
} else {
|
||||||
if (ab->fence_src) {
|
|
||||||
struct sync_merge_data m = {.name = "droiddeck-release", .fd2 = fd};
|
|
||||||
if (ioctl(ab->fence_fd, SYNC_IOC_MERGE, &m) == 0) { close(fd); fd = m.fence; }
|
|
||||||
wl_event_source_remove(ab->fence_src);
|
|
||||||
close(ab->fence_fd);
|
|
||||||
}
|
|
||||||
ab->fence_fd = fd;
|
ab->fence_fd = fd;
|
||||||
ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab);
|
ab->fence_src = wl_event_loop_add_fd(g_loop, fd, WL_EVENT_READABLE, on_fence_readable, ab);
|
||||||
if (!ab->fence_src) { close(fd); ab->fence_fd = -1; }
|
if (!ab->fence_src) { close(fd); ab->fence_fd = -1; }
|
||||||
@@ -160,7 +152,6 @@ static void handle_released(uint64_t id, int fd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ab->fence_src) return;
|
|
||||||
send_deferred_release(ab);
|
send_deferred_release(ab);
|
||||||
maybe_free(ab);
|
maybe_free(ab);
|
||||||
}
|
}
|
||||||
@@ -202,47 +193,27 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
|
|||||||
struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot(b) : NULL;
|
struct ahb_buf *ab = b ? *droiddeck_dmabuf_ahb_slot(b) : NULL;
|
||||||
if (!ab) return -1;
|
if (!ab) return -1;
|
||||||
int dmabuf_fd = droiddeck_dmabuf_fd(b);
|
int dmabuf_fd = droiddeck_dmabuf_fd(b);
|
||||||
int acquire = droiddeck_surface_dup_acquire(s, b);
|
int acquire = -1;
|
||||||
if (acquire == -2) return -1;
|
struct droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1};
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) {
|
||||||
const int explicit_acquire = acquire >= 0;
|
acquire = exp.fd;
|
||||||
#endif
|
} else if (dmabuf_fd >= 0) {
|
||||||
if (acquire < 0) {
|
if (!g_export_failed_logged) {
|
||||||
struct droiddeck_dma_buf_sync_file exp = {.flags = DROIDDECK_DMA_BUF_SYNC_READ, .fd = -1};
|
g_export_failed_logged = 1;
|
||||||
if (dmabuf_fd >= 0 && ioctl(dmabuf_fd, DROIDDECK_DMA_BUF_IOCTL_EXPORT_SYNC_FILE, &exp) == 0 && exp.fd >= 0) {
|
droiddeck_log("layer", "zero-copy: DMA_BUF_IOCTL_EXPORT_SYNC_FILE failed (%s): waiting for each frame on the CPU instead",
|
||||||
acquire = exp.fd;
|
strerror(errno));
|
||||||
} else {
|
|
||||||
if (!g_export_failed_logged) {
|
|
||||||
g_export_failed_logged = 1;
|
|
||||||
droiddeck_log("layer", "zero-copy: no acquire fence from the game's dma-buf (%s): %s",
|
|
||||||
dmabuf_fd >= 0 ? strerror(errno) : "no dma-buf fd",
|
|
||||||
draw ? "its frames are copied instead" : "it cannot be copied, so each frame is waited for on the CPU");
|
|
||||||
}
|
|
||||||
if (dmabuf_fd >= 0) {
|
|
||||||
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN};
|
|
||||||
int r;
|
|
||||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
|
||||||
}
|
|
||||||
if (draw) return -1;
|
|
||||||
}
|
}
|
||||||
|
struct pollfd p = {.fd = dmabuf_fd, .events = POLLIN};
|
||||||
|
int r;
|
||||||
|
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
||||||
}
|
}
|
||||||
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h, draw,
|
int r = sc_layer_present_ahb(ab->ahb, ab->w, ab->h, acquire, (void *)(uintptr_t)ab->id, scene_w, scene_h, draw,
|
||||||
s ? droiddeck_surface_color(s) : NULL, ab->format);
|
s ? droiddeck_surface_color(s) : NULL, ab->format);
|
||||||
if (r < 0) return -1;
|
if (r < 0) return -1;
|
||||||
if (r == 1) return 0;
|
if (r == 1) return 0;
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
static int explicit_logged;
|
|
||||||
if (explicit_acquire && !explicit_logged) {
|
|
||||||
explicit_logged = 1;
|
|
||||||
droiddeck_log("layer", "probe: SurfaceControl accepted a verified producer acquire fence");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (!ab->on_layer) {
|
if (!ab->on_layer) {
|
||||||
ab->on_layer = 1;
|
ab->on_layer = 1;
|
||||||
g_stat_zero_copy++;
|
g_stat_zero_copy++;
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
if (explicit_acquire) g_stat_producer_fence++;
|
|
||||||
#endif
|
|
||||||
g_last_zero_copy_ns = now_ns();
|
g_last_zero_copy_ns = now_ns();
|
||||||
}
|
}
|
||||||
if (s && g_announced != s) {
|
if (s && g_announced != s) {
|
||||||
@@ -282,12 +253,6 @@ unsigned ahb_swapchain_stats_take(void) {
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned ahb_swapchain_producer_fence_stats_take(void) {
|
|
||||||
unsigned n = g_stat_producer_fence;
|
|
||||||
g_stat_producer_fence = 0;
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ahb_swapchain_advertised(void) { return g_advertised; }
|
int ahb_swapchain_advertised(void) { return g_advertised; }
|
||||||
|
|
||||||
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) {
|
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b) {
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ int ahb_swapchain_present(struct dmabuf_buffer *b, struct surface *s, int scene_
|
|||||||
int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced);
|
int ahb_swapchain_defer_release(struct dmabuf_buffer *b, struct wl_resource *buffer, struct surface *s, int paced);
|
||||||
void ahb_swapchain_surface_gone(struct surface *s);
|
void ahb_swapchain_surface_gone(struct surface *s);
|
||||||
unsigned ahb_swapchain_stats_take(void);
|
unsigned ahb_swapchain_stats_take(void);
|
||||||
unsigned ahb_swapchain_producer_fence_stats_take(void);
|
|
||||||
int ahb_swapchain_advertised(void);
|
int ahb_swapchain_advertised(void);
|
||||||
int droiddeck_surface_dup_acquire(const struct surface *s, const struct dmabuf_buffer *b);
|
|
||||||
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b);
|
uint32_t ahb_swapchain_ahb_format(const struct dmabuf_buffer *b);
|
||||||
|
|
||||||
void ahb_swapchain_layer_released(void *token, int release_fd);
|
void ahb_swapchain_layer_released(void *token, int release_fd);
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/timerfd.h>
|
#include <sys/timerfd.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <sys/sysmacros.h>
|
#include <sys/sysmacros.h>
|
||||||
@@ -24,14 +23,6 @@
|
|||||||
#include "linux-dmabuf-v1-server-protocol.h"
|
#include "linux-dmabuf-v1-server-protocol.h"
|
||||||
#include "sc_layer.h"
|
#include "sc_layer.h"
|
||||||
#include "ahb_swapchain.h"
|
#include "ahb_swapchain.h"
|
||||||
#include "frame_acquire.h"
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
#include "droiddeck-frame-acquire-v1-server-protocol.h"
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#include <sys/sysmacros.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include "frame_worker_peer.h"
|
|
||||||
#endif
|
|
||||||
#include "display_buffers.h"
|
#include "display_buffers.h"
|
||||||
#include "viewporter-server-protocol.h"
|
#include "viewporter-server-protocol.h"
|
||||||
#include "droiddeck-desktop-v1-server-protocol.h"
|
#include "droiddeck-desktop-v1-server-protocol.h"
|
||||||
@@ -219,7 +210,6 @@ struct surface {
|
|||||||
struct wl_list link;
|
struct wl_list link;
|
||||||
|
|
||||||
struct wl_resource *pending_buffer;
|
struct wl_resource *pending_buffer;
|
||||||
struct dd_frame_acquire pending_frame_acquire, frame_acquire;
|
|
||||||
struct wl_listener pending_buffer_destroy;
|
struct wl_listener pending_buffer_destroy;
|
||||||
int pending_attach;
|
int pending_attach;
|
||||||
int pending_src_set, pending_dst_set;
|
int pending_src_set, pending_dst_set;
|
||||||
@@ -343,7 +333,6 @@ volatile int g_hide_shell;
|
|||||||
|
|
||||||
volatile int g_zero_copy;
|
volatile int g_zero_copy;
|
||||||
static int g_zero_copy_paused;
|
static int g_zero_copy_paused;
|
||||||
static int g_mirror_capture;
|
|
||||||
extern volatile int g_display_buffer_driver;
|
extern volatile int g_display_buffer_driver;
|
||||||
extern void droiddeck_on_overlay_planes(int planes);
|
extern void droiddeck_on_overlay_planes(int planes);
|
||||||
static int g_overlay_planes_told = -1;
|
static int g_overlay_planes_told = -1;
|
||||||
@@ -837,7 +826,6 @@ static void unmap_toplevel(struct surface *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void drop_dmabuf(struct surface *s, int paced) {
|
static void drop_dmabuf(struct surface *s, int paced) {
|
||||||
dd_frame_acquire_clear(&s->frame_acquire);
|
|
||||||
if (s->dmabuf) {
|
if (s->dmabuf) {
|
||||||
wl_list_remove(&s->dmabuf_destroy.link);
|
wl_list_remove(&s->dmabuf_destroy.link);
|
||||||
if (buffer_shown_elsewhere(s->dmabuf, s)) {
|
if (buffer_shown_elsewhere(s->dmabuf, s)) {
|
||||||
@@ -853,21 +841,18 @@ static void drop_dmabuf(struct surface *s, int paced) {
|
|||||||
|
|
||||||
static void on_dmabuf_destroyed(struct wl_listener *l, void *data) {
|
static void on_dmabuf_destroyed(struct wl_listener *l, void *data) {
|
||||||
struct surface *s = wl_container_of(l, s, dmabuf_destroy);
|
struct surface *s = wl_container_of(l, s, dmabuf_destroy);
|
||||||
dd_frame_acquire_clear(&s->frame_acquire);
|
|
||||||
wl_list_remove(&s->dmabuf_destroy.link);
|
wl_list_remove(&s->dmabuf_destroy.link);
|
||||||
s->dmabuf = NULL;
|
s->dmabuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) {
|
static void on_pending_buffer_destroyed(struct wl_listener *l, void *data) {
|
||||||
struct surface *s = wl_container_of(l, s, pending_buffer_destroy);
|
struct surface *s = wl_container_of(l, s, pending_buffer_destroy);
|
||||||
dd_frame_acquire_clear(&s->pending_frame_acquire);
|
|
||||||
wl_list_remove(&s->pending_buffer_destroy.link);
|
wl_list_remove(&s->pending_buffer_destroy.link);
|
||||||
wl_list_init(&s->pending_buffer_destroy.link);
|
wl_list_init(&s->pending_buffer_destroy.link);
|
||||||
s->pending_buffer = NULL;
|
s->pending_buffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct surface_state {
|
struct surface_state {
|
||||||
struct dd_frame_acquire frame_acquire;
|
|
||||||
struct wl_resource *buffer;
|
struct wl_resource *buffer;
|
||||||
struct wl_listener buffer_destroy;
|
struct wl_listener buffer_destroy;
|
||||||
int attach;
|
int attach;
|
||||||
@@ -880,7 +865,6 @@ struct surface_state {
|
|||||||
|
|
||||||
static void on_state_buffer_destroyed(struct wl_listener *l, void *data) {
|
static void on_state_buffer_destroyed(struct wl_listener *l, void *data) {
|
||||||
struct surface_state *st = wl_container_of(l, st, buffer_destroy);
|
struct surface_state *st = wl_container_of(l, st, buffer_destroy);
|
||||||
dd_frame_acquire_clear(&st->frame_acquire);
|
|
||||||
wl_list_remove(&st->buffer_destroy.link);
|
wl_list_remove(&st->buffer_destroy.link);
|
||||||
wl_list_init(&st->buffer_destroy.link);
|
wl_list_init(&st->buffer_destroy.link);
|
||||||
st->buffer = NULL;
|
st->buffer = NULL;
|
||||||
@@ -889,8 +873,6 @@ static void on_state_buffer_destroyed(struct wl_listener *l, void *data) {
|
|||||||
|
|
||||||
static void surface_state_take(struct surface *s, struct surface_state *st) {
|
static void surface_state_take(struct surface *s, struct surface_state *st) {
|
||||||
st->attach = s->pending_attach;
|
st->attach = s->pending_attach;
|
||||||
st->frame_acquire = s->pending_frame_acquire;
|
|
||||||
s->pending_frame_acquire.fd_plus_one = 0;
|
|
||||||
st->buffer = s->pending_buffer;
|
st->buffer = s->pending_buffer;
|
||||||
wl_list_init(&st->buffer_destroy.link);
|
wl_list_init(&st->buffer_destroy.link);
|
||||||
if (st->buffer) {
|
if (st->buffer) {
|
||||||
@@ -1203,7 +1185,6 @@ static void surface_attach(struct wl_client *c, struct wl_resource *r,
|
|||||||
if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link);
|
if (s->pending_buffer) wl_list_remove(&s->pending_buffer_destroy.link);
|
||||||
wl_list_init(&s->pending_buffer_destroy.link);
|
wl_list_init(&s->pending_buffer_destroy.link);
|
||||||
s->pending_buffer = buffer;
|
s->pending_buffer = buffer;
|
||||||
dd_frame_acquire_clear(&s->pending_frame_acquire);
|
|
||||||
s->pending_attach = 1;
|
s->pending_attach = 1;
|
||||||
if (buffer) {
|
if (buffer) {
|
||||||
s->pending_buffer_destroy.notify = on_pending_buffer_destroyed;
|
s->pending_buffer_destroy.notify = on_pending_buffer_destroyed;
|
||||||
@@ -1469,7 +1450,6 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
|||||||
|
|
||||||
surface_drop_idle(s);
|
surface_drop_idle(s);
|
||||||
buf_trace_attach(buffer);
|
buf_trace_attach(buffer);
|
||||||
dd_frame_acquire_clear(&s->frame_acquire);
|
|
||||||
if (s->role == ROLE_CURSOR) {
|
if (s->role == ROLE_CURSOR) {
|
||||||
if (!buffer) {
|
if (!buffer) {
|
||||||
cursor_publish_hidden();
|
cursor_publish_hidden();
|
||||||
@@ -1481,8 +1461,6 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
|||||||
if (buffer) surface_hold_idle(s, buffer);
|
if (buffer) surface_hold_idle(s, buffer);
|
||||||
} else if (db) {
|
} else if (db) {
|
||||||
take_dmabuf(s, db, buffer);
|
take_dmabuf(s, db, buffer);
|
||||||
s->frame_acquire = st->frame_acquire;
|
|
||||||
st->frame_acquire.fd_plus_one = 0;
|
|
||||||
} else if (shm) {
|
} else if (shm) {
|
||||||
drop_dmabuf(s, 1);
|
drop_dmabuf(s, 1);
|
||||||
take_shm(s, shm, buffer);
|
take_shm(s, shm, buffer);
|
||||||
@@ -1495,7 +1473,6 @@ static void surface_state_apply(struct surface *s, struct surface_state *st) {
|
|||||||
if (buffer) send_buffer_release(buffer);
|
if (buffer) send_buffer_release(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dd_frame_acquire_clear(&st->frame_acquire);
|
|
||||||
pending_releases_apply(s);
|
pending_releases_apply(s);
|
||||||
|
|
||||||
wl_list_for_each(child, &s->children, child_link) {
|
wl_list_for_each(child, &s->children, child_link) {
|
||||||
@@ -1560,7 +1537,6 @@ static void settle_unwaited(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void surface_state_discard(struct surface_state *st) {
|
static void surface_state_discard(struct surface_state *st) {
|
||||||
dd_frame_acquire_clear(&st->frame_acquire);
|
|
||||||
struct wl_resource *cb, *tmp;
|
struct wl_resource *cb, *tmp;
|
||||||
wl_list_remove(&st->buffer_destroy.link);
|
wl_list_remove(&st->buffer_destroy.link);
|
||||||
wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb);
|
wl_resource_for_each_safe(cb, tmp, &st->frames) wl_resource_destroy(cb);
|
||||||
@@ -1572,8 +1548,6 @@ static void surface_state_merge(struct surface_state *older, struct surface_stat
|
|||||||
if (older->attach && !newer->attach) {
|
if (older->attach && !newer->attach) {
|
||||||
newer->attach = 1;
|
newer->attach = 1;
|
||||||
newer->buffer = older->buffer;
|
newer->buffer = older->buffer;
|
||||||
newer->frame_acquire = older->frame_acquire;
|
|
||||||
older->frame_acquire.fd_plus_one = 0;
|
|
||||||
wl_list_remove(&older->buffer_destroy.link);
|
wl_list_remove(&older->buffer_destroy.link);
|
||||||
wl_list_init(&older->buffer_destroy.link);
|
wl_list_init(&older->buffer_destroy.link);
|
||||||
if (newer->buffer) {
|
if (newer->buffer) {
|
||||||
@@ -1725,210 +1699,6 @@ static const struct wl_surface_interface surface_impl = {
|
|||||||
.offset = surface_offset,
|
.offset = surface_offset,
|
||||||
};
|
};
|
||||||
|
|
||||||
int droiddeck_surface_dup_acquire(const struct surface *s, const struct dmabuf_buffer *b) {
|
|
||||||
return s && s->dmabuf && s->dmabuf_buf == b ? dd_frame_acquire_dup(&s->frame_acquire) : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
// Private signed fixture: only the app-owned worker decision may issue a grant.
|
|
||||||
static pthread_mutex_t frame_worker_lock = PTHREAD_MUTEX_INITIALIZER;
|
|
||||||
static char frame_worker_file[PATH_MAX];
|
|
||||||
static struct dd_worker_grant frame_worker_grant;
|
|
||||||
static int frame_worker_pidfd = -1;
|
|
||||||
static bool frame_worker_map_reported;
|
|
||||||
|
|
||||||
static enum dd_worker_stat_result frame_worker_starttime(pid_t pid, uint64_t *out) {
|
|
||||||
char proc[64], line[4096];
|
|
||||||
snprintf(proc, sizeof(proc), "/proc/%d/stat", pid);
|
|
||||||
FILE *f = fopen(proc, "re");
|
|
||||||
if (!f) return dd_worker_open_failure(errno);
|
|
||||||
// Proc writes one bounded line; truncation is a read failure, not invisibility.
|
|
||||||
bool read = fgets(line, sizeof(line), f) != NULL && strchr(line, '\n') != NULL;
|
|
||||||
fclose(f);
|
|
||||||
return read ? dd_worker_parse_start(line, out) : DD_WORKER_STAT_READ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void droiddeck_frame_worker_revoke(int owner, int pid) {
|
|
||||||
pthread_mutex_lock(&frame_worker_lock);
|
|
||||||
if (frame_worker_grant.owner == (uint32_t)owner &&
|
|
||||||
(!pid || frame_worker_grant.pid == (uint32_t)pid)) {
|
|
||||||
if (frame_worker_pidfd >= 0) close(frame_worker_pidfd);
|
|
||||||
frame_worker_pidfd = -1;
|
|
||||||
frame_worker_grant = (struct dd_worker_grant){0};
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&frame_worker_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
int droiddeck_frame_worker_grant(int owner, pid_t pid, uint64_t expires, const char *path,
|
|
||||||
uint64_t expected_dev, uint64_t expected_ino, uint64_t receipt) {
|
|
||||||
struct stat st;
|
|
||||||
if (owner <= 0 || pid <= 1 || !receipt || !path ||
|
|
||||||
strlen(path) >= sizeof(frame_worker_file) || lstat(path, &st) < 0 || !S_ISREG(st.st_mode) ||
|
|
||||||
(uint64_t)st.st_dev != expected_dev || (uint64_t)st.st_ino != expected_ino ||
|
|
||||||
st.st_uid != getuid()) {
|
|
||||||
droiddeck_log("probe", "worker_admission=NATIVE_FILE");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int pidfd = syscall(__NR_pidfd_open, pid, 0);
|
|
||||||
if (pidfd < 0) {
|
|
||||||
droiddeck_log("probe", "worker_admission=NATIVE_PIDFD");
|
|
||||||
return 0; // No fallback to a recyclable PID.
|
|
||||||
}
|
|
||||||
struct pollfd alive = {.fd = pidfd, .events = POLLIN};
|
|
||||||
uint64_t raw_start = 0;
|
|
||||||
enum dd_worker_stat_result stat = frame_worker_starttime(pid, &raw_start);
|
|
||||||
switch (stat) {
|
|
||||||
case DD_WORKER_STAT_OK:
|
|
||||||
if (raw_start != receipt) droiddeck_log("probe", "worker_admission=NATIVE_STAT_MISMATCH");
|
|
||||||
break;
|
|
||||||
case DD_WORKER_STAT_DENIED: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_DENIED"); break;
|
|
||||||
case DD_WORKER_STAT_HIDDEN: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_HIDDEN"); break;
|
|
||||||
case DD_WORKER_STAT_OPEN: droiddeck_log("probe", "worker_admission=NATIVE_STAT_OPEN_OTHER"); break;
|
|
||||||
case DD_WORKER_STAT_READ: droiddeck_log("probe", "worker_admission=NATIVE_STAT_READ"); break;
|
|
||||||
case DD_WORKER_STAT_PARSE: droiddeck_log("probe", "worker_admission=NATIVE_STAT_PARSE"); break;
|
|
||||||
case DD_WORKER_STAT_ZERO: droiddeck_log("probe", "worker_admission=NATIVE_STAT_ZERO"); break;
|
|
||||||
}
|
|
||||||
if (!dd_worker_receipt_allows_reserve(stat, raw_start, receipt)) { close(pidfd); return 0; }
|
|
||||||
if (poll(&alive, 1, 0) != 0) {
|
|
||||||
droiddeck_log("probe", "worker_admission=NATIVE_PIDFD_NOT_LIVE");
|
|
||||||
close(pidfd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
pthread_mutex_lock(&frame_worker_lock);
|
|
||||||
if (frame_worker_pidfd < 0) {
|
|
||||||
strcpy(frame_worker_file, path);
|
|
||||||
frame_worker_grant = (struct dd_worker_grant){
|
|
||||||
.owner = owner, .uid = getuid(), .pid = pid, .start_ticks = receipt, .expires = expires,
|
|
||||||
.dev_major = major(st.st_dev), .dev_minor = minor(st.st_dev), .ino = st.st_ino,
|
|
||||||
.canonical_file = frame_worker_file, .app_launch_verified = true, .final_go = true,
|
|
||||||
};
|
|
||||||
frame_worker_map_reported = false;
|
|
||||||
frame_worker_pidfd = pidfd;
|
|
||||||
pidfd = -1;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&frame_worker_lock);
|
|
||||||
if (pidfd >= 0) {
|
|
||||||
droiddeck_log("probe", "worker_admission=NATIVE_ALREADY_RESERVED");
|
|
||||||
close(pidfd);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
droiddeck_log("probe", "frame acquire reserved one app-verified worker");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool frame_worker_verified_exec_locked(const struct dd_worker_grant *g, uint64_t now) {
|
|
||||||
char proc[64], line[PATH_MAX + 128];
|
|
||||||
const char *failure = "worker_admission=MAP_STARTTIME";
|
|
||||||
uint64_t raw_start = 0;
|
|
||||||
if (frame_worker_starttime(g->pid, &raw_start) != DD_WORKER_STAT_OK || raw_start != g->start_ticks)
|
|
||||||
goto reject;
|
|
||||||
snprintf(proc, sizeof(proc), "/proc/%u/maps", g->pid);
|
|
||||||
FILE *f = fopen(proc, "re");
|
|
||||||
failure = "worker_admission=MAP_OPEN";
|
|
||||||
if (!f) goto reject;
|
|
||||||
bool matched = false;
|
|
||||||
size_t budget = 2 * 1024 * 1024;
|
|
||||||
while (budget && fgets(line, sizeof(line), f)) {
|
|
||||||
size_t n = strlen(line);
|
|
||||||
if (!n || line[n - 1] != '\n' || n > budget) break;
|
|
||||||
budget -= n;
|
|
||||||
if (dd_worker_grant_matches(g, g->owner, g->uid, g->pid, raw_start, now, line)) {
|
|
||||||
matched = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
if (matched) return true;
|
|
||||||
failure = "worker_admission=MAP_IDENTITY";
|
|
||||||
reject:
|
|
||||||
if (!frame_worker_map_reported) {
|
|
||||||
frame_worker_map_reported = true;
|
|
||||||
droiddeck_log("probe", "%s", failure);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int frame_acquire_peer_allowed(const struct wl_client *client, bool verify_exec, bool bind) {
|
|
||||||
pid_t pid = 0;
|
|
||||||
uid_t uid = (uid_t)-1;
|
|
||||||
wl_client_get_credentials(client, &pid, &uid, NULL);
|
|
||||||
struct timespec t;
|
|
||||||
if (clock_gettime(CLOCK_BOOTTIME, &t) < 0) return 0;
|
|
||||||
uint64_t now = (uint64_t)t.tv_sec * 1000 + (uint64_t)t.tv_nsec / 1000000;
|
|
||||||
pthread_mutex_lock(&frame_worker_lock);
|
|
||||||
const struct dd_worker_grant *g = &frame_worker_grant;
|
|
||||||
struct pollfd alive = {.fd = frame_worker_pidfd, .events = POLLIN};
|
|
||||||
bool allowed = frame_worker_pidfd >= 0 && uid == getuid() && pid > 1 &&
|
|
||||||
g->pid == (uint32_t)pid && g->uid == uid && now < g->expires &&
|
|
||||||
poll(&alive, 1, 0) == 0 && (!verify_exec ||
|
|
||||||
(frame_worker_verified_exec_locked(g, now) && poll(&alive, 1, 0) == 0));
|
|
||||||
// The short startup authorization may not be renewed by registry enumeration.
|
|
||||||
// Only an authenticated bind activates the grant for the lifetime of this live,
|
|
||||||
// unreplaced worker; session teardown revokes it independently of process exit.
|
|
||||||
if (allowed && bind) frame_worker_grant.expires = UINT64_MAX;
|
|
||||||
pthread_mutex_unlock(&frame_worker_lock);
|
|
||||||
return allowed;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool frame_acquire_global_filter(const struct wl_client *client, const struct wl_global *global, void *data) {
|
|
||||||
return wl_global_get_interface(global) != &droiddeck_frame_acquire_v1_interface ||
|
|
||||||
frame_acquire_peer_allowed(client, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void frame_acquire_destroy(struct wl_client *client, struct wl_resource *resource) {
|
|
||||||
wl_resource_destroy(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void frame_acquire_set(struct wl_client *client, struct wl_resource *resource,
|
|
||||||
struct wl_resource *surface, struct wl_resource *buffer, int32_t fd) {
|
|
||||||
if (!frame_acquire_peer_allowed(client, false, false)) {
|
|
||||||
close(fd);
|
|
||||||
wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_UNAUTHORIZED_PEER,
|
|
||||||
"paired capture peer is not authorized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct surface *s = NULL;
|
|
||||||
if (surface && buffer && wl_resource_get_client(surface) == client &&
|
|
||||||
wl_resource_get_client(buffer) == client &&
|
|
||||||
wl_resource_instance_of(surface, &wl_surface_interface, &surface_impl) &&
|
|
||||||
get_dmabuf(buffer))
|
|
||||||
s = wl_resource_get_user_data(surface);
|
|
||||||
if (!s || !s->pending_attach || s->pending_buffer != buffer) {
|
|
||||||
close(fd);
|
|
||||||
wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_ATTACHMENT,
|
|
||||||
"fence does not match pending DMA-BUF attachment");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
enum dd_frame_acquire_result result = dd_frame_acquire_set(&s->pending_frame_acquire, fd);
|
|
||||||
if (result == DD_ACQUIRE_DUPLICATE)
|
|
||||||
wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_DUPLICATE_FENCE,
|
|
||||||
"pending attachment already has a fence");
|
|
||||||
else if (result == DD_ACQUIRE_INVALID)
|
|
||||||
wl_resource_post_error(resource, DROIDDECK_FRAME_ACQUIRE_V1_ERROR_INVALID_FENCE,
|
|
||||||
"expected an already signaled Linux sync_file");
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct droiddeck_frame_acquire_v1_interface frame_acquire_impl = {
|
|
||||||
.destroy = frame_acquire_destroy,
|
|
||||||
.set_acquire_fence = frame_acquire_set,
|
|
||||||
};
|
|
||||||
|
|
||||||
static void bind_frame_acquire(struct wl_client *client, void *data, uint32_t version, uint32_t id) {
|
|
||||||
if (!frame_acquire_peer_allowed(client, true, true)) {
|
|
||||||
wl_client_post_implementation_error(client, "paired capture peer is not authorized");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
struct wl_resource *resource =
|
|
||||||
wl_resource_create(client, &droiddeck_frame_acquire_v1_interface, 1, id);
|
|
||||||
if (!resource) {
|
|
||||||
wl_client_post_no_memory(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wl_resource_set_implementation(resource, &frame_acquire_impl, NULL, NULL);
|
|
||||||
droiddeck_log("probe", "frame acquire bound to app-issued worker and exact executable map");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void detach_from_parent(struct surface *s) {
|
static void detach_from_parent(struct surface *s) {
|
||||||
if (!s->parent) return;
|
if (!s->parent) return;
|
||||||
wl_list_remove(&s->child_link);
|
wl_list_remove(&s->child_link);
|
||||||
@@ -1938,7 +1708,6 @@ static void detach_from_parent(struct surface *s) {
|
|||||||
|
|
||||||
static void surface_resource_destroy(struct wl_resource *r) {
|
static void surface_resource_destroy(struct wl_resource *r) {
|
||||||
struct surface *s = wl_resource_get_user_data(r);
|
struct surface *s = wl_resource_get_user_data(r);
|
||||||
dd_frame_acquire_clear(&s->pending_frame_acquire);
|
|
||||||
struct surface *child, *tmp;
|
struct surface *child, *tmp;
|
||||||
struct wl_resource *cb, *cbtmp;
|
struct wl_resource *cb, *cbtmp;
|
||||||
|
|
||||||
@@ -2503,69 +2272,6 @@ static void bind_output(struct wl_client *c, void *data, uint32_t ver, uint32_t
|
|||||||
|
|
||||||
struct draw_list { struct vkp_draw *d; int n, cap; };
|
struct draw_list { struct vkp_draw *d; int n, cap; };
|
||||||
|
|
||||||
#define ZERO_COPY_FALLBACK_SIGNATURES 32u
|
|
||||||
enum zero_copy_fallback_reason {
|
|
||||||
ZERO_COPY_NO_SURFACE_BUFFER = 1,
|
|
||||||
ZERO_COPY_NO_GRALLOC_AHB = 2,
|
|
||||||
ZERO_COPY_AHB_PRESENT_FAILED = 3
|
|
||||||
};
|
|
||||||
struct zero_copy_fallback_signature {
|
|
||||||
uint32_t reason, format, stride, offset;
|
|
||||||
int width, height;
|
|
||||||
uint64_t modifier;
|
|
||||||
};
|
|
||||||
static struct zero_copy_fallback_signature g_zero_copy_fallbacks[ZERO_COPY_FALLBACK_SIGNATURES];
|
|
||||||
static uint32_t g_zero_copy_fallback_count;
|
|
||||||
static int g_zero_copy_fallback_limit_logged;
|
|
||||||
|
|
||||||
static int zero_copy_fallback_should_log(const struct dmabuf_buffer *b, uint32_t reason) {
|
|
||||||
const struct zero_copy_fallback_signature key = {
|
|
||||||
.reason = reason, .format = b ? b->format : 0,
|
|
||||||
.stride = b && b->n_planes ? b->stride[0] : 0,
|
|
||||||
.offset = b && b->n_planes ? b->offset[0] : 0,
|
|
||||||
.width = b ? b->width : 0, .height = b ? b->height : 0,
|
|
||||||
.modifier = b ? b->modifier : 0};
|
|
||||||
for (uint32_t i = 0; i < g_zero_copy_fallback_count; i++) {
|
|
||||||
const struct zero_copy_fallback_signature *seen = &g_zero_copy_fallbacks[i];
|
|
||||||
if (seen->reason == key.reason && seen->format == key.format && seen->stride == key.stride &&
|
|
||||||
seen->offset == key.offset && seen->width == key.width && seen->height == key.height &&
|
|
||||||
seen->modifier == key.modifier)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (g_zero_copy_fallback_count >= ZERO_COPY_FALLBACK_SIGNATURES) {
|
|
||||||
if (!g_zero_copy_fallback_limit_logged) {
|
|
||||||
g_zero_copy_fallback_limit_logged = 1;
|
|
||||||
droiddeck_log("layer", "zero-copy: further fallback diagnostics suppressed after %u distinct buffer signatures",
|
|
||||||
ZERO_COPY_FALLBACK_SIGNATURES);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
g_zero_copy_fallbacks[g_zero_copy_fallback_count++] = key;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void note_zero_copy_fallback(struct surface *s, const struct dmabuf_buffer *b, uint32_t reason,
|
|
||||||
int scene_w, int scene_h, int present_result) {
|
|
||||||
if (!zero_copy_fallback_should_log(b, reason)) return;
|
|
||||||
char name[160] = "unknown surface";
|
|
||||||
if (s) describe(s, name, sizeof(name));
|
|
||||||
if (reason == ZERO_COPY_NO_SURFACE_BUFFER) {
|
|
||||||
droiddeck_log("layer", "zero-copy: layer candidate %s has no associated Wayland surface buffer; using the layer-copy path",
|
|
||||||
name);
|
|
||||||
} else {
|
|
||||||
droiddeck_log("layer", "zero-copy: %s buffer %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx %s; "
|
|
||||||
"scene %dx%d will use the layer-copy path (direct-present result %d)",
|
|
||||||
name, b->format & 0xff, (b->format >> 8) & 0xff, (b->format >> 16) & 0xff,
|
|
||||||
(b->format >> 24) & 0xff, b->width, b->height,
|
|
||||||
b->n_planes ? b->stride[0] : 0, b->n_planes ? b->offset[0] : 0,
|
|
||||||
(unsigned long long)b->modifier,
|
|
||||||
reason == ZERO_COPY_NO_GRALLOC_AHB
|
|
||||||
? "has no registered gralloc AHardwareBuffer"
|
|
||||||
: "has a registered gralloc AHardwareBuffer but direct presentation failed",
|
|
||||||
scene_w, scene_h, present_result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int add_cursor(struct draw_list *dl, int scene_w);
|
static int add_cursor(struct draw_list *dl, int scene_w);
|
||||||
|
|
||||||
static struct vkp_image *surface_image(struct surface *s) {
|
static struct vkp_image *surface_image(struct surface *s) {
|
||||||
@@ -2685,53 +2391,17 @@ static int black_fill_below(const struct draw_list *dl, int n) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define LAYER_CANDIDATE_DIAGNOSTICS 32u
|
|
||||||
static unsigned g_layer_candidate_diag_count;
|
|
||||||
static int g_layer_candidate_diag_limit;
|
|
||||||
|
|
||||||
static void note_layer_candidate_skip(const struct vkp_draw *d, int index, int reason,
|
|
||||||
int scene_w, int scene_h) {
|
|
||||||
static int seen[LAYER_CANDIDATE_DIAGNOSTICS][8];
|
|
||||||
const int key[8] = {index, reason, scene_w, scene_h, d->dx, d->dy, d->dw, d->dh};
|
|
||||||
for (unsigned i = 0; i < g_layer_candidate_diag_count; i++)
|
|
||||||
if (!memcmp(seen[i], key, sizeof(key))) return;
|
|
||||||
if (g_layer_candidate_diag_count >= LAYER_CANDIDATE_DIAGNOSTICS) {
|
|
||||||
if (!g_layer_candidate_diag_limit++) droiddeck_log("layer", "zero-copy: further candidate-rejection details suppressed after %u signatures",
|
|
||||||
LAYER_CANDIDATE_DIAGNOSTICS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
memcpy(seen[g_layer_candidate_diag_count++], key, sizeof(key));
|
|
||||||
const char *why = reason == 1 ? "translucent draw" :
|
|
||||||
reason == 2 ? "image is not DMA-BUF" :
|
|
||||||
reason == 3 ? "source rectangle is outside/invalid" :
|
|
||||||
reason == 4 ? "draw rectangle is outside scene or invalid" :
|
|
||||||
"not fullscreen and no black backing below";
|
|
||||||
droiddeck_log("layer", "zero-copy: candidate draw %d rejected: %s; scene %dx%d, dst %dx%d at %d,%d, src %.2f,%.2f %.2fx%.2f, image %dx%d",
|
|
||||||
index, why, scene_w, scene_h, d->dw, d->dh, d->dx, d->dy,
|
|
||||||
d->sx, d->sy, d->sw, d->sh, vkp_image_width(d->img), vkp_image_height(d->img));
|
|
||||||
}
|
|
||||||
|
|
||||||
static int layer_candidate(const struct draw_list *dl, int scene_w, int scene_h) {
|
static int layer_candidate(const struct draw_list *dl, int scene_w, int scene_h) {
|
||||||
for (int i = dl->n - 1; i >= 0 && i >= dl->n - 2; i--) {
|
for (int i = dl->n - 1; i >= 0 && i >= dl->n - 2; i--) {
|
||||||
const struct vkp_draw *d = &dl->d[i];
|
const struct vkp_draw *d = &dl->d[i];
|
||||||
if (d->blend) { note_layer_candidate_skip(d, i, 1, scene_w, scene_h); continue; }
|
if (d->blend) continue;
|
||||||
if (!vkp_image_is_dmabuf(d->img)) { note_layer_candidate_skip(d, i, 2, scene_w, scene_h); continue; }
|
if (!vkp_image_is_dmabuf(d->img)) continue;
|
||||||
if (d->sx < 0 || d->sy < 0 || d->sw < 1.0f || d->sh < 1.0f ||
|
if (d->sx < 0 || d->sy < 0 || d->sw < 1.0f || d->sh < 1.0f ||
|
||||||
d->sx + d->sw >= vkp_image_width(d->img) + 1.0f ||
|
d->sx + d->sw >= vkp_image_width(d->img) + 1.0f ||
|
||||||
d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) {
|
d->sy + d->sh >= vkp_image_height(d->img) + 1.0f) continue;
|
||||||
note_layer_candidate_skip(d, i, 3, scene_w, scene_h);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (d->dx == 0 && d->dy == 0 && d->dw == scene_w && d->dh == scene_h) return i;
|
if (d->dx == 0 && d->dy == 0 && d->dw == scene_w && d->dh == scene_h) return i;
|
||||||
if (d->dx < 0 || d->dy < 0 || d->dw <= 0 || d->dh <= 0 || d->dx + d->dw > scene_w ||
|
if (d->dx < 0 || d->dy < 0 || d->dw <= 0 || d->dh <= 0 || d->dx + d->dw > scene_w ||
|
||||||
d->dy + d->dh > scene_h) {
|
d->dy + d->dh > scene_h || !black_fill_below(dl, i)) continue;
|
||||||
note_layer_candidate_skip(d, i, 4, scene_w, scene_h);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!black_fill_below(dl, i)) {
|
|
||||||
note_layer_candidate_skip(d, i, 5, scene_w, scene_h);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -2752,56 +2422,6 @@ static void note_copy_scene(const struct draw_list *dl, int scene_w, int scene_h
|
|||||||
vkp_image_is_dmabuf(t->img) ? "GPU" : "memory", t->blend ? ", translucent" : "");
|
vkp_image_is_dmabuf(t->img) ? "GPU" : "memory", t->blend ? ", translucent" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct surface *surface_for_image(const struct vkp_image *img);
|
|
||||||
|
|
||||||
static void note_layer_candidate_rejected(const struct draw_list *dl, int scene_w, int scene_h) {
|
|
||||||
static int seen[32][14];
|
|
||||||
static unsigned seen_count;
|
|
||||||
static int limit_logged;
|
|
||||||
static time_t window_start;
|
|
||||||
struct timespec now_ts;
|
|
||||||
const struct vkp_draw *a = dl->n > 0 ? &dl->d[dl->n - 1] : NULL;
|
|
||||||
const struct vkp_draw *b = dl->n > 1 ? &dl->d[dl->n - 2] : NULL;
|
|
||||||
struct surface *sa = a ? surface_for_image(a->img) : NULL;
|
|
||||||
struct surface *sb = b ? surface_for_image(b->img) : NULL;
|
|
||||||
const int signature[14] = {
|
|
||||||
dl->n, scene_w, scene_h,
|
|
||||||
a ? a->dw : 0, a ? a->dh : 0,
|
|
||||||
a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0,
|
|
||||||
a ? vkp_image_is_dmabuf(a->img) : 0, a ? a->blend : 0, sa && sa->dmabuf_buf ? 1 : 0,
|
|
||||||
b ? b->dw : 0, b ? b->dh : 0, b ? vkp_image_is_dmabuf(b->img) : 0, sb && sb->dmabuf_buf ? 1 : 0
|
|
||||||
};
|
|
||||||
clock_gettime(CLOCK_MONOTONIC, &now_ts);
|
|
||||||
if (!window_start || now_ts.tv_sec - window_start >= 30) {
|
|
||||||
seen_count = 0;
|
|
||||||
limit_logged = 0;
|
|
||||||
window_start = now_ts.tv_sec;
|
|
||||||
}
|
|
||||||
for (unsigned i = 0; i < seen_count; i++)
|
|
||||||
if (!memcmp(signature, seen[i], sizeof(signature))) return;
|
|
||||||
if (seen_count >= 32) {
|
|
||||||
if (!limit_logged++) droiddeck_log("layer", "zero-copy: further fullscreen-candidate rejection details suppressed after 32 signatures in 30 seconds");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
memcpy(seen[seen_count++], signature, sizeof(signature));
|
|
||||||
char below[48];
|
|
||||||
if (b)
|
|
||||||
snprintf(below, sizeof(below), "%s %dx%d",
|
|
||||||
vkp_image_is_dmabuf(b->img) ? "DMA-BUF" : "non-DMA-BUF", b->dw, b->dh);
|
|
||||||
else
|
|
||||||
snprintf(below, sizeof(below), "none");
|
|
||||||
droiddeck_log("layer", "zero-copy: no eligible fullscreen DMA-BUF layer candidate: scene %dx%d, %d draws; "
|
|
||||||
"top draw %dx%d at %d,%d image %dx%d %s%s surface=%s dmabuf=%s; "
|
|
||||||
"draw below %s",
|
|
||||||
scene_w, scene_h, dl->n, a ? a->dw : 0, a ? a->dh : 0, a ? a->dx : 0, a ? a->dy : 0,
|
|
||||||
a ? vkp_image_width(a->img) : 0, a ? vkp_image_height(a->img) : 0,
|
|
||||||
a && vkp_image_is_dmabuf(a->img) ? "DMA-BUF" : "non-DMA-BUF",
|
|
||||||
a && a->blend ? " blended" : "",
|
|
||||||
sa ? "associated" : "unassociated",
|
|
||||||
sa && sa->dmabuf_buf ? "yes" : "no",
|
|
||||||
below);
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct surface *surface_for_image(const struct vkp_image *img) {
|
static struct surface *surface_for_image(const struct vkp_image *img) {
|
||||||
struct surface *s;
|
struct surface *s;
|
||||||
wl_list_for_each(s, &g_surfaces, link)
|
wl_list_for_each(s, &g_surfaces, link)
|
||||||
@@ -2810,56 +2430,16 @@ static struct surface *surface_for_image(const struct vkp_image *img) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct surface *ahb_layer_only_candidate(int scene_w, int scene_h) {
|
static struct surface *ahb_layer_only_candidate(int scene_w, int scene_h) {
|
||||||
static struct {
|
|
||||||
const struct surface *surface;
|
|
||||||
int reason, scene_w, scene_h, w, h, buf_w, buf_h, x, y, src_set, dst_set, children;
|
|
||||||
} seen[32];
|
|
||||||
static unsigned seen_count;
|
|
||||||
static int limit_logged;
|
|
||||||
struct surface *s;
|
struct surface *s;
|
||||||
int w = 0, h = 0, reason = 0;
|
int w, h;
|
||||||
if (wl_list_empty(&g_toplevels)) return NULL;
|
if (wl_list_empty(&g_toplevels)) return NULL;
|
||||||
s = wl_container_of(g_toplevels.prev, s, toplevel_link);
|
s = wl_container_of(g_toplevels.prev, s, toplevel_link);
|
||||||
if (!s->dmabuf_buf) reason = 1;
|
if (!s->dmabuf_buf || s->dmabuf_buf->img || !ahb_swapchain_has_ahb(s->dmabuf_buf)) return NULL;
|
||||||
else if (s->dmabuf_buf->img) reason = 2;
|
if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) return NULL;
|
||||||
else if (!ahb_swapchain_has_ahb(s->dmabuf_buf)) reason = 3;
|
if (!wl_list_empty(&s->children)) return NULL;
|
||||||
else if ((g_desktop && !s->placed) || s->x != 0 || s->y != 0 || s->src_set || s->dst_set) reason = 4;
|
if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) return NULL;
|
||||||
else if (!wl_list_empty(&s->children)) reason = 5;
|
|
||||||
else if (g_hide_shell && !strcmp(client_name(wl_resource_get_client(s->resource)), "explorer.exe")) reason = 6;
|
|
||||||
surface_size(s, &w, &h);
|
surface_size(s, &w, &h);
|
||||||
if (!reason && (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h)) reason = 7;
|
if (w != scene_w || h != scene_h || s->buf_w != scene_w || s->buf_h != scene_h) return NULL;
|
||||||
if (reason) {
|
|
||||||
int found = 0;
|
|
||||||
for (unsigned i = 0; i < seen_count; i++) {
|
|
||||||
if (seen[i].surface == s && seen[i].reason == reason && seen[i].scene_w == scene_w &&
|
|
||||||
seen[i].scene_h == scene_h && seen[i].w == w && seen[i].h == h &&
|
|
||||||
seen[i].buf_w == s->buf_w && seen[i].buf_h == s->buf_h && seen[i].x == s->x &&
|
|
||||||
seen[i].y == s->y && seen[i].src_set == s->src_set && seen[i].dst_set == s->dst_set &&
|
|
||||||
seen[i].children == !wl_list_empty(&s->children)) { found = 1; break; }
|
|
||||||
}
|
|
||||||
if (!found && seen_count < 32) {
|
|
||||||
seen[seen_count].surface = s; seen[seen_count].reason = reason;
|
|
||||||
seen[seen_count].scene_w = scene_w; seen[seen_count].scene_h = scene_h;
|
|
||||||
seen[seen_count].w = w; seen[seen_count].h = h; seen[seen_count].buf_w = s->buf_w; seen[seen_count].buf_h = s->buf_h;
|
|
||||||
seen[seen_count].x = s->x; seen[seen_count].y = s->y; seen[seen_count].src_set = s->src_set;
|
|
||||||
seen[seen_count].dst_set = s->dst_set; seen[seen_count].children = !wl_list_empty(&s->children);
|
|
||||||
seen_count++;
|
|
||||||
const char *why = reason == 1 ? "no DMA-BUF buffer" :
|
|
||||||
reason == 2 ? "buffer is already importable by Vulkan" :
|
|
||||||
reason == 3 ? "no registered gralloc AHardwareBuffer" :
|
|
||||||
reason == 4 ? "surface is positioned/cropped/scaled" :
|
|
||||||
reason == 5 ? "surface has child surfaces" :
|
|
||||||
reason == 6 ? "hidden shell surface" : "surface or buffer dimensions differ from scene";
|
|
||||||
char name[160]; describe(s, name, sizeof(name));
|
|
||||||
droiddeck_log("layer", "zero-copy: AHardwareBuffer-only candidate rejected: %s; %s, scene %dx%d, surface %dx%d at %d,%d, buffer %dx%d, crop=%d destination=%d children=%d",
|
|
||||||
why, name, scene_w, scene_h, w, h, s->x, s->y, s->buf_w, s->buf_h,
|
|
||||||
s->src_set, s->dst_set, !wl_list_empty(&s->children));
|
|
||||||
} else if (!found && !limit_logged) {
|
|
||||||
limit_logged = 1;
|
|
||||||
droiddeck_log("layer", "zero-copy: further AHardwareBuffer-only candidate diagnostics suppressed after 32 signatures");
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2962,7 +2542,7 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) {
|
|||||||
static int said = -1, said_tm = -1;
|
static int said = -1, said_tm = -1;
|
||||||
static const char *said_why;
|
static const char *said_why;
|
||||||
const int tm = route != 0 && !droiddeck_color_output();
|
const int tm = route != 0 && !droiddeck_color_output();
|
||||||
if (route == said && tm == said_tm && (route < 1 || route > 2 || hs->why == said_why)) return;
|
if (route == said && tm == said_tm && (route != 1 || hs->why == said_why)) return;
|
||||||
int was = said;
|
int was = said;
|
||||||
said = route; said_why = hs->why; said_tm = tm;
|
said = route; said_why = hs->why; said_tm = tm;
|
||||||
char name[160] = "the HDR game";
|
char name[160] = "the HDR game";
|
||||||
@@ -2979,10 +2559,6 @@ static void hdr_note_route(int route, const struct hdr_scene *hs) {
|
|||||||
"BT2020_PQ", name, hs->why ? hs->why : "?", droiddeck_color_sdr_white());
|
"BT2020_PQ", name, hs->why ? hs->why : "?", droiddeck_color_sdr_white());
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (g_mirror_capture) {
|
|
||||||
droiddeck_log("color", "Mirror: %s is composed through the screen swapchain", name);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (tm)
|
if (tm)
|
||||||
droiddeck_log("color", "HDR with frame generation for %s, HDR output switched off: the scene is tone-mapped to "
|
droiddeck_log("color", "HDR with frame generation for %s, HDR output switched off: the scene is tone-mapped to "
|
||||||
"SDR and presented through an SDR screen swapchain", name);
|
"SDR and presented through an SDR screen swapchain", name);
|
||||||
@@ -3203,11 +2779,6 @@ static void render_scene(void) {
|
|||||||
const int cardboard = vkp_cardboard_active();
|
const int cardboard = vkp_cardboard_active();
|
||||||
struct hdr_scene hs;
|
struct hdr_scene hs;
|
||||||
int hdr_route = hdr_plan(&dl, w, h, fx_on, framegen, &hs);
|
int hdr_route = hdr_plan(&dl, w, h, fx_on, framegen, &hs);
|
||||||
/* Mirror's PixelCopy cannot see the separate game layer. Keep unimportable frames visible on top. */
|
|
||||||
if (g_mirror_capture && hdr_route != 3 && hs.n_hdr > 0) {
|
|
||||||
hdr_route = 2;
|
|
||||||
hs.why = "Mirror needs the screen swapchain";
|
|
||||||
}
|
|
||||||
const char *hdr_copy = NULL;
|
const char *hdr_copy = NULL;
|
||||||
if (droiddeck_color_hdr_open()) {
|
if (droiddeck_color_hdr_open()) {
|
||||||
hdr_note_route(hdr_route, &hs);
|
hdr_note_route(hdr_route, &hs);
|
||||||
@@ -3273,16 +2844,16 @@ static void render_scene(void) {
|
|||||||
else if (rendered && how == 2) droiddeck_color_frame_shown(hs.color, DROIDDECK_HDR_TONEMAPPED, 0);
|
else if (rendered && how == 2) droiddeck_color_frame_shown(hs.color, DROIDDECK_HDR_TONEMAPPED, 0);
|
||||||
else if (rendered) hdr_copy = "the HDR composition pass is unavailable on this driver";
|
else if (rendered) hdr_copy = "the HDR composition pass is unavailable on this driver";
|
||||||
}
|
}
|
||||||
if (hdr_route == 0 && !g_mirror_capture && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
if (hdr_route == 0 && vkp_quest_layer_presentation() && !framegen && !cardboard && !cursor_on &&
|
||||||
!ahb_only) {
|
!ahb_only) {
|
||||||
settle_unwaited();
|
settle_unwaited();
|
||||||
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
rendered = vkp_render(w, h, dl.d, dl.n) == 0;
|
||||||
} else if (hdr_route == 0 || hdr_route == 3) {
|
} else if (hdr_route == 0 || hdr_route == 3) {
|
||||||
const int pass_on = fx_on || framegen;
|
const int pass_on = fx_on || framegen;
|
||||||
tell_overlay_planes();
|
tell_overlay_planes();
|
||||||
const int fg_layer = framegen && !g_mirror_capture && hdr_route == 0 && framegen_fits_layer();
|
const int fg_layer = framegen && hdr_route == 0 && framegen_fits_layer();
|
||||||
g_framegen_layer = fg_layer;
|
g_framegen_layer = fg_layer;
|
||||||
int li = (g_zero_copy && !g_mirror_capture && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1;
|
int li = (g_zero_copy && (!framegen || fg_layer) && !bfi && !cardboard && !cursor_on) ? layer_candidate(&dl, w, h) : -1;
|
||||||
int over = li >= 0 ? dl.n - 1 - li : 0;
|
int over = li >= 0 ? dl.n - 1 - li : 0;
|
||||||
const int fx_blocks = (li >= 0 && fx_on && over > 0);
|
const int fx_blocks = (li >= 0 && fx_on && over > 0);
|
||||||
if (fx_blocks) { li = -1; over = 0; }
|
if (fx_blocks) { li = -1; over = 0; }
|
||||||
@@ -3311,10 +2882,7 @@ static void render_scene(void) {
|
|||||||
struct surface *ls = li >= 0 ? surface_for_image(dl.d[li].img) : NULL;
|
struct surface *ls = li >= 0 ? surface_for_image(dl.d[li].img) : NULL;
|
||||||
const struct vkp_draw *ld = li >= 0 ? &dl.d[li] : NULL;
|
const struct vkp_draw *ld = li >= 0 ? &dl.d[li] : NULL;
|
||||||
if (li < 0) ls = layer_only;
|
if (li < 0) ls = layer_only;
|
||||||
if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) {
|
if (g_zero_copy && li < 0 && !ls && !blocked && !cardboard) note_copy_scene(&dl, w, h, cursor_on);
|
||||||
if (!cursor_on && !bfi) note_layer_candidate_rejected(&dl, w, h);
|
|
||||||
note_copy_scene(&dl, w, h, cursor_on);
|
|
||||||
}
|
|
||||||
if (cardboard) ls = NULL;
|
if (cardboard) ls = NULL;
|
||||||
if (cursor_on) ls = NULL;
|
if (cursor_on) ls = NULL;
|
||||||
if (bfi) ls = NULL;
|
if (bfi) ls = NULL;
|
||||||
@@ -3342,30 +2910,15 @@ static void render_scene(void) {
|
|||||||
r = generated >= 0 ? 0 : -1;
|
r = generated >= 0 ? 0 : -1;
|
||||||
else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
else if (generated >= 0 && !(fx_on && li >= 0) && ls && ls->dmabuf_buf && ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
||||||
r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld);
|
r = ahb_swapchain_present(ls->dmabuf_buf, ls, w, h, ld);
|
||||||
if (!fg_pass && generated >= 0 && !fx_on && !framegen && r != 0) {
|
|
||||||
if (!ls || !ls->dmabuf_buf)
|
|
||||||
note_zero_copy_fallback(ls, NULL, ZERO_COPY_NO_SURFACE_BUFFER, w, h, r);
|
|
||||||
else if (!ahb_swapchain_has_ahb(ls->dmabuf_buf))
|
|
||||||
note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_NO_GRALLOC_AHB, w, h, r);
|
|
||||||
else
|
|
||||||
note_zero_copy_fallback(ls, ls->dmabuf_buf, ZERO_COPY_AHB_PRESENT_FAILED, w, h, r);
|
|
||||||
}
|
|
||||||
if (r == 0 && !fg_pass) g_zero_copy_shown = ls;
|
if (r == 0 && !fg_pass) g_zero_copy_shown = ls;
|
||||||
else settle_unwaited();
|
else settle_unwaited();
|
||||||
int ov = 0, ov_done = 0;
|
if (!fg_pass && generated >= 0 && r != 0 && li >= 0)
|
||||||
if (!fg_pass && generated >= 0 && r != 0 && li >= 0) {
|
r = fx_on ? sc_layer_present_pass(&dl.d[li], 1, w, h)
|
||||||
if (fx_on) {
|
: sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL);
|
||||||
r = sc_layer_present_pass(&dl.d[li], 1, w, h);
|
|
||||||
} else {
|
|
||||||
r = sc_layer_present(dl.d[li].img, w, h, ld, ls ? droiddeck_surface_color(ls) : NULL,
|
|
||||||
over == 1 ? &dl.d[li + 1] : NULL, &ov);
|
|
||||||
ov_done = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (r == 0) {
|
if (r == 0) {
|
||||||
if (ls) ls->drawn = 1;
|
if (ls) ls->drawn = 1;
|
||||||
int go[8];
|
int go[8], ov = 0;
|
||||||
if (!ov_done && over == 1 && li >= 0 && vkp_map_draw(&dl.d[li + 1], go))
|
if (over == 1 && li >= 0 && vkp_map_draw(&dl.d[li + 1], go))
|
||||||
ov = sc_layer_present_overlay(dl.d[li + 1].img, go, dl.d[li + 1].blend) == 0 ? 1 : -1;
|
ov = sc_layer_present_overlay(dl.d[li + 1].img, go, dl.d[li + 1].blend) == 0 ? 1 : -1;
|
||||||
if (ov <= 0) sc_layer_hide_overlay();
|
if (ov <= 0) sc_layer_hide_overlay();
|
||||||
if (ov < 0) {
|
if (ov < 0) {
|
||||||
@@ -4822,15 +4375,11 @@ static void output_resized(void) {
|
|||||||
wl_display_flush_clients(g_display);
|
wl_display_flush_clients(g_display);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dispatch_input(int fd, int remaining) {
|
static int on_input_readable(int fd, uint32_t mask, void *data) {
|
||||||
struct input_msg m;
|
struct input_msg m;
|
||||||
int vsync = 0;
|
int vsync = 0;
|
||||||
int64_t vsync_ns = 0;
|
int64_t vsync_ns = 0;
|
||||||
while (remaining != 0) {
|
while (read(fd, &m, sizeof(m)) == (ssize_t)sizeof(m)) {
|
||||||
ssize_t n = read(fd, &m, sizeof(m));
|
|
||||||
if (n < 0 && errno == EINTR) continue;
|
|
||||||
if (n != (ssize_t)sizeof(m)) break;
|
|
||||||
if (remaining > 0) --remaining;
|
|
||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case 1: deliver_key(&m); break;
|
case 1: deliver_key(&m); break;
|
||||||
case 2: pointer_event(m.p1, m.p2, 0, 0); break;
|
case 2: pointer_event(m.p1, m.p2, 0, 0); break;
|
||||||
@@ -4872,27 +4421,9 @@ static void dispatch_input(int fd, int remaining) {
|
|||||||
wl_display_flush_clients(g_display);
|
wl_display_flush_clients(g_display);
|
||||||
}
|
}
|
||||||
if (vsync) on_vsync(vsync_ns);
|
if (vsync) on_vsync(vsync_ns);
|
||||||
}
|
|
||||||
|
|
||||||
static int on_input_readable(int fd, uint32_t mask, void *data) {
|
|
||||||
dispatch_input(fd, -1);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void droiddeck_dispatch_pending_input(void) {
|
|
||||||
int fd = g_input_pipe[0];
|
|
||||||
if (fd < 0) return;
|
|
||||||
|
|
||||||
int bytes;
|
|
||||||
int result;
|
|
||||||
do {
|
|
||||||
result = ioctl(fd, FIONREAD, &bytes);
|
|
||||||
} while (result < 0 && errno == EINTR);
|
|
||||||
if (result == 0 && bytes >= (int)sizeof(struct input_msg)) {
|
|
||||||
dispatch_input(fd, bytes / (int)sizeof(struct input_msg));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void droiddeck_wayland_set_scale_mode(int mode, int alignment) {
|
void droiddeck_wayland_set_scale_mode(int mode, int alignment) {
|
||||||
if (g_input_pipe[1] < 0) {
|
if (g_input_pipe[1] < 0) {
|
||||||
vk_present_set_scale_mode(mode, alignment);
|
vk_present_set_scale_mode(mode, alignment);
|
||||||
@@ -5012,12 +4543,6 @@ const char *droiddeck_client_name(struct wl_client *client) { return client_name
|
|||||||
struct wl_display *droiddeck_get_display(void) { return g_display; }
|
struct wl_display *droiddeck_get_display(void) { return g_display; }
|
||||||
void droiddeck_request_redraw(void) { schedule_render(); }
|
void droiddeck_request_redraw(void) { schedule_render(); }
|
||||||
|
|
||||||
void droiddeck_set_mirror_capture(int on) {
|
|
||||||
if (g_mirror_capture == on) return;
|
|
||||||
g_mirror_capture = on;
|
|
||||||
schedule_render();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wl_resource *droiddeck_ime_target(void) {
|
struct wl_resource *droiddeck_ime_target(void) {
|
||||||
struct surface *s;
|
struct surface *s;
|
||||||
if (g_ime_click && g_ime_click->mapped) return g_ime_click->resource;
|
if (g_ime_click && g_ime_click->mapped) return g_ime_click->resource;
|
||||||
@@ -5035,11 +4560,6 @@ void droiddeck_surface_scene_origin(struct wl_resource *surface, int *x, int *y)
|
|||||||
|
|
||||||
void droiddeck_inject_key(uint32_t evdev, int pressed) { key_event(evdev, pressed); }
|
void droiddeck_inject_key(uint32_t evdev, int pressed) { key_event(evdev, pressed); }
|
||||||
|
|
||||||
int droiddeck_key_is_down(uint32_t evdev) {
|
|
||||||
return evdev < sizeof(g_keys_down) * 8 &&
|
|
||||||
(g_keys_down[evdev >> 3] & (1u << (evdev & 7))) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static struct wl_event_source *g_stats_timer;
|
static struct wl_event_source *g_stats_timer;
|
||||||
volatile unsigned g_zero_copy_last;
|
volatile unsigned g_zero_copy_last;
|
||||||
@@ -5049,7 +4569,6 @@ static int on_stats_timer(void *data) {
|
|||||||
struct surface *s;
|
struct surface *s;
|
||||||
wl_list_for_each(s, &g_toplevels, toplevel_link) windows++;
|
wl_list_for_each(s, &g_toplevels, toplevel_link) windows++;
|
||||||
unsigned zero_copy = ahb_swapchain_stats_take();
|
unsigned zero_copy = ahb_swapchain_stats_take();
|
||||||
unsigned verified = ahb_swapchain_producer_fence_stats_take();
|
|
||||||
unsigned layer_frames = sc_layer_frames_take();
|
unsigned layer_frames = sc_layer_frames_take();
|
||||||
g_zero_copy_last = zero_copy;
|
g_zero_copy_last = zero_copy;
|
||||||
unsigned generated = vkp_framegen_stats_take();
|
unsigned generated = vkp_framegen_stats_take();
|
||||||
@@ -5058,8 +4577,7 @@ static int on_stats_timer(void *data) {
|
|||||||
int off = 0;
|
int off = 0;
|
||||||
if (g_zero_copy || zero_copy) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u zero-copy frames", zero_copy);
|
if (g_zero_copy || zero_copy) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u zero-copy frames", zero_copy);
|
||||||
if (layer_frames) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u layer frames", layer_frames);
|
if (layer_frames) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u layer frames", layer_frames);
|
||||||
if (generated) off += snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u generated frames", generated);
|
if (generated) snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u generated frames", generated);
|
||||||
if (verified) snprintf(extra + off, sizeof(extra) - (size_t)off, " | %u verified acquire frames", verified);
|
|
||||||
droiddeck_log("stats", "last 10 s: %u frames on screen (%.1f fps) | %u GPU frames from games | %u window redraws | %d windows open%s",
|
droiddeck_log("stats", "last 10 s: %u frames on screen (%.1f fps) | %u GPU frames from games | %u window redraws | %d windows open%s",
|
||||||
g_stat_frames + generated, (g_stat_frames + generated) / 10.0, g_stat_dmabuf, g_stat_shm, windows, extra);
|
g_stat_frames + generated, (g_stat_frames + generated) / 10.0, g_stat_dmabuf, g_stat_shm, windows, extra);
|
||||||
}
|
}
|
||||||
@@ -5260,12 +4778,6 @@ int droiddeck_wayland_run(void) {
|
|||||||
wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relative_pointer_manager);
|
wl_global_create(display, &zwp_relative_pointer_manager_v1_interface, 1, NULL, bind_relative_pointer_manager);
|
||||||
droiddeck_ext_init(display);
|
droiddeck_ext_init(display);
|
||||||
ahb_swapchain_init(display);
|
ahb_swapchain_init(display);
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
if (ahb_swapchain_advertised()) {
|
|
||||||
wl_display_set_global_filter(display, frame_acquire_global_filter, NULL);
|
|
||||||
wl_global_create(display, &droiddeck_frame_acquire_v1_interface, 1, NULL, bind_frame_acquire);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
display_buffers_init(display);
|
display_buffers_init(display);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,40 +62,8 @@ struct entry {
|
|||||||
static struct wl_list g_entries;
|
static struct wl_list g_entries;
|
||||||
static struct wl_event_loop *g_loop;
|
static struct wl_event_loop *g_loop;
|
||||||
static uint64_t g_next_id = 1;
|
static uint64_t g_next_id = 1;
|
||||||
|
static int g_refused_logged;
|
||||||
static int g_ubwc_promised;
|
static int g_ubwc_promised;
|
||||||
|
|
||||||
#define DISPLAY_BUFFER_MISMATCH_SIGNATURES 64u
|
|
||||||
struct display_buffer_mismatch_signature {
|
|
||||||
uint32_t kind, format, stride, offset;
|
|
||||||
int width, height;
|
|
||||||
uint64_t modifier;
|
|
||||||
};
|
|
||||||
static struct display_buffer_mismatch_signature g_mismatch_signatures[DISPLAY_BUFFER_MISMATCH_SIGNATURES];
|
|
||||||
static uint32_t g_mismatch_signature_count;
|
|
||||||
static int g_mismatch_limit_logged;
|
|
||||||
|
|
||||||
static int mismatch_should_log(const struct dmabuf_buffer *b, uint32_t kind) {
|
|
||||||
const struct display_buffer_mismatch_signature key = {
|
|
||||||
.kind = kind, .format = b->format, .stride = b->stride[0], .offset = b->offset[0],
|
|
||||||
.width = b->width, .height = b->height, .modifier = b->modifier};
|
|
||||||
for (uint32_t i = 0; i < g_mismatch_signature_count; i++) {
|
|
||||||
const struct display_buffer_mismatch_signature *seen = &g_mismatch_signatures[i];
|
|
||||||
if (seen->kind == key.kind && seen->format == key.format && seen->stride == key.stride &&
|
|
||||||
seen->offset == key.offset && seen->width == key.width && seen->height == key.height &&
|
|
||||||
seen->modifier == key.modifier)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (g_mismatch_signature_count >= DISPLAY_BUFFER_MISMATCH_SIGNATURES) {
|
|
||||||
if (!g_mismatch_limit_logged) {
|
|
||||||
g_mismatch_limit_logged = 1;
|
|
||||||
droiddeck_log("layer", "display buffers: further mismatch diagnostics suppressed after %u distinct buffer signatures",
|
|
||||||
DISPLAY_BUFFER_MISMATCH_SIGNATURES);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
g_mismatch_signatures[g_mismatch_signature_count++] = key;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
static int g_ubwc_probed[2];
|
static int g_ubwc_probed[2];
|
||||||
|
|
||||||
static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) {
|
static uint32_t ahb_format_of(uint32_t drm, uint64_t modifier) {
|
||||||
@@ -270,51 +238,16 @@ static void handle_alloc(struct peer *p, const struct display_buffers_request *q
|
|||||||
} else {
|
} else {
|
||||||
if (ahb) AHardwareBuffer_release(ahb);
|
if (ahb) AHardwareBuffer_release(ahb);
|
||||||
fd = -1;
|
fd = -1;
|
||||||
static struct {
|
if (sized && wanted && (compressed || !g_refused_logged)) {
|
||||||
pid_t pid;
|
g_refused_logged = 1;
|
||||||
uint32_t width, height, format, stride, offset, reason;
|
droiddeck_log(compressed ? "error" : "layer", "display buffers: no gralloc buffer matches pid %d's %ux%u "
|
||||||
uint64_t size, modifier;
|
"%c%c%c%c %s layout (stride %u bytes, pixels at %u, %llu bytes; gralloc's layout has pixels at "
|
||||||
} refused[32];
|
"%llu, %llu bytes): %s", (int)p->pid, q->width, q->height,
|
||||||
static unsigned refused_count;
|
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
|
||||||
static int refused_limit_logged;
|
compressed ? "UBWC" : "linear", q->stride, q->offset, (unsigned long long)q->size,
|
||||||
uint32_t reason = !sized ? 1u : !sane ? 2u : !wanted ? 3u :
|
(unsigned long long)(compressed ? ubwc_meta_size(q->width, q->height) : 0),
|
||||||
!ahb_swapchain_advertised() ? 4u :
|
(unsigned long long)(compressed ? ubwc_size(q->width, q->height, q->stride) : q->size),
|
||||||
p->count >= DISPLAY_BUFFERS_MAX_PER_CLIENT ? 5u : 6u;
|
compressed ? "its compressed frames cannot be shown" : "its frames keep the copy path");
|
||||||
int seen = 0;
|
|
||||||
for (unsigned i = 0; i < refused_count; i++) {
|
|
||||||
if (refused[i].pid == p->pid && refused[i].width == q->width && refused[i].height == q->height &&
|
|
||||||
refused[i].format == q->format && refused[i].stride == q->stride && refused[i].offset == q->offset &&
|
|
||||||
refused[i].size == q->size && refused[i].modifier == q->modifier && refused[i].reason == reason) {
|
|
||||||
seen = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!seen && refused_count < 32) {
|
|
||||||
refused[refused_count].pid = p->pid;
|
|
||||||
refused[refused_count].width = q->width;
|
|
||||||
refused[refused_count].height = q->height;
|
|
||||||
refused[refused_count].format = q->format;
|
|
||||||
refused[refused_count].stride = q->stride;
|
|
||||||
refused[refused_count].offset = q->offset;
|
|
||||||
refused[refused_count].size = q->size;
|
|
||||||
refused[refused_count].modifier = q->modifier;
|
|
||||||
refused[refused_count].reason = reason;
|
|
||||||
refused_count++;
|
|
||||||
const char *why = reason == 1 ? "invalid dimensions, format, or stride" :
|
|
||||||
reason == 2 ? "size/offset/layout sanity check failed" :
|
|
||||||
reason == 3 ? "zero-copy or UBWC offering is disabled" :
|
|
||||||
reason == 4 ? "AHardwareBuffer swapchain is not advertised" :
|
|
||||||
reason == 5 ? "per-client allocation limit reached" :
|
|
||||||
"gralloc allocation/fd/size validation failed";
|
|
||||||
droiddeck_log(compressed ? "error" : "layer",
|
|
||||||
"display buffers: allocation refused for pid %d: %s; request %ux%u %c%c%c%c %s stride=%u offset=%u size=%llu modifier=0x%llx (client has %d allocations)",
|
|
||||||
(int)p->pid, why, q->width, q->height,
|
|
||||||
q->format & 0xff, (q->format >> 8) & 0xff, (q->format >> 16) & 0xff, (q->format >> 24) & 0xff,
|
|
||||||
compressed ? "UBWC" : "linear", q->stride, q->offset,
|
|
||||||
(unsigned long long)q->size, (unsigned long long)q->modifier, p->count);
|
|
||||||
} else if (!seen && !refused_limit_logged) {
|
|
||||||
refused_limit_logged = 1;
|
|
||||||
droiddeck_log("layer", "display buffers: further allocation-refusal diagnostics suppressed after 32 signatures");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (reply(p, &r, fd) != 0 && e) entry_free(e);
|
if (reply(p, &r, fd) != 0 && e) entry_free(e);
|
||||||
@@ -366,18 +299,9 @@ static int on_listen(int fd, uint32_t mask, void *data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) {
|
void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, struct dmabuf_buffer *b) {
|
||||||
static int invalid_logged;
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct entry *e;
|
struct entry *e;
|
||||||
if (!g_loop || wl_list_empty(&g_entries)) return;
|
if (!g_loop || wl_list_empty(&g_entries) || b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) return;
|
||||||
if (b->n_planes != 1 || b->offset[0] != 0 || fstat(b->fd[0], &st) != 0) {
|
|
||||||
if (!invalid_logged) {
|
|
||||||
invalid_logged = 1;
|
|
||||||
droiddeck_log("layer", "display buffers: cannot associate %s's DMA-BUF with gralloc (plane count %u; expected one plane at offset 0, or fstat failed)",
|
|
||||||
droiddeck_client_name(c), b->n_planes);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
wl_list_for_each(e, &g_entries, link) {
|
wl_list_for_each(e, &g_entries, link) {
|
||||||
if (e->dev != st.st_dev || e->ino != st.st_ino) continue;
|
if (e->dev != st.st_dev || e->ino != st.st_ino) continue;
|
||||||
AHardwareBuffer_Desc d;
|
AHardwareBuffer_Desc d;
|
||||||
@@ -387,27 +311,11 @@ void display_buffers_match(struct wl_client *c, struct wl_resource *buffer, stru
|
|||||||
(uint32_t)b->height == e->height
|
(uint32_t)b->height == e->height
|
||||||
: (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) &&
|
: (b->modifier == MOD_LINEAR || b->modifier == MOD_INVALID) &&
|
||||||
e->stride == b->stride[0];
|
e->stride == b->stride[0];
|
||||||
const uint32_t expected_format = ahb_format_of(b->format, e->modifier);
|
if (laid_out && e->format == ahb_format_of(b->format, e->modifier) && b->width > 0 && b->height > 0 &&
|
||||||
const int dimensions = b->width > 0 && b->height > 0 &&
|
(uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height)
|
||||||
(uint32_t)b->width <= d.width && (uint32_t)b->height <= d.height;
|
|
||||||
if (laid_out && e->format == expected_format && dimensions) {
|
|
||||||
ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier);
|
ahb_swapchain_adopt(c, buffer, b, e->ahb, e->modifier);
|
||||||
} else if (mismatch_should_log(b, 2)) {
|
|
||||||
droiddeck_log("layer", "display buffers: gralloc DMA-BUF identity matched but layout was rejected for %s: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; gralloc %ux%u stride %u format 0x%x, expected format 0x%x (layout %s, dimensions %s)",
|
|
||||||
droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff,
|
|
||||||
(b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height,
|
|
||||||
b->stride[0], b->offset[0], (unsigned long long)b->modifier,
|
|
||||||
e->width, e->height, e->stride, e->format, expected_format,
|
|
||||||
laid_out ? "ok" : "mismatch", dimensions ? "ok" : "mismatch");
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mismatch_should_log(b, 1)) {
|
|
||||||
droiddeck_log("layer", "display buffers: no registered gralloc allocation matches %s's DMA-BUF identity: %c%c%c%c %dx%d stride %u offset %u modifier 0x%llx; imported normally, copy path only",
|
|
||||||
droiddeck_client_name(c), b->format & 0xff, (b->format >> 8) & 0xff,
|
|
||||||
(b->format >> 16) & 0xff, (b->format >> 24) & 0xff, b->width, b->height,
|
|
||||||
b->stride[0], b->offset[0], (unsigned long long)b->modifier);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_buffers_init(struct wl_display *display) {
|
void display_buffers_init(struct wl_display *display) {
|
||||||
|
|||||||
@@ -4,14 +4,12 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <linux/input-event-codes.h>
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include "droiddeck_ext.h"
|
#include "droiddeck_ext.h"
|
||||||
#include "ahb_swapchain.h"
|
#include "ahb_swapchain.h"
|
||||||
#include "droiddeck_color.h"
|
#include "droiddeck_color.h"
|
||||||
|
|
||||||
enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT, HOST_KEY, HOST_SELECT_GAME_FIELD, HOST_MIRROR_CAPTURE };
|
enum host_kind { HOST_CLIPBOARD = 1, HOST_TEXT_COMMIT, HOST_TEXT_PREEDIT, HOST_TEXT_DELETE, HOST_ZERO_COPY, HOST_HDR_OUTPUT };
|
||||||
|
|
||||||
struct host_msg {
|
struct host_msg {
|
||||||
enum host_kind kind;
|
enum host_kind kind;
|
||||||
@@ -25,32 +23,6 @@ static pthread_mutex_t g_mu = PTHREAD_MUTEX_INITIALIZER;
|
|||||||
static struct host_msg *g_head, *g_tail;
|
static struct host_msg *g_head, *g_tail;
|
||||||
static int g_wake[2] = {-1, -1};
|
static int g_wake[2] = {-1, -1};
|
||||||
|
|
||||||
/* Compositor-thread-only fallback ordering state. */
|
|
||||||
static int g_pending_token, g_pending_submit;
|
|
||||||
static int g_fallback_failed;
|
|
||||||
static int g_next_token = 1;
|
|
||||||
static struct host_msg *g_deferred_head, *g_deferred_tail;
|
|
||||||
static size_t g_deferred_count, g_deferred_bytes;
|
|
||||||
static int g_deferred_overflow;
|
|
||||||
static int g_completed_token, g_completed_result;
|
|
||||||
|
|
||||||
#define DROIDDECK_EVDEV_KEY_MAX 768
|
|
||||||
#define DROIDDECK_TEXT_DEFERRED_LIMIT 256
|
|
||||||
#define DROIDDECK_TEXT_DEFERRED_BYTES (256 * 1024)
|
|
||||||
static unsigned char g_ordered_key_down[DROIDDECK_EVDEV_KEY_MAX];
|
|
||||||
|
|
||||||
void droiddeck_host_text_input_fallback_complete(int token, int result) {
|
|
||||||
pthread_mutex_lock(&g_mu);
|
|
||||||
g_completed_token = token;
|
|
||||||
g_completed_result = result;
|
|
||||||
pthread_mutex_unlock(&g_mu);
|
|
||||||
if (g_wake[1] >= 0) {
|
|
||||||
char c = 1;
|
|
||||||
ssize_t n = write(g_wake[1], &c, 1);
|
|
||||||
(void)n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void host_post(enum host_kind kind, const char *text, size_t len, int a, int b) {
|
static void host_post(enum host_kind kind, const char *text, size_t len, int a, int b) {
|
||||||
struct host_msg *m = calloc(1, sizeof(*m));
|
struct host_msg *m = calloc(1, sizeof(*m));
|
||||||
if (!m) return;
|
if (!m) return;
|
||||||
@@ -79,9 +51,6 @@ void droiddeck_host_clipboard_text(const char *utf8, int len) {
|
|||||||
void droiddeck_host_text_commit(const char *utf8, int len) {
|
void droiddeck_host_text_commit(const char *utf8, int len) {
|
||||||
host_post(HOST_TEXT_COMMIT, utf8, len > 0 ? (size_t)len : 0, 0, 0);
|
host_post(HOST_TEXT_COMMIT, utf8, len > 0 ? (size_t)len : 0, 0, 0);
|
||||||
}
|
}
|
||||||
void droiddeck_host_text_commit_and_submit(const char *utf8, int len) {
|
|
||||||
if (len > 0) host_post(HOST_TEXT_COMMIT, utf8, (size_t)len, 1, 0);
|
|
||||||
}
|
|
||||||
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end) {
|
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end) {
|
||||||
host_post(HOST_TEXT_PREEDIT, utf8, len > 0 ? (size_t)len : 0, cursor_begin, cursor_end);
|
host_post(HOST_TEXT_PREEDIT, utf8, len > 0 ? (size_t)len : 0, cursor_begin, cursor_end);
|
||||||
}
|
}
|
||||||
@@ -91,179 +60,26 @@ void droiddeck_host_text_delete(int before, int after) {
|
|||||||
void droiddeck_host_zero_copy(int on, int live) {
|
void droiddeck_host_zero_copy(int on, int live) {
|
||||||
host_post(HOST_ZERO_COPY, NULL, 0, on, live);
|
host_post(HOST_ZERO_COPY, NULL, 0, on, live);
|
||||||
}
|
}
|
||||||
void droiddeck_host_mirror_capture(int on) {
|
|
||||||
host_post(HOST_MIRROR_CAPTURE, NULL, 0, on, 0);
|
|
||||||
}
|
|
||||||
void droiddeck_host_hdr_output(int on) {
|
void droiddeck_host_hdr_output(int on) {
|
||||||
host_post(HOST_HDR_OUTPUT, NULL, 0, on, 0);
|
host_post(HOST_HDR_OUTPUT, NULL, 0, on, 0);
|
||||||
}
|
}
|
||||||
void droiddeck_host_key(int evdev, int state) {
|
|
||||||
host_post(HOST_KEY, NULL, 0, evdev, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
void droiddeck_host_select_game_field(int copy) {
|
|
||||||
host_post(HOST_SELECT_GAME_FIELD, NULL, 0, copy, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void tap_unheld_key(uint32_t key) {
|
|
||||||
if (droiddeck_key_is_down(key)) return;
|
|
||||||
droiddeck_inject_key(key, 1);
|
|
||||||
droiddeck_inject_key(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void select_game_field(int copy) {
|
|
||||||
/* Apply pending raw releases before using the compositor's held-key state. */
|
|
||||||
droiddeck_dispatch_pending_input();
|
|
||||||
int temporary_ctrl = !droiddeck_key_is_down(KEY_LEFTCTRL) && !droiddeck_key_is_down(KEY_RIGHTCTRL);
|
|
||||||
if (temporary_ctrl) droiddeck_inject_key(KEY_LEFTCTRL, 1);
|
|
||||||
tap_unheld_key(KEY_A);
|
|
||||||
if (copy) tap_unheld_key(KEY_C);
|
|
||||||
if (temporary_ctrl) droiddeck_inject_key(KEY_LEFTCTRL, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void restore_deferred_to_front(void) {
|
|
||||||
if (g_deferred_head) {
|
|
||||||
g_deferred_tail->next = g_head;
|
|
||||||
if (!g_head) g_tail = g_deferred_tail;
|
|
||||||
g_head = g_deferred_head;
|
|
||||||
g_deferred_head = g_deferred_tail = NULL;
|
|
||||||
g_deferred_count = g_deferred_bytes = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Only suppress the queued submit for this commit, not a later commit or a held-key release. */
|
|
||||||
static void discard_queued_submit(void) {
|
|
||||||
struct host_msg *prev = NULL;
|
|
||||||
struct host_msg *m = g_head;
|
|
||||||
int enter_held = g_ordered_key_down[KEY_ENTER];
|
|
||||||
int key_pad_enter_held = g_ordered_key_down[KEY_KPENTER];
|
|
||||||
while (m) {
|
|
||||||
int soft_submit = 0;
|
|
||||||
if (m->kind == HOST_TEXT_COMMIT) {
|
|
||||||
if (m->a || m->len == 0) break;
|
|
||||||
soft_submit = 1;
|
|
||||||
size_t i = 0;
|
|
||||||
for (; i < m->len; i++) {
|
|
||||||
char c = m->text[i];
|
|
||||||
if (c != '\r' && c != '\n') soft_submit = 0;
|
|
||||||
if (c != '\r' && c != '\n' && c != '\b' && c != '\t' && c != 0x7f) break;
|
|
||||||
}
|
|
||||||
if (i != m->len) break;
|
|
||||||
}
|
|
||||||
struct host_msg *next = m->next;
|
|
||||||
int *held = m->a == KEY_ENTER ? &enter_held : m->a == KEY_KPENTER ? &key_pad_enter_held : NULL;
|
|
||||||
if (soft_submit || (m->kind == HOST_KEY && held && (m->b != 0 || !*held))) {
|
|
||||||
if (prev) prev->next = next; else g_head = next;
|
|
||||||
if (g_tail == m) g_tail = prev;
|
|
||||||
free(m->text);
|
|
||||||
free(m);
|
|
||||||
} else {
|
|
||||||
if (m->kind == HOST_KEY && held) *held = 0;
|
|
||||||
prev = m;
|
|
||||||
}
|
|
||||||
m = next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int release_held_key(const struct host_msg *m) {
|
|
||||||
int k = m->a;
|
|
||||||
if (m->kind != HOST_KEY || m->b != 0 || k < 0 || k >= DROIDDECK_EVDEV_KEY_MAX ||
|
|
||||||
!g_ordered_key_down[k]) return 0;
|
|
||||||
g_ordered_key_down[k] = 0;
|
|
||||||
droiddeck_inject_key((uint32_t)k, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void discard_deferred_input(void) {
|
|
||||||
struct host_msg *m = g_deferred_head;
|
|
||||||
while (m) {
|
|
||||||
struct host_msg *next = m->next;
|
|
||||||
release_held_key(m);
|
|
||||||
free(m->text);
|
|
||||||
free(m);
|
|
||||||
m = next;
|
|
||||||
}
|
|
||||||
g_deferred_head = g_deferred_tail = NULL;
|
|
||||||
g_deferred_count = g_deferred_bytes = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int on_wake(int fd, uint32_t mask, void *data) {
|
static int on_wake(int fd, uint32_t mask, void *data) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
while (read(fd, buf, sizeof(buf)) > 0) {}
|
while (read(fd, buf, sizeof(buf)) > 0) {}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int deferred = 0, submit = 0;
|
|
||||||
pthread_mutex_lock(&g_mu);
|
pthread_mutex_lock(&g_mu);
|
||||||
if (g_pending_token != 0 && g_completed_token == g_pending_token) {
|
|
||||||
int result = g_completed_result;
|
|
||||||
g_completed_token = 0;
|
|
||||||
restore_deferred_to_front();
|
|
||||||
if (result != DROIDDECK_TEXT_DELIVERED) discard_queued_submit();
|
|
||||||
if (result == DROIDDECK_TEXT_UNRESOLVED) {
|
|
||||||
g_fallback_failed = 1;
|
|
||||||
} else {
|
|
||||||
if (result == DROIDDECK_TEXT_DELIVERED) submit = g_pending_submit;
|
|
||||||
g_pending_submit = 0;
|
|
||||||
g_pending_token = 0;
|
|
||||||
g_fallback_failed = 0;
|
|
||||||
g_deferred_overflow = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
struct host_msg *m = g_head;
|
struct host_msg *m = g_head;
|
||||||
if (m) { g_head = m->next; if (!g_head) g_tail = NULL; m->next = NULL; }
|
if (m) { g_head = m->next; if (!g_head) g_tail = NULL; }
|
||||||
pthread_mutex_unlock(&g_mu);
|
pthread_mutex_unlock(&g_mu);
|
||||||
if (submit) tap_unheld_key(KEY_ENTER);
|
|
||||||
if (!m) break;
|
if (!m) break;
|
||||||
if (g_pending_token != 0 &&
|
|
||||||
(m->kind == HOST_TEXT_COMMIT || m->kind == HOST_TEXT_PREEDIT ||
|
|
||||||
m->kind == HOST_TEXT_DELETE || m->kind == HOST_KEY ||
|
|
||||||
m->kind == HOST_SELECT_GAME_FIELD)) {
|
|
||||||
int released_during_recovery = g_fallback_failed && release_held_key(m);
|
|
||||||
if (released_during_recovery || g_deferred_overflow ||
|
|
||||||
g_deferred_count == DROIDDECK_TEXT_DEFERRED_LIMIT ||
|
|
||||||
m->len > DROIDDECK_TEXT_DEFERRED_BYTES - g_deferred_bytes) {
|
|
||||||
if (!released_during_recovery) {
|
|
||||||
/* An incomplete queue could replay a submit or lose a paired release. */
|
|
||||||
if (!g_deferred_overflow)
|
|
||||||
droiddeck_log("text-input", "deferred input exceeded the recovery queue limit");
|
|
||||||
discard_deferred_input();
|
|
||||||
release_held_key(m);
|
|
||||||
g_deferred_overflow = 1;
|
|
||||||
}
|
|
||||||
free(m->text);
|
|
||||||
free(m);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (g_deferred_tail) g_deferred_tail->next = m; else g_deferred_head = m;
|
|
||||||
g_deferred_tail = m;
|
|
||||||
g_deferred_count++;
|
|
||||||
g_deferred_bytes += m->len;
|
|
||||||
deferred = 1;
|
|
||||||
}
|
|
||||||
if (deferred) continue;
|
|
||||||
switch (m->kind) {
|
switch (m->kind) {
|
||||||
case HOST_CLIPBOARD:
|
case HOST_CLIPBOARD:
|
||||||
clipboard_host_text(m->text, m->len);
|
clipboard_host_text(m->text, m->len);
|
||||||
m->text = NULL;
|
m->text = NULL;
|
||||||
break;
|
break;
|
||||||
case HOST_TEXT_COMMIT:
|
case HOST_TEXT_COMMIT:
|
||||||
if (!text_input_host_commit(m->text ? m->text : "", m->len)) {
|
text_input_host_commit(m->text ? m->text : "", m->len);
|
||||||
int token = 0;
|
|
||||||
if (g_next_token == INT_MAX) g_next_token = 1;
|
|
||||||
else g_next_token++;
|
|
||||||
token = g_next_token;
|
|
||||||
g_pending_token = 0;
|
|
||||||
if (droiddeck_on_text_input_fallback(m->text ? m->text : "", (int)m->len, token)) {
|
|
||||||
g_pending_token = token;
|
|
||||||
g_pending_submit = m->a;
|
|
||||||
} else {
|
|
||||||
droiddeck_log("text-input", "fallback had no accepting Android listener");
|
|
||||||
pthread_mutex_lock(&g_mu);
|
|
||||||
discard_queued_submit();
|
|
||||||
pthread_mutex_unlock(&g_mu);
|
|
||||||
}
|
|
||||||
} else if (m->a) {
|
|
||||||
tap_unheld_key(KEY_ENTER);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case HOST_TEXT_PREEDIT:
|
case HOST_TEXT_PREEDIT:
|
||||||
text_input_host_preedit(m->text ? m->text : "", m->len, m->a, m->b);
|
text_input_host_preedit(m->text ? m->text : "", m->len, m->a, m->b);
|
||||||
@@ -274,25 +90,9 @@ static int on_wake(int fd, uint32_t mask, void *data) {
|
|||||||
case HOST_ZERO_COPY:
|
case HOST_ZERO_COPY:
|
||||||
ahb_swapchain_set_mode(m->a, m->b);
|
ahb_swapchain_set_mode(m->a, m->b);
|
||||||
break;
|
break;
|
||||||
case HOST_MIRROR_CAPTURE:
|
|
||||||
droiddeck_set_mirror_capture(m->a);
|
|
||||||
break;
|
|
||||||
case HOST_HDR_OUTPUT:
|
case HOST_HDR_OUTPUT:
|
||||||
droiddeck_color_set_output(m->a);
|
droiddeck_color_set_output(m->a);
|
||||||
break;
|
break;
|
||||||
case HOST_SELECT_GAME_FIELD:
|
|
||||||
select_game_field(m->a);
|
|
||||||
break;
|
|
||||||
case HOST_KEY:
|
|
||||||
if (m->b == 1) {
|
|
||||||
int k = m->a;
|
|
||||||
if (k >= 0 && k < DROIDDECK_EVDEV_KEY_MAX) g_ordered_key_down[k] = 1;
|
|
||||||
} else if (m->b == 0) {
|
|
||||||
int k = m->a;
|
|
||||||
if (k >= 0 && k < DROIDDECK_EVDEV_KEY_MAX) g_ordered_key_down[k] = 0;
|
|
||||||
}
|
|
||||||
droiddeck_inject_key((uint32_t)m->a, m->b);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
free(m->text);
|
free(m->text);
|
||||||
free(m);
|
free(m);
|
||||||
|
|||||||
@@ -15,36 +15,22 @@ struct wl_display *droiddeck_get_display(void);
|
|||||||
struct wl_resource *droiddeck_ime_target(void);
|
struct wl_resource *droiddeck_ime_target(void);
|
||||||
void droiddeck_surface_scene_origin(struct wl_resource *surface, int *x, int *y);
|
void droiddeck_surface_scene_origin(struct wl_resource *surface, int *x, int *y);
|
||||||
void droiddeck_inject_key(uint32_t evdev, int pressed);
|
void droiddeck_inject_key(uint32_t evdev, int pressed);
|
||||||
int droiddeck_key_is_down(uint32_t evdev);
|
|
||||||
void droiddeck_dispatch_pending_input(void);
|
|
||||||
|
|
||||||
void droiddeck_on_clipboard_text(const char *utf8, int len);
|
void droiddeck_on_clipboard_text(const char *utf8, int len);
|
||||||
int droiddeck_on_text_input_fallback(const char *utf8, int len, int token);
|
|
||||||
void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h);
|
void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h);
|
||||||
|
|
||||||
|
|
||||||
void droiddeck_host_clipboard_text(const char *utf8, int len);
|
void droiddeck_host_clipboard_text(const char *utf8, int len);
|
||||||
void droiddeck_host_text_commit(const char *utf8, int len);
|
void droiddeck_host_text_commit(const char *utf8, int len);
|
||||||
void droiddeck_host_text_commit_and_submit(const char *utf8, int len);
|
|
||||||
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end);
|
void droiddeck_host_text_preedit(const char *utf8, int len, int cursor_begin, int cursor_end);
|
||||||
void droiddeck_host_text_delete(int before, int after);
|
void droiddeck_host_text_delete(int before, int after);
|
||||||
void droiddeck_host_zero_copy(int on, int live);
|
void droiddeck_host_zero_copy(int on, int live);
|
||||||
void droiddeck_host_mirror_capture(int on);
|
|
||||||
void droiddeck_set_mirror_capture(int on);
|
|
||||||
void droiddeck_host_hdr_output(int on);
|
void droiddeck_host_hdr_output(int on);
|
||||||
void droiddeck_host_key(int evdev, int state);
|
|
||||||
void droiddeck_host_select_game_field(int copy);
|
|
||||||
enum droiddeck_text_input_result {
|
|
||||||
DROIDDECK_TEXT_NOT_DELIVERED = 0,
|
|
||||||
DROIDDECK_TEXT_DELIVERED = 1,
|
|
||||||
DROIDDECK_TEXT_UNRESOLVED = 2,
|
|
||||||
};
|
|
||||||
void droiddeck_host_text_input_fallback_complete(int token, int result);
|
|
||||||
|
|
||||||
void clipboard_init(struct wl_display *display);
|
void clipboard_init(struct wl_display *display);
|
||||||
void clipboard_host_text(char *utf8, size_t len);
|
void clipboard_host_text(char *utf8, size_t len);
|
||||||
void text_input_init(struct wl_display *display);
|
void text_input_init(struct wl_display *display);
|
||||||
int text_input_host_commit(const char *utf8, size_t len);
|
void text_input_host_commit(const char *utf8, size_t len);
|
||||||
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end);
|
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end);
|
||||||
void text_input_host_delete(int before, int after);
|
void text_input_host_delete(int before, int after);
|
||||||
void toplevel_icon_init(struct wl_display *display);
|
void toplevel_icon_init(struct wl_display *display);
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
#include "smaa_edge_frag.h"
|
#include "smaa_edge_frag.h"
|
||||||
#include "smaa_weights_frag.h"
|
#include "smaa_weights_frag.h"
|
||||||
#include "smaa_blend_frag.h"
|
#include "smaa_blend_frag.h"
|
||||||
#include "smaa_tables.h"
|
|
||||||
#include "toon_frag.h"
|
#include "toon_frag.h"
|
||||||
#include "toon_color_frag.h"
|
#include "toon_color_frag.h"
|
||||||
#include "hdr_frag.h"
|
#include "hdr_frag.h"
|
||||||
@@ -197,7 +196,6 @@ struct pc_sgsr { float ndc[4]; float vp[4]; float edge; };
|
|||||||
struct pc_easu { float ndc[4]; uint32_t con0[4], con1[4], con2[4], con3[4]; float outW, outH; };
|
struct pc_easu { float ndc[4]; uint32_t con0[4], con1[4], con2[4], con3[4]; float outW, outH; };
|
||||||
struct pc_rcas { float ndc[4]; uint32_t con[4]; float outW, outH; };
|
struct pc_rcas { float ndc[4]; uint32_t con[4]; float outW, outH; };
|
||||||
struct pc_res { float ndc[4]; float res[2]; float extra; float pad; };
|
struct pc_res { float ndc[4]; float res[2]; float extra; float pad; };
|
||||||
struct pc_smaa { float ndc[4]; float metrics[4]; };
|
|
||||||
struct pc_color { float ndc[4]; float b, c, g, s; };
|
struct pc_color { float ndc[4]; float b, c, g, s; };
|
||||||
struct pc_toon_color {
|
struct pc_toon_color {
|
||||||
float ndc[4]; float res[2]; float b, c, g, s;
|
float ndc[4]; float res[2]; float b, c, g, s;
|
||||||
@@ -232,7 +230,7 @@ static VkDevice g_dev;
|
|||||||
static VkPhysicalDevice g_pd;
|
static VkPhysicalDevice g_pd;
|
||||||
static VkPhysicalDeviceMemoryProperties g_mp;
|
static VkPhysicalDeviceMemoryProperties g_mp;
|
||||||
static int g_ready;
|
static int g_ready;
|
||||||
static VkRenderPass g_rp, g_smaa_edge_rp, g_smaa_weights_rp;
|
static VkRenderPass g_rp, g_smaa_rp;
|
||||||
static VkDescriptorSetLayout g_dsl;
|
static VkDescriptorSetLayout g_dsl;
|
||||||
static VkPipelineLayout g_pl;
|
static VkPipelineLayout g_pl;
|
||||||
static VkDescriptorPool g_dpool;
|
static VkDescriptorPool g_dpool;
|
||||||
@@ -249,9 +247,7 @@ static int g_context;
|
|||||||
#define g_t (g_contexts[g_context].targets)
|
#define g_t (g_contexts[g_context].targets)
|
||||||
#define g_mid (g_contexts[g_context].mid)
|
#define g_mid (g_contexts[g_context].mid)
|
||||||
#define g_nissrc (g_contexts[g_context].nissrc)
|
#define g_nissrc (g_contexts[g_context].nissrc)
|
||||||
static struct fx_target g_smaa_edges, g_smaa_weights, g_smaa_area, g_smaa_search;
|
static struct fx_target g_smaa_edges, g_smaa_weights;
|
||||||
static VkBuffer g_smaa_buf;
|
|
||||||
static VkDeviceMemory g_smaa_mem;
|
|
||||||
/* Half set: NIS = nis_luma prepass (scene rgb + luma in alpha, scene size) into g_nissrc, then
|
/* Half set: NIS = nis_luma prepass (scene rgb + luma in alpha, scene size) into g_nissrc, then
|
||||||
* nis3 gathers its luma from that alpha, its coefficient banks (nis_coef.h) in a uniform buffer
|
* nis3 gathers its luma from that alpha, its coefficient banks (nis_coef.h) in a uniform buffer
|
||||||
* at descriptor set 1 (g_pl_nis = {g_dsl, g_coef_dsl}, same push-constant range as g_pl).
|
* at descriptor set 1 (g_pl_nis = {g_dsl, g_coef_dsl}, same push-constant range as g_pl).
|
||||||
@@ -315,7 +311,6 @@ static void target_destroy(struct fx_target *t) {
|
|||||||
#define FX_TARGET_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | \
|
#define FX_TARGET_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT | \
|
||||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
|
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT)
|
||||||
#define FX_SCRATCH_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
|
#define FX_SCRATCH_USAGE (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT)
|
||||||
#define SMAA_EDGE_FORMAT VK_FORMAT_R8G8_UNORM
|
|
||||||
|
|
||||||
static int target_ensure_format(struct fx_target *t, int w, int h,
|
static int target_ensure_format(struct fx_target *t, int w, int h,
|
||||||
VkImageUsageFlags usage, const char *what,
|
VkImageUsageFlags usage, const char *what,
|
||||||
@@ -323,9 +318,8 @@ static int target_ensure_format(struct fx_target *t, int w, int h,
|
|||||||
if (t->img && t->w == w && t->h == h) return 0;
|
if (t->img && t->w == w && t->h == h) return 0;
|
||||||
target_destroy(t);
|
target_destroy(t);
|
||||||
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
VkImageCreateInfo ii = {.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
|
||||||
/* SMAA's own images need no views in other formats, and the GPU is faster without the flag. */
|
.flags = VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, .imageType = VK_IMAGE_TYPE_2D,
|
||||||
.flags = render_pass == g_rp ? VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT : 0,
|
.format = format, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
|
||||||
.imageType = VK_IMAGE_TYPE_2D, .format = format, .extent = {(uint32_t)w, (uint32_t)h, 1}, .mipLevels = 1,
|
|
||||||
.arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
.arrayLayers = 1, .samples = VK_SAMPLE_COUNT_1_BIT, .tiling = VK_IMAGE_TILING_OPTIMAL,
|
||||||
.usage = usage,
|
.usage = usage,
|
||||||
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
.sharingMode = VK_SHARING_MODE_EXCLUSIVE, .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED};
|
||||||
@@ -343,16 +337,12 @@ static int target_ensure_format(struct fx_target *t, int w, int h,
|
|||||||
(unsigned long long)req.size, (int)r);
|
(unsigned long long)req.size, (int)r);
|
||||||
target_destroy(t); return -1;
|
target_destroy(t); return -1;
|
||||||
}
|
}
|
||||||
r = g_vk.BindImageMemory(g_dev, t->img, t->mem, 0);
|
g_vk.BindImageMemory(g_dev, t->img, t->mem, 0);
|
||||||
if (r != VK_SUCCESS) {
|
|
||||||
droiddeck_log("error", "effects: %s image %dx%d: vkBindImageMemory %d", what, w, h, (int)r);
|
|
||||||
target_destroy(t); return -1;
|
|
||||||
}
|
|
||||||
if (!(t->view = make_view(t->img, format))) { target_destroy(t); return -1; }
|
if (!(t->view = make_view(t->img, format))) { target_destroy(t); return -1; }
|
||||||
VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = render_pass,
|
VkFramebufferCreateInfo fi = {.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO, .renderPass = render_pass,
|
||||||
.attachmentCount = 1, .pAttachments = &t->view, .width = (uint32_t)w,
|
.attachmentCount = 1, .pAttachments = &t->view, .width = (uint32_t)w,
|
||||||
.height = (uint32_t)h, .layers = 1};
|
.height = (uint32_t)h, .layers = 1};
|
||||||
if (render_pass && g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; }
|
if (g_vk.CreateFramebuffer(g_dev, &fi, NULL, &t->fb) != VK_SUCCESS) { target_destroy(t); return -1; }
|
||||||
if (!(t->ds = alloc_ds(t->view))) { target_destroy(t); return -1; }
|
if (!(t->ds = alloc_ds(t->view))) { target_destroy(t); return -1; }
|
||||||
t->w = w; t->h = h;
|
t->w = w; t->h = h;
|
||||||
return 0;
|
return 0;
|
||||||
@@ -376,44 +366,6 @@ void vkp_effects_forget_image(VkImage img) {
|
|||||||
g_context = saved;
|
g_context = saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt) {
|
|
||||||
if (!g_dev || !img || w <= 0 || h <= 0 || fmt == VK_FORMAT_UNDEFINED) return VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
for (int i = 0; i < FX_CONTEXTS; ++i) {
|
|
||||||
struct fx_context *ctx = &g_contexts[i];
|
|
||||||
if (ctx->scene.img == img && ctx->scene.view) return ctx->scene.view;
|
|
||||||
for (int j = 0; j < 2; ++j)
|
|
||||||
if (ctx->targets[j].img == img && ctx->targets[j].view) return ctx->targets[j].view;
|
|
||||||
if (ctx->mid.img == img && ctx->mid.view) return ctx->mid.view;
|
|
||||||
if (ctx->nissrc.img == img && ctx->nissrc.view) return ctx->nissrc.view;
|
|
||||||
}
|
|
||||||
if (g_smaa_edges.img == img && g_smaa_edges.view) return g_smaa_edges.view;
|
|
||||||
if (g_smaa_weights.img == img && g_smaa_weights.view) return g_smaa_weights.view;
|
|
||||||
|
|
||||||
/* The effects chain can bypass every pass and return the compositor's scene image
|
|
||||||
* directly. Keep a view for that image in the existing per-context cache so the
|
|
||||||
* normal image-forget path destroys it before the image itself. */
|
|
||||||
int saved = g_context;
|
|
||||||
g_context = 0;
|
|
||||||
if (g_scene.img != img || g_scene.view == VK_NULL_HANDLE ||
|
|
||||||
g_scene.w != w || g_scene.h != h) {
|
|
||||||
scene_release();
|
|
||||||
VkImageView view = make_view(img, fmt);
|
|
||||||
if (!view) {
|
|
||||||
g_context = saved;
|
|
||||||
return VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
g_scene.img = img;
|
|
||||||
g_scene.view = view;
|
|
||||||
g_scene.w = w;
|
|
||||||
g_scene.h = h;
|
|
||||||
g_scene.ds = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
VkImageView result = g_scene.view;
|
|
||||||
g_context = saved;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_effects_release_generated_sources(void) {
|
void vkp_effects_release_generated_sources(void) {
|
||||||
for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release();
|
for (g_context = 1; g_context < FX_CONTEXTS; g_context++) scene_release();
|
||||||
g_context = 0;
|
g_context = 0;
|
||||||
@@ -471,22 +423,6 @@ static VkPipeline post_pipeline_for_renderpass(VkShaderModule vert,
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The mapped memory of a new host-visible buffer. On failure: NULL, and the caller frees what there is. */
|
|
||||||
static void *host_buffer(VkDeviceSize size, VkBufferUsageFlags usage, VkBuffer *buf, VkDeviceMemory *mem) {
|
|
||||||
VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .size = size,
|
|
||||||
.usage = usage, .sharingMode = VK_SHARING_MODE_EXCLUSIVE};
|
|
||||||
if (g_vk.CreateBuffer(g_dev, &bci, NULL, buf) != VK_SUCCESS) return NULL;
|
|
||||||
VkMemoryRequirements req;
|
|
||||||
g_vk.GetBufferMemoryRequirements(g_dev, *buf, &req);
|
|
||||||
int idx = memtype(req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
|
||||||
if (idx < 0) return NULL;
|
|
||||||
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = req.size, .memoryTypeIndex = (uint32_t)idx};
|
|
||||||
if (g_vk.AllocateMemory(g_dev, &mai, NULL, mem) != VK_SUCCESS) return NULL;
|
|
||||||
if (g_vk.BindBufferMemory(g_dev, *buf, *mem, 0) != VK_SUCCESS) return NULL;
|
|
||||||
void *p = NULL;
|
|
||||||
return g_vk.MapMemory(g_dev, *mem, 0, size, 0, &p) == VK_SUCCESS ? p : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void coef_destroy(void) {
|
static void coef_destroy(void) {
|
||||||
if (g_coef_pool) g_vk.DestroyDescriptorPool(g_dev, g_coef_pool, NULL); /* frees g_coef_ds */
|
if (g_coef_pool) g_vk.DestroyDescriptorPool(g_dev, g_coef_pool, NULL); /* frees g_coef_ds */
|
||||||
if (g_coef_buf) g_vk.DestroyBuffer(g_dev, g_coef_buf, NULL);
|
if (g_coef_buf) g_vk.DestroyBuffer(g_dev, g_coef_buf, NULL);
|
||||||
@@ -508,8 +444,18 @@ static int coef_create(void) {
|
|||||||
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = sets,
|
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = sets,
|
||||||
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
||||||
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl_nis) != VK_SUCCESS) goto fail;
|
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl_nis) != VK_SUCCESS) goto fail;
|
||||||
void *p = host_buffer(4096, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, &g_coef_buf, &g_coef_mem);
|
VkBufferCreateInfo bci = {.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, .size = 4096,
|
||||||
if (!p) goto fail;
|
.usage = VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, .sharingMode = VK_SHARING_MODE_EXCLUSIVE};
|
||||||
|
if (g_vk.CreateBuffer(g_dev, &bci, NULL, &g_coef_buf) != VK_SUCCESS) goto fail;
|
||||||
|
VkMemoryRequirements req;
|
||||||
|
g_vk.GetBufferMemoryRequirements(g_dev, g_coef_buf, &req);
|
||||||
|
int idx = memtype(req.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||||
|
if (idx < 0) goto fail;
|
||||||
|
VkMemoryAllocateInfo mai = {.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO, .allocationSize = req.size, .memoryTypeIndex = (uint32_t)idx};
|
||||||
|
if (g_vk.AllocateMemory(g_dev, &mai, NULL, &g_coef_mem) != VK_SUCCESS) goto fail;
|
||||||
|
if (g_vk.BindBufferMemory(g_dev, g_coef_buf, g_coef_mem, 0) != VK_SUCCESS) goto fail;
|
||||||
|
void *p = NULL;
|
||||||
|
if (g_vk.MapMemory(g_dev, g_coef_mem, 0, 4096, 0, &p) != VK_SUCCESS || !p) goto fail;
|
||||||
memcpy(p, kNisCoefScale, sizeof(kNisCoefScale));
|
memcpy(p, kNisCoefScale, sizeof(kNisCoefScale));
|
||||||
memcpy((char *)p + sizeof(kNisCoefScale), kNisCoefUsm, sizeof(kNisCoefUsm));
|
memcpy((char *)p + sizeof(kNisCoefScale), kNisCoefUsm, sizeof(kNisCoefUsm));
|
||||||
g_vk.UnmapMemory(g_dev, g_coef_mem);
|
g_vk.UnmapMemory(g_dev, g_coef_mem);
|
||||||
@@ -529,29 +475,6 @@ fail:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smaa_tables_destroy(void) {
|
|
||||||
target_destroy(&g_smaa_area); target_destroy(&g_smaa_search);
|
|
||||||
if (g_smaa_buf) g_vk.DestroyBuffer(g_dev, g_smaa_buf, NULL);
|
|
||||||
if (g_smaa_mem) g_vk.FreeMemory(g_dev, g_smaa_mem, NULL);
|
|
||||||
g_smaa_buf = VK_NULL_HANDLE; g_smaa_mem = VK_NULL_HANDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int smaa_tables_ensure(void) {
|
|
||||||
if (g_smaa_buf) return 0;
|
|
||||||
const VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
||||||
unsigned char *p = NULL;
|
|
||||||
if (target_ensure_format(&g_smaa_area, SMAA_AREA_W, SMAA_AREA_H, usage, "SMAA area table",
|
|
||||||
VK_FORMAT_R8G8_UNORM, VK_NULL_HANDLE) == 0 &&
|
|
||||||
target_ensure_format(&g_smaa_search, SMAA_SEARCH_W, SMAA_SEARCH_H, usage, "SMAA search table",
|
|
||||||
VK_FORMAT_R8_UNORM, VK_NULL_HANDLE) == 0)
|
|
||||||
p = host_buffer(sizeof(kSmaaArea) + sizeof(kSmaaSearch), VK_BUFFER_USAGE_TRANSFER_SRC_BIT, &g_smaa_buf, &g_smaa_mem);
|
|
||||||
if (!p) { smaa_tables_destroy(); return -1; }
|
|
||||||
memcpy(p, kSmaaArea, sizeof(kSmaaArea));
|
|
||||||
memcpy(p + sizeof(kSmaaArea), kSmaaSearch, sizeof(kSmaaSearch));
|
|
||||||
g_vk.UnmapMemory(g_dev, g_smaa_mem);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* nis_luma keeps luma in the target's alpha: only formats with at least 8 alpha bits (not the
|
/* nis_luma keeps luma in the target's alpha: only formats with at least 8 alpha bits (not the
|
||||||
* 2-bit alpha of the 10-bit HDR composition format) can hold it. */
|
* 2-bit alpha of the 10-bit HDR composition format) can hold it. */
|
||||||
static int fx_alpha_holds_luma(VkFormat f) {
|
static int fx_alpha_holds_luma(VkFormat f) {
|
||||||
@@ -579,19 +502,16 @@ static void objects_destroy(void) {
|
|||||||
}
|
}
|
||||||
g_context = saved;
|
g_context = saved;
|
||||||
target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights);
|
target_destroy(&g_smaa_edges); target_destroy(&g_smaa_weights);
|
||||||
smaa_tables_destroy();
|
|
||||||
for (int i = 0; i < P_COUNT; i++) { if (g_pipe[i]) g_vk.DestroyPipeline(g_dev, g_pipe[i], NULL); g_pipe[i] = VK_NULL_HANDLE; }
|
for (int i = 0; i < P_COUNT; i++) { if (g_pipe[i]) g_vk.DestroyPipeline(g_dev, g_pipe[i], NULL); g_pipe[i] = VK_NULL_HANDLE; }
|
||||||
if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL);
|
if (g_dpool) g_vk.DestroyDescriptorPool(g_dev, g_dpool, NULL);
|
||||||
if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL);
|
if (g_pl) g_vk.DestroyPipelineLayout(g_dev, g_pl, NULL);
|
||||||
coef_destroy();
|
coef_destroy();
|
||||||
if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL);
|
if (g_dsl) g_vk.DestroyDescriptorSetLayout(g_dev, g_dsl, NULL);
|
||||||
if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL);
|
if (g_sampler) g_vk.DestroySampler(g_dev, g_sampler, NULL);
|
||||||
if (g_smaa_edge_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_edge_rp, NULL);
|
if (g_smaa_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_rp, NULL);
|
||||||
if (g_smaa_weights_rp) g_vk.DestroyRenderPass(g_dev, g_smaa_weights_rp, NULL);
|
|
||||||
if (g_rp) g_vk.DestroyRenderPass(g_dev, g_rp, NULL);
|
if (g_rp) g_vk.DestroyRenderPass(g_dev, g_rp, NULL);
|
||||||
g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE;
|
g_dpool = VK_NULL_HANDLE; g_pl = VK_NULL_HANDLE; g_dsl = VK_NULL_HANDLE;
|
||||||
g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE;
|
g_sampler = VK_NULL_HANDLE; g_rp = VK_NULL_HANDLE; g_smaa_rp = VK_NULL_HANDLE;
|
||||||
g_smaa_edge_rp = VK_NULL_HANDLE; g_smaa_weights_rp = VK_NULL_HANDLE;
|
|
||||||
g_nis_fast = 0; g_nis_attempted = 0; g_upscale_half = 0;
|
g_nis_fast = 0; g_nis_attempted = 0; g_upscale_half = 0;
|
||||||
g_ready = 0;
|
g_ready = 0;
|
||||||
}
|
}
|
||||||
@@ -645,12 +565,9 @@ static int objects_ensure(void) {
|
|||||||
|
|
||||||
VkAttachmentDescription smaa_att = att;
|
VkAttachmentDescription smaa_att = att;
|
||||||
smaa_att.format = FX_FORMAT;
|
smaa_att.format = FX_FORMAT;
|
||||||
smaa_att.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR; /* SMAA.hlsl discards pixels without an edge */
|
|
||||||
VkRenderPassCreateInfo smaa_rci = rci;
|
VkRenderPassCreateInfo smaa_rci = rci;
|
||||||
smaa_rci.pAttachments = &smaa_att;
|
smaa_rci.pAttachments = &smaa_att;
|
||||||
if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_weights_rp) != VK_SUCCESS) goto fail;
|
if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_rp) != VK_SUCCESS) goto fail;
|
||||||
smaa_att.format = SMAA_EDGE_FORMAT;
|
|
||||||
if (g_vk.CreateRenderPass(g_dev, &smaa_rci, NULL, &g_smaa_edge_rp) != VK_SUCCESS) goto fail;
|
|
||||||
|
|
||||||
VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR,
|
VkSamplerCreateInfo sci = {.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO, .magFilter = VK_FILTER_LINEAR,
|
||||||
.minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
|
.minFilter = VK_FILTER_LINEAR, .mipmapMode = VK_SAMPLER_MIPMAP_MODE_NEAREST,
|
||||||
@@ -664,13 +581,13 @@ static int objects_ensure(void) {
|
|||||||
VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b};
|
VkDescriptorSetLayoutCreateInfo dli = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO, .bindingCount = 1, .pBindings = &b};
|
||||||
if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_dsl) != VK_SUCCESS) goto fail;
|
if (g_vk.CreateDescriptorSetLayout(g_dev, &dli, NULL, &g_dsl) != VK_SUCCESS) goto fail;
|
||||||
VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE};
|
VkPushConstantRange pcr = {.stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, .offset = 0, .size = PC_MAX_SIZE};
|
||||||
VkDescriptorSetLayout set_layouts[3] = {g_dsl, g_dsl, g_dsl};
|
VkDescriptorSetLayout set_layouts[2] = {g_dsl, g_dsl};
|
||||||
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 3, .pSetLayouts = set_layouts,
|
VkPipelineLayoutCreateInfo pli = {.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .setLayoutCount = 2, .pSetLayouts = set_layouts,
|
||||||
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
.pushConstantRangeCount = 1, .pPushConstantRanges = &pcr};
|
||||||
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail;
|
if (g_vk.CreatePipelineLayout(g_dev, &pli, NULL, &g_pl) != VK_SUCCESS) goto fail;
|
||||||
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, FX_CONTEXTS * 5 + 4};
|
VkDescriptorPoolSize ps = {VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, FX_CONTEXTS * 5 + 2};
|
||||||
VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
VkDescriptorPoolCreateInfo dpi = {.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO,
|
||||||
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = FX_CONTEXTS * 5 + 4,
|
.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT, .maxSets = FX_CONTEXTS * 5 + 2,
|
||||||
.poolSizeCount = 1, .pPoolSizes = &ps};
|
.poolSizeCount = 1, .pPoolSizes = &ps};
|
||||||
if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail;
|
if (g_vk.CreateDescriptorPool(g_dev, &dpi, NULL, &g_dpool) != VK_SUCCESS) goto fail;
|
||||||
|
|
||||||
@@ -757,8 +674,8 @@ static int pipelines_ensure(int spatial, const struct fx_settings *s) {
|
|||||||
if (s->color_on && !(s->toon && g_fx_fmt == FX_FORMAT)) MK(1, P_COLOR, color_code, "color");
|
if (s->color_on && !(s->toon && g_fx_fmt == FX_FORMAT)) MK(1, P_COLOR, color_code, "color");
|
||||||
if (s->aa_mode == 1 || s->aa_mode == 2) MK(1, P_FXAA, fxaa_code, "fxaa");
|
if (s->aa_mode == 1 || s->aa_mode == 2) MK(1, P_FXAA, fxaa_code, "fxaa");
|
||||||
if (s->aa_mode == 2) {
|
if (s->aa_mode == 2) {
|
||||||
MKL(1, P_SMAA_EDGE, smaa_edge_code, "smaa_edge", g_smaa_edge_rp, g_pl);
|
MKL(1, P_SMAA_EDGE, smaa_edge_code, "smaa_edge", g_smaa_rp, g_pl);
|
||||||
MKL(1, P_SMAA_WEIGHTS, smaa_weights_code, "smaa_weights", g_smaa_weights_rp, g_pl);
|
MKL(1, P_SMAA_WEIGHTS, smaa_weights_code, "smaa_weights", g_smaa_rp, g_pl);
|
||||||
MK(1, P_SMAA_BLEND, smaa_blend_code, "smaa_blend");
|
MK(1, P_SMAA_BLEND, smaa_blend_code, "smaa_blend");
|
||||||
}
|
}
|
||||||
if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) MK(1, P_TOON_COLOR, toon_color_code, "toon_color");
|
if (s->toon && s->color_on && g_fx_fmt == FX_FORMAT) MK(1, P_TOON_COLOR, toon_color_code, "toon_color");
|
||||||
@@ -787,32 +704,14 @@ static void barrier(VkCommandBuffer cmd, VkImage img, VkImageLayout from, VkImag
|
|||||||
g_vk.CmdPipelineBarrier(cmd, src_stage, dst_stage, 0, 0, NULL, 0, NULL, 1, &b);
|
g_vk.CmdPipelineBarrier(cmd, src_stage, dst_stage, 0, 0, NULL, 0, NULL, 1, &b);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The tables are copied into place in every frame: a recorded frame can be dropped before it is submitted. */
|
static void pass_renderpass(VkCommandBuffer cmd, VkRenderPass render_pass,
|
||||||
static void smaa_tables_copy(VkCommandBuffer cmd) {
|
VkPipeline p, struct fx_target *dst, VkDescriptorSet src,
|
||||||
const VkBufferImageCopy area = {.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
const void *pc, uint32_t pcsz) {
|
||||||
.imageExtent = {SMAA_AREA_W, SMAA_AREA_ROWS, 1}};
|
|
||||||
const VkBufferImageCopy search = {.bufferOffset = sizeof(kSmaaArea), .imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
|
||||||
.imageExtent = {SMAA_SEARCH_W, SMAA_SEARCH_H, 1}};
|
|
||||||
const struct { VkImage img; const VkBufferImageCopy *copy; } t[2] = {{g_smaa_area.img, &area}, {g_smaa_search.img, &search}};
|
|
||||||
for (int i = 0; i < 2; i++) {
|
|
||||||
barrier(cmd, t[i].img, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
|
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, 0, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT);
|
|
||||||
g_vk.CmdCopyBufferToImage(cmd, g_smaa_buf, t[i].img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, t[i].copy);
|
|
||||||
barrier(cmd, t[i].img, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
|
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT,
|
|
||||||
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_ACCESS_SHADER_READ_BIT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void pass_sets(VkCommandBuffer cmd, VkRenderPass render_pass, VkPipeline p, struct fx_target *dst,
|
|
||||||
const VkDescriptorSet *src, uint32_t count, const void *pc, uint32_t pcsz) {
|
|
||||||
const VkClearValue clear = {0};
|
|
||||||
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = render_pass, .framebuffer = dst->fb,
|
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = render_pass, .framebuffer = dst->fb,
|
||||||
.renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}},
|
.renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}};
|
||||||
.clearValueCount = 1, .pClearValues = &clear};
|
|
||||||
g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE);
|
g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p);
|
g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p);
|
||||||
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, count, src, 0, NULL);
|
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, 1, &src, 0, NULL);
|
||||||
if (g_nis_fast && p == g_pipe[P_NIS] && g_coef_ds) /* nis3: coefficient banks at set 1 */
|
if (g_nis_fast && p == g_pipe[P_NIS] && g_coef_ds) /* nis3: coefficient banks at set 1 */
|
||||||
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl_nis, 1, 1, &g_coef_ds, 0, NULL);
|
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl_nis, 1, 1, &g_coef_ds, 0, NULL);
|
||||||
g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pcsz, pc);
|
g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pcsz, pc);
|
||||||
@@ -822,7 +721,21 @@ static void pass_sets(VkCommandBuffer cmd, VkRenderPass render_pass, VkPipeline
|
|||||||
|
|
||||||
static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst,
|
static void pass(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst,
|
||||||
VkDescriptorSet src, const void *pc, uint32_t pcsz) {
|
VkDescriptorSet src, const void *pc, uint32_t pcsz) {
|
||||||
pass_sets(cmd, g_rp, p, dst, &src, 1, pc, pcsz);
|
pass_renderpass(cmd, g_rp, p, dst, src, pc, pcsz);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void pass_dual(VkCommandBuffer cmd, VkPipeline p, struct fx_target *dst,
|
||||||
|
VkDescriptorSet src, VkDescriptorSet second,
|
||||||
|
const void *pc, uint32_t pcsz) {
|
||||||
|
VkRenderPassBeginInfo rpi = {.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, .renderPass = g_rp, .framebuffer = dst->fb,
|
||||||
|
.renderArea = {{0, 0}, {(uint32_t)dst->w, (uint32_t)dst->h}}};
|
||||||
|
VkDescriptorSet sets[2] = {src, second};
|
||||||
|
g_vk.CmdBeginRenderPass(cmd, &rpi, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
g_vk.CmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, p);
|
||||||
|
g_vk.CmdBindDescriptorSets(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, g_pl, 0, 2, sets, 0, NULL);
|
||||||
|
g_vk.CmdPushConstants(cmd, g_pl, VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT, 0, pcsz, pc);
|
||||||
|
g_vk.CmdDraw(cmd, 4, 1, 0, 0);
|
||||||
|
g_vk.CmdEndRenderPass(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
static const float FULL_NDC[4] = {-1.0f, -1.0f, 1.0f, 1.0f};
|
||||||
@@ -834,12 +747,6 @@ struct fx_source_state {
|
|||||||
VkAccessFlags access;
|
VkAccessFlags access;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* NIS here is the SDR implementation and is documented for <=2x upscales: other outputs run FSR instead. */
|
|
||||||
static int nis_falls_back(int scene_w, int scene_h, int cw, int ch) {
|
|
||||||
return g_scene_is_pq || cw < scene_w || ch < scene_h || (double)cw > (double)scene_w * 2.0 ||
|
|
||||||
(double)ch > (double)scene_h * 2.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||||
int out_w, int out_h, int *res_w, int *res_h,
|
int out_w, int out_h, int *res_w, int *res_h,
|
||||||
VkImageLayout input_layout, const struct fx_settings *frozen,
|
VkImageLayout input_layout, const struct fx_settings *frozen,
|
||||||
@@ -865,7 +772,11 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
|||||||
const int upscaling = cw > scene_w || ch > scene_h;
|
const int upscaling = cw > scene_w || ch > scene_h;
|
||||||
int spatial = 0;
|
int spatial = 0;
|
||||||
if (spatial_mode(s->scaling) && (s->scaling == 6 || upscaling)) spatial = s->scaling;
|
if (spatial_mode(s->scaling) && (s->scaling == 6 || upscaling)) spatial = s->scaling;
|
||||||
const int nis_fallback = spatial == 7 && nis_falls_back(scene_w, scene_h, cw, ch);
|
/* NIS here is the SDR implementation and is documented for <=2x upscales. */
|
||||||
|
const int nis_fallback = spatial == 7 &&
|
||||||
|
(g_scene_is_pq || cw < scene_w || ch < scene_h ||
|
||||||
|
(double)cw > (double)scene_w * 2.0 ||
|
||||||
|
(double)ch > (double)scene_h * 2.0);
|
||||||
static int last_nis_fallback = 0;
|
static int last_nis_fallback = 0;
|
||||||
const int was_nis_fallback =
|
const int was_nis_fallback =
|
||||||
__atomic_exchange_n(&last_nis_fallback, nis_fallback, __ATOMIC_RELAXED);
|
__atomic_exchange_n(&last_nis_fallback, nis_fallback, __ATOMIC_RELAXED);
|
||||||
@@ -890,10 +801,9 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
|||||||
target_ensure(&g_mid, cw, ch, FX_SCRATCH_USAGE, "EASU") == 0)) {
|
target_ensure(&g_mid, cw, ch, FX_SCRATCH_USAGE, "EASU") == 0)) {
|
||||||
if (s->aa_mode == 2 &&
|
if (s->aa_mode == 2 &&
|
||||||
(target_ensure_format(&g_smaa_edges, cw, ch, FX_SCRATCH_USAGE,
|
(target_ensure_format(&g_smaa_edges, cw, ch, FX_SCRATCH_USAGE,
|
||||||
"SMAA edges", SMAA_EDGE_FORMAT, g_smaa_edge_rp) != 0 ||
|
"SMAA edges", FX_FORMAT, g_smaa_rp) != 0 ||
|
||||||
target_ensure_format(&g_smaa_weights, cw, ch, FX_SCRATCH_USAGE,
|
target_ensure_format(&g_smaa_weights, cw, ch, FX_SCRATCH_USAGE,
|
||||||
"SMAA weights", FX_FORMAT, g_smaa_weights_rp) != 0 ||
|
"SMAA weights", FX_FORMAT, g_smaa_rp) != 0)) {
|
||||||
smaa_tables_ensure() != 0)) {
|
|
||||||
droiddeck_log("error", "effects: SMAA scratch allocation failed; falling back to FXAA");
|
droiddeck_log("error", "effects: SMAA scratch allocation failed; falling back to FXAA");
|
||||||
snapshot.aa_mode = 1;
|
snapshot.aa_mode = 1;
|
||||||
s = &snapshot;
|
s = &snapshot;
|
||||||
@@ -1021,17 +931,14 @@ static VkImage effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int
|
|||||||
switch (order[i]) {
|
switch (order[i]) {
|
||||||
case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break;
|
case FX_FXAA: pass(cmd, g_pipe[P_FXAA], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||||
case FX_FXAA_TOON: pass(cmd, g_pipe[P_FXAA_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
case FX_FXAA_TOON: pass(cmd, g_pipe[P_FXAA_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||||
case FX_SMAA: {
|
case FX_SMAA:
|
||||||
struct pc_smaa pc = {.metrics = {1.0f / (float)cw, 1.0f / (float)ch, (float)cw, (float)ch}};
|
pass_renderpass(cmd, g_smaa_rp, g_pipe[P_SMAA_EDGE],
|
||||||
const VkDescriptorSet weigh[3] = {g_smaa_edges.ds, g_smaa_area.ds, g_smaa_search.ds};
|
&g_smaa_edges, cur_ds, &pr, sizeof(pr));
|
||||||
const VkDescriptorSet blend[2] = {cur_ds, g_smaa_weights.ds};
|
pass_renderpass(cmd, g_smaa_rp, g_pipe[P_SMAA_WEIGHTS],
|
||||||
SET_NDC(pc);
|
&g_smaa_weights, g_smaa_edges.ds, &pr, sizeof(pr));
|
||||||
smaa_tables_copy(cmd);
|
pass_dual(cmd, g_pipe[P_SMAA_BLEND], dst, cur_ds,
|
||||||
pass_sets(cmd, g_smaa_edge_rp, g_pipe[P_SMAA_EDGE], &g_smaa_edges, &cur_ds, 1, &pc, sizeof(pc));
|
g_smaa_weights.ds, &pr, sizeof(pr));
|
||||||
pass_sets(cmd, g_smaa_weights_rp, g_pipe[P_SMAA_WEIGHTS], &g_smaa_weights, weigh, 3, &pc, sizeof(pc));
|
|
||||||
pass_sets(cmd, g_rp, g_pipe[P_SMAA_BLEND], dst, blend, 2, &pc, sizeof(pc));
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
case FX_TOON: pass(cmd, g_pipe[P_TOON], dst, cur_ds, &pr, sizeof(pr)); break;
|
||||||
case FX_TOON_COLOR: {
|
case FX_TOON_COLOR: {
|
||||||
struct pc_toon_color pc = {0};
|
struct pc_toon_color pc = {0};
|
||||||
@@ -1092,23 +999,13 @@ VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int sce
|
|||||||
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL, NULL);
|
VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vkp_effects_prepare_generated(int in_w, int in_h, int out_w, int out_h) {
|
int vkp_effects_prepare_generated(void) {
|
||||||
vkp_effects_sync();
|
vkp_effects_sync();
|
||||||
pthread_mutex_lock(&g_lock);
|
pthread_mutex_lock(&g_lock);
|
||||||
g_generated_settings = g_cur;
|
g_generated_settings = g_cur;
|
||||||
pthread_mutex_unlock(&g_lock);
|
pthread_mutex_unlock(&g_lock);
|
||||||
int spatial = g_generated_settings.scaling;
|
return spatial_mode(g_generated_settings.scaling) && g_generated_settings.scaling != 6 &&
|
||||||
if (!spatial_mode(spatial) || spatial == 6 || effect_count(&g_generated_settings) != 0) return 0;
|
effect_count(&g_generated_settings) == 0;
|
||||||
/* Build the spatial filter's pipelines now, before frame generation records commands that sample the
|
|
||||||
* chain's views: one failing later in the same pass would tear the chain down (chain_failed) under a
|
|
||||||
* recorded command buffer. Build only what effects_run will use for this output, as it decides it:
|
|
||||||
* NIS on an output it hands to FSR builds FSR, so a NIS that cannot build here costs nothing. */
|
|
||||||
int cw = out_w > FX_MAX_DIM ? FX_MAX_DIM : out_w < 1 ? 1 : out_w;
|
|
||||||
int ch = out_h > FX_MAX_DIM ? FX_MAX_DIM : out_h < 1 ? 1 : out_h;
|
|
||||||
if (cw <= in_w && ch <= in_h) return 1; /* clamped, it no longer upscales: effects_run builds no filter */
|
|
||||||
if (spatial == 7 && nis_falls_back(in_w, in_h, cw, ch)) spatial = 4;
|
|
||||||
if (objects_ensure() != 0 || pipelines_ensure(spatial, &g_generated_settings) != 0) return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
||||||
@@ -1129,18 +1026,13 @@ VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_
|
|||||||
struct fx_source_state source_state = {0};
|
struct fx_source_state source_state = {0};
|
||||||
VkImage result = effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h,
|
VkImage result = effects_run(cmd, scene, scene_w, scene_h, out_w, out_h, res_w, res_h,
|
||||||
VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state);
|
VK_IMAGE_LAYOUT_GENERAL, &g_generated_settings, &source_state);
|
||||||
if (result != scene) {
|
barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
||||||
barrier(cmd, result, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
if (result != scene)
|
||||||
barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL,
|
barrier(cmd, scene, source_state.layout, VK_IMAGE_LAYOUT_GENERAL,
|
||||||
source_state.stage, source_state.access,
|
source_state.stage, source_state.access,
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT);
|
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT);
|
||||||
} else if (source_state.layout == VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL) {
|
|
||||||
barrier(cmd, scene, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
|
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_TRANSFER_READ_BIT);
|
|
||||||
}
|
|
||||||
g_context = 0;
|
g_context = 0;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ VkFilter vkp_effects_blit_filter(void);
|
|||||||
|
|
||||||
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
VkImage vkp_effects_run(VkCommandBuffer cmd, VkImage scene, int scene_w, int scene_h,
|
||||||
int out_w, int out_h, int *res_w, int *res_h);
|
int out_w, int out_h, int *res_w, int *res_h);
|
||||||
int vkp_effects_prepare_generated(int in_w, int in_h, int out_w, int out_h);
|
int vkp_effects_prepare_generated(void);
|
||||||
void vkp_effects_release_generated_sources(void);
|
void vkp_effects_release_generated_sources(void);
|
||||||
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
VkImage vkp_effects_run_before_generated(VkCommandBuffer cmd, VkImage scene, int w, int h,
|
||||||
int *res_w, int *res_h);
|
int *res_w, int *res_h);
|
||||||
@@ -28,7 +28,6 @@ VkImage vkp_effects_run_generated(VkCommandBuffer cmd, VkImage scene, int scene_
|
|||||||
void vkp_effects_destroy(void);
|
void vkp_effects_destroy(void);
|
||||||
|
|
||||||
void vkp_effects_forget_image(VkImage img);
|
void vkp_effects_forget_image(VkImage img);
|
||||||
VkImageView vkp_effects_framegen_image_view(VkImage img, int w, int h, VkFormat fmt);
|
|
||||||
|
|
||||||
void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq);
|
void vkp_effects_set_formats(VkFormat scene_fmt, VkFormat target_fmt, int scene_is_pq);
|
||||||
|
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
#ifndef DD_FRAME_ACQUIRE_H
|
|
||||||
#define DD_FRAME_ACQUIRE_H
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <linux/sync_file.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
/* A zero-initialized slot owns no descriptor. Only an already successful
|
|
||||||
* sync_file can enter this slot; display-side release ownership is separate. */
|
|
||||||
struct dd_frame_acquire { int fd_plus_one; };
|
|
||||||
enum dd_frame_acquire_result { DD_ACQUIRE_OK, DD_ACQUIRE_DUPLICATE, DD_ACQUIRE_INVALID };
|
|
||||||
|
|
||||||
static inline void dd_frame_acquire_clear(struct dd_frame_acquire *f) {
|
|
||||||
if (f->fd_plus_one) close(f->fd_plus_one - 1);
|
|
||||||
f->fd_plus_one = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum dd_frame_acquire_result
|
|
||||||
dd_frame_acquire_set(struct dd_frame_acquire *f, int fd) {
|
|
||||||
enum dd_frame_acquire_result result;
|
|
||||||
struct sync_file_info info = {0};
|
|
||||||
if (f->fd_plus_one) result = DD_ACQUIRE_DUPLICATE;
|
|
||||||
else if (fd < 0 || fd == INT_MAX || ioctl(fd, SYNC_IOC_FILE_INFO, &info) != 0 ||
|
|
||||||
info.status != 1 || info.num_fences == 0) result = DD_ACQUIRE_INVALID;
|
|
||||||
else {
|
|
||||||
f->fd_plus_one = fd + 1;
|
|
||||||
return DD_ACQUIRE_OK;
|
|
||||||
}
|
|
||||||
if (fd >= 0) close(fd);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline int dd_frame_acquire_dup(const struct dd_frame_acquire *f) {
|
|
||||||
if (!f->fd_plus_one) return -1; /* Legacy: no explicit attachment proof. */
|
|
||||||
int fd = fcntl(f->fd_plus_one - 1, F_DUPFD_CLOEXEC, 0);
|
|
||||||
return fd < 0 ? -2 : fd; /* Do not re-enter the legacy direct path. */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
#ifndef DD_WORKER_PEER_H
|
|
||||||
#define DD_WORKER_PEER_H
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/* Model of one app-issued, session-bound authorization record. No callers,
|
|
||||||
* property access, proc traversal, or authorization is installed by this file. */
|
|
||||||
struct dd_worker_grant {
|
|
||||||
uint32_t owner, uid, pid, dev_major, dev_minor;
|
|
||||||
uint64_t start_ticks, ino, expires;
|
|
||||||
const char *canonical_file;
|
|
||||||
bool app_launch_verified, final_go;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum dd_worker_stat_result {
|
|
||||||
DD_WORKER_STAT_OK, DD_WORKER_STAT_DENIED, DD_WORKER_STAT_HIDDEN, DD_WORKER_STAT_OPEN,
|
|
||||||
DD_WORKER_STAT_READ, DD_WORKER_STAT_PARSE, DD_WORKER_STAT_ZERO,
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline enum dd_worker_stat_result dd_worker_parse_start(const char *line, uint64_t *out) {
|
|
||||||
const char *p = strrchr(line, ')');
|
|
||||||
if (!p || p[1] != ' ' || !p[2] || p[3] != ' ') return DD_WORKER_STAT_PARSE;
|
|
||||||
p += 2;
|
|
||||||
// State is field 3. The starttime (22) is always followed by vsize (23).
|
|
||||||
for (int field = 3; field < 22; ++field) {
|
|
||||||
p = strchr(p, ' ');
|
|
||||||
if (!p) return DD_WORKER_STAT_PARSE;
|
|
||||||
while (*p == ' ') ++p;
|
|
||||||
}
|
|
||||||
char *end;
|
|
||||||
if (*p < '0' || *p > '9') return DD_WORKER_STAT_PARSE;
|
|
||||||
errno = 0;
|
|
||||||
uint64_t value = strtoull(p, &end, 10);
|
|
||||||
if (errno || end == p || *end != ' ') return DD_WORKER_STAT_PARSE;
|
|
||||||
if (!value) return DD_WORKER_STAT_ZERO;
|
|
||||||
*out = value;
|
|
||||||
return DD_WORKER_STAT_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline enum dd_worker_stat_result dd_worker_open_failure(int error) {
|
|
||||||
if (error == EACCES || error == EPERM) return DD_WORKER_STAT_DENIED;
|
|
||||||
if (error == ENOENT || error == ESRCH) return DD_WORKER_STAT_HIDDEN;
|
|
||||||
return DD_WORKER_STAT_OPEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool dd_worker_receipt_allows_reserve(enum dd_worker_stat_result stat,
|
|
||||||
uint64_t raw, uint64_t receipt) {
|
|
||||||
if (!receipt) return false;
|
|
||||||
if (stat == DD_WORKER_STAT_OK) return raw == receipt;
|
|
||||||
// Only a visibility denial can defer the broker-side stat check, not any
|
|
||||||
// bad read, malformed record, mismatched timestamp, or other open error.
|
|
||||||
return stat == DD_WORKER_STAT_DENIED || stat == DD_WORKER_STAT_HIDDEN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool dd_worker_map_matches(const struct dd_worker_grant *g, const char *line) {
|
|
||||||
unsigned major, minor;
|
|
||||||
uint64_t lo, hi, off, ino;
|
|
||||||
int prefix = 0;
|
|
||||||
char mode[5];
|
|
||||||
if (!g->canonical_file || !*g->canonical_file ||
|
|
||||||
sscanf(line, "%" SCNx64 "-%" SCNx64 " %4s %" SCNx64 " %x:%x %" SCNu64 " %n",
|
|
||||||
&lo,&hi,mode,&off,&major,&minor,&ino,&prefix)!=7 ||
|
|
||||||
prefix <= 0 || hi <= lo || strlen(mode)!=4 || mode[2]!='x' ||
|
|
||||||
major!=g->dev_major || minor!=g->dev_minor || !ino || ino!=g->ino)
|
|
||||||
return false;
|
|
||||||
size_t path_len=strcspn(line+prefix,"\r\n");
|
|
||||||
return strlen(g->canonical_file)==path_len && !memcmp(line+prefix,g->canonical_file,path_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool dd_worker_grant_matches(const struct dd_worker_grant *g, uint32_t owner,
|
|
||||||
uint32_t uid, uint32_t pid, uint64_t start, uint64_t now, const char *executable_map) {
|
|
||||||
return g && g->app_launch_verified && g->final_go && owner && owner==g->owner &&
|
|
||||||
uid==g->uid && pid>1 && pid==g->pid && start && start==g->start_ticks &&
|
|
||||||
now<g->expires && executable_map && dd_worker_map_matches(g,executable_map);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -3,7 +3,6 @@
|
|||||||
#include "framegen_engine.h"
|
#include "framegen_engine.h"
|
||||||
#include "effects_chain.h"
|
#include "effects_chain.h"
|
||||||
#include "vk_loader.h"
|
#include "vk_loader.h"
|
||||||
#include "sc_layer.h"
|
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -37,7 +36,7 @@ static VkQueue g_queue;
|
|||||||
static uint32_t g_qfam;
|
static uint32_t g_qfam;
|
||||||
static _Atomic int g_dev_ready, g_dev_lost;
|
static _Atomic int g_dev_ready, g_dev_lost;
|
||||||
static int g_features_enabled;
|
static int g_features_enabled;
|
||||||
static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok, g_caps_zero_ok;
|
static _Atomic int g_caps_lsfg_ok, g_caps_ddfg_ok;
|
||||||
static VkPhysicalDeviceMemoryProperties g_memprops;
|
static VkPhysicalDeviceMemoryProperties g_memprops;
|
||||||
static struct {
|
static struct {
|
||||||
PFN_vkCreateImage CreateImage;
|
PFN_vkCreateImage CreateImage;
|
||||||
@@ -79,24 +78,6 @@ static int format_refused(VkFormat f) {
|
|||||||
|
|
||||||
static _Atomic unsigned g_stat_generated;
|
static _Atomic unsigned g_stat_generated;
|
||||||
static uint64_t g_total_generated;
|
static uint64_t g_total_generated;
|
||||||
|
|
||||||
#define FG_PROVEN_FRAMES 120
|
|
||||||
#define FG_HANG_STRIKES 2
|
|
||||||
static _Atomic int g_hang_strikes;
|
|
||||||
static int g_submitted_since_ready;
|
|
||||||
static uint64_t g_generated_at_ready;
|
|
||||||
|
|
||||||
// A driver that hangs on the engine's shaders loses the device on its first generated frame after every
|
|
||||||
// recovery, so the compositor would recover and hang again for as long as frame generation stays armed.
|
|
||||||
static int framegen_loss_strike(int submitted, uint64_t completed_since_ready) {
|
|
||||||
if (!submitted || completed_since_ready >= FG_PROVEN_FRAMES) {
|
|
||||||
atomic_store(&g_hang_strikes, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (atomic_fetch_add(&g_hang_strikes, 1) + 1 < FG_HANG_STRIKES) return 0;
|
|
||||||
atomic_store(&g_hang_strikes, 0);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
static float g_presented_rate, g_source_rate;
|
static float g_presented_rate, g_source_rate;
|
||||||
static uint32_t g_present_accum, g_source_accum;
|
static uint32_t g_present_accum, g_source_accum;
|
||||||
static int64_t g_window_start_ns;
|
static int64_t g_window_start_ns;
|
||||||
@@ -106,49 +87,12 @@ static int64_t now_ns(void) {
|
|||||||
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
return (int64_t)ts.tv_sec * 1000000000LL + ts.tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The pair the last run made, for the display probe and the pacer: when its real frame reached the
|
|
||||||
* compositor, the game moment each generated frame shows, and the refresh the pacer timed each for. */
|
|
||||||
static _Atomic int g_pacer_on;
|
|
||||||
static int g_layer_path;
|
|
||||||
static int g_out_gens;
|
|
||||||
static int64_t g_out_planned[VKP_FG_MAX_GENERATIONS + 1];
|
|
||||||
static int64_t g_completion_issue;
|
|
||||||
static int g_paced_route = 1;
|
|
||||||
|
|
||||||
void vkp_framegen_set_pacer(int on) {
|
|
||||||
if (atomic_exchange(&g_pacer_on, on ? 1 : 0) != (on ? 1 : 0)) {
|
|
||||||
fge_pacer_reset();
|
|
||||||
FGLOG("ZeroFG pacer %s", on ? "on: frame generation times its frames itself" : "off: the display layer times them");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int pacer_wanted(void) { return atomic_load(&g_pacer_on); }
|
|
||||||
|
|
||||||
void vkp_framegen_pacer_abort(void) {
|
|
||||||
g_completion_issue = 0;
|
|
||||||
fge_pacer_reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_framegen_output_planned(int k, int gens, int64_t *planned) {
|
|
||||||
*planned = (k < 0 || k >= gens || k >= g_out_gens)
|
|
||||||
? g_out_planned[g_out_gens] : g_out_planned[k];
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_framegen_completed(void) {
|
|
||||||
if (!g_completion_issue) return;
|
|
||||||
fge_pacer_completed(g_completion_issue, now_ns());
|
|
||||||
g_completion_issue = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns) { fge_pacer_shown(planned_ns, shown_ns); }
|
|
||||||
|
|
||||||
|
|
||||||
void vkp_framegen_set_engine(int kind) {
|
void vkp_framegen_set_engine(int kind) {
|
||||||
if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG && kind != VKP_FG_ENGINE_ZEROFG) kind = VKP_FG_ENGINE_LSFG;
|
if (kind != VKP_FG_ENGINE_LSFG && kind != VKP_FG_ENGINE_DDFG) kind = VKP_FG_ENGINE_LSFG;
|
||||||
atomic_store(&g_kind, kind);
|
atomic_store(&g_kind, kind);
|
||||||
atomic_store(&g_failed_kind, -1);
|
atomic_store(&g_failed_kind, -1);
|
||||||
atomic_store(&g_cfg_dirty, 1);
|
atomic_store(&g_cfg_dirty, 1);
|
||||||
atomic_store(&g_hang_strikes, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
void vkp_framegen_set_armed(int armed, int multiplier, int target_fps) {
|
||||||
@@ -174,22 +118,6 @@ void vkp_framegen_set_lsfg_cache_path(const char *path) {
|
|||||||
pthread_mutex_unlock(&g_lock);
|
pthread_mutex_unlock(&g_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkp_framegen_set_layer_timing(int layer) {
|
|
||||||
g_layer_path = layer;
|
|
||||||
fge_set_layer_timing(layer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_framegen_set_paced_route(int composed) {
|
|
||||||
composed = composed != 0;
|
|
||||||
if (composed == g_paced_route) return;
|
|
||||||
g_paced_route = composed;
|
|
||||||
if (atomic_load(&g_pacer_on)) {
|
|
||||||
fge_pacer_reset();
|
|
||||||
FGLOG("ZeroPacer %s", composed ? "times the layer's frames again (composed route)"
|
|
||||||
: "waits: the direct route presents the real frame on its own timing");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void vkp_framegen_set_tuning(float flow_scale, float refresh_hz) {
|
void vkp_framegen_set_tuning(float flow_scale, float refresh_hz) {
|
||||||
if (flow_scale < 0.25f) flow_scale = 0.25f;
|
if (flow_scale < 0.25f) flow_scale = 0.25f;
|
||||||
if (flow_scale > 1.0f) flow_scale = 1.0f;
|
if (flow_scale > 1.0f) flow_scale = 1.0f;
|
||||||
@@ -218,15 +146,15 @@ static void mark_failed(int kind) {
|
|||||||
int vkp_framegen_problem(void) {
|
int vkp_framegen_problem(void) {
|
||||||
if (!atomic_load(&g_dev_ready)) return -1;
|
if (!atomic_load(&g_dev_ready)) return -1;
|
||||||
int kind = atomic_load(&g_kind);
|
int kind = atomic_load(&g_kind);
|
||||||
int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) :
|
int caps_ok = kind == VKP_FG_ENGINE_DDFG
|
||||||
kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) :
|
? atomic_load(&g_caps_ddfg_ok)
|
||||||
atomic_load(&g_caps_lsfg_ok);
|
: atomic_load(&g_caps_lsfg_ok);
|
||||||
if (!caps_ok) return 1;
|
if (!caps_ok) return 1;
|
||||||
if (start_failed_for(kind)) return 2;
|
if (start_failed_for(kind)) return 2;
|
||||||
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
|
if (g_engine_ok && g_engine_kind == kind && fge_unavailable()) return 2;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(atomic_load(&g_kind)); }
|
const char *vkp_framegen_caps_reason(void) { return fge_caps_reason(); }
|
||||||
|
|
||||||
void vkp_framegen_stats(float out[6]) {
|
void vkp_framegen_stats(float out[6]) {
|
||||||
float accepted = 0.0f, src = 0.0f, thermal = -1.0f;
|
float accepted = 0.0f, src = 0.0f, thermal = -1.0f;
|
||||||
@@ -259,33 +187,16 @@ void vkp_framegen_device_ready(VkDevice dev, VkQueue queue, uint32_t qfam, int f
|
|||||||
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
|
fge_device_ready(g_gipa, g_inst, g_pd, dev, queue, qfam, features_enabled);
|
||||||
atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG));
|
atomic_store(&g_caps_lsfg_ok, fge_caps_ok(VKP_FG_ENGINE_LSFG));
|
||||||
atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
|
atomic_store(&g_caps_ddfg_ok, fge_caps_ok(VKP_FG_ENGINE_DDFG));
|
||||||
atomic_store(&g_caps_zero_ok, fge_caps_ok(VKP_FG_ENGINE_ZEROFG));
|
|
||||||
atomic_store(&g_dev_lost, 0);
|
atomic_store(&g_dev_lost, 0);
|
||||||
g_submitted_since_ready = 0;
|
|
||||||
g_generated_at_ready = g_total_generated;
|
|
||||||
atomic_store(&g_dev_ready,
|
atomic_store(&g_dev_ready,
|
||||||
vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
|
vk.CreateImage && vk.CreateImageView && vk.CmdPipelineBarrier);
|
||||||
FGLOG("engines ready on compositor device: LSFG %s, DD-FG %s, ZeroFG %s",
|
FGLOG("engines ready on the compositor's device: LSFG Native %s (%s), DD-FG Native %s",
|
||||||
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable",
|
fge_caps_ok(VKP_FG_ENGINE_LSFG) ? "available" : "unavailable", fge_caps_reason(),
|
||||||
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable",
|
fge_caps_ok(VKP_FG_ENGINE_DDFG) ? "available" : "unavailable");
|
||||||
fge_caps_ok(VKP_FG_ENGINE_ZEROFG) ? "available" : "unavailable");
|
|
||||||
}
|
|
||||||
|
|
||||||
// The compositor reports one loss twice: when it happens and again while releasing the lost device.
|
|
||||||
static int framegen_count_loss(void) {
|
|
||||||
if (atomic_exchange(&g_dev_lost, 1)) return 0;
|
|
||||||
int failed = framegen_loss_strike(g_submitted_since_ready, g_total_generated - g_generated_at_ready);
|
|
||||||
g_submitted_since_ready = 0;
|
|
||||||
return failed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void vkp_framegen_device_lost(void) {
|
void vkp_framegen_device_lost(void) {
|
||||||
if (framegen_count_loss()) {
|
atomic_store(&g_dev_lost, 1);
|
||||||
int kind = atomic_load(&g_kind);
|
|
||||||
mark_failed(kind);
|
|
||||||
FGLOG("%s lost the GPU %d times in a row before its frames completed; frame generation stays off "
|
|
||||||
"until it is set again", fge_engine_name(kind), FG_HANG_STRIKES);
|
|
||||||
}
|
|
||||||
atomic_store(&g_dev_ready, 0);
|
atomic_store(&g_dev_ready, 0);
|
||||||
fge_device_lost();
|
fge_device_lost();
|
||||||
if (g_dev) {
|
if (g_dev) {
|
||||||
@@ -372,18 +283,16 @@ static int engine_usable(void) {
|
|||||||
int kind = atomic_load(&g_kind);
|
int kind = atomic_load(&g_kind);
|
||||||
int ready = atomic_load(&g_dev_ready);
|
int ready = atomic_load(&g_dev_ready);
|
||||||
int lost = atomic_load(&g_dev_lost);
|
int lost = atomic_load(&g_dev_lost);
|
||||||
int caps_ok = kind == VKP_FG_ENGINE_ZEROFG ? atomic_load(&g_caps_zero_ok) :
|
int caps_ok = kind == VKP_FG_ENGINE_DDFG
|
||||||
kind == VKP_FG_ENGINE_DDFG ? atomic_load(&g_caps_ddfg_ok) :
|
? atomic_load(&g_caps_ddfg_ok)
|
||||||
atomic_load(&g_caps_lsfg_ok);
|
: atomic_load(&g_caps_lsfg_ok);
|
||||||
return ready && !lost && caps_ok && !start_failed_for(kind);
|
return ready && !lost && caps_ok && !start_failed_for(kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
int vkp_framegen_format_ok(VkFormat fmt) {
|
int vkp_framegen_format_ok(VkFormat fmt) {
|
||||||
if (!g_dev_ready || g_dev_lost || format_refused(fmt)) return 0;
|
|
||||||
int kind = atomic_load(&g_kind);
|
|
||||||
if (kind == VKP_FG_ENGINE_ZEROFG) return fge_format_ok(VKP_FG_ENGINE_ZEROFG, fmt);
|
|
||||||
if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1;
|
if (fmt == VK_FORMAT_R8G8B8A8_UNORM) return 1;
|
||||||
return fge_format_ok(kind, fmt);
|
if (!g_dev_ready || g_dev_lost || format_refused(fmt)) return 0;
|
||||||
|
return fge_format_ok(fmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void refuse_format(VkFormat fmt, int kind, int w, int h, const char *what) {
|
static void refuse_format(VkFormat fmt, int kind, int w, int h, const char *what) {
|
||||||
@@ -468,14 +377,11 @@ static void log_arm_transition(int armed, int kind, int mult) {
|
|||||||
|
|
||||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]) {
|
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]) {
|
||||||
|
(void)scene_view;
|
||||||
int kind = atomic_load(&g_kind);
|
int kind = atomic_load(&g_kind);
|
||||||
int armed = atomic_load(&g_armed);
|
int armed = atomic_load(&g_armed);
|
||||||
int mult = atomic_load(&g_mult);
|
int mult = atomic_load(&g_mult);
|
||||||
g_planned = 0;
|
g_planned = 0;
|
||||||
const int64_t issue = now_ns();
|
|
||||||
g_out_gens = 0;
|
|
||||||
memset(g_out_planned, 0, sizeof(g_out_planned));
|
|
||||||
g_completion_issue = 0;
|
|
||||||
if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; }
|
if (!armed || !engine_usable() || w <= 0 || h <= 0) { log_arm_transition(0, kind, mult); return 0; }
|
||||||
if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; }
|
if (!ensure_engine(kind)) { log_arm_transition(0, kind, mult); return 0; }
|
||||||
log_arm_transition(1, kind, mult);
|
log_arm_transition(1, kind, mult);
|
||||||
@@ -517,31 +423,8 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
|||||||
|
|
||||||
++g_source_frames;
|
++g_source_frames;
|
||||||
const uint64_t game_frames = droiddeck_game_frames();
|
const uint64_t game_frames = droiddeck_game_frames();
|
||||||
const uint64_t planning_sequence = game_frames ? game_frames : g_source_frames;
|
uint32_t n_gen = fge_plan(g_ring_n, game_frames ? game_frames : g_source_frames, g_presented_rate);
|
||||||
uint32_t n_gen = fge_plan(g_ring_n, planning_sequence, g_presented_rate);
|
|
||||||
if (n_gen > g_ring_n) n_gen = g_ring_n;
|
if (n_gen > g_ring_n) n_gen = g_ring_n;
|
||||||
if (kind == VKP_FG_ENGINE_ZEROFG && n_gen > 0 && !scene_view) {
|
|
||||||
scene_view = vkp_effects_framegen_image_view(scene, w, h, fmt);
|
|
||||||
if (!scene_view) {
|
|
||||||
static int view_warning;
|
|
||||||
if (!view_warning++) FGLOG("ZeroFG could not create a view for the source image; showing real frames only");
|
|
||||||
n_gen = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fge_set_phases(NULL, 0);
|
|
||||||
if (kind == VKP_FG_ENGINE_ZEROFG && pacer_wanted() && g_layer_path && g_paced_route) {
|
|
||||||
int64_t vsync = 0, period = 0;
|
|
||||||
sc_layer_timeline(&vsync, &period);
|
|
||||||
int64_t planned[VKP_FG_MAX_GENERATIONS + 1];
|
|
||||||
float phases[VKP_FG_MAX_GENERATIONS + 1];
|
|
||||||
const uint32_t count = period > 0
|
|
||||||
? fge_pacer_plan((uint32_t)mult, period, vsync, issue, n_gen, planned, phases) : 0;
|
|
||||||
if (count >= 1 && count - 1 <= n_gen) {
|
|
||||||
n_gen = count - 1;
|
|
||||||
for (uint32_t i = 0; i < count; i++) g_out_planned[i] = planned[i];
|
|
||||||
fge_set_phases(phases, n_gen);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_planned = n_gen;
|
g_planned = n_gen;
|
||||||
|
|
||||||
VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS];
|
VkImageMemoryBarrier bars[1 + VKP_FG_MAX_GENERATIONS];
|
||||||
@@ -569,26 +452,21 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
|||||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
0, 0, NULL, 0, NULL, nb, bars);
|
0, 0, NULL, 0, NULL, nb, bars);
|
||||||
|
|
||||||
if (n_gen) g_submitted_since_ready = 1;
|
fge_process(cmd, scene, (uint32_t)w, (uint32_t)h, n_gen);
|
||||||
fge_process(cmd, scene, scene_view, (uint32_t)w, (uint32_t)h, fmt, planning_sequence, n_gen);
|
|
||||||
for (uint32_t g = 0; g < n_gen; g++) {
|
for (uint32_t g = 0; g < n_gen; g++) {
|
||||||
fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h);
|
fge_generate(cmd, g, n_gen, g_ring[g].img, g_ring[g].view, (uint32_t)w, (uint32_t)h);
|
||||||
gens[g] = g_ring[g].img;
|
gens[g] = g_ring[g].img;
|
||||||
}
|
}
|
||||||
if (n_gen) {
|
if (n_gen) {
|
||||||
nb = 0;
|
nb = 0;
|
||||||
const VkAccessFlags generated_access = kind == VKP_FG_ENGINE_ZEROFG
|
|
||||||
? VK_ACCESS_MEMORY_WRITE_BIT : VK_ACCESS_SHADER_WRITE_BIT;
|
|
||||||
const VkPipelineStageFlags generated_stage = kind == VKP_FG_ENGINE_ZEROFG
|
|
||||||
? VK_PIPELINE_STAGE_ALL_COMMANDS_BIT : VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
|
|
||||||
for (uint32_t g = 0; g < n_gen; g++)
|
for (uint32_t g = 0; g < n_gen; g++)
|
||||||
bars[nb++] = (VkImageMemoryBarrier){
|
bars[nb++] = (VkImageMemoryBarrier){
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER,
|
||||||
.srcAccessMask = generated_access, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT,
|
||||||
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
.oldLayout = VK_IMAGE_LAYOUT_GENERAL, .newLayout = VK_IMAGE_LAYOUT_GENERAL,
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED, .dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.image = g_ring[g].img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
.image = g_ring[g].img, .subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}};
|
||||||
vk.CmdPipelineBarrier(cmd, generated_stage, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
0, 0, NULL, 0, NULL, nb, bars);
|
0, 0, NULL, 0, NULL, nb, bars);
|
||||||
if (!g_generating_logged) {
|
if (!g_generating_logged) {
|
||||||
g_generating_logged = 1;
|
g_generating_logged = 1;
|
||||||
@@ -598,8 +476,6 @@ int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view,
|
|||||||
fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? ", FP16: the HDR picture" : "");
|
fmt == VK_FORMAT_R16G16B16A16_SFLOAT ? ", FP16: the HDR picture" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_out_gens = (int)n_gen;
|
|
||||||
if (n_gen > 0) g_completion_issue = issue;
|
|
||||||
return (int)n_gen;
|
return (int)n_gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
|
|
||||||
enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1, VKP_FG_ENGINE_ZEROFG = 2 };
|
enum { VKP_FG_ENGINE_LSFG = 0, VKP_FG_ENGINE_DDFG = 1 };
|
||||||
#define VKP_FG_MAX_GENERATIONS 3
|
#define VKP_FG_MAX_GENERATIONS 3
|
||||||
|
|
||||||
void vkp_framegen_set_engine(int kind);
|
void vkp_framegen_set_engine(int kind);
|
||||||
@@ -26,21 +26,6 @@ void vkp_framegen_device_lost(void);
|
|||||||
|
|
||||||
int vkp_framegen_active(void);
|
int vkp_framegen_active(void);
|
||||||
int vkp_framegen_extra_images(void);
|
int vkp_framegen_extra_images(void);
|
||||||
/* 1 when the next run's frames are shown through the scene layer's timed group, 0 through the swapchain's FIFO. */
|
|
||||||
void vkp_framegen_set_layer_timing(int layer);
|
|
||||||
/* ZeroFG's pacer (include/zerofg/inline_pacer.h) times the layer's frames instead of the layer's own spacing. */
|
|
||||||
void vkp_framegen_set_pacer(int on);
|
|
||||||
/* 1 when the layer pass presents the real frame itself after its generated frames (the composed route): only
|
|
||||||
* then can the pacer time the whole group. The direct route keeps the layer's own timing. */
|
|
||||||
void vkp_framegen_set_paced_route(int composed);
|
|
||||||
/* Reset pacing history when a planned real-frame pair is aborted before presentation. */
|
|
||||||
void vkp_framegen_pacer_abort(void);
|
|
||||||
/* Refresh planned for output k of the last run (k == gens: its real frame; 0: use layer timing). */
|
|
||||||
void vkp_framegen_output_planned(int k, int gens, int64_t *planned);
|
|
||||||
/* The last run's GPU work finished (the compositor's fence signalled). */
|
|
||||||
void vkp_framegen_completed(void);
|
|
||||||
/* A real frame the pacer timed for planned_ns was shown at shown_ns. */
|
|
||||||
void vkp_framegen_real_shown(int64_t planned_ns, int64_t shown_ns);
|
|
||||||
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
int vkp_framegen_run(VkCommandBuffer cmd, VkImage scene, VkImageView scene_view, int w, int h,
|
||||||
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]);
|
VkFormat fmt, VkImage gens[VKP_FG_MAX_GENERATIONS]);
|
||||||
void vkp_framegen_presented(int generated);
|
void vkp_framegen_presented(int generated);
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -14,9 +13,6 @@
|
|||||||
#include "lsfg/lsfg_probe.h"
|
#include "lsfg/lsfg_probe.h"
|
||||||
#include "lsfg/lsfg_vkd.h"
|
#include "lsfg/lsfg_vkd.h"
|
||||||
#include "ddfg/ddfg_engine.h"
|
#include "ddfg/ddfg_engine.h"
|
||||||
#include "framegen_zerofg.h"
|
|
||||||
|
|
||||||
#include <zerofg/inline_pacer.h>
|
|
||||||
|
|
||||||
#define ELOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
#define ELOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
||||||
#define ELOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
#define ELOGE(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "framegen: " __VA_ARGS__)
|
||||||
@@ -26,17 +22,12 @@ namespace {
|
|||||||
VkTable g_table{};
|
VkTable g_table{};
|
||||||
lsfg::Caps g_caps{};
|
lsfg::Caps g_caps{};
|
||||||
VkPhysicalDeviceVulkan12Features g_v12{};
|
VkPhysicalDeviceVulkan12Features g_v12{};
|
||||||
VkPhysicalDeviceVulkan13Features g_v13{};
|
|
||||||
VkPhysicalDeviceFeatures2 g_f2{};
|
VkPhysicalDeviceFeatures2 g_f2{};
|
||||||
VkPhysicalDevice g_pd = VK_NULL_HANDLE;
|
VkPhysicalDevice g_pd = VK_NULL_HANDLE;
|
||||||
VkDevice g_dev = VK_NULL_HANDLE;
|
VkDevice g_dev = VK_NULL_HANDLE;
|
||||||
VkQueue g_queue = VK_NULL_HANDLE;
|
VkQueue g_queue = VK_NULL_HANDLE;
|
||||||
uint32_t g_qfam = 0;
|
uint32_t g_qfam = 0;
|
||||||
bool g_probed = false, g_ready = false;
|
bool g_probed = false, g_ready = false;
|
||||||
bool g_zero_supported = false, g_zero_enabled = false;
|
|
||||||
zerofg::InlinePacer g_pacer;
|
|
||||||
zerofg::InlineReadiness g_readiness;
|
|
||||||
std::mutex g_pacer_mutex;
|
|
||||||
|
|
||||||
std::unique_ptr<lsfg::Engine> g_lsfg;
|
std::unique_ptr<lsfg::Engine> g_lsfg;
|
||||||
std::unique_ptr<ddfg::Engine> g_ddfg;
|
std::unique_ptr<ddfg::Engine> g_ddfg;
|
||||||
@@ -97,57 +88,30 @@ const void *fge_probe(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
|||||||
if (n) enumExts(pd, nullptr, &n, exts.data());
|
if (n) enumExts(pd, nullptr, &n, exts.data());
|
||||||
}
|
}
|
||||||
g_caps = lsfg::Caps{};
|
g_caps = lsfg::Caps{};
|
||||||
g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false);
|
|
||||||
|
|
||||||
|
g_caps.features = lsfg::queryFeatures(g_table, pd, exts, false);
|
||||||
g_caps.probedFormat = ring_fmt;
|
g_caps.probedFormat = ring_fmt;
|
||||||
g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
g_caps.storageOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||||
? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false;
|
? lsfg::probeStorageFormat(g_table, pd, ring_fmt) : false;
|
||||||
g_caps.linearBlitOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
g_caps.linearBlitOnSwapchainFormat = g_table.GetPhysicalDeviceFormatProperties
|
||||||
? lsfg::probeLinearBlit(g_table, pd, ring_fmt) : false;
|
? lsfg::probeLinearBlit(g_table, pd, ring_fmt) : false;
|
||||||
g_probed = true;
|
g_probed = true;
|
||||||
|
if (!g_caps.features.deviceGatesPass()) {
|
||||||
VkPhysicalDeviceProperties props{};
|
|
||||||
if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props);
|
|
||||||
VkPhysicalDeviceVulkan13Features supported13{};
|
|
||||||
supported13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
|
||||||
VkPhysicalDeviceFeatures2 supported2{};
|
|
||||||
supported2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
|
||||||
if (props.apiVersion >= VK_API_VERSION_1_3) supported2.pNext = &supported13;
|
|
||||||
if (g_table.GetPhysicalDeviceFeatures2) g_table.GetPhysicalDeviceFeatures2(pd, &supported2);
|
|
||||||
g_zero_supported = props.apiVersion >= VK_API_VERSION_1_3 &&
|
|
||||||
supported13.synchronization2 == VK_TRUE &&
|
|
||||||
supported2.features.shaderStorageImageExtendedFormats == VK_TRUE;
|
|
||||||
g_zero_enabled = false;
|
|
||||||
|
|
||||||
const bool lsfg_supported = g_caps.features.deviceGatesPass();
|
|
||||||
if (!lsfg_supported) {
|
|
||||||
lsfg::explain(g_caps);
|
lsfg::explain(g_caps);
|
||||||
ELOG("device gates for the LSFG chain fail: %s", g_caps.reason);
|
ELOG("device gates for the LSFG chain fail: %s", g_caps.reason);
|
||||||
}
|
|
||||||
if (!lsfg_supported && !g_zero_supported) {
|
|
||||||
g_v12 = {};
|
|
||||||
g_v13 = {};
|
|
||||||
g_f2 = {};
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_v12 = VkPhysicalDeviceVulkan12Features{};
|
g_v12 = VkPhysicalDeviceVulkan12Features{};
|
||||||
g_v12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
g_v12.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_2_FEATURES;
|
||||||
g_v12.vulkanMemoryModel =
|
g_v12.vulkanMemoryModel = VK_TRUE;
|
||||||
g_caps.features.vulkanMemoryModel ? VK_TRUE : VK_FALSE;
|
|
||||||
g_v12.vulkanMemoryModelDeviceScope =
|
g_v12.vulkanMemoryModelDeviceScope =
|
||||||
g_caps.features.vulkanMemoryModelDeviceScope ? VK_TRUE : VK_FALSE;
|
g_caps.features.vulkanMemoryModelDeviceScope ? VK_TRUE : VK_FALSE;
|
||||||
g_v13 = VkPhysicalDeviceVulkan13Features{};
|
|
||||||
g_v13.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_1_3_FEATURES;
|
|
||||||
g_v13.synchronization2 = g_zero_supported ? VK_TRUE : VK_FALSE;
|
|
||||||
if (g_zero_supported) g_v12.pNext = &g_v13;
|
|
||||||
|
|
||||||
g_f2 = VkPhysicalDeviceFeatures2{};
|
g_f2 = VkPhysicalDeviceFeatures2{};
|
||||||
g_f2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
g_f2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
|
||||||
g_f2.pNext = &g_v12;
|
g_f2.pNext = &g_v12;
|
||||||
g_f2.features.shaderStorageImageWriteWithoutFormat =
|
g_f2.features.shaderStorageImageWriteWithoutFormat = VK_TRUE;
|
||||||
supported2.features.shaderStorageImageWriteWithoutFormat ? VK_TRUE : VK_FALSE;
|
g_f2.features.shaderStorageImageExtendedFormats = VK_TRUE;
|
||||||
g_f2.features.shaderStorageImageExtendedFormats =
|
|
||||||
supported2.features.shaderStorageImageExtendedFormats ? VK_TRUE : VK_FALSE;
|
|
||||||
return &g_f2;
|
return &g_f2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,17 +122,9 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
|||||||
fill_device(dev);
|
fill_device(dev);
|
||||||
g_caps.featuresEnabled = features_enabled != 0;
|
g_caps.featuresEnabled = features_enabled != 0;
|
||||||
lsfg::explain(g_caps);
|
lsfg::explain(g_caps);
|
||||||
VkPhysicalDeviceProperties props{};
|
|
||||||
if (g_table.GetPhysicalDeviceProperties) g_table.GetPhysicalDeviceProperties(pd, &props);
|
|
||||||
g_zero_enabled = g_zero_supported && features_enabled != 0;
|
|
||||||
zfg_device_ready(gipa, inst, pd, dev,
|
|
||||||
props.apiVersion > VK_API_VERSION_1_3 ? VK_API_VERSION_1_3 : props.apiVersion,
|
|
||||||
g_zero_enabled,
|
|
||||||
g_zero_enabled && g_f2.features.shaderStorageImageExtendedFormats == VK_TRUE);
|
|
||||||
g_ready = true;
|
g_ready = true;
|
||||||
ELOG("device ready: lsfg caps '%s', storage on ring format %d, ZeroFG %s",
|
ELOG("device ready: lsfg caps '%s', storage on ring format %d", g_caps.reason,
|
||||||
g_caps.reason, (int)g_caps.storageOnSwapchainFormat,
|
(int)g_caps.storageOnSwapchainFormat);
|
||||||
g_zero_enabled ? "available" : "unavailable");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void fge_device_lost(void) {
|
void fge_device_lost(void) {
|
||||||
@@ -193,45 +149,24 @@ void fge_device_lost(void) {
|
|||||||
g_v12 = {};
|
g_v12 = {};
|
||||||
g_f2 = {};
|
g_f2 = {};
|
||||||
g_build[0] = 0;
|
g_build[0] = 0;
|
||||||
g_zero_supported = g_zero_enabled = false;
|
|
||||||
zfg_device_lost();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int fge_caps_ok(int kind) {
|
int fge_caps_ok(int kind) {
|
||||||
if (!g_ready) return 0;
|
if (!g_ready) return 0;
|
||||||
if (kind == 2) return g_zero_enabled && zfg_caps_ok();
|
|
||||||
if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0;
|
if (kind == 1) return g_caps.storageOnSwapchainFormat ? 1 : 0;
|
||||||
return g_caps.supported() ? 1 : 0;
|
return g_caps.supported() ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fge_engine_available(int kind) { return fge_caps_ok(kind); }
|
const char *fge_caps_reason(void) { return g_caps.reason; }
|
||||||
|
|
||||||
const char *fge_caps_reason(int kind) {
|
int fge_format_ok(VkFormat fmt) {
|
||||||
if (kind == 2 && !g_zero_enabled)
|
|
||||||
return "ZeroFG requires Vulkan 1.3, synchronization2 and extended storage-image formats";
|
|
||||||
if (kind == 2) return zfg_caps_reason();
|
|
||||||
return g_caps.reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
int fge_format_ok(int kind, VkFormat fmt) {
|
|
||||||
if (kind == 2) return zfg_format_ok(fmt);
|
|
||||||
if (!g_ready || !g_table.GetPhysicalDeviceFormatProperties || fmt == VK_FORMAT_UNDEFINED) return 0;
|
if (!g_ready || !g_table.GetPhysicalDeviceFormatProperties || fmt == VK_FORMAT_UNDEFINED) return 0;
|
||||||
return lsfg::probeStorageFormat(g_table, g_pd, fmt) && lsfg::probeLinearBlit(g_table, g_pd, fmt) ? 1 : 0;
|
return lsfg::probeStorageFormat(g_table, g_pd, fmt) && lsfg::probeLinearBlit(g_table, g_pd, fmt) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fge_start(int kind, const char *cache_path) {
|
int fge_start(int kind, const char *cache_path) {
|
||||||
fge_stop();
|
fge_stop();
|
||||||
fge_pacer_reset();
|
|
||||||
if (!g_ready) return -1;
|
if (!g_ready) return -1;
|
||||||
if (kind == 2) {
|
|
||||||
if (!g_zero_enabled || !zfg_start()) {
|
|
||||||
ELOGE("ZeroFG engine init failed");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
g_kind = 2;
|
|
||||||
std::snprintf(g_build, sizeof(g_build), "ZeroFG ReallyZero, Vulkan 1.3 Compat");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (kind == 1) {
|
if (kind == 1) {
|
||||||
auto e = std::make_unique<ddfg::Engine>();
|
auto e = std::make_unique<ddfg::Engine>();
|
||||||
if (!e->init(g_table, g_pd, g_dev, g_qfam, g_queue)) {
|
if (!e->init(g_table, g_pd, g_dev, g_qfam, g_queue)) {
|
||||||
@@ -266,16 +201,14 @@ int fge_start(int kind, const char *cache_path) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void fge_stop(void) {
|
void fge_stop(void) {
|
||||||
if ((g_kind == 0 || g_kind == 2) && g_table.DeviceWaitIdle && g_dev)
|
if (g_lsfg) {
|
||||||
g_table.DeviceWaitIdle(g_dev);
|
if (g_table.DeviceWaitIdle && g_dev) g_table.DeviceWaitIdle(g_dev);
|
||||||
|
g_lsfg.reset();
|
||||||
g_lsfg.reset();
|
}
|
||||||
|
|
||||||
for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) {
|
for (auto it = g_retained_ddfg.begin(); it != g_retained_ddfg.end();) {
|
||||||
if ((*it)->destroy()) it = g_retained_ddfg.erase(it);
|
if ((*it)->destroy()) it = g_retained_ddfg.erase(it);
|
||||||
else ++it;
|
else ++it;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_ddfg) {
|
if (g_ddfg) {
|
||||||
if (g_ddfg->destroy()) g_ddfg.reset();
|
if (g_ddfg->destroy()) g_ddfg.reset();
|
||||||
else {
|
else {
|
||||||
@@ -283,13 +216,10 @@ void fge_stop(void) {
|
|||||||
g_retained_ddfg.push_back(std::move(g_ddfg));
|
g_retained_ddfg.push_back(std::move(g_ddfg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zfg_stop();
|
|
||||||
g_kind = -1;
|
g_kind = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int fge_unavailable(void) {
|
int fge_unavailable(void) {
|
||||||
if (g_kind == 2) return zfg_unavailable();
|
|
||||||
if (g_kind == 1) return g_ddfg && g_ddfg->unavailable() ? 1 : 0;
|
if (g_kind == 1) return g_ddfg && g_ddfg->unavailable() ? 1 : 0;
|
||||||
return g_lsfg && g_lsfg->unavailable() ? 1 : 0;
|
return g_lsfg && g_lsfg->unavailable() ? 1 : 0;
|
||||||
}
|
}
|
||||||
@@ -297,13 +227,11 @@ int fge_unavailable(void) {
|
|||||||
void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, float refresh_hz,
|
void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, float refresh_hz,
|
||||||
int model, int perf_preset) {
|
int model, int perf_preset) {
|
||||||
if (multiplier < 2) multiplier = 2;
|
if (multiplier < 2) multiplier = 2;
|
||||||
if (g_kind == 2) { zfg_configure(multiplier, refresh_hz); return; }
|
|
||||||
if (g_kind == 1 && g_ddfg) g_ddfg->configure(multiplier, model, perf_preset, flow_scale);
|
if (g_kind == 1 && g_ddfg) g_ddfg->configure(multiplier, model, perf_preset, flow_scale);
|
||||||
else if (g_lsfg) g_lsfg->configure(multiplier, target_fps, flow_scale, refresh_hz);
|
else if (g_lsfg) g_lsfg->configure(multiplier, target_fps, flow_scale, refresh_hz);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
||||||
if (g_kind == 2) return zfg_prepare(w, h, fmt);
|
|
||||||
if (g_kind == 1) return g_ddfg && g_ddfg->prepare(w, h, fmt) ? 1 : 0;
|
if (g_kind == 1) return g_ddfg && g_ddfg->prepare(w, h, fmt) ? 1 : 0;
|
||||||
if (!g_lsfg) return 0;
|
if (!g_lsfg) return 0;
|
||||||
g_lsfg->setGuestExtent(w, h);
|
g_lsfg->setGuestExtent(w, h);
|
||||||
@@ -311,74 +239,24 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||||
if (g_kind == 2) return zfg_plan(capacity, source_frames);
|
|
||||||
if (g_kind == 1) return g_ddfg ? g_ddfg->plan(capacity) : 0;
|
if (g_kind == 1) return g_ddfg ? g_ddfg->plan(capacity) : 0;
|
||||||
if (!g_lsfg) return 0;
|
if (!g_lsfg) return 0;
|
||||||
g_lsfg->setPresentedRate(presented_rate);
|
g_lsfg->setPresentedRate(presented_rate);
|
||||||
return g_lsfg->plan(capacity, source_frames);
|
return g_lsfg->plan(capacity, source_frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||||
uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens) {
|
|
||||||
if (g_kind == 2) {
|
|
||||||
zfg_process(cmd, source, source_view, w, h, fmt, sequence, gens);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (g_kind == 1) { if (g_ddfg) g_ddfg->process(cmd, source, w, h, gens); return; }
|
if (g_kind == 1) { if (g_ddfg) g_ddfg->process(cmd, source, w, h, gens); return; }
|
||||||
if (g_lsfg) g_lsfg->process(cmd, source, w, h, gens);
|
if (g_lsfg) g_lsfg->process(cmd, source, w, h, gens);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||||
uint32_t w, uint32_t h) {
|
uint32_t w, uint32_t h) {
|
||||||
if (g_kind == 2) { zfg_generate(cmd, g, count, img, view, w, h); return; }
|
|
||||||
if (g_kind == 1) { if (g_ddfg) g_ddfg->generateInto(cmd, g, count, img, view, w, h); return; }
|
if (g_kind == 1) { if (g_ddfg) g_ddfg->generateInto(cmd, g, count, img, view, w, h); return; }
|
||||||
if (g_lsfg) g_lsfg->generateInto(cmd, g, g, img, view, w, h);
|
if (g_lsfg) g_lsfg->generateInto(cmd, g, g, img, view, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fge_set_layer_timing(int layer) { zfg_set_layer_timing(layer); }
|
|
||||||
|
|
||||||
void fge_set_phases(const float *phases, uint32_t count) { zfg_set_phases(phases, count); }
|
|
||||||
|
|
||||||
float fge_phase(uint32_t index, uint32_t count) {
|
|
||||||
if (g_kind == 2) return zfg_phase(index, count);
|
|
||||||
return static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
|
||||||
int64_t *present_ns, float *phases) {
|
|
||||||
if (period_ns <= 0 || issue_ns <= 0) return 0;
|
|
||||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
|
||||||
g_pacer.SetMultiplier(multiplier);
|
|
||||||
g_pacer.ObserveVsync(static_cast<uint64_t>(period_ns), static_cast<uint64_t>(vsync_ns > 0 ? vsync_ns : 0));
|
|
||||||
const uint64_t issue = static_cast<uint64_t>(issue_ns);
|
|
||||||
const zerofg::InlinePacer::Plan plan =
|
|
||||||
g_pacer.PlanPair(issue, issue + g_readiness.MarginNs(static_cast<uint64_t>(period_ns)), max_generated + 1);
|
|
||||||
for (uint32_t i = 0; i < plan.count; i++) {
|
|
||||||
present_ns[i] = static_cast<int64_t>(plan.outputs[i].present_ns);
|
|
||||||
phases[i] = plan.outputs[i].phase;
|
|
||||||
}
|
|
||||||
return plan.count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) {
|
|
||||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
|
||||||
if (issue_ns > 0 && done_ns > issue_ns)
|
|
||||||
g_readiness.ObserveCompleted(static_cast<uint64_t>(issue_ns), static_cast<uint64_t>(done_ns));
|
|
||||||
}
|
|
||||||
|
|
||||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) {
|
|
||||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
|
||||||
if (planned_ns > 0 && shown_ns > 0)
|
|
||||||
g_pacer.ObserveRealShown(static_cast<uint64_t>(planned_ns), static_cast<uint64_t>(shown_ns));
|
|
||||||
}
|
|
||||||
|
|
||||||
void fge_pacer_reset(void) {
|
|
||||||
std::lock_guard<std::mutex> lock(g_pacer_mutex);
|
|
||||||
g_pacer.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fge_forget_targets(void) {
|
void fge_forget_targets(void) {
|
||||||
if (g_kind == 2) { zfg_forget_targets(); return; }
|
|
||||||
if (g_lsfg) g_lsfg->forgetTargets();
|
if (g_lsfg) g_lsfg->forgetTargets();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,14 +266,10 @@ void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
|||||||
*accepted = (float)g_lsfg->acceptedGenerations();
|
*accepted = (float)g_lsfg->acceptedGenerations();
|
||||||
*source_rate = g_lsfg->sourceRate();
|
*source_rate = g_lsfg->sourceRate();
|
||||||
*thermal = (float)g_lsfg->thermalStatus();
|
*thermal = (float)g_lsfg->thermalStatus();
|
||||||
} else if (g_kind == 2) {
|
|
||||||
zfg_telemetry(accepted, source_rate);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *fge_engine_name(int kind) {
|
const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
||||||
return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native";
|
|
||||||
}
|
|
||||||
const char *fge_build_info(void) { return g_build; }
|
const char *fge_build_info(void) { return g_build; }
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -16,9 +16,8 @@ void fge_device_lost(void);
|
|||||||
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysicalDevice pd,
|
||||||
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
|
VkDevice dev, VkQueue queue, uint32_t qfam, int features_enabled);
|
||||||
int fge_caps_ok(int kind);
|
int fge_caps_ok(int kind);
|
||||||
const char *fge_caps_reason(int kind);
|
const char *fge_caps_reason(void);
|
||||||
int fge_format_ok(int kind, VkFormat fmt);
|
int fge_format_ok(VkFormat fmt);
|
||||||
int fge_engine_available(int kind);
|
|
||||||
|
|
||||||
int fge_start(int kind, const char *cache_path);
|
int fge_start(int kind, const char *cache_path);
|
||||||
void fge_stop(void);
|
void fge_stop(void);
|
||||||
@@ -27,22 +26,10 @@ void fge_configure(uint32_t multiplier, uint32_t target_fps, float flow_scale, f
|
|||||||
int model, int perf_preset);
|
int model, int perf_preset);
|
||||||
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt);
|
int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt);
|
||||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate);
|
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate);
|
||||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens);
|
||||||
uint32_t w, uint32_t h, VkFormat fmt, uint64_t sequence, uint32_t gens);
|
|
||||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||||
uint32_t w, uint32_t h);
|
uint32_t w, uint32_t h);
|
||||||
void fge_forget_targets(void);
|
void fge_forget_targets(void);
|
||||||
void fge_set_layer_timing(int layer);
|
|
||||||
/* The phases the pacer chose for the next pair's generated frames (engines that can take any phase). */
|
|
||||||
void fge_set_phases(const float *phases, uint32_t count);
|
|
||||||
/* The phase generated frame [index] of [count] shows. */
|
|
||||||
float fge_phase(uint32_t index, uint32_t count);
|
|
||||||
|
|
||||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
|
||||||
int64_t *present_ns, float *phases);
|
|
||||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns);
|
|
||||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns);
|
|
||||||
void fge_pacer_reset(void);
|
|
||||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal);
|
void fge_telemetry(float *accepted, float *source_rate, float *thermal);
|
||||||
const char *fge_engine_name(int kind);
|
const char *fge_engine_name(int kind);
|
||||||
const char *fge_build_info(void);
|
const char *fge_build_info(void);
|
||||||
|
|||||||
@@ -10,12 +10,9 @@ void fge_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance inst, VkPhysica
|
|||||||
(void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled;
|
(void)gipa; (void)inst; (void)pd; (void)dev; (void)queue; (void)qfam; (void)features_enabled;
|
||||||
}
|
}
|
||||||
void fge_device_lost(void) {}
|
void fge_device_lost(void) {}
|
||||||
void zfg_discard_history_update(void) {}
|
|
||||||
void zfg_commit_history_update(void) {}
|
|
||||||
int fge_caps_ok(int kind) { (void)kind; return 0; }
|
int fge_caps_ok(int kind) { (void)kind; return 0; }
|
||||||
const char *fge_caps_reason(int kind) { (void)kind; return "frame-generation engines not built into this compositor"; }
|
const char *fge_caps_reason(void) { return "frame-generation engines not built into this compositor"; }
|
||||||
int fge_format_ok(int kind, VkFormat fmt) { (void)kind; (void)fmt; return 0; }
|
int fge_format_ok(VkFormat fmt) { (void)fmt; return 0; }
|
||||||
int fge_engine_available(int kind) { (void)kind; return 0; }
|
|
||||||
int fge_start(int kind, const char *cache_path) { (void)kind; (void)cache_path; return -1; }
|
int fge_start(int kind, const char *cache_path) { (void)kind; (void)cache_path; return -1; }
|
||||||
void fge_stop(void) {}
|
void fge_stop(void) {}
|
||||||
int fge_unavailable(void) { return 1; }
|
int fge_unavailable(void) { return 1; }
|
||||||
@@ -27,28 +24,16 @@ int fge_prepare(uint32_t w, uint32_t h, VkFormat fmt) { (void)w; (void)h; (void)
|
|||||||
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
uint32_t fge_plan(uint32_t capacity, uint64_t source_frames, float presented_rate) {
|
||||||
(void)capacity; (void)source_frames; (void)presented_rate; return 0;
|
(void)capacity; (void)source_frames; (void)presented_rate; return 0;
|
||||||
}
|
}
|
||||||
void fge_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view, uint32_t w, uint32_t h,
|
void fge_process(VkCommandBuffer cmd, VkImage source, uint32_t w, uint32_t h, uint32_t gens) {
|
||||||
VkFormat fmt, uint64_t sequence, uint32_t gens) {
|
(void)cmd; (void)source; (void)w; (void)h; (void)gens;
|
||||||
(void)cmd; (void)source; (void)source_view; (void)w; (void)h; (void)fmt; (void)sequence; (void)gens;
|
|
||||||
}
|
}
|
||||||
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
void fge_generate(VkCommandBuffer cmd, uint32_t g, uint32_t count, VkImage img, VkImageView view,
|
||||||
uint32_t w, uint32_t h) {
|
uint32_t w, uint32_t h) {
|
||||||
(void)cmd; (void)g; (void)count; (void)img; (void)view; (void)w; (void)h;
|
(void)cmd; (void)g; (void)count; (void)img; (void)view; (void)w; (void)h;
|
||||||
}
|
}
|
||||||
void fge_forget_targets(void) {}
|
void fge_forget_targets(void) {}
|
||||||
void fge_set_layer_timing(int layer) { (void)layer; }
|
|
||||||
void fge_set_phases(const float *phases, uint32_t count) { (void)phases; (void)count; }
|
|
||||||
float fge_phase(uint32_t index, uint32_t count) { return (float)(index + 1) / (float)(count + 1); }
|
|
||||||
uint32_t fge_pacer_plan(uint32_t multiplier, int64_t period_ns, int64_t vsync_ns, int64_t issue_ns, uint32_t max_generated,
|
|
||||||
int64_t *present_ns, float *phases) {
|
|
||||||
(void)multiplier; (void)period_ns; (void)vsync_ns; (void)issue_ns; (void)max_generated; (void)present_ns; (void)phases;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
void fge_pacer_completed(int64_t issue_ns, int64_t done_ns) { (void)issue_ns; (void)done_ns; }
|
|
||||||
void fge_pacer_shown(int64_t planned_ns, int64_t shown_ns) { (void)planned_ns; (void)shown_ns; }
|
|
||||||
void fge_pacer_reset(void) {}
|
|
||||||
void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
void fge_telemetry(float *accepted, float *source_rate, float *thermal) {
|
||||||
*accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f;
|
*accepted = 0.0f; *source_rate = 0.0f; *thermal = -1.0f;
|
||||||
}
|
}
|
||||||
const char *fge_engine_name(int kind) { return kind == 2 ? "ZeroFG" : kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
const char *fge_engine_name(int kind) { return kind == 1 ? "DD-FG Native" : "LSFG Native"; }
|
||||||
const char *fge_build_info(void) { return "stub"; }
|
const char *fge_build_info(void) { return "stub"; }
|
||||||
@@ -14,12 +14,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenArmed(JNI
|
|||||||
vkp_framegen_set_armed(armed ? 1 : 0, (int)multiplier, (int)targetFps);
|
vkp_framegen_set_armed(armed ? 1 : 0, (int)multiplier, (int)targetFps);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetFrameGenPacer(JNIEnv *env, jclass clazz, jboolean on) {
|
|
||||||
(void)env; (void)clazz;
|
|
||||||
vkp_framegen_set_pacer(on ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLsfgCachePath(JNIEnv *env, jclass clazz, jstring path) {
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetLsfgCachePath(JNIEnv *env, jclass clazz, jstring path) {
|
||||||
(void)clazz;
|
(void)clazz;
|
||||||
|
|||||||
@@ -1,624 +0,0 @@
|
|||||||
#include "framegen_zerofg.h"
|
|
||||||
#include "sc_layer.h"
|
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <array>
|
|
||||||
#include <chrono>
|
|
||||||
#include <cmath>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
#include <android/log.h>
|
|
||||||
#include <zerofg/zerofg.h>
|
|
||||||
|
|
||||||
#define ZFG_LOG(...) __android_log_print(ANDROID_LOG_INFO, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__)
|
|
||||||
#define ZFG_ERR(...) __android_log_print(ANDROID_LOG_ERROR, "DroidDeckWayland", "ZeroFG: " __VA_ARGS__)
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
PFN_vkGetInstanceProcAddr g_gipa = nullptr;
|
|
||||||
PFN_vkGetDeviceProcAddr g_gdpa = nullptr;
|
|
||||||
VkInstance g_instance = VK_NULL_HANDLE;
|
|
||||||
VkPhysicalDevice g_physical = VK_NULL_HANDLE;
|
|
||||||
VkDevice g_device = VK_NULL_HANDLE;
|
|
||||||
uint32_t g_api_version = VK_API_VERSION_1_0;
|
|
||||||
bool g_synchronization2 = false, g_extended_formats = false;
|
|
||||||
bool g_ready = false, g_supported = false, g_failed = false;
|
|
||||||
char g_reason[160] = "device has not been checked";
|
|
||||||
|
|
||||||
PFN_vkGetPhysicalDeviceMemoryProperties g_GetPhysicalDeviceMemoryProperties = nullptr;
|
|
||||||
PFN_vkGetPhysicalDeviceFormatProperties g_GetPhysicalDeviceFormatProperties = nullptr;
|
|
||||||
PFN_vkCreateImage g_CreateImage = nullptr;
|
|
||||||
PFN_vkDestroyImage g_DestroyImage = nullptr;
|
|
||||||
PFN_vkCreateImageView g_CreateImageView = nullptr;
|
|
||||||
PFN_vkDestroyImageView g_DestroyImageView = nullptr;
|
|
||||||
PFN_vkGetImageMemoryRequirements g_GetImageMemoryRequirements = nullptr;
|
|
||||||
PFN_vkAllocateMemory g_AllocateMemory = nullptr;
|
|
||||||
PFN_vkFreeMemory g_FreeMemory = nullptr;
|
|
||||||
PFN_vkBindImageMemory g_BindImageMemory = nullptr;
|
|
||||||
PFN_vkCmdPipelineBarrier g_CmdPipelineBarrier = nullptr;
|
|
||||||
PFN_vkCmdCopyImage g_CmdCopyImage = nullptr;
|
|
||||||
PFN_vkDeviceWaitIdle g_DeviceWaitIdle = nullptr;
|
|
||||||
VkPhysicalDeviceMemoryProperties g_memory_properties{};
|
|
||||||
|
|
||||||
std::unique_ptr<zerofg::Interpolator> g_interpolator;
|
|
||||||
VkImage g_history = VK_NULL_HANDLE;
|
|
||||||
VkImageView g_history_view = VK_NULL_HANDLE;
|
|
||||||
VkDeviceMemory g_history_memory = VK_NULL_HANDLE;
|
|
||||||
uint32_t g_width = 0, g_height = 0;
|
|
||||||
VkFormat g_format = VK_FORMAT_UNDEFINED;
|
|
||||||
bool g_history_layout_defined = false, g_history_valid = false;
|
|
||||||
uint64_t g_history_sequence = 0;
|
|
||||||
bool g_history_recorded_pending = false;
|
|
||||||
uint64_t g_history_recorded_sequence = 0;
|
|
||||||
std::array<bool, 4> g_fallback_outputs{};
|
|
||||||
VkImage g_current = VK_NULL_HANDLE;
|
|
||||||
VkImageView g_current_view = VK_NULL_HANDLE;
|
|
||||||
uint64_t g_current_sequence = 0;
|
|
||||||
bool g_pair_pending = false;
|
|
||||||
// The interpolator keeps per-pair work and the prepared Real by sequence. A pass dropped after recording
|
|
||||||
// Interpolate never ran on the GPU, so the next pair's A gets a fresh identity no record has seen: nothing the
|
|
||||||
// dropped pass would have prepared is reused, nor its flow start. The identity is stable for the whole pair, so
|
|
||||||
// its phases still share their work (and ReallyZero sees one pair, not a first picture per phase).
|
|
||||||
bool g_interpolate_uncommitted = false;
|
|
||||||
bool g_record_stale = false;
|
|
||||||
uint64_t g_pair_anonymous = 0; // the recovery pair's A identity, 0 for an ordinary pair
|
|
||||||
uint64_t g_anonymous_count = 0;
|
|
||||||
constexpr uint64_t kAnonymousSequence = 1ull << 63; // above any frame sequence the compositor hands out
|
|
||||||
|
|
||||||
// Pacing. The compositor presents a pair's generated frames and its real frame back to back in FIFO,
|
|
||||||
// so they reach the panel on consecutive refreshes right after the tick that drew them.
|
|
||||||
constexpr uint64_t kBreakNs = 250000000ull;
|
|
||||||
constexpr size_t kIntervalWindow = 8;
|
|
||||||
constexpr size_t kMinIntervals = 4;
|
|
||||||
constexpr double kSlotTolerance = 0.15;
|
|
||||||
uint32_t g_multiplier = 2;
|
|
||||||
float g_refresh_hz = 0.0f;
|
|
||||||
bool g_layer_timing = false;
|
|
||||||
// The phases the pacer chose for this pair (count 0: none, the timing above decides).
|
|
||||||
std::array<float, 4> g_external_phases{};
|
|
||||||
uint32_t g_external_count = 0;
|
|
||||||
uint64_t g_last_sequence = 0;
|
|
||||||
uint64_t g_last_issue_ns = 0;
|
|
||||||
uint64_t g_pair_interval_ns = 0;
|
|
||||||
uint32_t g_prev_count = 0, g_pair_count = 0;
|
|
||||||
std::array<uint64_t, kIntervalWindow> g_intervals{};
|
|
||||||
size_t g_interval_count = 0, g_interval_next = 0;
|
|
||||||
|
|
||||||
uint64_t now_ns() {
|
|
||||||
return static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::nanoseconds>(
|
|
||||||
std::chrono::steady_clock::now().time_since_epoch()).count());
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset_pacing() {
|
|
||||||
g_last_issue_ns = 0;
|
|
||||||
g_pair_interval_ns = 0;
|
|
||||||
g_prev_count = g_pair_count = 0;
|
|
||||||
g_interval_count = g_interval_next = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t period_ns() {
|
|
||||||
return g_refresh_hz > 1.0f ? static_cast<uint64_t>(1e9 / static_cast<double>(g_refresh_hz)) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t typical_interval_ns() {
|
|
||||||
if (g_interval_count < kMinIntervals) return 0;
|
|
||||||
std::array<uint64_t, kIntervalWindow> sorted = g_intervals;
|
|
||||||
std::sort(sorted.begin(), sorted.begin() + g_interval_count);
|
|
||||||
return sorted[g_interval_count / 2];
|
|
||||||
}
|
|
||||||
|
|
||||||
void note_sequence(uint64_t sequence) {
|
|
||||||
if (sequence == g_last_sequence) return;
|
|
||||||
const uint64_t now = now_ns();
|
|
||||||
if (sequence < g_last_sequence) {
|
|
||||||
// The frame counter changed source (game frames vs compositor scenes): no pair across it.
|
|
||||||
g_history_valid = false;
|
|
||||||
g_history_sequence = 0;
|
|
||||||
reset_pacing();
|
|
||||||
} else if (g_last_issue_ns && now > g_last_issue_ns) {
|
|
||||||
const uint64_t interval = now - g_last_issue_ns;
|
|
||||||
if (interval > kBreakNs) {
|
|
||||||
reset_pacing();
|
|
||||||
} else {
|
|
||||||
g_pair_interval_ns = interval;
|
|
||||||
g_intervals[g_interval_next] = interval;
|
|
||||||
g_interval_next = (g_interval_next + 1) % kIntervalWindow;
|
|
||||||
g_interval_count = std::min(g_interval_count + 1, kIntervalWindow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
g_last_sequence = sequence;
|
|
||||||
g_last_issue_ns = now;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generated frames a pair can show without its presents queueing past the next game frame:
|
|
||||||
// one refresh each, the real frame one more, all inside the game's typical frame interval.
|
|
||||||
uint32_t pair_capacity(uint32_t wanted) {
|
|
||||||
const uint64_t period = period_ns();
|
|
||||||
const uint64_t typical = typical_interval_ns();
|
|
||||||
if (!period || !typical) return wanted;
|
|
||||||
const double slots = std::floor(static_cast<double>(typical) / static_cast<double>(period) + kSlotTolerance);
|
|
||||||
return slots < 2.0 ? 0u : std::min<uint32_t>(wanted, static_cast<uint32_t>(slots) - 1u);
|
|
||||||
}
|
|
||||||
|
|
||||||
// The scene layer (sc_layer.c) shows a group of [count] generated frames and then B, frame k of the group
|
|
||||||
// max(k, round(k * gap / (count + 1))) refreshes after the first, a group every game frame interval.
|
|
||||||
float layer_phase(uint32_t index, uint32_t count, uint64_t period) {
|
|
||||||
const float even = static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
|
||||||
int64_t cadence_gap = 0;
|
|
||||||
int cadence_frames = 0;
|
|
||||||
sc_layer_cadence_info(&cadence_gap, &cadence_frames);
|
|
||||||
const uint64_t gap = cadence_gap > 0 ? static_cast<uint64_t>(cadence_gap) : typical_interval_ns();
|
|
||||||
const uint32_t group_frames = cadence_frames > static_cast<int>(count)
|
|
||||||
? static_cast<uint32_t>(cadence_frames) : count + 1;
|
|
||||||
if (!gap) return even;
|
|
||||||
const int64_t slots = static_cast<int64_t>((gap + period / 2) / period);
|
|
||||||
if (slots < static_cast<int64_t>(group_frames)) return even;
|
|
||||||
const auto step = [&](uint32_t k) {
|
|
||||||
const int64_t s = static_cast<int64_t>((static_cast<uint64_t>(k) * gap / group_frames + period / 2) / period);
|
|
||||||
return std::max<int64_t>(s, k);
|
|
||||||
};
|
|
||||||
const double phase = static_cast<double>(step(index) - step(count) + slots) / static_cast<double>(slots);
|
|
||||||
return static_cast<float>(std::clamp(phase, 0.05, 0.95));
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIFO presents the generated group and B back-to-back; phase uses the measured real-frame span.
|
|
||||||
float pair_phase(uint32_t index, uint32_t count) {
|
|
||||||
if (g_external_count == count && index < count) return std::clamp(g_external_phases[index], 0.01f, 0.99f);
|
|
||||||
const float even = static_cast<float>(index + 1) / static_cast<float>(count + 1);
|
|
||||||
const uint64_t period = period_ns();
|
|
||||||
if (!period) return even;
|
|
||||||
if (g_layer_timing) return layer_phase(index, count, period);
|
|
||||||
if (!g_pair_interval_ns) return even;
|
|
||||||
const double span = static_cast<double>(g_pair_interval_ns) +
|
|
||||||
(static_cast<double>(count) - static_cast<double>(g_prev_count)) * static_cast<double>(period);
|
|
||||||
if (span <= static_cast<double>(period) * (count + 1)) return even;
|
|
||||||
const double phase = 1.0 - static_cast<double>(count - index) * static_cast<double>(period) / span;
|
|
||||||
return static_cast<float>(std::clamp(phase, 0.05, 0.95));
|
|
||||||
}
|
|
||||||
|
|
||||||
void load_device_functions() {
|
|
||||||
if (g_gipa && g_instance) {
|
|
||||||
g_GetPhysicalDeviceMemoryProperties =
|
|
||||||
reinterpret_cast<PFN_vkGetPhysicalDeviceMemoryProperties>(
|
|
||||||
g_gipa(g_instance, "vkGetPhysicalDeviceMemoryProperties"));
|
|
||||||
g_GetPhysicalDeviceFormatProperties =
|
|
||||||
reinterpret_cast<PFN_vkGetPhysicalDeviceFormatProperties>(
|
|
||||||
g_gipa(g_instance, "vkGetPhysicalDeviceFormatProperties"));
|
|
||||||
}
|
|
||||||
if (!g_gdpa || !g_device) return;
|
|
||||||
#define LOAD(name) g_##name = reinterpret_cast<PFN_vk##name>(g_gdpa(g_device, "vk" #name))
|
|
||||||
LOAD(CreateImage);
|
|
||||||
LOAD(DestroyImage);
|
|
||||||
LOAD(CreateImageView);
|
|
||||||
LOAD(DestroyImageView);
|
|
||||||
LOAD(GetImageMemoryRequirements);
|
|
||||||
LOAD(AllocateMemory);
|
|
||||||
LOAD(FreeMemory);
|
|
||||||
LOAD(BindImageMemory);
|
|
||||||
LOAD(CmdPipelineBarrier);
|
|
||||||
LOAD(CmdCopyImage);
|
|
||||||
LOAD(DeviceWaitIdle);
|
|
||||||
#undef LOAD
|
|
||||||
}
|
|
||||||
|
|
||||||
void clear_history_state() {
|
|
||||||
g_history_valid = false;
|
|
||||||
g_history_sequence = 0;
|
|
||||||
g_pair_pending = false;
|
|
||||||
g_current = VK_NULL_HANDLE;
|
|
||||||
g_current_view = VK_NULL_HANDLE;
|
|
||||||
g_current_sequence = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void destroy_history() {
|
|
||||||
if (g_device) {
|
|
||||||
if (g_history_view && g_DestroyImageView) g_DestroyImageView(g_device, g_history_view, nullptr);
|
|
||||||
if (g_history && g_DestroyImage) g_DestroyImage(g_device, g_history, nullptr);
|
|
||||||
if (g_history_memory && g_FreeMemory) g_FreeMemory(g_device, g_history_memory, nullptr);
|
|
||||||
}
|
|
||||||
g_history = VK_NULL_HANDLE;
|
|
||||||
g_history_view = VK_NULL_HANDLE;
|
|
||||||
g_history_memory = VK_NULL_HANDLE;
|
|
||||||
g_width = g_height = 0;
|
|
||||||
g_format = VK_FORMAT_UNDEFINED;
|
|
||||||
g_history_layout_defined = false;
|
|
||||||
clear_history_state();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t find_memory_type(uint32_t bits) {
|
|
||||||
uint32_t fallback = UINT32_MAX;
|
|
||||||
for (uint32_t i = 0; i < g_memory_properties.memoryTypeCount; ++i) {
|
|
||||||
if ((bits & (1u << i)) == 0) continue;
|
|
||||||
const auto flags = g_memory_properties.memoryTypes[i].propertyFlags;
|
|
||||||
if (flags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) return i;
|
|
||||||
if (fallback == UINT32_MAX) fallback = i;
|
|
||||||
}
|
|
||||||
return fallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool make_history(uint32_t width, uint32_t height, VkFormat format) {
|
|
||||||
if (!g_CreateImage || !g_GetImageMemoryRequirements || !g_AllocateMemory ||
|
|
||||||
!g_BindImageMemory || !g_CreateImageView || !g_GetPhysicalDeviceMemoryProperties) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "Vulkan image functions unavailable");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
VkImageCreateInfo image_info{};
|
|
||||||
image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
|
|
||||||
image_info.imageType = VK_IMAGE_TYPE_2D;
|
|
||||||
image_info.format = format;
|
|
||||||
image_info.extent = {width, height, 1};
|
|
||||||
image_info.mipLevels = 1;
|
|
||||||
image_info.arrayLayers = 1;
|
|
||||||
image_info.samples = VK_SAMPLE_COUNT_1_BIT;
|
|
||||||
image_info.tiling = VK_IMAGE_TILING_OPTIMAL;
|
|
||||||
image_info.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
||||||
image_info.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
|
||||||
image_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
if (g_CreateImage(g_device, &image_info, nullptr, &g_history) != VK_SUCCESS) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history image");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkMemoryRequirements requirements{};
|
|
||||||
g_GetImageMemoryRequirements(g_device, g_history, &requirements);
|
|
||||||
const uint32_t memory_index = find_memory_type(requirements.memoryTypeBits);
|
|
||||||
if (memory_index == UINT32_MAX) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "no compatible memory for temporal history");
|
|
||||||
destroy_history();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
VkMemoryAllocateInfo allocation{};
|
|
||||||
allocation.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
|
|
||||||
allocation.allocationSize = requirements.size;
|
|
||||||
allocation.memoryTypeIndex = memory_index;
|
|
||||||
if (g_AllocateMemory(g_device, &allocation, nullptr, &g_history_memory) != VK_SUCCESS ||
|
|
||||||
g_BindImageMemory(g_device, g_history, g_history_memory, 0) != VK_SUCCESS) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "could not allocate temporal history memory");
|
|
||||||
destroy_history();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
VkImageViewCreateInfo view_info{};
|
|
||||||
view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
|
|
||||||
view_info.image = g_history;
|
|
||||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D;
|
|
||||||
view_info.format = format;
|
|
||||||
view_info.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
|
||||||
if (g_CreateImageView(g_device, &view_info, nullptr, &g_history_view) != VK_SUCCESS) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "could not create temporal history view");
|
|
||||||
destroy_history();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
g_width = width;
|
|
||||||
g_height = height;
|
|
||||||
g_format = format;
|
|
||||||
g_history_layout_defined = false;
|
|
||||||
g_history_recorded_pending = false;
|
|
||||||
g_history_recorded_sequence = 0;
|
|
||||||
clear_history_state();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy_current_to_history(VkCommandBuffer cmd, VkImage source,
|
|
||||||
uint32_t width, uint32_t height, uint64_t sequence) {
|
|
||||||
if (!g_history || !source || !g_CmdPipelineBarrier || !g_CmdCopyImage) return;
|
|
||||||
VkImageMemoryBarrier before{};
|
|
||||||
before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
const bool layout_defined = g_history_layout_defined || g_history_recorded_pending;
|
|
||||||
before.srcAccessMask = layout_defined ? VK_ACCESS_SHADER_READ_BIT : 0;
|
|
||||||
before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
before.oldLayout = layout_defined ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_UNDEFINED;
|
|
||||||
before.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
before.image = g_history;
|
|
||||||
before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
|
||||||
g_CmdPipelineBarrier(cmd,
|
|
||||||
layout_defined ? VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT : VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 0, nullptr, 1, &before);
|
|
||||||
|
|
||||||
VkImageCopy region{};
|
|
||||||
region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
|
||||||
region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
|
||||||
region.extent = {width, height, 1};
|
|
||||||
g_CmdCopyImage(cmd, source, VK_IMAGE_LAYOUT_GENERAL, g_history, VK_IMAGE_LAYOUT_GENERAL, 1, ®ion);
|
|
||||||
|
|
||||||
VkImageMemoryBarrier after{};
|
|
||||||
after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
after.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
|
||||||
after.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
after.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
after.image = g_history;
|
|
||||||
after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
|
||||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
|
||||||
0, 0, nullptr, 0, nullptr, 1, &after);
|
|
||||||
g_history_recorded_pending = true;
|
|
||||||
g_history_recorded_sequence = sequence;
|
|
||||||
g_pair_pending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy_current_to_output(VkCommandBuffer cmd, VkImage output, uint32_t width, uint32_t height) {
|
|
||||||
if (!g_current || !output || !g_CmdPipelineBarrier || !g_CmdCopyImage) return;
|
|
||||||
VkImageMemoryBarrier before{};
|
|
||||||
before.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
before.srcAccessMask = VK_ACCESS_MEMORY_WRITE_BIT | VK_ACCESS_SHADER_WRITE_BIT;
|
|
||||||
before.dstAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
before.oldLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
before.newLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
||||||
before.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
before.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
before.image = output;
|
|
||||||
before.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
|
||||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT,
|
|
||||||
0, 0, nullptr, 0, nullptr, 1, &before);
|
|
||||||
VkImageCopy region{};
|
|
||||||
region.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
|
||||||
region.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
|
|
||||||
region.extent = {width, height, 1};
|
|
||||||
g_CmdCopyImage(cmd, g_current, VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
output, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, ®ion);
|
|
||||||
VkImageMemoryBarrier after{};
|
|
||||||
after.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
|
|
||||||
after.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
|
||||||
after.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_SHADER_READ_BIT;
|
|
||||||
after.oldLayout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL;
|
|
||||||
after.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
after.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
after.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
|
|
||||||
after.image = output;
|
|
||||||
after.subresourceRange = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1};
|
|
||||||
g_CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
|
||||||
0, 0, nullptr, 0, nullptr, 1, &after);
|
|
||||||
}
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance,
|
|
||||||
VkPhysicalDevice physical_device, VkDevice device,
|
|
||||||
uint32_t api_version, int synchronization2_enabled,
|
|
||||||
int extended_storage_formats_enabled) {
|
|
||||||
g_gipa = gipa;
|
|
||||||
g_instance = instance;
|
|
||||||
g_physical = physical_device;
|
|
||||||
g_device = device;
|
|
||||||
g_api_version = api_version;
|
|
||||||
g_synchronization2 = synchronization2_enabled != 0;
|
|
||||||
g_extended_formats = extended_storage_formats_enabled != 0;
|
|
||||||
g_gdpa = g_gipa && g_instance
|
|
||||||
? reinterpret_cast<PFN_vkGetDeviceProcAddr>(g_gipa(g_instance, "vkGetDeviceProcAddr"))
|
|
||||||
: nullptr;
|
|
||||||
load_device_functions();
|
|
||||||
if (g_GetPhysicalDeviceMemoryProperties && g_physical)
|
|
||||||
g_GetPhysicalDeviceMemoryProperties(g_physical, &g_memory_properties);
|
|
||||||
g_ready = g_device != VK_NULL_HANDLE;
|
|
||||||
g_supported = g_ready && g_api_version >= VK_API_VERSION_1_3 &&
|
|
||||||
g_synchronization2 && g_extended_formats;
|
|
||||||
g_failed = false;
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "%s", g_supported ? "available" :
|
|
||||||
"requires Vulkan 1.3, synchronization2 and shaderStorageImageExtendedFormats");
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_device_lost(void) {
|
|
||||||
g_interpolator.reset();
|
|
||||||
destroy_history();
|
|
||||||
g_gipa = nullptr; g_gdpa = nullptr;
|
|
||||||
g_instance = VK_NULL_HANDLE; g_physical = VK_NULL_HANDLE; g_device = VK_NULL_HANDLE;
|
|
||||||
g_ready = g_supported = g_failed = false;
|
|
||||||
g_synchronization2 = g_extended_formats = false;
|
|
||||||
g_api_version = VK_API_VERSION_1_0;
|
|
||||||
g_GetPhysicalDeviceMemoryProperties = nullptr;
|
|
||||||
g_GetPhysicalDeviceFormatProperties = nullptr;
|
|
||||||
g_CreateImage = nullptr; g_DestroyImage = nullptr;
|
|
||||||
g_CreateImageView = nullptr; g_DestroyImageView = nullptr;
|
|
||||||
g_GetImageMemoryRequirements = nullptr; g_AllocateMemory = nullptr;
|
|
||||||
g_FreeMemory = nullptr; g_BindImageMemory = nullptr;
|
|
||||||
g_CmdPipelineBarrier = nullptr; g_CmdCopyImage = nullptr; g_DeviceWaitIdle = nullptr;
|
|
||||||
g_memory_properties = {};
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "device lost");
|
|
||||||
}
|
|
||||||
|
|
||||||
int zfg_caps_ok(void) { return g_supported ? 1 : 0; }
|
|
||||||
const char *zfg_caps_reason(void) { return g_reason; }
|
|
||||||
|
|
||||||
int zfg_start(void) {
|
|
||||||
if (!g_supported || !g_ready) return 0;
|
|
||||||
if (g_interpolator) return 1;
|
|
||||||
zerofg::CreateInfo info{};
|
|
||||||
info.vulkan.instance = g_instance;
|
|
||||||
info.vulkan.physical_device = g_physical;
|
|
||||||
info.vulkan.device = g_device;
|
|
||||||
info.vulkan.get_instance_proc_addr = g_gipa;
|
|
||||||
info.mode = zerofg::Mode::kReallyZero;
|
|
||||||
info.backend = zerofg::Backend::kCompat;
|
|
||||||
info.frame_context_count = 4;
|
|
||||||
info.capabilities.effective_api_version = g_api_version;
|
|
||||||
info.capabilities.synchronization2_enabled = g_synchronization2;
|
|
||||||
info.capabilities.shader_storage_image_extended_formats_enabled = g_extended_formats;
|
|
||||||
zerofg::Status status = zerofg::Status::kSuccess;
|
|
||||||
g_interpolator = zerofg::Interpolator::Create(info, &status);
|
|
||||||
if (!g_interpolator) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "interpolator creation failed (%d)", (int)status);
|
|
||||||
g_failed = true;
|
|
||||||
ZFG_ERR("%s", g_reason);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
g_failed = false;
|
|
||||||
ZFG_LOG("ReallyZero engine ready (Compat backend)");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_stop(void) {
|
|
||||||
g_interpolator.reset();
|
|
||||||
destroy_history();
|
|
||||||
reset_pacing();
|
|
||||||
g_last_sequence = 0;
|
|
||||||
g_failed = false;
|
|
||||||
}
|
|
||||||
int zfg_unavailable(void) { return g_failed || !g_interpolator ? 1 : 0; }
|
|
||||||
|
|
||||||
int zfg_format_ok(VkFormat format) {
|
|
||||||
if (!g_supported || !g_GetPhysicalDeviceFormatProperties || format == VK_FORMAT_UNDEFINED) return 0;
|
|
||||||
VkFormatProperties input{};
|
|
||||||
g_GetPhysicalDeviceFormatProperties(g_physical, format, &input);
|
|
||||||
const VkFormatFeatureFlags sampled =
|
|
||||||
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
|
|
||||||
if ((input.optimalTilingFeatures & sampled) != sampled) return 0;
|
|
||||||
if (format == VK_FORMAT_A2B10G10R10_UNORM_PACK32)
|
|
||||||
return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) != 0;
|
|
||||||
VkFormatProperties internal{};
|
|
||||||
g_GetPhysicalDeviceFormatProperties(g_physical, VK_FORMAT_A2B10G10R10_UNORM_PACK32, &internal);
|
|
||||||
const VkFormatFeatureFlags needed = VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT | VK_FORMAT_FEATURE_BLIT_SRC_BIT;
|
|
||||||
return (input.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_DST_BIT) != 0 &&
|
|
||||||
(internal.optimalTilingFeatures & needed) == needed;
|
|
||||||
}
|
|
||||||
|
|
||||||
int zfg_prepare(uint32_t width, uint32_t height, VkFormat format) {
|
|
||||||
if (!g_interpolator || g_failed || !width || !height) return 0;
|
|
||||||
if (!zfg_format_ok(format)) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "unsupported input/output format %d", (int)format);
|
|
||||||
g_failed = true;
|
|
||||||
ZFG_ERR("%s", g_reason);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (g_width == width && g_height == height && g_format == format && g_history) return 1;
|
|
||||||
// ReallyZero's Resize accepts 64..16384 per side: refuse this frame only, before touching the
|
|
||||||
// engine's state, so a supported size later still generates.
|
|
||||||
if (width < 64 || height < 64 || width > 16384 || height > 16384) return 0;
|
|
||||||
if (g_DeviceWaitIdle) g_DeviceWaitIdle(g_device);
|
|
||||||
destroy_history();
|
|
||||||
const zerofg::Status resized = g_interpolator->Resize(width, height, format, format);
|
|
||||||
if (resized != zerofg::Status::kSuccess) {
|
|
||||||
std::snprintf(g_reason, sizeof(g_reason), "resize failed (%d)", (int)resized);
|
|
||||||
g_failed = true;
|
|
||||||
ZFG_ERR("%s", g_reason);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (!make_history(width, height, format)) {
|
|
||||||
g_failed = true;
|
|
||||||
ZFG_ERR("%s", g_reason);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
ZFG_LOG("prepared %ux%u format %d", width, height, (int)format);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_configure(uint32_t multiplier, float refresh_hz) {
|
|
||||||
g_multiplier = std::clamp<uint32_t>(multiplier, 2, 4);
|
|
||||||
g_refresh_hz = refresh_hz > 1.0f ? refresh_hz : 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_set_layer_timing(int layer) { g_layer_timing = layer != 0; }
|
|
||||||
|
|
||||||
void zfg_set_phases(const float *phases, uint32_t count) {
|
|
||||||
g_external_count = phases ? std::min<uint32_t>(count, static_cast<uint32_t>(g_external_phases.size())) : 0;
|
|
||||||
for (uint32_t i = 0; i < g_external_count; i++) g_external_phases[i] = phases[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
float zfg_phase(uint32_t index, uint32_t count) { return pair_phase(index, count); }
|
|
||||||
|
|
||||||
uint32_t zfg_plan(uint32_t capacity, uint64_t sequence) {
|
|
||||||
if (!g_interpolator || g_failed) return 0;
|
|
||||||
note_sequence(sequence);
|
|
||||||
if (!g_history_valid || sequence <= g_history_sequence || !g_pair_interval_ns) return 0;
|
|
||||||
return pair_capacity(std::min<uint32_t>({capacity, 3u, g_multiplier - 1}));
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_telemetry(float *generated, float *source_rate) {
|
|
||||||
const uint64_t typical = typical_interval_ns();
|
|
||||||
*generated = static_cast<float>(g_pair_count);
|
|
||||||
*source_rate = typical ? static_cast<float>(1e9 / static_cast<double>(typical)) : 0.0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_process(VkCommandBuffer cmd, VkImage source, VkImageView source_view,
|
|
||||||
uint32_t width, uint32_t height, VkFormat format,
|
|
||||||
uint64_t sequence, uint32_t generations) {
|
|
||||||
g_pair_pending = false;
|
|
||||||
g_fallback_outputs.fill(false);
|
|
||||||
if (!g_interpolator || g_failed || !source || !g_history ||
|
|
||||||
format != g_format || width != g_width || height != g_height) return;
|
|
||||||
if (sequence > g_history_sequence) {
|
|
||||||
g_prev_count = g_pair_count;
|
|
||||||
g_pair_count = generations;
|
|
||||||
}
|
|
||||||
if (generations == 0 || !g_history_valid || sequence <= g_history_sequence) {
|
|
||||||
copy_current_to_history(cmd, source, width, height, sequence);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!source_view) return;
|
|
||||||
g_current = source;
|
|
||||||
g_current_view = source_view;
|
|
||||||
g_current_sequence = sequence;
|
|
||||||
g_pair_pending = true;
|
|
||||||
g_pair_anonymous = g_record_stale ? (kAnonymousSequence | ++g_anonymous_count) : 0;
|
|
||||||
g_record_stale = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_generate(VkCommandBuffer cmd, uint32_t index, uint32_t count,
|
|
||||||
VkImage output, VkImageView output_view, uint32_t width, uint32_t height) {
|
|
||||||
if (!g_pair_pending || !g_interpolator || !g_history_valid || index >= count || !output || !output_view) return;
|
|
||||||
const float phase = pair_phase(index, count);
|
|
||||||
zerofg::Image previous{};
|
|
||||||
previous.image = g_history; previous.view = g_history_view;
|
|
||||||
previous.layout = VK_IMAGE_LAYOUT_GENERAL; previous.format = g_format;
|
|
||||||
previous.width = g_width; previous.height = g_height;
|
|
||||||
previous.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
||||||
previous.sequence = g_history_sequence;
|
|
||||||
zerofg::Image current{};
|
|
||||||
current.image = g_current; current.view = g_current_view;
|
|
||||||
current.layout = VK_IMAGE_LAYOUT_GENERAL; current.format = g_format;
|
|
||||||
current.width = g_width; current.height = g_height;
|
|
||||||
current.usage = VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
|
|
||||||
current.sequence = g_current_sequence;
|
|
||||||
zerofg::Image result{};
|
|
||||||
result.image = output; result.view = output_view;
|
|
||||||
result.layout = VK_IMAGE_LAYOUT_GENERAL; result.format = g_format;
|
|
||||||
result.width = width; result.height = height;
|
|
||||||
result.usage = VK_IMAGE_USAGE_STORAGE_BIT | VK_IMAGE_USAGE_SAMPLED_BIT |
|
|
||||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
|
||||||
if (g_pair_anonymous) previous.sequence = g_pair_anonymous;
|
|
||||||
g_interpolate_uncommitted = true;
|
|
||||||
|
|
||||||
const zerofg::Status status =
|
|
||||||
g_interpolator->Interpolate(cmd, index, previous, current, phase, result);
|
|
||||||
if (status != zerofg::Status::kSuccess) {
|
|
||||||
ZFG_ERR("interpolation status %d; copying the real frame as fallback", (int)status);
|
|
||||||
g_fallback_outputs[index] = true;
|
|
||||||
copy_current_to_output(cmd, output, width, height);
|
|
||||||
}
|
|
||||||
if (index + 1 >= count) {
|
|
||||||
copy_current_to_history(cmd, g_current, width, height, g_current_sequence);
|
|
||||||
g_pair_pending = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_commit_history_update(void) {
|
|
||||||
g_interpolate_uncommitted = false;
|
|
||||||
if (!g_history_recorded_pending) return;
|
|
||||||
g_history_layout_defined = true;
|
|
||||||
g_history_valid = true;
|
|
||||||
g_history_sequence = g_history_recorded_sequence;
|
|
||||||
g_history_recorded_pending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_discard_history_update(void) {
|
|
||||||
g_history_recorded_pending = false;
|
|
||||||
g_history_recorded_sequence = 0;
|
|
||||||
if (g_interpolate_uncommitted) g_record_stale = true;
|
|
||||||
g_interpolate_uncommitted = false;
|
|
||||||
g_pair_pending = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void zfg_forget_targets(void) {
|
|
||||||
g_pair_pending = false;
|
|
||||||
if (g_interpolate_uncommitted) g_record_stale = true;
|
|
||||||
g_interpolate_uncommitted = false;
|
|
||||||
g_history_recorded_pending = false;
|
|
||||||
g_history_recorded_sequence = 0;
|
|
||||||
g_history_valid = false;
|
|
||||||
g_history_sequence = 0;
|
|
||||||
reset_pacing();
|
|
||||||
}
|
|
||||||
} // extern "C"
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#ifndef FRAMEGEN_ZEROFG_H
|
|
||||||
#define FRAMEGEN_ZEROFG_H
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <vulkan/vulkan.h>
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
void zfg_device_ready(PFN_vkGetInstanceProcAddr gipa, VkInstance instance,
|
|
||||||
VkPhysicalDevice physical_device, VkDevice device,
|
|
||||||
uint32_t api_version, int synchronization2_enabled,
|
|
||||||
int extended_storage_formats_enabled);
|
|
||||||
void zfg_device_lost(void);
|
|
||||||
int zfg_caps_ok(void);
|
|
||||||
const char *zfg_caps_reason(void);
|
|
||||||
int zfg_start(void);
|
|
||||||
void zfg_stop(void);
|
|
||||||
int zfg_unavailable(void);
|
|
||||||
int zfg_format_ok(VkFormat format);
|
|
||||||
int zfg_prepare(uint32_t width, uint32_t height, VkFormat format);
|
|
||||||
void zfg_configure(uint32_t multiplier, float refresh_hz);
|
|
||||||
void zfg_set_layer_timing(int layer);
|
|
||||||
void zfg_set_phases(const float *phases, uint32_t count);
|
|
||||||
float zfg_phase(uint32_t index, uint32_t count);
|
|
||||||
uint32_t zfg_plan(uint32_t capacity, uint64_t sequence);
|
|
||||||
void zfg_telemetry(float *generated, float *source_rate);
|
|
||||||
void zfg_process(VkCommandBuffer command_buffer, VkImage source, VkImageView source_view,
|
|
||||||
uint32_t width, uint32_t height, VkFormat format,
|
|
||||||
uint64_t sequence, uint32_t generations);
|
|
||||||
void zfg_generate(VkCommandBuffer command_buffer, uint32_t index, uint32_t count,
|
|
||||||
VkImage output, VkImageView output_view,
|
|
||||||
uint32_t width, uint32_t height);
|
|
||||||
void zfg_forget_targets(void);
|
|
||||||
void zfg_commit_history_update(void);
|
|
||||||
void zfg_discard_history_update(void);
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
@@ -58,7 +58,6 @@ static struct {
|
|||||||
void (*reparent)(ASurfaceTransaction *, ASurfaceControl *, ASurfaceControl *);
|
void (*reparent)(ASurfaceTransaction *, ASurfaceControl *, ASurfaceControl *);
|
||||||
void (*setOnComplete)(ASurfaceTransaction *, void *, sc_complete_fn);
|
void (*setOnComplete)(ASurfaceTransaction *, void *, sc_complete_fn);
|
||||||
int (*prevReleaseFence)(ASurfaceTransactionStats *, ASurfaceControl *);
|
int (*prevReleaseFence)(ASurfaceTransactionStats *, ASurfaceControl *);
|
||||||
int (*presentFence)(ASurfaceTransactionStats *);
|
|
||||||
void (*setFrameRate)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t);
|
void (*setFrameRate)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t);
|
||||||
void (*setFrameRateStrategy)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t, int8_t);
|
void (*setFrameRateStrategy)(ASurfaceTransaction *, ASurfaceControl *, float, int8_t, int8_t);
|
||||||
void (*setBufferDataSpace)(ASurfaceTransaction *, ASurfaceControl *, int32_t);
|
void (*setBufferDataSpace)(ASurfaceTransaction *, ASurfaceControl *, int32_t);
|
||||||
@@ -103,7 +102,6 @@ static int load_api(void) {
|
|||||||
SYM(reparent, "ASurfaceTransaction_reparent");
|
SYM(reparent, "ASurfaceTransaction_reparent");
|
||||||
SYM(setOnComplete, "ASurfaceTransaction_setOnComplete");
|
SYM(setOnComplete, "ASurfaceTransaction_setOnComplete");
|
||||||
SYM(prevReleaseFence, "ASurfaceTransactionStats_getPreviousReleaseFenceFd");
|
SYM(prevReleaseFence, "ASurfaceTransactionStats_getPreviousReleaseFenceFd");
|
||||||
SYM(presentFence, "ASurfaceTransactionStats_getPresentFenceFd");
|
|
||||||
SYM(setFrameRate, "ASurfaceTransaction_setFrameRate");
|
SYM(setFrameRate, "ASurfaceTransaction_setFrameRate");
|
||||||
SYM(setFrameRateStrategy, "ASurfaceTransaction_setFrameRateWithChangeStrategy");
|
SYM(setFrameRateStrategy, "ASurfaceTransaction_setFrameRateWithChangeStrategy");
|
||||||
SYM(setBufferDataSpace, "ASurfaceTransaction_setBufferDataSpace");
|
SYM(setBufferDataSpace, "ASurfaceTransaction_setBufferDataSpace");
|
||||||
@@ -189,8 +187,6 @@ struct layer {
|
|||||||
static struct layer g_layers[SC_LAYER_COUNT];
|
static struct layer g_layers[SC_LAYER_COUNT];
|
||||||
static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l);
|
static void apply_frame_rate(ASurfaceTransaction *tx, struct layer *l);
|
||||||
static void coverage_text(const struct layer *l, char *out, size_t n);
|
static void coverage_text(const struct layer *l, char *out, size_t n);
|
||||||
static int overlay_slot(struct layer *l, struct vkp_image *src, int *idx, int *wait_fd);
|
|
||||||
static int overlay_shown(struct layer *l, int idx, const int geo[8], int translucent);
|
|
||||||
static int g_layers_ready;
|
static int g_layers_ready;
|
||||||
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||||
static int g_pending_cb;
|
static int g_pending_cb;
|
||||||
@@ -267,33 +263,7 @@ static int64_t cadence_target(int64_t now, int64_t earliest, int64_t period) {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t g_planned_next_ns;
|
|
||||||
|
|
||||||
void sc_layer_set_planned(int64_t present_ns) {
|
|
||||||
pthread_mutex_lock(&g_lock);
|
|
||||||
g_planned_next_ns = present_ns;
|
|
||||||
pthread_mutex_unlock(&g_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns) {
|
|
||||||
pthread_mutex_lock(&g_timeline_lock);
|
|
||||||
*present_ns = g_timeline_present_ns;
|
|
||||||
*period_ns = g_timeline_period_ns;
|
|
||||||
pthread_mutex_unlock(&g_timeline_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames) {
|
|
||||||
if (gap_ns) *gap_ns = g_cadence_gap_ns;
|
|
||||||
if (group_frames) *group_frames = g_group_frames;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void apply_present_time(ASurfaceTransaction *tx, int game) {
|
static void apply_present_time(ASurfaceTransaction *tx, int game) {
|
||||||
pthread_mutex_lock(&g_lock);
|
|
||||||
const int64_t planned = game ? g_planned_next_ns : 0;
|
|
||||||
if (game) {
|
|
||||||
g_planned_next_ns = 0;
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&g_lock);
|
|
||||||
if (!api.setDesiredPresentTime) return;
|
if (!api.setDesiredPresentTime) return;
|
||||||
pthread_mutex_lock(&g_timeline_lock);
|
pthread_mutex_lock(&g_timeline_lock);
|
||||||
const int64_t present = g_timeline_present_ns, deadline = g_timeline_deadline_ns, period = g_timeline_period_ns;
|
const int64_t present = g_timeline_present_ns, deadline = g_timeline_deadline_ns, period = g_timeline_period_ns;
|
||||||
@@ -313,9 +283,6 @@ static void apply_present_time(ASurfaceTransaction *tx, int game) {
|
|||||||
target = cadence_target(now, target, period);
|
target = cadence_target(now, target, period);
|
||||||
}
|
}
|
||||||
if (game && g_group_frames > 1 && ++g_group_index >= g_group_frames) { g_group_index = 0; g_group_frames = 1; }
|
if (game && g_group_frames > 1 && ++g_group_index >= g_group_frames) { g_group_index = 0; g_group_frames = 1; }
|
||||||
if (planned > 0) {
|
|
||||||
target = planned;
|
|
||||||
}
|
|
||||||
api.setDesiredPresentTime(tx, target - period / 2);
|
api.setDesiredPresentTime(tx, target - period / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,15 +721,9 @@ static int layer_geometry(int w, int h, int scene_w, int scene_h, const struct v
|
|||||||
static ARect g_game_src, g_game_dst;
|
static ARect g_game_src, g_game_dst;
|
||||||
static int g_game_geo_known;
|
static int g_game_geo_known;
|
||||||
|
|
||||||
static void note_game_geometry(const int r[8]) {
|
|
||||||
g_game_src = (ARect){r[0], r[1], r[2], r[3]};
|
|
||||||
g_game_dst = (ARect){r[4], r[5], r[6], r[7]};
|
|
||||||
g_game_geo_known = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void apply_geometry(ASurfaceTransaction *tx, struct layer *l, const int r[8]) {
|
static void apply_geometry(ASurfaceTransaction *tx, struct layer *l, const int r[8]) {
|
||||||
ARect srcR = {r[0], r[1], r[2], r[3]}, dstR = {r[4], r[5], r[6], r[7]};
|
ARect srcR = {r[0], r[1], r[2], r[3]}, dstR = {r[4], r[5], r[6], r[7]};
|
||||||
if (l == &g_layers[SC_LAYER_GAME]) note_game_geometry(r);
|
if (l == &g_layers[SC_LAYER_GAME]) { g_game_src = srcR; g_game_dst = dstR; g_game_geo_known = 1; }
|
||||||
if (!l->geo_valid || memcmp(&srcR, &l->geo_src, sizeof(srcR)) || memcmp(&dstR, &l->geo_dst, sizeof(dstR))) {
|
if (!l->geo_valid || memcmp(&srcR, &l->geo_src, sizeof(srcR)) || memcmp(&dstR, &l->geo_dst, sizeof(dstR))) {
|
||||||
api.setGeometry(tx, l->sc, &srcR, &dstR, 0 );
|
api.setGeometry(tx, l->sc, &srcR, &dstR, 0 );
|
||||||
l->geo_src = srcR; l->geo_dst = dstR; l->geo_valid = 1;
|
l->geo_src = srcR; l->geo_dst = dstR; l->geo_valid = 1;
|
||||||
@@ -924,9 +885,7 @@ static int present_slot(struct layer *l, int idx, const int r[8], const struct d
|
|||||||
int translucent) {
|
int translucent) {
|
||||||
struct slot *s = &l->slots[idx];
|
struct slot *s = &l->slots[idx];
|
||||||
ASurfaceTransaction *tx = api.txCreate();
|
ASurfaceTransaction *tx = api.txCreate();
|
||||||
if (!tx) {
|
if (!tx) return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const int was_shown = l->shown;
|
const int was_shown = l->shown;
|
||||||
const int32_t ds_applied = l->ds_applied;
|
const int32_t ds_applied = l->ds_applied;
|
||||||
const uint32_t md_applied = l->md_applied;
|
const uint32_t md_applied = l->md_applied;
|
||||||
@@ -1039,40 +998,19 @@ unavailable:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
|
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
|
||||||
const struct droiddeck_color *color, const struct vkp_draw *over, int *over_shown) {
|
const struct droiddeck_color *color) {
|
||||||
struct layer *l = layer_of(SC_LAYER_GAME);
|
struct layer *l = layer_of(SC_LAYER_GAME);
|
||||||
*over_shown = 0;
|
|
||||||
if (!src || ensure_sc(l) != 0) return -1;
|
if (!src || ensure_sc(l) != 0) return -1;
|
||||||
int sw = vkp_image_width(src), sh = vkp_image_height(src);
|
int sw = vkp_image_width(src), sh = vkp_image_height(src);
|
||||||
int r[8];
|
int r[8];
|
||||||
int g = layer_geometry(sw, sh, scene_w, scene_h, draw, r);
|
int g = layer_geometry(sw, sh, scene_w, scene_h, draw, r);
|
||||||
if (g < 0) return -1;
|
if (g < 0) return -1;
|
||||||
int og[8];
|
if (g == 0) { sc_layer_hide(); return 0; }
|
||||||
if (over && !vkp_map_draw(over, og)) over = NULL;
|
|
||||||
if (g == 0) {
|
|
||||||
sc_layer_hide();
|
|
||||||
if (over) *over_shown = sc_layer_present_overlay(over->img, og, over->blend) == 0 ? 1 : -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct vkp_blit blits[2] = {{.src = src, .wait_fd = -1}, {.src = over ? over->img : NULL, .wait_fd = -1}};
|
int wait_fd;
|
||||||
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &blits[0].wait_fd);
|
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||||
if (idx < 0) {
|
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||||
log_drop(l);
|
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
|
||||||
if (g_alloc_failed) return -1;
|
|
||||||
if (over) *over_shown = sc_layer_present_overlay(over->img, og, over->blend) == 0 ? 1 : -1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
blits[0].dst = l->slots[idx].img;
|
|
||||||
struct layer *ol = layer_of(SC_LAYER_OVERLAY);
|
|
||||||
int over_idx = -1;
|
|
||||||
if (over) {
|
|
||||||
note_game_geometry(r);
|
|
||||||
const int taken = overlay_slot(ol, over->img, &over_idx, &blits[1].wait_fd);
|
|
||||||
*over_shown = taken < 0 ? -1 : 1;
|
|
||||||
if (taken > 0) blits[1].dst = ol->slots[over_idx].img;
|
|
||||||
}
|
|
||||||
if (vkp_blit_images(blits, over_idx >= 0 ? 2 : 1) != 0) return -1;
|
|
||||||
if (present_slot(l, idx, r, color, 0) != 0) return -1;
|
if (present_slot(l, idx, r, color, 0) != 0) return -1;
|
||||||
if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_LAYER_COPY, AHB_RGBA8);
|
if (color && color->dataspace) droiddeck_color_frame_shown(color, DROIDDECK_HDR_LAYER_COPY, AHB_RGBA8);
|
||||||
if (!l->first_logged) {
|
if (!l->first_logged) {
|
||||||
@@ -1082,7 +1020,6 @@ int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const stru
|
|||||||
pool_kind(l->pool_modifier), l->pool_n);
|
pool_kind(l->pool_modifier), l->pool_n);
|
||||||
}
|
}
|
||||||
vkp_signal_first_frame();
|
vkp_signal_first_frame();
|
||||||
if (over_idx >= 0 && overlay_shown(ol, over_idx, og, over->blend) != 0) *over_shown = -1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1138,7 +1075,6 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
|||||||
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
|
if (vkp_update_map(scene_w, scene_h) != 0) return -1;
|
||||||
const int deep = hf && !hf->tonemap;
|
const int deep = hf && !hf->tonemap;
|
||||||
if (hf) composed = 1;
|
if (hf) composed = 1;
|
||||||
vkp_framegen_set_paced_route(composed);
|
|
||||||
if (hf && hf->tonemap) color = NULL;
|
if (hf && hf->tonemap) color = NULL;
|
||||||
int n = vkp_pass_begin_generate(scene_w, scene_h, draws, n_draws, hf, &rw, &rh);
|
int n = vkp_pass_begin_generate(scene_w, scene_h, draws, n_draws, hf, &rw, &rh);
|
||||||
if (n < 0) return -1;
|
if (n < 0) return -1;
|
||||||
@@ -1148,7 +1084,7 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
|||||||
if (!mapped) { vkp_pass_abort(); sc_layer_hide(); return 0; }
|
if (!mapped) { vkp_pass_abort(); sc_layer_hide(); return 0; }
|
||||||
idx[VKP_FG_MAX_GENERATIONS] = deep ? take_hdr_slot(l, rw, rh, &first_fd)
|
idx[VKP_FG_MAX_GENERATIONS] = deep ? take_hdr_slot(l, rw, rh, &first_fd)
|
||||||
: take_free_slot(l, rw, rh, AHB_RGBA8, &first_fd);
|
: take_free_slot(l, rw, rh, AHB_RGBA8, &first_fd);
|
||||||
if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); vkp_framegen_pacer_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
|
if (idx[VKP_FG_MAX_GENERATIONS] < 0) { vkp_pass_abort(); log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||||
pthread_mutex_lock(&g_lock);
|
pthread_mutex_lock(&g_lock);
|
||||||
l->slots[idx[VKP_FG_MAX_GENERATIONS]].busy = 1;
|
l->slots[idx[VKP_FG_MAX_GENERATIONS]].busy = 1;
|
||||||
pthread_mutex_unlock(&g_lock);
|
pthread_mutex_unlock(&g_lock);
|
||||||
@@ -1170,18 +1106,13 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
|||||||
if (!have_fd) { first_fd = fd; have_fd = 1; }
|
if (!have_fd) { first_fd = fd; have_fd = 1; }
|
||||||
}
|
}
|
||||||
if (vkp_pass_copy_generated(dst, m, real, first_fd) != 0) {
|
if (vkp_pass_copy_generated(dst, m, real, first_fd) != 0) {
|
||||||
vkp_framegen_pacer_abort();
|
|
||||||
slots_idle(l, idx, 0, m);
|
slots_idle(l, idx, 0, m);
|
||||||
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
g_group_frames = m + 1;
|
g_group_frames = m + 1;
|
||||||
for (int k = 0; k < m; k++) {
|
for (int k = 0; k < m; k++) {
|
||||||
int64_t planned;
|
|
||||||
vkp_framegen_output_planned(k, m, &planned);
|
|
||||||
sc_layer_set_planned(planned);
|
|
||||||
if (present_slot(l, idx[k], r, color, 0) == 0) continue;
|
if (present_slot(l, idx[k], r, color, 0) == 0) continue;
|
||||||
vkp_framegen_pacer_abort();
|
|
||||||
slots_idle(l, idx, k, m);
|
slots_idle(l, idx, k, m);
|
||||||
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
if (real) slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||||
g_group_index = 0;
|
g_group_index = 0;
|
||||||
@@ -1190,11 +1121,7 @@ int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const
|
|||||||
}
|
}
|
||||||
vkp_framegen_presented(m);
|
vkp_framegen_presented(m);
|
||||||
if (real) {
|
if (real) {
|
||||||
int64_t planned;
|
|
||||||
vkp_framegen_output_planned(m, m, &planned);
|
|
||||||
sc_layer_set_planned(planned);
|
|
||||||
if (present_slot(l, idx[VKP_FG_MAX_GENERATIONS], r, color, 0) != 0) {
|
if (present_slot(l, idx[VKP_FG_MAX_GENERATIONS], r, color, 0) != 0) {
|
||||||
vkp_framegen_pacer_abort();
|
|
||||||
slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
slots_idle(l, idx, VKP_FG_MAX_GENERATIONS, VKP_FG_MAX_GENERATIONS + 1);
|
||||||
g_group_index = 0;
|
g_group_index = 0;
|
||||||
g_group_frames = 1;
|
g_group_frames = 1;
|
||||||
@@ -1282,19 +1209,17 @@ int sc_layer_overlay_affordable(void) {
|
|||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int overlay_slot(struct layer *l, struct vkp_image *src, int *idx, int *wait_fd) {
|
int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent) {
|
||||||
*wait_fd = -1;
|
struct layer *l = layer_of(SC_LAYER_OVERLAY);
|
||||||
if (!src) return -1;
|
if (!src || !geo) return -1;
|
||||||
if (!sc_layer_overlay_affordable()) return -1;
|
if (!sc_layer_overlay_affordable()) return -1;
|
||||||
if (ensure_sc(l) != 0) return -1;
|
if (ensure_sc(l) != 0) return -1;
|
||||||
int sw = vkp_image_width(src), sh = vkp_image_height(src);
|
int sw = vkp_image_width(src), sh = vkp_image_height(src);
|
||||||
if (sw <= 0 || sh <= 0) return -1;
|
if (sw <= 0 || sh <= 0) return -1;
|
||||||
*idx = take_free_slot(l, sw, sh, AHB_RGBA8, wait_fd);
|
int wait_fd;
|
||||||
if (*idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
|
int idx = take_free_slot(l, sw, sh, AHB_RGBA8, &wait_fd);
|
||||||
return 1;
|
if (idx < 0) { log_drop(l); return g_alloc_failed ? -1 : 0; }
|
||||||
}
|
if (vkp_blit_image(src, l->slots[idx].img, wait_fd) != 0) return -1;
|
||||||
|
|
||||||
static int overlay_shown(struct layer *l, int idx, const int geo[8], int translucent) {
|
|
||||||
if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1;
|
if (present_slot(l, idx, geo, NULL, translucent) != 0) return -1;
|
||||||
if (!l->first_logged) {
|
if (!l->first_logged) {
|
||||||
l->first_logged = 1;
|
l->first_logged = 1;
|
||||||
@@ -1303,18 +1228,6 @@ static int overlay_shown(struct layer *l, int idx, const int geo[8], int translu
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sc_layer_present_overlay(struct vkp_image *src, const int geo[8], int translucent) {
|
|
||||||
struct layer *l = layer_of(SC_LAYER_OVERLAY);
|
|
||||||
if (!geo) return -1;
|
|
||||||
int idx;
|
|
||||||
struct vkp_blit blit = {.src = src, .wait_fd = -1};
|
|
||||||
const int taken = overlay_slot(l, src, &idx, &blit.wait_fd);
|
|
||||||
if (taken <= 0) return taken;
|
|
||||||
blit.dst = l->slots[idx].img;
|
|
||||||
if (vkp_blit_images(&blit, 1) != 0) return -1;
|
|
||||||
return overlay_shown(l, idx, geo, translucent);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int hide_layer(struct layer *l) {
|
static int hide_layer(struct layer *l) {
|
||||||
if (!l->sc || !l->shown || api.state != 1) return 0;
|
if (!l->sc || !l->shown || api.state != 1) return 0;
|
||||||
ASurfaceTransaction *tx = api.txCreate();
|
ASurfaceTransaction *tx = api.txCreate();
|
||||||
|
|||||||
@@ -4,10 +4,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <android/hardware_buffer.h>
|
#include <android/hardware_buffer.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct vkp_image;
|
struct vkp_image;
|
||||||
struct vkp_draw;
|
struct vkp_draw;
|
||||||
struct droiddeck_color;
|
struct droiddeck_color;
|
||||||
@@ -26,7 +22,7 @@ void sc_layer_hdr_symbols(char *out, size_t size);
|
|||||||
|
|
||||||
|
|
||||||
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
|
int sc_layer_present(struct vkp_image *src, int scene_w, int scene_h, const struct vkp_draw *draw,
|
||||||
const struct droiddeck_color *color, const struct vkp_draw *over, int *over_shown);
|
const struct droiddeck_color *color);
|
||||||
|
|
||||||
int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int scene_h);
|
int sc_layer_present_pass(const struct vkp_draw *draws, int n, int scene_w, int scene_h);
|
||||||
int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const struct vkp_hdr_frame *hf,
|
int sc_layer_present_generated(const struct vkp_draw *draws, int n_draws, const struct vkp_hdr_frame *hf,
|
||||||
@@ -55,16 +51,7 @@ void sc_layer_window_gone(void);
|
|||||||
|
|
||||||
void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns);
|
void sc_layer_frame_timeline(int64_t present_ns, int64_t deadline_ns, int64_t period_ns);
|
||||||
void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even);
|
void sc_layer_aim_take(unsigned *next, unsigned *later, unsigned *even);
|
||||||
/* The refresh the next game-layer frame is timed for, instead of the layer's own spacing (0: the layer's). */
|
|
||||||
void sc_layer_set_planned(int64_t present_ns);
|
|
||||||
/* The display's frame timeline: the next expected present and the refresh period (0 until known). */
|
|
||||||
void sc_layer_timeline(int64_t *present_ns, int64_t *period_ns);
|
|
||||||
void sc_layer_cadence_info(int64_t *gap_ns, int *group_frames);
|
|
||||||
unsigned sc_layer_frames_take(void);
|
unsigned sc_layer_frames_take(void);
|
||||||
unsigned sc_layer_drops_take(void);
|
unsigned sc_layer_drops_take(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "effects_chain.h"
|
#include "effects_chain.h"
|
||||||
#include "cardboard.h"
|
#include "cardboard.h"
|
||||||
#include "framegen_bridge.h"
|
#include "framegen_bridge.h"
|
||||||
#include "framegen_zerofg.h"
|
|
||||||
#include "hdr_compose.h"
|
#include "hdr_compose.h"
|
||||||
#include "blend_pass.h"
|
#include "blend_pass.h"
|
||||||
#include "gpu_busy.h"
|
#include "gpu_busy.h"
|
||||||
@@ -21,8 +20,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#include <linux/sync_file.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -605,10 +602,6 @@ static void update_map(int scene_w, int scene_h) {
|
|||||||
float min_y = (float)g_map.ry + g_map.rh - image_h;
|
float min_y = (float)g_map.ry + g_map.rh - image_h;
|
||||||
if (g_map.off_y < min_y) g_map.off_y = min_y;
|
if (g_map.off_y < min_y) g_map.off_y = min_y;
|
||||||
if (g_map.off_y > g_map.ry) g_map.off_y = (float)g_map.ry;
|
if (g_map.off_y > g_map.ry) g_map.off_y = (float)g_map.ry;
|
||||||
} else if (align == VKP_ALIGN_PICTURE_TOP) {
|
|
||||||
g_map.off_y = 0;
|
|
||||||
} else if (align == VKP_ALIGN_PICTURE_BOTTOM) {
|
|
||||||
g_map.off_y = H - image_h;
|
|
||||||
} else {
|
} else {
|
||||||
g_map.off_y = (float)g_map.ry + (g_map.rh - image_h) * 0.5f;
|
g_map.off_y = (float)g_map.ry + (g_map.rh - image_h) * 0.5f;
|
||||||
}
|
}
|
||||||
@@ -2769,8 +2762,8 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
const int upscale_w = (int)(scene_w * g_map.kx + 0.5f);
|
const int upscale_w = (int)(scene_w * g_map.kx + 0.5f);
|
||||||
const int upscale_h = (int)(scene_h * g_map.ky + 0.5f);
|
const int upscale_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||||
const int post_upscale = fx && fg && !hf && !cb && vkp_effects_upscaling() &&
|
const int post_upscale = fx && fg && !hf && !cb && vkp_effects_upscaling() &&
|
||||||
(upscale_w > input_w || upscale_h > input_h) &&
|
vkp_effects_prepare_generated() &&
|
||||||
vkp_effects_prepare_generated(input_w, input_h, upscale_w, upscale_h);
|
(upscale_w > input_w || upscale_h > input_h);
|
||||||
if (post_upscale) {
|
if (post_upscale) {
|
||||||
static int last_input_w, last_input_h, last_output_w, last_output_h;
|
static int last_input_w, last_input_h, last_output_w, last_output_h;
|
||||||
if (input_w != last_input_w || input_h != last_input_h ||
|
if (input_w != last_input_w || input_h != last_input_h ||
|
||||||
@@ -2900,7 +2893,6 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
|
|
||||||
if (!(pass && fx)) release_external_client_draws(cmd, draws, n);
|
if (!(pass && fx)) release_external_client_draws(cmd, draws, n);
|
||||||
int ngen = 0;
|
int ngen = 0;
|
||||||
int history_staged = 0;
|
|
||||||
VkImage gens[VKP_FG_MAX_GENERATIONS] = {VK_NULL_HANDLE};
|
VkImage gens[VKP_FG_MAX_GENERATIONS] = {VK_NULL_HANDLE};
|
||||||
VkImage result = scene_img;
|
VkImage result = scene_img;
|
||||||
int rw = input_w, rh = input_h;
|
int rw = input_w, rh = input_h;
|
||||||
@@ -2939,8 +2931,6 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
0, 0, NULL, 0, NULL, 1, &b_general);
|
0, 0, NULL, 0, NULL, 1, &b_general);
|
||||||
|
|
||||||
if (fg) {
|
if (fg) {
|
||||||
vkp_framegen_set_layer_timing(0);
|
|
||||||
history_staged = 1;
|
|
||||||
ngen = vkp_framegen_run(cmd, result, VK_NULL_HANDLE, rw, rh, scene_fmt, gens);
|
ngen = vkp_framegen_run(cmd, result, VK_NULL_HANDLE, rw, rh, scene_fmt, gens);
|
||||||
if (ngen < 0) ngen = 0;
|
if (ngen < 0) ngen = 0;
|
||||||
if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS;
|
if (ngen > VKP_FG_MAX_GENERATIONS) ngen = VKP_FG_MAX_GENERATIONS;
|
||||||
@@ -2966,10 +2956,7 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
/* Teardown may have retained this frame's pending work, or
|
/* Teardown may have retained this frame's pending work, or
|
||||||
* acquire may have reported real device loss. Neither permits
|
* acquire may have reported real device loss. Neither permits
|
||||||
* a completion-marker submit or another fence wait. */
|
* a completion-marker submit or another fence wait. */
|
||||||
if (g_dev_state != 1) {
|
if (g_dev_state != 1) return -1;
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
droiddeck_log("framegen", "present %d/%d: no swapchain image; the frame ends early", k + 1, presents);
|
droiddeck_log("framegen", "present %d/%d: no swapchain image; the frame ends early", k + 1, presents);
|
||||||
pr = VK_ERROR_OUT_OF_DATE_KHR;
|
pr = VK_ERROR_OUT_OF_DATE_KHR;
|
||||||
break;
|
break;
|
||||||
@@ -2993,7 +2980,6 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
if (img >= g_rnd_count || !g_rnds[img]) {
|
if (img >= g_rnd_count || !g_rnds[img]) {
|
||||||
droiddeck_log("error", "present: image index %u exceeds semaphore count %u",
|
droiddeck_log("error", "present: image index %u exceeds semaphore count %u",
|
||||||
img, g_rnd_count);
|
img, g_rnd_count);
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
destroy_swapchain();
|
destroy_swapchain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -3002,17 +2988,12 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
.pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[img]};
|
.pCommandBuffers = &g_cmds[k], .signalSemaphoreCount = 1, .pSignalSemaphores = &g_rnds[img]};
|
||||||
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, last ? g_fence : VK_NULL_HANDLE);
|
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, last ? g_fence : VK_NULL_HANDLE);
|
||||||
if (qr != VK_SUCCESS) {
|
if (qr != VK_SUCCESS) {
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
if (qr == VK_ERROR_DEVICE_LOST) device_lost("submit");
|
if (qr == VK_ERROR_DEVICE_LOST) device_lost("submit");
|
||||||
else LOGE("present: submit %d/%d failed (%d)", k + 1, presents, (int)qr);
|
else LOGE("present: submit %d/%d failed (%d)", k + 1, presents, (int)qr);
|
||||||
if (g_dev_state != -2) destroy_swapchain();
|
if (g_dev_state != -2) destroy_swapchain();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
fence_submitted = last;
|
fence_submitted = last;
|
||||||
if (k == 0 && history_staged) {
|
|
||||||
zfg_commit_history_update();
|
|
||||||
history_staged = 0;
|
|
||||||
}
|
|
||||||
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1,
|
VkPresentInfoKHR pi = {.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR, .waitSemaphoreCount = 1,
|
||||||
.pWaitSemaphores = &g_rnds[img], .swapchainCount = 1,
|
.pWaitSemaphores = &g_rnds[img], .swapchainCount = 1,
|
||||||
.pSwapchains = &g_swapchain, .pImageIndices = &img};
|
.pSwapchains = &g_swapchain, .pImageIndices = &img};
|
||||||
@@ -3020,37 +3001,21 @@ static int render_impl(int scene_w, int scene_h, const struct vkp_draw *draws, i
|
|||||||
pr = g_vk.QueuePresentKHR(g_queue, &pi);
|
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);
|
perf_add(&g_perf.present_ns, &g_perf.present_max_ns, &g_perf.presents, perf_now() - t_pres);
|
||||||
if (k < ngen) presented_gen++;
|
if (k < ngen) presented_gen++;
|
||||||
if (pr == VK_ERROR_DEVICE_LOST) {
|
if (pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
device_lost("present");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) break;
|
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) break;
|
||||||
}
|
}
|
||||||
if (!fence_submitted) {
|
if (!fence_submitted) {
|
||||||
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO};
|
VkSubmitInfo si = {.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO};
|
||||||
VkResult marker = 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_SUCCESS) {
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
if (marker == VK_ERROR_DEVICE_LOST) device_lost("frame completion submit");
|
if (marker == VK_ERROR_DEVICE_LOST) device_lost("frame completion submit");
|
||||||
else quarantine_pending_work(marker, "frame completion submit");
|
else quarantine_pending_work(marker, "frame completion submit");
|
||||||
return -1; /* no fence was submitted; never wait on its unsignalled state */
|
return -1; /* no fence was submitted; never wait on its unsignalled state */
|
||||||
}
|
}
|
||||||
if (history_staged) {
|
|
||||||
zfg_discard_history_update();
|
|
||||||
history_staged = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
VkResult fr = timed_wait(g_fence, UINT64_MAX);
|
VkResult fr = timed_wait(g_fence, UINT64_MAX);
|
||||||
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) {
|
if (fr == VK_ERROR_DEVICE_LOST || pr == VK_ERROR_DEVICE_LOST) { device_lost("present"); return -1; }
|
||||||
if (history_staged) zfg_discard_history_update();
|
if (fr != VK_SUCCESS) return -1;
|
||||||
device_lost("present");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (fr != VK_SUCCESS) {
|
|
||||||
if (history_staged) zfg_discard_history_update();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
vkp_effects_release_generated_sources();
|
vkp_effects_release_generated_sources();
|
||||||
if (fg) vkp_framegen_presented(presented_gen);
|
if (fg) vkp_framegen_presented(presented_gen);
|
||||||
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) {
|
if (pr == VK_ERROR_OUT_OF_DATE_KHR || pr == VK_ERROR_SURFACE_LOST_KHR) {
|
||||||
@@ -3197,38 +3162,8 @@ static void blit_to_layer(VkCommandBuffer cmd, VkImage src, VkImageLayout src_la
|
|||||||
0, 0, NULL, 0, NULL, 1, &release);
|
0, 0, NULL, 0, NULL, 1, &release);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int merge_wait_fds(int a, int b) {
|
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd) {
|
||||||
if (a < 0) return b;
|
if (!src || src->blit_dst || !dst || !dst->blit_dst || dev_init() != 0) {
|
||||||
if (b < 0) return a;
|
|
||||||
struct sync_merge_data m = {.name = "droiddeck-layer-copy", .fd2 = b};
|
|
||||||
if (ioctl(a, SYNC_IOC_MERGE, &m) == 0) {
|
|
||||||
close(a);
|
|
||||||
close(b);
|
|
||||||
return m.fence;
|
|
||||||
}
|
|
||||||
struct pollfd p = {.fd = b, .events = POLLIN};
|
|
||||||
int r;
|
|
||||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
|
||||||
close(b);
|
|
||||||
if (r != 0) return a;
|
|
||||||
p.fd = a;
|
|
||||||
do { r = poll(&p, 1, 100); } while (r < 0 && errno == EINTR);
|
|
||||||
close(a);
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
int vkp_blit_images(const struct vkp_blit *blits, int n) {
|
|
||||||
int wait_fd = -1;
|
|
||||||
for (int i = 0; i < n; i++) {
|
|
||||||
if (wait_fd == -2) { if (blits[i].wait_fd >= 0) close(blits[i].wait_fd); continue; }
|
|
||||||
wait_fd = merge_wait_fds(wait_fd, blits[i].wait_fd);
|
|
||||||
}
|
|
||||||
int valid = n > 0 && wait_fd != -2;
|
|
||||||
for (int i = 0; valid && i < n; i++) {
|
|
||||||
const struct vkp_image *src = blits[i].src, *dst = blits[i].dst;
|
|
||||||
if (!src || src->blit_dst || !dst || !dst->blit_dst) valid = 0;
|
|
||||||
}
|
|
||||||
if (!valid || dev_init() != 0) {
|
|
||||||
if (wait_fd >= 0) close(wait_fd);
|
if (wait_fd >= 0) close(wait_fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -3241,35 +3176,32 @@ int vkp_blit_images(const struct vkp_blit *blits, int n) {
|
|||||||
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
VkCommandBufferBeginInfo bi = {.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
|
||||||
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT};
|
||||||
g_vk.BeginCommandBuffer(g_cmd, &bi);
|
g_vk.BeginCommandBuffer(g_cmd, &bi);
|
||||||
for (int i = 0; i < n; i++) {
|
stage_linear_dmabuf(g_cmd, src);
|
||||||
struct vkp_image *src = blits[i].src, *dst = blits[i].dst;
|
struct vkp_external_client_barrier_pair src_pair;
|
||||||
stage_linear_dmabuf(g_cmd, src);
|
const int src_external = vkp_external_client_barrier_pair(
|
||||||
struct vkp_external_client_barrier_pair src_pair;
|
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
|
||||||
const int src_external = vkp_external_client_barrier_pair(
|
VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
||||||
src->image, g_qfam, foreign_image(src), src->blit_dst, &src_pair);
|
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VkImageMemoryBarrier acq = src_external ? src_pair.acquire : (VkImageMemoryBarrier){
|
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, .oldLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.newLayout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
|
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
||||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
if (!src_external) {
|
||||||
.image = src->image, .subresourceRange = range, .dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT};
|
acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
|
||||||
if (!src_external) {
|
acq.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
||||||
acq.oldLayout = src->in_general ? VK_IMAGE_LAYOUT_GENERAL : VK_IMAGE_LAYOUT_PREINITIALIZED;
|
acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
||||||
acq.newLayout = VK_IMAGE_LAYOUT_GENERAL;
|
src->in_general = 1;
|
||||||
acq.srcAccessMask = VK_ACCESS_HOST_WRITE_BIT;
|
|
||||||
src->in_general = 1;
|
|
||||||
}
|
|
||||||
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq);
|
|
||||||
int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h;
|
|
||||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
|
||||||
.srcOffsets = {{0, 0, 0}, {bw, bh, 1}},
|
|
||||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
|
||||||
.dstOffsets = {{0, 0, 0}, {bw, bh, 1}}};
|
|
||||||
blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
|
||||||
dst, &blit, VK_FILTER_NEAREST);
|
|
||||||
release_external_client_image(g_cmd, src);
|
|
||||||
}
|
}
|
||||||
|
g_vk.CmdPipelineBarrier(g_cmd, VK_PIPELINE_STAGE_HOST_BIT | VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
|
||||||
|
VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 0, NULL, 1, &acq);
|
||||||
|
int bw = src->w < dst->w ? src->w : dst->w, bh = src->h < dst->h ? src->h : dst->h;
|
||||||
|
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||||
|
.srcOffsets = {{0, 0, 0}, {bw, bh, 1}},
|
||||||
|
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||||
|
.dstOffsets = {{0, 0, 0}, {bw, bh, 1}}};
|
||||||
|
blit_to_layer(g_cmd, src->image, src_external ? VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL : VK_IMAGE_LAYOUT_GENERAL,
|
||||||
|
dst, &blit, VK_FILTER_NEAREST);
|
||||||
|
release_external_client_image(g_cmd, src);
|
||||||
g_vk.EndCommandBuffer(g_cmd);
|
g_vk.EndCommandBuffer(g_cmd);
|
||||||
|
|
||||||
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
VkPipelineStageFlags wait_stage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
@@ -3402,9 +3334,6 @@ static struct {
|
|||||||
int active;
|
int active;
|
||||||
VkImage result;
|
VkImage result;
|
||||||
int rw, rh;
|
int rw, rh;
|
||||||
/* The layer buffers' size: rw x rh, or the spatial filter's output when it runs on each frame after generation. */
|
|
||||||
int ow, oh;
|
|
||||||
int post_upscale;
|
|
||||||
int ngen;
|
int ngen;
|
||||||
VkImage gens[VKP_FG_MAX_GENERATIONS];
|
VkImage gens[VKP_FG_MAX_GENERATIONS];
|
||||||
} g_pass;
|
} g_pass;
|
||||||
@@ -3544,30 +3473,10 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
int mapped_w = (int)(scene_w * g_map.kx + 0.5f), mapped_h = (int)(scene_h * g_map.ky + 0.5f);
|
||||||
g_pass.post_upscale = generate && !hf && vkp_effects_active() && vkp_effects_upscaling() &&
|
|
||||||
(mapped_w > input_w || mapped_h > input_h) &&
|
|
||||||
vkp_effects_prepare_generated(input_w, input_h, mapped_w, mapped_h);
|
|
||||||
if (g_pass.post_upscale) {
|
|
||||||
static int last_input_w, last_input_h, last_output_w, last_output_h;
|
|
||||||
if (input_w != last_input_w || input_h != last_input_h || mapped_w != last_output_w || mapped_h != last_output_h) {
|
|
||||||
droiddeck_log("framegen", "post-upscale on the display layer: interpolate %dx%d, spatial filter each "
|
|
||||||
"frame to %dx%d", input_w, input_h, mapped_w, mapped_h);
|
|
||||||
last_input_w = input_w; last_input_h = input_h;
|
|
||||||
last_output_w = mapped_w; last_output_h = mapped_h;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (generate && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
|
if (generate && !vkp_effects_sharpening()) { mapped_w = scene_w; mapped_h = scene_h; }
|
||||||
g_pass.rw = input_w; g_pass.rh = input_h;
|
g_pass.rw = input_w; g_pass.rh = input_h;
|
||||||
if (g_pass.post_upscale) {
|
g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h,
|
||||||
g_pass.ow = (int)(scene_w * g_map.kx + 0.5f);
|
&g_pass.rw, &g_pass.rh);
|
||||||
g_pass.oh = (int)(scene_h * g_map.ky + 0.5f);
|
|
||||||
g_pass.result = vkp_effects_run_before_generated(cmd, scene_img, input_w, input_h, &g_pass.rw, &g_pass.rh);
|
|
||||||
} else {
|
|
||||||
g_pass.result = vkp_effects_run(cmd, scene_img, input_w, input_h, mapped_w, mapped_h,
|
|
||||||
&g_pass.rw, &g_pass.rh);
|
|
||||||
g_pass.ow = g_pass.rw;
|
|
||||||
g_pass.oh = g_pass.rh;
|
|
||||||
}
|
|
||||||
effects_overlay_draws(cmd, g_pass.result, g_pass.rw, g_pass.rh, scene_w, scene_h,
|
effects_overlay_draws(cmd, g_pass.result, g_pass.rw, g_pass.rh, scene_w, scene_h,
|
||||||
draws ? draws + overlay_start : NULL, n - overlay_start);
|
draws ? draws + overlay_start : NULL, n - overlay_start);
|
||||||
release_external_client_draws(cmd, draws, n);
|
release_external_client_draws(cmd, draws, n);
|
||||||
@@ -3582,45 +3491,38 @@ static int pass_begin_impl(int scene_w, int scene_h, const struct vkp_draw *draw
|
|||||||
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
g_vk.CmdPipelineBarrier(cmd, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||||
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||||
0, 0, NULL, 0, NULL, 1, &b);
|
0, 0, NULL, 0, NULL, 1, &b);
|
||||||
vkp_framegen_set_layer_timing(1);
|
|
||||||
int ngen = vkp_framegen_run(cmd, g_pass.result, VK_NULL_HANDLE, g_pass.rw, g_pass.rh, scene_fmt, g_pass.gens);
|
int ngen = vkp_framegen_run(cmd, g_pass.result, VK_NULL_HANDLE, g_pass.rw, g_pass.rh, scene_fmt, g_pass.gens);
|
||||||
if (ngen < 0) ngen = 0;
|
if (ngen < 0) ngen = 0;
|
||||||
g_pass.ngen = ngen > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : ngen;
|
g_pass.ngen = ngen > VKP_FG_MAX_GENERATIONS ? VKP_FG_MAX_GENERATIONS : ngen;
|
||||||
}
|
}
|
||||||
g_pass.active = 1;
|
g_pass.active = 1;
|
||||||
if (rw) *rw = g_pass.ow;
|
if (rw) *rw = g_pass.rw;
|
||||||
if (rh) *rh = g_pass.oh;
|
if (rh) *rh = g_pass.rh;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp_image *const *dsts, int n,
|
static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp_image *const *dsts, int n,
|
||||||
int wait_fd) {
|
int wait_fd) {
|
||||||
if (!g_pass.active) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; }
|
if (!g_pass.active) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||||
g_pass.active = 0;
|
g_pass.active = 0;
|
||||||
if (g_dev_state != 1) { zfg_discard_history_update(); if (wait_fd >= 0) close(wait_fd); return -1; }
|
if (g_dev_state != 1) { if (wait_fd >= 0) close(wait_fd); return -1; }
|
||||||
VkCommandBuffer cmd = g_cmds[0];
|
VkCommandBuffer cmd = g_cmds[0];
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (dsts[i] && dsts[i]->blit_dst) continue;
|
if (dsts[i] && dsts[i]->blit_dst) continue;
|
||||||
if (wait_fd >= 0) close(wait_fd);
|
if (wait_fd >= 0) close(wait_fd);
|
||||||
g_vk.EndCommandBuffer(cmd);
|
g_vk.EndCommandBuffer(cmd);
|
||||||
zfg_discard_history_update();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
const int gpu_wait = take_wait_fd(wait_fd);
|
const int gpu_wait = take_wait_fd(wait_fd);
|
||||||
if (gpu_wait < 0) { zfg_discard_history_update(); g_vk.EndCommandBuffer(cmd); return -1; }
|
if (gpu_wait < 0) { g_vk.EndCommandBuffer(cmd); return -1; }
|
||||||
const int post_upscale = g_pass.post_upscale && src_layout == VK_IMAGE_LAYOUT_GENERAL;
|
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
struct vkp_image *dst = dsts[i];
|
struct vkp_image *dst = dsts[i];
|
||||||
VkImage src = srcs[i];
|
|
||||||
int sw = g_pass.rw, sh = g_pass.rh;
|
|
||||||
if (post_upscale)
|
|
||||||
src = vkp_effects_run_generated(cmd, src, g_pass.rw, g_pass.rh, g_pass.ow, g_pass.oh, i, &sw, &sh);
|
|
||||||
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
VkImageBlit blit = {.srcSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||||
.srcOffsets = {{0, 0, 0}, {sw, sh, 1}},
|
.srcOffsets = {{0, 0, 0}, {g_pass.rw, g_pass.rh, 1}},
|
||||||
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
.dstSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1},
|
||||||
.dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}};
|
.dstOffsets = {{0, 0, 0}, {dst->w, dst->h, 1}}};
|
||||||
blit_to_layer(cmd, src, src_layout, dst, &blit,
|
blit_to_layer(cmd, srcs[i], src_layout, dst, &blit,
|
||||||
(sw == dst->w && sh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
|
(g_pass.rw == dst->w && g_pass.rh == dst->h) ? VK_FILTER_NEAREST : VK_FILTER_LINEAR);
|
||||||
}
|
}
|
||||||
g_vk.EndCommandBuffer(cmd);
|
g_vk.EndCommandBuffer(cmd);
|
||||||
|
|
||||||
@@ -3631,17 +3533,13 @@ static int pass_finish(const VkImage *srcs, VkImageLayout src_layout, struct vkp
|
|||||||
g_vk.ResetFences(g_dev, 1, &g_fence);
|
g_vk.ResetFences(g_dev, 1, &g_fence);
|
||||||
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
VkResult qr = g_vk.QueueSubmit(g_queue, 1, &si, g_fence);
|
||||||
if (qr != VK_SUCCESS) {
|
if (qr != VK_SUCCESS) {
|
||||||
zfg_discard_history_update();
|
|
||||||
if (qr == VK_ERROR_DEVICE_LOST) device_lost("layer pass");
|
if (qr == VK_ERROR_DEVICE_LOST) device_lost("layer pass");
|
||||||
else LOGE("layer: effects pass submit failed (%d)", (int)qr);
|
else LOGE("layer: effects pass submit failed (%d)", (int)qr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
zfg_commit_history_update();
|
|
||||||
VkResult fr = timed_wait(g_fence, 1000000000ULL);
|
VkResult fr = timed_wait(g_fence, 1000000000ULL);
|
||||||
if (fr == VK_ERROR_DEVICE_LOST) { device_lost("layer pass"); return -1; }
|
if (fr == VK_ERROR_DEVICE_LOST) { device_lost("layer pass"); return -1; }
|
||||||
if (fr != VK_SUCCESS) { LOGE("layer: effects pass fence wait -> %s", vk_result_name(fr)); return -1; }
|
if (fr != VK_SUCCESS) { LOGE("layer: effects pass fence wait -> %s", vk_result_name(fr)); return -1; }
|
||||||
if (post_upscale) vkp_effects_release_generated_sources();
|
|
||||||
vkp_framegen_completed();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3659,7 +3557,6 @@ int vkp_pass_copy_generated(struct vkp_image *const *dsts, int n, struct vkp_ima
|
|||||||
}
|
}
|
||||||
|
|
||||||
void vkp_pass_abort(void) {
|
void vkp_pass_abort(void) {
|
||||||
zfg_discard_history_update();
|
|
||||||
if (!g_pass.active) return;
|
if (!g_pass.active) return;
|
||||||
g_pass.active = 0;
|
g_pass.active = 0;
|
||||||
if (g_dev_state == 1)
|
if (g_dev_state == 1)
|
||||||
|
|||||||
@@ -105,11 +105,7 @@ int vkp_render_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n
|
|||||||
int vkp_pass_begin_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
|
int vkp_pass_begin_hdr(int scene_w, int scene_h, const struct vkp_draw *draws, int n,
|
||||||
const struct vkp_hdr_frame *hf, int *rw, int *rh);
|
const struct vkp_hdr_frame *hf, int *rw, int *rh);
|
||||||
|
|
||||||
struct vkp_blit {
|
int vkp_blit_image(struct vkp_image *src, struct vkp_image *dst, int wait_fd);
|
||||||
struct vkp_image *src, *dst;
|
|
||||||
int wait_fd;
|
|
||||||
};
|
|
||||||
int vkp_blit_images(const struct vkp_blit *blits, int n);
|
|
||||||
int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px);
|
int vkp_image_readback(struct vkp_image *src, uint32_t *out, int max_px);
|
||||||
int vkp_update_map(int scene_w, int scene_h);
|
int vkp_update_map(int scene_w, int scene_h);
|
||||||
int vkp_map_draw(const struct vkp_draw *d, int out[8]);
|
int vkp_map_draw(const struct vkp_draw *d, int out[8]);
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ static jmethodID g_on_compositor_frame;
|
|||||||
static jmethodID g_on_game_program;
|
static jmethodID g_on_game_program;
|
||||||
static jmethodID g_on_pointer_lock;
|
static jmethodID g_on_pointer_lock;
|
||||||
static jmethodID g_on_clipboard;
|
static jmethodID g_on_clipboard;
|
||||||
static jmethodID g_on_text_input_fallback;
|
|
||||||
static jmethodID g_on_text_input;
|
static jmethodID g_on_text_input;
|
||||||
static jmethodID g_on_overlay_planes;
|
static jmethodID g_on_overlay_planes;
|
||||||
static jmethodID g_on_refresh_target;
|
static jmethodID g_on_refresh_target;
|
||||||
@@ -93,8 +92,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|||||||
if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); g_on_game_program = NULL; }
|
if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); g_on_game_program = NULL; }
|
||||||
g_on_pointer_lock = (*env)->GetStaticMethodID(env, g_compositor_cls, "onPointerLock", "(ZII)V");
|
g_on_pointer_lock = (*env)->GetStaticMethodID(env, g_compositor_cls, "onPointerLock", "(ZII)V");
|
||||||
g_on_clipboard = (*env)->GetStaticMethodID(env, g_compositor_cls, "onClipboardText", "([B)V");
|
g_on_clipboard = (*env)->GetStaticMethodID(env, g_compositor_cls, "onClipboardText", "([B)V");
|
||||||
g_on_text_input_fallback = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInputFallback",
|
|
||||||
"([BI)Z");
|
|
||||||
g_on_text_input = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInput",
|
g_on_text_input = (*env)->GetStaticMethodID(env, g_compositor_cls, "onTextInput",
|
||||||
"(ZLjava/lang/String;IIII)V");
|
"(ZLjava/lang/String;IIII)V");
|
||||||
g_on_overlay_planes = (*env)->GetStaticMethodID(env, g_compositor_cls, "onOverlayPlanes", "(I)V");
|
g_on_overlay_planes = (*env)->GetStaticMethodID(env, g_compositor_cls, "onOverlayPlanes", "(I)V");
|
||||||
@@ -206,20 +203,6 @@ void droiddeck_on_clipboard_text(const char *utf8, int len) {
|
|||||||
(*env)->DeleteLocalRef(env, arr);
|
(*env)->DeleteLocalRef(env, arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
int droiddeck_on_text_input_fallback(const char *utf8, int len, int token) {
|
|
||||||
JNIEnv *env;
|
|
||||||
if (len <= 0 || token <= 0 || !utf8 || !g_compositor_cls || !g_on_text_input_fallback || !(env = thread_env()))
|
|
||||||
return 0;
|
|
||||||
jbyteArray arr = (*env)->NewByteArray(env, len);
|
|
||||||
if (!arr) { (*env)->ExceptionClear(env); return 0; }
|
|
||||||
(*env)->SetByteArrayRegion(env, arr, 0, len, (const jbyte *)utf8);
|
|
||||||
jboolean accepted = (*env)->CallStaticBooleanMethod(env, g_compositor_cls, g_on_text_input_fallback, arr,
|
|
||||||
(jint)token);
|
|
||||||
if ((*env)->ExceptionCheck(env)) { (*env)->ExceptionClear(env); accepted = JNI_FALSE; }
|
|
||||||
(*env)->DeleteLocalRef(env, arr);
|
|
||||||
return accepted == JNI_TRUE ? 1 : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h) {
|
void droiddeck_on_text_input(int enabled, const char *program, int x, int y, int w, int h) {
|
||||||
JNIEnv *env;
|
JNIEnv *env;
|
||||||
if (!g_compositor_cls || !g_on_text_input || !(env = thread_env())) return;
|
if (!g_compositor_cls || !g_on_text_input || !(env = thread_env())) return;
|
||||||
@@ -393,18 +376,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKey(
|
|||||||
droiddeck_wayland_send_key(evdev, state);
|
droiddeck_wayland_send_key(evdev, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKeyOrdered(
|
|
||||||
JNIEnv *env, jclass clazz, jint evdev, jint state) {
|
|
||||||
droiddeck_host_key(evdev, state);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSelectGameField(
|
|
||||||
JNIEnv *env, jclass clazz, jboolean copy) {
|
|
||||||
droiddeck_host_select_game_field(copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFocusTakesTouch(
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFocusTakesTouch(
|
||||||
JNIEnv *env, jclass clazz) {
|
JNIEnv *env, jclass clazz) {
|
||||||
@@ -461,11 +432,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetZeroCopy(JNIEnv *
|
|||||||
__android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : "");
|
__android_log_print(ANDROID_LOG_INFO, TAG, "zero-copy layer mode %s%s", on ? "on" : "off", live ? " (live)" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetMirrorCapture(JNIEnv *env, jclass clazz, jboolean on) {
|
|
||||||
droiddeck_host_mirror_capture(on ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDisplayBufferDriver(JNIEnv *env, jclass clazz, jboolean on) {
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetDisplayBufferDriver(JNIEnv *env, jclass clazz, jboolean on) {
|
||||||
g_display_buffer_driver = on ? 1 : 0;
|
g_display_buffer_driver = on ? 1 : 0;
|
||||||
@@ -841,15 +807,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommit(JNIE
|
|||||||
free(buf);
|
free(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputCommitAndSubmit(
|
|
||||||
JNIEnv *env, jclass clazz, jbyteArray utf8) {
|
|
||||||
int len;
|
|
||||||
char *buf = dup_bytes(env, utf8, &len);
|
|
||||||
if (buf && len) droiddeck_host_text_commit_and_submit(buf, len);
|
|
||||||
free(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputPreedit(JNIEnv *env, jclass clazz, jbyteArray utf8,
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputPreedit(JNIEnv *env, jclass clazz, jbyteArray utf8,
|
||||||
jint cursorBegin, jint cursorEnd) {
|
jint cursorBegin, jint cursorEnd) {
|
||||||
@@ -864,12 +821,6 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeTextInputDelete(JNIE
|
|||||||
droiddeck_host_text_delete(before, after);
|
droiddeck_host_text_delete(before, after);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCompleteTextInputFallback(
|
|
||||||
JNIEnv *env, jclass clazz, jint token, jint result) {
|
|
||||||
droiddeck_host_text_input_fallback_complete(token, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern void adrenotools_set_turbo(bool turbo);
|
extern void adrenotools_set_turbo(bool turbo);
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) {
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSetGpuTurbo(JNIEnv *env, jclass clazz, jboolean on) {
|
||||||
@@ -921,42 +872,3 @@ JNIEXPORT jint JNICALL
|
|||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamFrames(JNIEnv *env, jclass clazz) {
|
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeStreamFrames(JNIEnv *env, jclass clazz) {
|
||||||
return (jint)droiddeck_stream_frames();
|
return (jint)droiddeck_stream_frames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
extern int droiddeck_frame_worker_grant(int owner, pid_t pid, uint64_t expires, const char *path,
|
|
||||||
uint64_t dev, uint64_t ino, uint64_t receipt);
|
|
||||||
extern void droiddeck_frame_worker_revoke(int owner, int pid);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeEnabled(JNIEnv *env, jclass c) {
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
return JNI_TRUE;
|
|
||||||
#else
|
|
||||||
return JNI_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeGrant(JNIEnv *env, jclass c,
|
|
||||||
jint owner, jint pid, jlong expires, jstring path, jlong dev, jlong ino, jlong start_ticks) {
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
if (!path || expires <= 0 || ino <= 0 || start_ticks <= 0) return JNI_FALSE;
|
|
||||||
const char *name = (*env)->GetStringUTFChars(env, path, NULL);
|
|
||||||
if (!name) return JNI_FALSE;
|
|
||||||
int granted = droiddeck_frame_worker_grant(owner, pid, (uint64_t)expires, name, (uint64_t)dev, (uint64_t)ino, (uint64_t)start_ticks);
|
|
||||||
(*env)->ReleaseStringUTFChars(env, path, name);
|
|
||||||
return granted ? JNI_TRUE : JNI_FALSE;
|
|
||||||
#else
|
|
||||||
return JNI_FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
|
||||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_frameWorkerProbeRevoke(JNIEnv *env, jclass c,
|
|
||||||
jint owner, jint pid) {
|
|
||||||
#ifdef DROIDDECK_FRAME_ACQUIRE_PROBE
|
|
||||||
droiddeck_frame_worker_revoke(owner, pid);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
@@ -10,12 +10,6 @@
|
|||||||
#ifndef KEY_DELETE
|
#ifndef KEY_DELETE
|
||||||
#define KEY_DELETE 111
|
#define KEY_DELETE 111
|
||||||
#endif
|
#endif
|
||||||
#ifndef KEY_ENTER
|
|
||||||
#define KEY_ENTER 28
|
|
||||||
#endif
|
|
||||||
#ifndef KEY_TAB
|
|
||||||
#define KEY_TAB 15
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static struct wl_display *g_disp;
|
static struct wl_display *g_disp;
|
||||||
|
|
||||||
@@ -209,43 +203,16 @@ static int32_t utf8_offset(const char *s, size_t len, int chars) {
|
|||||||
return (int32_t)i;
|
return (int32_t)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int control_evdev(unsigned char c) {
|
void text_input_host_commit(const char *utf8, size_t len) {
|
||||||
switch (c) {
|
|
||||||
case '\r': case '\n': return KEY_ENTER;
|
|
||||||
case '\b': return KEY_BACKSPACE;
|
|
||||||
case 0x7f: return KEY_DELETE;
|
|
||||||
case '\t': return KEY_TAB;
|
|
||||||
default: return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int all_controls(const char *utf8, size_t len) {
|
|
||||||
for (size_t i = 0; i < len; i++)
|
|
||||||
if (control_evdev((unsigned char)utf8[i]) < 0) return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int text_input_host_commit(const char *utf8, size_t len) {
|
|
||||||
struct text_input *ti = active_input();
|
struct text_input *ti = active_input();
|
||||||
if (!ti) {
|
if (!ti) {
|
||||||
droiddeck_log("text-input", "typed text (%zu chars): no program accepts Wayland text input", utf8_chars(utf8, len));
|
droiddeck_log("text-input", "typed text (%zu chars) dropped: no program accepts text input", utf8_chars(utf8, len));
|
||||||
return 0;
|
return;
|
||||||
}
|
|
||||||
if (len > 0 && all_controls(utf8, len)) {
|
|
||||||
/* Keep editing keys on the compositor queue so they cannot overtake text commits. */
|
|
||||||
for (size_t i = 0; i < len; i++) {
|
|
||||||
int code = control_evdev((unsigned char)utf8[i]);
|
|
||||||
droiddeck_inject_key(code, 1);
|
|
||||||
droiddeck_inject_key(code, 0);
|
|
||||||
}
|
|
||||||
droiddeck_log("text-input", "injected %zu soft control(s) to %s", len, ti_program(ti));
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
if (ti->has_preedit) { zwp_text_input_v3_send_preedit_string(ti->res, "", 0, 0); ti->has_preedit = 0; }
|
if (ti->has_preedit) { zwp_text_input_v3_send_preedit_string(ti->res, "", 0, 0); ti->has_preedit = 0; }
|
||||||
zwp_text_input_v3_send_commit_string(ti->res, utf8);
|
zwp_text_input_v3_send_commit_string(ti->res, utf8);
|
||||||
zwp_text_input_v3_send_done(ti->res, ti->serial);
|
zwp_text_input_v3_send_done(ti->res, ti->serial);
|
||||||
droiddeck_log("text-input", "committed %zu chars to %s", utf8_chars(utf8, len), ti_program(ti));
|
droiddeck_log("text-input", "committed %zu chars to %s", utf8_chars(utf8, len), ti_program(ti));
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end) {
|
void text_input_host_preedit(const char *utf8, size_t len, int cursor_begin, int cursor_end) {
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ import android.widget.EditText
|
|||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
@@ -193,15 +192,13 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
private var prootNoSeccomp by mutableStateOf(false)
|
private var prootNoSeccomp by mutableStateOf(false)
|
||||||
private var prootFastPath by mutableStateOf(true)
|
private var prootFastPath by mutableStateOf(true)
|
||||||
private var nativeUserland by mutableStateOf(true)
|
private var nativeUserland by mutableStateOf(true)
|
||||||
private var desktopAsUser by mutableStateOf(false)
|
|
||||||
private var cursorComposite by mutableStateOf(true)
|
private var cursorComposite by mutableStateOf(true)
|
||||||
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
|
private var guestHostname by mutableStateOf(SessionPrefs.DEFAULT_GUEST_HOSTNAME)
|
||||||
private var phantomWarning by mutableStateOf<String?>(null)
|
private var phantomWarning by mutableStateOf<String?>(null)
|
||||||
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
|
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
|
||||||
private var showPhantomGate by mutableStateOf(false)
|
private var showPhantomGate by mutableStateOf(false)
|
||||||
private var directAudio by mutableStateOf(false)
|
private var directAudio by mutableStateOf(false)
|
||||||
private var picturePositionLandscape by mutableStateOf("center")
|
private var picturePosition by mutableStateOf("center")
|
||||||
private var picturePositionPortrait by mutableStateOf("top")
|
|
||||||
private var integerScaling by mutableStateOf(false)
|
private var integerScaling by mutableStateOf(false)
|
||||||
private var stretch16x9 by mutableStateOf(false)
|
private var stretch16x9 by mutableStateOf(false)
|
||||||
private var avoidNotch by mutableStateOf(false)
|
private var avoidNotch by mutableStateOf(false)
|
||||||
@@ -209,12 +206,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||||
private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM)
|
private var homePage by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.HOME_PAGE_STEAM)
|
||||||
private var launcherFullscreen by mutableStateOf(true)
|
private var launcherFullscreen by mutableStateOf(true)
|
||||||
private var launcherFrost by mutableStateOf(false)
|
|
||||||
private var frostWallpaper by mutableStateOf(true)
|
|
||||||
private var frostCards by mutableStateOf(true)
|
|
||||||
private var frostTransparency by mutableStateOf(com.droiddeck.launcher.ui.FROST_WALLPAPER_DEFAULT)
|
|
||||||
private var frostCardTransparency by mutableStateOf(com.droiddeck.launcher.ui.FROST_DEFAULT)
|
|
||||||
private val frost = com.droiddeck.launcher.ui.LauncherFrost(this)
|
|
||||||
private var controllerHaptics by mutableStateOf(true)
|
private var controllerHaptics by mutableStateOf(true)
|
||||||
private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO)
|
private var downloadSource by mutableStateOf(DownloadSource.MODE_AUTO)
|
||||||
private var downloadMirror by mutableStateOf("")
|
private var downloadMirror by mutableStateOf("")
|
||||||
@@ -305,6 +296,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
protons.installExperimental { progress -> com.droiddeck.launcher.session.ExperimentalProtons.installFromFile(this, zip, progress) }
|
protons.installExperimental { progress -> com.droiddeck.launcher.session.ExperimentalProtons.installFromFile(this, zip, progress) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private val pickLossless = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||||
|
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let { importLossless(it) }
|
||||||
|
}
|
||||||
private val pickSaveZip = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
private val pickSaveZip = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) { r ->
|
||||||
val then = onSavePicked.also { onSavePicked = null } ?: return@registerForActivityResult
|
val then = onSavePicked.also { onSavePicked = null } ?: return@registerForActivityResult
|
||||||
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let(then)
|
if (r.resultCode == RESULT_OK) InAppFilePicker.pickedFile(r.data)?.let(then)
|
||||||
@@ -515,6 +509,17 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
bootMovieCustomName = com.droiddeck.launcher.session.BootMovie.customName(this)
|
bootMovieCustomName = com.droiddeck.launcher.session.BootMovie.customName(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun importLossless(dll: File) {
|
||||||
|
Thread({
|
||||||
|
val message = Lossless.message(this, Lossless.import(this, dll))
|
||||||
|
val state = Lossless.state(this)
|
||||||
|
ui.post {
|
||||||
|
lossless = state
|
||||||
|
android.widget.Toast.makeText(this, message, android.widget.Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}, "lossless-import").start()
|
||||||
|
}
|
||||||
|
|
||||||
private fun importSaves(name: String, game: () -> GameSaves.Game) {
|
private fun importSaves(name: String, game: () -> GameSaves.Game) {
|
||||||
if (SessionState.running) {
|
if (SessionState.running) {
|
||||||
android.widget.Toast.makeText(this, R.string.main_saves_close_session, android.widget.Toast.LENGTH_LONG).show()
|
android.widget.Toast.makeText(this, R.string.main_saves_close_session, android.widget.Toast.LENGTH_LONG).show()
|
||||||
@@ -612,7 +617,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
private var appScale by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.DEFAULT_SCALE)
|
private var appScale by mutableStateOf(com.droiddeck.launcher.core.AppUiPrefs.DEFAULT_SCALE)
|
||||||
private var hdrOn by mutableStateOf(false)
|
private var hdrOn by mutableStateOf(false)
|
||||||
private var zeroCopyOn by mutableStateOf(true)
|
private var zeroCopyOn by mutableStateOf(true)
|
||||||
private var producerAcquireFences by mutableStateOf(false)
|
|
||||||
private var upscaler by mutableStateOf(0)
|
private var upscaler by mutableStateOf(0)
|
||||||
private var upscaleSharpness by mutableStateOf(75)
|
private var upscaleSharpness by mutableStateOf(75)
|
||||||
private var hdrReason by mutableStateOf<String?>(null)
|
private var hdrReason by mutableStateOf<String?>(null)
|
||||||
@@ -1088,7 +1092,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
} else {
|
} else {
|
||||||
putExtra(SessionService.EXTRA_STEAM_URL,
|
putExtra(SessionService.EXTRA_STEAM_URL,
|
||||||
com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(game.gameIdString))
|
com.droiddeck.launcher.frontend.GameLaunchLink.steamUrl(game.gameIdString))
|
||||||
putExtra(SessionService.EXTRA_FRONTEND_STEAM_GAME, true)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.playing(game), steamSession = true)
|
.playing(game), steamSession = true)
|
||||||
@@ -1368,14 +1371,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
requestedOrientation = launcherOrientation
|
requestedOrientation = launcherOrientation
|
||||||
homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this)
|
homePage = com.droiddeck.launcher.core.AppUiPrefs.homePage(this)
|
||||||
launcherFullscreen = SessionPrefs.launcherFullscreen(this)
|
launcherFullscreen = SessionPrefs.launcherFullscreen(this)
|
||||||
launcherFrost = SessionPrefs.launcherFrost(this)
|
|
||||||
frostWallpaper = SessionPrefs.frostWallpaper(this)
|
|
||||||
frostCards = SessionPrefs.frostCards(this)
|
|
||||||
frostTransparency = SessionPrefs.frostTransparency(this)
|
|
||||||
frostCardTransparency = SessionPrefs.frostCardTransparency(this)
|
|
||||||
frost.start()
|
|
||||||
frost.prepare(launcherFrost && frostWallpaper)
|
|
||||||
frost.show(frostShown())
|
|
||||||
controllerHaptics = SessionPrefs.controllerHaptics(this)
|
controllerHaptics = SessionPrefs.controllerHaptics(this)
|
||||||
downloadSource = DownloadSource.mode(this)
|
downloadSource = DownloadSource.mode(this)
|
||||||
downloadMirror = DownloadSource.mirror(this)
|
downloadMirror = DownloadSource.mirror(this)
|
||||||
@@ -1400,14 +1395,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
}
|
}
|
||||||
val appsTabShown = "android-apps" !in com.droiddeck.launcher.ui.NavTabs.hidden
|
val appsTabShown = "android-apps" !in com.droiddeck.launcher.ui.NavTabs.hidden
|
||||||
androidx.compose.runtime.LaunchedEffect(appsTabShown) { if (appsTabShown && androidApps.isEmpty()) refreshAndroidApps() }
|
androidx.compose.runtime.LaunchedEffect(appsTabShown) { if (appsTabShown && androidApps.isEmpty()) refreshAndroidApps() }
|
||||||
val frostShown = frostShown()
|
DroidDeckTheme(theme, appScale = appScale) {
|
||||||
androidx.compose.runtime.LaunchedEffect(frostShown) { frost.show(frostShown) }
|
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().exposeTestTags()) {
|
||||||
val frostChoice = if (frostShown) com.droiddeck.launcher.ui.FrostChoice(frostTransparency, frostCards, frostCardTransparency) else null
|
|
||||||
DroidDeckTheme(theme, appScale = appScale, frost = frostChoice) {
|
|
||||||
val palette = com.droiddeck.launcher.ui.LocalPalette.current
|
|
||||||
val veil = com.droiddeck.launcher.ui.LocalFrost.current
|
|
||||||
val ground = if (frost.prepared) androidx.compose.ui.Modifier.background(veil ?: palette.background) else androidx.compose.ui.Modifier
|
|
||||||
com.droiddeck.launcher.ui.FocusGlideHost(androidx.compose.ui.Modifier.fillMaxSize().then(ground).exposeTestTags()) {
|
|
||||||
if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog(
|
if (decky.deckyPendingZip != null) com.droiddeck.launcher.ui.DeckyZipWarningDialog(
|
||||||
onConfirm = { decky.confirmPluginZip() }, onCancel = { decky.cancelPluginZip() },
|
onConfirm = { decky.confirmPluginZip() }, onCancel = { decky.cancelPluginZip() },
|
||||||
)
|
)
|
||||||
@@ -1483,12 +1472,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
launcherOrientation = launcherOrientation,
|
launcherOrientation = launcherOrientation,
|
||||||
homePage = homePage,
|
homePage = homePage,
|
||||||
launcherFullscreen = launcherFullscreen,
|
launcherFullscreen = launcherFullscreen,
|
||||||
launcherFrost = launcherFrost,
|
|
||||||
frostWallpaper = frostWallpaper,
|
|
||||||
frostCards = frostCards,
|
|
||||||
frostTransparency = frostTransparency,
|
|
||||||
frostCardTransparency = frostCardTransparency,
|
|
||||||
frostSupported = frost.supported,
|
|
||||||
controllerHaptics = controllerHaptics,
|
controllerHaptics = controllerHaptics,
|
||||||
downloadSource = downloadSource,
|
downloadSource = downloadSource,
|
||||||
downloadMirror = downloadMirror,
|
downloadMirror = downloadMirror,
|
||||||
@@ -1647,6 +1630,9 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
FrameGen.set(this, mode)
|
FrameGen.set(this, mode)
|
||||||
frameGenLabel = FrameGen.label(this)
|
frameGenLabel = FrameGen.label(this)
|
||||||
},
|
},
|
||||||
|
onImportLossless = {
|
||||||
|
pickLossless.launch(InAppFilePicker.buildIntent(this, listOf("dll"), getString(R.string.lsfg_pick_title)))
|
||||||
|
},
|
||||||
onProtons = { openProtons() },
|
onProtons = { openProtons() },
|
||||||
onComponents = { focusContent -> openComponents(focusContent) },
|
onComponents = { focusContent -> openComponents(focusContent) },
|
||||||
onGameComponents = { game -> openComponents(gameKey = game.profileKey) },
|
onGameComponents = { game -> openComponents(gameKey = game.profileKey) },
|
||||||
@@ -1821,28 +1807,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
launcherFullscreen = on
|
launcherFullscreen = on
|
||||||
applyLauncherFullscreen()
|
applyLauncherFullscreen()
|
||||||
},
|
},
|
||||||
onLauncherFrost = { on ->
|
|
||||||
SessionPrefs.setLauncherFrost(this, on)
|
|
||||||
launcherFrost = on
|
|
||||||
if (on && frostWallpaper && !frost.prepared) restartLauncher()
|
|
||||||
},
|
|
||||||
onFrostWallpaper = { on ->
|
|
||||||
SessionPrefs.setFrostWallpaper(this, on)
|
|
||||||
frostWallpaper = on
|
|
||||||
if (on && !frost.prepared) restartLauncher()
|
|
||||||
},
|
|
||||||
onFrostCards = { on ->
|
|
||||||
SessionPrefs.setFrostCards(this, on)
|
|
||||||
frostCards = on
|
|
||||||
},
|
|
||||||
onFrostTransparency = { percent ->
|
|
||||||
SessionPrefs.setFrostTransparency(this, percent)
|
|
||||||
frostTransparency = SessionPrefs.frostTransparency(this)
|
|
||||||
},
|
|
||||||
onFrostCardTransparency = { percent ->
|
|
||||||
SessionPrefs.setFrostCardTransparency(this, percent)
|
|
||||||
frostCardTransparency = SessionPrefs.frostCardTransparency(this)
|
|
||||||
},
|
|
||||||
onGameStoresSpeedTier = { tier -> SessionPrefs.setGameStoresSpeedTier(this, tier); gameStoresSpeedTier = tier },
|
onGameStoresSpeedTier = { tier -> SessionPrefs.setGameStoresSpeedTier(this, tier); gameStoresSpeedTier = tier },
|
||||||
onNavigated = { navRequest = null },
|
onNavigated = { navRequest = null },
|
||||||
onStoresShowMature = { show -> SessionPrefs.setStoresShowMature(this, show); storesShowMature = show },
|
onStoresShowMature = { show -> SessionPrefs.setStoresShowMature(this, show); storesShowMature = show },
|
||||||
@@ -2149,9 +2113,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun frostShown(): Boolean =
|
|
||||||
launcherFrost && frostWallpaper && frost.prepared && frost.available && theme != com.droiddeck.launcher.ui.Themes.TRUE_BLACK
|
|
||||||
|
|
||||||
private fun applyLauncherFullscreen() {
|
private fun applyLauncherFullscreen() {
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
window.decorView.systemUiVisibility = if (launcherFullscreen) {
|
window.decorView.systemUiVisibility = if (launcherFullscreen) {
|
||||||
@@ -2233,7 +2194,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return try {
|
return try {
|
||||||
super.dispatchKeyEvent(event) || com.droiddeck.launcher.ui.PageBumpers.handle(event)
|
super.dispatchKeyEvent(event)
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
if (e.message?.contains("active focus target") != true) throw e
|
if (e.message?.contains("active focus target") != true) throw e
|
||||||
android.util.Log.w("MainActivity", "key ${event.keyCode} dropped: ${e.message}")
|
android.util.Log.w("MainActivity", "key ${event.keyCode} dropped: ${e.message}")
|
||||||
@@ -2242,9 +2203,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val triggerKeys = com.droiddeck.launcher.input.TriggerKeys { dispatchKeyEvent(it) }
|
private val triggerKeys = com.droiddeck.launcher.input.TriggerKeys { dispatchKeyEvent(it) }
|
||||||
|
|
||||||
internal fun onMenuMotion(event: MotionEvent) = triggerKeys.onMotion(event)
|
|
||||||
|
|
||||||
private val rightStickLayouts = HashMap<Int, Boolean>()
|
private val rightStickLayouts = HashMap<Int, Boolean>()
|
||||||
private val rightStickScrollHandler = android.os.Handler(android.os.Looper.getMainLooper())
|
private val rightStickScrollHandler = android.os.Handler(android.os.Looper.getMainLooper())
|
||||||
private var rightStickScrollDeviceId = -1
|
private var rightStickScrollDeviceId = -1
|
||||||
@@ -2366,10 +2324,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
refreshHomeAppState()
|
refreshHomeAppState()
|
||||||
}
|
}
|
||||||
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||||
settingsMode?.let { mode ->
|
settingsMode?.let { hdrOn = SessionPrefs.hdr(this, it) }
|
||||||
hdrOn = SessionPrefs.hdr(this, mode)
|
|
||||||
if (mode == SessionService.MODE_STEAM) loadPicturePositions()
|
|
||||||
}
|
|
||||||
compatLaunchVisible = true
|
compatLaunchVisible = true
|
||||||
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
||||||
com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false)
|
com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false)
|
||||||
@@ -2505,7 +2460,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
launchCoordinator.cancelAll()
|
launchCoordinator.cancelAll()
|
||||||
cancelCompatLaunch()
|
cancelCompatLaunch()
|
||||||
updates.unregister()
|
updates.unregister()
|
||||||
frost.stop()
|
|
||||||
runCatching { unregisterReceiver(shortcutsInstallStatus) }
|
runCatching { unregisterReceiver(shortcutsInstallStatus) }
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
@@ -2910,10 +2864,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait,
|
mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait,
|
||||||
panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||||
hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn,
|
hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn,
|
||||||
producerAcquireFences = producerAcquireFences.takeIf {
|
|
||||||
mode == SessionService.MODE_STEAM &&
|
|
||||||
com.droiddeck.launcher.runtime.FrameAcquireWorkerProbe.available(this)
|
|
||||||
},
|
|
||||||
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
|
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
|
||||||
gpuDrivers = drivers.summary(),
|
gpuDrivers = drivers.summary(),
|
||||||
touchMode = touchMode,
|
touchMode = touchMode,
|
||||||
@@ -2928,8 +2878,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
backHold = backHold,
|
backHold = backHold,
|
||||||
backActionsInverted = backActionsInverted,
|
backActionsInverted = backActionsInverted,
|
||||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||||
picturePositionLandscape = picturePositionLandscape.takeIf { mode == SessionService.MODE_STEAM },
|
picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null,
|
||||||
picturePositionPortrait = picturePositionPortrait.takeIf { mode == SessionService.MODE_STEAM },
|
|
||||||
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
|
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
|
||||||
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
|
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
|
||||||
avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null,
|
avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null,
|
||||||
@@ -2979,10 +2928,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
SessionPrefs.prefMode(SessionState.mode) == SessionPrefs.prefMode(mode))
|
SessionPrefs.prefMode(SessionState.mode) == SessionPrefs.prefMode(mode))
|
||||||
com.droiddeck.launcher.wayland.WaylandCompositor.nativeSetZeroCopy(on)
|
com.droiddeck.launcher.wayland.WaylandCompositor.nativeSetZeroCopy(on)
|
||||||
},
|
},
|
||||||
onProducerAcquireFences = {
|
|
||||||
SessionPrefs.setProducerAcquireFences(this, it)
|
|
||||||
producerAcquireFences = it
|
|
||||||
},
|
|
||||||
onGpuDrivers = { openComponents(focusContent = true, tab = com.droiddeck.launcher.ui.GPU_TAB) },
|
onGpuDrivers = { openComponents(focusContent = true, tab = com.droiddeck.launcher.ui.GPU_TAB) },
|
||||||
onUpscaler = { m -> SessionPrefs.setUpscaler(this, m); upscaler = m },
|
onUpscaler = { m -> SessionPrefs.setUpscaler(this, m); upscaler = m },
|
||||||
onUpscaleSharpness = { pct -> SessionPrefs.setUpscaleSharpness(this, pct); upscaleSharpness = pct },
|
onUpscaleSharpness = { pct -> SessionPrefs.setUpscaleSharpness(this, pct); upscaleSharpness = pct },
|
||||||
@@ -3006,10 +2951,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
backActionsInverted = inverted
|
backActionsInverted = inverted
|
||||||
},
|
},
|
||||||
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
||||||
onPicturePosition = { portrait, value ->
|
onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value },
|
||||||
SessionPrefs.setPicturePosition(this, portrait, value)
|
|
||||||
if (portrait) picturePositionPortrait = value else picturePositionLandscape = value
|
|
||||||
},
|
|
||||||
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
|
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
|
||||||
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
|
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
|
||||||
onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on },
|
onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on },
|
||||||
@@ -3107,7 +3049,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
fsyncFirst = fsyncFirst,
|
fsyncFirst = fsyncFirst,
|
||||||
gamescopeRealtime = gamescopeRealtime,
|
gamescopeRealtime = gamescopeRealtime,
|
||||||
gpuClockPin = gpuClockPin,
|
gpuClockPin = gpuClockPin,
|
||||||
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, desktopAsUser = desktopAsUser, cursorComposite = cursorComposite,
|
prootNoSeccomp = prootNoSeccomp, prootFastPath = prootFastPath, nativeUserland = nativeUserland, cursorComposite = cursorComposite,
|
||||||
guestHostname = guestHostname, phantomWarning = phantomWarning,
|
guestHostname = guestHostname, phantomWarning = phantomWarning,
|
||||||
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
onClientOverride = { on -> SessionPrefs.setClientCpusOverride(this, on); clientOverride = on },
|
||||||
onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on },
|
onPaceCores = { on -> SessionPrefs.setPaceCores(this, on); paceCores = on },
|
||||||
@@ -3124,7 +3066,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
onProotNoSeccomp = { on -> SessionPrefs.setProotNoSeccomp(this, on); prootNoSeccomp = on },
|
||||||
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
|
onProotFastPath = { on -> SessionPrefs.setProotFastPath(this, on); prootFastPath = on },
|
||||||
onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on },
|
onNativeUserland = { on -> SessionPrefs.setNativeUserland(this, on); nativeUserland = on },
|
||||||
onDesktopAsUser = { on -> SessionPrefs.setDesktopAsUser(this, on); desktopAsUser = on },
|
|
||||||
onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
|
onCursorComposite = { on -> SessionPrefs.setCursorComposite(this, on); cursorComposite = on },
|
||||||
onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) },
|
onGuestHostname = { name -> SessionPrefs.setGuestHostname(this, name) },
|
||||||
onClientCore = { core, on ->
|
onClientCore = { core, on ->
|
||||||
@@ -3326,11 +3267,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadPicturePositions() {
|
|
||||||
picturePositionLandscape = SessionPrefs.picturePosition(this, portrait = false)
|
|
||||||
picturePositionPortrait = SessionPrefs.picturePosition(this, portrait = true)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun loadModeSettings(mode: String) {
|
private fun loadModeSettings(mode: String) {
|
||||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||||
@@ -3352,7 +3288,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
loadBootMovie()
|
loadBootMovie()
|
||||||
hdrOn = SessionPrefs.hdr(this, mode)
|
hdrOn = SessionPrefs.hdr(this, mode)
|
||||||
zeroCopyOn = SessionPrefs.zeroCopy(this, mode)
|
zeroCopyOn = SessionPrefs.zeroCopy(this, mode)
|
||||||
producerAcquireFences = SessionPrefs.producerAcquireFences(this)
|
|
||||||
upscaler = SessionPrefs.upscaler(this)
|
upscaler = SessionPrefs.upscaler(this)
|
||||||
upscaleSharpness = SessionPrefs.upscaleSharpness(this)
|
upscaleSharpness = SessionPrefs.upscaleSharpness(this)
|
||||||
hdrReason = com.droiddeck.launcher.wayland.HdrSupport.blocked(this)
|
hdrReason = com.droiddeck.launcher.wayland.HdrSupport.blocked(this)
|
||||||
@@ -3366,7 +3301,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
backHold = SessionPrefs.backHold(this)
|
backHold = SessionPrefs.backHold(this)
|
||||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||||
directAudio = SessionPrefs.directAudio(this)
|
directAudio = SessionPrefs.directAudio(this)
|
||||||
loadPicturePositions()
|
picturePosition = SessionPrefs.picturePosition(this)
|
||||||
integerScaling = SessionPrefs.integerScaling(this)
|
integerScaling = SessionPrefs.integerScaling(this)
|
||||||
stretch16x9 = SessionPrefs.stretch16x9(this)
|
stretch16x9 = SessionPrefs.stretch16x9(this)
|
||||||
avoidNotch = SessionPrefs.avoidNotch(this)
|
avoidNotch = SessionPrefs.avoidNotch(this)
|
||||||
@@ -3449,7 +3384,6 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
|||||||
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
|
prootNoSeccomp = SessionPrefs.prootNoSeccomp(this)
|
||||||
prootFastPath = SessionPrefs.prootFastPath(this)
|
prootFastPath = SessionPrefs.prootFastPath(this)
|
||||||
nativeUserland = SessionPrefs.nativeUserland(this)
|
nativeUserland = SessionPrefs.nativeUserland(this)
|
||||||
desktopAsUser = SessionPrefs.desktopAsUser(this)
|
|
||||||
cursorComposite = SessionPrefs.cursorComposite(this)
|
cursorComposite = SessionPrefs.cursorComposite(this)
|
||||||
guestHostname = SessionPrefs.guestHostname(this)
|
guestHostname = SessionPrefs.guestHostname(this)
|
||||||
refreshPhantomStatus()
|
refreshPhantomStatus()
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ internal class ProtonMenu(
|
|||||||
var experimentalReleases by Operation.experimentalReleases
|
var experimentalReleases by Operation.experimentalReleases
|
||||||
companion object {
|
companion object {
|
||||||
const val EXPERIMENTAL = "experimental"
|
const val EXPERIMENTAL = "experimental"
|
||||||
private val REMEMBERED = setOf(ProtonExtras.OWN, ProtonExtras.ANTICHEAT)
|
|
||||||
}
|
}
|
||||||
@VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) }
|
@VisibleForTesting internal var latestCheck: (Boolean) -> Boolean = { force -> ProtonExtras.checkLatest(activity, force) }
|
||||||
@VisibleForTesting internal var experimentalRefresh: () -> List<ExperimentalProtons.Release>? = { ExperimentalProtons.refresh(activity) }
|
@VisibleForTesting internal var experimentalRefresh: () -> List<ExperimentalProtons.Release>? = { ExperimentalProtons.refresh(activity) }
|
||||||
@@ -67,7 +66,7 @@ internal class ProtonMenu(
|
|||||||
ui.post { protonStage = label; protonPercent = value }
|
ui.post { protonStage = label; protonPercent = value }
|
||||||
}
|
}
|
||||||
}.getOrElse { it.message ?: it.javaClass.simpleName }
|
}.getOrElse { it.message ?: it.javaClass.simpleName }
|
||||||
if (problem == null && !automatic && tool.id in REMEMBERED) ProtonExtras.setDeclined(activity, false, tool.id)
|
if (problem == null && !automatic && tool.id == ProtonExtras.OWN) ProtonExtras.setDeclined(activity, false)
|
||||||
if (tool.id == ProtonExtras.OWN) {
|
if (tool.id == ProtonExtras.OWN) {
|
||||||
if (problem == null) Onboarding.finish(Onboarding.Step.PROTON) else Onboarding.fail(Onboarding.Step.PROTON, problem)
|
if (problem == null) Onboarding.finish(Onboarding.Step.PROTON) else Onboarding.fail(Onboarding.Step.PROTON, problem)
|
||||||
Onboarding.recheck(activity)
|
Onboarding.recheck(activity)
|
||||||
@@ -97,7 +96,7 @@ internal class ProtonMenu(
|
|||||||
protonPercent = -1
|
protonPercent = -1
|
||||||
Thread({
|
Thread({
|
||||||
if (older) ProtonExtras.removeOlder(activity, tool) else ProtonExtras.remove(activity, tool, dir)
|
if (older) ProtonExtras.removeOlder(activity, tool) else ProtonExtras.remove(activity, tool, dir)
|
||||||
if (tool.id in REMEMBERED && ProtonExtras.installedAll(activity, tool).isEmpty()) ProtonExtras.setDeclined(activity, true, tool.id)
|
if (tool.id == ProtonExtras.OWN && ProtonExtras.installedAll(activity, tool).isEmpty()) ProtonExtras.setDeclined(activity, true)
|
||||||
ui.post {
|
ui.post {
|
||||||
protonBusyId = null
|
protonBusyId = null
|
||||||
protonStage = null
|
protonStage = null
|
||||||
@@ -159,7 +158,7 @@ internal class ProtonMenu(
|
|||||||
refreshExperimental()
|
refreshExperimental()
|
||||||
protonRows = ProtonExtras.offered(activity).map {
|
protonRows = ProtonExtras.offered(activity).map {
|
||||||
val all = ProtonExtras.installedAll(activity, it)
|
val all = ProtonExtras.installedAll(activity, it)
|
||||||
ProtonRow(it.id, if (it.label != 0) activity.getString(it.label) else it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it))
|
ProtonRow(it.id, it.name, all.lastOrNull(), ProtonExtras.queued(activity, it), all, ProtonExtras.update(activity, it))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,32 +4,25 @@ import android.app.NativeActivity
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.SystemClock
|
import android.os.SystemClock
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.Surface
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.droiddeck.launcher.gpu.SteamVr
|
import com.droiddeck.launcher.gpu.SteamVr
|
||||||
import com.droiddeck.launcher.session.SessionService
|
import com.droiddeck.launcher.session.SessionService
|
||||||
import com.droiddeck.launcher.session.SessionState
|
import com.droiddeck.launcher.session.SessionState
|
||||||
import com.droiddeck.launcher.session.xr.XrLayerSource
|
|
||||||
import com.droiddeck.launcher.session.xr.XrPanels
|
|
||||||
import com.droiddeck.launcher.wayland.CompositorHost
|
import com.droiddeck.launcher.wayland.CompositorHost
|
||||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
import com.droiddeck.launcher.wayland.WaylandCompositor
|
||||||
|
|
||||||
class QuestXrActivity : NativeActivity(), XrLayerSource {
|
class QuestXrActivity : NativeActivity() {
|
||||||
private var steamVrStarted = false
|
private var steamVrStarted = false
|
||||||
@Volatile private var closing = false
|
@Volatile private var closing = false
|
||||||
@Volatile private var steamVrStatus = SteamVr.Status.UNAVAILABLE
|
@Volatile private var steamVrStatus = SteamVr.Status.UNAVAILABLE
|
||||||
private var sessionId: String? = null
|
private var sessionId: String? = null
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
// NativeActivity opens the library itself, but the layer host's JNI methods resolve only
|
|
||||||
// through a System.loadLibrary.
|
|
||||||
System.loadLibrary("droiddeckxr")
|
|
||||||
sessionId = SessionState.sessionId
|
sessionId = SessionState.sessionId
|
||||||
SessionService.setXrActivityVisible(this, true)
|
SessionService.setXrActivityVisible(this, true)
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onXrActive(active: Boolean) {
|
fun onXrActive(active: Boolean) {
|
||||||
XrPanels.setDrawing(active)
|
|
||||||
if (active) {
|
if (active) {
|
||||||
check(CompositorHost.isStarted) { "DroidDeck compositor is not running" }
|
check(CompositorHost.isStarted) { "DroidDeck compositor is not running" }
|
||||||
SessionService.resume(this)
|
SessionService.resume(this)
|
||||||
@@ -107,30 +100,8 @@ class QuestXrActivity : NativeActivity(), XrLayerSource {
|
|||||||
|
|
||||||
fun onXrStatus(): Int = steamVrStatus.ordinal
|
fun onXrStatus(): Int = steamVrStatus.ordinal
|
||||||
|
|
||||||
fun onXrHostBuffers(state: java.nio.ByteBuffer, control: java.nio.ByteBuffer) {
|
|
||||||
runOnUiThread { if (!closing) XrPanels.attach(this, state, control) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onXrHostFrame() = XrPanels.frame()
|
|
||||||
|
|
||||||
override val context: android.content.Context get() = this
|
|
||||||
override fun createLayer(width: Int, height: Int) = nativeCreateLayer(width, height)
|
|
||||||
override fun layerSurface(id: Int) = nativeLayerSurface(id)
|
|
||||||
override fun destroyLayer(id: Int) = nativeDestroyLayer(id)
|
|
||||||
override fun setOrbImage(image: android.graphics.Bitmap) = nativeSetOrbImage(image)
|
|
||||||
override fun leave() {
|
|
||||||
closing = true
|
|
||||||
finish()
|
|
||||||
}
|
|
||||||
|
|
||||||
private external fun nativeCreateLayer(width: Int, height: Int): Int
|
|
||||||
private external fun nativeLayerSurface(id: Int): Surface?
|
|
||||||
private external fun nativeDestroyLayer(id: Int)
|
|
||||||
private external fun nativeSetOrbImage(image: android.graphics.Bitmap)
|
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
closing = true
|
closing = true
|
||||||
XrPanels.detach()
|
|
||||||
SessionService.setXrActivityVisible(this, false)
|
SessionService.setXrActivityVisible(this, false)
|
||||||
super.onDestroy()
|
super.onDestroy()
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
@@ -19,15 +19,6 @@ object AgentAttachments {
|
|||||||
/** Guest paths waiting to go with the next message. */
|
/** Guest paths waiting to go with the next message. */
|
||||||
val pending = mutableStateListOf<String>()
|
val pending = mutableStateListOf<String>()
|
||||||
|
|
||||||
/** True while the file picker is open over a session: it answers the drawer's agent page, so the drawer must stay. */
|
|
||||||
@Volatile var picking = false
|
|
||||||
|
|
||||||
/** Launches a system screen that answers the agent page, keeping the drawer for it; the result callback clears [picking]. */
|
|
||||||
fun pick(launch: () -> Unit) {
|
|
||||||
picking = true
|
|
||||||
if (runCatching(launch).isFailure) picking = false
|
|
||||||
}
|
|
||||||
|
|
||||||
private const val NEW = "new"
|
private const val NEW = "new"
|
||||||
private const val GUEST_DIR = "/root/.cache/droiddeck/attachments"
|
private const val GUEST_DIR = "/root/.cache/droiddeck/attachments"
|
||||||
private val IMAGE = setOf("png", "jpg", "jpeg", "webp", "gif", "bmp")
|
private val IMAGE = setOf("png", "jpg", "jpeg", "webp", "gif", "bmp")
|
||||||
@@ -44,17 +35,14 @@ object AgentAttachments {
|
|||||||
val folder = chat ?: NEW
|
val folder = chat ?: NEW
|
||||||
val dir = File(hostDir(app), folder).apply { mkdirs() }
|
val dir = File(hostDir(app), folder).apply { mkdirs() }
|
||||||
return uris.mapNotNull { uri ->
|
return uris.mapNotNull { uri ->
|
||||||
var target: File? = null
|
|
||||||
runCatching {
|
runCatching {
|
||||||
val name = displayName(app, uri).replace(Regex("[^A-Za-z0-9._-]"), "_").ifEmpty { "file" }
|
val name = displayName(app, uri).replace(Regex("[^A-Za-z0-9._-]"), "_").ifEmpty { "file" }
|
||||||
var candidate = File(dir, name)
|
var target = File(dir, name)
|
||||||
var n = 1
|
var n = 1
|
||||||
// Created atomically, so copies running side by side never pick the same name.
|
while (target.exists()) target = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}")
|
||||||
while (!candidate.createNewFile()) candidate = File(dir, "${name.substringBeforeLast('.')}-${n++}${name.substringAfterLast('.', "").let { if (it.isEmpty()) "" else ".$it" }}")
|
app.contentResolver.openInputStream(uri)!!.use { input -> target.outputStream().use { input.copyTo(it) } }
|
||||||
target = candidate
|
"$GUEST_DIR/$folder/${target.name}"
|
||||||
app.contentResolver.openInputStream(uri)!!.use { input -> candidate.outputStream().use { input.copyTo(it) } }
|
}.getOrNull()
|
||||||
"$GUEST_DIR/$folder/${candidate.name}"
|
|
||||||
}.onFailure { target?.delete() }.getOrNull()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
package com.droiddeck.launcher.agent
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.Intent
|
|
||||||
import android.os.Bundle
|
|
||||||
import androidx.activity.ComponentActivity
|
|
||||||
import androidx.activity.compose.setContent
|
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.layout.fillMaxSize
|
|
||||||
import androidx.compose.foundation.layout.padding
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.ui.Modifier
|
|
||||||
import androidx.compose.ui.unit.dp
|
|
||||||
import com.droiddeck.launcher.core.AppUiPrefs
|
|
||||||
import com.droiddeck.launcher.ui.AgentPage
|
|
||||||
import com.droiddeck.launcher.ui.DroidDeckTheme
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The agent's chat in a window of its own, for Quest's flat mode: opened in its own task, it is a
|
|
||||||
* separate Horizon panel the user can move, resize and close like any other.
|
|
||||||
*/
|
|
||||||
class AgentChatActivity : ComponentActivity() {
|
|
||||||
override fun attachBaseContext(newBase: Context) {
|
|
||||||
super.attachBaseContext(newBase)
|
|
||||||
com.droiddeck.launcher.core.AppLanguage.applyTo(this, newBase)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContent {
|
|
||||||
DroidDeckTheme(appScale = AppUiPrefs.scale(this)) {
|
|
||||||
AgentPage(
|
|
||||||
Modifier.fillMaxSize().background(MaterialTheme.colorScheme.background).padding(horizontal = 12.dp, vertical = 6.dp),
|
|
||||||
visible = true, startTyping = AgentHost.entries.isEmpty(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
fun open(context: Context) {
|
|
||||||
context.startActivity(
|
|
||||||
Intent(context, AgentChatActivity::class.java)
|
|
||||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ import java.util.UUID
|
|||||||
object AgentGuest {
|
object AgentGuest {
|
||||||
private val main by lazy { Handler(Looper.getMainLooper()) }
|
private val main by lazy { Handler(Looper.getMainLooper()) }
|
||||||
var focusRevision by mutableIntStateOf(0)
|
var focusRevision by mutableIntStateOf(0)
|
||||||
@androidx.annotation.VisibleForTesting internal set
|
private set
|
||||||
var steamKeyboard by mutableStateOf(false)
|
var steamKeyboard by mutableStateOf(false)
|
||||||
private set
|
private set
|
||||||
var desktopTextField by mutableStateOf(false)
|
var desktopTextField by mutableStateOf(false)
|
||||||
|
|||||||
@@ -75,9 +75,7 @@ object AgentHost {
|
|||||||
"Never kill by a command-line pattern (pkill -f, pgrep -f piped to kill): your own command line holds the user's message, so the pattern matches you. " +
|
"Never kill by a command-line pattern (pkill -f, pgrep -f piped to kill): your own command line holds the user's message, so the pattern matches you. " +
|
||||||
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " +
|
"Files the user attaches are listed at the end of their message, under /root/.cache/droiddeck/attachments. " +
|
||||||
"To have the user pick between options, end your reply with a fenced code block whose language is choices, one short option per line, " +
|
"To have the user pick between options, end your reply with a fenced code block whose language is choices, one short option per line, " +
|
||||||
"and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message. " +
|
"and end your turn: DroidDeck shows them as buttons and sends the one picked as the next message."
|
||||||
"To show the user an image (a screenshot, a mockup, a chart), put  on a line of its own: " +
|
|
||||||
"DroidDeck draws the file in the chat."
|
|
||||||
|
|
||||||
val entries = mutableStateListOf<Entry>()
|
val entries = mutableStateListOf<Entry>()
|
||||||
val queue = mutableStateListOf<Queued>()
|
val queue = mutableStateListOf<Queued>()
|
||||||
|
|||||||
@@ -226,18 +226,7 @@ object AgentSetup {
|
|||||||
/** The whole output of a step's last run; the card shows only its last line. */
|
/** The whole output of a step's last run; the card shows only its last line. */
|
||||||
fun logFile(app: Context, step: Step) = File(app.filesDir, "agent/setup-${step.name.lowercase()}.log")
|
fun logFile(app: Context, step: Step) = File(app.filesDir, "agent/setup-${step.name.lowercase()}.log")
|
||||||
|
|
||||||
/**
|
fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git")
|
||||||
* An install set up before setup wrote the Gradle init script gets the step again, but only
|
|
||||||
* once the checkout's setup writes it: the step runs that script, and an older one never would.
|
|
||||||
*/
|
|
||||||
fun buildToolsInstalled(app: Context) = AgentHost.guestFileExists(app, "/root/aapt2/aapt2") && AgentHost.guestFileExists(app, "$CHECKOUT/.git") &&
|
|
||||||
(AgentHost.guestFileExists(app, GRADLE_INIT) || !setupWritesGradleInit(app))
|
|
||||||
|
|
||||||
private const val GRADLE_INIT = "/root/.gradle/init.d/droiddeck-device.gradle"
|
|
||||||
|
|
||||||
private fun setupWritesGradleInit(app: Context) = runCatching {
|
|
||||||
File(LinuxRuntime.rootDir(app), "$CHECKOUT/tools/agent/setup".removePrefix("/")).readText().contains(GRADLE_INIT.substringAfterLast('/'))
|
|
||||||
}.getOrDefault(false)
|
|
||||||
|
|
||||||
/** dd-lab-build compiled this install's commit, so a Lab build compiles only what changed. */
|
/** dd-lab-build compiled this install's commit, so a Lab build compiles only what changed. */
|
||||||
private fun prepared(app: Context) = runCatching {
|
private fun prepared(app: Context) = runCatching {
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.droiddeck.launcher.core.TarZst;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.AtomicMoveNotSupportedException;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -37,15 +36,9 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
private final HostLifecycle host = new HostLifecycle(Process::killProcess);
|
private final HostLifecycle host = new HostLifecycle(Process::killProcess);
|
||||||
|
|
||||||
static final class HostLifecycle {
|
static final class HostLifecycle {
|
||||||
static final int MAX_STARTUP_CRASH_RESTARTS = 4;
|
|
||||||
private static final long[] STARTUP_RESTART_DELAYS_MS = {250L, 1000L, 2000L, 4000L};
|
|
||||||
|
|
||||||
volatile int pid = -1;
|
volatile int pid = -1;
|
||||||
private long generation;
|
private long generation;
|
||||||
private long launches;
|
private long launches;
|
||||||
private boolean preferStandardPerformanceMode;
|
|
||||||
private boolean sinkReady;
|
|
||||||
private int startupCrashRestarts;
|
|
||||||
private final IntConsumer terminate;
|
private final IntConsumer terminate;
|
||||||
final ReentrantReadWriteLock commands = new ReentrantReadWriteLock();
|
final ReentrantReadWriteLock commands = new ReentrantReadWriteLock();
|
||||||
|
|
||||||
@@ -55,9 +48,6 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
|
|
||||||
synchronized long begin() {
|
synchronized long begin() {
|
||||||
stop();
|
stop();
|
||||||
preferStandardPerformanceMode = false;
|
|
||||||
sinkReady = false;
|
|
||||||
startupCrashRestarts = 0;
|
|
||||||
return generation;
|
return generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +55,6 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
generation++;
|
generation++;
|
||||||
if (pid > 1) terminate.accept(pid);
|
if (pid > 1) terminate.accept(pid);
|
||||||
pid = -1;
|
pid = -1;
|
||||||
sinkReady = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean launch(long expected, IntSupplier launch) {
|
boolean launch(long expected, IntSupplier launch) {
|
||||||
@@ -74,7 +63,6 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
if (expected != generation) return false;
|
if (expected != generation) return false;
|
||||||
launches++;
|
launches++;
|
||||||
sinkReady = false;
|
|
||||||
pid = launch.getAsInt();
|
pid = launch.getAsInt();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -105,45 +93,11 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
return token == launches && pid > 1;
|
return token == launches && pid > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized boolean preferStandardPerformanceMode() {
|
|
||||||
return preferStandardPerformanceMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized void markLowLatencyFailed(long token) {
|
|
||||||
if (token == launches && pid > 1) preferStandardPerformanceMode = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized void markSinkReady(long token) {
|
|
||||||
if (token == launches && pid > 1) {
|
|
||||||
sinkReady = true;
|
|
||||||
startupCrashRestarts = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized boolean exited(long expected) {
|
synchronized boolean exited(long expected) {
|
||||||
if (expected != generation || pid <= 1) return false;
|
if (expected != generation || pid <= 1) return false;
|
||||||
pid = -1;
|
pid = -1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Decides whether a dead host should be restarted and after how many milliseconds.
|
|
||||||
* Returns 0 for immediate recovery of a host that had a working sink, a positive backoff
|
|
||||||
* while falling back to standard AAudio mode after a startup crash, or -1 to stop retrying.
|
|
||||||
*/
|
|
||||||
synchronized long nextRestartDelayMs(long expected) {
|
|
||||||
if (expected != generation) return -1L;
|
|
||||||
if (sinkReady) {
|
|
||||||
sinkReady = false;
|
|
||||||
startupCrashRestarts = 0;
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
preferStandardPerformanceMode = true;
|
|
||||||
if (startupCrashRestarts >= MAX_STARTUP_CRASH_RESTARTS) return -1L;
|
|
||||||
long delay = STARTUP_RESTART_DELAYS_MS[Math.min(startupCrashRestarts, STARTUP_RESTART_DELAYS_MS.length - 1)];
|
|
||||||
startupCrashRestarts++;
|
|
||||||
return delay;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PulseAudioComponent(Context context) {
|
public PulseAudioComponent(Context context) {
|
||||||
@@ -213,14 +167,11 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
if (micFifoPath != null && !micFifoPath.isEmpty()) {
|
if (micFifoPath != null && !micFifoPath.isEmpty()) {
|
||||||
new File(micFifoPath).delete();
|
new File(micFifoPath).delete();
|
||||||
}
|
}
|
||||||
boolean standardMode = host.preferStandardPerformanceMode();
|
|
||||||
String initialPerformanceMode = standardMode ? "0" : "1";
|
|
||||||
ArrayList<String> config = new ArrayList<>();
|
ArrayList<String> config = new ArrayList<>();
|
||||||
config.add("load-module module-native-protocol-unix auth-anonymous=1 auth-cookie-enabled=0 socket=\""
|
config.add("load-module module-native-protocol-unix auth-anonymous=1 auth-cookie-enabled=0 socket=\""
|
||||||
+ socket().getAbsolutePath() + "\"");
|
+ socket().getAbsolutePath() + "\"");
|
||||||
config.add(".nofail");
|
config.add(".nofail");
|
||||||
config.add("load-module module-directaudio-native-sink sink_name=DirectAudio performance_mode="
|
config.add("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);
|
||||||
+ initialPerformanceMode + " adaptive=1 decay=0 limiter=1 watchdog=1 volume=1.0 control_dir=" + deviceControls);
|
|
||||||
config.add("set-default-sink DirectAudio");
|
config.add("set-default-sink DirectAudio");
|
||||||
config.add(".fail");
|
config.add(".fail");
|
||||||
if (micFifoPath != null && !micFifoPath.isEmpty()) {
|
if (micFifoPath != null && !micFifoPath.isEmpty()) {
|
||||||
@@ -246,25 +197,7 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
final java.io.PrintWriter out = openLog();
|
final java.io.PrintWriter out = openLog();
|
||||||
if (!host.launch(generation, () -> HostProcess.startUncounted(command, env.toArray(new String[0]), workingDir, status -> {
|
if (!host.launch(generation, () -> HostProcess.startUncounted(command, env.toArray(new String[0]), workingDir, status -> {
|
||||||
if (host.exited(generation)) {
|
if (host.exited(generation)) {
|
||||||
long delayMs = host.nextRestartDelayMs(generation);
|
Log.w(TAG, "audio host exited with status " + status + "; restarting");
|
||||||
if (delayMs < 0) {
|
|
||||||
String msg = "audio host exited with status " + status
|
|
||||||
+ " before a client sink came up too many times; not restarting again in this session";
|
|
||||||
Log.w(TAG, msg);
|
|
||||||
note(out, msg);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Log.w(TAG, "audio host exited with status " + status + "; restarting"
|
|
||||||
+ (host.preferStandardPerformanceMode() ? " with standard AAudio mode" : "")
|
|
||||||
+ (delayMs > 0 ? " in " + delayMs + " ms" : ""));
|
|
||||||
if (delayMs > 0) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(delayMs);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
start(generation);
|
start(generation);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -278,24 +211,6 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
guard.start();
|
guard.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean loadDirectAudioSink(long token, String performanceMode) {
|
|
||||||
if ("0".equals(performanceMode)) pactlOk(token, "unload-module", "module-directaudio-native-sink");
|
|
||||||
String loaded = pactlFor(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio",
|
|
||||||
"performance_mode=" + performanceMode,
|
|
||||||
"adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls);
|
|
||||||
if (loaded == null) return false;
|
|
||||||
if (pactlOk(token, "set-default-sink", "DirectAudio")) return true;
|
|
||||||
String moduleId = loaded.trim();
|
|
||||||
pactlOk(token, "unload-module", moduleId.matches("\\d+") ? moduleId : "module-directaudio-native-sink");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean loadPlainAAudioSink(long token, String performanceMode) {
|
|
||||||
return pactlOk(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink",
|
|
||||||
"performance_mode=" + performanceMode, "adaptive=1", "volume=1.0", "control_dir=" + deviceControls)
|
|
||||||
&& pactlOk(token, "set-default-sink", "AAudioSink");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ensureClientSink(java.io.PrintWriter out, long token) {
|
private void ensureClientSink(java.io.PrintWriter out, long token) {
|
||||||
try {
|
try {
|
||||||
// Nothing that may block (a sink whose AAudio open hangs: a Galaxy S24 FE (US) hung the
|
// Nothing that may block (a sink whose AAudio open hangs: a Galaxy S24 FE (US) hung the
|
||||||
@@ -317,42 +232,27 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
if (sinks == null) {
|
if (sinks == null) {
|
||||||
line = "== client sink: the daemon did not answer in 30 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.*")) {
|
} else if (sinks.contains("\tDirectAudio\t") || sinks.startsWith("DirectAudio\t") || sinks.contains("\tDirectAudio\n") || sinks.matches("(?s).*\\bDirectAudio\\b.*")) {
|
||||||
host.markSinkReady(token);
|
line = "== client sink: DirectAudio (module-directaudio-native-sink)";
|
||||||
line = "== client sink: DirectAudio (module-directaudio-native-sink"
|
|
||||||
+ (host.preferStandardPerformanceMode() ? ", standard mode" : "") + ")";
|
|
||||||
} else {
|
} else {
|
||||||
// AAudio can refuse the first open with AAUDIO_ERROR_DISCONNECTED while Android is
|
// AAudio can refuse the first open with AAUDIO_ERROR_DISCONNECTED while Android is
|
||||||
// still switching the output route (Galaxy S24 FE) or when low-latency MMAP output
|
// still switching the output route as the session starts (seen on a Galaxy S24 FE):
|
||||||
// is rejected by the HAL (Samsung One UI). Retry low-latency once if it hasn't been
|
// try DirectAudio again, then the plain sink, a few times over ten seconds.
|
||||||
// disqualified yet, then fall back to performance_mode=0 (non-MMAP) on DirectAudio
|
|
||||||
// before trying the plain AAudio sink.
|
|
||||||
String loadedAs = null;
|
String loadedAs = null;
|
||||||
for (int attempt = 1; attempt <= 5 && loadedAs == null && host.live(token); attempt++) {
|
for (int attempt = 1; attempt <= 5 && loadedAs == null && host.live(token); attempt++) {
|
||||||
try { Thread.sleep(2000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; }
|
try { Thread.sleep(2000L); } catch (InterruptedException e) { Thread.currentThread().interrupt(); return; }
|
||||||
if (!host.live(token)) break;
|
if (pactlOk(token, "load-module", "module-directaudio-native-sink", "sink_name=DirectAudio", "performance_mode=1",
|
||||||
if (attempt == 1 && !host.preferStandardPerformanceMode()) {
|
"adaptive=1", "decay=0", "limiter=1", "watchdog=1", "volume=1.0", "control_dir=" + deviceControls)
|
||||||
if (loadDirectAudioSink(token, "1")) {
|
&& pactlOk(token, "set-default-sink", "DirectAudio")) {
|
||||||
loadedAs = "DirectAudio on attempt " + attempt;
|
loadedAs = "DirectAudio on attempt " + attempt;
|
||||||
break;
|
} else if (pactlOk(token, "load-module", "module-aaudio-sink", "sink_name=AAudioSink",
|
||||||
}
|
"performance_mode=" + (attempt == 1 ? "1" : "0"), "adaptive=1", "volume=1.0", "control_dir=" + deviceControls)
|
||||||
if (!host.live(token)) break;
|
&& pactlOk(token, "set-default-sink", "AAudioSink")) {
|
||||||
host.markLowLatencyFailed(token);
|
loadedAs = "the plain AAudio sink (AAudioSink) on attempt " + attempt;
|
||||||
}
|
|
||||||
if (loadDirectAudioSink(token, "0")) {
|
|
||||||
loadedAs = "DirectAudio (standard mode) on attempt " + attempt;
|
|
||||||
} else if (host.live(token) && loadPlainAAudioSink(token, "0")) {
|
|
||||||
loadedAs = "the plain AAudio sink (AAudioSink, standard mode) on attempt " + attempt;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (loadedAs != null) {
|
line = loadedAs != null ? "== client sink: DirectAudio did not come up at start; retried and got " + loadedAs
|
||||||
host.markSinkReady(token);
|
: "== client sink: DirectAudio did not come up and the AAudio fallback failed too after 5 retries - no client sound."
|
||||||
line = "== client sink: DirectAudio did not come up at start; retried and got " + loadedAs;
|
+ " If audio.log shows AAUDIO_ERROR_DISCONNECTED, Android refused the audio output: rebooting the phone usually fixes this";
|
||||||
} else if (!host.live(token)) {
|
|
||||||
line = "== client sink: audio host exited during sink recovery";
|
|
||||||
} else {
|
|
||||||
line = "== 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.w(TAG, line);
|
||||||
}
|
}
|
||||||
Log.i(TAG, line);
|
Log.i(TAG, line);
|
||||||
@@ -507,22 +407,11 @@ public class PulseAudioComponent extends SessionPart {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
File destination = new File(workingDir, lib);
|
File destination = new File(workingDir, lib);
|
||||||
File temp = null;
|
|
||||||
try (InputStream in = resource.openStream()) {
|
try (InputStream in = resource.openStream()) {
|
||||||
temp = File.createTempFile(lib + ".", ".tmp", workingDir);
|
Files.copy(in, destination.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
Files.copy(in, temp.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
FileUtils.chmod(destination, 0771);
|
||||||
FileUtils.chmod(temp, 0771);
|
|
||||||
try {
|
|
||||||
Files.move(temp.toPath(), destination.toPath(),
|
|
||||||
StandardCopyOption.ATOMIC_MOVE, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} catch (AtomicMoveNotSupportedException e) {
|
|
||||||
Files.move(temp.toPath(), destination.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
temp = null;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.w(TAG, "copy " + lib, e);
|
Log.w(TAG, "copy " + lib, e);
|
||||||
} finally {
|
|
||||||
if (temp != null) temp.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ import java.io.File
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import java.util.TimeZone
|
|
||||||
|
|
||||||
object DeviceReport {
|
object DeviceReport {
|
||||||
private const val TAG = "DeviceReport"
|
private const val TAG = "DeviceReport"
|
||||||
@@ -37,10 +36,6 @@ object DeviceReport {
|
|||||||
.map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") }
|
.map { it.substringAfter(':').trim().split(Regex("\\s+")).filter(String::isNotEmpty).joinToString(" ") }
|
||||||
.filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" }
|
.filter(String::isNotEmpty).distinct().joinToString(" | ").ifEmpty { "not reported" }
|
||||||
|
|
||||||
internal fun buildDate(millis: Long): String? = millis.takeIf { it > 0 }?.let {
|
|
||||||
SimpleDateFormat("yyyy-MM-dd HH:mm 'UTC'", Locale.US).apply { timeZone = TimeZone.getTimeZone("UTC") }.format(Date(it))
|
|
||||||
}
|
|
||||||
|
|
||||||
fun write(context: Context, target: File, mode: String) {
|
fun write(context: Context, target: File, mode: String) {
|
||||||
try {
|
try {
|
||||||
target.writeText(build(context, mode))
|
target.writeText(build(context, mode))
|
||||||
@@ -134,7 +129,6 @@ object DeviceReport {
|
|||||||
k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
|
k("Android", "${Build.VERSION.RELEASE} (API ${Build.VERSION.SDK_INT})")
|
||||||
k("Security patch", Build.VERSION.SECURITY_PATCH)
|
k("Security patch", Build.VERSION.SECURITY_PATCH)
|
||||||
k("Build", Build.DISPLAY)
|
k("Build", Build.DISPLAY)
|
||||||
k("Build date", buildDate(Build.TIME))
|
|
||||||
k("Fingerprint", Build.FINGERPRINT)
|
k("Fingerprint", Build.FINGERPRINT)
|
||||||
k("Kernel", System.getProperty("os.version"))
|
k("Kernel", System.getProperty("os.version"))
|
||||||
k("ABIs", Build.SUPPORTED_ABIS.joinToString(", "))
|
k("ABIs", Build.SUPPORTED_ABIS.joinToString(", "))
|
||||||
|
|||||||
@@ -10,13 +10,11 @@ object FrameGen {
|
|||||||
const val ENGINE_DDFG = "ddfg"
|
const val ENGINE_DDFG = "ddfg"
|
||||||
private const val LEGACY_ENGINE_WINFG = "winfg"
|
private const val LEGACY_ENGINE_WINFG = "winfg"
|
||||||
const val ENGINE_LSFG = "lsfg"
|
const val ENGINE_LSFG = "lsfg"
|
||||||
const val ENGINE_ZEROFG = "zerofg"
|
|
||||||
|
|
||||||
private const val DDFG_PERF_PRESET = 2
|
private const val DDFG_PERF_PRESET = 2
|
||||||
private const val DDFG_MODEL = 4
|
private const val DDFG_MODEL = 4
|
||||||
private const val FLOW_SCALE_DDFG = 0.60f
|
private const val FLOW_SCALE_DDFG = 0.60f
|
||||||
private const val FLOW_SCALE_LSFG = 0.80f
|
private const val FLOW_SCALE_LSFG = 0.80f
|
||||||
private const val FLOW_SCALE_ZEROFG = 1.0f
|
|
||||||
|
|
||||||
val ADAPTIVE_TARGETS = listOf(120, 90, 60)
|
val ADAPTIVE_TARGETS = listOf(120, 90, 60)
|
||||||
|
|
||||||
@@ -71,14 +69,6 @@ object FrameGen {
|
|||||||
.putString("engine", mode.engine).putInt("multiplier", mode.multiplier).putInt("target", mode.target).apply()
|
.putString("engine", mode.engine).putInt("multiplier", mode.multiplier).putInt("target", mode.target).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pacerEnabled(context: Context): Boolean =
|
|
||||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getBoolean("pacer", false)
|
|
||||||
|
|
||||||
fun setPacer(context: Context, enabled: Boolean) {
|
|
||||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putBoolean("pacer", enabled).apply()
|
|
||||||
WaylandCompositor.nativeSetFrameGenPacer(enabled)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearGlobal(context: Context) {
|
fun clearGlobal(context: Context) {
|
||||||
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
|
context.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
|
||||||
.remove("engine").remove("multiplier").remove("target").apply()
|
.remove("engine").remove("multiplier").remove("target").apply()
|
||||||
@@ -90,7 +80,6 @@ object FrameGen {
|
|||||||
mode.engine == ENGINE_DDFG -> context.getString(R.string.frame_gen_ddfg, mode.multiplier)
|
mode.engine == ENGINE_DDFG -> context.getString(R.string.frame_gen_ddfg, mode.multiplier)
|
||||||
mode.engine == ENGINE_LSFG && mode.target > 0 -> context.getString(R.string.frame_gen_lsfg_adaptive, mode.target)
|
mode.engine == ENGINE_LSFG && mode.target > 0 -> context.getString(R.string.frame_gen_lsfg_adaptive, mode.target)
|
||||||
mode.engine == ENGINE_LSFG -> context.getString(R.string.frame_gen_lsfg, mode.multiplier)
|
mode.engine == ENGINE_LSFG -> context.getString(R.string.frame_gen_lsfg, mode.multiplier)
|
||||||
mode.engine == ENGINE_ZEROFG -> context.getString(R.string.frame_gen_zerofg, mode.multiplier)
|
|
||||||
else -> context.getString(R.string.frame_gen_off)
|
else -> context.getString(R.string.frame_gen_off)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +104,6 @@ object FrameGen {
|
|||||||
|
|
||||||
fun applyPrepared(context: Context, prepared: PreparedApply, refreshHz: Float): String? {
|
fun applyPrepared(context: Context, prepared: PreparedApply, refreshHz: Float): String? {
|
||||||
val mode = prepared.mode
|
val mode = prepared.mode
|
||||||
WaylandCompositor.nativeSetFrameGenPacer(pacerEnabled(context))
|
|
||||||
when (mode.engine) {
|
when (mode.engine) {
|
||||||
ENGINE_LSFG -> {
|
ENGINE_LSFG -> {
|
||||||
val status = prepared.lsfgStatus ?: LsfgNative.STATUS_NOT_INSTALLED
|
val status = prepared.lsfgStatus ?: LsfgNative.STATUS_NOT_INSTALLED
|
||||||
@@ -123,7 +111,7 @@ object FrameGen {
|
|||||||
if (status != LsfgNative.STATUS_OK || cachePath == null) {
|
if (status != LsfgNative.STATUS_OK || cachePath == null) {
|
||||||
WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
|
WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
|
||||||
val problem = context.getString(
|
val problem = context.getString(
|
||||||
if (status == LsfgNative.STATUS_NOT_INSTALLED) R.string.lsfg_needs_steam else R.string.lsfg_problem_failed,
|
if (status == LsfgNative.STATUS_NOT_INSTALLED) R.string.lsfg_problem_missing else R.string.lsfg_problem_failed,
|
||||||
)
|
)
|
||||||
Log.w(TAG, "$problem (status $status)")
|
Log.w(TAG, "$problem (status $status)")
|
||||||
return problem
|
return problem
|
||||||
@@ -139,11 +127,6 @@ object FrameGen {
|
|||||||
WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_DDFG, refreshHz)
|
WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_DDFG, refreshHz)
|
||||||
WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0)
|
WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0)
|
||||||
}
|
}
|
||||||
ENGINE_ZEROFG -> {
|
|
||||||
WaylandCompositor.nativeSetFrameGenEngine(WaylandCompositor.FG_ENGINE_ZEROFG)
|
|
||||||
WaylandCompositor.nativeSetFrameGenTuning(FLOW_SCALE_ZEROFG, refreshHz)
|
|
||||||
WaylandCompositor.nativeSetFrameGenArmed(true, mode.multiplier, 0)
|
|
||||||
}
|
|
||||||
else -> WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
|
else -> WaylandCompositor.nativeSetFrameGenArmed(false, 0, 0)
|
||||||
}
|
}
|
||||||
Log.i(TAG, "frame generation: $mode at ${refreshHz}Hz")
|
Log.i(TAG, "frame generation: $mode at ${refreshHz}Hz")
|
||||||
|
|||||||
@@ -2,16 +2,22 @@ package com.droiddeck.launcher.gpu
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import com.droiddeck.launcher.R
|
||||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||||
import com.droiddeck.launcher.session.GameStorage
|
import com.droiddeck.launcher.session.GameStorage
|
||||||
|
import com.droiddeck.launcher.session.SessionPrefs
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.security.DigestOutputStream
|
import java.security.DigestOutputStream
|
||||||
import java.security.MessageDigest
|
import java.security.MessageDigest
|
||||||
|
|
||||||
object Lossless {
|
object Lossless {
|
||||||
data class State(val owned: Boolean, val ready: Boolean) {
|
enum class Source { NONE, STEAM, IMPORT }
|
||||||
|
|
||||||
|
enum class ImportResult { UPDATED, UNCHANGED, NOT_OWNED, INVALID, FAILED }
|
||||||
|
|
||||||
|
data class State(val owned: Boolean, val ready: Boolean, val source: Source) {
|
||||||
companion object {
|
companion object {
|
||||||
val NONE = State(owned = false, ready = false)
|
val NONE = State(owned = false, ready = false, source = Source.NONE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,13 +26,15 @@ object Lossless {
|
|||||||
private const val KEY_OWNED = "owned"
|
private const val KEY_OWNED = "owned"
|
||||||
private const val KEY_ID = "id"
|
private const val KEY_ID = "id"
|
||||||
private const val KEY_SOURCE = "source"
|
private const val KEY_SOURCE = "source"
|
||||||
private const val SOURCE_STEAM = "STEAM"
|
|
||||||
private const val KEY_STEAM_STAMP = "steamStamp"
|
private const val KEY_STEAM_STAMP = "steamStamp"
|
||||||
private const val STEAM_MANIFEST = "steamapps/appmanifest_993090.acf"
|
|
||||||
private const val STEAM_DLL = "steamapps/common/Lossless Scaling/Lossless.dll"
|
private const val STEAM_DLL = "steamapps/common/Lossless Scaling/Lossless.dll"
|
||||||
private const val UNCHANGED = -1
|
private const val UNCHANGED = -1
|
||||||
|
|
||||||
fun state(context: Context) = State(owned(context), cacheFile(context)?.isFile == true)
|
fun state(context: Context): State {
|
||||||
|
val source = prefs(context).getString(KEY_SOURCE, null)
|
||||||
|
?.let { name -> Source.entries.firstOrNull { it.name == name } } ?: Source.NONE
|
||||||
|
return State(owned(context), cacheFile(context)?.isFile == true, source)
|
||||||
|
}
|
||||||
|
|
||||||
fun owned(context: Context): Boolean {
|
fun owned(context: Context): Boolean {
|
||||||
if (prefs(context).getBoolean(KEY_OWNED, false)) return true
|
if (prefs(context).getBoolean(KEY_OWNED, false)) return true
|
||||||
@@ -35,46 +43,61 @@ object Lossless {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cacheFile(context: Context): File? = steamCacheId(context)?.let { cacheFor(context, it) }
|
fun cacheFile(context: Context): File? = prefs(context).getString(KEY_ID, null)?.let { cacheFor(context, it) }
|
||||||
|
|
||||||
private fun steamCacheId(context: Context): String? = prefs(context).let {
|
|
||||||
if (it.getString(KEY_SOURCE, null) == SOURCE_STEAM) it.getString(KEY_ID, null) else null
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun sync(context: Context): Int {
|
fun sync(context: Context): Int {
|
||||||
val settings = prefs(context)
|
|
||||||
if (steamCacheId(context) == null && settings.contains(KEY_ID)) {
|
|
||||||
settings.edit().remove(KEY_ID).remove(KEY_SOURCE).remove(KEY_STEAM_STAMP).apply()
|
|
||||||
}
|
|
||||||
val steam = steamDll(context)
|
val steam = steamDll(context)
|
||||||
if (steam != null) {
|
if (steam != null) {
|
||||||
markOwned(context)
|
markOwned(context)
|
||||||
val stamp = "${steam.length()}:${steam.lastModified()}"
|
val stamp = "${steam.length()}:${steam.lastModified()}"
|
||||||
if (stamp != settings.getString(KEY_STEAM_STAMP, null)) {
|
if (stamp != prefs(context).getString(KEY_STEAM_STAMP, null)) {
|
||||||
val status = adoptSteamDll(context, steam)
|
val status = adopt(context, steam, Source.STEAM)
|
||||||
if (status != LsfgNative.STATUS_OK && status != UNCHANGED) {
|
if (status != LsfgNative.STATUS_OK && status != UNCHANGED) {
|
||||||
Log.w(TAG, "Steam copy $steam not taken: ${statusName(status)}")
|
Log.w(TAG, "Steam copy $steam not taken: ${statusName(status)}")
|
||||||
}
|
}
|
||||||
settings.edit().putString(KEY_STEAM_STAMP, stamp).apply()
|
prefs(context).edit().putString(KEY_STEAM_STAMP, stamp).apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ensureBuilt(context)
|
return ensureBuilt(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun import(context: Context, dll: File): ImportResult {
|
||||||
|
if (!owned(context)) return ImportResult.NOT_OWNED
|
||||||
|
return when (adopt(context, dll, Source.IMPORT)) {
|
||||||
|
UNCHANGED -> ImportResult.UNCHANGED
|
||||||
|
LsfgNative.STATUS_OK -> ImportResult.UPDATED
|
||||||
|
LsfgNative.STATUS_UNREADABLE_FILE, LsfgNative.STATUS_NOT_PORTABLE_EXECUTABLE,
|
||||||
|
LsfgNative.STATUS_MISSING_SHADERS -> ImportResult.INVALID
|
||||||
|
else -> ImportResult.FAILED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun message(context: Context, result: ImportResult): String = context.getString(
|
||||||
|
when (result) {
|
||||||
|
ImportResult.UPDATED -> R.string.lsfg_imported
|
||||||
|
ImportResult.UNCHANGED -> R.string.lsfg_import_unchanged
|
||||||
|
ImportResult.NOT_OWNED -> R.string.lsfg_import_not_owned
|
||||||
|
ImportResult.INVALID -> R.string.lsfg_import_invalid
|
||||||
|
ImportResult.FAILED -> R.string.lsfg_import_failed
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
private fun ensureBuilt(context: Context): Int {
|
private fun ensureBuilt(context: Context): Int {
|
||||||
val cache = cacheFile(context) ?: return LsfgNative.STATUS_NOT_INSTALLED
|
val id = prefs(context).getString(KEY_ID, null) ?: return LsfgNative.STATUS_NOT_INSTALLED
|
||||||
|
val cache = cacheFor(context, id)
|
||||||
if (usable(cache)) return LsfgNative.STATUS_OK
|
if (usable(cache)) return LsfgNative.STATUS_OK
|
||||||
val dll = storedDll(context)
|
val dll = storedDll(context)
|
||||||
if (!dll.isFile) return LsfgNative.STATUS_NOT_INSTALLED
|
if (!dll.isFile) return LsfgNative.STATUS_NOT_INSTALLED
|
||||||
return build(dll, cache)
|
return build(dll, cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun adoptSteamDll(context: Context, source: File): Int {
|
private fun adopt(context: Context, source: File, from: Source): Int {
|
||||||
val staged = File(dir(context).apply { mkdirs() }, "Lossless.dll.staged")
|
val staged = File(dir(context).apply { mkdirs() }, "Lossless.dll.staged")
|
||||||
try {
|
try {
|
||||||
val id = copyHashing(source, staged)
|
val id = copyHashing(source, staged)
|
||||||
if (id == steamCacheId(context) && usable(cacheFor(context, id))) return UNCHANGED
|
if (id == prefs(context).getString(KEY_ID, null) && usable(cacheFor(context, id))) return UNCHANGED
|
||||||
val cache = cacheFor(context, id)
|
val cache = cacheFor(context, id)
|
||||||
var status = LsfgNative.nativeValidateDll(staged.path)
|
var status = LsfgNative.nativeValidateDll(staged.path)
|
||||||
if (status == LsfgNative.STATUS_OK) status = build(staged, cache)
|
if (status == LsfgNative.STATUS_OK) status = build(staged, cache)
|
||||||
@@ -86,9 +109,9 @@ object Lossless {
|
|||||||
cache.delete()
|
cache.delete()
|
||||||
return LsfgNative.STATUS_CACHE_UNUSABLE
|
return LsfgNative.STATUS_CACHE_UNUSABLE
|
||||||
}
|
}
|
||||||
prefs(context).edit().putString(KEY_ID, id).putString(KEY_SOURCE, SOURCE_STEAM).apply()
|
prefs(context).edit().putString(KEY_ID, id).putString(KEY_SOURCE, from.name).apply()
|
||||||
removeStale(context, id)
|
removeStale(context, id)
|
||||||
Log.i(TAG, "Steam Lossless.dll from $source ready as $id")
|
Log.i(TAG, "Lossless.dll from $source ($from) ready as $id")
|
||||||
return LsfgNative.STATUS_OK
|
return LsfgNative.STATUS_OK
|
||||||
} catch (e: java.io.IOException) {
|
} catch (e: java.io.IOException) {
|
||||||
Log.w(TAG, "could not copy $source", e)
|
Log.w(TAG, "could not copy $source", e)
|
||||||
@@ -135,13 +158,9 @@ object Lossless {
|
|||||||
GameStorage.effective(context)?.path?.let(::File),
|
GameStorage.effective(context)?.path?.let(::File),
|
||||||
GameStorage.x64CardLibrary(context),
|
GameStorage.x64CardLibrary(context),
|
||||||
) + com.droiddeck.launcher.frontend.AddedGames.roots(context).map { it.host }
|
) + com.droiddeck.launcher.frontend.AddedGames.roots(context).map { it.host }
|
||||||
return installedSteamDll(libraries)
|
return libraries.map { File(it, STEAM_DLL) }.filter { it.isFile }.maxByOrNull { it.lastModified() }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun installedSteamDll(libraries: List<File>): File? =
|
|
||||||
libraries.asSequence().filter { File(it, STEAM_MANIFEST).isFile }
|
|
||||||
.map { File(it, STEAM_DLL) }.filter { it.isFile }.maxByOrNull { it.lastModified() }
|
|
||||||
|
|
||||||
private fun markOwned(context: Context) {
|
private fun markOwned(context: Context) {
|
||||||
if (!prefs(context).getBoolean(KEY_OWNED, false)) prefs(context).edit().putBoolean(KEY_OWNED, true).apply()
|
if (!prefs(context).getBoolean(KEY_OWNED, false)) prefs(context).edit().putBoolean(KEY_OWNED, true).apply()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ internal object DroidDeckHudConfig {
|
|||||||
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
"showPerCore" to "1", "showTemp" to "1", "showBatteryTemp" to "1", "showGpuTemp" to "0",
|
||||||
"showVram" to "1", "showRAM" to "1", "showSwap" to "1", "showBattery" to "0", "showBatteryTime" to "0", "showPower" to "1",
|
"showVram" to "1", "showRAM" to "1", "showSwap" to "1", "showBattery" to "0", "showBatteryTime" to "0", "showPower" to "1",
|
||||||
"showFPS" to "1", "showFPSGraph" to "1", "fpsDecimal" to "1",
|
"showFPS" to "1", "showFPSGraph" to "1", "fpsDecimal" to "1",
|
||||||
"showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "0", "showLow001" to "0",
|
"showLatency" to "1", "showAvg" to "1", "showLow1" to "1", "showLow01" to "1", "showLow001" to "1",
|
||||||
"showEngine" to "1", "showRenderer" to "1",
|
"showEngine" to "1", "showRenderer" to "1",
|
||||||
"showDisplay" to "1", "showHdr" to "1", "showNet" to "1", "showResolution" to "1",
|
"showDisplay" to "1", "showHdr" to "1", "showNet" to "1", "showResolution" to "1",
|
||||||
"showProton" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "",
|
"showProton" to "1", "showSession" to "1", "showClock" to "1", "hudOrder" to "",
|
||||||
|
|||||||
@@ -92,8 +92,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
private var showBatteryTemp = false
|
private var showBatteryTemp = false
|
||||||
private var showGraph = false
|
private var showGraph = false
|
||||||
private var showLow1 = true
|
private var showLow1 = true
|
||||||
private var showLow01 = false
|
private var showLow01 = true
|
||||||
private var showLow001 = false
|
private var showLow001 = true
|
||||||
private var fpsDecimal = true
|
private var fpsDecimal = true
|
||||||
private var showClockTime = true
|
private var showClockTime = true
|
||||||
private var showLatency = true
|
private var showLatency = true
|
||||||
@@ -187,12 +187,6 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
private var graphRect: RectF? = null
|
private var graphRect: RectF? = null
|
||||||
private var contentW = 0f
|
private var contentW = 0f
|
||||||
private var contentH = 0f
|
private var contentH = 0f
|
||||||
private var viewportW = Float.POSITIVE_INFINITY
|
|
||||||
private var viewportH = Float.POSITIVE_INFINITY
|
|
||||||
|
|
||||||
private val panelFit: Float
|
|
||||||
get() = if (dPanel == null || contentW <= 0f || contentH <= 0f) 1f
|
|
||||||
else minOf(1f, viewportW / contentW, viewportH / contentH)
|
|
||||||
|
|
||||||
private var onMovedListener: BiConsumer<Float, Float>? = null
|
private var onMovedListener: BiConsumer<Float, Float>? = null
|
||||||
private var onSizeCycledListener: Consumer<String>? = null
|
private var onSizeCycledListener: Consumer<String>? = null
|
||||||
@@ -999,20 +993,13 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
viewportW = viewportLimit(widthMeasureSpec)
|
|
||||||
viewportH = viewportLimit(heightMeasureSpec)
|
|
||||||
if (stripRect != null) { setMeasuredDimension(contentW.roundToInt(), resolveSize(contentH.roundToInt(), heightMeasureSpec)); return }
|
if (stripRect != null) { setMeasuredDimension(contentW.roundToInt(), resolveSize(contentH.roundToInt(), heightMeasureSpec)); return }
|
||||||
val fit = panelFit
|
|
||||||
setMeasuredDimension(
|
setMeasuredDimension(
|
||||||
resolveSize((contentW * fit).roundToInt(), widthMeasureSpec),
|
resolveSize(contentW.roundToInt(), widthMeasureSpec),
|
||||||
resolveSize((contentH * fit).roundToInt(), heightMeasureSpec),
|
resolveSize(contentH.roundToInt(), heightMeasureSpec),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun viewportLimit(spec: Int): Float =
|
|
||||||
if (MeasureSpec.getMode(spec) == MeasureSpec.UNSPECIFIED) Float.POSITIVE_INFINITY
|
|
||||||
else MeasureSpec.getSize(spec).toFloat()
|
|
||||||
|
|
||||||
override fun onDraw(canvas: Canvas) {
|
override fun onDraw(canvas: Canvas) {
|
||||||
if (contentW <= 0f || contentH <= 0f) { lockController.drawBadge(canvas); return }
|
if (contentW <= 0f || contentH <= 0f) { lockController.drawBadge(canvas); return }
|
||||||
val blend = if (dock == DroidDeckHudDock.NONE && previewEdge != DroidDeckHudDock.NONE) previewBlend else 0f
|
val blend = if (dock == DroidDeckHudDock.NONE && previewEdge != DroidDeckHudDock.NONE) previewBlend else 0f
|
||||||
@@ -1047,10 +1034,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun drawContent(canvas: Canvas) {
|
private fun drawContent(canvas: Canvas) {
|
||||||
val fit = panelFit
|
|
||||||
dPanel?.let { panel -> panelFrame(panel, fit)?.let { canvas.drawBitmap(it, 0f, 0f, null) } }
|
dPanel?.let { panel -> panelFrame(panel)?.let { canvas.drawBitmap(it, 0f, 0f, null) } }
|
||||||
val saved = canvas.save()
|
|
||||||
if (fit != 1f) canvas.scale(fit, fit)
|
|
||||||
|
|
||||||
if (tileRects.isNotEmpty()) {
|
if (tileRects.isNotEmpty()) {
|
||||||
tilePaint.color = Color.argb((14 * bgOpacity).roundToInt().coerceIn(8, 40), 255, 255, 255)
|
tilePaint.color = Color.argb((14 * bgOpacity).roundToInt().coerceIn(8, 40), 255, 255, 255)
|
||||||
@@ -1080,7 +1065,6 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
if (stripRect != null && layerType != LAYER_TYPE_SOFTWARE) drawCachedGraph(canvas, it) else drawGraph(canvas, it)
|
if (stripRect != null && layerType != LAYER_TYPE_SOFTWARE) drawCachedGraph(canvas, it) else drawGraph(canvas, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas.restoreToCount(saved)
|
|
||||||
lockController.drawBadge(canvas)
|
lockController.drawBadge(canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1193,14 +1177,13 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
return if (dy <= 0f) p.right - stroke else if (dy >= r) cx else cx + sqrt(r * r - dy * dy)
|
return if (dy <= 0f) p.right - stroke else if (dy >= r) cx else cx + sqrt(r * r - dy * dy)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun panelFrame(panel: RectF, fit: Float): Bitmap? {
|
private fun panelFrame(panel: RectF): Bitmap? {
|
||||||
if (width <= 0 || height <= 0) return null
|
if (width <= 0 || height <= 0) return null
|
||||||
val stroke = outlineWidth()
|
val stroke = outlineWidth()
|
||||||
val key = "$width,$height,$fit,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}"
|
val key = "$width,$height,$panel,$dRadius,$dDividerTop,$stroke,$accent,$surfaceRgb,$bgOpacity,${outlineColor()}"
|
||||||
if (key == dFrameKey) dFrame?.let { return it }
|
if (key == dFrameKey) dFrame?.let { return it }
|
||||||
val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
val c = Canvas(bmp)
|
val c = Canvas(bmp)
|
||||||
c.scale(fit, fit)
|
|
||||||
val corner = sp(6f)
|
val corner = sp(6f)
|
||||||
val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner)
|
val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner)
|
||||||
bgPaint.color = panelColor()
|
bgPaint.color = panelColor()
|
||||||
@@ -1273,8 +1256,8 @@ class DroidDeckHudView(context: Context) : View(context) {
|
|||||||
|
|
||||||
internal val isStrip: Boolean get() = stripRect != null
|
internal val isStrip: Boolean get() = stripRect != null
|
||||||
|
|
||||||
internal val contentWidth: Float get() = contentW * panelFit
|
internal val contentWidth: Float get() = contentW
|
||||||
internal val contentHeight: Float get() = contentH * panelFit
|
internal val contentHeight: Float get() = contentH
|
||||||
|
|
||||||
internal val isDragging: Boolean get() = lockController.isDragging() || tabDragging
|
internal val isDragging: Boolean get() = lockController.isDragging() || tabDragging
|
||||||
|
|
||||||
|
|||||||
@@ -46,14 +46,7 @@ internal class ControllerPortraitGeometry(
|
|||||||
}
|
}
|
||||||
row(shoulders, top + pad + buttonHeight / 2f, buttonHeight, 4f * unit)
|
row(shoulders, top + pad + buttonHeight / 2f, buttonHeight, 4f * unit)
|
||||||
var bodyTop = top + pad + buttonHeight + gap
|
var bodyTop = top + pad + buttonHeight + gap
|
||||||
if (presented.any { it.control in REAR && isStock(it) } && docked) {
|
if (presented.any { it.control in REAR && isStock(it) }) {
|
||||||
val chipHeight = 36f * unit
|
|
||||||
val cell = (w - 2f * pad - 5f * gap) / 6f
|
|
||||||
listOf(0, 1, 4, 5).zip(REAR).forEach { (index, control) ->
|
|
||||||
put(control, Box(safe.left + pad + cell / 2f + index * (cell + gap), bodyTop + chipHeight / 2f, cell, chipHeight))
|
|
||||||
}
|
|
||||||
bodyTop += chipHeight + gap
|
|
||||||
} else if (presented.any { it.control in REAR && isStock(it) }) {
|
|
||||||
val rearHeight = min(56f * unit, (panel - bodyTop + top) * .12f).coerceAtLeast(buttonHeight)
|
val rearHeight = min(56f * unit, (panel - bodyTop + top) * .12f).coerceAtLeast(buttonHeight)
|
||||||
row(REAR, bodyTop + rearHeight / 2f, rearHeight, gap)
|
row(REAR, bodyTop + rearHeight / 2f, rearHeight, gap)
|
||||||
bodyTop += rearHeight + gap
|
bodyTop += rearHeight + gap
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ object ControllerPrefs {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val opacities = listOf(40, 60, 80, 100)
|
val opacities = listOf(40, 60, 80, 100)
|
||||||
val onScreenOpacityRange = 10..100
|
|
||||||
|
|
||||||
val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
|
val sizes = listOf(80, 85, 90, 95, 100, 105, 110, 115, 120, 125)
|
||||||
|
|
||||||
@@ -46,7 +45,6 @@ object ControllerPrefs {
|
|||||||
val size: Int,
|
val size: Int,
|
||||||
val stickClick: Boolean,
|
val stickClick: Boolean,
|
||||||
val adaptiveSticks: Boolean,
|
val adaptiveSticks: Boolean,
|
||||||
val onScreenOpacity: Int,
|
|
||||||
val rumble: Boolean,
|
val rumble: Boolean,
|
||||||
val steamButton: Boolean,
|
val steamButton: Boolean,
|
||||||
val qamButton: Boolean,
|
val qamButton: Boolean,
|
||||||
@@ -68,8 +66,7 @@ object ControllerPrefs {
|
|||||||
opacity = p.getInt("opacity", 100).takeIf { it in opacities } ?: 100,
|
opacity = p.getInt("opacity", 100).takeIf { it in opacities } ?: 100,
|
||||||
size = p.getInt("size", 100).takeIf { it in sizes } ?: 100,
|
size = p.getInt("size", 100).takeIf { it in sizes } ?: 100,
|
||||||
stickClick = p.getBoolean("stickClick", true),
|
stickClick = p.getBoolean("stickClick", true),
|
||||||
adaptiveSticks = p.getBoolean("adaptiveSticks", false),
|
adaptiveSticks = p.getBoolean("adaptiveSticks", true),
|
||||||
onScreenOpacity = onScreenOpacity(context),
|
|
||||||
rumble = rumbleEnabled(context),
|
rumble = rumbleEnabled(context),
|
||||||
steamButton = p.getBoolean("steamButton", true),
|
steamButton = p.getBoolean("steamButton", true),
|
||||||
qamButton = p.getBoolean("qamButton", true),
|
qamButton = p.getBoolean("qamButton", true),
|
||||||
@@ -106,13 +103,6 @@ object ControllerPrefs {
|
|||||||
prefs(context).edit().putBoolean("stickClick", on).apply()
|
prefs(context).edit().putBoolean("stickClick", on).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onScreenOpacity(context: Context): Int =
|
|
||||||
prefs(context).getInt("onScreenOpacity", 100).coerceIn(onScreenOpacityRange)
|
|
||||||
|
|
||||||
fun setOnScreenOpacity(context: Context, percent: Int) {
|
|
||||||
prefs(context).edit().putInt("onScreenOpacity", percent.coerceIn(onScreenOpacityRange)).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setAdaptiveSticks(context: Context, on: Boolean) {
|
fun setAdaptiveSticks(context: Context, on: Boolean) {
|
||||||
prefs(context).edit().putBoolean("adaptiveSticks", on).apply()
|
prefs(context).edit().putBoolean("adaptiveSticks", on).apply()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,24 +2,14 @@ package com.droiddeck.launcher.input
|
|||||||
|
|
||||||
class HeldInput(private val emit: (Int, Boolean) -> Unit) {
|
class HeldInput(private val emit: (Int, Boolean) -> Unit) {
|
||||||
private val owners = IntArray(768)
|
private val owners = IntArray(768)
|
||||||
private val ordered = arrayOfNulls<(Int, Boolean) -> Unit>(768)
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun set(source: Int, code: Int, down: Boolean, orderedEmit: ((Int, Boolean) -> Unit)? = null) {
|
fun set(source: Int, code: Int, down: Boolean) {
|
||||||
if (code !in owners.indices) return
|
if (code !in owners.indices) return
|
||||||
val before = owners[code]
|
val before = owners[code]
|
||||||
val after = if (down) before or source else before and source.inv()
|
val after = if (down) before or source else before and source.inv()
|
||||||
owners[code] = after
|
owners[code] = after
|
||||||
if ((before == 0) != (after == 0)) {
|
if ((before == 0) != (after == 0)) emit(code, after != 0)
|
||||||
if (after != 0) {
|
|
||||||
ordered[code] = orderedEmit
|
|
||||||
orderedEmit?.invoke(code, true) ?: emit(code, true)
|
|
||||||
} else {
|
|
||||||
val fn = ordered[code]
|
|
||||||
ordered[code] = null
|
|
||||||
fn?.invoke(code, false) ?: emit(code, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
@@ -31,9 +21,7 @@ class HeldInput(private val emit: (Int, Boolean) -> Unit) {
|
|||||||
fun clear() {
|
fun clear() {
|
||||||
for (code in owners.indices) if (owners[code] != 0) {
|
for (code in owners.indices) if (owners[code] != 0) {
|
||||||
owners[code] = 0
|
owners[code] = 0
|
||||||
val fn = ordered[code]
|
emit(code, false)
|
||||||
ordered[code] = null
|
|
||||||
fn?.invoke(code, false) ?: emit(code, false)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import android.app.Activity
|
|||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.text.InputType
|
import android.text.InputType
|
||||||
|
import android.view.KeyCharacterMap
|
||||||
import android.view.KeyEvent
|
import android.view.KeyEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.WindowInsets
|
import android.view.WindowInsets
|
||||||
@@ -11,17 +12,15 @@ import android.view.inputmethod.BaseInputConnection
|
|||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
import android.view.inputmethod.InputConnection
|
import android.view.inputmethod.InputConnection
|
||||||
import android.view.inputmethod.InputMethodManager
|
import android.view.inputmethod.InputMethodManager
|
||||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
|
||||||
|
|
||||||
class KeyboardHost(
|
class KeyboardHost(
|
||||||
context: Context,
|
context: Context,
|
||||||
private val sendKeyEvent: (KeyEvent) -> Boolean,
|
private val sendKeyEvent: (KeyEvent) -> Boolean,
|
||||||
private val sendText: (String) -> Unit,
|
|
||||||
) : View(context) {
|
) : View(context) {
|
||||||
constructor(activity: Activity) :
|
constructor(activity: Activity) : this(activity, { activity.dispatchKeyEvent(it) })
|
||||||
this(activity, { activity.dispatchKeyEvent(it) }, { WaylandCompositor.textInputCommit(it) })
|
|
||||||
|
|
||||||
private val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
private val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||||
|
private val map: KeyCharacterMap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD)
|
||||||
var shown = false
|
var shown = false
|
||||||
private set
|
private set
|
||||||
var imeShowing = false
|
var imeShowing = false
|
||||||
@@ -41,7 +40,8 @@ class KeyboardHost(
|
|||||||
|
|
||||||
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
|
override fun onCreateInputConnection(outAttrs: EditorInfo): InputConnection? {
|
||||||
if (!shown) return null
|
if (!shown) return null
|
||||||
outAttrs.inputType = InputType.TYPE_CLASS_TEXT
|
outAttrs.inputType = InputType.TYPE_CLASS_TEXT or InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS or
|
||||||
|
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD
|
||||||
outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE or EditorInfo.IME_FLAG_NO_FULLSCREEN or
|
outAttrs.imeOptions = EditorInfo.IME_ACTION_NONE or EditorInfo.IME_FLAG_NO_FULLSCREEN or
|
||||||
EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
EditorInfo.IME_FLAG_NO_EXTRACT_UI
|
||||||
return KeyConnection()
|
return KeyConnection()
|
||||||
@@ -93,153 +93,45 @@ class KeyboardHost(
|
|||||||
|
|
||||||
fun type(text: CharSequence?) {
|
fun type(text: CharSequence?) {
|
||||||
if (text.isNullOrEmpty()) return
|
if (text.isNullOrEmpty()) return
|
||||||
// Text and soft editing actions share this queue to preserve IME ordering.
|
val events = map.getEvents(text.toString().toCharArray())
|
||||||
sendText(text.toString())
|
if (events != null) {
|
||||||
|
for (event in events) sendKeyEvent(event)
|
||||||
|
} else {
|
||||||
|
for (ch in text) {
|
||||||
|
val t = System.currentTimeMillis()
|
||||||
|
val down = KeyEvent(t, t, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_UNKNOWN, 0, 0,
|
||||||
|
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, 0, 0)
|
||||||
|
sendKeyEvent(CharKeyEvent(down, ch))
|
||||||
|
sendKeyEvent(CharKeyEvent(KeyEvent.changeAction(down, KeyEvent.ACTION_UP), ch))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tap(keyCode: Int) {
|
fun tap(keyCode: Int) {
|
||||||
val control = softControl(keyCode)
|
|
||||||
if (control != null) {
|
|
||||||
sendText(control.toString())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val t = System.currentTimeMillis()
|
val t = System.currentTimeMillis()
|
||||||
sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_DOWN, keyCode, 0))
|
sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_DOWN, keyCode, 0))
|
||||||
sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_UP, keyCode, 0))
|
sendKeyEvent(KeyEvent(t, t, KeyEvent.ACTION_UP, keyCode, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
private inner class KeyConnection : BaseInputConnection(this, false) {
|
private inner class KeyConnection : BaseInputConnection(this, false) {
|
||||||
// A press keeps the route chosen on its first down across repeats and the matching up.
|
|
||||||
private val controlRoutes = HashMap<Int, Boolean>()
|
|
||||||
|
|
||||||
private var composingText = ""
|
|
||||||
private var composingCursor = 0
|
|
||||||
|
|
||||||
override fun commitText(text: CharSequence?, newCursorPosition: Int): Boolean {
|
override fun commitText(text: CharSequence?, newCursorPosition: Int): Boolean {
|
||||||
composingText = ""
|
|
||||||
composingCursor = 0
|
|
||||||
type(text)
|
type(text)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun setComposingText(text: CharSequence?, newCursorPosition: Int): Boolean {
|
override fun setComposingText(text: CharSequence?, newCursorPosition: Int): Boolean = true
|
||||||
composingText = text?.toString().orEmpty()
|
override fun finishComposingText(): Boolean = true
|
||||||
val rawCursor = if (newCursorPosition > 0) {
|
|
||||||
composingText.length.toLong() + newCursorPosition - 1L
|
|
||||||
} else {
|
|
||||||
newCursorPosition.toLong()
|
|
||||||
}
|
|
||||||
composingCursor = rawCursor.coerceIn(0L, composingText.length.toLong()).toInt()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun finishComposingText(): Boolean {
|
|
||||||
val text = composingText
|
|
||||||
composingText = ""
|
|
||||||
composingCursor = 0
|
|
||||||
type(text)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean {
|
override fun deleteSurroundingText(beforeLength: Int, afterLength: Int): Boolean {
|
||||||
val before = beforeLength.coerceAtLeast(0)
|
repeat(beforeLength) { tap(KeyEvent.KEYCODE_DEL) }
|
||||||
val after = afterLength.coerceAtLeast(0)
|
repeat(afterLength) { tap(KeyEvent.KEYCODE_FORWARD_DEL) }
|
||||||
if (before == 0 && after == 0) return true
|
|
||||||
val consumedBefore = minOf(before, composingCursor)
|
|
||||||
val consumedAfter = minOf(after, composingText.length - composingCursor)
|
|
||||||
val guestBefore = before - consumedBefore
|
|
||||||
val guestAfter = after - consumedAfter
|
|
||||||
if (guestBefore > 1 || guestAfter > 1) return false
|
|
||||||
return applyDeletion(
|
|
||||||
composingCursor - consumedBefore,
|
|
||||||
composingCursor + consumedAfter,
|
|
||||||
guestBefore,
|
|
||||||
guestAfter,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun deleteSurroundingTextInCodePoints(beforeLength: Int, afterLength: Int): Boolean {
|
|
||||||
val before = beforeLength.coerceAtLeast(0)
|
|
||||||
val after = afterLength.coerceAtLeast(0)
|
|
||||||
if (before == 0 && after == 0) return true
|
|
||||||
if (splitsPair(composingCursor)) return false
|
|
||||||
val text = composingText
|
|
||||||
val beforePoints = Character.codePointCount(text, 0, composingCursor)
|
|
||||||
val afterPoints = Character.codePointCount(text, composingCursor, text.length)
|
|
||||||
val consumedBefore = minOf(before, beforePoints)
|
|
||||||
val consumedAfter = minOf(after, afterPoints)
|
|
||||||
val start = Character.offsetByCodePoints(text, composingCursor, -consumedBefore)
|
|
||||||
val end = Character.offsetByCodePoints(text, composingCursor, consumedAfter)
|
|
||||||
if (hasUnpairedSurrogate(text, start, end)) return false
|
|
||||||
return applyDeletion(
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
before - consumedBefore,
|
|
||||||
after - consumedAfter,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun applyDeletion(start: Int, end: Int, guestBefore: Int, guestAfter: Int): Boolean {
|
|
||||||
if (guestBefore > 64 || guestAfter > 64) return false
|
|
||||||
if (splitsPair(start) || splitsPair(end)) return false
|
|
||||||
if (start < end) {
|
|
||||||
composingText = composingText.removeRange(start, end)
|
|
||||||
composingCursor = start
|
|
||||||
}
|
|
||||||
val controls = StringBuilder()
|
|
||||||
repeat(guestBefore) { controls.append(BACKSPACE) }
|
|
||||||
repeat(guestAfter) { controls.append(FORWARD_DELETE) }
|
|
||||||
if (controls.isNotEmpty()) sendText(controls.toString())
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun splitsPair(index: Int): Boolean =
|
override fun sendKeyEvent(event: KeyEvent): Boolean = this@KeyboardHost.sendKeyEvent(event)
|
||||||
index > 0 && index < composingText.length &&
|
|
||||||
composingText[index - 1].isHighSurrogate() && composingText[index].isLowSurrogate()
|
|
||||||
|
|
||||||
private fun hasUnpairedSurrogate(text: CharSequence, start: Int, end: Int): Boolean {
|
|
||||||
var i = start
|
|
||||||
while (i < end) {
|
|
||||||
val c = text[i]
|
|
||||||
if (c.isHighSurrogate()) {
|
|
||||||
if (i + 1 >= end || !text[i + 1].isLowSurrogate()) return true
|
|
||||||
i += 2
|
|
||||||
} else if (c.isLowSurrogate()) {
|
|
||||||
return true
|
|
||||||
} else {
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun sendKeyEvent(event: KeyEvent): Boolean {
|
|
||||||
val control = softControl(event.keyCode)
|
|
||||||
if (control == null) return this@KeyboardHost.sendKeyEvent(event)
|
|
||||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
|
||||||
val soft = if (event.repeatCount == 0) {
|
|
||||||
val route = !event.isModified()
|
|
||||||
controlRoutes[event.keyCode] = route
|
|
||||||
route
|
|
||||||
} else {
|
|
||||||
controlRoutes[event.keyCode] ?: !event.isModified()
|
|
||||||
}
|
|
||||||
if (!soft) return this@KeyboardHost.sendKeyEvent(event)
|
|
||||||
if (control == ENTER) finishComposingText()
|
|
||||||
sendText(control.toString())
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
if (event.action == KeyEvent.ACTION_UP) {
|
|
||||||
val soft = controlRoutes.remove(event.keyCode) ?: !event.isModified()
|
|
||||||
if (soft) return true
|
|
||||||
return this@KeyboardHost.sendKeyEvent(event)
|
|
||||||
}
|
|
||||||
return this@KeyboardHost.sendKeyEvent(event)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun performEditorAction(actionCode: Int): Boolean {
|
override fun performEditorAction(actionCode: Int): Boolean {
|
||||||
finishComposingText()
|
tap(KeyEvent.KEYCODE_ENTER)
|
||||||
sendText(ENTER.toString())
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,22 +140,8 @@ class KeyboardHost(
|
|||||||
override fun getSelectedText(flags: Int): CharSequence? = null
|
override fun getSelectedText(flags: Int): CharSequence? = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun softControl(keyCode: Int): Char? = when (keyCode) {
|
private class CharKeyEvent(origin: KeyEvent, private val ch: Char) : KeyEvent(origin) {
|
||||||
KeyEvent.KEYCODE_DEL -> BACKSPACE
|
override fun getUnicodeChar(): Int = ch.code
|
||||||
KeyEvent.KEYCODE_FORWARD_DEL -> FORWARD_DELETE
|
override fun getUnicodeChar(metaState: Int): Int = ch.code
|
||||||
KeyEvent.KEYCODE_ENTER -> ENTER
|
|
||||||
KeyEvent.KEYCODE_TAB -> TAB
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun KeyEvent.isModified(): Boolean =
|
|
||||||
isCtrlPressed || isShiftPressed || isAltPressed || isMetaPressed
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
// Control characters represent editing keys on the guest text channel.
|
|
||||||
const val ENTER = '\r'
|
|
||||||
const val BACKSPACE = '\b'
|
|
||||||
const val FORWARD_DELETE = '\u007f'
|
|
||||||
const val TAB = '\t'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,13 +36,6 @@ object OnScreenLayout {
|
|||||||
fun elements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
fun elements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
||||||
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
|
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
|
||||||
trackpads: Boolean? = null): List<InputSurfaceElement> {
|
trackpads: Boolean? = null): List<InputSurfaceElement> {
|
||||||
val placed = placeElements(context, saved, width, height, safe, buttonsOnly, dock, rearButtons, trackpads)
|
|
||||||
// Below the game a stick covers nothing, so it keeps its base in view instead of appearing only under the thumb.
|
|
||||||
return if (dock == null) placed else placed.map { if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false) else it }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun placeElements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
|
|
||||||
buttonsOnly: Boolean, dock: Dock?, rearButtons: Boolean?, trackpads: Boolean?): List<InputSurfaceElement> {
|
|
||||||
if (saved == null) return emptyList()
|
if (saved == null) return emptyList()
|
||||||
if (width <= 0 || height <= 0) return saved.elements
|
if (width <= 0 || height <= 0) return saved.elements
|
||||||
val layout = oriented(saved, dock?.portrait ?: (height > width))
|
val layout = oriented(saved, dock?.portrait ?: (height > width))
|
||||||
|
|||||||
@@ -1,324 +0,0 @@
|
|||||||
package com.droiddeck.launcher.input
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.content.SharedPreferences
|
|
||||||
import android.net.Uri
|
|
||||||
import android.os.Build
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.IBinder
|
|
||||||
import android.os.Looper
|
|
||||||
import android.os.Parcel
|
|
||||||
import android.provider.Settings
|
|
||||||
import android.util.Log
|
|
||||||
import android.view.InputDevice
|
|
||||||
import android.view.KeyEvent
|
|
||||||
import java.util.EnumMap
|
|
||||||
import java.util.EnumSet
|
|
||||||
import java.util.concurrent.Executor
|
|
||||||
import java.util.concurrent.LinkedBlockingQueue
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
import org.json.JSONObject
|
|
||||||
|
|
||||||
enum class AirTrigger(val keyCode: Int, val control: InputControl, val pressLight: Int, val releaseLight: Int) {
|
|
||||||
LEFT(KeyEvent.KEYCODE_F7, InputControl.LT, 106, 107), RIGHT(KeyEvent.KEYCODE_F8, InputControl.RT, 108, 109);
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private const val DEVICE_PREFIX = "nubia_tgk"
|
|
||||||
|
|
||||||
internal fun isTriggerDevice(device: InputDevice?): Boolean {
|
|
||||||
if (device == null) return false
|
|
||||||
if (device.name.startsWith(DEVICE_PREFIX)) return true
|
|
||||||
// Some RedMagic firmware merges the trigger sensors with an unnamed built-in keyboard.
|
|
||||||
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q &&
|
|
||||||
device.name.isEmpty() && !device.isVirtual && !device.isExternal &&
|
|
||||||
device.supportsSource(InputDevice.SOURCE_KEYBOARD) &&
|
|
||||||
device.hasKeys(LEFT.keyCode, RIGHT.keyCode).all { it }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun of(keyCode: Int, device: InputDevice?): AirTrigger? =
|
|
||||||
entries.firstOrNull { it.keyCode == keyCode }?.takeIf { isTriggerDevice(device) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Game Space's single tap holds the button while the trigger is touched; its long press latches it until the next touch. */
|
|
||||||
enum class AirTriggerAction { TAP, LATCH, RAPID }
|
|
||||||
|
|
||||||
/** Game Space's rapid fire counts for its low, normal and high click frequency. */
|
|
||||||
enum class RapidFireRate(val clicksPerSecond: Int) { LOW(2), NORMAL(5), HIGH(10) }
|
|
||||||
|
|
||||||
/** Game Space's touch atmosphere lamp cases, by their name in RedMagic's shoulder light settings. */
|
|
||||||
enum class AirTriggerLed(val effect: String, val fallback: String) {
|
|
||||||
OFF("close", "02000000"), STEADY("steady", "02101000"), PULSE("pulse", "02102000")
|
|
||||||
}
|
|
||||||
|
|
||||||
data class AirTriggerSetup(
|
|
||||||
val element: InputSurfaceElement,
|
|
||||||
val action: AirTriggerAction = AirTriggerAction.TAP,
|
|
||||||
val rate: RapidFireRate = RapidFireRate.NORMAL,
|
|
||||||
) {
|
|
||||||
/** Long press and rapid fire decide when the button is let go, so they press a toggle button as a plain one. */
|
|
||||||
internal val target get() = if (action != AirTriggerAction.TAP && element.toggle) element.copy(toggle = false) else element
|
|
||||||
}
|
|
||||||
|
|
||||||
object AirTriggerButtons {
|
|
||||||
fun options(layout: SavedInputLayout?): List<InputSurfaceElement> {
|
|
||||||
val placed = layout?.let { (it.elements + it.rotated).distinctBy { element -> element.id } }.orEmpty()
|
|
||||||
.filter { it.kind == InputElementKind.BUTTON || it.kind == InputElementKind.TRIGGER }
|
|
||||||
return placed + AirTrigger.entries.filter { trigger -> placed.none { it.control == trigger.control } }
|
|
||||||
.map { InputSurfaceElement(it.control, 0f, 0f, 0f, 0f) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun resolve(layout: SavedInputLayout?, trigger: AirTrigger, chosen: String?): InputSurfaceElement {
|
|
||||||
val options = options(layout)
|
|
||||||
return chosen?.let { id -> options.firstOrNull { it.id == id } } ?: options.first { it.control == trigger.control }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
object AirTriggerPrefs {
|
|
||||||
private const val FILE = "redmagic-air-triggers"
|
|
||||||
private const val ENABLED = "enabled"
|
|
||||||
private const val VIBRATION = "vibration"
|
|
||||||
private const val SCREEN_LIGHT = "screen-light"
|
|
||||||
private const val LED = "led"
|
|
||||||
internal const val OWNED = "distribute-owned"
|
|
||||||
|
|
||||||
fun prefs(context: Context): SharedPreferences = context.getSharedPreferences(FILE, Context.MODE_PRIVATE)
|
|
||||||
fun enabled(context: Context) = prefs(context).getBoolean(ENABLED, false)
|
|
||||||
fun setEnabled(context: Context, on: Boolean) = prefs(context).edit().putBoolean(ENABLED, on).apply()
|
|
||||||
fun button(context: Context, layoutId: String, trigger: AirTrigger): String? = prefs(context).getString(key(layoutId, trigger), null)
|
|
||||||
fun setButton(context: Context, layoutId: String, trigger: AirTrigger, elementId: String) =
|
|
||||||
prefs(context).edit().putString(key(layoutId, trigger), elementId).apply()
|
|
||||||
fun action(context: Context, layoutId: String, trigger: AirTrigger) = read(context, key(layoutId, trigger, "action"), AirTriggerAction.TAP)
|
|
||||||
fun setAction(context: Context, layoutId: String, trigger: AirTrigger, action: AirTriggerAction) =
|
|
||||||
prefs(context).edit().putString(key(layoutId, trigger, "action"), action.name).apply()
|
|
||||||
fun rate(context: Context, layoutId: String, trigger: AirTrigger) = read(context, key(layoutId, trigger, "rate"), RapidFireRate.NORMAL)
|
|
||||||
fun setRate(context: Context, layoutId: String, trigger: AirTrigger, rate: RapidFireRate) =
|
|
||||||
prefs(context).edit().putString(key(layoutId, trigger, "rate"), rate.name).apply()
|
|
||||||
fun vibration(context: Context) = prefs(context).getBoolean(VIBRATION, false)
|
|
||||||
fun setVibration(context: Context, on: Boolean) = prefs(context).edit().putBoolean(VIBRATION, on).apply()
|
|
||||||
fun screenLight(context: Context) = prefs(context).getBoolean(SCREEN_LIGHT, false)
|
|
||||||
fun setScreenLight(context: Context, on: Boolean) = prefs(context).edit().putBoolean(SCREEN_LIGHT, on).apply()
|
|
||||||
fun led(context: Context) = read(context, LED, AirTriggerLed.STEADY)
|
|
||||||
fun setLed(context: Context, led: AirTriggerLed) = prefs(context).edit().putString(LED, led.name).apply()
|
|
||||||
|
|
||||||
private inline fun <reified E : Enum<E>> read(context: Context, key: String, default: E): E =
|
|
||||||
prefs(context).getString(key, null)?.let { name -> enumValues<E>().firstOrNull { it.name == name } } ?: default
|
|
||||||
|
|
||||||
private fun key(layoutId: String, trigger: AirTrigger, setting: String? = null) =
|
|
||||||
listOfNotNull(trigger.name.lowercase(), setting).joinToString("-") + ".$layoutId"
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Game Space's exported provider switches the triggers to plain F7/F8 keys without its panel, and needs no permission. */
|
|
||||||
object RedMagicAirTriggers {
|
|
||||||
private const val TAG = "AirTriggers"
|
|
||||||
private const val AUTHORITY = "cn.nubia.tgk.data.TgkDataProvider"
|
|
||||||
private val URI = Uri.parse("content://$AUTHORITY")
|
|
||||||
private const val OPEN = "openTouchGameKeyDistribute"
|
|
||||||
private const val CLOSE = "closeTouchGameKeyDistribute"
|
|
||||||
private const val SHOULDER_LIGHT_ON = 110
|
|
||||||
private const val SHOULDER_LIGHT_OFF = 111
|
|
||||||
private const val SHOULDER_SETTINGS = "lighting_shoulder_config_json"
|
|
||||||
private val REAPPLY_MS = longArrayOf(1_000, 5_000)
|
|
||||||
internal var worker: Executor = ThreadPoolExecutor(0, 1, 10, TimeUnit.SECONDS, LinkedBlockingQueue()) { Thread(it, "air-triggers") }
|
|
||||||
internal var lights: TriggerLights = ColorfulLights
|
|
||||||
private val main = Handler(Looper.getMainLooper())
|
|
||||||
private var reapply: Runnable? = null
|
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
fun supported(context: Context) = context.packageManager.resolveContentProvider(AUTHORITY, 0) != null &&
|
|
||||||
InputDevice.getDeviceIds().any { AirTrigger.isTriggerDevice(InputDevice.getDevice(it)) }
|
|
||||||
|
|
||||||
/** Call on the main thread. */
|
|
||||||
fun open(context: Context) {
|
|
||||||
val app = context.applicationContext
|
|
||||||
cancelReapply()
|
|
||||||
worker.execute { apply(app) }
|
|
||||||
// Game Space runs its own trigger setup for the app that comes to the front, which switches the trigger keys and lights off again.
|
|
||||||
val again = Runnable { worker.execute { apply(app) } }
|
|
||||||
reapply = again
|
|
||||||
REAPPLY_MS.forEach { main.postDelayed(again, it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun apply(app: Context) {
|
|
||||||
val prefs = AirTriggerPrefs.prefs(app)
|
|
||||||
if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false) && Settings.Global.getInt(app.contentResolver, OPEN, 0) != 1)
|
|
||||||
prefs.edit().putBoolean(AirTriggerPrefs.OWNED, true).commit()
|
|
||||||
call(app, OPEN)
|
|
||||||
if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false)) return
|
|
||||||
lights.request(SHOULDER_LIGHT_ON)
|
|
||||||
// The light service drops every trigger light until an effect is set, which Game Space only does from its own view.
|
|
||||||
lights.setEffect(shoulderEffect(Settings.Global.getString(app.contentResolver, SHOULDER_SETTINGS), AirTriggerPrefs.led(app)))
|
|
||||||
// Entering the scene turns the lights off; the release actions show the idle light picked in RedMagic's lighting settings.
|
|
||||||
AirTrigger.entries.forEach { lights.request(it.releaseLight) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The code RedMagic's shoulder light settings give the effect, such as "02101000" for steady. */
|
|
||||||
internal fun shoulderEffect(settings: String?, led: AirTriggerLed): String = settings
|
|
||||||
?.let { runCatching { JSONObject(it).optJSONObject("shoulder_effects")?.optString(led.effect) }.getOrNull() }
|
|
||||||
?.takeIf { it.length == 8 } ?: led.fallback
|
|
||||||
|
|
||||||
/** Closes only what this app opened, so a distribute another app turned on stays on. Call on the main thread. */
|
|
||||||
fun restore(context: Context) {
|
|
||||||
val app = context.applicationContext
|
|
||||||
cancelReapply()
|
|
||||||
worker.execute {
|
|
||||||
val prefs = AirTriggerPrefs.prefs(app)
|
|
||||||
if (!prefs.getBoolean(AirTriggerPrefs.OWNED, false)) return@execute
|
|
||||||
lights.request(SHOULDER_LIGHT_OFF)
|
|
||||||
if (call(app, CLOSE)) prefs.edit().remove(AirTriggerPrefs.OWNED).commit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun light(code: Int) = worker.execute { lights.request(code) }
|
|
||||||
|
|
||||||
private fun cancelReapply() {
|
|
||||||
reapply?.let(main::removeCallbacks)
|
|
||||||
reapply = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun call(context: Context, method: String) = runCatching { context.contentResolver.call(URI, method, null, null) != null }
|
|
||||||
.onFailure { Log.w(TAG, "$method failed", it) }.getOrDefault(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal interface TriggerLights {
|
|
||||||
fun request(action: Int)
|
|
||||||
fun setEffect(effect: String)
|
|
||||||
}
|
|
||||||
|
|
||||||
private object ColorfulLights : TriggerLights {
|
|
||||||
private const val TAG = "AirTriggers"
|
|
||||||
private const val SERVICE = "ColorfulLightService"
|
|
||||||
private const val INTERFACE = "com.zte.hardware.IColorfulLightManager"
|
|
||||||
// IColorfulLightManager transaction codes; its ColorfulLightManager wrapper is a blocked hidden API.
|
|
||||||
private const val REQUEST_LIGHT = IBinder.FIRST_CALL_TRANSACTION
|
|
||||||
private const val SET_SHOULDER_EFFECT = IBinder.FIRST_CALL_TRANSACTION + 2
|
|
||||||
private val binder: IBinder? by lazy {
|
|
||||||
runCatching { Class.forName("android.os.ServiceManager").getMethod("getService", String::class.java).invoke(null, SERVICE) as IBinder? }
|
|
||||||
.getOrNull()?.takeIf { runCatching { it.interfaceDescriptor }.getOrNull() == INTERFACE }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun request(action: Int) = transact(REQUEST_LIGHT) { writeInt(action) }
|
|
||||||
override fun setEffect(effect: String) = transact(SET_SHOULDER_EFFECT) { writeString(effect) }
|
|
||||||
|
|
||||||
private fun transact(code: Int, write: Parcel.() -> Unit) {
|
|
||||||
val binder = binder ?: return
|
|
||||||
val data = Parcel.obtain()
|
|
||||||
val reply = Parcel.obtain()
|
|
||||||
try {
|
|
||||||
data.writeInterfaceToken(INTERFACE)
|
|
||||||
data.write()
|
|
||||||
binder.transact(code, data, reply, 0)
|
|
||||||
reply.readException()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.w(TAG, "light call $code failed", e)
|
|
||||||
} finally {
|
|
||||||
data.recycle()
|
|
||||||
reply.recycle()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Presses the chosen button on screen when it is shown, so it animates and keeps one toggle state; otherwise uses a source of its own. */
|
|
||||||
class AirTriggerInput(
|
|
||||||
private val pad: PadBridge,
|
|
||||||
private val onScreen: (elementId: String, trigger: AirTrigger, held: Boolean, cancelled: Boolean) -> Boolean = { _, _, _, _ -> false },
|
|
||||||
private val touched: (AirTrigger, Boolean) -> Unit = { _, _ -> },
|
|
||||||
private val handler: Handler = Handler(Looper.getMainLooper()),
|
|
||||||
) {
|
|
||||||
private val sources = EnumMap<AirTrigger, InputSurfaceSource>(AirTrigger::class.java)
|
|
||||||
private val setups = EnumMap<AirTrigger, AirTriggerSetup>(AirTrigger::class.java)
|
|
||||||
private val held = EnumSet.noneOf(AirTrigger::class.java)
|
|
||||||
private val pressed = EnumSet.noneOf(AirTrigger::class.java)
|
|
||||||
private val heldOnScreen = EnumMap<AirTrigger, String>(AirTrigger::class.java)
|
|
||||||
private val timers = EnumMap<AirTrigger, Runnable>(AirTrigger::class.java)
|
|
||||||
|
|
||||||
fun configure(setups: Map<AirTrigger, AirTriggerSetup>) {
|
|
||||||
for (trigger in AirTrigger.entries) {
|
|
||||||
val setup = setups[trigger]
|
|
||||||
if (this.setups[trigger] == setup) continue
|
|
||||||
stop(trigger)
|
|
||||||
if (sources[trigger]?.element != setup?.target) {
|
|
||||||
pressed.remove(trigger)
|
|
||||||
heldOnScreen.remove(trigger)?.let { onScreen(it, trigger, false, true) }
|
|
||||||
sources.remove(trigger)?.close()
|
|
||||||
if (setup != null) sources[trigger] = InputSurfaceSource(pad, InputRole.PRIMARY, setup.target)
|
|
||||||
} else if (trigger in pressed) unpress(trigger, cancelled = true)
|
|
||||||
if (setup != null) this.setups[trigger] = setup else this.setups.remove(trigger)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onKey(event: KeyEvent, enabled: () -> Boolean): Boolean {
|
|
||||||
if (event.keyCode != AirTrigger.LEFT.keyCode && event.keyCode != AirTrigger.RIGHT.keyCode) return false
|
|
||||||
val trigger = AirTrigger.of(event.keyCode, event.device) ?: return false
|
|
||||||
return onKey(trigger, event.action, event.repeatCount, event.action == KeyEvent.ACTION_DOWN && enabled())
|
|
||||||
}
|
|
||||||
|
|
||||||
fun onKey(trigger: AirTrigger, action: Int, repeatCount: Int, enabled: Boolean): Boolean {
|
|
||||||
val source = sources[trigger]
|
|
||||||
when (action) {
|
|
||||||
KeyEvent.ACTION_DOWN -> if (source != null && enabled && repeatCount == 0 && held.add(trigger)) {
|
|
||||||
touched(trigger, true)
|
|
||||||
val setup = setups[trigger]
|
|
||||||
if (setup?.action == AirTriggerAction.LATCH && trigger in pressed) unpress(trigger, cancelled = false)
|
|
||||||
else if (trigger !in pressed) {
|
|
||||||
press(trigger, source)
|
|
||||||
if (setup?.action == AirTriggerAction.RAPID) rapid(trigger, 500L / setup.rate.clicksPerSecond)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
KeyEvent.ACTION_UP -> if (held.remove(trigger)) {
|
|
||||||
touched(trigger, false)
|
|
||||||
if (setups[trigger]?.action != AirTriggerAction.LATCH) {
|
|
||||||
stop(trigger)
|
|
||||||
if (trigger in pressed) unpress(trigger, cancelled = false)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return source != null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun rapid(trigger: AirTrigger, halfPeriod: Long) {
|
|
||||||
val tick = object : Runnable {
|
|
||||||
override fun run() {
|
|
||||||
if (trigger in pressed) unpress(trigger, cancelled = false) else sources[trigger]?.let { press(trigger, it) }
|
|
||||||
handler.postDelayed(this, halfPeriod)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
timers[trigger] = tick
|
|
||||||
handler.postDelayed(tick, halfPeriod)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stop(trigger: AirTrigger) {
|
|
||||||
timers.remove(trigger)?.let(handler::removeCallbacks)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun press(trigger: AirTrigger, source: InputSurfaceSource) {
|
|
||||||
pressed += trigger
|
|
||||||
if (source.element == setups[trigger]?.element && onScreen(source.element.id, trigger, true, false)) {
|
|
||||||
heldOnScreen[trigger] = source.element.id
|
|
||||||
// The router counts held keys, so a toggle latched while its button was hidden is released before the button takes over.
|
|
||||||
if (source.latched) source.release()
|
|
||||||
} else source.update(1f)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun unpress(trigger: AirTrigger, cancelled: Boolean) {
|
|
||||||
pressed -= trigger
|
|
||||||
heldOnScreen.remove(trigger)?.let { onScreen(it, trigger, false, cancelled) }
|
|
||||||
?: sources[trigger]?.let { if (cancelled) it.cancel() else it.update(0f) }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun release() {
|
|
||||||
AirTrigger.entries.forEach(::stop)
|
|
||||||
held.toList().forEach { held.remove(it); touched(it, false) }
|
|
||||||
pressed.toList().forEach { unpress(it, cancelled = true) }
|
|
||||||
sources.values.forEach { it.release() }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun close() {
|
|
||||||
release()
|
|
||||||
sources.values.forEach { it.close() }
|
|
||||||
sources.clear()
|
|
||||||
setups.clear()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,327 +0,0 @@
|
|||||||
package com.droiddeck.launcher.input
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.net.LocalSocket
|
|
||||||
import android.net.LocalSocketAddress
|
|
||||||
import android.os.Handler
|
|
||||||
import android.os.Looper
|
|
||||||
import android.util.Log
|
|
||||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
|
||||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
|
||||||
import java.io.File
|
|
||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.RejectedExecutionException
|
|
||||||
import java.util.concurrent.ScheduledThreadPoolExecutor
|
|
||||||
import java.util.concurrent.TimeUnit
|
|
||||||
|
|
||||||
private enum class TextDelivery(val result: Int) {
|
|
||||||
NOT_DELIVERED(WaylandCompositor.TEXT_NOT_DELIVERED),
|
|
||||||
DELIVERED(WaylandCompositor.TEXT_DELIVERED),
|
|
||||||
UNRESOLVED(WaylandCompositor.TEXT_UNRESOLVED),
|
|
||||||
}
|
|
||||||
|
|
||||||
class SessionTextInput(context: Context, private val hasFocus: () -> Boolean) {
|
|
||||||
private val delivery = deliveryFor(context)
|
|
||||||
private val owner = Any()
|
|
||||||
|
|
||||||
fun start() = delivery.start(owner, hasFocus)
|
|
||||||
fun stop() = delivery.stop(owner)
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
private var instance: SessionTextDelivery? = null
|
|
||||||
|
|
||||||
@Synchronized private fun deliveryFor(context: Context): SessionTextDelivery =
|
|
||||||
instance ?: SessionTextDelivery(context.applicationContext).also { instance = it }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SessionTextDelivery(private val appContext: Context) {
|
|
||||||
private val handler = Handler(Looper.getMainLooper())
|
|
||||||
private val lock = Any()
|
|
||||||
private var generation = 0L
|
|
||||||
@Volatile private var active = false
|
|
||||||
private var owner: Any? = null
|
|
||||||
private var focusCheck: (() -> Boolean)? = null
|
|
||||||
private var executor: ScheduledThreadPoolExecutor? = null
|
|
||||||
private var socket: LocalSocket? = null
|
|
||||||
private var pendingToken = 0
|
|
||||||
private var runningToken = 0
|
|
||||||
private var failedToken = 0
|
|
||||||
private val guestListener = object : WaylandCompositor.TextInputFallbackListener {
|
|
||||||
override fun onTextInputFallback(text: String, token: Int): Boolean {
|
|
||||||
synchronized(lock) {
|
|
||||||
if (!active || pendingToken != 0 || failedToken != 0 || token <= 0) return false
|
|
||||||
val received = generation
|
|
||||||
pendingToken = token
|
|
||||||
val posted = try {
|
|
||||||
handler.post { enqueue(text, received, token) }
|
|
||||||
} catch (e: RuntimeException) {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
if (!posted) pendingToken = 0
|
|
||||||
return posted
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun start(nextOwner: Any, hasFocus: () -> Boolean) {
|
|
||||||
val previous = synchronized(lock) {
|
|
||||||
if (owner === nextOwner) return
|
|
||||||
owner
|
|
||||||
}
|
|
||||||
if (previous != null) stop(previous)
|
|
||||||
val queue = ScheduledThreadPoolExecutor(1) { runnable ->
|
|
||||||
Thread(runnable, "session-text-input").apply { isDaemon = true }
|
|
||||||
}
|
|
||||||
queue.executeExistingDelayedTasksAfterShutdownPolicy = false
|
|
||||||
synchronized(lock) {
|
|
||||||
this.owner = nextOwner
|
|
||||||
focusCheck = hasFocus
|
|
||||||
active = true
|
|
||||||
executor = queue
|
|
||||||
if (failedToken != 0) scheduleRetryLocked(failedToken, INITIAL_DELAY_MS)
|
|
||||||
}
|
|
||||||
WaylandCompositor.setTextInputFallbackListener(guestListener)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun stop(oldOwner: Any) {
|
|
||||||
val detached = synchronized(lock) {
|
|
||||||
if (owner !== oldOwner) return
|
|
||||||
owner = null
|
|
||||||
focusCheck = null
|
|
||||||
active = false
|
|
||||||
generation += 1
|
|
||||||
val queue = executor
|
|
||||||
val open = socket
|
|
||||||
val token = if (runningToken == 0 && failedToken == 0) pendingToken else 0
|
|
||||||
executor = null
|
|
||||||
socket = null
|
|
||||||
Triple(queue, open, token)
|
|
||||||
}
|
|
||||||
WaylandCompositor.clearTextInputFallbackListener(guestListener)
|
|
||||||
handler.removeCallbacksAndMessages(null)
|
|
||||||
detached.second?.let { requestCancel(it) }
|
|
||||||
detached.first?.shutdown()
|
|
||||||
if (detached.third != 0) complete(detached.third)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun enqueue(text: String, received: Long, token: Int) {
|
|
||||||
val currentFocus = synchronized(lock) { if (active && generation == received) focusCheck else null }
|
|
||||||
if (currentFocus == null || !currentFocus() || !WaylandCompositor.isTextInputFallbackListener(guestListener)) {
|
|
||||||
Log.d(TAG, "guest text fallback skipped outside the active focused session")
|
|
||||||
complete(token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val bytes = text.toByteArray(Charsets.UTF_8)
|
|
||||||
if (bytes.isEmpty() || bytes.size > MAX_BYTES) {
|
|
||||||
complete(token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val queue = synchronized(lock) {
|
|
||||||
if (active && generation == received) executor else null
|
|
||||||
}
|
|
||||||
if (queue == null) {
|
|
||||||
complete(token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
queue.execute {
|
|
||||||
try {
|
|
||||||
val delivery = send(bytes, received, token)
|
|
||||||
if (delivery == TextDelivery.UNRESOLVED) recover(token)
|
|
||||||
else complete(token, delivery)
|
|
||||||
} finally {
|
|
||||||
releaseRunning(token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (e: RejectedExecutionException) {
|
|
||||||
complete(token)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun recover(token: Int) {
|
|
||||||
if (probe()) {
|
|
||||||
complete(token)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val marked = synchronized(lock) {
|
|
||||||
if (pendingToken == token && failedToken == 0) {
|
|
||||||
failedToken = token
|
|
||||||
WaylandCompositor.completeTextInputFallback(token, TextDelivery.UNRESOLVED.result)
|
|
||||||
scheduleRetryLocked(token, INITIAL_DELAY_MS)
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (marked) Log.w(TAG, "text injection could not be confirmed")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun scheduleRetryLocked(token: Int, delayMs: Long) {
|
|
||||||
if (!active || failedToken != token || pendingToken != token) return
|
|
||||||
val queue = executor ?: return
|
|
||||||
val current = generation
|
|
||||||
try {
|
|
||||||
queue.schedule({ retryProbe(current, token, delayMs) }, delayMs, TimeUnit.MILLISECONDS)
|
|
||||||
} catch (e: RejectedExecutionException) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun retryProbe(received: Long, token: Int, delayMs: Long) {
|
|
||||||
val ready = synchronized(lock) {
|
|
||||||
active && generation == received && failedToken == token && pendingToken == token
|
|
||||||
}
|
|
||||||
if (!ready) return
|
|
||||||
val proven = probe()
|
|
||||||
val owned = synchronized(lock) {
|
|
||||||
if (proven) {
|
|
||||||
if (active && generation == received && failedToken == token && pendingToken == token) {
|
|
||||||
pendingToken = 0
|
|
||||||
runningToken = 0
|
|
||||||
failedToken = 0
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (active && generation == received && failedToken == token && pendingToken == token) {
|
|
||||||
val next = (delayMs * 2).coerceAtMost(MAX_DELAY_MS)
|
|
||||||
scheduleRetryLocked(token, next)
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (owned) WaylandCompositor.completeTextInputFallback(token, TextDelivery.NOT_DELIVERED.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun probe(): Boolean {
|
|
||||||
val live = LocalSocket()
|
|
||||||
return try {
|
|
||||||
live.connect(LocalSocketAddress(endpoint().path, LocalSocketAddress.Namespace.FILESYSTEM))
|
|
||||||
live.soTimeout = TIMEOUT_MS
|
|
||||||
val out = live.outputStream
|
|
||||||
out.write(lengthPrefix(0))
|
|
||||||
out.flush()
|
|
||||||
live.inputStream.read() == 0
|
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.w(TAG, "could not probe guest text input state", e)
|
|
||||||
false
|
|
||||||
} finally {
|
|
||||||
close(live)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun complete(token: Int, delivery: TextDelivery = TextDelivery.NOT_DELIVERED) {
|
|
||||||
val owned = synchronized(lock) {
|
|
||||||
if (pendingToken == token) {
|
|
||||||
pendingToken = 0
|
|
||||||
runningToken = 0
|
|
||||||
failedToken = 0
|
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (owned) WaylandCompositor.completeTextInputFallback(token, delivery.result)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun releaseRunning(token: Int) {
|
|
||||||
synchronized(lock) {
|
|
||||||
if (runningToken == token) runningToken = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun send(bytes: ByteArray, received: Long, token: Int): TextDelivery {
|
|
||||||
val live = LocalSocket()
|
|
||||||
if (!claim(live, received, token)) {
|
|
||||||
close(live)
|
|
||||||
return TextDelivery.NOT_DELIVERED
|
|
||||||
}
|
|
||||||
var requested = false
|
|
||||||
try {
|
|
||||||
live.connect(LocalSocketAddress(endpoint().path, LocalSocketAddress.Namespace.FILESYSTEM))
|
|
||||||
live.soTimeout = TIMEOUT_MS
|
|
||||||
if (!isCurrent(received)) return TextDelivery.NOT_DELIVERED
|
|
||||||
val out = live.outputStream
|
|
||||||
out.write(lengthPrefix(bytes.size))
|
|
||||||
requested = true
|
|
||||||
out.write(bytes)
|
|
||||||
out.flush()
|
|
||||||
val input = live.inputStream
|
|
||||||
val ack = try {
|
|
||||||
input.read()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
// Android may report a socket read timeout as a plain IOException.
|
|
||||||
requestCancel(live)
|
|
||||||
input.read()
|
|
||||||
}
|
|
||||||
if (ack == 0) Log.d(TAG, "guest did not complete text delivery")
|
|
||||||
if (ack != 0 && ack != 1 && isCurrent(received)) Log.w(TAG, "guest did not acknowledge text delivery")
|
|
||||||
return when (ack) {
|
|
||||||
1 -> TextDelivery.DELIVERED
|
|
||||||
0 -> TextDelivery.NOT_DELIVERED
|
|
||||||
else -> TextDelivery.UNRESOLVED
|
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
|
||||||
if (isCurrent(received)) Log.w(TAG, "could not hand text to the guest", e)
|
|
||||||
if (!requested) return TextDelivery.NOT_DELIVERED
|
|
||||||
return TextDelivery.UNRESOLVED
|
|
||||||
} finally {
|
|
||||||
release(live)
|
|
||||||
close(live)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun requestCancel(live: LocalSocket) {
|
|
||||||
try {
|
|
||||||
live.shutdownOutput()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
Log.w(TAG, "could not request guest text input cancellation", e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun isCurrent(received: Long) = synchronized(lock) { active && generation == received }
|
|
||||||
|
|
||||||
private fun claim(live: LocalSocket, received: Long, token: Int) = synchronized(lock) {
|
|
||||||
if (!active || generation != received || pendingToken != token || runningToken != 0 || failedToken != 0) {
|
|
||||||
false
|
|
||||||
} else {
|
|
||||||
runningToken = token
|
|
||||||
socket = live
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun release(live: LocalSocket) {
|
|
||||||
synchronized(lock) {
|
|
||||||
if (socket === live) socket = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun endpoint(): File = File(LinuxRuntime.sessionRoot(appContext), "text-input.sock")
|
|
||||||
|
|
||||||
private fun lengthPrefix(size: Int): ByteArray {
|
|
||||||
val flagged = if (size == 0) size else size or Int.MIN_VALUE
|
|
||||||
return byteArrayOf(
|
|
||||||
(flagged ushr 24).toByte(),
|
|
||||||
(flagged ushr 16).toByte(),
|
|
||||||
(flagged ushr 8).toByte(),
|
|
||||||
flagged.toByte(),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun close(sock: LocalSocket) {
|
|
||||||
try {
|
|
||||||
sock.close()
|
|
||||||
} catch (e: IOException) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
const val TAG = "SessionTextInput"
|
|
||||||
const val MAX_BYTES = 65536
|
|
||||||
const val TIMEOUT_MS = 3000
|
|
||||||
const val INITIAL_DELAY_MS = 500L
|
|
||||||
const val MAX_DELAY_MS = 5000L
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -38,11 +38,6 @@ object ElfSeccompPatch {
|
|||||||
val end = minOf(data.size, buffer.getLong(at + 8).toInt() + buffer.getLong(at + 32).toInt()) and 3.inv()
|
val end = minOf(data.size, buffer.getLong(at + 8).toInt() + buffer.getLong(at + 32).toInt()) and 3.inv()
|
||||||
var pos = start
|
var pos = start
|
||||||
while (pos + 4 <= end) {
|
while (pos + 4 <= end) {
|
||||||
if (patchTermiosRequest(buffer, pos, end)) {
|
|
||||||
patched++
|
|
||||||
pos += 4
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
val replacement = when (buffer.getInt(pos)) {
|
val replacement = when (buffer.getInt(pos)) {
|
||||||
MOV_X8_SET_ROBUST_LIST -> NOP
|
MOV_X8_SET_ROBUST_LIST -> NOP
|
||||||
MOV_X8_CLONE3, MOV_X8_RSEQ -> MOV_X0_ENOSYS
|
MOV_X8_CLONE3, MOV_X8_RSEQ -> MOV_X0_ENOSYS
|
||||||
@@ -70,40 +65,6 @@ object ElfSeccompPatch {
|
|||||||
return patched
|
return patched
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* glibc 2.42 and later read and set a terminal with TCGETS2 and TCSETS2/W2/F2, which Android's
|
|
||||||
* SELinux policy refuses on an app's pseudo-terminal slaves (EACCES): isatty() was false in every
|
|
||||||
* Konsole, ssh and tmux session, so bash had no prompt or job control and stdout was not line
|
|
||||||
* buffered. TCGETS and TCSETS* carry the same struct without its two speed fields, which glibc
|
|
||||||
* then takes from c_cflag. A site is `movz xN, #lo` then `movk xN, #hi, lsl #16`; the movz gets
|
|
||||||
* the old request and the movk becomes a no-op.
|
|
||||||
*/
|
|
||||||
private fun patchTermiosRequest(buffer: ByteBuffer, pos: Int, end: Int): Boolean {
|
|
||||||
val movz = buffer.getInt(pos)
|
|
||||||
if ((movz and 0x7fe00000) != 0x52800000) return false
|
|
||||||
val low = (movz ushr 5) and 0xffff
|
|
||||||
if (low !in 0x542a..0x542d) return false
|
|
||||||
val register = movz and 0x1f
|
|
||||||
var next = pos + 4
|
|
||||||
while (next < minOf(end, pos + 4 + 4 * 4)) {
|
|
||||||
val movk = buffer.getInt(next)
|
|
||||||
if ((movk and 0x7fe00000) == 0x72a00000 && (movk and 0x1f) == register) {
|
|
||||||
val request = when ((movk ushr 5) and 0xffff) {
|
|
||||||
0x802c -> if (low == 0x542a) 0x5401 else return false
|
|
||||||
0x402c -> if (low != 0x542a) 0x5402 + (low - 0x542b) else return false
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
buffer.putInt(pos, (movz and 0x1f.inv() and (0xffff shl 5).inv()) or (request shl 5) or register)
|
|
||||||
buffer.putInt(next, NOP)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
// Anything between that might read or write the register would see the old low half
|
|
||||||
if (intArrayOf(0, 5, 10, 16).any { (movk ushr it) and 0x1f == register }) return false
|
|
||||||
next += 4
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Patches the file behind [path] (symlinks followed) if it still has unpatched call sites. */
|
/** Patches the file behind [path] (symlinks followed) if it still has unpatched call sites. */
|
||||||
fun patchFile(path: File): Int {
|
fun patchFile(path: File): Int {
|
||||||
val target = path.canonicalFile
|
val target = path.canonicalFile
|
||||||
|
|||||||
@@ -1,271 +0,0 @@
|
|||||||
package com.droiddeck.launcher.runtime
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.SystemClock
|
|
||||||
import android.system.Os
|
|
||||||
import android.system.OsConstants
|
|
||||||
import android.util.Log
|
|
||||||
import com.droiddeck.launcher.wayland.WaylandCompositor
|
|
||||||
import java.io.File
|
|
||||||
import java.io.InputStream
|
|
||||||
import java.nio.file.Files
|
|
||||||
import java.nio.file.LinkOption.NOFOLLOW_LINKS
|
|
||||||
import java.security.MessageDigest
|
|
||||||
|
|
||||||
/** One app-issued Steam session and one attested Gamescope worker. This is not an
|
|
||||||
* isolation boundary against arbitrary code already running as the Android app UID. */
|
|
||||||
internal object FrameAcquireWorkerProbe {
|
|
||||||
private const val SESSION_SCRIPT = "/usr/local/bin/droiddeck-session"
|
|
||||||
private const val PATH = "/usr/local/bin/gamescope"
|
|
||||||
private const val CAPABILITY = "linuxfs/usr/local/share/droiddeck/gamescope-producer-acquire-v1"
|
|
||||||
internal const val GAMESCOPE_ENABLE = "GAMESCOPE_DROIDDECK_PRODUCER_ACQUIRE=1"
|
|
||||||
internal const val GAME_ENABLE = "DROIDDECK_GAME_DROIDDECK_GAME_FRAME_ACQUIRE=1"
|
|
||||||
private const val MAX_BINARY_BYTES = 32L * 1024L * 1024L
|
|
||||||
internal const val RECEIPT_TAG = 0x44445046
|
|
||||||
internal const val RECEIPT_BYTES = Int.SIZE_BYTES + Long.SIZE_BYTES
|
|
||||||
private const val TTL_MS = 90_000L
|
|
||||||
|
|
||||||
internal data class Ticket(
|
|
||||||
val owner: Int, val root: File, val configuredRoot: File, val binary: File,
|
|
||||||
val expected: ByteArray, val expires: Long, val steamGameUrl: String?,
|
|
||||||
)
|
|
||||||
internal data class Qualified(val ticket: Ticket, val dev: Long, val ino: Long, val mtime: Long, val ctime: Long)
|
|
||||||
private var intent: Ticket? = null
|
|
||||||
private var nativeOwner = 0
|
|
||||||
private var nativePid = 0
|
|
||||||
|
|
||||||
private enum class Stage { ARM, MATCH, PUBLISH }
|
|
||||||
private enum class Reason {
|
|
||||||
ENABLED, MATCH_ACK, MATCH_OWNER, MATCH_EXPIRED, MATCH_PATH, MATCH_ROOT,
|
|
||||||
MATCH_ARGV, MATCH_FILE, MATCH_DIGEST, QUALIFIED, PUBLISH_TICKET, PUBLISH_RESTAT,
|
|
||||||
PUBLISH_NATIVE, PUBLISH_RECEIPT, RESERVED
|
|
||||||
}
|
|
||||||
private val reported = mutableSetOf<Stage>()
|
|
||||||
@Synchronized private fun breadcrumb(stage: Stage, reason: Reason) {
|
|
||||||
if (reported.add(stage)) Log.i("FrameAcquireWorkerProbe", "worker_admission=" + reason.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun validEnvironment(agentEnvironment: List<String>, customEnvironment: List<String>): Boolean {
|
|
||||||
// AgentEnv supplies a replacement PATH whenever any executable override is staged.
|
|
||||||
// Custom env is user-editable, including names not known to this build; it is not a trust root.
|
|
||||||
return agentEnvironment.isEmpty() && customEnvironment.isEmpty()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun available(context: Context): Boolean =
|
|
||||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.core.DeviceSupport.adreno() &&
|
|
||||||
runCatching { context.assets.open(CAPABILITY).use { it.readBytes().decodeToString() } }
|
|
||||||
.getOrNull() == "droiddeck-producer-acquire-v1\n"
|
|
||||||
|
|
||||||
private fun digest(input: InputStream, maxBytes: Long): ByteArray {
|
|
||||||
val out = MessageDigest.getInstance("SHA-256")
|
|
||||||
val buffer = ByteArray(64 * 1024)
|
|
||||||
var size = 0L
|
|
||||||
while (true) {
|
|
||||||
val n = input.read(buffer)
|
|
||||||
if (n == -1) break
|
|
||||||
require(n > 0)
|
|
||||||
size += n
|
|
||||||
require(size <= maxBytes)
|
|
||||||
out.update(buffer, 0, n)
|
|
||||||
}
|
|
||||||
require(size > 0)
|
|
||||||
return out.digest()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compute asset identity outside SessionService's stop lock and before a worker
|
|
||||||
// exists. The resulting ticket still has to be assigned to that exact owner.
|
|
||||||
private const val STEAM_RUN_PREFIX = "steam://rungameid/"
|
|
||||||
|
|
||||||
internal fun permittedLaunch(url: String?, frontendGame: Boolean): Boolean =
|
|
||||||
if (url == null) !frontendGame else frontendGame && url.startsWith(STEAM_RUN_PREFIX) &&
|
|
||||||
com.droiddeck.launcher.frontend.GameLaunchLink.validId(url.removePrefix(STEAM_RUN_PREFIX))
|
|
||||||
|
|
||||||
internal fun prepare(context: Context, steamGameUrl: String?, frontendGame: Boolean): Ticket? {
|
|
||||||
if (!permittedLaunch(steamGameUrl, frontendGame) ||
|
|
||||||
!available(context) || !WaylandCompositor.frameWorkerProbeEnabled()) return null
|
|
||||||
return runCatching {
|
|
||||||
val configuredRoot = LinuxRuntime.rootDir(context).absoluteFile
|
|
||||||
val root = configuredRoot.canonicalFile
|
|
||||||
val file = File(root.path + PATH)
|
|
||||||
require(file.canonicalFile == file && Files.isRegularFile(file.toPath(), NOFOLLOW_LINKS))
|
|
||||||
val script = File(root.path + SESSION_SCRIPT)
|
|
||||||
require(exactSteamScript(SESSION_SCRIPT, root, configuredRoot))
|
|
||||||
val stagedScript = script.inputStream().use { digest(it, 1024L * 1024L) }
|
|
||||||
val signedScript = context.assets.open("linuxfs" + SESSION_SCRIPT).use { digest(it, 1024L * 1024L) }
|
|
||||||
require(MessageDigest.isEqual(stagedScript, signedScript))
|
|
||||||
val expected = context.assets.open("linuxfs" + PATH).use { digest(it, MAX_BINARY_BYTES) }
|
|
||||||
Ticket(0, root, configuredRoot, file, expected, SystemClock.elapsedRealtime() + TTL_MS, steamGameUrl)
|
|
||||||
}.getOrNull()
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized fun arm(owner: Int, prepared: Ticket): Boolean {
|
|
||||||
if (owner <= 0 || SystemClock.elapsedRealtime() >= prepared.expires) return false
|
|
||||||
reported.clear()
|
|
||||||
intent = prepared.copy(owner = owner)
|
|
||||||
breadcrumb(Stage.ARM, Reason.ENABLED)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Native shebang handling can give Bash the staged host filename as its $0. */
|
|
||||||
internal fun exactSteamScript(token: String, root: File, configuredRoot: File): Boolean {
|
|
||||||
if (token != SESSION_SCRIPT && token != root.path + SESSION_SCRIPT &&
|
|
||||||
token != configuredRoot.path + SESSION_SCRIPT) return false
|
|
||||||
return runCatching {
|
|
||||||
val expected = File(root.path + SESSION_SCRIPT)
|
|
||||||
val supplied = if (token == SESSION_SCRIPT) expected else File(token)
|
|
||||||
// Reject symlinks within the authorized root, including a symlink replacing the script.
|
|
||||||
// Android's configured root itself may be an alias of its app-issued canonical root.
|
|
||||||
require(configuredRoot.canonicalFile == root && expected.canonicalFile == expected &&
|
|
||||||
supplied.canonicalFile == expected &&
|
|
||||||
Files.isRegularFile(expected.toPath(), NOFOLLOW_LINKS) &&
|
|
||||||
Files.isRegularFile(supplied.toPath(), NOFOLLOW_LINKS))
|
|
||||||
Files.isSameFile(supplied.toPath(), expected.toPath())
|
|
||||||
}.getOrDefault(false)
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun exactGamescopeArgs(
|
|
||||||
argv: List<String>, steamGameUrl: String? = null, script: (String) -> Boolean,
|
|
||||||
): Boolean {
|
|
||||||
if (argv.firstOrNull() !in listOf("gamescope", PATH)) return false
|
|
||||||
val delimiter = argv.indexOf("--")
|
|
||||||
val tailSize = if (steamGameUrl == null) 3 else 4
|
|
||||||
if (delimiter < 4 || argv.size != delimiter + tailSize || argv[delimiter + 2] != "steam" ||
|
|
||||||
!script(argv[delimiter + 1]) ||
|
|
||||||
(steamGameUrl != null && (!permittedLaunch(steamGameUrl, true) || argv.last() != steamGameUrl))) return false
|
|
||||||
val opts = argv.subList(1, delimiter)
|
|
||||||
if (opts.take(4) != listOf("--backend", "wayland", "--expose-wayland", "-f")) return false
|
|
||||||
val dimensions = setOf("-W", "-H", "-w", "-h")
|
|
||||||
val seen = mutableSetOf<String>()
|
|
||||||
var i = 4
|
|
||||||
while (i < opts.size) {
|
|
||||||
val option = opts[i++]
|
|
||||||
if (!seen.add(option)) return false
|
|
||||||
when (option) {
|
|
||||||
"-e", "--hdr-enabled", "--mangoapp" -> Unit
|
|
||||||
"-S" -> if (opts.getOrNull(i++) != "stretch") return false
|
|
||||||
"--default-touch-mode" -> if (opts.getOrNull(i++) != "4") return false
|
|
||||||
"-W", "-H", "-w", "-h", "-r", "--xwayland-count" -> {
|
|
||||||
val value = opts.getOrNull(i++) ?: return false
|
|
||||||
if (value.length !in 1..6 || value.any { it !in '0'..'9' } ||
|
|
||||||
value.toIntOrNull()?.let { it > 0 } != true) return false
|
|
||||||
}
|
|
||||||
else -> return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return seen.containsAll(dimensions)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun match(owner: Int, root: File, file: String, argv: List<String>, ack: Boolean): Qualified? {
|
|
||||||
val t = synchronized(this) { intent } ?: return null
|
|
||||||
// Startup's --version worker and unrelated workers must not consume the one diagnostic.
|
|
||||||
val candidate = "--version" !in argv && (file.substringAfterLast('/') == "gamescope" ||
|
|
||||||
argv.firstOrNull()?.substringAfterLast('/') == "gamescope")
|
|
||||||
val rejection = when {
|
|
||||||
!ack -> Reason.MATCH_ACK
|
|
||||||
t.owner != owner -> Reason.MATCH_OWNER
|
|
||||||
SystemClock.elapsedRealtime() >= t.expires -> Reason.MATCH_EXPIRED
|
|
||||||
file != PATH -> Reason.MATCH_PATH
|
|
||||||
runCatching { root.canonicalFile }.getOrNull() != t.root -> Reason.MATCH_ROOT
|
|
||||||
!exactGamescopeArgs(argv, t.steamGameUrl) { exactSteamScript(it, t.root, t.configuredRoot) } -> Reason.MATCH_ARGV
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
if (rejection != null) {
|
|
||||||
if (candidate) breadcrumb(Stage.MATCH, rejection)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
// Hash an actual descriptor rather than two pathname opens. Check both the
|
|
||||||
// descriptor and pathname identity; a race or substituted executable denies the grant.
|
|
||||||
val qualified = runCatching {
|
|
||||||
require(t.binary.canonicalFile == t.binary)
|
|
||||||
val before = Os.lstat(t.binary.path)
|
|
||||||
require(OsConstants.S_ISREG(before.st_mode) && before.st_size in 1..MAX_BINARY_BYTES)
|
|
||||||
val fd = Os.open(t.binary.path, OsConstants.O_RDONLY or OsConstants.O_NOFOLLOW or OsConstants.O_CLOEXEC, 0)
|
|
||||||
val sum = try {
|
|
||||||
require(stillSame(before, Os.fstat(fd)))
|
|
||||||
android.os.ParcelFileDescriptor.AutoCloseInputStream(android.os.ParcelFileDescriptor.dup(fd)).use {
|
|
||||||
digest(it, MAX_BINARY_BYTES)
|
|
||||||
}.also { require(stillSame(before, Os.fstat(fd))) }
|
|
||||||
} finally {
|
|
||||||
Os.close(fd)
|
|
||||||
}
|
|
||||||
val after = Os.lstat(t.binary.path)
|
|
||||||
require(stillSame(before, after))
|
|
||||||
if (!MessageDigest.isEqual(sum, t.expected)) {
|
|
||||||
breadcrumb(Stage.MATCH, Reason.MATCH_DIGEST)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
Qualified(t, after.st_dev, after.st_ino, after.st_mtime, after.st_ctime)
|
|
||||||
}.getOrNull()
|
|
||||||
breadcrumb(Stage.MATCH, if (qualified == null) Reason.MATCH_FILE else Reason.QUALIFIED)
|
|
||||||
return qualified
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun stillSame(a: android.system.StructStat, b: android.system.StructStat): Boolean =
|
|
||||||
a.st_dev == b.st_dev && a.st_ino == b.st_ino && a.st_size == b.st_size &&
|
|
||||||
a.st_mtime == b.st_mtime && a.st_ctime == b.st_ctime &&
|
|
||||||
OsConstants.S_ISREG(b.st_mode)
|
|
||||||
|
|
||||||
internal fun validReceipt(pid: Int, workerPid: Int, ticks: Long, bytes: Int): Long =
|
|
||||||
if (pid > 1 && pid == workerPid && ticks > 0 && bytes == RECEIPT_BYTES) ticks else 0L
|
|
||||||
|
|
||||||
internal fun parseSelfStat(stat: String, pid: Int): Long {
|
|
||||||
if (pid <= 1 || !stat.startsWith("$pid (")) return 0L
|
|
||||||
val comm = stat.lastIndexOf(')')
|
|
||||||
if (comm < 3 || stat.getOrNull(comm + 1) != ' ') return 0L
|
|
||||||
val fields = stat.substring(comm + 2).split(' ').filter { it.isNotEmpty() }
|
|
||||||
if (fields.firstOrNull()?.length != 1 || fields.size < 21) return 0L
|
|
||||||
val value = fields[19] // field 22 from field 3 (the single-character task state).
|
|
||||||
return value.takeIf { it.isNotEmpty() && it.all { ch -> ch in '0'..'9' } }
|
|
||||||
?.toLongOrNull()?.takeIf { it > 0 } ?: 0L
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun selfStartTicks(pid: Int): Long = runCatching {
|
|
||||||
File("/proc/self/stat").inputStream().use { input ->
|
|
||||||
val bytes = ByteArray(4096)
|
|
||||||
var used = 0
|
|
||||||
while (used < bytes.size) {
|
|
||||||
val n = input.read(bytes, used, bytes.size - used)
|
|
||||||
if (n < 0) break
|
|
||||||
if (n == 0) return@runCatching 0L
|
|
||||||
used += n
|
|
||||||
}
|
|
||||||
if (used == bytes.size || used == 0 || bytes[used-1] != '\n'.code.toByte()) 0L
|
|
||||||
else parseSelfStat(String(bytes, 0, used, Charsets.US_ASCII), pid)
|
|
||||||
}
|
|
||||||
}.getOrDefault(0L)
|
|
||||||
|
|
||||||
/** Runs just before the final GO byte. Failure never changes ordinary launch. */
|
|
||||||
@Synchronized fun publish(q: Qualified, pid: Int, startTicks: Long) {
|
|
||||||
val t = q.ticket
|
|
||||||
if (intent !== t || pid <= 1 || SystemClock.elapsedRealtime() >= t.expires) {
|
|
||||||
if (intent === t) breadcrumb(Stage.PUBLISH, Reason.PUBLISH_TICKET)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
intent = null // At most one candidate per explicitly armed session.
|
|
||||||
if (startTicks <= 0L) {
|
|
||||||
breadcrumb(Stage.PUBLISH, Reason.PUBLISH_RECEIPT)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val status = runCatching {
|
|
||||||
val st = Os.lstat(t.binary.path)
|
|
||||||
require(OsConstants.S_ISREG(st.st_mode) && st.st_dev == q.dev && st.st_ino == q.ino &&
|
|
||||||
st.st_mtime == q.mtime && st.st_ctime == q.ctime)
|
|
||||||
if (WaylandCompositor.frameWorkerProbeGrant(t.owner, pid, t.expires, t.binary.path, st.st_dev, st.st_ino, startTicks)) {
|
|
||||||
nativeOwner = t.owner
|
|
||||||
nativePid = pid
|
|
||||||
Reason.RESERVED
|
|
||||||
} else Reason.PUBLISH_NATIVE
|
|
||||||
}.getOrDefault(Reason.PUBLISH_RESTAT)
|
|
||||||
breadcrumb(Stage.PUBLISH, status)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Synchronized fun revoke(owner: Int, pid: Int = 0) {
|
|
||||||
if (owner <= 0) return
|
|
||||||
if (pid == 0 && intent?.owner == owner) intent = null
|
|
||||||
if (nativeOwner == owner && (pid == 0 || pid == nativePid)) {
|
|
||||||
WaylandCompositor.frameWorkerProbeRevoke(owner, pid)
|
|
||||||
nativeOwner = 0
|
|
||||||
nativePid = 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -44,17 +44,7 @@ open class GuestWorker : Service() {
|
|||||||
val targets = data.createIntArray() ?: IntArray(fds.size) { it }
|
val targets = data.createIntArray() ?: IntArray(fds.size) { it }
|
||||||
val fillBinderFd = data.readInt() != 0
|
val fillBinderFd = data.readInt() != 0
|
||||||
val go = data.readFileDescriptor()
|
val go = data.readFileDescriptor()
|
||||||
val nice = data.readInt()
|
reply?.writeInt(Process.myPid())
|
||||||
val pid = Process.myPid()
|
|
||||||
reply?.writeInt(pid)
|
|
||||||
// Optional fixed-size receipt, on the exact local, non-exported worker's Binder.
|
|
||||||
// Nothing in the guest socket request populates these fields.
|
|
||||||
if (reply != null &&
|
|
||||||
Binder.getCallingUid() == Process.myUid() &&
|
|
||||||
data.dataAvail() == Int.SIZE_BYTES && data.readInt() == FrameAcquireWorkerProbe.RECEIPT_TAG) {
|
|
||||||
reply.writeInt(pid)
|
|
||||||
reply.writeLong(FrameAcquireWorkerProbe.selfStartTicks(pid))
|
|
||||||
}
|
|
||||||
Handler(Looper.getMainLooper()).post {
|
Handler(Looper.getMainLooper()).post {
|
||||||
// The app writes a byte once it has the reply and has taken the launch on: an exec
|
// The app writes a byte once it has the reply and has taken the launch on: an exec
|
||||||
// before then would end this process with the reply undelivered, and with none (the
|
// before then would end this process with the reply undelivered, and with none (the
|
||||||
@@ -76,7 +66,7 @@ open class GuestWorker : Service() {
|
|||||||
byte(GO_TIMEOUT_MS) == 1 && Os.write(go.fileDescriptor, byteArrayOf(1), 0, 1) == 1 && byte(-1) == 1
|
byte(GO_TIMEOUT_MS) == 1 && Os.write(go.fileDescriptor, byteArrayOf(1), 0, 1) == 1 && byte(-1) == 1
|
||||||
}.getOrElse { why = it.toString(); false }
|
}.getOrElse { why = it.toString(); false }
|
||||||
go.close()
|
go.close()
|
||||||
if (committed) exec(argv, env, fds, targets, fillBinderFd, nice)
|
if (committed) exec(argv, env, fds, targets, fillBinderFd)
|
||||||
else {
|
else {
|
||||||
Log.w(TAG, "launch not committed ($why): not running ${argv.firstOrNull()}")
|
Log.w(TAG, "launch not committed ($why): not running ${argv.firstOrNull()}")
|
||||||
Process.killProcess(Process.myPid())
|
Process.killProcess(Process.myPid())
|
||||||
@@ -88,8 +78,7 @@ open class GuestWorker : Service() {
|
|||||||
|
|
||||||
override fun onBind(intent: Intent): IBinder = binder
|
override fun onBind(intent: Intent): IBinder = binder
|
||||||
|
|
||||||
private fun exec(argv: Array<String>, env: Array<String>, fds: List<ParcelFileDescriptor?>, targets: IntArray, fillBinderFd: Boolean,
|
private fun exec(argv: Array<String>, env: Array<String>, fds: List<ParcelFileDescriptor?>, targets: IntArray, fillBinderFd: Boolean) {
|
||||||
nice: Int) {
|
|
||||||
try {
|
try {
|
||||||
val top = targets.maxOrNull() ?: 2
|
val top = targets.maxOrNull() ?: 2
|
||||||
val (binderTop, binderFd) = keepBinderOpen(maxOf(BINDER_FDS, top + 1))
|
val (binderTop, binderFd) = keepBinderOpen(maxOf(BINDER_FDS, top + 1))
|
||||||
@@ -116,10 +105,6 @@ open class GuestWorker : Service() {
|
|||||||
// This thread blocks SIGQUIT, SIGUSR1 and SIGPIPE (Android's runtime), and an exec keeps
|
// This thread blocks SIGQUIT, SIGUSR1 and SIGPIPE (Android's runtime), and an exec keeps
|
||||||
// that: the program's hook sets DDH_SIGMASK instead (none blocked, unless the request says).
|
// that: the program's hook sets DDH_SIGMASK instead (none blocked, unless the request says).
|
||||||
val mask = if (env.any { it.startsWith("DDH_SIGMASK=") }) emptyList() else listOf("DDH_SIGMASK=0")
|
val mask = if (env.any { it.startsWith("DDH_SIGMASK=") }) emptyList() else listOf("DDH_SIGMASK=0")
|
||||||
// Android raised this thread to THREAD_PRIORITY_TOP_APP_BOOST (a service the top app binds with
|
|
||||||
// BIND_IMPORTANT is scheduled as the top app); the program and its threads would keep it and
|
|
||||||
// run ahead of the game. They get the asker's priority instead, as a forked child would.
|
|
||||||
runCatching { Process.setThreadPriority(nice) }
|
|
||||||
Os.execve(argv[0], argv.map(fill).toTypedArray(),
|
Os.execve(argv[0], argv.map(fill).toTypedArray(),
|
||||||
env.filterNot { it.startsWith("DDH_WORKER_PID=") }.map(fill).toTypedArray() + mask +
|
env.filterNot { it.startsWith("DDH_WORKER_PID=") }.map(fill).toTypedArray() + mask +
|
||||||
"DDH_WORKER_PID=${Process.myPid()}")
|
"DDH_WORKER_PID=${Process.myPid()}")
|
||||||
@@ -233,70 +218,6 @@ class GuestWorker60 : GuestWorker()
|
|||||||
class GuestWorker61 : GuestWorker()
|
class GuestWorker61 : GuestWorker()
|
||||||
class GuestWorker62 : GuestWorker()
|
class GuestWorker62 : GuestWorker()
|
||||||
class GuestWorker63 : GuestWorker()
|
class GuestWorker63 : GuestWorker()
|
||||||
class GuestWorker64 : GuestWorker()
|
|
||||||
class GuestWorker65 : GuestWorker()
|
|
||||||
class GuestWorker66 : GuestWorker()
|
|
||||||
class GuestWorker67 : GuestWorker()
|
|
||||||
class GuestWorker68 : GuestWorker()
|
|
||||||
class GuestWorker69 : GuestWorker()
|
|
||||||
class GuestWorker70 : GuestWorker()
|
|
||||||
class GuestWorker71 : GuestWorker()
|
|
||||||
class GuestWorker72 : GuestWorker()
|
|
||||||
class GuestWorker73 : GuestWorker()
|
|
||||||
class GuestWorker74 : GuestWorker()
|
|
||||||
class GuestWorker75 : GuestWorker()
|
|
||||||
class GuestWorker76 : GuestWorker()
|
|
||||||
class GuestWorker77 : GuestWorker()
|
|
||||||
class GuestWorker78 : GuestWorker()
|
|
||||||
class GuestWorker79 : GuestWorker()
|
|
||||||
class GuestWorker80 : GuestWorker()
|
|
||||||
class GuestWorker81 : GuestWorker()
|
|
||||||
class GuestWorker82 : GuestWorker()
|
|
||||||
class GuestWorker83 : GuestWorker()
|
|
||||||
class GuestWorker84 : GuestWorker()
|
|
||||||
class GuestWorker85 : GuestWorker()
|
|
||||||
class GuestWorker86 : GuestWorker()
|
|
||||||
class GuestWorker87 : GuestWorker()
|
|
||||||
class GuestWorker88 : GuestWorker()
|
|
||||||
class GuestWorker89 : GuestWorker()
|
|
||||||
class GuestWorker90 : GuestWorker()
|
|
||||||
class GuestWorker91 : GuestWorker()
|
|
||||||
class GuestWorker92 : GuestWorker()
|
|
||||||
class GuestWorker93 : GuestWorker()
|
|
||||||
class GuestWorker94 : GuestWorker()
|
|
||||||
class GuestWorker95 : GuestWorker()
|
|
||||||
class GuestWorker96 : GuestWorker()
|
|
||||||
class GuestWorker97 : GuestWorker()
|
|
||||||
class GuestWorker98 : GuestWorker()
|
|
||||||
class GuestWorker99 : GuestWorker()
|
|
||||||
class GuestWorker100 : GuestWorker()
|
|
||||||
class GuestWorker101 : GuestWorker()
|
|
||||||
class GuestWorker102 : GuestWorker()
|
|
||||||
class GuestWorker103 : GuestWorker()
|
|
||||||
class GuestWorker104 : GuestWorker()
|
|
||||||
class GuestWorker105 : GuestWorker()
|
|
||||||
class GuestWorker106 : GuestWorker()
|
|
||||||
class GuestWorker107 : GuestWorker()
|
|
||||||
class GuestWorker108 : GuestWorker()
|
|
||||||
class GuestWorker109 : GuestWorker()
|
|
||||||
class GuestWorker110 : GuestWorker()
|
|
||||||
class GuestWorker111 : GuestWorker()
|
|
||||||
class GuestWorker112 : GuestWorker()
|
|
||||||
class GuestWorker113 : GuestWorker()
|
|
||||||
class GuestWorker114 : GuestWorker()
|
|
||||||
class GuestWorker115 : GuestWorker()
|
|
||||||
class GuestWorker116 : GuestWorker()
|
|
||||||
class GuestWorker117 : GuestWorker()
|
|
||||||
class GuestWorker118 : GuestWorker()
|
|
||||||
class GuestWorker119 : GuestWorker()
|
|
||||||
class GuestWorker120 : GuestWorker()
|
|
||||||
class GuestWorker121 : GuestWorker()
|
|
||||||
class GuestWorker122 : GuestWorker()
|
|
||||||
class GuestWorker123 : GuestWorker()
|
|
||||||
class GuestWorker124 : GuestWorker()
|
|
||||||
class GuestWorker125 : GuestWorker()
|
|
||||||
class GuestWorker126 : GuestWorker()
|
|
||||||
class GuestWorker127 : GuestWorker()
|
|
||||||
|
|
||||||
/** The pool of [GuestWorker] processes, and the socket guests ask it through (`droiddeck-spawn`). */
|
/** The pool of [GuestWorker] processes, and the socket guests ask it through (`droiddeck-spawn`). */
|
||||||
object GuestWorkers {
|
object GuestWorkers {
|
||||||
@@ -323,28 +244,7 @@ object GuestWorkers {
|
|||||||
GuestWorker54::class.java, GuestWorker55::class.java, GuestWorker56::class.java,
|
GuestWorker54::class.java, GuestWorker55::class.java, GuestWorker56::class.java,
|
||||||
GuestWorker57::class.java, GuestWorker58::class.java, GuestWorker59::class.java,
|
GuestWorker57::class.java, GuestWorker58::class.java, GuestWorker59::class.java,
|
||||||
GuestWorker60::class.java, GuestWorker61::class.java, GuestWorker62::class.java,
|
GuestWorker60::class.java, GuestWorker61::class.java, GuestWorker62::class.java,
|
||||||
GuestWorker63::class.java, GuestWorker64::class.java, GuestWorker65::class.java,
|
GuestWorker63::class.java,
|
||||||
GuestWorker66::class.java, GuestWorker67::class.java, GuestWorker68::class.java,
|
|
||||||
GuestWorker69::class.java, GuestWorker70::class.java, GuestWorker71::class.java,
|
|
||||||
GuestWorker72::class.java, GuestWorker73::class.java, GuestWorker74::class.java,
|
|
||||||
GuestWorker75::class.java, GuestWorker76::class.java, GuestWorker77::class.java,
|
|
||||||
GuestWorker78::class.java, GuestWorker79::class.java, GuestWorker80::class.java,
|
|
||||||
GuestWorker81::class.java, GuestWorker82::class.java, GuestWorker83::class.java,
|
|
||||||
GuestWorker84::class.java, GuestWorker85::class.java, GuestWorker86::class.java,
|
|
||||||
GuestWorker87::class.java, GuestWorker88::class.java, GuestWorker89::class.java,
|
|
||||||
GuestWorker90::class.java, GuestWorker91::class.java, GuestWorker92::class.java,
|
|
||||||
GuestWorker93::class.java, GuestWorker94::class.java, GuestWorker95::class.java,
|
|
||||||
GuestWorker96::class.java, GuestWorker97::class.java, GuestWorker98::class.java,
|
|
||||||
GuestWorker99::class.java, GuestWorker100::class.java, GuestWorker101::class.java,
|
|
||||||
GuestWorker102::class.java, GuestWorker103::class.java, GuestWorker104::class.java,
|
|
||||||
GuestWorker105::class.java, GuestWorker106::class.java, GuestWorker107::class.java,
|
|
||||||
GuestWorker108::class.java, GuestWorker109::class.java, GuestWorker110::class.java,
|
|
||||||
GuestWorker111::class.java, GuestWorker112::class.java, GuestWorker113::class.java,
|
|
||||||
GuestWorker114::class.java, GuestWorker115::class.java, GuestWorker116::class.java,
|
|
||||||
GuestWorker117::class.java, GuestWorker118::class.java, GuestWorker119::class.java,
|
|
||||||
GuestWorker120::class.java, GuestWorker121::class.java, GuestWorker122::class.java,
|
|
||||||
GuestWorker123::class.java, GuestWorker124::class.java, GuestWorker125::class.java,
|
|
||||||
GuestWorker126::class.java, GuestWorker127::class.java,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
private class Slot(val index: Int) {
|
private class Slot(val index: Int) {
|
||||||
@@ -356,8 +256,6 @@ object GuestWorkers {
|
|||||||
/** The session it runs a program for ([serve]'s number). */
|
/** The session it runs a program for ([serve]'s number). */
|
||||||
@Volatile var session = 0
|
@Volatile var session = 0
|
||||||
@Volatile var onExit: ((Int) -> Unit)? = null
|
@Volatile var onExit: ((Int) -> Unit)? = null
|
||||||
/** The priority it runs its program at: the asker's (a guest, or the app thread that started it). */
|
|
||||||
@Volatile var nice = 0
|
|
||||||
/** Set once its program was handed over: only then does its end count as the program's. */
|
/** Set once its program was handed over: only then does its end count as the program's. */
|
||||||
@Volatile var started = false
|
@Volatile var started = false
|
||||||
/** Between the pid and the last word of a launch (under the slots lock): its end is held back. */
|
/** Between the pid and the last word of a launch (under the slots lock): its end is held back. */
|
||||||
@@ -379,12 +277,6 @@ object GuestWorkers {
|
|||||||
private val authorizing = Any()
|
private val authorizing = Any()
|
||||||
private val warming = java.util.concurrent.atomic.AtomicBoolean(false)
|
private val warming = java.util.concurrent.atomic.AtomicBoolean(false)
|
||||||
private const val WARM_WORKERS = 2
|
private const val WARM_WORKERS = 2
|
||||||
// A game's start hands off a burst of programs (Wine's services, the agent's checks) within a few
|
|
||||||
// seconds: bound ahead while the client starts it, not forked while the game draws its first frames.
|
|
||||||
private const val LAUNCH_WORKERS = 16
|
|
||||||
private const val LAUNCH_MS = 20_000L
|
|
||||||
@Volatile private var launchUntil = 0L
|
|
||||||
private val launches = java.util.concurrent.atomic.AtomicInteger()
|
|
||||||
private const val ACK_TIMEOUT_MS = 5000
|
private const val ACK_TIMEOUT_MS = 5000
|
||||||
private const val ANSWER_TIMEOUT_MS = 5000
|
private const val ANSWER_TIMEOUT_MS = 5000
|
||||||
private const val RECEIVE_TIMEOUT_MS = 10000
|
private const val RECEIVE_TIMEOUT_MS = 10000
|
||||||
@@ -394,20 +286,15 @@ object GuestWorkers {
|
|||||||
private val receiving = java.util.concurrent.atomic.AtomicInteger()
|
private val receiving = java.util.concurrent.atomic.AtomicInteger()
|
||||||
private val connections = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "guest-worker-binder").apply { isDaemon = true } }
|
private val connections = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "guest-worker-binder").apply { isDaemon = true } }
|
||||||
@Volatile private var server: Thread? = null
|
@Volatile private var server: Thread? = null
|
||||||
// Android sets a worker's main thread to THREAD_PRIORITY_TOP_APP_BOOST again each time the app returns to the top
|
|
||||||
private const val TOP_APP_BOOST = -10
|
|
||||||
private const val PRIORITY_CHECK_MS = 2000L
|
|
||||||
@Volatile private var keeper: Thread? = null
|
|
||||||
|
|
||||||
/** The app, once [attach] or [serve] ran in its main process; null before. */
|
/** The app, once [attach] or [serve] ran in its main process; null before. */
|
||||||
@Volatile var context: Context? = null
|
@Volatile var context: Context? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
/** Whether the session runs its programs in workers: the native userland, and not turned off. */
|
/** Whether the session runs its programs in workers: the native userland, and not turned off. */
|
||||||
fun enabled(context: Context): Boolean = handoffAllowed(context) && NativeGuest.enabled(context)
|
fun enabled(context: Context): Boolean =
|
||||||
|
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context) &&
|
||||||
private fun handoffAllowed(context: Context): Boolean =
|
NativeGuest.enabled(context)
|
||||||
android.os.Build.VERSION.SDK_INT >= 30 && com.droiddeck.launcher.session.SessionPrefs.childProcessHandoff(context)
|
|
||||||
|
|
||||||
/** How the running session's root was started: in a worker (true) or counted (false); null with none running. */
|
/** How the running session's root was started: in a worker (true) or counted (false); null with none running. */
|
||||||
@Volatile var sessionRootUncounted: Boolean? = null
|
@Volatile var sessionRootUncounted: Boolean? = null
|
||||||
@@ -418,7 +305,7 @@ object GuestWorkers {
|
|||||||
* the next one would start.
|
* the next one would start.
|
||||||
*/
|
*/
|
||||||
fun limitHandled(context: Context): Boolean =
|
fun limitHandled(context: Context): Boolean =
|
||||||
sessionRootUncounted ?: (NativeGuest.sessionMode != false && handoffAllowed(context) && NativeGuest.nextSession(context))
|
sessionRootUncounted ?: (NativeGuest.sessionMode != false && enabled(context))
|
||||||
|
|
||||||
/** Whether pid is a program running in one of the workers. */
|
/** Whether pid is a program running in one of the workers. */
|
||||||
fun runsInWorker(pid: Int): Boolean = pid > 0 && synchronized(slots) { slots.any { it != null && it.started && it.pid == pid } }
|
fun runsInWorker(pid: Int): Boolean = pid > 0 && synchronized(slots) { slots.any { it != null && it.started && it.pid == pid } }
|
||||||
@@ -445,9 +332,7 @@ object GuestWorkers {
|
|||||||
*/
|
*/
|
||||||
private fun start(context: Context, argv: List<String>, env: List<String>, fds: List<ParcelFileDescriptor>, targets: IntArray,
|
private fun start(context: Context, argv: List<String>, env: List<String>, fds: List<ParcelFileDescriptor>, targets: IntArray,
|
||||||
guest: Boolean, onExit: (Int) -> Unit, commit: (Int) -> Boolean = { true },
|
guest: Boolean, onExit: (Int) -> Unit, commit: (Int) -> Boolean = { true },
|
||||||
confirmed: () -> Boolean = { true }, owner: Int = session,
|
confirmed: () -> Boolean = { true }, owner: Int = session): Int {
|
||||||
nice: Int = Process.getThreadPriority(Process.myTid()),
|
|
||||||
testWorker: FrameAcquireWorkerProbe.Qualified? = null): Int {
|
|
||||||
val app = context.applicationContext
|
val app = context.applicationContext
|
||||||
if (guest && owner <= stopped) {
|
if (guest && owner <= stopped) {
|
||||||
Log.w(TAG, (if (owner == 0) "a request naming no session" else "session $owner is stopping") +
|
Log.w(TAG, (if (owner == 0) "a request naming no session" else "session $owner is stopping") +
|
||||||
@@ -463,9 +348,7 @@ object GuestWorkers {
|
|||||||
slot.guest = guest
|
slot.guest = guest
|
||||||
slot.session = owner
|
slot.session = owner
|
||||||
slot.onExit = onExit
|
slot.onExit = onExit
|
||||||
slot.nice = nice
|
refill(app)
|
||||||
// during a game's start the pool drains instead: its refill would fork while the game starts
|
|
||||||
if (android.os.SystemClock.elapsedRealtime() >= launchUntil) refill(app)
|
|
||||||
// The worker execs once a byte comes through this socket: after the reply has reached us, so
|
// The worker execs once a byte comes through this socket: after the reply has reached us, so
|
||||||
// that its exec does not cut the reply off, and after the slot is marked started. Closed
|
// that its exec does not cut the reply off, and after the slot is marked started. Closed
|
||||||
// without one, the worker ends without running the program (the caller starts it another way).
|
// without one, the worker ends without running the program (the caller starts it another way).
|
||||||
@@ -482,22 +365,13 @@ object GuestWorkers {
|
|||||||
data.writeIntArray(targets)
|
data.writeIntArray(targets)
|
||||||
data.writeInt(if (guest) 0 else 1)
|
data.writeInt(if (guest) 0 else 1)
|
||||||
data.writeFileDescriptor(go[0].fileDescriptor)
|
data.writeFileDescriptor(go[0].fileDescriptor)
|
||||||
data.writeInt(nice)
|
slot.service!!.transact(GuestWorker.RUN, data, reply, 0)
|
||||||
val service = checkNotNull(slot.service)
|
|
||||||
if (testWorker != null) data.writeInt(FrameAcquireWorkerProbe.RECEIPT_TAG)
|
|
||||||
check(service.transact(GuestWorker.RUN, data, reply, 0))
|
|
||||||
// The worker has its own copy: with ours closed (and the request's, which holds one too),
|
// The worker has its own copy: with ours closed (and the request's, which holds one too),
|
||||||
// a worker that gave up leaves no reader
|
// a worker that gave up leaves no reader
|
||||||
data.recycle()
|
data.recycle()
|
||||||
data = null
|
data = null
|
||||||
go[0].close()
|
go[0].close()
|
||||||
val pid = reply.readInt()
|
val pid = reply.readInt()
|
||||||
val startTicks = if (testWorker != null) {
|
|
||||||
val size = reply.dataAvail()
|
|
||||||
if (size == FrameAcquireWorkerProbe.RECEIPT_BYTES)
|
|
||||||
FrameAcquireWorkerProbe.validReceipt(pid, reply.readInt(), reply.readLong(), size)
|
|
||||||
else 0L
|
|
||||||
} else 0L
|
|
||||||
// Once a session's teardown has begun (stopGuests), none of its programs may start: it
|
// Once a session's teardown has begun (stopGuests), none of its programs may start: it
|
||||||
// would not find them.
|
// would not find them.
|
||||||
val stopping = { guest && owner <= stopped }
|
val stopping = { guest && owner <= stopped }
|
||||||
@@ -526,12 +400,7 @@ object GuestWorkers {
|
|||||||
// launching slot), or never.
|
// launching slot), or never.
|
||||||
val answered = Os.poll(arrayOf(answer), ANSWER_TIMEOUT_MS) > 0 && Os.read(go[1].fileDescriptor, ByteArray(1), 0, 1) == 1
|
val answered = Os.poll(arrayOf(answer), ANSWER_TIMEOUT_MS) > 0 && Os.read(go[1].fileDescriptor, ByteArray(1), 0, 1) == 1
|
||||||
val accepted = answered && synchronized(authorizing) {
|
val accepted = answered && synchronized(authorizing) {
|
||||||
if (stopping() || !confirmed()) false
|
!stopping() && confirmed() && Os.write(go[1].fileDescriptor, byteArrayOf(1), 0, 1) == 1
|
||||||
else {
|
|
||||||
if (testWorker != null) FrameAcquireWorkerProbe.publish(testWorker, pid,
|
|
||||||
if (slot.service === service) startTicks else 0L)
|
|
||||||
Os.write(go[1].fileDescriptor, byteArrayOf(1), 0, 1) == 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val endedRunning = synchronized(slots) {
|
val endedRunning = synchronized(slots) {
|
||||||
slot.launching = false
|
slot.launching = false
|
||||||
@@ -629,33 +498,6 @@ object GuestWorkers {
|
|||||||
}, "guest-worker-warm").apply { isDaemon = true; start() }
|
}, "guest-worker-warm").apply { isDaemon = true; start() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A game is about to start: [LAUNCH_WORKERS] bound ahead, back to [WARM_WORKERS] once it is up. */
|
|
||||||
fun expectLaunch(context: Context) {
|
|
||||||
val app = context.applicationContext
|
|
||||||
val raised = synchronized(slots) { (warmTarget > 0).also { if (it) warmTarget = LAUNCH_WORKERS } }
|
|
||||||
if (!raised) return
|
|
||||||
launchUntil = android.os.SystemClock.elapsedRealtime() + LAUNCH_MS
|
|
||||||
val launch = launches.incrementAndGet()
|
|
||||||
refill(app)
|
|
||||||
Thread({
|
|
||||||
try {
|
|
||||||
Thread.sleep(LAUNCH_MS)
|
|
||||||
} catch (_: InterruptedException) {
|
|
||||||
return@Thread
|
|
||||||
}
|
|
||||||
if (launches.get() != launch) return@Thread
|
|
||||||
val extra = synchronized(slots) {
|
|
||||||
if (warmTarget != LAUNCH_WORKERS) emptyList()
|
|
||||||
else {
|
|
||||||
warmTarget = WARM_WORKERS
|
|
||||||
List((warm.size - WARM_WORKERS).coerceAtLeast(0)) { warm.removeLast() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
extra.forEach { release(app, it) }
|
|
||||||
refill(app)
|
|
||||||
}, "guest-worker-launch").apply { isDaemon = true; start() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun release(app: Context, slot: Slot) {
|
private fun release(app: Context, slot: Slot) {
|
||||||
var report = false
|
var report = false
|
||||||
val removed = synchronized(slots) {
|
val removed = synchronized(slots) {
|
||||||
@@ -708,7 +550,6 @@ object GuestWorkers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
context?.let { app -> drained.forEach { release(app, it) } }
|
context?.let { app -> drained.forEach { release(app, it) } }
|
||||||
FrameAcquireWorkerProbe.revoke(of)
|
|
||||||
val pids = guestPids(of)
|
val pids = guestPids(of)
|
||||||
if (pids.isEmpty()) return
|
if (pids.isEmpty()) return
|
||||||
pids.forEach { Process.sendSignal(it, OsConstants.SIGTERM) }
|
pids.forEach { Process.sendSignal(it, OsConstants.SIGTERM) }
|
||||||
@@ -721,35 +562,12 @@ object GuestWorkers {
|
|||||||
this.context = context.applicationContext
|
this.context = context.applicationContext
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Puts a running program's main thread back to its asker's priority after Android boosted it (once started, never stops). */
|
|
||||||
private fun keepPriorities() {
|
|
||||||
synchronized(this) {
|
|
||||||
if (keeper != null) return
|
|
||||||
keeper = Thread({
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
Thread.sleep(PRIORITY_CHECK_MS)
|
|
||||||
} catch (_: InterruptedException) {
|
|
||||||
return@Thread
|
|
||||||
}
|
|
||||||
val running = synchronized(slots) {
|
|
||||||
slots.filterNotNull().filter { it.started && it.pid > 0 && it.nice != TOP_APP_BOOST }
|
|
||||||
}
|
|
||||||
for (s in running) runCatching {
|
|
||||||
if (Process.getThreadPriority(s.pid) == TOP_APP_BOOST) Process.setThreadPriority(s.pid, s.nice)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, "guest-worker-priority").apply { isDaemon = true; start() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Starts a session's use of the workers (and the spawn socket, once); returns its number. */
|
/** Starts a session's use of the workers (and the spawn socket, once); returns its number. */
|
||||||
fun serve(context: Context): Int {
|
fun serve(context: Context): Int {
|
||||||
val app = context.applicationContext
|
val app = context.applicationContext
|
||||||
this.context = app
|
this.context = app
|
||||||
val number = synchronized(slots) { warmTarget = WARM_WORKERS; ++session }
|
val number = synchronized(slots) { warmTarget = WARM_WORKERS; ++session }
|
||||||
refill(app)
|
refill(app)
|
||||||
keepPriorities()
|
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
if (server != null) return number
|
if (server != null) return number
|
||||||
server = Thread({
|
server = Thread({
|
||||||
@@ -924,21 +742,16 @@ object GuestWorkers {
|
|||||||
// A request that names none is refused (start() runs nothing for session 0): the hook and
|
// A request that names none is refused (start() runs nothing for session 0): the hook and
|
||||||
// droiddeck-spawn always name it, and which session's it is cannot be told otherwise.
|
// droiddeck-spawn always name it, and which session's it is cannot be told otherwise.
|
||||||
val owner = request.optInt("session", 0).coerceAtLeast(0)
|
val owner = request.optInt("session", 0).coerceAtLeast(0)
|
||||||
// The sender is the forked child (or droiddeck-spawn): its priority is the one the program would inherit
|
val pid = start(app, command, env.map { (k, v) -> "$k=$v" }, programFds, targets, true, owner = owner, onExit = { code ->
|
||||||
val nice = runCatching { Process.getThreadPriority(client.peerCredentials.pid) }.getOrDefault(Process.THREAD_PRIORITY_DEFAULT)
|
|
||||||
val testWorker = FrameAcquireWorkerProbe.match(owner, root, file, argv, ack)
|
|
||||||
val pid = start(app, command, env.map { (k, v) -> "$k=$v" }, programFds, targets, true, owner = owner, nice = nice, onExit = { code ->
|
|
||||||
if (testWorker != null && worker > 1) FrameAcquireWorkerProbe.revoke(owner, worker)
|
|
||||||
status = code
|
status = code
|
||||||
if (table != null && slot >= 0) reportExit(table, slot, code, parent, child, worker)
|
if (table != null && slot >= 0) reportExit(table, slot, code, parent, child, worker)
|
||||||
exited.countDown()
|
exited.countDown()
|
||||||
}, confirmed = {
|
}, confirmed = {
|
||||||
val confirmed = !ack || runCatching {
|
!ack || runCatching {
|
||||||
out.write("ok\n".toByteArray())
|
out.write("ok\n".toByteArray())
|
||||||
out.flush()
|
out.flush()
|
||||||
confirmedToHook = true
|
confirmedToHook = true
|
||||||
}.isSuccess
|
}.isSuccess
|
||||||
confirmed
|
|
||||||
}, commit = { started ->
|
}, commit = { started ->
|
||||||
worker = started
|
worker = started
|
||||||
if (!ack) return@start true
|
if (!ack) return@start true
|
||||||
@@ -957,8 +770,7 @@ object GuestWorkers {
|
|||||||
}
|
}
|
||||||
ended && line.toString() == "go"
|
ended && line.toString() == "go"
|
||||||
}.getOrDefault(false)
|
}.getOrDefault(false)
|
||||||
}, testWorker = testWorker)
|
})
|
||||||
if (pid <= 0 && testWorker != null && worker > 1) FrameAcquireWorkerProbe.revoke(owner, worker)
|
|
||||||
handedOver = true
|
handedOver = true
|
||||||
programFds.filter { it !== table }.forEach { runCatching { it.close() } }
|
programFds.filter { it !== table }.forEach { runCatching { it.close() } }
|
||||||
if (pid <= 0) table?.let { runCatching { it.close() } }
|
if (pid <= 0) table?.let { runCatching { it.close() } }
|
||||||
|
|||||||
@@ -35,40 +35,9 @@ object LegacyNames {
|
|||||||
@Synchronized
|
@Synchronized
|
||||||
fun migrateEtc(root: File) {
|
fun migrateEtc(root: File) {
|
||||||
for ((old, new) in LINKED_DIRS) moveAndLink(File(root, old), File(root, new))
|
for ((old, new) in LINKED_DIRS) moveAndLink(File(root, old), File(root, new))
|
||||||
clearEmptyStandIn(root)
|
File(root, "etc/droiddeck/empty").mkdirs()
|
||||||
File(root, NO_THERMAL).mkdirs()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* It stands in for /sys/bus/pci/devices, and libpci exits the whole process on an entry it cannot
|
|
||||||
* parse; older builds let thermal bind mount points leak into it. The guest can write here, so a
|
|
||||||
* link is never followed: one in place of the folder is removed, and one above it stops the cleanup.
|
|
||||||
*/
|
|
||||||
private fun clearEmptyStandIn(root: File) {
|
|
||||||
val linkedAbove = listOf("etc", "etc/droiddeck").firstOrNull { Files.isSymbolicLink(File(root, it).toPath()) }
|
|
||||||
if (linkedAbove != null) {
|
|
||||||
Log.w(TAG, "not clearing the empty stand-in: $linkedAbove is a link")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val empty = File(root, "etc/droiddeck/empty")
|
|
||||||
if (Files.isSymbolicLink(empty.toPath())) runCatching { Files.delete(empty.toPath()) }
|
|
||||||
.onFailure { Log.w(TAG, "could not remove the link at $empty", it); return }
|
|
||||||
empty.mkdirs()
|
|
||||||
empty.listFiles()?.forEach { entry ->
|
|
||||||
runCatching { deleteWithoutFollowing(entry.toPath()) }.onFailure { Log.w(TAG, "could not clear $entry", it) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun deleteWithoutFollowing(path: java.nio.file.Path) {
|
|
||||||
if (Files.isDirectory(path, java.nio.file.LinkOption.NOFOLLOW_LINKS)) {
|
|
||||||
Files.newDirectoryStream(path).use { entries -> entries.forEach(::deleteWithoutFollowing) }
|
|
||||||
}
|
|
||||||
Files.deleteIfExists(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Stands in for a /sys/class/thermal the kernel won't list; proot adds the bound zones' mount points to it. */
|
|
||||||
const val NO_THERMAL = "etc/droiddeck/no-thermal"
|
|
||||||
|
|
||||||
@Synchronized
|
@Synchronized
|
||||||
fun migrateRootfs(root: File) {
|
fun migrateRootfs(root: File) {
|
||||||
migrateEtc(root)
|
migrateEtc(root)
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ public final class LinuxRuntime {
|
|||||||
// A kernel that refuses to list /sys/class/thermal (Pixel 10, Android 17) made mangoapp abort
|
// 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
|
// at start ("filesystem_error ... Permission denied: '/sys/class/thermal/'") until its
|
||||||
// wrapper gave up: it lists the directory for CPU temperatures. Empty there instead.
|
// 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, LegacyNames.NO_THERMAL).getPath() + ":/sys/class/thermal");
|
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.getFilesDir().getPath());
|
||||||
bind(cmd, context.getCacheDir().getPath());
|
bind(cmd, context.getCacheDir().getPath());
|
||||||
bind(cmd, liveDir(context).getPath());
|
bind(cmd, liveDir(context).getPath());
|
||||||
|
|||||||
@@ -24,16 +24,6 @@ object NativeGuest {
|
|||||||
fun enabled(context: Context): Boolean =
|
fun enabled(context: Context): Boolean =
|
||||||
SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context))
|
SessionPrefs.nativeUserland(context) && available(LinuxRuntime.rootDir(context))
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the next session will start natively. The session stages the hook from the APK before
|
|
||||||
* it starts, so only the setting and the rootfs's loader decide, and a runtime still to be
|
|
||||||
* installed will have one.
|
|
||||||
*/
|
|
||||||
fun nextSession(context: Context): Boolean =
|
|
||||||
SessionPrefs.nativeUserland(context) && willRun(LinuxRuntime.rootDir(context), LinuxRuntime.isInstalled(context))
|
|
||||||
|
|
||||||
internal fun willRun(root: File, installed: Boolean): Boolean = !installed || loader(root) != null
|
|
||||||
|
|
||||||
/** The mode the running session started in; null between sessions. */
|
/** The mode the running session started in; null between sessions. */
|
||||||
@Volatile var sessionMode: Boolean? = null
|
@Volatile var sessionMode: Boolean? = null
|
||||||
|
|
||||||
|
|||||||
@@ -219,19 +219,6 @@ object BottomDesktop {
|
|||||||
|
|
||||||
fun sendText(text: String) {
|
fun sendText(text: String) {
|
||||||
val target = service ?: return
|
val target = service ?: return
|
||||||
if (text.isNotEmpty() && text.all { it == '\r' || it == '\n' || it == '\b' || it == '\u007f' || it == '\t' }) {
|
|
||||||
for (c in text) {
|
|
||||||
val evdev = when (c) {
|
|
||||||
'\r', '\n' -> 28
|
|
||||||
'\b' -> 14
|
|
||||||
'\u007f' -> 111
|
|
||||||
else -> 15
|
|
||||||
}
|
|
||||||
sendKey(evdev, true)
|
|
||||||
sendKey(evdev, false)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
send(target, Message.obtain(null, Comp.MSG_TEXT).apply { data = Bundle().apply { putString(Comp.KEY_TEXT, text) } })
|
send(target, Message.obtain(null, Comp.MSG_TEXT).apply { data = Bundle().apply { putString(Comp.KEY_TEXT, text) } })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,6 @@ object ComponentsManager {
|
|||||||
private const val DD_COMPONENTS = "Droid-Deck/DroidDeck-Components"
|
private const val DD_COMPONENTS = "Droid-Deck/DroidDeck-Components"
|
||||||
internal const val DD_NIGHTLY = "linux-nightly"
|
internal const val DD_NIGHTLY = "linux-nightly"
|
||||||
internal const val DD_BIONIC = "bionic-stable"
|
internal const val DD_BIONIC = "bionic-stable"
|
||||||
/** FEX for original Xbox games on DroidDeck-Bionic: kept apart from [DD_BIONIC] so automatic FEX updates never pick it. */
|
|
||||||
internal const val DD_XBOX = "bionic-xbox"
|
|
||||||
private val RELEASES = linkedMapOf(
|
private val RELEASES = linkedMapOf(
|
||||||
"FexCore-Linux" to "fex",
|
"FexCore-Linux" to "fex",
|
||||||
"Dxvk-Linux" to "dxvk",
|
"Dxvk-Linux" to "dxvk",
|
||||||
@@ -40,8 +38,7 @@ object ComponentsManager {
|
|||||||
"Vkd3d-proton-Linux" to "vkd3d",
|
"Vkd3d-proton-Linux" to "vkd3d",
|
||||||
)
|
)
|
||||||
private val NIGHTLY_PREFIXES = linkedMapOf("DD-dxvk-" to "dxvk", "DD-vkd3d-proton-" to "vkd3d", "DD-FEXCore-" to "fex")
|
private val NIGHTLY_PREFIXES = linkedMapOf("DD-dxvk-" to "dxvk", "DD-vkd3d-proton-" to "vkd3d", "DD-FEXCore-" to "fex")
|
||||||
private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC) +
|
private val SOURCES = RELEASES.keys.map { NIGHTLIES to it } + (DD_COMPONENTS to DD_NIGHTLY) + (DD_COMPONENTS to DD_BIONIC)
|
||||||
(DD_COMPONENTS to DD_XBOX)
|
|
||||||
private val DOWNLOAD_REPOS = listOf(NIGHTLIES, DD_COMPONENTS)
|
private val DOWNLOAD_REPOS = listOf(NIGHTLIES, DD_COMPONENTS)
|
||||||
private val TYPES = mapOf("FEXCore-Linux" to "fex", "FEXCore-Bionic" to "fex", "DXVK-Linux" to "dxvk", "VKD3D-Linux" to "vkd3d")
|
private val TYPES = mapOf("FEXCore-Linux" to "fex", "FEXCore-Bionic" to "fex", "DXVK-Linux" to "dxvk", "VKD3D-Linux" to "vkd3d")
|
||||||
private val TYPE_OF = mapOf("fex" to "FEXCore-Linux", "dxvk" to "DXVK-Linux", "vkd3d" to "VKD3D-Linux")
|
private val TYPE_OF = mapOf("fex" to "FEXCore-Linux", "dxvk" to "DXVK-Linux", "vkd3d" to "VKD3D-Linux")
|
||||||
@@ -256,28 +253,6 @@ object ComponentsManager {
|
|||||||
saveState(context, state)
|
saveState(context, state)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum class Assigned { SET, NOT_LISTED, CHANGED }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets a game's component to a listed package, fetching it first when it is not stored. [expected] is the component
|
|
||||||
* the caller read when it decided: if the game's component is something else once the package is ready (the player
|
|
||||||
* chose one during the download), nothing is written. [onSet] runs under the same lock as the write.
|
|
||||||
*/
|
|
||||||
internal fun assignGameComponent(context: Context, scope: String, comp: String, file: String, release: String,
|
|
||||||
expected: String?, onSet: () -> Unit = {}): Assigned {
|
|
||||||
val wcp = File(packagesDir(context), safeName(file))
|
|
||||||
if (!wcp.isFile || runCatching { packageInfo(context, wcp) }.isFailure) {
|
|
||||||
wcp.delete()
|
|
||||||
download(context, catalogItem(context, file, release) ?: return Assigned.NOT_LISTED) {}
|
|
||||||
}
|
|
||||||
synchronized(lock) {
|
|
||||||
if (gameComponents(context, scope)[comp] != expected) return Assigned.CHANGED
|
|
||||||
setGameComponent(context, scope, comp, file) { runtimeManaged(context, it) }
|
|
||||||
onSet()
|
|
||||||
}
|
|
||||||
return Assigned.SET
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearGameComponents(context: Context, scope: String) = synchronized(lock) {
|
fun clearGameComponents(context: Context, scope: String) = synchronized(lock) {
|
||||||
require(GameEnvironment.validScope(scope))
|
require(GameEnvironment.validScope(scope))
|
||||||
val state = loadState(context)
|
val state = loadState(context)
|
||||||
@@ -1149,7 +1124,7 @@ object ComponentsManager {
|
|||||||
|
|
||||||
internal fun assetComp(release: String, name: String): String? = RELEASES[release] ?: when (release) {
|
internal fun assetComp(release: String, name: String): String? = RELEASES[release] ?: when (release) {
|
||||||
DD_NIGHTLY -> NIGHTLY_PREFIXES.entries.firstOrNull { name.startsWith(it.key) }?.value
|
DD_NIGHTLY -> NIGHTLY_PREFIXES.entries.firstOrNull { name.startsWith(it.key) }?.value
|
||||||
DD_BIONIC, DD_XBOX -> "fex"
|
DD_BIONIC -> "fex"
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -268,7 +268,7 @@ internal object EnhancedSessionLogShare {
|
|||||||
val out = outputDirectory.apply { deleteRecursively(); mkdirs() }
|
val out = outputDirectory.apply { deleteRecursively(); mkdirs() }
|
||||||
val redactionLearningComplete = LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
val redactionLearningComplete = LogRedactor.learnFromRuntime(LinuxRuntime.rootDir(context))
|
||||||
val discovery = collect(context, folder, limits.maxDiscoveredFiles, legacy = true)
|
val discovery = collect(context, folder, limits.maxDiscoveredFiles, legacy = true)
|
||||||
val candidates = discovery.candidates.filter { it.linePrefix == null }.sortedBy(::sharePriority)
|
val candidates = discovery.candidates.filter { it.linePrefix == null }
|
||||||
if (candidates.isEmpty()) {
|
if (candidates.isEmpty()) {
|
||||||
out.deleteRecursively()
|
out.deleteRecursively()
|
||||||
return null
|
return null
|
||||||
@@ -697,6 +697,15 @@ internal object EnhancedSessionLogShare {
|
|||||||
Category.GAMES, "DROIDDECK_DIAGNOSTICS event=game_",
|
Category.GAMES, "DROIDDECK_DIAGNOSTICS event=game_",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (SessionPaths.current()?.canonicalFile == folder.canonicalFile && !File(folder, "steam").exists()) {
|
||||||
|
val steam = File(SessionPrefs.activeSteamRoot(context), "logs")
|
||||||
|
val scan = directFiles(steam, remaining(maxFiles, out.size))
|
||||||
|
truncated = truncated || scan.truncated
|
||||||
|
partial = partial || scan.partial
|
||||||
|
scan.files.forEach {
|
||||||
|
add(it, steam, "${folder.name}/steam/${it.name}", "live-steam")
|
||||||
|
}
|
||||||
|
}
|
||||||
val logs = LinuxRuntime.logDir(context)
|
val logs = LinuxRuntime.logDir(context)
|
||||||
for ((name, root) in listOf(SessionLogShare.STORES_DIR to File(logs, SessionLogShare.STORES_DIR), SessionPaths.TOOLS_DIR to File(logs, SessionPaths.TOOLS_DIR))) {
|
for ((name, root) in listOf(SessionLogShare.STORES_DIR to File(logs, SessionLogShare.STORES_DIR), SessionPaths.TOOLS_DIR to File(logs, SessionPaths.TOOLS_DIR))) {
|
||||||
val scan = directFiles(root, STORE_LOG_SCAN)
|
val scan = directFiles(root, STORE_LOG_SCAN)
|
||||||
@@ -733,24 +742,9 @@ internal object EnhancedSessionLogShare {
|
|||||||
if (relative == EnhancedDiagnostics.MANIFEST_FILE) return@forEach
|
if (relative == EnhancedDiagnostics.MANIFEST_FILE) return@forEach
|
||||||
add(file, folder, "${folder.name}/$relative", "session")
|
add(file, folder, "${folder.name}/$relative", "session")
|
||||||
}
|
}
|
||||||
if (SessionPaths.current()?.canonicalFile == folder.canonicalFile && !File(folder, "steam").exists()) {
|
|
||||||
val steam = File(SessionPrefs.activeSteamRoot(context), "logs")
|
|
||||||
val scan = directFiles(steam, remaining(maxFiles, out.size))
|
|
||||||
truncated = truncated || scan.truncated
|
|
||||||
partial = partial || scan.partial
|
|
||||||
scan.files.forEach {
|
|
||||||
add(it, steam, "${folder.name}/steam/${it.name}", "live-steam")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CollectionResult(out.values.toList(), truncated, partial)
|
return CollectionResult(out.values.toList(), truncated, partial)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun sharePriority(candidate: Candidate): Int = when {
|
|
||||||
candidate.origin == "session-critical" -> 0
|
|
||||||
candidate.origin == "session" && candidate.category == Category.GAMES -> 1
|
|
||||||
else -> 2
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun remaining(maxFiles: Int, found: Int): Int = (maxFiles - found + 1).coerceAtLeast(0)
|
private fun remaining(maxFiles: Int, found: Int): Int = (maxFiles - found + 1).coerceAtLeast(0)
|
||||||
|
|
||||||
private fun walk(root: File, limit: Int): ScanResult {
|
private fun walk(root: File, limit: Int): ScanResult {
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
package com.droiddeck.launcher.session
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
internal object PageCacheTrim {
|
|
||||||
private const val TAG = "PageCacheTrim"
|
|
||||||
private const val MIN_FILE_BYTES = 8L shl 20
|
|
||||||
private const val POLL_MS = 3000L
|
|
||||||
private const val RESCAN_MS = 120_000L
|
|
||||||
|
|
||||||
data class Mem(val freeKb: Long, val fileKb: Long)
|
|
||||||
|
|
||||||
fun parse(meminfo: String): Mem? {
|
|
||||||
fun field(name: String) = Regex("""(?m)^$name:\s+(\d+) kB""").find(meminfo)?.groupValues?.get(1)?.toLongOrNull()
|
|
||||||
val free = field("MemFree") ?: return null
|
|
||||||
val file = (field("Active\\(file\\)") ?: return null) + (field("Inactive\\(file\\)") ?: return null)
|
|
||||||
return Mem(free, file)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun shouldTrim(mem: Mem, baselineFileKb: Long): Boolean {
|
|
||||||
val built = mem.fileKb - baselineFileKb
|
|
||||||
return (mem.freeKb < 2560 * 1024 && built >= 768 * 1024) ||
|
|
||||||
(mem.freeKb < 1024 * 1024 && built >= 128 * 1024)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun start(roots: () -> List<File>, alive: () -> Boolean) {
|
|
||||||
Thread({
|
|
||||||
var baseline = 0L
|
|
||||||
var files = emptyList<File>()
|
|
||||||
var scanned = 0L
|
|
||||||
var trims = 0
|
|
||||||
var failureLogged = false
|
|
||||||
while (alive()) {
|
|
||||||
runCatching {
|
|
||||||
val mem = parse(File("/proc/meminfo").readText())
|
|
||||||
if (mem != null && shouldTrim(mem, baseline)) {
|
|
||||||
val now = System.currentTimeMillis()
|
|
||||||
if (now - scanned > RESCAN_MS) {
|
|
||||||
files = roots().flatMap { root -> root.walkTopDown().onEnter { !java.nio.file.Files.isSymbolicLink(it.toPath()) }.filter { it.isFile && it.length() >= MIN_FILE_BYTES }.toList() }
|
|
||||||
scanned = now
|
|
||||||
}
|
|
||||||
val began = System.nanoTime()
|
|
||||||
files.forEach(::drop)
|
|
||||||
val after = parse(File("/proc/meminfo").readText())
|
|
||||||
baseline = after?.fileKb ?: mem.fileKb
|
|
||||||
trims++
|
|
||||||
Log.i(TAG, "trim #$trims: free ${mem.freeKb / 1024} -> ${after?.freeKb?.div(1024)} MB, file cache ${mem.fileKb / 1024} -> ${after?.fileKb?.div(1024)} MB, ${files.size} files, ${(System.nanoTime() - began) / 1_000_000} ms")
|
|
||||||
}
|
|
||||||
}.onFailure {
|
|
||||||
if (!failureLogged) Log.w(TAG, "trim failed: $it")
|
|
||||||
failureLogged = true
|
|
||||||
}
|
|
||||||
Thread.sleep(POLL_MS)
|
|
||||||
}
|
|
||||||
}, "page-cache-trim").apply { isDaemon = true }.start()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun drop(file: File) {
|
|
||||||
PageCacheNative.fadviseDontNeed(file.path)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal object PageCacheNative {
|
|
||||||
init {
|
|
||||||
System.loadLibrary("sdnative")
|
|
||||||
}
|
|
||||||
|
|
||||||
@JvmStatic external fun fadviseDontNeed(path: String): Int
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,6 @@ import com.droiddeck.launcher.core.Downloader
|
|||||||
import com.droiddeck.launcher.core.FileUtils
|
import com.droiddeck.launcher.core.FileUtils
|
||||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||||
import com.droiddeck.launcher.runtime.NativeGuest
|
import com.droiddeck.launcher.runtime.NativeGuest
|
||||||
import com.droiddeck.launcher.storage.SteamStorage
|
|
||||||
import com.droiddeck.launcher.stores.steam.SteamClient
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
@@ -36,9 +34,7 @@ object ProtonExtras {
|
|||||||
private var replacing = false
|
private var replacing = false
|
||||||
|
|
||||||
class Tool(val id: String, val name: String, val prefix: String, val repo: String, val assetPattern: Regex,
|
class Tool(val id: String, val name: String, val prefix: String, val repo: String, val assetPattern: Regex,
|
||||||
val prereleases: Boolean = false, val x86_64: Boolean = false, val label: Int = 0) {
|
val prereleases: Boolean = false)
|
||||||
val arch: String get() = if (x86_64) "x86-64" else "ARM64"
|
|
||||||
}
|
|
||||||
|
|
||||||
internal data class Asset(val tag: String, val name: String, val url: String, val sha512: String?, val size: Long,
|
internal data class Asset(val tag: String, val name: String, val url: String, val sha512: String?, val size: Long,
|
||||||
val sha256: String? = null, val releaseName: String = tag)
|
val sha256: String? = null, val releaseName: String = tag)
|
||||||
@@ -46,13 +42,11 @@ object ProtonExtras {
|
|||||||
|
|
||||||
const val OWN = "droiddeck"
|
const val OWN = "droiddeck"
|
||||||
const val BIONIC = "bionic"
|
const val BIONIC = "bionic"
|
||||||
const val ANTICHEAT = "anticheat"
|
|
||||||
|
|
||||||
val tools = listOf(
|
val tools = listOf(
|
||||||
Tool("ge", "GE-Proton", "GE-Proton", "GloriousEggroll/proton-ge-custom", Regex("aarch64\\.tar\\.(gz|xz)$")),
|
Tool("ge", "GE-Proton", "GE-Proton", "GloriousEggroll/proton-ge-custom", Regex("aarch64\\.tar\\.(gz|xz)$")),
|
||||||
Tool("cachyos", "proton-cachyos", "proton-cachyos", "CachyOS/proton-cachyos", Regex("arm64\\.tar\\.(gz|xz)$")),
|
Tool("cachyos", "proton-cachyos", "proton-cachyos", "CachyOS/proton-cachyos", Regex("arm64\\.tar\\.(gz|xz)$")),
|
||||||
Tool("droiddeck", "DroidDeck-Proton", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Proton-.*aarch64\\.tar\\.(gz|xz)$")),
|
Tool("droiddeck", "DroidDeck-Proton", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Proton-.*aarch64\\.tar\\.(gz|xz)$")),
|
||||||
Tool(ANTICHEAT, "DroidDeck-Proton x86-64", "DroidDeck-Proton", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Proton-.*x86_64\\.tar\\.(gz|xz)$"), x86_64 = true, label = R.string.pextra_anticheat),
|
|
||||||
// Bionic (Android libc) Proton started outside the Linux userland; test builds are prereleases. No-proot only.
|
// Bionic (Android libc) Proton started outside the Linux userland; test builds are prereleases. No-proot only.
|
||||||
Tool(BIONIC, "DroidDeck-Bionic", "DroidDeck-Bionic", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Bionic-.*aarch64\\.tar\\.(gz|xz)$"), prereleases = true),
|
Tool(BIONIC, "DroidDeck-Bionic", "DroidDeck-Bionic", "Droid-Deck/DroidDeck-Proton", Regex("^DroidDeck-Bionic-.*aarch64\\.tar\\.(gz|xz)$"), prereleases = true),
|
||||||
)
|
)
|
||||||
@@ -72,14 +66,11 @@ object ProtonExtras {
|
|||||||
|
|
||||||
internal fun installedIn(dir: File, tool: Tool): List<String> =
|
internal fun installedIn(dir: File, tool: Tool): List<String> =
|
||||||
dir.listFiles()
|
dir.listFiles()
|
||||||
?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && x86_64Build(it) == tool.x86_64 && usable(it) }
|
?.filter { it.isDirectory && it.name.startsWith(tool.prefix) && usable(it) }
|
||||||
?.map { it.name }
|
?.map { it.name }
|
||||||
?.sortedWith { a, b -> compareVersions(a, b) }
|
?.sortedWith { a, b -> compareVersions(a, b) }
|
||||||
?: emptyList()
|
?: emptyList()
|
||||||
|
|
||||||
internal fun x86_64Build(dir: File): Boolean =
|
|
||||||
File(dir, "files/lib/wine/x86_64-unix").isDirectory && !File(dir, "files/bin-arm64").isDirectory
|
|
||||||
|
|
||||||
private fun usable(dir: File): Boolean {
|
private fun usable(dir: File): Boolean {
|
||||||
val manifest = runCatching { File(dir, "toolmanifest.vdf").readText() }.getOrNull() ?: return false
|
val manifest = runCatching { File(dir, "toolmanifest.vdf").readText() }.getOrNull() ?: return false
|
||||||
val command = Regex("\\\"commandline\\\"\\s+\\\"/?([^\\\" ]+)").find(manifest)?.groupValues?.getOrNull(1) ?: return false
|
val command = Regex("\\\"commandline\\\"\\s+\\\"/?([^\\\" ]+)").find(manifest)?.groupValues?.getOrNull(1) ?: return false
|
||||||
@@ -117,31 +108,15 @@ object ProtonExtras {
|
|||||||
|
|
||||||
fun update(context: Context, tool: Tool): String? = updateFor(installedTags(context, tool), cachedLatest(context, tool))
|
fun update(context: Context, tool: Tool): String? = updateFor(installedTags(context, tool), cachedLatest(context, tool))
|
||||||
|
|
||||||
fun missing(context: Context, tool: Tool): String? = missing(context, tool) { antiCheatRuntimeInstalled(context) }
|
fun missing(context: Context, tool: Tool): String? =
|
||||||
|
if (tool.id == OWN && !declined(context) && installedAll(context, tool).isEmpty()) cachedLatest(context, tool) else null
|
||||||
internal fun missing(context: Context, tool: Tool, antiCheat: () -> Boolean): String? = when {
|
|
||||||
declined(context, tool.id) || installedAll(context, tool).isNotEmpty() -> null
|
|
||||||
tool.id == OWN || tool.id == ANTICHEAT && antiCheat() -> cachedLatest(context, tool)
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun antiCheatRuntimeInstalled(context: Context): Boolean =
|
|
||||||
antiCheatRuntimeIn(listOf("arm64", SteamClient.X86_64).flatMap { arch ->
|
|
||||||
runCatching { SteamClient.libraries(context, arch).map { it.host } }.getOrDefault(emptyList())
|
|
||||||
} + listOfNotNull(GameStorage.effective(context)?.let { File(it.path) }, GameStorage.x64CardLibrary(context)))
|
|
||||||
|
|
||||||
internal fun antiCheatRuntimeIn(libraries: List<File>): Boolean = libraries.any { library ->
|
|
||||||
ANTICHEAT_RUNTIMES.any { File(library, "steamapps/appmanifest_$it.acf").isFile }
|
|
||||||
}
|
|
||||||
|
|
||||||
private val ANTICHEAT_RUNTIMES = listOf(SteamStorage.EAC_RUNTIME, SteamStorage.BATTLEYE_RUNTIME)
|
|
||||||
|
|
||||||
private fun choices(context: Context) = context.getSharedPreferences("proton-auto-updates", Context.MODE_PRIVATE)
|
private fun choices(context: Context) = context.getSharedPreferences("proton-auto-updates", Context.MODE_PRIVATE)
|
||||||
|
|
||||||
fun declined(context: Context, id: String = OWN): Boolean = choices(context).getBoolean("$id.declined", false)
|
fun declined(context: Context): Boolean = choices(context).getBoolean("$OWN.declined", false)
|
||||||
|
|
||||||
fun setDeclined(context: Context, declined: Boolean, id: String = OWN) {
|
fun setDeclined(context: Context, declined: Boolean) {
|
||||||
choices(context).edit().putBoolean("$id.declined", declined).apply()
|
choices(context).edit().putBoolean("$OWN.declined", declined).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cachedLatest(context: Context, tool: Tool): String? =
|
fun cachedLatest(context: Context, tool: Tool): String? =
|
||||||
@@ -245,8 +220,8 @@ object ProtonExtras {
|
|||||||
if (runCatching { ComponentsManager.carryOver(context, old, newest) }.onFailure { Log.w(TAG, "components of $old", it) }.isFailure) continue
|
if (runCatching { ComponentsManager.carryOver(context, old, newest) }.onFailure { Log.w(TAG, "components of $old", it) }.isFailure) continue
|
||||||
if (runCatching { keepUserSettings(context, old, newest) }.onFailure { Log.w(TAG, "user settings of $old", it) }.isFailure) continue
|
if (runCatching { keepUserSettings(context, old, newest) }.onFailure { Log.w(TAG, "user settings of $old", it) }.isFailure) continue
|
||||||
if (runCatching { ProtonDefault.moveGames(context, setOf(old), newest) }.onFailure { Log.w(TAG, "per-game picks of $old", it) }.isFailure) continue
|
if (runCatching { ProtonDefault.moveGames(context, setOf(old), newest) }.onFailure { Log.w(TAG, "per-game picks of $old", it) }.isFailure) continue
|
||||||
// DroidDeck-Bionic and the x86-64 build: the guest finds no default for a deleted build and falls back to DroidDeck-Proton
|
// DroidDeck-Bionic only: the guest finds no default for a deleted Bionic build and falls back to DroidDeck-Proton
|
||||||
if ((tool.id == BIONIC || tool.id == ANTICHEAT) && runCatching { ProtonDefault.moveDefault(context, setOf(old), newest) }.onFailure { Log.w(TAG, "default pick of $old", it) }.isFailure) continue
|
if (tool.id == BIONIC && runCatching { ProtonDefault.moveDefault(context, setOf(old), newest) }.onFailure { Log.w(TAG, "default pick of $old", it) }.isFailure) continue
|
||||||
if (deleteTool(context, old)) ComponentsManager.forgetProton(context, old)
|
if (deleteTool(context, old)) ComponentsManager.forgetProton(context, old)
|
||||||
else Log.w(TAG, "could not remove $old")
|
else Log.w(TAG, "could not remove $old")
|
||||||
}
|
}
|
||||||
@@ -313,7 +288,7 @@ object ProtonExtras {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun prefetchNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? {
|
private fun prefetchNow(context: Context, tool: Tool, onProgress: (String, Int) -> Unit): String? {
|
||||||
val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name, tool.arch)
|
val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name)
|
||||||
val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() }
|
val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() }
|
||||||
val archive = File(downloads, "${tool.id}-${asset.name}")
|
val archive = File(downloads, "${tool.id}-${asset.name}")
|
||||||
if (asset.size > 0 && archive.length() > asset.size) archive.delete()
|
if (asset.size > 0 && archive.length() > asset.size) archive.delete()
|
||||||
@@ -330,7 +305,7 @@ object ProtonExtras {
|
|||||||
if (SessionState.running) return context.getString(R.string.pextra_stop_session)
|
if (SessionState.running) return context.getString(R.string.pextra_stop_session)
|
||||||
if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required)
|
if (!LinuxRuntime.isInstalled(context)) return context.getString(R.string.user_apps_runtime_required)
|
||||||
|
|
||||||
val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name, tool.arch)
|
val asset = releases(tool)?.let { pickAsset(tool, it) } ?: return context.getString(R.string.pextra_no_release, tool.name)
|
||||||
val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() }
|
val downloads = File(context.filesDir, "proton-downloads").apply { mkdirs() }
|
||||||
val archive = File(downloads, "${tool.id}-${asset.name}")
|
val archive = File(downloads, "${tool.id}-${asset.name}")
|
||||||
if (asset.size > 0 && archive.length() > asset.size) archive.delete()
|
if (asset.size > 0 && archive.length() > asset.size) archive.delete()
|
||||||
@@ -399,7 +374,7 @@ object ProtonExtras {
|
|||||||
archive.delete()
|
archive.delete()
|
||||||
unqueue(context, tool)
|
unqueue(context, tool)
|
||||||
record(context, tool, placed, asset.tag)
|
record(context, tool, placed, asset.tag)
|
||||||
if (tool.id == OWN || tool.id == BIONIC || tool.id == ANTICHEAT) replaceOlder(context, tool)
|
if (tool.id == OWN || tool.id == BIONIC) replaceOlder(context, tool)
|
||||||
if (EsyncPacks.enabled(context)) {
|
if (EsyncPacks.enabled(context)) {
|
||||||
onProgress(context.getString(R.string.esync_fetching), -1)
|
onProgress(context.getString(R.string.esync_fetching), -1)
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ object SessionDisplay {
|
|||||||
const val LINK_PORTRAIT = "link/portrait"
|
const val LINK_PORTRAIT = "link/portrait"
|
||||||
|
|
||||||
const val DEFAULT_RESOLUTION = "720p"
|
const val DEFAULT_RESOLUTION = "720p"
|
||||||
const val DEFAULT_STEAM_PORTRAIT_RESOLUTION = "1280x800"
|
|
||||||
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
||||||
|
|
||||||
fun presetHeight(choice: String): Int? =
|
fun presetHeight(choice: String): Int? =
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.droiddeck.launcher.runtime.DesktopCatalog
|
|||||||
import com.droiddeck.launcher.runtime.LegacyNames
|
import com.droiddeck.launcher.runtime.LegacyNames
|
||||||
import com.droiddeck.launcher.runtime.LinuxRuntime
|
import com.droiddeck.launcher.runtime.LinuxRuntime
|
||||||
import com.droiddeck.launcher.runtime.ProotFastPath
|
import com.droiddeck.launcher.runtime.ProotFastPath
|
||||||
import org.json.JSONObject
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
object SessionFiles {
|
object SessionFiles {
|
||||||
@@ -22,8 +21,6 @@ object SessionFiles {
|
|||||||
private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad"
|
private const val NO_PAD_SWITCH = "Download/droiddeck-no-pad"
|
||||||
const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio"
|
const val DIRECTAUDIO_DIR = "usr/local/lib/directaudio"
|
||||||
private const val STAGED_LEDGER = "usr/local/.droiddeck-staged"
|
private const val STAGED_LEDGER = "usr/local/.droiddeck-staged"
|
||||||
private const val IME_MANIFEST = "usr/local/share/droiddeck/ime-files.json"
|
|
||||||
private const val IME_DEFAULT_MODE = 420
|
|
||||||
val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread")
|
val DIRECTAUDIO_SETS = arrayOf("linux-wine11", "linux-wine11-systhread")
|
||||||
|
|
||||||
internal val DESKTOP_FILES = arrayOf(
|
internal val DESKTOP_FILES = arrayOf(
|
||||||
@@ -136,8 +133,6 @@ object SessionFiles {
|
|||||||
"usr/local/bin/droiddeck-spawn" to "usr/local/bin/droiddeck-spawn",
|
"usr/local/bin/droiddeck-spawn" to "usr/local/bin/droiddeck-spawn",
|
||||||
"usr/local/bin/droiddeck-log-writer" to "usr/local/bin/droiddeck-log-writer",
|
"usr/local/bin/droiddeck-log-writer" to "usr/local/bin/droiddeck-log-writer",
|
||||||
"usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard",
|
"usr/local/bin/droiddeck-desktop-clipboard" to "usr/local/bin/droiddeck-desktop-clipboard",
|
||||||
"usr/local/bin/droiddeck-text-input" to "usr/local/bin/droiddeck-text-input",
|
|
||||||
"usr/local/bin/droiddeck-steam-ime" to "usr/local/bin/droiddeck-steam-ime",
|
|
||||||
"usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window",
|
"usr/local/bin/droiddeck-gpu-window" to "usr/local/bin/droiddeck-gpu-window",
|
||||||
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
|
"usr/local/bin/droiddeck-steam-install" to "usr/local/bin/droiddeck-steam-install",
|
||||||
"usr/local/bin/droiddeck-steam-preapply" to "usr/local/bin/droiddeck-steam-preapply",
|
"usr/local/bin/droiddeck-steam-preapply" to "usr/local/bin/droiddeck-steam-preapply",
|
||||||
@@ -161,7 +156,6 @@ object SessionFiles {
|
|||||||
"usr/local/bin/droiddeck-desktop-bookmarks" to "usr/local/bin/droiddeck-desktop-bookmarks",
|
"usr/local/bin/droiddeck-desktop-bookmarks" to "usr/local/bin/droiddeck-desktop-bookmarks",
|
||||||
"usr/local/bin/droiddeck-downloads" to "usr/local/bin/droiddeck-downloads",
|
"usr/local/bin/droiddeck-downloads" to "usr/local/bin/droiddeck-downloads",
|
||||||
"usr/local/bin/droiddeck-root" to "usr/local/bin/droiddeck-root",
|
"usr/local/bin/droiddeck-root" to "usr/local/bin/droiddeck-root",
|
||||||
"usr/local/bin/droiddeck-user" to "usr/local/bin/droiddeck-user",
|
|
||||||
"usr/local/bin/droiddeck-text" to "usr/local/bin/droiddeck-text",
|
"usr/local/bin/droiddeck-text" to "usr/local/bin/droiddeck-text",
|
||||||
"usr/local/bin/droiddeck-snapd" to "usr/local/bin/droiddeck-snapd",
|
"usr/local/bin/droiddeck-snapd" to "usr/local/bin/droiddeck-snapd",
|
||||||
"usr/local/bin/droiddeck-emulators" to "usr/local/bin/droiddeck-emulators",
|
"usr/local/bin/droiddeck-emulators" to "usr/local/bin/droiddeck-emulators",
|
||||||
@@ -340,7 +334,6 @@ object SessionFiles {
|
|||||||
if (installed) ledger.staged(key, target) else Log.e(TAG, "DirectAudio $set/$relative NOT staged")
|
if (installed) ledger.staged(key, target) else Log.e(TAG, "DirectAudio $set/$relative NOT staged")
|
||||||
}
|
}
|
||||||
for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger)
|
for (pack in SERVICE_PACKS.keys) stageStoreService(context, root, pack, ledger)
|
||||||
stageImeFiles(context, root, ledger)
|
|
||||||
ledger.save()
|
ledger.save()
|
||||||
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
for (old in arrayOf("aarch64-unix", "aarch64-windows", "i386-windows")) File(root, "$DIRECTAUDIO_DIR/lib/wine/$old").deleteRecursively()
|
||||||
val preload = StringBuilder("/usr/local/lib/libddsession.so\n")
|
val preload = StringBuilder("/usr/local/lib/libddsession.so\n")
|
||||||
@@ -367,7 +360,6 @@ object SessionFiles {
|
|||||||
Log.e(TAG, "could not write steam-compatibility-label")
|
Log.e(TAG, "could not write steam-compatibility-label")
|
||||||
}
|
}
|
||||||
writeCjkFontConfig(root, etc)
|
writeCjkFontConfig(root, etc)
|
||||||
writeSessionBusPolicy(etc)
|
|
||||||
writeDesktopStrings(context, File(etc, "droiddeck").apply { mkdirs() })
|
writeDesktopStrings(context, File(etc, "droiddeck").apply { mkdirs() })
|
||||||
val droiddeckEtc = File(etc, "droiddeck").apply { mkdirs() }
|
val droiddeckEtc = File(etc, "droiddeck").apply { mkdirs() }
|
||||||
val stagedSocket = File(droiddeckEtc, "bwrap-socket.staged")
|
val stagedSocket = File(droiddeckEtc, "bwrap-socket.staged")
|
||||||
@@ -427,42 +419,6 @@ object SessionFiles {
|
|||||||
seen?.let { SessionPrefs.setBootMovieSteamSeen(context, it) }
|
seen?.let { SessionPrefs.setBootMovieSteamSeen(context, it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun stageImeFiles(context: Context, root: File, ledger: StageLedger) {
|
|
||||||
val entries = LinkedHashMap<String, Int>()
|
|
||||||
try {
|
|
||||||
val text = context.assets.open("linuxfs/$IME_MANIFEST").bufferedReader().use { it.readText() }
|
|
||||||
val files = JSONObject(text).getJSONObject("files")
|
|
||||||
for (name in files.keys()) {
|
|
||||||
entries[name] = files.optJSONObject(name)?.optString("mode").orEmpty().toIntOrNull(8) ?: IME_DEFAULT_MODE
|
|
||||||
}
|
|
||||||
entries[IME_MANIFEST] = IME_DEFAULT_MODE
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.w(TAG, "the Chinese input payload is not bundled; Steam sessions start without it", e)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
for ((relative, mode) in entries) {
|
|
||||||
val target = File(root, relative)
|
|
||||||
if (ledger.current(relative, target)) continue
|
|
||||||
val staged = File(target.parentFile, target.name + ".staged")
|
|
||||||
var installed = false
|
|
||||||
try {
|
|
||||||
target.parentFile?.mkdirs()
|
|
||||||
context.assets.open("linuxfs/$relative").use { input ->
|
|
||||||
staged.outputStream().use { output -> FileUtils.copy(input, output) }
|
|
||||||
}
|
|
||||||
installed = staged.setReadable(true, false) &&
|
|
||||||
staged.setWritable((mode and 0x80) != 0, true) &&
|
|
||||||
staged.setExecutable((mode and 0x49) != 0, false) &&
|
|
||||||
staged.renameTo(target)
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.w(TAG, "could not stage $relative", e)
|
|
||||||
} finally {
|
|
||||||
if (!installed) staged.delete()
|
|
||||||
}
|
|
||||||
if (installed) ledger.staged(relative, target) else Log.e(TAG, "$relative NOT staged")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal fun resetMissingStartupMovie(config: File, force: Boolean): Boolean {
|
internal fun resetMissingStartupMovie(config: File, force: Boolean): Boolean {
|
||||||
synchronized(STEAM_CONFIG) {
|
synchronized(STEAM_CONFIG) {
|
||||||
if (!config.isFile) return true
|
if (!config.isFile) return true
|
||||||
@@ -926,24 +882,6 @@ object SessionFiles {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A session bus admits only its owner, and with droiddeck-user (the native hook's ordinary
|
|
||||||
* user) a root process and a user's share the bus while the kernel sees one Android uid.
|
|
||||||
*/
|
|
||||||
private fun writeSessionBusPolicy(etc: File) {
|
|
||||||
val xml = """<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
|
||||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
|
||||||
<busconfig>
|
|
||||||
<policy context="default">
|
|
||||||
<allow user="*"/>
|
|
||||||
</policy>
|
|
||||||
</busconfig>
|
|
||||||
"""
|
|
||||||
val conf = File(etc, "dbus-1/session.d/droiddeck-users.conf")
|
|
||||||
conf.parentFile?.mkdirs()
|
|
||||||
if (!FileUtils.writeString(conf, xml)) Log.e(TAG, "could not write the session bus policy")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun writeCjkFontConfig(root: File, etc: File) {
|
private fun writeCjkFontConfig(root: File, etc: File) {
|
||||||
try {
|
try {
|
||||||
val confDir = File(etc, "fonts/conf.d").apply { mkdirs() }
|
val confDir = File(etc, "fonts/conf.d").apply { mkdirs() }
|
||||||
|
|||||||
@@ -63,24 +63,6 @@ object SessionPrefs {
|
|||||||
.takeIf { value -> orientationOptions.any { it.first == value } }
|
.takeIf { value -> orientationOptions.any { it.first == value } }
|
||||||
?: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
?: ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE
|
||||||
|
|
||||||
fun orientation(context: Context, mode: String?): Int {
|
|
||||||
val key = when (mode) {
|
|
||||||
"steam", SessionService.MODE_STEAM, SessionService.MODE_RUN -> "orientation.steam"
|
|
||||||
"desktop", SessionService.MODE_DESKTOP -> "orientation.desktop"
|
|
||||||
else -> null
|
|
||||||
} ?: return orientation(context)
|
|
||||||
val stored = prefs(context).getInt(key, Int.MIN_VALUE)
|
|
||||||
return if (stored == Int.MIN_VALUE) orientation(context)
|
|
||||||
else stored.takeIf { value -> orientationOptions.any { it.first == value } } ?: orientation(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setOrientation(context: Context, mode: String, orientation: Int) {
|
|
||||||
require(mode == "steam" || mode == "desktop")
|
|
||||||
require(orientationOptions.any { it.first == orientation })
|
|
||||||
val key = if (mode == "steam") "orientation.steam" else "orientation.desktop"
|
|
||||||
prefs(context).edit().putInt(key, orientation).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The session menu's width in dp the user dragged it to; null keeps the default. */
|
/** The session menu's width in dp the user dragged it to; null keeps the default. */
|
||||||
fun drawerWidthDp(context: Context): Int? = prefs(context).getInt("drawerWidthDp", 0).takeIf { it > 0 }
|
fun drawerWidthDp(context: Context): Int? = prefs(context).getInt("drawerWidthDp", 0).takeIf { it > 0 }
|
||||||
|
|
||||||
@@ -93,19 +75,11 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putInt("orientation", orientation).apply()
|
prefs(context).edit().putInt("orientation", orientation).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun windowOrientation(context: Context, followScreen: Boolean, smallestWidthDp: Int, mode: String? = null): Int {
|
fun windowOrientation(context: Context, followScreen: Boolean, smallestWidthDp: Int): Int =
|
||||||
val modeKey = when (mode) {
|
if (followScreen && smallestWidthDp >= SessionDisplay.UNFOLDED_MIN_DP && !prefs(context).contains("orientation"))
|
||||||
"steam", SessionService.MODE_STEAM, SessionService.MODE_RUN -> "orientation.steam"
|
|
||||||
"desktop", SessionService.MODE_DESKTOP -> "orientation.desktop"
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
val preferences = prefs(context)
|
|
||||||
if (modeKey != null && preferences.contains(modeKey)) return orientation(context, mode)
|
|
||||||
return if (followScreen && smallestWidthDp >= SessionDisplay.UNFOLDED_MIN_DP && !preferences.contains("orientation"))
|
|
||||||
ActivityInfo.SCREEN_ORIENTATION_USER else orientation(context)
|
ActivityInfo.SCREEN_ORIENTATION_USER else orientation(context)
|
||||||
}
|
|
||||||
|
|
||||||
fun portrait(context: Context, mode: String? = null): Boolean = when (orientation(context, mode)) {
|
fun portrait(context: Context): Boolean = when (orientation(context)) {
|
||||||
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> true
|
ActivityInfo.SCREEN_ORIENTATION_PORTRAIT -> true
|
||||||
ActivityInfo.SCREEN_ORIENTATION_USER ->
|
ActivityInfo.SCREEN_ORIENTATION_USER ->
|
||||||
context.resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
|
context.resources.configuration.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||||
@@ -118,39 +92,6 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putBoolean("launcherFullscreen", on).apply()
|
prefs(context).edit().putBoolean("launcherFullscreen", on).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun launcherFrost(context: Context): Boolean = prefs(context).getBoolean("launcherFrost", false)
|
|
||||||
|
|
||||||
fun setLauncherFrost(context: Context, on: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("launcherFrost", on).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun frostWallpaper(context: Context): Boolean = prefs(context).getBoolean("frostWallpaper", true)
|
|
||||||
|
|
||||||
fun setFrostWallpaper(context: Context, on: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("frostWallpaper", on).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun frostCards(context: Context): Boolean = prefs(context).getBoolean("frostCards", true)
|
|
||||||
|
|
||||||
fun setFrostCards(context: Context, on: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("frostCards", on).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun frostTransparency(context: Context): Int = frostPercent(context, "frostTransparency", com.droiddeck.launcher.ui.FROST_WALLPAPER_DEFAULT)
|
|
||||||
|
|
||||||
fun setFrostTransparency(context: Context, percent: Int) = setFrostPercent(context, "frostTransparency", percent)
|
|
||||||
|
|
||||||
fun frostCardTransparency(context: Context): Int = frostPercent(context, "frostCardTransparency", com.droiddeck.launcher.ui.FROST_DEFAULT)
|
|
||||||
|
|
||||||
fun setFrostCardTransparency(context: Context, percent: Int) = setFrostPercent(context, "frostCardTransparency", percent)
|
|
||||||
|
|
||||||
private fun frostPercent(context: Context, key: String, default: Int): Int =
|
|
||||||
prefs(context).getInt(key, default).coerceIn(0, com.droiddeck.launcher.ui.FROST_MAX)
|
|
||||||
|
|
||||||
private fun setFrostPercent(context: Context, key: String, percent: Int) {
|
|
||||||
prefs(context).edit().putInt(key, percent.coerceIn(0, com.droiddeck.launcher.ui.FROST_MAX)).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun controllerHaptics(context: Context): Boolean = prefs(context).getBoolean("controllerHaptics", true)
|
fun controllerHaptics(context: Context): Boolean = prefs(context).getBoolean("controllerHaptics", true)
|
||||||
|
|
||||||
fun setControllerHaptics(context: Context, on: Boolean) {
|
fun setControllerHaptics(context: Context, on: Boolean) {
|
||||||
@@ -364,13 +305,13 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putInt("libraryCardLevel", level).apply()
|
prefs(context).edit().putInt("libraryCardLevel", level).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", false)
|
fun libraryShowTitle(context: Context): Boolean = prefs(context).getBoolean("libraryShowTitle", true)
|
||||||
|
|
||||||
fun setLibraryShowTitle(context: Context, show: Boolean) {
|
fun setLibraryShowTitle(context: Context, show: Boolean) {
|
||||||
prefs(context).edit().putBoolean("libraryShowTitle", show).apply()
|
prefs(context).edit().putBoolean("libraryShowTitle", show).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", false)
|
fun libraryShowSize(context: Context): Boolean = prefs(context).getBoolean("libraryShowSize", true)
|
||||||
|
|
||||||
fun setLibraryShowSize(context: Context, show: Boolean) {
|
fun setLibraryShowSize(context: Context, show: Boolean) {
|
||||||
prefs(context).edit().putBoolean("libraryShowSize", show).apply()
|
prefs(context).edit().putBoolean("libraryShowSize", show).apply()
|
||||||
@@ -552,17 +493,6 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply()
|
prefs(context).edit().putString("drawerPageHidden", keys.joinToString(",")).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun drawerSections(context: Context): Map<String, Boolean> =
|
|
||||||
idList(prefs(context).getString("drawerSections", null)).mapNotNull { entry ->
|
|
||||||
val at = entry.lastIndexOf('=').takeIf { it > 0 } ?: return@mapNotNull null
|
|
||||||
entry.substring(0, at) to (entry.substring(at + 1) == "1")
|
|
||||||
}.toMap()
|
|
||||||
|
|
||||||
fun setDrawerSections(context: Context, sections: Map<String, Boolean>) {
|
|
||||||
prefs(context).edit().putString("drawerSections", sections.entries.filter { ',' !in it.key }
|
|
||||||
.joinToString(",") { "${it.key}=${if (it.value) 1 else 0}" }).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setNavTabHidden(context: Context, keys: Set<String>) {
|
fun setNavTabHidden(context: Context, keys: Set<String>) {
|
||||||
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
prefs(context).edit().putString("navTabHidden", keys.joinToString(",")).apply()
|
||||||
}
|
}
|
||||||
@@ -946,21 +876,13 @@ object SessionPrefs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private val picturePositions = setOf("center", "top", "bottom", "left", "right")
|
fun picturePosition(context: Context): String =
|
||||||
|
prefs(context).getString("picturePosition", "center")
|
||||||
|
?.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center"
|
||||||
|
|
||||||
private fun picturePositionKey(portrait: Boolean) =
|
fun setPicturePosition(context: Context, position: String) {
|
||||||
if (portrait) "picturePosition.portrait" else "picturePosition.landscape"
|
prefs(context).edit().putString("picturePosition",
|
||||||
|
position.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center").apply()
|
||||||
fun picturePosition(context: Context, portrait: Boolean): String {
|
|
||||||
val preferences = prefs(context)
|
|
||||||
return preferences.getString(picturePositionKey(portrait), null)?.takeIf { it in picturePositions }
|
|
||||||
?: preferences.getString("picturePosition", null)?.takeIf { it in picturePositions }
|
|
||||||
?: if (portrait) "top" else "center"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setPicturePosition(context: Context, portrait: Boolean, position: String) {
|
|
||||||
require(position in picturePositions)
|
|
||||||
prefs(context).edit().putString(picturePositionKey(portrait), position).apply()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun integerScaling(context: Context): Boolean =
|
fun integerScaling(context: Context): Boolean =
|
||||||
@@ -1185,13 +1107,6 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putBoolean("nativeUserland", on).apply()
|
prefs(context).edit().putBoolean("nativeUserland", on).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether the Plasma desktop, and so its apps and shells, runs as an ordinary user instead of root (native userland only). */
|
|
||||||
fun desktopAsUser(context: Context): Boolean = prefs(context).getBoolean("desktopAsUser", false)
|
|
||||||
|
|
||||||
fun setDesktopAsUser(context: Context, on: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("desktopAsUser", on).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true)
|
fun prootFastPath(context: Context): Boolean = prefs(context).getBoolean("prootFastPath", true)
|
||||||
|
|
||||||
fun setProotFastPath(context: Context, on: Boolean) {
|
fun setProotFastPath(context: Context, on: Boolean) {
|
||||||
@@ -1521,12 +1436,10 @@ object SessionPrefs {
|
|||||||
|
|
||||||
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||||
val fallback = if (mode == SessionService.MODE_STEAM) SessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION
|
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||||
else SessionDisplay.LINK_LANDSCAPE
|
|
||||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return fallback
|
|
||||||
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||||
SessionDisplay.presetHeight(value) != null) return value
|
SessionDisplay.presetHeight(value) != null) return value
|
||||||
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: fallback
|
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
|
||||||
}
|
}
|
||||||
|
|
||||||
fun parseOrientedResolution(text: String): Pair<Int, Int>? =
|
fun parseOrientedResolution(text: String): Pair<Int, Int>? =
|
||||||
@@ -1788,9 +1701,6 @@ object SessionPrefs {
|
|||||||
name.removeSuffix(from) + to to moved
|
name.removeSuffix(from) + to to moved
|
||||||
}
|
}
|
||||||
|
|
||||||
fun storedAddedGameAppId(context: Context, folderPath: String): Long? =
|
|
||||||
prefs(context).getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L }
|
|
||||||
|
|
||||||
fun addedGameAppId(context: Context, folderPath: String, first: Long): Long = synchronized(addedGameLock) {
|
fun addedGameAppId(context: Context, folderPath: String, first: Long): Long = synchronized(addedGameLock) {
|
||||||
val p = prefs(context)
|
val p = prefs(context)
|
||||||
p.getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L }
|
p.getLong("addedAppId:$folderPath", 0L).takeIf { it != 0L }
|
||||||
@@ -1887,17 +1797,10 @@ object SessionPrefs {
|
|||||||
prefs(context).edit().putBoolean(hdrKey(mode), on).apply()
|
prefs(context).edit().putBoolean(hdrKey(mode), on).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart-scoped opt-in; not inferred from Zero-copy (which defaults on). */
|
fun zeroCopy(context: Context, mode: String): Boolean = prefs(context).getBoolean("zeroCopy.$mode", true)
|
||||||
fun producerAcquireFences(context: Context): Boolean = prefs(context).getBoolean("producerAcquireFences", false)
|
|
||||||
|
|
||||||
fun setProducerAcquireFences(context: Context, on: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("producerAcquireFences", on).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun zeroCopy(context: Context, mode: String): Boolean = prefs(context).getBoolean("zeroCopy.${prefMode(mode)}", true)
|
|
||||||
|
|
||||||
fun setZeroCopy(context: Context, mode: String, on: Boolean) {
|
fun setZeroCopy(context: Context, mode: String, on: Boolean) {
|
||||||
prefs(context).edit().putBoolean("zeroCopy.${prefMode(mode)}", on).apply()
|
prefs(context).edit().putBoolean("zeroCopy.$mode", on).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
const val FPS_UNPACED = -1
|
const val FPS_UNPACED = -1
|
||||||
@@ -1907,18 +1810,16 @@ object SessionPrefs {
|
|||||||
|
|
||||||
const val PIP_FPS = 30
|
const val PIP_FPS = 30
|
||||||
|
|
||||||
fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false, hostCap: Int = 0): Int {
|
fun compositorFpsLimit(mirrorRefreshLimit: Int, sessionLimit: Int = 0, pip: Boolean = false): Int {
|
||||||
val limit = listOf(mirrorRefreshLimit, sessionLimit, hostCap).filter { it > 0 }.minOrNull() ?: FPS_UNPACED
|
val limit = when {
|
||||||
|
mirrorRefreshLimit <= 0 && sessionLimit <= 0 -> FPS_UNPACED
|
||||||
|
mirrorRefreshLimit <= 0 -> sessionLimit
|
||||||
|
sessionLimit <= 0 -> mirrorRefreshLimit
|
||||||
|
else -> minOf(mirrorRefreshLimit, sessionLimit)
|
||||||
|
}
|
||||||
return if (pip && mirrorRefreshLimit <= 0 && (limit <= 0 || limit > PIP_FPS)) PIP_FPS else limit
|
return if (pip && mirrorRefreshLimit <= 0 && (limit <= 0 || limit > PIP_FPS)) PIP_FPS else limit
|
||||||
}
|
}
|
||||||
|
|
||||||
fun layerFrameRate(ownLimit: Int, refreshHz: Float, blackFrameInsertion: Boolean): Float =
|
|
||||||
if (ownLimit > 0 && !blackFrameInsertion) ownLimit.toFloat() else refreshHz
|
|
||||||
|
|
||||||
/** The per-app rate Android holds this window to (Game Mode's FPS override), or 0 when the panel's rate applies. */
|
|
||||||
fun hostFrameCap(overrideHz: Float, panelHz: Float): Int =
|
|
||||||
if (overrideHz > 1f && panelHz - overrideHz > 1f) Math.round(overrideHz) else 0
|
|
||||||
|
|
||||||
val upscalerChoices = listOf(
|
val upscalerChoices = listOf(
|
||||||
2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
|
2 to "Nearest", 0 to "Linear", 4 to "AMD FSR 1", 3 to "Snapdragon GSR",
|
||||||
8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only",
|
8 to "Snapdragon GSR (quality)", 7 to "NVIDIA NIS", 6 to "Sharpen only",
|
||||||
@@ -2014,84 +1915,24 @@ object SessionPrefs {
|
|||||||
sessionPrefs.edit().putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString()).apply()
|
sessionPrefs.edit().putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString()).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
private const val GAME_UPSCALER_OVERRIDES_KEY = "upscaler.gameOverrides"
|
|
||||||
|
|
||||||
private fun gameUpscalerOverrides(context: Context): JSONObject = runCatching {
|
|
||||||
JSONObject(prefs(context).getString(GAME_UPSCALER_OVERRIDES_KEY, null) ?: "{}")
|
|
||||||
}.getOrDefault(JSONObject())
|
|
||||||
|
|
||||||
private fun legacyScreenEffectsUpscaler(context: Context, profileId: String): Int? =
|
|
||||||
runCatching {
|
|
||||||
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
|
||||||
val profile = profiles.optJSONObject(profileId)
|
|
||||||
if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) {
|
|
||||||
profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1).takeIf { it >= 0 }
|
|
||||||
} else null
|
|
||||||
}.getOrNull()?.let(::canonicalUpscaler)
|
|
||||||
|
|
||||||
private fun clearLegacyScreenEffectsUpscaler(context: Context, profileId: String) {
|
|
||||||
val sessionPrefs = prefs(context)
|
|
||||||
val profiles = runCatching {
|
|
||||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
|
||||||
}.getOrNull() ?: return
|
|
||||||
val profile = profiles.optJSONObject(profileId) ?: return
|
|
||||||
if (!profile.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY)) return
|
|
||||||
profile.remove(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY)
|
|
||||||
if (profile.length() == 0) profiles.remove(profileId)
|
|
||||||
sessionPrefs.edit().apply {
|
|
||||||
if (profiles.length() == 0) remove(SCREEN_EFFECTS_PROFILES_KEY)
|
|
||||||
else putString(SCREEN_EFFECTS_PROFILES_KEY, profiles.toString())
|
|
||||||
}.apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hasGameUpscalerOverride(context: Context, gameId: String): Boolean {
|
|
||||||
if (gameId.isBlank()) return false
|
|
||||||
val stored = gameUpscalerOverrides(context)
|
|
||||||
return (stored.has(gameId) && stored.optInt(gameId, -1) >= 0) ||
|
|
||||||
legacyScreenEffectsUpscaler(context, "game:$gameId") != null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun setGameUpscaler(context: Context, gameId: String, mode: Int) {
|
|
||||||
if (gameId.isBlank()) return
|
|
||||||
val overrides = gameUpscalerOverrides(context)
|
|
||||||
overrides.put(gameId, canonicalUpscaler(mode))
|
|
||||||
prefs(context).edit().putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString()).apply()
|
|
||||||
clearLegacyScreenEffectsUpscaler(context, "game:$gameId")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun clearGameUpscaler(context: Context, gameId: String) {
|
|
||||||
if (gameId.isBlank()) return
|
|
||||||
val sessionPrefs = prefs(context)
|
|
||||||
val overrides = gameUpscalerOverrides(context)
|
|
||||||
if (overrides.has(gameId)) {
|
|
||||||
overrides.remove(gameId)
|
|
||||||
sessionPrefs.edit().apply {
|
|
||||||
if (overrides.length() == 0) remove(GAME_UPSCALER_OVERRIDES_KEY)
|
|
||||||
else putString(GAME_UPSCALER_OVERRIDES_KEY, overrides.toString())
|
|
||||||
}.apply()
|
|
||||||
}
|
|
||||||
clearLegacyScreenEffectsUpscaler(context, "game:$gameId")
|
|
||||||
}
|
|
||||||
|
|
||||||
fun hasScreenEffectsUpscalerOverride(context: Context, profileId: String?): Boolean {
|
fun hasScreenEffectsUpscalerOverride(context: Context, profileId: String?): Boolean {
|
||||||
if (profileId.isNullOrBlank()) return false
|
if (profileId.isNullOrBlank()) return false
|
||||||
if (profileId.startsWith("game:")) {
|
return runCatching {
|
||||||
return hasGameUpscalerOverride(context, profileId.removePrefix("game:"))
|
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||||
}
|
profiles.optJSONObject(profileId)?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true
|
||||||
return legacyScreenEffectsUpscaler(context, profileId) != null
|
}.getOrDefault(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun screenEffectsUpscaler(context: Context, profileId: String?): Int {
|
fun screenEffectsUpscaler(context: Context, profileId: String?): Int {
|
||||||
if (profileId.isNullOrBlank()) return upscaler(context)
|
if (profileId.isNullOrBlank()) return upscaler(context)
|
||||||
if (profileId.startsWith("game:")) {
|
val stored = runCatching {
|
||||||
val gameId = profileId.removePrefix("game:")
|
val profiles = JSONObject(prefs(context).getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||||
val overrides = gameUpscalerOverrides(context)
|
val profile = profiles.optJSONObject(profileId)
|
||||||
if (overrides.has(gameId)) {
|
if (profile?.has(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY) == true) {
|
||||||
val stored = overrides.optInt(gameId, -1)
|
profile.optInt(SCREEN_EFFECTS_PROFILE_UPSCALER_KEY, -1)
|
||||||
if (stored >= 0) return canonicalUpscaler(stored)
|
} else -1
|
||||||
}
|
}.getOrDefault(-1)
|
||||||
}
|
return if (stored >= 0) canonicalUpscaler(stored) else upscaler(context)
|
||||||
return legacyScreenEffectsUpscaler(context, profileId) ?: upscaler(context)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setScreenEffectsUpscaler(context: Context, profileId: String?, mode: Int) {
|
fun setScreenEffectsUpscaler(context: Context, profileId: String?, mode: Int) {
|
||||||
@@ -2099,10 +1940,6 @@ object SessionPrefs {
|
|||||||
setUpscaler(context, mode)
|
setUpscaler(context, mode)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (profileId.startsWith("game:")) {
|
|
||||||
setGameUpscaler(context, profileId.removePrefix("game:"), mode)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val sessionPrefs = prefs(context)
|
val sessionPrefs = prefs(context)
|
||||||
val profiles = runCatching {
|
val profiles = runCatching {
|
||||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||||
@@ -2139,7 +1976,6 @@ object SessionPrefs {
|
|||||||
val profiles = runCatching {
|
val profiles = runCatching {
|
||||||
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
JSONObject(sessionPrefs.getString(SCREEN_EFFECTS_PROFILES_KEY, null) ?: "{}")
|
||||||
}.getOrElse { JSONObject() }
|
}.getOrElse { JSONObject() }
|
||||||
if (profileId.startsWith("game:")) clearGameUpscaler(context, profileId.removePrefix("game:"))
|
|
||||||
if (!profiles.has(profileId)) return
|
if (!profiles.has(profileId)) return
|
||||||
profiles.remove(profileId)
|
profiles.remove(profileId)
|
||||||
sessionPrefs.edit().apply {
|
sessionPrefs.edit().apply {
|
||||||
@@ -2284,12 +2120,6 @@ object SessionPrefs {
|
|||||||
(resolutionChosen(context, SessionService.MODE_DESKTOP) || resolutionChosen(context, SessionService.MODE_DESKTOP, true))) SessionService.MODE_DESKTOP
|
(resolutionChosen(context, SessionService.MODE_DESKTOP) || resolutionChosen(context, SessionService.MODE_DESKTOP, true))) SessionService.MODE_DESKTOP
|
||||||
else prefMode(mode)
|
else prefMode(mode)
|
||||||
|
|
||||||
fun showGlassesShortcut(context: Context): Boolean = prefs(context).getBoolean("showGlassesShortcut", true)
|
|
||||||
|
|
||||||
fun setShowGlassesShortcut(context: Context, show: Boolean) {
|
|
||||||
prefs(context).edit().putBoolean("showGlassesShortcut", show).apply()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", true)
|
fun pipAutoEnter(context: Context): Boolean = prefs(context).getBoolean("pipAutoEnter", true)
|
||||||
|
|
||||||
fun setPipAutoEnter(context: Context, enabled: Boolean) {
|
fun setPipAutoEnter(context: Context, enabled: Boolean) {
|
||||||
|
|||||||
@@ -394,10 +394,8 @@ class SessionService : Service() {
|
|||||||
SessionState.program = intent?.getStringExtra(EXTRA_PROGRAM)
|
SessionState.program = intent?.getStringExtra(EXTRA_PROGRAM)
|
||||||
SessionState.programArgs = intent?.getStringArrayExtra(EXTRA_PROGRAM_ARGS)?.toList().orEmpty()
|
SessionState.programArgs = intent?.getStringArrayExtra(EXTRA_PROGRAM_ARGS)?.toList().orEmpty()
|
||||||
SessionState.steamUi = intent?.getStringExtra(EXTRA_STEAM_UI)
|
SessionState.steamUi = intent?.getStringExtra(EXTRA_STEAM_UI)
|
||||||
val launchSteamUrl = intent?.getStringExtra(EXTRA_STEAM_URL)
|
SessionState.steamUrl = intent?.getStringExtra(EXTRA_STEAM_URL)
|
||||||
val frontendSteamGame = intent?.getBooleanExtra(EXTRA_FRONTEND_STEAM_GAME, false) == true
|
val steamUrlGameId = SessionState.steamUrl
|
||||||
SessionState.steamUrl = launchSteamUrl
|
|
||||||
val steamUrlGameId = launchSteamUrl
|
|
||||||
?.let { url ->
|
?.let { url ->
|
||||||
when {
|
when {
|
||||||
url.startsWith(GAME_URL_PREFIX) ->
|
url.startsWith(GAME_URL_PREFIX) ->
|
||||||
@@ -428,11 +426,6 @@ class SessionService : Service() {
|
|||||||
++sessionGen
|
++sessionGen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val trimGen = gen
|
|
||||||
PageCacheTrim.start(
|
|
||||||
roots = { listOfNotNull(File(filesDir, "linuxfs"), GameStorage.effective(applicationContext)?.let { File(it.path) }).filter(File::isDirectory) },
|
|
||||||
alive = { SessionState.running && sessionGen == trimGen },
|
|
||||||
)
|
|
||||||
if (SessionState.stopRequested) {
|
if (SessionState.stopRequested) {
|
||||||
stopSession(0)
|
stopSession(0)
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
@@ -454,7 +447,7 @@ class SessionService : Service() {
|
|||||||
Thread({
|
Thread({
|
||||||
OrphanReaper.reap("session starting")
|
OrphanReaper.reap("session starting")
|
||||||
ProtonExtras.awaitReplacement(120_000)
|
ProtonExtras.awaitReplacement(120_000)
|
||||||
runSession(gen, launchSteamUrl, frontendSteamGame)
|
runSession(gen)
|
||||||
}, "session-start").start()
|
}, "session-start").start()
|
||||||
return START_NOT_STICKY
|
return START_NOT_STICKY
|
||||||
}
|
}
|
||||||
@@ -507,7 +500,7 @@ class SessionService : Service() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun runSession(gen: Int, launchSteamUrl: String?, frontendSteamGame: Boolean) {
|
private fun runSession(gen: Int) {
|
||||||
SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this)
|
SessionPrefs.ensurePowerVrAutoDriversAfterGpuQuery(this)
|
||||||
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
if (!com.droiddeck.launcher.core.DeviceSupport.adreno()) {
|
||||||
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
|
com.droiddeck.launcher.gpu.VulkanInfo.query()["api"]?.let { SessionPrefs.setHostVulkanApi(this, it) }
|
||||||
@@ -562,10 +555,9 @@ class SessionService : Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val nextAgentEnvironment = runCatching { com.droiddeck.launcher.agent.AgentEnv.beginSession(this) }
|
val agentEnvironment = runCatching { com.droiddeck.launcher.agent.AgentEnv.beginSession(this) }
|
||||||
.onFailure { Log.w(TAG, "agent environment skipped", it) }
|
.onFailure { Log.w(TAG, "agent environment skipped", it) }
|
||||||
val agentEnvironment = nextAgentEnvironment.getOrDefault(emptyList())
|
.getOrDefault(emptyList())
|
||||||
val customEnvironment = extraEnv()
|
|
||||||
try {
|
try {
|
||||||
if (systemVulkan) {
|
if (systemVulkan) {
|
||||||
SystemVulkanDriver.prepare(this)
|
SystemVulkanDriver.prepare(this)
|
||||||
@@ -622,9 +614,6 @@ class SessionService : Service() {
|
|||||||
val size = SessionState.outputSize
|
val size = SessionState.outputSize
|
||||||
val guest = ArrayList<String>()
|
val guest = ArrayList<String>()
|
||||||
val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP
|
val steamHere = SessionState.mode == MODE_STEAM || SessionState.mode == MODE_DESKTOP
|
||||||
runCatching { SessionEvents.step("components-xbox") { XboxBackCompatComponents.ensure(this) } }
|
|
||||||
.onSuccess { if (it != null) Log.i(TAG, it) }
|
|
||||||
.onFailure { Log.w(TAG, "original Xbox components", it) }
|
|
||||||
runCatching { SessionEvents.step("components-republish") { ComponentsManager.republish(this) } }
|
runCatching { SessionEvents.step("components-republish") { ComponentsManager.republish(this) } }
|
||||||
.onSuccess { if (it) Log.i(TAG, "component selections published for the installed Proton builds") }
|
.onSuccess { if (it) Log.i(TAG, "component selections published for the installed Proton builds") }
|
||||||
.onFailure { Log.w(TAG, "component selections", it) }
|
.onFailure { Log.w(TAG, "component selections", it) }
|
||||||
@@ -634,7 +623,7 @@ class SessionService : Service() {
|
|||||||
.onFailure { Log.w(TAG, "forced components", it) }
|
.onFailure { Log.w(TAG, "forced components", it) }
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
SessionEvents.step("client-environment") { addClientEnvironment(guest, steamHere, agentEnvironment, customEnvironment) }
|
SessionEvents.step("client-environment") { addClientEnvironment(guest, steamHere, agentEnvironment) }
|
||||||
} catch (e: IllegalStateException) {
|
} catch (e: IllegalStateException) {
|
||||||
Log.e(TAG, "Could not resolve the selected Linux Vulkan driver", e)
|
Log.e(TAG, "Could not resolve the selected Linux Vulkan driver", e)
|
||||||
failSession(gen, "VULKAN_DRIVER_UNAVAILABLE", e.message ?: "Selected Linux Vulkan driver is unavailable", -1)
|
failSession(gen, "VULKAN_DRIVER_UNAVAILABLE", e.message ?: "Selected Linux Vulkan driver is unavailable", -1)
|
||||||
@@ -672,7 +661,7 @@ class SessionService : Service() {
|
|||||||
Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output")
|
Log.i(TAG, "game resolution: ${w}x$h on a ${size.first}x${size.second} output")
|
||||||
}
|
}
|
||||||
if (SessionState.followScreen || size.first < size.second ||
|
if (SessionState.followScreen || size.first < size.second ||
|
||||||
SessionPrefs.orientation(this, SessionState.mode) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
SessionPrefs.orientation(this) == android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
|
||||||
guest.add("DD_FOLLOW_OUTPUT=1")
|
guest.add("DD_FOLLOW_OUTPUT=1")
|
||||||
if (SessionState.hdr) {
|
if (SessionState.hdr) {
|
||||||
guest.add("DD_HDR=1")
|
guest.add("DD_HDR=1")
|
||||||
@@ -719,35 +708,21 @@ class SessionService : Service() {
|
|||||||
// this session's worker number: the shared field may be a newer session's by the time it is used
|
// this session's worker number: the shared field may be a newer session's by the time it is used
|
||||||
var ownWorkers = 0
|
var ownWorkers = 0
|
||||||
if (com.droiddeck.launcher.runtime.GuestWorkers.enabled(this)) {
|
if (com.droiddeck.launcher.runtime.GuestWorkers.enabled(this)) {
|
||||||
val fenceWorker = com.droiddeck.launcher.runtime.FrameAcquireWorkerProbe
|
|
||||||
val preparedFence = if (steamHere && !systemVulkan && !VenusComponent.wanted(this) &&
|
|
||||||
SessionPrefs.zeroCopy(this, MODE_STEAM) && SessionPrefs.producerAcquireFences(this) &&
|
|
||||||
nextAgentEnvironment.isSuccess && fenceWorker.validEnvironment(agentEnvironment, customEnvironment)
|
|
||||||
) fenceWorker.prepare(this, launchSteamUrl, frontendSteamGame) else null
|
|
||||||
var fenceArmed = false
|
|
||||||
// Under the lock a stop takes its number with: a stop either comes first (and this session
|
// Under the lock a stop takes its number with: a stop either comes first (and this session
|
||||||
// starts no workers) or owns them
|
// starts no workers) or owns them
|
||||||
ownWorkers = synchronized(stopLock) {
|
ownWorkers = synchronized(stopLock) {
|
||||||
if (gen != sessionGen || !SessionState.running) 0
|
if (gen != sessionGen || !SessionState.running) 0
|
||||||
else com.droiddeck.launcher.runtime.GuestWorkers.serve(this).also {
|
else com.droiddeck.launcher.runtime.GuestWorkers.serve(this).also { guestWorkerSession = it }
|
||||||
guestWorkerSession = it
|
|
||||||
if (preparedFence != null) fenceArmed = fenceWorker.arm(it, preparedFence)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (ownWorkers > 0) {
|
if (ownWorkers > 0) {
|
||||||
guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this))
|
guest.add("DD_SPAWN=" + com.droiddeck.launcher.runtime.GuestWorkers.socketName(this))
|
||||||
guest.add("DD_SPAWN_SESSION=$ownWorkers")
|
guest.add("DD_SPAWN_SESSION=$ownWorkers")
|
||||||
if (fenceArmed) {
|
|
||||||
guest.add(fenceWorker.GAMESCOPE_ENABLE)
|
|
||||||
guest.add(fenceWorker.GAME_ENABLE)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Proton builds up to 11.12 report X11 text fields under this name.
|
// Proton builds up to 11.12 report X11 text fields under this name.
|
||||||
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
|
guest.add("BL_LAUNCH_DIR=" + sessionRoot.path)
|
||||||
GameStorage.effective(this)?.let { guest.add("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
|
GameStorage.effective(this)?.let { guest.add("DD_LIBRARY_LABEL=" + it.label.replace('"', ' ')) }
|
||||||
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop")
|
if (SessionState.mode == MODE_STEAM && SessionState.steamUi == "desktop") guest.add("DD_STEAM_UI=desktop")
|
||||||
if (SessionPrefs.desktopAsUser(this)) guest.add("DD_DESKTOP_USER=1")
|
|
||||||
// Detailed graphics logs: per-game logs and the guest's Vulkan summary (a GPU that is not
|
// 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.
|
// an Adreno, or Setup's switch), and graphics-report.txt for every session.
|
||||||
if (GraphicsReport.detailed(this)) guest.add("DD_GAME_LOGS=1")
|
if (GraphicsReport.detailed(this)) guest.add("DD_GAME_LOGS=1")
|
||||||
@@ -762,7 +737,7 @@ class SessionService : Service() {
|
|||||||
val desktopGuest = ArrayList(guest)
|
val desktopGuest = ArrayList(guest)
|
||||||
guest.add(LinuxRuntime.SESSION_SCRIPT)
|
guest.add(LinuxRuntime.SESSION_SCRIPT)
|
||||||
guest.add(SessionState.mode)
|
guest.add(SessionState.mode)
|
||||||
if (SessionState.mode == MODE_STEAM) launchSteamUrl?.takeIf { it.startsWith("steam://") }?.let {
|
if (SessionState.mode == MODE_STEAM) SessionState.steamUrl?.takeIf { it.startsWith("steam://") }?.let {
|
||||||
guest.add(it)
|
guest.add(it)
|
||||||
Log.i(TAG, "steam: handing the client $it")
|
Log.i(TAG, "steam: handing the client $it")
|
||||||
}
|
}
|
||||||
@@ -927,13 +902,7 @@ class SessionService : Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
sessionPid = pid
|
sessionPid = pid
|
||||||
// Under the lock Stop clears it with, and only while this session still runs: a Stop since the
|
com.droiddeck.launcher.runtime.GuestWorkers.sessionRootUncounted = com.droiddeck.launcher.runtime.GuestWorkers.runsInWorker(pid)
|
||||||
// check above has cleared it already, and this would set it again for no running session.
|
|
||||||
val uncounted = com.droiddeck.launcher.runtime.GuestWorkers.runsInWorker(pid)
|
|
||||||
synchronized(stopLock) {
|
|
||||||
if (gen == sessionGen && SessionState.running)
|
|
||||||
com.droiddeck.launcher.runtime.GuestWorkers.sessionRootUncounted = uncounted
|
|
||||||
}
|
|
||||||
if (pid > 1) {
|
if (pid > 1) {
|
||||||
raiseTracer(pid, gen)
|
raiseTracer(pid, gen)
|
||||||
SessionEvents.guestStarted(pid)
|
SessionEvents.guestStarted(pid)
|
||||||
@@ -945,15 +914,11 @@ class SessionService : Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (gen == sessionGen && SessionState.running) {
|
if (gen == sessionGen && SessionState.running) {
|
||||||
val workers = ownWorkers
|
|
||||||
suspendController = SessionSuspendController(
|
suspendController = SessionSuspendController(
|
||||||
sessionRoot = { sessionPid },
|
sessionRoot = { sessionPid },
|
||||||
// Programs handed off to worker processes are not descendants of the session root, and
|
|
||||||
// the clock shift applied at resume would move their monotonic time backwards.
|
|
||||||
helperRoots = {
|
helperRoots = {
|
||||||
components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } +
|
components.mapNotNull { it.suspendPid().takeIf { pid -> pid > 1 } } +
|
||||||
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 }) +
|
listOfNotNull(BottomDesktop.suspendPid.takeIf { it > 1 })
|
||||||
(if (workers > 0) com.droiddeck.launcher.runtime.GuestWorkers.guestPids(workers) else emptyList())
|
|
||||||
},
|
},
|
||||||
suspendAudio = {
|
suspendAudio = {
|
||||||
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")
|
if (!pulse.setSinkSuspended(true)) Log.w(TAG, "could not suspend audio sink")
|
||||||
@@ -1045,8 +1010,7 @@ class SessionService : Service() {
|
|||||||
return com.droiddeck.launcher.input.GesturePrefs.read(this, game).relativeMouseMode
|
return com.droiddeck.launcher.input.GesturePrefs.read(this, game).relativeMouseMode
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addClientEnvironment(guest: MutableList<String>, steamHere: Boolean,
|
private fun addClientEnvironment(guest: MutableList<String>, steamHere: Boolean, agentEnvironment: List<String>) {
|
||||||
agentEnvironment: List<String>, customEnvironment: List<String>) {
|
|
||||||
guest.add("/usr/bin/env")
|
guest.add("/usr/bin/env")
|
||||||
guest.add("-i")
|
guest.add("-i")
|
||||||
guest.add("DROIDDECK_BWRAP_SOCKET=" + com.droiddeck.launcher.runtime.BwrapSpawner.socket(this))
|
guest.add("DROIDDECK_BWRAP_SOCKET=" + com.droiddeck.launcher.runtime.BwrapSpawner.socket(this))
|
||||||
@@ -1164,7 +1128,7 @@ class SessionService : Service() {
|
|||||||
guest.add("DD_ZRAM=1")
|
guest.add("DD_ZRAM=1")
|
||||||
}
|
}
|
||||||
guest.add("AUDIO_DIRECT_DECAY=0")
|
guest.add("AUDIO_DIRECT_DECAY=0")
|
||||||
val extra = customEnvironment + agentEnvironment
|
val extra = extraEnv() + agentEnvironment
|
||||||
guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra))
|
guest.addAll(TurnipEnvironment.gameEnvironment(tuOverride, tuDriver, SessionPrefs.tuSysmem(this), extra))
|
||||||
if (extra.none { it.startsWith("MESA_NO_ERROR=") }) guest.add("${GAME_PREFIX}MESA_NO_ERROR=")
|
if (extra.none { it.startsWith("MESA_NO_ERROR=") }) guest.add("${GAME_PREFIX}MESA_NO_ERROR=")
|
||||||
extra.forEach { guest.add(it) }
|
extra.forEach { guest.add(it) }
|
||||||
@@ -1788,7 +1752,6 @@ class SessionService : Service() {
|
|||||||
SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen))
|
SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen))
|
||||||
watchGameExit(gameId, gen, exitWatchToken, pendingSteamPreviousGameId)
|
watchGameExit(gameId, gen, exitWatchToken, pendingSteamPreviousGameId)
|
||||||
Log.i(TAG, "queued Steam game $gameId for the running client")
|
Log.i(TAG, "queued Steam game $gameId for the running client")
|
||||||
com.droiddeck.launcher.runtime.GuestWorkers.expectLaunch(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun watchGameExit(
|
private fun watchGameExit(
|
||||||
@@ -2784,9 +2747,6 @@ class SessionService : Service() {
|
|||||||
const val EXTRA_PROGRAM_ARGS = "programArgs"
|
const val EXTRA_PROGRAM_ARGS = "programArgs"
|
||||||
const val EXTRA_STEAM_UI = "steamUi"
|
const val EXTRA_STEAM_UI = "steamUi"
|
||||||
const val EXTRA_STEAM_URL = "steamUrl"
|
const val EXTRA_STEAM_URL = "steamUrl"
|
||||||
// Set by the first-party Library play action on the private SessionActivity/Service path.
|
|
||||||
// Never copied from an exported intent or Agent command.
|
|
||||||
internal const val EXTRA_FRONTEND_STEAM_GAME = "com.droiddeck.launcher.FRONTEND_STEAM_GAME"
|
|
||||||
const val EXTRA_GAME_ID = "gameId"
|
const val EXTRA_GAME_ID = "gameId"
|
||||||
|
|
||||||
fun start(
|
fun start(
|
||||||
@@ -2794,7 +2754,6 @@ class SessionService : Service() {
|
|||||||
steamUi: String? = null, steamUrl: String? = null, programArgs: Array<String>? = null,
|
steamUi: String? = null, steamUrl: String? = null, programArgs: Array<String>? = null,
|
||||||
gameId: String? = null,
|
gameId: String? = null,
|
||||||
displayId: Int = Display.DEFAULT_DISPLAY,
|
displayId: Int = Display.DEFAULT_DISPLAY,
|
||||||
frontendSteamGame: Boolean = false,
|
|
||||||
) {
|
) {
|
||||||
SteamClientPrefetch.cancel()
|
SteamClientPrefetch.cancel()
|
||||||
SessionState.activityDisplayId = displayId
|
SessionState.activityDisplayId = displayId
|
||||||
@@ -2805,7 +2764,6 @@ class SessionService : Service() {
|
|||||||
if (programArgs != null) intent.putExtra(EXTRA_PROGRAM_ARGS, programArgs)
|
if (programArgs != null) intent.putExtra(EXTRA_PROGRAM_ARGS, programArgs)
|
||||||
if (steamUi != null) intent.putExtra(EXTRA_STEAM_UI, steamUi)
|
if (steamUi != null) intent.putExtra(EXTRA_STEAM_UI, steamUi)
|
||||||
if (steamUrl != null) intent.putExtra(EXTRA_STEAM_URL, steamUrl)
|
if (steamUrl != null) intent.putExtra(EXTRA_STEAM_URL, steamUrl)
|
||||||
if (frontendSteamGame) intent.putExtra(EXTRA_FRONTEND_STEAM_GAME, true)
|
|
||||||
if (gameId != null) intent.putExtra(EXTRA_GAME_ID, gameId)
|
if (gameId != null) intent.putExtra(EXTRA_GAME_ID, gameId)
|
||||||
if (Build.VERSION.SDK_INT >= 26) context.startForegroundService(intent)
|
if (Build.VERSION.SDK_INT >= 26) context.startForegroundService(intent)
|
||||||
else context.startService(intent)
|
else context.startService(intent)
|
||||||
|
|||||||
@@ -1,12 +1,6 @@
|
|||||||
package com.droiddeck.launcher.session
|
package com.droiddeck.launcher.session
|
||||||
|
|
||||||
internal object SessionVisibilityPolicy {
|
internal object SessionVisibilityPolicy {
|
||||||
fun shouldCloseSecondScreenOnStop(
|
|
||||||
screenOff: Boolean,
|
|
||||||
dockedDrawerOpen: Boolean,
|
|
||||||
attachmentPickerOpen: Boolean,
|
|
||||||
): Boolean = !screenOff && !(dockedDrawerOpen && attachmentPickerOpen)
|
|
||||||
|
|
||||||
fun isHidden(
|
fun isHidden(
|
||||||
activityStarted: Boolean,
|
activityStarted: Boolean,
|
||||||
defaultDisplayOn: Boolean,
|
defaultDisplayOn: Boolean,
|
||||||
|
|||||||
@@ -12,15 +12,15 @@ object SettingsReset {
|
|||||||
private const val TAG = "SettingsReset"
|
private const val TAG = "SettingsReset"
|
||||||
|
|
||||||
internal val SESSION_KEYS = setOf(
|
internal val SESSION_KEYS = setOf(
|
||||||
"orientation", "launcherFullscreen", "launcherFrost", "frostWallpaper", "frostCards", "frostTransparency", "frostCardTransparency", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
|
"orientation", "launcherFullscreen", "controllerHaptics", "animations", "lowStorageWarning", "theme", "runSteamAtStartup", "startupSession", "addedGamesArt",
|
||||||
"drawerWidthDp", "dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
|
"drawerWidthDp", "dualScreenMode", "dualScreenSessionMode", "dualScreenLauncher", "dualScreenSessionControls", "androidTextFieldKeyboard",
|
||||||
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
"soundtracksIngame", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
|
||||||
"storesInstallLanguage",
|
"storesInstallLanguage",
|
||||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||||
"stretch16x9", "avoidNotch", "picturePosition", "picturePosition.portrait", "picturePosition.landscape", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "producerAcquireFences", "paceCores",
|
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores",
|
||||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||||
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", "mountSharedStorage",
|
"noXalia", "fastSync", "fsyncFirst", "syncFallback", "prootNoSeccomp", "prootFastPath", "nativeUserland", "cursorComposite", "mountSharedStorage",
|
||||||
"guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark",
|
"guestHostname", "fexPreset", "forceSsbs", "logs", "gameDebugLogsEnabled", "enhancedDiagnosticsNext", "storageDiagnostics", "buildWatermark",
|
||||||
|
|||||||
@@ -10,23 +10,9 @@ import java.io.File
|
|||||||
// browser view placed outside the Big Picture window, composition capped at "notification" so gamescope keeps the game
|
// browser view placed outside the Big Picture window, composition capped at "notification" so gamescope keeps the game
|
||||||
// focused, and gamepad focus on the main UI. The hold is a lease the app renews, so Steam recovers if the app goes away.
|
// focused, and gamepad focus on the main UI. The hold is a lease the app renews, so Steam recovers if the app goes away.
|
||||||
object SteamQam {
|
object SteamQam {
|
||||||
/** [mainPath] is Steam's main menu page, shown beside the quick access menu in the split layout. */
|
data class Target(val port: Int, val path: String)
|
||||||
data class Target(val port: Int, val path: String, val mainPath: String? = null)
|
|
||||||
|
|
||||||
const val MAIN_MENU = 1
|
|
||||||
const val QUICK_ACCESS = 2
|
const val QUICK_ACCESS = 2
|
||||||
|
|
||||||
/** Height in CSS pixels both menus are laid out at in the split layout, so they show at one scale. */
|
|
||||||
const val SPLIT_CSS_HEIGHT = 480
|
|
||||||
|
|
||||||
/** Steam's own width for the main menu; quick access takes the rest of the panel. */
|
|
||||||
const val MAIN_CSS_WIDTH = 240
|
|
||||||
|
|
||||||
/** Holds the parked main menu in place and spreads its item rows (not dividers) over the full height, at most 80 px each. */
|
|
||||||
private const val MAIN_PARKED_CSS =
|
|
||||||
".BasicUI > .Panel { transform: none !important; width: 100% !important; height: 100% !important; margin: 0 !important; } " +
|
|
||||||
".BasicUI > .Panel > :has(> .Focusable) { flex: 1 1 0 !important; height: auto !important; max-height: 80px; } " +
|
|
||||||
".BasicUI > .Panel > :has(> .Focusable) > .Panel { height: 100% !important; }"
|
|
||||||
const val LEASE_MS = 5_000
|
const val LEASE_MS = 5_000
|
||||||
private const val TAG = "SteamQam"
|
private const val TAG = "SteamQam"
|
||||||
private const val EVAL_MS = 6_000L
|
private const val EVAL_MS = 6_000L
|
||||||
@@ -40,54 +26,21 @@ object SteamQam {
|
|||||||
* Takes or renews the lease for [owner], or releases it. A live lease held by a newer panel is never taken back by an
|
* Takes or renews the lease for [owner], or releases it. A live lease held by a newer panel is never taken back by an
|
||||||
* older one, so a late request from a panel being torn down cannot end its replacement's lease or change its layout.
|
* older one, so a late request from a panel being torn down cannot end its replacement's lease or change its layout.
|
||||||
*/
|
*/
|
||||||
internal fun leaseScript(on: Boolean, owner: Long, aspect: Float = 0f, split: Boolean = false): String =
|
internal fun leaseScript(on: Boolean, owner: Long, aspect: Float = 0f): String =
|
||||||
if (on) "if (!(g.__ddQamUntil > Date.now()) || !(g.__ddQamOwner > $owner)) { g.__ddQamOwner = $owner; g.__ddQamUntil = Date.now() + $LEASE_MS;" +
|
if (on) "if (!(g.__ddQamUntil > Date.now()) || !(g.__ddQamOwner > $owner)) { g.__ddQamOwner = $owner; g.__ddQamUntil = Date.now() + $LEASE_MS;" +
|
||||||
(if (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " g.__ddQamSplit = $split; }"
|
(if (aspect > 0f) " g.__ddQamAspect = $aspect;" else "") + " }"
|
||||||
else "if (g.__ddQamOwner === $owner) g.__ddQamUntil = 0;"
|
else "if (g.__ddQamOwner === $owner) g.__ddQamUntil = 0;"
|
||||||
|
|
||||||
/**
|
/** [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. */
|
||||||
* [aspect] is the panel's width over height: the menu is laid out at that shape so every tab shows at one scale. With
|
internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0): String = """(() => {
|
||||||
* [split], Steam's main menu is kept rendered at its own width beside the quick access menu, which gets the rest.
|
const g = globalThis, QAM = 2;
|
||||||
*/
|
|
||||||
internal fun script(on: Boolean, aspect: Float = 0f, owner: Long = 0, split: Boolean = false): String = """(() => {
|
|
||||||
const g = globalThis, QAM = 2, MAIN = 1;
|
|
||||||
const W = SteamUIStore.WindowStore.SteamUIWindows[0];
|
const W = SteamUIStore.WindowStore.SteamUIWindows[0];
|
||||||
const m = W.MenuStore, c = W.m_CompositionStateStore;
|
const m = W.MenuStore, c = W.m_CompositionStateStore;
|
||||||
const nav = W.m_FocusNavContext;
|
const nav = W.m_FocusNavContext;
|
||||||
const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0");
|
const popup = g_PopupManager.GetExistingPopup("SP BPM_uid0");
|
||||||
const held = () => g.__ddQamUntil > Date.now();
|
const held = () => g.__ddQamUntil > Date.now();
|
||||||
const split = () => held() && g.__ddQamSplit === true;
|
const ours = () => held() && m.m_eOpenSideMenu === QAM && !g.__ddQamTop;
|
||||||
// Steam's views carry no names: the main menu's is the one Steam focuses while the main menu is open. Until Steam
|
|
||||||
// has shown it, the main menu is opened once with its view parked like the quick access menu's.
|
|
||||||
const probing = () => g.__ddMainProbe > Date.now();
|
|
||||||
const ours = () => held() && !g.__ddQamTop && (m.m_eOpenSideMenu === QAM || (probing() && m.m_eOpenSideMenu === MAIN));
|
|
||||||
const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0;
|
const width = (h) => g.__ddQamAspect > 0 ? Math.round(h * g.__ddQamAspect) : 0;
|
||||||
const parkX = () => popup.m_popup.innerWidth + 64;
|
|
||||||
const mainSize = () => [$MAIN_CSS_WIDTH, $SPLIT_CSS_HEIGHT];
|
|
||||||
const qamSplitSize = () => [Math.max(Math.round($SPLIT_CSS_HEIGHT * (g.__ddQamAspect > 0 ? g.__ddQamAspect : 1)) - $MAIN_CSS_WIDTH, 320), $SPLIT_CSS_HEIGHT];
|
|
||||||
const size = (w, h) => split() ? qamSplitSize() : [width(h) || w, h];
|
|
||||||
const mainView = () => views().find(v => v.__ddMain);
|
|
||||||
// Only the quick access view is parked: the one Steam focuses while quick access is open. Before Steam has
|
|
||||||
// focused it, any view but the main menu's and the header's web page (Store and other pages) may be it.
|
|
||||||
const headerView = () => W.m_HeaderStore?.m_currentBrowserAndBackstack?.m_browserView;
|
|
||||||
const isQam = (v) => !v.__ddMain && v !== headerView() &&
|
|
||||||
(!!v.__ddQamView || !views().some(o => o.__ddQamView) || (probing() && m.m_eOpenSideMenu === MAIN));
|
|
||||||
const mainParked = () => split() && (m.m_eOpenSideMenu !== MAIN || probing());
|
|
||||||
const mainDoc = () => {
|
|
||||||
for (const s of SteamUIStore.m_GamepadNavigationManager?.m_rgGamepadInputSources || []) {
|
|
||||||
try { const d = s.m_targetWindow?.document; if (d?.title?.startsWith("MainMenu")) return d; } catch (e) {}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
// Steam slides the main menu out whenever it is not the open side menu; parked, it stays in place and fills its view.
|
|
||||||
const mainStyle = (on) => {
|
|
||||||
const d = mainDoc();
|
|
||||||
let s = d?.getElementById("dd-main-split");
|
|
||||||
if (!on) { s?.remove(); return; }
|
|
||||||
if (!d?.head) return;
|
|
||||||
if (!s) { s = d.createElement("style"); s.id = "dd-main-split"; d.head.appendChild(s); }
|
|
||||||
if (s.textContent !== "$MAIN_PARKED_CSS") s.textContent = "$MAIN_PARKED_CSS";
|
|
||||||
};
|
|
||||||
if (!c.__ddQam) {
|
if (!c.__ddQam) {
|
||||||
c.__ddQam = c.ComputeOverallMinimumRequestedComposition;
|
c.__ddQam = c.ComputeOverallMinimumRequestedComposition;
|
||||||
m.__ddQam = m.OnMenuDeactivated;
|
m.__ddQam = m.OnMenuDeactivated;
|
||||||
@@ -106,18 +59,6 @@ object SteamQam {
|
|||||||
return without >= 2 ? v : 1;
|
return without >= 2 ? v : 1;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Steam frosts its Store page while a side menu is open; a parked menu is not over it.
|
|
||||||
const inst = m.m_Instance;
|
|
||||||
if (inst?.SetStoreBrowserGlass && !inst.__ddQamGlass) {
|
|
||||||
inst.__ddQamGlass = inst.SetStoreBrowserGlass;
|
|
||||||
inst.SetStoreBrowserGlass = function (e) { return inst.__ddQamGlass.call(this, ours() ? 0 : e); };
|
|
||||||
}
|
|
||||||
const glass = () => {
|
|
||||||
const on = !ours() && m.m_eOpenSideMenu !== 0;
|
|
||||||
if (g.__ddQamGlassOn === on) return;
|
|
||||||
g.__ddQamGlassOn = on;
|
|
||||||
inst?.SetStoreBrowserGlass?.(m.m_eOpenSideMenu);
|
|
||||||
};
|
|
||||||
const views = () => popup?.m_rgChildBrowserViews || [];
|
const views = () => popup?.m_rgChildBrowserViews || [];
|
||||||
const backdrop = (hide) => {
|
const backdrop = (hide) => {
|
||||||
const doc = popup?.m_popup?.document;
|
const doc = popup?.m_popup?.document;
|
||||||
@@ -134,61 +75,16 @@ object SteamQam {
|
|||||||
};
|
};
|
||||||
const keep = () => {
|
const keep = () => {
|
||||||
for (const v of views()) {
|
for (const v of views()) {
|
||||||
if (!v.__ddQam) v.__ddQam = v.SetBounds;
|
if (v.__ddQam) continue;
|
||||||
if (v.__ddQamW === 4) continue;
|
v.__ddQam = v.SetBounds;
|
||||||
v.__ddQamW = 4;
|
|
||||||
v.__ddQamVis = v.__ddQamVis || v.SetVisible;
|
|
||||||
v.__ddQamFocus = v.__ddQamFocus || v.SetFocus;
|
|
||||||
v.SetBounds = function (x, y, w, h, ...r) {
|
v.SetBounds = function (x, y, w, h, ...r) {
|
||||||
if (v.__ddMain && mainParked()) {
|
|
||||||
if (w > 0) v.__ddMainAsked = [x, y, w, h];
|
|
||||||
[w, h] = mainSize();
|
|
||||||
v.__ddMainOn = true; v.__ddMainW = w; v.__ddMainH = h;
|
|
||||||
return v.__ddQam.call(this, parkX(), 0, w, h, ...r);
|
|
||||||
}
|
|
||||||
if (v.__ddMain && w > 0) mainStyle(false);
|
|
||||||
v.__ddAsked = [x, y, w, h];
|
v.__ddAsked = [x, y, w, h];
|
||||||
if (w > 0 && ours() && isQam(v)) { x = parkX(); [w, h] = size(w, h); }
|
if (w > 0 && ours()) { x = popup.m_popup.innerWidth + 64; w = width(h) || w; }
|
||||||
v.__ddAt = x;
|
v.__ddAt = x;
|
||||||
v.__ddW = w;
|
v.__ddW = w;
|
||||||
v.__ddH = h;
|
|
||||||
return v.__ddQam.call(this, x, y, w, h, ...r);
|
return v.__ddQam.call(this, x, y, w, h, ...r);
|
||||||
};
|
};
|
||||||
v.SetVisible = function (on, ...r) {
|
|
||||||
return v.__ddQamVis.call(this, on || (!!v.__ddMain && mainParked()), ...r);
|
|
||||||
};
|
|
||||||
v.SetFocus = function (on, ...r) {
|
|
||||||
if (on && m.m_eOpenSideMenu === MAIN && v !== headerView()) {
|
|
||||||
for (const o of views()) if (o !== v) delete o.__ddMain;
|
|
||||||
v.__ddMain = true;
|
|
||||||
delete v.__ddQamView;
|
|
||||||
}
|
|
||||||
if (on && m.m_eOpenSideMenu === QAM && !v.__ddMain && v !== headerView()) {
|
|
||||||
for (const o of views()) if (o !== v) delete o.__ddQamView;
|
|
||||||
v.__ddQamView = true;
|
|
||||||
}
|
|
||||||
return v.__ddQamFocus.call(this, on, ...r);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
if (g.__ddMainProbe && !probing()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; }
|
|
||||||
if (probing() && mainView()) { g.__ddMainProbe = 0; g.__ddMainProbed = true; }
|
|
||||||
const mv = mainView();
|
|
||||||
if (mv && !probing()) {
|
|
||||||
if (mainParked()) {
|
|
||||||
const [w, h] = mainSize();
|
|
||||||
if (!mv.__ddMainOn || mv.__ddMainW !== w || mv.__ddMainH !== h) {
|
|
||||||
mv.__ddQam.call(mv, parkX(), 0, w, h);
|
|
||||||
mv.__ddQamVis.call(mv, true);
|
|
||||||
mv.__ddMainOn = true; mv.__ddMainW = w; mv.__ddMainH = h;
|
|
||||||
}
|
|
||||||
} else if (mv.__ddMainOn) {
|
|
||||||
mv.__ddMainOn = false;
|
|
||||||
if (m.m_eOpenSideMenu !== MAIN) { mv.__ddQamVis.call(mv, false); mv.__ddQam.call(mv, 0, 0, 0, 0); }
|
|
||||||
else if (mv.__ddMainAsked) mv.__ddQam.call(mv, ...mv.__ddMainAsked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mainStyle(!!mv && mainParked() && !probing());
|
|
||||||
glass();
|
|
||||||
if (!held()) {
|
if (!held()) {
|
||||||
const parked = !g.__ddQamTop;
|
const parked = !g.__ddQamTop;
|
||||||
g.__ddQamTop = false;
|
g.__ddQamTop = false;
|
||||||
@@ -228,25 +124,6 @@ object SteamQam {
|
|||||||
}
|
}
|
||||||
g.__ddQamTop = false;
|
g.__ddQamTop = false;
|
||||||
}
|
}
|
||||||
// Each Split activation gets a fresh probe budget, and a spent one refills after a backoff, so a Steam that was
|
|
||||||
// still loading does not leave the main menu undiscovered for good.
|
|
||||||
if (split() !== !!g.__ddQamSplitOn) { g.__ddQamSplitOn = split(); if (split()) g.__ddMainProbes = 0; }
|
|
||||||
if (split() && !mv) {
|
|
||||||
if (probing()) return;
|
|
||||||
if ((g.__ddMainProbes || 0) >= 3 && Date.now() - (g.__ddMainProbeLast || 0) > 30000) g.__ddMainProbes = 0;
|
|
||||||
if ((g.__ddMainProbes || 0) < 3 && m.m_eOpenSideMenu !== MAIN) {
|
|
||||||
g.__ddMainProbes = (g.__ddMainProbes || 0) + 1;
|
|
||||||
g.__ddMainProbeLast = Date.now();
|
|
||||||
g.__ddMainProbe = Date.now() + 1500;
|
|
||||||
m.OpenMainMenu();
|
|
||||||
c.EnsureCorrectComposition?.();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (g.__ddMainProbed) {
|
|
||||||
g.__ddMainProbed = false;
|
|
||||||
if (m.m_eOpenSideMenu === MAIN) m.OpenQuickAccessMenu(g.__ddQamTab ?? undefined);
|
|
||||||
}
|
|
||||||
const decky = !!g.DeckyPluginLoader?.tabsHook?.qamBrowserViewPatch;
|
const decky = !!g.DeckyPluginLoader?.tabsHook?.qamBrowserViewPatch;
|
||||||
// Decky hooks the menu after Steam starts; the menu has to unmount for its tab to appear, so reopen on the next tick.
|
// Decky hooks the menu after Steam starts; the menu has to unmount for its tab to appear, so reopen on the next tick.
|
||||||
if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; }
|
if (m.m_eOpenSideMenu === QAM && decky && !g.__ddQamDecky) { g.__ddQamDecky = true; m.CloseSideMenus(); return; }
|
||||||
@@ -259,26 +136,18 @@ object SteamQam {
|
|||||||
if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab;
|
if (m.m_eQuickAccessTab != null) g.__ddQamTab = m.m_eQuickAccessTab;
|
||||||
if (!g.__ddQamOn) { g.__ddQamOn = true; c.EnsureCorrectComposition?.(); }
|
if (!g.__ddQamOn) { g.__ddQamOn = true; c.EnsureCorrectComposition?.(); }
|
||||||
for (const v of views()) {
|
for (const v of views()) {
|
||||||
if (v.__ddMain) continue;
|
|
||||||
if (!isQam(v)) {
|
|
||||||
// A view parked before the quick access view was known goes back where Steam asked for it.
|
|
||||||
const a = v.__ddAsked;
|
|
||||||
if (a?.[2] > 0 && v.__ddAt >= popup.m_popup.innerWidth) { v.__ddQam.call(v, ...a); v.__ddAt = a[0]; v.__ddW = a[2]; v.__ddH = a[3]; }
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!v.__ddAsked) {
|
if (!v.__ddAsked) {
|
||||||
const b = v.GetBounds?.();
|
const b = v.GetBounds?.();
|
||||||
if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; v.__ddH = b.height; }
|
if (b && b.width > 0) { v.__ddAsked = [b.x, b.y, b.width, b.height]; v.__ddAt = b.x; v.__ddW = b.width; }
|
||||||
}
|
}
|
||||||
const a = v.__ddAsked;
|
const a = v.__ddAsked;
|
||||||
const [w, h] = a?.[2] > 0 ? size(a[2], a[3]) : [0, 0];
|
if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || (width(a[3]) && v.__ddW !== width(a[3])))) v.SetBounds(...a);
|
||||||
if (a?.[2] > 0 && (v.__ddAt < popup.m_popup.innerWidth || v.__ddW !== w || v.__ddH !== h)) v.SetBounds(...a);
|
|
||||||
}
|
}
|
||||||
const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root");
|
const main = nav?.m_rgGamepadNavigationTrees?.find(t => t.m_ID === "GamepadUI_Full_Root");
|
||||||
if (main && /^(QuickAccess|MainMenu)/.test(nav.m_LastActiveNavTree?.m_ID ?? "")) nav.SetActiveNavTree(main);
|
if (main && nav.m_LastActiveNavTree?.m_ID?.startsWith("QuickAccess")) nav.SetActiveNavTree(main);
|
||||||
backdrop(true);
|
backdrop(true);
|
||||||
};
|
};
|
||||||
${leaseScript(on, owner, aspect, split)}
|
${leaseScript(on, owner, aspect)}
|
||||||
keep();
|
keep();
|
||||||
if (held() && !g.__ddQamTimer) {
|
if (held() && !g.__ddQamTimer) {
|
||||||
g.__ddQamTimer = setInterval(() => {
|
g.__ddQamTimer = setInterval(() => {
|
||||||
@@ -292,8 +161,7 @@ object SteamQam {
|
|||||||
/** [open] is Steam's open side menu; [top] is true while the menu is shown on the top screen. */
|
/** [open] is Steam's open side menu; [top] is true while the menu is shown on the top screen. */
|
||||||
data class Hold(val open: Int, val top: Boolean)
|
data class Hold(val open: Int, val top: Boolean)
|
||||||
|
|
||||||
fun hold(context: Context, aspect: Float, owner: Long, split: Boolean = false): Hold? =
|
fun hold(context: Context, aspect: Float, owner: Long): Hold? = eval(context, script(true, aspect, owner))?.let(::parseHold)
|
||||||
eval(context, script(true, aspect, owner, split))?.let(::parseHold)
|
|
||||||
|
|
||||||
internal fun parseHold(text: String): Hold? = runCatching {
|
internal fun parseHold(text: String): Hold? = runCatching {
|
||||||
val a = JSONArray(text)
|
val a = JSONArray(text)
|
||||||
@@ -313,9 +181,7 @@ object SteamQam {
|
|||||||
fun target(context: Context): Target? = runCatching {
|
fun target(context: Context): Target? = runCatching {
|
||||||
val devtools = File(AgentGuest.dir(context), "cdp-port").readText().trim().toInt()
|
val devtools = File(AgentGuest.dir(context), "cdp-port").readText().trim().toInt()
|
||||||
val (relay, secret) = parseRelay(helper(context, "start", devtools.toString())) ?: return null
|
val (relay, secret) = parseRelay(helper(context, "start", devtools.toString())) ?: return null
|
||||||
val found = runCatching {
|
val found = runCatching { parseTarget(relay, get(relay, "/$secret/json"))?.let { it.copy(path = "/$secret${it.path}") } }
|
||||||
parseTarget(relay, get(relay, "/$secret/json"))?.let { t -> t.copy(path = "/$secret${t.path}", mainPath = t.mainPath?.let { "/$secret$it" }) }
|
|
||||||
}
|
|
||||||
if (found.getOrNull() == null) helper(context, "stop", relay.toString())
|
if (found.getOrNull() == null) helper(context, "stop", relay.toString())
|
||||||
found.getOrThrow()
|
found.getOrThrow()
|
||||||
}.onFailure { android.util.Log.e(TAG, "no quick access target: $it") }.getOrNull()
|
}.onFailure { android.util.Log.e(TAG, "no quick access target: $it") }.getOrNull()
|
||||||
@@ -366,16 +232,14 @@ object SteamQam {
|
|||||||
|
|
||||||
internal fun parseTarget(port: Int, json: String): Target? {
|
internal fun parseTarget(port: Int, json: String): Target? {
|
||||||
val list = JSONArray(json)
|
val list = JSONArray(json)
|
||||||
fun page(prefix: String): String? {
|
for (i in 0 until list.length()) {
|
||||||
for (i in 0 until list.length()) {
|
val t = list.optJSONObject(i) ?: continue
|
||||||
val t = list.optJSONObject(i) ?: continue
|
if (!t.optString("title").startsWith("QuickAccess")) continue
|
||||||
if (!t.optString("title").startsWith(prefix)) continue
|
val ws = t.optString("webSocketDebuggerUrl")
|
||||||
val ws = t.optString("webSocketDebuggerUrl")
|
val path = Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1) ?: continue
|
||||||
Regex("^ws://[^/]+(/devtools/page/[A-Za-z0-9-]+)$").find(ws)?.groupValues?.get(1)?.let { return it }
|
return Target(port, path)
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return page("QuickAccess")?.let { Target(port, it, page("MainMenu")) }
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun eval(context: Context, expression: String): String? = runCatching {
|
private fun eval(context: Context, expression: String): String? = runCatching {
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
package com.droiddeck.launcher.session
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.util.Log
|
|
||||||
import com.droiddeck.launcher.gpu.GpuInfo
|
|
||||||
import com.droiddeck.launcher.stores.Store
|
|
||||||
import com.droiddeck.launcher.stores.StoreGameSidecar
|
|
||||||
import com.droiddeck.launcher.stores.StoreInstallRoot
|
|
||||||
import com.droiddeck.launcher.stores.xbox.XboxManifest
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Microsoft's original Xbox releases for PC run its emulator, which needs FEX and VKD3D-Proton builds with fixes of
|
|
||||||
* their own (each off unless droiddeck-game-env turns it on for these games) and a newer DXVK than some Protons carry.
|
|
||||||
* Each installed one gets them as its game components. A component the player chose for the game is never replaced;
|
|
||||||
* one set here follows this list, so a newer build replaces it, and one the player cleared stays cleared.
|
|
||||||
*/
|
|
||||||
internal object XboxBackCompatComponents {
|
|
||||||
private const val TAG = "XboxBackCompat"
|
|
||||||
private const val PREFS = "xbox-backcompat-components"
|
|
||||||
|
|
||||||
internal data class Wanted(val comp: String, val file: String, val release: String)
|
|
||||||
|
|
||||||
internal fun wanted(family: GpuInfo.Family?): List<Wanted> = listOf(
|
|
||||||
Wanted("fex", "FEXCore-2611.1-xbox-bionic.wcp", ComponentsManager.DD_XBOX),
|
|
||||||
Wanted("vkd3d", "vkd3d-proton-arm64ec-3.1-xbox-linux.wcp", "Vkd3d-proton-Linux"),
|
|
||||||
Wanted("dxvk", if (family == GpuInfo.Family.A6XX) "dxvk-gplasync-3.2-a6xx-1-linux.wcp" else "dxvk-gplasync-3.2-1-linux.wcp",
|
|
||||||
"Dxvk-gplasync-Linux"),
|
|
||||||
)
|
|
||||||
|
|
||||||
/** The file to set for one component of a game, or null to leave it as it is. */
|
|
||||||
internal fun decide(current: String?, assigned: String?, wanted: String): String? = when {
|
|
||||||
current == null && assigned == null -> wanted
|
|
||||||
current != null && current == assigned && current != wanted -> wanted
|
|
||||||
else -> null
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class Game(val scope: String, val title: String)
|
|
||||||
|
|
||||||
internal fun installed(context: Context): List<Game> = StoreInstallRoot.gameFolders(context).mapNotNull { folder ->
|
|
||||||
val sidecar = StoreGameSidecar.read(folder)?.takeIf { it.store == Store.XBOX && it.isInstalled } ?: return@mapNotNull null
|
|
||||||
if (!XboxManifest.backCompat(folder)) return@mapNotNull null
|
|
||||||
val appId = SessionPrefs.storedAddedGameAppId(context, folder.path) ?: return@mapNotNull null
|
|
||||||
Game(appId.toString(), sidecar.title)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ensure(context: Context): String? {
|
|
||||||
val games = installed(context)
|
|
||||||
if (games.isEmpty()) return null
|
|
||||||
val marks = context.getSharedPreferences(PREFS, Context.MODE_PRIVATE)
|
|
||||||
val wanted = wanted(runCatching { GpuInfo.detect().family }.getOrNull())
|
|
||||||
val lines = mutableListOf<String>()
|
|
||||||
for (game in games) {
|
|
||||||
val current = ComponentsManager.gameComponents(context, game.scope)
|
|
||||||
for (w in wanted) {
|
|
||||||
val key = "${game.scope}/${w.comp}"
|
|
||||||
val file = decide(current[w.comp], marks.getString(key, null), w.file) ?: continue
|
|
||||||
val label = ComponentsManager.LABEL[w.comp]
|
|
||||||
runCatching {
|
|
||||||
ComponentsManager.assignGameComponent(context, game.scope, w.comp, file, w.release, expected = current[w.comp]) {
|
|
||||||
marks.edit().putString(key, file).apply()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onSuccess { result ->
|
|
||||||
lines += when (result) {
|
|
||||||
ComponentsManager.Assigned.SET -> "${game.title}: $label ${file.removeSuffix(".wcp")}"
|
|
||||||
ComponentsManager.Assigned.NOT_LISTED -> "${game.title}: $file is not listed; $label unchanged"
|
|
||||||
ComponentsManager.Assigned.CHANGED -> "${game.title}: $label was chosen during the download; kept"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.onFailure { e ->
|
|
||||||
Log.w(TAG, "${game.title}: $file", e)
|
|
||||||
lines += "${game.title}: $label unchanged (${e.message ?: e.javaClass.simpleName})"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return lines.joinToString("; ").ifEmpty { null }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.droiddeck.launcher.session.xr
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The menu gesture: both controllers held together. It arms when the two aim points come within
|
|
||||||
* [ARM_METRES], cancels once they part beyond [CANCEL_METRES], and fires after [HOLD_MS] held.
|
|
||||||
* It needs both controllers apart again before it can arm a second time.
|
|
||||||
*/
|
|
||||||
internal class XrGesture {
|
|
||||||
enum class Phase { IDLE, ARMING, FIRED }
|
|
||||||
|
|
||||||
var phase = Phase.IDLE
|
|
||||||
private set
|
|
||||||
var progress = 0f
|
|
||||||
private set
|
|
||||||
var midpoint = Vec3.ZERO
|
|
||||||
private set
|
|
||||||
private var startedMs = 0L
|
|
||||||
private var needsRelease = false
|
|
||||||
|
|
||||||
/** Returns true on the frame the gesture completes. */
|
|
||||||
fun update(left: XrHand, right: XrHand, nowMs: Long): Boolean {
|
|
||||||
if (!left.active || !right.active) {
|
|
||||||
reset(release = false)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
val a = left.aim.position
|
|
||||||
val b = right.aim.position
|
|
||||||
val distance = (a - b).length
|
|
||||||
midpoint = Vec3.lerp(a, b, 0.5f)
|
|
||||||
if (needsRelease) {
|
|
||||||
if (distance > CANCEL_METRES) needsRelease = false
|
|
||||||
phase = Phase.IDLE
|
|
||||||
progress = 0f
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
when (phase) {
|
|
||||||
Phase.IDLE, Phase.FIRED -> if (distance < ARM_METRES) {
|
|
||||||
phase = Phase.ARMING
|
|
||||||
startedMs = nowMs
|
|
||||||
progress = 0f
|
|
||||||
}
|
|
||||||
Phase.ARMING -> if (distance > CANCEL_METRES) {
|
|
||||||
phase = Phase.IDLE
|
|
||||||
progress = 0f
|
|
||||||
} else {
|
|
||||||
progress = ((nowMs - startedMs).toFloat() / HOLD_MS).coerceIn(0f, 1f)
|
|
||||||
if (progress >= 1f) {
|
|
||||||
phase = Phase.FIRED
|
|
||||||
needsRelease = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
fun reset(release: Boolean) {
|
|
||||||
phase = Phase.IDLE
|
|
||||||
progress = 0f
|
|
||||||
if (release) needsRelease = true
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
const val ARM_METRES = 0.09f
|
|
||||||
const val CANCEL_METRES = 0.14f
|
|
||||||
const val HOLD_MS = 1500L
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loaded 100 of 450 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user